Thread (2 messages) flat view 2 messages, 2 authors, 2011-05-26

Re: [PATCH] af-packet: Use existing netdev reference for bound sockets.

From: David Miller <davem@davemloft.net>
Date: 2011-05-26 18:22:45

From: greearb@candelatech.com
Date: Wed, 25 May 2011 16:15:32 -0700
quoted hunk ↗ jump to hunk
@@ -1161,6 +1168,7 @@ static int packet_snd(struct socket *sock,
 
 	if (saddr == NULL) {
 		ifindex	= po->ifindex;
+		dev = po->prot_hook.dev;
 		proto	= po->num;
 		addr	= NULL;
 	} else {
@@ -1174,8 +1182,11 @@ static int packet_snd(struct socket *sock,
 		addr	= saddr->sll_addr;
 	}
 
+	if (!dev) {
+		dev = dev_get_by_index(sock_net(sk), ifindex);
+		need_rls_dev = true;
+	}
 
Why don't you move this second hunk into the "saddr != NULL" code
block?

That way all you can:

1) Call dev_get_by_index() unconditionally from that spot.

2) Only have the dev==NULL check right afterwards inside of the
   unbound case as well.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help