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.