Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

netfilter: use in_dev_for_each_ifa_rcu

Netfilter hooks are always running under rcu read lock, use
the new iterator macro so sparse won't complain once we add
proper __rcu annotations.

Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Florian Westphal and committed by
David S. Miller
b8d19572 d519e870

+16 -7
+7 -2
net/ipv4/netfilter/nf_tproxy_ipv4.c
··· 53 53 54 54 __be32 nf_tproxy_laddr4(struct sk_buff *skb, __be32 user_laddr, __be32 daddr) 55 55 { 56 + const struct in_ifaddr *ifa; 56 57 struct in_device *indev; 57 58 __be32 laddr; 58 59 ··· 62 61 63 62 laddr = 0; 64 63 indev = __in_dev_get_rcu(skb->dev); 65 - for_primary_ifa(indev) { 64 + 65 + in_dev_for_each_ifa_rcu(ifa, indev) { 66 + if (ifa->ifa_flags & IFA_F_SECONDARY) 67 + continue; 68 + 66 69 laddr = ifa->ifa_local; 67 70 break; 68 - } endfor_ifa(indev); 71 + } 69 72 70 73 return laddr ? laddr : daddr; 71 74 }
+7 -2
net/netfilter/nf_conntrack_broadcast.c
··· 41 41 42 42 in_dev = __in_dev_get_rcu(rt->dst.dev); 43 43 if (in_dev != NULL) { 44 - for_primary_ifa(in_dev) { 44 + const struct in_ifaddr *ifa; 45 + 46 + in_dev_for_each_ifa_rcu(ifa, in_dev) { 47 + if (ifa->ifa_flags & IFA_F_SECONDARY) 48 + continue; 49 + 45 50 if (ifa->ifa_broadcast == iph->daddr) { 46 51 mask = ifa->ifa_mask; 47 52 break; 48 53 } 49 - } endfor_ifa(in_dev); 54 + } 50 55 } 51 56 52 57 if (mask == 0)