diff mbox

[ovs-dev,v2] netdev-linux: Refactoring the netdev_linux_send in forwarding batch packets

Message ID 20170531155130.GR2820@ovn.org
State Not Applicable
Headers show

Commit Message

Ben Pfaff May 31, 2017, 3:51 p.m. UTC
On Wed, May 31, 2017 at 01:45:08AM +0000, Zhenyu Gao wrote:
> We don't need to initialize sock,msg and sll before calling
> sendmsg each time.
> Just initialize them before the loop, it can reduce cpu cycles.
> 
> Signed-off-by: Zhenyu Gao <sysugaozhenyu@gmail.com>

Thanks.  I folded in the following additional style improvements and
applied this to master.

By the way, "blp@nicira.com" is an obsolete email address.  Please use
blp@ovn.org.

--8<--------------------------cut here-------------------------->8--
diff mbox

Patch

diff --git a/lib/netdev-linux.c b/lib/netdev-linux.c
index e5ad6ae32289..8ae740a17e4c 100644
--- a/lib/netdev-linux.c
+++ b/lib/netdev-linux.c
@@ -1192,13 +1192,11 @@  netdev_linux_send(struct netdev *netdev_, int qid OVS_UNUSED,
                   struct dp_packet_batch *batch, bool may_steal,
                   bool concurrent_txq OVS_UNUSED)
 {
-    int i;
     int error = 0;
-    int ifindex;
     int sock = 0;
+
     struct sockaddr_ll sll;
     struct msghdr msg;
-
     if (!is_tap_netdev(netdev_)) {
         sock = af_packet_sock();
         if (sock < 0) {
@@ -1206,7 +1204,7 @@  netdev_linux_send(struct netdev *netdev_, int qid OVS_UNUSED,
             goto free_batch;
         }
 
-        ifindex = netdev_get_ifindex(netdev_);
+        int ifindex = netdev_get_ifindex(netdev_);
         if (ifindex < 0) {
             error = -ifindex;
             goto free_batch;
@@ -1227,7 +1225,7 @@  netdev_linux_send(struct netdev *netdev_, int qid OVS_UNUSED,
     }
 
     /* 'i' is incremented only if there's no error */
-    for (i = 0; i < batch->count;) {
+    for (int i = 0; i < batch->count; ) {
         const void *data = dp_packet_data(batch->packets[i]);
         size_t size = dp_packet_size(batch->packets[i]);
         ssize_t retval;