net: add rcu annotations for ifa_list
Subsystems (18)
Florian Westphal
maintainerv2 cover net: add rcu annotations for ifa_list
v2:
- remove ifa_list iteration in afs instead of conversion All other patches are unchanged.
Eric Dumazet reported following problem:
It looks that unless RTNL is held, accessing ifa_list needs proper RCU protection. indev->ifa_list can be changed under us by another cpu (which owns RTNL) [..]
A proper rcu_dereference() with an happy sparse support would require adding __rcu attribute.
This patch series does that: add __rcu to the ifa_list pointers. That makes sparse complain, so the series also adds the required rcu_assign_pointer/dereference helpers where needed.
All patches except the last one are preparation work. Two new macros are introduced for in_ifaddr walks.
Last patch adds the __rcu annotations and the assign_pointer/dereference helper calls.
This patch is a bit large, but I found no better way -- other approaches (annotate-first or add helpers-first) all result in mid-series sparse warnings.
This series is submitted vs. net-next rather than net for several reasons:
1. Its (mostly) compile-tested only
2. 3rd patch changes behaviour wrt. secondary addresses (see changelog)
3. The problem exists for a very long time (2004), so it doesn't seem to be urgent to fix this -- rcu use to free ifa_list predates the git era.
Florian Westphal (7):
afs: do not send list of client addresses
net: inetdevice: provide replacement iterators for in_ifaddr walk
devinet: use in_dev_for_each_ifa_rcu in more places
netfilter: use in_dev_for_each_ifa_rcu
net: use new in_dev_ifa iterators
drivers: use in_dev_for_each_ifa_rtnl/rcu
net: ipv4: provide __rcu annotation for ifa_list
drivers/infiniband/core/roce_gid_mgmt.c | 5 drivers/infiniband/hw/cxgb4/cm.c | 9 - drivers/infiniband/hw/i40iw/i40iw_cm.c | 7 drivers/infiniband/hw/i40iw/i40iw_main.c | 6 drivers/infiniband/hw/i40iw/i40iw_utils.c | 12 - drivers/infiniband/hw/nes/nes.c | 8 drivers/infiniband/hw/usnic/usnic_ib_main.c | 15 + drivers/isdn/hysdn/hysdn_net.c | 6 drivers/isdn/i4l/isdn_net.c | 20 +- drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c | 8 drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c | 5 drivers/net/ethernet/via/via-velocity.h | 2 drivers/net/plip/plip.c | 4 drivers/net/vmxnet3/vmxnet3_drv.c | 19 +- drivers/net/wan/hdlc_cisco.c | 11 - drivers/net/wireless/ath/ath6kl/cfg80211.c | 4 drivers/net/wireless/marvell/mwifiex/cfg80211.c | 2 fs/afs/Makefile | 1 fs/afs/cmservice.c | 24 -- fs/afs/internal.h | 15 - fs/afs/netdevices.c | 48 ----- include/linux/inetdevice.h | 19 +- net/core/netpoll.c | 10 - net/core/pktgen.c | 8 net/ipv4/devinet.c | 146 ++++++++++------- net/ipv4/fib_frontend.c | 24 +- net/ipv4/igmp.c | 5 net/ipv4/netfilter/nf_tproxy_ipv4.c | 9 - net/ipv6/addrconf.c | 4 net/mac80211/main.c | 4 net/netfilter/nf_conntrack_broadcast.c | 9 - net/netfilter/nf_nat_redirect.c | 12 - net/netfilter/nfnetlink_osf.c | 5 net/sctp/protocol.c | 2 net/smc/smc_clc.c | 11 - 35 files changed, 266 insertions(+), 233 deletions(-)
Florian Westphal
maintainerPATCH v2 1/7 afs: do not send list of client addresses
David Howell says:
I'm told that there's not really any point populating the list. Current OpenAFS ignores it, as does AuriStor - and IBM AFS 3.6 will do the right thing.
The list is actually useless as it's the client's view of the world, not the servers, so if there's any NAT in the way its contents are invalid. Further, it doesn't support IPv6 addresses.
On that basis, feel free to make it an empty list and remove all the interface enumeration.
V1 of this patch reworked the function to use a new helper for the ifa_list iteration to avoid sparse warnings once the proper __rcu annotations get added in struct in_device later.
But, in light of the above, just remove afs_get_ipv4_interfaces.
Compile tested only.
--- fs/afs/Makefile | 1 - fs/afs/cmservice.c | 24 +---------------------- fs/afs/internal.h | 15 -------------- fs/afs/netdevices.c | 48 --------------------------------------------- 4 files changed, 1 insertion(+), 87 deletions(-) delete mode 100644 fs/afs/netdevices.c
fs/afs/Makefile +0 -1
@@ -29,7 +29,6 @@ kafs-y := \ server.o \ server_list.o \ super.o \ - netdevices.o \ vlclient.o \ vl_list.o \ vl_probe.o \
fs/afs/cmservice.c +1 -23
@@ -584,9 +584,8 @@ static int afs_deliver_cb_probe_uuid(struct afs_call *call)*/ static void SRXAFSCB_TellMeAboutYourself (struct work_struct *work) { -struct afs_interface *ifs; struct afs_call *call = container_of(work, struct afs_call, work); -int loop, nifs; +int loop; struct { struct /* InterfaceAddr */ {
@@ -604,19 +603,7 @@ static void SRXAFSCB_TellMeAboutYourself(struct work_struct *work)_enter ("" ); - nifs =0 ; - ifs =kcalloc (32 ,sizeof (*ifs),GFP_KERNEL ); -if (ifs) { - nifs =afs_get_ipv4_interfaces (call->net, ifs,32 , false); -if (nifs <0 ) { -kfree (ifs); - ifs =NULL ; - nifs =0 ; - } - } -memset (&reply,0 ,sizeof (reply)); - reply.ia.nifs =htonl (nifs); reply.ia.uuid[0 ] = call->net->uuid.time_low; reply.ia.uuid[1 ] =htonl (ntohs (call->net->uuid.time_mid));
@@ -626,15 +613,6 @@ static void SRXAFSCB_TellMeAboutYourself(struct work_struct *work)for (loop =0 ; loop <6 ; loop++) reply.ia.uuid[loop +5 ] =htonl ((s8 ) call->net->uuid.node[loop]); -if (ifs) { -for (loop =0 ; loop < nifs; loop++) { - reply.ia.ifaddr[loop] = ifs[loop].address.s_addr; - reply.ia.netmask[loop] = ifs[loop].netmask.s_addr; - reply.ia.mtu[loop] =htonl (ifs[loop].mtu); - } -kfree (ifs); - } - reply.cap.capcount =htonl (1 ); reply.cap.caps[0 ] =htonl (AFS_CAP_ERROR_TRANSLATION );afs_send_simple_reply (call, &reply,sizeof (reply));
fs/afs/internal.h +0 -15
@@ -724,15 +724,6 @@ struct afs_permits {struct afs_permit permits[];/* List of permits sorted by key pointer */ }; -/* -* record of one of a system's set of network interfaces -*/ -struct afs_interface { -struct in_addr address;/* IPv4 address bound to interface */ -struct in_addr netmask;/* netmask applied to address */ -unsigned mtu;/* MTU of interface */ -}; -/* * Error prioritisation and accumulation. */
@@ -1095,12 +1086,6 @@ extern const struct file_operations afs_mntpt_file_operations;extern struct vfsmount *afs_d_automount (struct path *);extern void afs_mntpt_kill_timer (void ); -/* -* netdevices.c -*/ -extern int afs_get_ipv4_interfaces (struct afs_net *,struct afs_interface *, -size_t ,bool ); -/* * proc.c */
fs/afs/netdevices.c deleted +0 -48
48 lines not on this page · raw message
Signature · 1 line
2.21.0
Re: [PATCH net-next v2 1/7] afs: do not send list of client addresses
Quoted 1 line · Florian Westphal
David Howell says:
"Howells"
Apart from that:
Florian Westphal
maintainerRe: [PATCH net-next v2 1/7] afs: do not send list of client addresses
Quoted 5 lines · David Howells
Quoted 1 line · Florian Westphal
David Howell says:
"Howells"
My bad.
Quoted 3 lines
Apart from that:
Tested-by David Howells <[email protected]>
Thanks, a lot, I've re-submitted this as v3 retaining your tested-by.
Florian Westphal
maintainerPATCH v2 2/7 net: inetdevice: provide replacement iterators for in_ifaddr walk
In reply to Florian WestphalThe ifa_list is protected either by rcu or rtnl lock, but the current iterators do not account for this.
This adds two iterators as replacement, a later patch in
the series will update them with the needed rcu/rtnl_dereference calls.
Its not done in this patch yet to avoid sparse warnings -- the fields lack the proper __rcu annotation.
--- include/linux/inetdevice.h | 10 +++++++++- net/ipv4/devinet.c | 31 ++++++++++++++++--------------- 2 files changed, 25 insertions(+), 16 deletions(-)
include/linux/inetdevice.h +9 -1
@@ -186,7 +186,7 @@ __be32 inet_confirm_addr(struct net *net, struct in_device *in_dev, __be32 dst,struct in_ifaddr *inet_ifa_byprefix (struct in_device *in_dev,__be32 prefix,__be32 mask);struct in_ifaddr *inet_lookup_ifaddr_rcu (struct net *net,__be32 addr); -static __inline__bool inet_ifa_match (__be32 addr,struct in_ifaddr *ifa) +static inline bool inet_ifa_match (__be32 addr,const struct in_ifaddr *ifa) {return !((addr^ifa->ifa_address)&ifa->ifa_mask); }
@@ -215,6 +215,14 @@ static __inline__ bool bad_mask(__be32 mask, __be32 addr)#define endfor_ifa (in_dev) } +#define in_dev_for_each_ifa_rtnl (ifa, in_dev) \ + for (ifa = (in_dev)->ifa_list; ifa; \ + ifa = ifa->ifa_next) + +#define in_dev_for_each_ifa_rcu (ifa, in_dev) \ + for (ifa = (in_dev)->ifa_list; ifa; \ + ifa = ifa->ifa_next) +static inline struct in_device *__in_dev_get_rcu (const struct net_device *dev) {return rcu_dereference (dev->ip_ptr);
net/ipv4/devinet.c +16 -15
@@ -873,13 +873,12 @@ static struct in_ifaddr *rtm_to_ifaddr(struct net *net, struct nlmsghdr *nlh,static struct in_ifaddr *find_matching_ifa (struct in_ifaddr *ifa) {struct in_device *in_dev = ifa->ifa_dev; -struct in_ifaddr *ifa1, **ifap; +struct in_ifaddr *ifa1;if (!ifa->ifa_local)return NULL ; -for (ifap = &in_dev->ifa_list; (ifa1 = *ifap) !=NULL ; - ifap = &ifa1->ifa_next) { +in_dev_for_each_ifa_rtnl (ifa1, in_dev) {if (ifa1->ifa_mask == ifa->ifa_mask &&inet_ifa_match (ifa1->ifa_address, ifa) && ifa1->ifa_local == ifa->ifa_local)
@@ -1208,7 +1207,7 @@ int devinet_ioctl(struct net *net, unsigned int cmd, struct ifreq *ifr)static int inet_gifconf (struct net_device *dev,char __user *buf,int len,int size) {struct in_device *in_dev =__in_dev_get_rtnl (dev); -struct in_ifaddr *ifa; +const struct in_ifaddr *ifa;struct ifreq ifr;int done =0 ;
@@ -1218,7 +1217,7 @@ static int inet_gifconf(struct net_device *dev, char __user *buf, int len, int sif (!in_dev) goto out; -for (ifa = in_dev->ifa_list; ifa; ifa = ifa->ifa_next) { +in_dev_for_each_ifa_rtnl (ifa, in_dev) {if (!buf) { done += size;continue ;
@@ -1321,10 +1320,11 @@ EXPORT_SYMBOL(inet_select_addr);static __be32 confirm_addr_indev (struct in_device *in_dev,__be32 dst,__be32 local,int scope) { -int same =0 ; +const struct in_ifaddr *ifa;__be32 addr =0 ; +int same =0 ; -for_ifa (in_dev) { +in_dev_for_each_ifa_rcu (ifa, in_dev) {if (!addr && (local == ifa->ifa_local || !local) && ifa->ifa_scope <= scope) {
@@ -1350,7 +1350,7 @@ static __be32 confirm_addr_indev(struct in_device *in_dev, __be32 dst, same =0 ; } } - }endfor_ifa (in_dev); + }return same ? addr :0 ; }
@@ -1424,7 +1424,7 @@ static void inetdev_changename(struct net_device *dev, struct in_device *in_dev)struct in_ifaddr *ifa;int named =0 ; -for (ifa = in_dev->ifa_list; ifa; ifa = ifa->ifa_next) { +in_dev_for_each_ifa_rtnl (ifa, in_dev) {char old[IFNAMSIZ ], *dot;memcpy (old, ifa->ifa_label,IFNAMSIZ );
@@ -1454,10 +1454,9 @@ static void inetdev_send_gratuitous_arp(struct net_device *dev, struct in_device *in_dev) { -struct in_ifaddr *ifa; +const struct in_ifaddr *ifa; -for (ifa = in_dev->ifa_list; ifa; - ifa = ifa->ifa_next) { +in_dev_for_each_ifa_rtnl (ifa, in_dev) { arp_send(ARPOP_REQUEST, ETH_P_ARP, ifa->ifa_local, dev, ifa->ifa_local, NULL,
@@ -1727,15 +1726,17 @@ static int in_dev_dump_addr(struct in_device *in_dev, struct sk_buff *skb,int ip_idx =0 ;int err; -for (ifa = in_dev->ifa_list; ifa; ifa = ifa->ifa_next, ip_idx++) { -if (ip_idx < s_ip_idx) +in_dev_for_each_ifa_rcu (ifa, in_dev) { +if (ip_idx < s_ip_idx) { + ip_idx++;continue ; - + } err =inet_fill_ifaddr (skb, ifa, fillargs);if (err <0 ) goto done;nl_dump_check_consistent (cb,nlmsg_hdr (skb)); + ip_idx++; } err =0 ;
Signature · 1 line
2.21.0
Florian Westphal
maintainerPATCH v2 3/7 devinet: use in_dev_for_each_ifa_rcu in more places
In reply to Florian WestphalThis also replaces spots that used for_primary_ifa().
for_primary_ifa() aborts the loop on the first secondary address seen.
Replace it with either the rcu or rtnl variant of in_dev_for_each_ifa(), but two places will now also consider secondary addresses too:inet_addr_onlink() and inet_ifa_byprefix().
I do not understand why they should ignore secondary addresses.
Why would a secondary address not be considered 'on link'? When matching a prefix, why ignore a matching secondary address?
Other places get converted as well, but gain "->flags & SECONDARY" check.
--- net/ipv4/devinet.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-)
net/ipv4/devinet.c +19 -8
@@ -327,15 +327,17 @@ static void inetdev_destroy(struct in_device *in_dev)int inet_addr_onlink (struct in_device *in_dev,__be32 a,__be32 b) { +const struct in_ifaddr *ifa; +rcu_read_lock (); -for_primary_ifa (in_dev) { +in_dev_for_each_ifa_rcu (ifa, in_dev) {if (inet_ifa_match (a, ifa)) {if (!b ||inet_ifa_match (b, ifa)) {rcu_read_unlock ();return 1 ; } } - }endfor_ifa (in_dev); + }rcu_read_unlock ();return 0 ; }
@@ -580,12 +582,14 @@ EXPORT_SYMBOL(inetdev_by_index);struct in_ifaddr *inet_ifa_byprefix (struct in_device *in_dev,__be32 prefix,__be32 mask) { +struct in_ifaddr *ifa; +ASSERT_RTNL (); -for_primary_ifa (in_dev) { +in_dev_for_each_ifa_rtnl (ifa, in_dev) {if (ifa->ifa_mask == mask &&inet_ifa_match (prefix, ifa))return ifa; - }endfor_ifa (in_dev); + }return NULL ; }
@@ -1245,17 +1249,22 @@ static int inet_gifconf(struct net_device *dev, char __user *buf, int len, int sstatic __be32 in_dev_select_addr (const struct in_device *in_dev,int scope) { -for_primary_ifa (in_dev) { +const struct in_ifaddr *ifa; + +in_dev_for_each_ifa_rcu (ifa, in_dev) { +if (ifa->ifa_flags &IFA_F_SECONDARY ) +continue ;if (ifa->ifa_scope !=RT_SCOPE_LINK && ifa->ifa_scope <= scope)return ifa->ifa_local; - }endfor_ifa (in_dev); + }return 0 ; }__be32 inet_select_addr (const struct net_device *dev,__be32 dst,int scope) { +const struct in_ifaddr *ifa;__be32 addr =0 ;struct in_device *in_dev;struct net *net =dev_net (dev);
@@ -1266,7 +1275,9 @@ __be32 inet_select_addr(const struct net_device *dev, __be32 dst, int scope)if (!in_dev) goto no_in_dev; -for_primary_ifa (in_dev) { +in_dev_for_each_ifa_rcu (ifa, in_dev) { +if (ifa->ifa_flags &IFA_F_SECONDARY ) +continue ;if (ifa->ifa_scope > scope)continue ;if (!dst ||inet_ifa_match (dst, ifa)) {
@@ -1275,7 +1286,7 @@ __be32 inet_select_addr(const struct net_device *dev, __be32 dst, int scope) }if (!addr) addr = ifa->ifa_local; - }endfor_ifa (in_dev); + }if (addr) goto out_unlock;
Signature · 1 line
2.21.0
Florian Westphal
maintainerPATCH v2 4/7 netfilter: use in_dev_for_each_ifa_rcu
In reply to Florian WestphalNetfilter hooks are always running under rcu read lock, use the new iterator macro so sparse won't complain once we add proper __rcu annotations.
--- net/ipv4/netfilter/nf_tproxy_ipv4.c | 9 +++++++-- net/netfilter/nf_conntrack_broadcast.c | 9 +++++++-- net/netfilter/nfnetlink_osf.c | 5 ++--- 3 files changed, 16 insertions(+), 7 deletions(-)
net/ipv4/netfilter/nf_tproxy_ipv4.c +7 -2
@@ -53,6 +53,7 @@ EXPORT_SYMBOL_GPL(nf_tproxy_handle_time_wait4);__be32 nf_tproxy_laddr4 (struct sk_buff *skb,__be32 user_laddr,__be32 daddr) { +const struct in_ifaddr *ifa;struct in_device *indev;__be32 laddr;
@@ -61,10 +62,14 @@ __be32 nf_tproxy_laddr4(struct sk_buff *skb, __be32 user_laddr, __be32 daddr) laddr =0 ; indev =__in_dev_get_rcu (skb->dev); -for_primary_ifa (indev) { + +in_dev_for_each_ifa_rcu (ifa, indev) { +if (ifa->ifa_flags &IFA_F_SECONDARY ) +continue ; + laddr = ifa->ifa_local;break ; - }endfor_ifa (indev); + }return laddr ? laddr : daddr; }
net/netfilter/nf_conntrack_broadcast.c +7 -2
@@ -41,12 +41,17 @@ int nf_conntrack_broadcast_help(struct sk_buff *skb, in_dev =__in_dev_get_rcu (rt->dst.dev);if (in_dev !=NULL ) { -for_primary_ifa (in_dev) { +const struct in_ifaddr *ifa; + +in_dev_for_each_ifa_rcu (ifa, in_dev) { +if (ifa->ifa_flags &IFA_F_SECONDARY ) +continue ; +if (ifa->ifa_broadcast == iph->daddr) { mask = ifa->ifa_mask;break ; } - }endfor_ifa (in_dev); + } }if (mask ==0 )
net/netfilter/nfnetlink_osf.c +2 -3
@@ -33,6 +33,7 @@ static inline int nf_osf_ttl(const struct sk_buff *skb, {struct in_device *in_dev =__in_dev_get_rcu (skb->dev);const struct iphdr *ip =ip_hdr (skb); +const struct in_ifaddr *ifa;int ret =0 ;if (ttl_check ==NF_OSF_TTL_TRUE )
@@ -42,15 +43,13 @@ static inline int nf_osf_ttl(const struct sk_buff *skb,else if (ip->ttl <= f_ttl)return 1 ; -for_ifa (in_dev) { +in_dev_for_each_ifa_rcu (ifa, in_dev) {if (inet_ifa_match (ip->saddr, ifa)) { ret = (ip->ttl == f_ttl);break ; } } -endfor_ifa (in_dev); -return ret; }
Signature · 1 line
2.21.0
Florian Westphal
maintainerPATCH v2 5/7 net: use new in_dev_ifa iterators
In reply to Florian WestphalUse in_dev_for_each_ifa_rcu/rtnl instead.
This prevents sparse warnings once proper __rcu annotations are added.
t di# Last commands done (6 commands done):
--- net/ipv4/fib_frontend.c | 24 +++++++++++++++++------- net/ipv4/igmp.c | 5 +++-- net/ipv6/addrconf.c | 4 +--- net/sctp/protocol.c | 2 +- net/smc/smc_clc.c | 11 +++++++---- 5 files changed, 29 insertions(+), 17 deletions(-)
net/ipv4/fib_frontend.c +17 -7
@@ -540,14 +540,22 @@ static int rtentry_to_fib_config(struct net *net, int cmd, struct rtentry *rt, cfg->fc_oif = dev->ifindex; cfg->fc_table =l3mdev_fib_table (dev);if (colon) { -struct in_ifaddr *ifa; -struct in_device *in_dev =__in_dev_get_rtnl (dev); +const struct in_ifaddr *ifa; +struct in_device *in_dev; + + in_dev =__in_dev_get_rtnl (dev);if (!in_dev)return -ENODEV ; + *colon =':' ; -for (ifa = in_dev->ifa_list; ifa; ifa = ifa->ifa_next) + +rcu_read_lock (); +in_dev_for_each_ifa_rcu (ifa, in_dev) {if (strcmp (ifa->ifa_label, devname) ==0 )break ; + } +rcu_read_unlock (); +if (!ifa)return -ENODEV ; cfg->fc_prefsrc = ifa->ifa_local;
@@ -1177,8 +1185,8 @@ void fib_del_ifaddr(struct in_ifaddr *ifa, struct in_ifaddr *iprim)* * Scan address list to be sure that addresses are really gone. */ - -for (ifa1 = in_dev->ifa_list; ifa1; ifa1 = ifa1->ifa_next) { +rcu_read_lock (); +in_dev_for_each_ifa_rcu (ifa1, in_dev) {if (ifa1 == ifa) {/* promotion, keep the IP */ gone =0 ;
@@ -1246,6 +1254,7 @@ void fib_del_ifaddr(struct in_ifaddr *ifa, struct in_ifaddr *iprim) } } } +rcu_read_unlock (); no_promotions:if (!(ok &BRD_OK ))
@@ -1415,6 +1424,7 @@ static int fib_netdev_event(struct notifier_block *this, unsigned long event, vostruct netdev_notifier_info_ext *info_ext = ptr;struct in_device *in_dev;struct net *net =dev_net (dev); +struct in_ifaddr *ifa;unsigned int flags;if (event ==NETDEV_UNREGISTER ) {
@@ -1429,9 +1439,9 @@ static int fib_netdev_event(struct notifier_block *this, unsigned long event, voswitch (event) {case NETDEV_UP : - for_ifa(in_dev) { +in_dev_for_each_ifa_rtnl (ifa, in_dev) {fib_add_ifaddr (ifa); - }endfor_ifa (in_dev); + }#ifdef CONFIG_IP_ROUTE_MULTIPATH fib_sync_up (dev,RTNH_F_DEAD );#endif
net/ipv4/igmp.c +3 -2
@@ -325,14 +325,15 @@ static __be32 igmpv3_get_srcaddr(struct net_device *dev, const struct flowi4 *fl4) {struct in_device *in_dev =__in_dev_get_rcu (dev); +const struct in_ifaddr *ifa;if (!in_dev)return htonl (INADDR_ANY ); -for_ifa (in_dev) { +in_dev_for_each_ifa_rcu (ifa, in_dev) {if (fl4->saddr == ifa->ifa_local)return fl4->saddr; - }endfor_ifa (in_dev); + }return htonl (INADDR_ANY ); }
net/ipv6/addrconf.c +1 -3
@@ -3127,11 +3127,9 @@ static void sit_add_v4_addrs(struct inet6_dev *idev)struct in_device *in_dev =__in_dev_get_rtnl (dev);if (in_dev && (dev->flags &IFF_UP )) {struct in_ifaddr *ifa; -int flag = scope; -for (ifa = in_dev->ifa_list; ifa; ifa = ifa->ifa_next) { - +in_dev_for_each_ifa_rtnl (ifa, in_dev) { addr.s6_addr32[3 ] = ifa->ifa_local;if (ifa->ifa_scope ==RT_SCOPE_LINK )
net/sctp/protocol.c +1 -1
@@ -96,7 +96,7 @@ static void sctp_v4_copy_addrlist(struct list_head *addrlist,return ; } -for (ifa = in_dev->ifa_list; ifa; ifa = ifa->ifa_next) { +in_dev_for_each_ifa_rcu (ifa, in_dev) {/* Add the address to the local list. */ addr =kzalloc (sizeof (*addr),GFP_ATOMIC );if (addr) {
net/smc/smc_clc.c +7 -4
@@ -97,17 +97,19 @@ static int smc_clc_prfx_set4_rcu(struct dst_entry *dst, __be32 ipv4, struct smc_clc_msg_proposal_prefix *prop) {struct in_device *in_dev =__in_dev_get_rcu (dst->dev); +const struct in_ifaddr *ifa;if (!in_dev)return -ENODEV ; -for_ifa (in_dev) { + +in_dev_for_each_ifa_rcu (ifa, in_dev) {if (!inet_ifa_match (ipv4, ifa))continue ; prop->prefix_len =inet_mask_len (ifa->ifa_mask); prop->outgoing_subnet = ifa->ifa_address & ifa->ifa_mask;/* prop->ipv6_prefixes_cnt = 0; already done by memset before */ return 0 ; - }endfor_ifa (in_dev); + }return -ENOENT ; }
@@ -190,14 +192,15 @@ static int smc_clc_prfx_match4_rcu(struct net_device *dev, struct smc_clc_msg_proposal_prefix *prop) {struct in_device *in_dev =__in_dev_get_rcu (dev); +const struct in_ifaddr *ifa;if (!in_dev)return -ENODEV ; -for_ifa (in_dev) { +in_dev_for_each_ifa_rcu (ifa, in_dev) {if (prop->prefix_len ==inet_mask_len (ifa->ifa_mask) &&inet_ifa_match (prop->outgoing_subnet, ifa))return 0 ; - }endfor_ifa (in_dev); + }return -ENOENT ; }
Signature · 1 line
2.21.0
Florian Westphal
maintainerPATCH v2 6/7 drivers: use in_dev_for_each_ifa_rtnl/rcu
In reply to Florian WestphalLike previous patches, use the new iterator macros to avoid sparse warnings once proper __rcu annotations are added.
Compile tested only.
--- drivers/infiniband/core/roce_gid_mgmt.c | 5 +++-- drivers/infiniband/hw/cxgb4/cm.c | 9 +++++++-- drivers/infiniband/hw/i40iw/i40iw_cm.c | 7 +++++-- drivers/infiniband/hw/i40iw/i40iw_main.c | 6 ++++-- drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c | 8 +++++--- drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c | 5 +++-- drivers/net/wan/hdlc_cisco.c | 11 +++++------ 7 files changed, 32 insertions(+), 19 deletions(-)
drivers/infiniband/core/roce_gid_mgmt.c +3 -2
@@ -330,6 +330,7 @@ static void bond_delete_netdev_default_gids(struct ib_device *ib_dev,static void enum_netdev_ipv4_ips (struct ib_device *ib_dev,u8 port,struct net_device *ndev) { +const struct in_ifaddr *ifa;struct in_device *in_dev;struct sin_list {struct list_head list;
@@ -349,7 +350,7 @@ static void enum_netdev_ipv4_ips(struct ib_device *ib_dev,return ; } -for_ifa (in_dev) { +in_dev_for_each_ifa_rcu (ifa, in_dev) {struct sin_list *entry =kzalloc (sizeof (*entry),GFP_ATOMIC );if (!entry)
@@ -359,7 +360,7 @@ static void enum_netdev_ipv4_ips(struct ib_device *ib_dev, entry->ip.sin_addr.s_addr = ifa->ifa_address;list_add_tail (&entry->list, &sin_list); } -endfor_ifa (in_dev); +rcu_read_unlock ();list_for_each_entry_safe (sin_iter, sin_temp, &sin_list, list) {
drivers/infiniband/hw/cxgb4/cm.c +7 -2
@@ -3230,17 +3230,22 @@ static int pick_local_ipaddrs(struct c4iw_dev *dev, struct iw_cm_id *cm_id)int found =0 ;struct sockaddr_in *laddr = (struct sockaddr_in *)&cm_id->m_local_addr;struct sockaddr_in *raddr = (struct sockaddr_in *)&cm_id->m_remote_addr; +const struct in_ifaddr *ifa; ind =in_dev_get (dev->rdev.lldi.ports[0 ]);if (!ind)return -EADDRNOTAVAIL ; -for_primary_ifa (ind) { +rcu_read_lock (); +in_dev_for_each_ifa_rcu (ifa, ind) { +if (ifa->ifa_flags &IFA_F_SECONDARY ) +continue ; laddr->sin_addr.s_addr = ifa->ifa_address; raddr->sin_addr.s_addr = ifa->ifa_address; found =1 ;break ; } -endfor_ifa (ind); +rcu_read_unlock (); +in_dev_put (ind);return found ?0 : -EADDRNOTAVAIL ; }
drivers/infiniband/hw/i40iw/i40iw_cm.c +5 -2
@@ -1773,8 +1773,11 @@ static enum i40iw_status_code i40iw_add_mqh_4(if ((((rdma_vlan_dev_vlan_id (dev) <I40IW_NO_VLAN ) && (rdma_vlan_dev_real_dev (dev) == iwdev->netdev)) || (dev == iwdev->netdev)) && (dev->flags &IFF_UP )) { +const struct in_ifaddr *ifa; + idev =in_dev_get (dev); -for_ifa (idev) { + +in_dev_for_each_ifa_rtnl (ifa, idev) { i40iw_debug(&iwdev->sc_dev, I40IW_DEBUG_CM, "Allocating child CM Listener forIP=%pI4, vlan_id=%d, MAC=%pM\n",
@@ -1819,7 +1822,7 @@ static enum i40iw_status_code i40iw_add_mqh_4( cm_parent_listen_node->cm_core->stats_listen_nodes_created--; } } -endfor_ifa (idev); +in_dev_put (idev); } }
drivers/infiniband/hw/i40iw/i40iw_main.c +4 -2
@@ -1222,8 +1222,10 @@ static void i40iw_add_ipv4_addr(struct i40iw_device *iwdev)if ((((rdma_vlan_dev_vlan_id (dev) <0xFFFF ) && (rdma_vlan_dev_real_dev (dev) == iwdev->netdev)) || (dev == iwdev->netdev)) && (dev->flags &IFF_UP )) { +const struct in_ifaddr *ifa; + idev =in_dev_get (dev); -for_ifa (idev) { +in_dev_for_each_ifa_rtnl (ifa, idev) {i40iw_debug (&iwdev->sc_dev,I40IW_DEBUG_CM ,"IP=%pI4, vlan_id=%d, MAC=%pM\n" , &ifa->ifa_address,rdma_vlan_dev_vlan_id (dev), dev->dev_addr);
@@ -1235,7 +1237,7 @@ static void i40iw_add_ipv4_addr(struct i40iw_device *iwdev) true, I40IW_ARP_ADD); } -endfor_ifa (idev); +in_dev_put (idev); } }
drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c +5 -3
@@ -3248,6 +3248,7 @@ netxen_config_indev_addr(struct netxen_adapter *adapter, struct net_device *dev, unsigned long event) {struct in_device *indev; +struct in_ifaddr *ifa;if (!netxen_destip_supported (adapter))return ;
@@ -3256,7 +3257,8 @@ netxen_config_indev_addr(struct netxen_adapter *adapter,if (!indev)return ; -for_ifa (indev) { +rcu_read_lock (); +in_dev_for_each_ifa_rcu (ifa, indev) {switch (event) {case NETDEV_UP :netxen_list_config_ip (adapter, ifa,NX_IP_UP );
@@ -3267,8 +3269,8 @@ netxen_config_indev_addr(struct netxen_adapter *adapter,default :break ; } - }endfor_ifa (indev); - + } +rcu_read_unlock ();in_dev_put (indev); }
drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c +3 -2
@@ -4119,13 +4119,14 @@ static void qlcnic_config_indev_addr(struct qlcnic_adapter *adapter, struct net_device *dev, unsigned long event) { + const struct in_ifaddr *ifa;struct in_device *indev; indev =in_dev_get (dev);if (!indev)return ; -for_ifa (indev) { +in_dev_for_each_ifa_rtnl (ifa, indev) {switch (event) {case NETDEV_UP : qlcnic_config_ipaddr(adapter,
@@ -4138,7 +4139,7 @@ qlcnic_config_indev_addr(struct qlcnic_adapter *adapter,default :break ; } - }endfor_ifa (indev); + }in_dev_put (indev); }
drivers/net/wan/hdlc_cisco.c +5 -6
@@ -196,16 +196,15 @@ static int cisco_rx(struct sk_buff *skb) mask = ~cpu_to_be32 (0 );/* is the mask correct? */ if (in_dev !=NULL ) { -struct in_ifaddr **ifap = &in_dev->ifa_list; +const struct in_ifaddr *ifa; -while (*ifap !=NULL ) { +in_dev_for_each_ifa_rcu (ifa, in_dev) {if (strcmp (dev->name, - (*ifap)->ifa_label) ==0 ) { - addr = (*ifap)->ifa_local; - mask = (*ifap)->ifa_mask; + ifa->ifa_label) ==0 ) { + addr = ifa->ifa_local; + mask = ifa->ifa_mask;break ; } - ifap = &(*ifap)->ifa_next; } cisco_keepalive_send(dev, CISCO_ADDR_REPLY,
Signature · 1 line
2.21.0
Florian Westphal
maintainerPATCH v2 7/7 net: ipv4: provide __rcu annotation for ifa_list
In reply to Florian Westphalifa_list is protected by rcu, yet code doesn't reflect this.
Add the __rcu annotations and fix up all places that are now reported by sparse.
I've done this in the same commit to not add intermediate patches that result in new warnings.
--- drivers/infiniband/hw/i40iw/i40iw_utils.c | 12 ++- drivers/infiniband/hw/nes/nes.c | 8 +- drivers/infiniband/hw/usnic/usnic_ib_main.c | 15 ++-- drivers/isdn/hysdn/hysdn_net.c | 6 +- drivers/isdn/i4l/isdn_net.c | 20 ++++- drivers/net/ethernet/via/via-velocity.h | 2 +- drivers/net/plip/plip.c | 4 +- drivers/net/vmxnet3/vmxnet3_drv.c | 19 ++-- drivers/net/wireless/ath/ath6kl/cfg80211.c | 4 +- .../net/wireless/marvell/mwifiex/cfg80211.c | 2 +- include/linux/inetdevice.h | 21 ++--- net/core/netpoll.c | 10 ++- net/core/pktgen.c | 8 +- net/ipv4/devinet.c | 88 ++++++++++++------- net/mac80211/main.c | 4 +- net/netfilter/nf_nat_redirect.c | 12 +-- 16 files changed, 150 insertions(+), 85 deletions(-)
drivers/infiniband/hw/i40iw/i40iw_utils.c +8 -4
@@ -174,10 +174,14 @@ int i40iw_inetaddr_event(struct notifier_block *notifier,rcu_read_lock (); in =__in_dev_get_rcu (upper_dev); -if (!in->ifa_list) - local_ipaddr =0 ; -else - local_ipaddr =ntohl (in->ifa_list->ifa_address); + local_ipaddr =0 ; +if (in) { +struct in_ifaddr *ifa; + + ifa =rcu_dereference (in->ifa_list); +if (ifa) + local_ipaddr =ntohl (ifa->ifa_address); + }rcu_read_unlock (); }else {
drivers/infiniband/hw/nes/nes.c +7 -1
@@ -183,7 +183,13 @@ static int nes_inetaddr_event(struct notifier_block *notifier,rcu_read_lock (); in =__in_dev_get_rcu (upper_dev); - nesvnic->local_ipaddr = in->ifa_list->ifa_address; +if (in) { +struct in_ifaddr *ifa; + + ifa =rcu_dereference (in->ifa_list); +if (ifa) + nesvnic->local_ipaddr = ifa->ifa_address; + }rcu_read_unlock (); }else { nesvnic->local_ipaddr = ifa->ifa_address;
drivers/infiniband/hw/usnic/usnic_ib_main.c +10 -5
@@ -427,11 +427,16 @@ static void *usnic_ib_device_add(struct pci_dev *dev)if (netif_carrier_ok (us_ibdev->netdev))usnic_fwd_carrier_up (us_ibdev->ufdev); - ind =in_dev_get (netdev); -if (ind->ifa_list) -usnic_fwd_add_ipaddr (us_ibdev->ufdev, - ind->ifa_list->ifa_address); -in_dev_put (ind); +rcu_read_lock (); + ind =__in_dev_get_rcu (netdev); +if (ind) { +const struct in_ifaddr *ifa; + + ifa =rcu_dereference (ind->ifa_list); +if (ifa) +usnic_fwd_add_ipaddr (us_ibdev->ufdev, ifa->ifa_address); + } +rcu_read_unlock ();usnic_mac_ip_to_gid (us_ibdev->netdev->perm_addr, us_ibdev->ufdev->inaddr, &gid.raw[0 ]);
drivers/isdn/hysdn/hysdn_net.c +5 -1
@@ -70,9 +70,13 @@ net_open(struct net_device *dev)for (i =0 ; i <ETH_ALEN ; i++) dev->dev_addr[i] =0xfc ;if ((in_dev = dev->ip_ptr) !=NULL ) { -struct in_ifaddr *ifa = in_dev->ifa_list; +const struct in_ifaddr *ifa; + +rcu_read_lock (); + ifa =rcu_dereference (in_dev->ifa_list);if (ifa !=NULL )memcpy (dev->dev_addr + (ETH_ALEN -sizeof (ifa->ifa_local)), &ifa->ifa_local,sizeof (ifa->ifa_local)); +rcu_read_unlock (); } }else memcpy (dev->dev_addr, card->mac_addr,ETH_ALEN );
drivers/isdn/i4l/isdn_net.c +16 -4
@@ -242,15 +242,23 @@ isdn_net_open(struct net_device *dev)/* Fill in the MAC-level header (not needed, but for compatibility... */ for (i =0 ; i <ETH_ALEN -sizeof (u32); i++) dev->dev_addr[i] =0xfc ; -if ((in_dev = dev->ip_ptr) !=NULL ) { + +rcu_read_lock (); + + in_dev =__in_dev_get_rcu (dev); +if (in_dev) { +const struct in_ifaddr *ifa; +/* * Any address will do - we take the first */ -struct in_ifaddr *ifa = in_dev->ifa_list; + ifa =rcu_dereference (in_dev->ifa_list);if (ifa !=NULL )memcpy (dev->dev_addr +2 , &ifa->ifa_local,4 ); } +rcu_read_unlock (); +/* If this interface has slaves, start them also */ p =MASTER_TO_SLAVE (dev);if (p) {
@@ -1636,15 +1644,19 @@ isdn_net_ciscohdlck_slarp_send_reply(isdn_net_local *lp)__be32 addr =0 ;/* local ipv4 address */ __be32 mask =0 ;/* local netmask */ -if ((in_dev = lp->netdev->dev->ip_ptr) !=NULL ) { +rcu_read_lock (); + in_dev =__in_dev_get_rcu (lp->netdev->dev); +if (in_dev) {/* take primary(first) address of interface */ -struct in_ifaddr *ifa = in_dev->ifa_list; +const struct in_ifaddr *ifa =rcu_dereference (in_dev->ifa_list);if (ifa !=NULL ) { addr = ifa->ifa_local; mask = ifa->ifa_mask; } } +rcu_read_unlock (); + skb =isdn_net_ciscohdlck_alloc_skb (lp,4 +14 );if (!skb)return ;
drivers/net/ethernet/via/via-velocity.h +1 -1
@@ -1509,7 +1509,7 @@ static inline int velocity_get_ip(struct velocity_info *vptr)rcu_read_lock (); in_dev =__in_dev_get_rcu (vptr->netdev);if (in_dev !=NULL ) { - ifa = (struct in_ifaddr *) in_dev->ifa_list; + ifa =rcu_dereference (in_dev->ifa_list);if (ifa !=NULL ) {memcpy (vptr->ip_addr, &ifa->ifa_address,4 ); res =0 ;
drivers/net/plip/plip.c +2 -2
@@ -1012,7 +1012,7 @@ plip_rewrite_address(const struct net_device *dev, struct ethhdr *eth) in_dev =__in_dev_get_rcu (dev);if (in_dev) {/* Any address will do - we take the first */ -const struct in_ifaddr *ifa = in_dev->ifa_list; +const struct in_ifaddr *ifa =rcu_dereference (in_dev->ifa_list);if (ifa) {memcpy (eth->h_source, dev->dev_addr,ETH_ALEN );memset (eth->h_dest,0xfc ,2 );
@@ -1107,7 +1107,7 @@ plip_open(struct net_device *dev)/* Any address will do - we take the first. We already have the first two bytes filled with 0xfc, from plip_init_dev(). */ -struct in_ifaddr *ifa=in_dev->ifa_list; +const struct in_ifaddr *ifa =rcu_dereference (in_dev->ifa_list);if (ifa !=NULL ) {memcpy (dev->dev_addr+2 , &ifa->ifa_local,4 ); }
drivers/net/vmxnet3/vmxnet3_drv.c +13 -6
@@ -3651,13 +3651,19 @@ vmxnet3_suspend(struct device *device) }if (adapter->wol &WAKE_ARP ) { - in_dev =in_dev_get (netdev); -if (!in_dev) +rcu_read_lock (); + + in_dev =__in_dev_get_rcu (netdev); +if (!in_dev) { +rcu_read_unlock (); goto skip_arp; + } - ifa = (struct in_ifaddr *)in_dev->ifa_list; -if (!ifa) + ifa =rcu_dereference (in_dev->ifa_list); +if (!ifa) { +rcu_read_unlock (); goto skip_arp; + } pmConf->filters[i].patternSize =ETH_HLEN +/* Ethernet header*/ sizeof(struct arphdr) + /* ARP header */
@@ -3677,7 +3683,9 @@ vmxnet3_suspend(struct device *device)/* The Unicast IPv4 address in 'tip' field. */ arpreq +=2 *ETH_ALEN +sizeof (u32); - *(u32 *)arpreq = ifa->ifa_address; + *(__be32 *)arpreq = ifa->ifa_address; + +rcu_read_unlock ();/* The mask for the relevant bits. */ pmConf->filters[i].mask[0 ] =0x00 ;
@@ -3686,7 +3694,6 @@ vmxnet3_suspend(struct device *device) pmConf->filters[i].mask[3 ] =0x00 ; pmConf->filters[i].mask[4 ] =0xC0 ;/* IPv4 TIP */ pmConf->filters[i].mask[5 ] =0x03 ;/* IPv4 TIP */ -in_dev_put (in_dev); pmConf->wakeUpEvents |=VMXNET3_PM_WAKEUP_FILTER ; i++;
drivers/net/wireless/ath/ath6kl/cfg80211.c +2 -2
@@ -2194,13 +2194,13 @@ static int ath6kl_wow_suspend_vif(struct ath6kl_vif *vif,if (!in_dev)return 0 ; - ifa = in_dev->ifa_list; + ifa =rtnl_dereference (in_dev->ifa_list);memset (&ips,0 ,sizeof (ips));/* Configure IP addr only if IP address count < MAX_IP_ADDRS */ while (index <MAX_IP_ADDRS && ifa) { ips[index] = ifa->ifa_local; - ifa = ifa->ifa_next; + ifa =rtnl_dereference (ifa->ifa_next); index++; }
drivers/net/wireless/marvell/mwifiex/cfg80211.c +1 -1
@@ -3268,7 +3268,7 @@ static void mwifiex_set_auto_arp_mef_entry(struct mwifiex_private *priv, in_dev =__in_dev_get_rtnl (adapter->priv[i]->netdev);if (!in_dev)continue ; - ifa = in_dev->ifa_list; + ifa =rtnl_dereference (in_dev->ifa_list);if (!ifa || !ifa->ifa_local)continue ; ips[i] = ifa->ifa_local;
include/linux/inetdevice.h +6 -15
@@ -26,7 +26,7 @@ struct in_device {struct net_device *dev;refcount_t refcnt;int dead; -struct in_ifaddr *ifa_list;/* IP ifaddr chain */ +struct in_ifaddr __rcu *ifa_list;/* IP ifaddr chain */ struct ip_mc_list __rcu *mc_list;/* IP multicast filter chain */ struct ip_mc_list __rcu *__rcu *mc_hash;
@@ -136,7 +136,7 @@ static inline void ipv4_devconf_setall(struct in_device *in_dev)struct in_ifaddr {struct hlist_node hash; -struct in_ifaddr *ifa_next; +struct in_ifaddr __rcu *ifa_next;struct in_device *ifa_dev;struct rcu_head rcu_head;__be32 ifa_local;
@@ -206,22 +206,13 @@ static __inline__ bool bad_mask(__be32 mask, __be32 addr)return false; } -#define for_primary_ifa (in_dev) { struct in_ifaddr *ifa; \ - for (ifa = (in_dev)->ifa_list; ifa && !(ifa->ifa_flags&IFA_F_SECONDARY); ifa = ifa->ifa_next) - -#define for_ifa (in_dev) { struct in_ifaddr *ifa; \ - for (ifa = (in_dev)->ifa_list; ifa; ifa = ifa->ifa_next) - - -#define endfor_ifa (in_dev) } -#define in_dev_for_each_ifa_rtnl (ifa, in_dev) \ - for (ifa = (in_dev)->ifa_list; ifa; \ - ifa = ifa->ifa_next) + for (ifa = rtnl_dereference((in_dev)->ifa_list); ifa; \ + ifa = rtnl_dereference(ifa->ifa_next))#define in_dev_for_each_ifa_rcu (ifa, in_dev) \ - for (ifa = (in_dev)->ifa_list; ifa; \ - ifa = ifa->ifa_next) + for (ifa = rcu_dereference((in_dev)->ifa_list); ifa; \ + ifa = rcu_dereference(ifa->ifa_next))static inline struct in_device *__in_dev_get_rcu (const struct net_device *dev) {
net/core/netpoll.c +8 -2
@@ -696,16 +696,22 @@ int netpoll_setup(struct netpoll *np)if (!np->local_ip.ip) {if (!np->ipv6) { +const struct in_ifaddr *ifa; + in_dev =__in_dev_get_rtnl (ndev); +if (!in_dev) + goto put_noaddr; -if (!in_dev || !in_dev->ifa_list) { + ifa =rtnl_dereference (in_dev->ifa_list); +if (!ifa) { +put_noaddr:np_err (np,"no IP address for %s, aborting\n" , np->dev_name); err = -EDESTADDRREQ ; goto put; } - np->local_ip.ip = in_dev->ifa_list->ifa_local; + np->local_ip.ip = ifa->ifa_local;np_info (np,"local IP %pI4\n" , &np->local_ip.ip); }else {#if IS_ENABLED (CONFIG_IPV6 )
net/core/pktgen.c +5 -3
@@ -2125,9 +2125,11 @@ static void pktgen_setup_inject(struct pktgen_dev *pkt_dev)rcu_read_lock (); in_dev =__in_dev_get_rcu (pkt_dev->odev);if (in_dev) { -if (in_dev->ifa_list) { - pkt_dev->saddr_min = - in_dev->ifa_list->ifa_address; +const struct in_ifaddr *ifa; + + ifa =rcu_dereference (in_dev->ifa_list); +if (ifa) { + pkt_dev->saddr_min = ifa->ifa_address; pkt_dev->saddr_max = pkt_dev->saddr_min; } }
net/ipv4/devinet.c +57 -31
223 lines not on this page · raw message
net/mac80211/main.c +2 -2
@@ -354,11 +354,11 @@ static int ieee80211_ifa_changed(struct notifier_block *nb,sdata_lock (sdata);/* Copy the addresses to the bss_conf list */ - ifa = idev->ifa_list; + ifa =rtnl_dereference (idev->ifa_list);while (ifa) {if (c <IEEE80211_BSS_ARP_ADDR_LIST_LEN ) bss_conf->arp_addr_list[c] = ifa->ifa_address; - ifa = ifa->ifa_next; + ifa =rtnl_dereference (ifa->ifa_next); c++; }
net/netfilter/nf_nat_redirect.c +7 -5
@@ -47,15 +47,17 @@ nf_nat_redirect_ipv4(struct sk_buff *skb,if (hooknum ==NF_INET_LOCAL_OUT ) { newdst =htonl (0x7F000001 ); }else { -struct in_device *indev; -struct in_ifaddr *ifa; +const struct in_device *indev; newdst =0 ; indev =__in_dev_get_rcu (skb->dev); -if (indev && indev->ifa_list) { - ifa = indev->ifa_list; - newdst = ifa->ifa_local; +if (indev) { +const struct in_ifaddr *ifa; + + ifa =rcu_dereference (indev->ifa_list); +if (ifa) + newdst = ifa->ifa_local; }if (!newdst)
Signature · 1 line
2.21.0