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

net: use new in_dev_ifa iterators

Use in_dev_for_each_ifa_rcu/rtnl instead.
This prevents sparse warnings once proper __rcu annotations are added.

Signed-off-by: Florian Westphal <fw@strlen.de>

t di# Last commands done (6 commands done):

Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Florian Westphal and committed by
David S. Miller
cd5a411d b8d19572

+29 -17
+17 -7
net/ipv4/fib_frontend.c
··· 540 540 cfg->fc_oif = dev->ifindex; 541 541 cfg->fc_table = l3mdev_fib_table(dev); 542 542 if (colon) { 543 - struct in_ifaddr *ifa; 544 - struct in_device *in_dev = __in_dev_get_rtnl(dev); 543 + const struct in_ifaddr *ifa; 544 + struct in_device *in_dev; 545 + 546 + in_dev = __in_dev_get_rtnl(dev); 545 547 if (!in_dev) 546 548 return -ENODEV; 549 + 547 550 *colon = ':'; 548 - for (ifa = in_dev->ifa_list; ifa; ifa = ifa->ifa_next) 551 + 552 + rcu_read_lock(); 553 + in_dev_for_each_ifa_rcu(ifa, in_dev) { 549 554 if (strcmp(ifa->ifa_label, devname) == 0) 550 555 break; 556 + } 557 + rcu_read_unlock(); 558 + 551 559 if (!ifa) 552 560 return -ENODEV; 553 561 cfg->fc_prefsrc = ifa->ifa_local; ··· 1185 1177 * 1186 1178 * Scan address list to be sure that addresses are really gone. 1187 1179 */ 1188 - 1189 - for (ifa1 = in_dev->ifa_list; ifa1; ifa1 = ifa1->ifa_next) { 1180 + rcu_read_lock(); 1181 + in_dev_for_each_ifa_rcu(ifa1, in_dev) { 1190 1182 if (ifa1 == ifa) { 1191 1183 /* promotion, keep the IP */ 1192 1184 gone = 0; ··· 1254 1246 } 1255 1247 } 1256 1248 } 1249 + rcu_read_unlock(); 1257 1250 1258 1251 no_promotions: 1259 1252 if (!(ok & BRD_OK)) ··· 1424 1415 struct netdev_notifier_info_ext *info_ext = ptr; 1425 1416 struct in_device *in_dev; 1426 1417 struct net *net = dev_net(dev); 1418 + struct in_ifaddr *ifa; 1427 1419 unsigned int flags; 1428 1420 1429 1421 if (event == NETDEV_UNREGISTER) { ··· 1439 1429 1440 1430 switch (event) { 1441 1431 case NETDEV_UP: 1442 - for_ifa(in_dev) { 1432 + in_dev_for_each_ifa_rtnl(ifa, in_dev) { 1443 1433 fib_add_ifaddr(ifa); 1444 - } endfor_ifa(in_dev); 1434 + } 1445 1435 #ifdef CONFIG_IP_ROUTE_MULTIPATH 1446 1436 fib_sync_up(dev, RTNH_F_DEAD); 1447 1437 #endif
+3 -2
net/ipv4/igmp.c
··· 336 336 const struct flowi4 *fl4) 337 337 { 338 338 struct in_device *in_dev = __in_dev_get_rcu(dev); 339 + const struct in_ifaddr *ifa; 339 340 340 341 if (!in_dev) 341 342 return htonl(INADDR_ANY); 342 343 343 - for_ifa(in_dev) { 344 + in_dev_for_each_ifa_rcu(ifa, in_dev) { 344 345 if (fl4->saddr == ifa->ifa_local) 345 346 return fl4->saddr; 346 - } endfor_ifa(in_dev); 347 + } 347 348 348 349 return htonl(INADDR_ANY); 349 350 }
+1 -3
net/ipv6/addrconf.c
··· 3127 3127 struct in_device *in_dev = __in_dev_get_rtnl(dev); 3128 3128 if (in_dev && (dev->flags & IFF_UP)) { 3129 3129 struct in_ifaddr *ifa; 3130 - 3131 3130 int flag = scope; 3132 3131 3133 - for (ifa = in_dev->ifa_list; ifa; ifa = ifa->ifa_next) { 3134 - 3132 + in_dev_for_each_ifa_rtnl(ifa, in_dev) { 3135 3133 addr.s6_addr32[3] = ifa->ifa_local; 3136 3134 3137 3135 if (ifa->ifa_scope == RT_SCOPE_LINK)
+1 -1
net/sctp/protocol.c
··· 81 81 return; 82 82 } 83 83 84 - for (ifa = in_dev->ifa_list; ifa; ifa = ifa->ifa_next) { 84 + in_dev_for_each_ifa_rcu(ifa, in_dev) { 85 85 /* Add the address to the local list. */ 86 86 addr = kzalloc(sizeof(*addr), GFP_ATOMIC); 87 87 if (addr) {
+7 -4
net/smc/smc_clc.c
··· 97 97 struct smc_clc_msg_proposal_prefix *prop) 98 98 { 99 99 struct in_device *in_dev = __in_dev_get_rcu(dst->dev); 100 + const struct in_ifaddr *ifa; 100 101 101 102 if (!in_dev) 102 103 return -ENODEV; 103 - for_ifa(in_dev) { 104 + 105 + in_dev_for_each_ifa_rcu(ifa, in_dev) { 104 106 if (!inet_ifa_match(ipv4, ifa)) 105 107 continue; 106 108 prop->prefix_len = inet_mask_len(ifa->ifa_mask); 107 109 prop->outgoing_subnet = ifa->ifa_address & ifa->ifa_mask; 108 110 /* prop->ipv6_prefixes_cnt = 0; already done by memset before */ 109 111 return 0; 110 - } endfor_ifa(in_dev); 112 + } 111 113 return -ENOENT; 112 114 } 113 115 ··· 192 190 struct smc_clc_msg_proposal_prefix *prop) 193 191 { 194 192 struct in_device *in_dev = __in_dev_get_rcu(dev); 193 + const struct in_ifaddr *ifa; 195 194 196 195 if (!in_dev) 197 196 return -ENODEV; 198 - for_ifa(in_dev) { 197 + in_dev_for_each_ifa_rcu(ifa, in_dev) { 199 198 if (prop->prefix_len == inet_mask_len(ifa->ifa_mask) && 200 199 inet_ifa_match(prop->outgoing_subnet, ifa)) 201 200 return 0; 202 - } endfor_ifa(in_dev); 201 + } 203 202 204 203 return -ENOENT; 205 204 }