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

net: core: introduce struct netdev_nested_priv for nested interface infrastructure

Functions related to nested interface infrastructure such as
netdev_walk_all_{ upper | lower }_dev() pass both private functions
and "data" pointer to handle their own things.
At this point, the data pointer type is void *.
In order to make it easier to expand common variables and functions,
this new netdev_nested_priv structure is added.

In the following patch, a new member variable will be added into this
struct to fix the lockdep issue.

Signed-off-by: Taehee Yoo <ap420073@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Taehee Yoo and committed by
David S. Miller
eff74233 fe8300fd

+183 -95
+7 -3
drivers/infiniband/core/cache.c
··· 1320 1320 } 1321 1321 EXPORT_SYMBOL(rdma_read_gid_attr_ndev_rcu); 1322 1322 1323 - static int get_lower_dev_vlan(struct net_device *lower_dev, void *data) 1323 + static int get_lower_dev_vlan(struct net_device *lower_dev, 1324 + struct netdev_nested_priv *priv) 1324 1325 { 1325 - u16 *vlan_id = data; 1326 + u16 *vlan_id = (u16 *)priv->data; 1326 1327 1327 1328 if (is_vlan_dev(lower_dev)) 1328 1329 *vlan_id = vlan_dev_vlan_id(lower_dev); ··· 1349 1348 int rdma_read_gid_l2_fields(const struct ib_gid_attr *attr, 1350 1349 u16 *vlan_id, u8 *smac) 1351 1350 { 1351 + struct netdev_nested_priv priv = { 1352 + .data = (void *)vlan_id, 1353 + }; 1352 1354 struct net_device *ndev; 1353 1355 1354 1356 rcu_read_lock(); ··· 1372 1368 * the lower vlan device for this gid entry. 1373 1369 */ 1374 1370 netdev_walk_all_lower_dev_rcu(attr->ndev, 1375 - get_lower_dev_vlan, vlan_id); 1371 + get_lower_dev_vlan, &priv); 1376 1372 } 1377 1373 } 1378 1374 rcu_read_unlock();
+6 -3
drivers/infiniband/core/cma.c
··· 2865 2865 bool found; 2866 2866 }; 2867 2867 2868 - static int get_lower_vlan_dev_tc(struct net_device *dev, void *data) 2868 + static int get_lower_vlan_dev_tc(struct net_device *dev, 2869 + struct netdev_nested_priv *priv) 2869 2870 { 2870 - struct iboe_prio_tc_map *map = data; 2871 + struct iboe_prio_tc_map *map = (struct iboe_prio_tc_map *)priv->data; 2871 2872 2872 2873 if (is_vlan_dev(dev)) 2873 2874 map->output_tc = get_vlan_ndev_tc(dev, map->input_prio); ··· 2887 2886 { 2888 2887 struct iboe_prio_tc_map prio_tc_map = {}; 2889 2888 int prio = rt_tos2priority(tos); 2889 + struct netdev_nested_priv priv; 2890 2890 2891 2891 /* If VLAN device, get it directly from the VLAN netdev */ 2892 2892 if (is_vlan_dev(ndev)) 2893 2893 return get_vlan_ndev_tc(ndev, prio); 2894 2894 2895 2895 prio_tc_map.input_prio = prio; 2896 + priv.data = (void *)&prio_tc_map; 2896 2897 rcu_read_lock(); 2897 2898 netdev_walk_all_lower_dev_rcu(ndev, 2898 2899 get_lower_vlan_dev_tc, 2899 - &prio_tc_map); 2900 + &priv); 2900 2901 rcu_read_unlock(); 2901 2902 /* If map is found from lower device, use it; Otherwise 2902 2903 * continue with the current netdevice to get priority to tc map.
+6 -3
drivers/infiniband/core/roce_gid_mgmt.c
··· 531 531 struct net_device *upper; 532 532 }; 533 533 534 - static int netdev_upper_walk(struct net_device *upper, void *data) 534 + static int netdev_upper_walk(struct net_device *upper, 535 + struct netdev_nested_priv *priv) 535 536 { 536 537 struct upper_list *entry = kmalloc(sizeof(*entry), GFP_ATOMIC); 537 - struct list_head *upper_list = data; 538 + struct list_head *upper_list = (struct list_head *)priv->data; 538 539 539 540 if (!entry) 540 541 return 0; ··· 554 553 struct net_device *ndev)) 555 554 { 556 555 struct net_device *ndev = cookie; 556 + struct netdev_nested_priv priv; 557 557 struct upper_list *upper_iter; 558 558 struct upper_list *upper_temp; 559 559 LIST_HEAD(upper_list); 560 560 561 + priv.data = &upper_list; 561 562 rcu_read_lock(); 562 - netdev_walk_all_upper_dev_rcu(ndev, netdev_upper_walk, &upper_list); 563 + netdev_walk_all_upper_dev_rcu(ndev, netdev_upper_walk, &priv); 563 564 rcu_read_unlock(); 564 565 565 566 handle_netdev(ib_dev, port, ndev);
+6 -3
drivers/infiniband/ulp/ipoib/ipoib_main.c
··· 342 342 struct net_device *result; 343 343 }; 344 344 345 - static int ipoib_upper_walk(struct net_device *upper, void *_data) 345 + static int ipoib_upper_walk(struct net_device *upper, 346 + struct netdev_nested_priv *priv) 346 347 { 347 - struct ipoib_walk_data *data = _data; 348 + struct ipoib_walk_data *data = (struct ipoib_walk_data *)priv->data; 348 349 int ret = 0; 349 350 350 351 if (ipoib_is_dev_match_addr_rcu(data->addr, upper)) { ··· 369 368 static struct net_device *ipoib_get_net_dev_match_addr( 370 369 const struct sockaddr *addr, struct net_device *dev) 371 370 { 371 + struct netdev_nested_priv priv; 372 372 struct ipoib_walk_data data = { 373 373 .addr = addr, 374 374 }; 375 375 376 + priv.data = (void *)&data; 376 377 rcu_read_lock(); 377 378 if (ipoib_is_dev_match_addr_rcu(addr, dev)) { 378 379 dev_hold(dev); ··· 382 379 goto out; 383 380 } 384 381 385 - netdev_walk_all_upper_dev_rcu(dev, ipoib_upper_walk, &data); 382 + netdev_walk_all_upper_dev_rcu(dev, ipoib_upper_walk, &priv); 386 383 out: 387 384 rcu_read_unlock(); 388 385 return data.result;
+6 -3
drivers/net/bonding/bond_alb.c
··· 942 942 bool strict_match; 943 943 }; 944 944 945 - static int alb_upper_dev_walk(struct net_device *upper, void *_data) 945 + static int alb_upper_dev_walk(struct net_device *upper, 946 + struct netdev_nested_priv *priv) 946 947 { 947 - struct alb_walk_data *data = _data; 948 + struct alb_walk_data *data = (struct alb_walk_data *)priv->data; 948 949 bool strict_match = data->strict_match; 949 950 struct bonding *bond = data->bond; 950 951 struct slave *slave = data->slave; ··· 984 983 bool strict_match) 985 984 { 986 985 struct bonding *bond = bond_get_bond_by_slave(slave); 986 + struct netdev_nested_priv priv; 987 987 struct alb_walk_data data = { 988 988 .strict_match = strict_match, 989 989 .mac_addr = mac_addr, ··· 992 990 .bond = bond, 993 991 }; 994 992 993 + priv.data = (void *)&data; 995 994 /* send untagged */ 996 995 alb_send_lp_vid(slave, mac_addr, 0, 0); 997 996 ··· 1000 997 * for that device. 1001 998 */ 1002 999 rcu_read_lock(); 1003 - netdev_walk_all_upper_dev_rcu(bond->dev, alb_upper_dev_walk, &data); 1000 + netdev_walk_all_upper_dev_rcu(bond->dev, alb_upper_dev_walk, &priv); 1004 1001 rcu_read_unlock(); 1005 1002 } 1006 1003
+7 -3
drivers/net/bonding/bond_main.c
··· 2511 2511 } 2512 2512 } 2513 2513 2514 - static int bond_upper_dev_walk(struct net_device *upper, void *data) 2514 + static int bond_upper_dev_walk(struct net_device *upper, 2515 + struct netdev_nested_priv *priv) 2515 2516 { 2516 - __be32 ip = *((__be32 *)data); 2517 + __be32 ip = *(__be32 *)priv->data; 2517 2518 2518 2519 return ip == bond_confirm_addr(upper, 0, ip); 2519 2520 } 2520 2521 2521 2522 static bool bond_has_this_ip(struct bonding *bond, __be32 ip) 2522 2523 { 2524 + struct netdev_nested_priv priv = { 2525 + .data = (void *)&ip, 2526 + }; 2523 2527 bool ret = false; 2524 2528 2525 2529 if (ip == bond_confirm_addr(bond->dev, 0, ip)) 2526 2530 return true; 2527 2531 2528 2532 rcu_read_lock(); 2529 - if (netdev_walk_all_upper_dev_rcu(bond->dev, bond_upper_dev_walk, &ip)) 2533 + if (netdev_walk_all_upper_dev_rcu(bond->dev, bond_upper_dev_walk, &priv)) 2530 2534 ret = true; 2531 2535 rcu_read_unlock(); 2532 2536
+26 -11
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
··· 5396 5396 return err; 5397 5397 } 5398 5398 5399 - static int ixgbe_macvlan_up(struct net_device *vdev, void *data) 5399 + static int ixgbe_macvlan_up(struct net_device *vdev, 5400 + struct netdev_nested_priv *priv) 5400 5401 { 5401 - struct ixgbe_adapter *adapter = data; 5402 + struct ixgbe_adapter *adapter = (struct ixgbe_adapter *)priv->data; 5402 5403 struct ixgbe_fwd_adapter *accel; 5403 5404 5404 5405 if (!netif_is_macvlan(vdev)) ··· 5416 5415 5417 5416 static void ixgbe_configure_dfwd(struct ixgbe_adapter *adapter) 5418 5417 { 5418 + struct netdev_nested_priv priv = { 5419 + .data = (void *)adapter, 5420 + }; 5421 + 5419 5422 netdev_walk_all_upper_dev_rcu(adapter->netdev, 5420 - ixgbe_macvlan_up, adapter); 5423 + ixgbe_macvlan_up, &priv); 5421 5424 } 5422 5425 5423 5426 static void ixgbe_configure(struct ixgbe_adapter *adapter) ··· 9028 9023 } 9029 9024 9030 9025 #endif /* CONFIG_IXGBE_DCB */ 9031 - static int ixgbe_reassign_macvlan_pool(struct net_device *vdev, void *data) 9026 + static int ixgbe_reassign_macvlan_pool(struct net_device *vdev, 9027 + struct netdev_nested_priv *priv) 9032 9028 { 9033 - struct ixgbe_adapter *adapter = data; 9029 + struct ixgbe_adapter *adapter = (struct ixgbe_adapter *)priv->data; 9034 9030 struct ixgbe_fwd_adapter *accel; 9035 9031 int pool; 9036 9032 ··· 9068 9062 static void ixgbe_defrag_macvlan_pools(struct net_device *dev) 9069 9063 { 9070 9064 struct ixgbe_adapter *adapter = netdev_priv(dev); 9065 + struct netdev_nested_priv priv = { 9066 + .data = (void *)adapter, 9067 + }; 9071 9068 9072 9069 /* flush any stale bits out of the fwd bitmask */ 9073 9070 bitmap_clear(adapter->fwd_bitmask, 1, 63); 9074 9071 9075 9072 /* walk through upper devices reassigning pools */ 9076 9073 netdev_walk_all_upper_dev_rcu(dev, ixgbe_reassign_macvlan_pool, 9077 - adapter); 9074 + &priv); 9078 9075 } 9079 9076 9080 9077 /** ··· 9251 9242 u8 queue; 9252 9243 }; 9253 9244 9254 - static int get_macvlan_queue(struct net_device *upper, void *_data) 9245 + static int get_macvlan_queue(struct net_device *upper, 9246 + struct netdev_nested_priv *priv) 9255 9247 { 9256 9248 if (netif_is_macvlan(upper)) { 9257 9249 struct ixgbe_fwd_adapter *vadapter = macvlan_accel_priv(upper); 9258 - struct upper_walk_data *data = _data; 9259 - struct ixgbe_adapter *adapter = data->adapter; 9260 - int ifindex = data->ifindex; 9250 + struct ixgbe_adapter *adapter; 9251 + struct upper_walk_data *data; 9252 + int ifindex; 9261 9253 9254 + data = (struct upper_walk_data *)priv->data; 9255 + ifindex = data->ifindex; 9256 + adapter = data->adapter; 9262 9257 if (vadapter && upper->ifindex == ifindex) { 9263 9258 data->queue = adapter->rx_ring[vadapter->rx_base_queue]->reg_idx; 9264 9259 data->action = data->queue; ··· 9278 9265 { 9279 9266 struct ixgbe_ring_feature *vmdq = &adapter->ring_feature[RING_F_VMDQ]; 9280 9267 unsigned int num_vfs = adapter->num_vfs, vf; 9268 + struct netdev_nested_priv priv; 9281 9269 struct upper_walk_data data; 9282 9270 struct net_device *upper; 9283 9271 ··· 9298 9284 data.ifindex = ifindex; 9299 9285 data.action = 0; 9300 9286 data.queue = 0; 9287 + priv.data = (void *)&data; 9301 9288 if (netdev_walk_all_upper_dev_rcu(adapter->netdev, 9302 - get_macvlan_queue, &data)) { 9289 + get_macvlan_queue, &priv)) { 9303 9290 *action = data.action; 9304 9291 *queue = data.queue; 9305 9292
+13 -11
drivers/net/ethernet/mellanox/mlxsw/spectrum.c
··· 3690 3690 return dev->netdev_ops == &mlxsw_sp_port_netdev_ops; 3691 3691 } 3692 3692 3693 - static int mlxsw_sp_lower_dev_walk(struct net_device *lower_dev, void *data) 3693 + static int mlxsw_sp_lower_dev_walk(struct net_device *lower_dev, 3694 + struct netdev_nested_priv *priv) 3694 3695 { 3695 - struct mlxsw_sp_port **p_mlxsw_sp_port = data; 3696 3696 int ret = 0; 3697 3697 3698 3698 if (mlxsw_sp_port_dev_check(lower_dev)) { 3699 - *p_mlxsw_sp_port = netdev_priv(lower_dev); 3699 + priv->data = (void *)netdev_priv(lower_dev); 3700 3700 ret = 1; 3701 3701 } 3702 3702 ··· 3705 3705 3706 3706 struct mlxsw_sp_port *mlxsw_sp_port_dev_lower_find(struct net_device *dev) 3707 3707 { 3708 - struct mlxsw_sp_port *mlxsw_sp_port; 3708 + struct netdev_nested_priv priv = { 3709 + .data = NULL, 3710 + }; 3709 3711 3710 3712 if (mlxsw_sp_port_dev_check(dev)) 3711 3713 return netdev_priv(dev); 3712 3714 3713 - mlxsw_sp_port = NULL; 3714 - netdev_walk_all_lower_dev(dev, mlxsw_sp_lower_dev_walk, &mlxsw_sp_port); 3715 + netdev_walk_all_lower_dev(dev, mlxsw_sp_lower_dev_walk, &priv); 3715 3716 3716 - return mlxsw_sp_port; 3717 + return (struct mlxsw_sp_port *)priv.data; 3717 3718 } 3718 3719 3719 3720 struct mlxsw_sp *mlxsw_sp_lower_get(struct net_device *dev) ··· 3727 3726 3728 3727 struct mlxsw_sp_port *mlxsw_sp_port_dev_lower_find_rcu(struct net_device *dev) 3729 3728 { 3730 - struct mlxsw_sp_port *mlxsw_sp_port; 3729 + struct netdev_nested_priv priv = { 3730 + .data = NULL, 3731 + }; 3731 3732 3732 3733 if (mlxsw_sp_port_dev_check(dev)) 3733 3734 return netdev_priv(dev); 3734 3735 3735 - mlxsw_sp_port = NULL; 3736 3736 netdev_walk_all_lower_dev_rcu(dev, mlxsw_sp_lower_dev_walk, 3737 - &mlxsw_sp_port); 3737 + &priv); 3738 3738 3739 - return mlxsw_sp_port; 3739 + return (struct mlxsw_sp_port *)priv.data; 3740 3740 } 3741 3741 3742 3742 struct mlxsw_sp_port *mlxsw_sp_port_lower_dev_hold(struct net_device *dev)
+8 -3
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
··· 7351 7351 return err; 7352 7352 } 7353 7353 7354 - static int __mlxsw_sp_rif_macvlan_flush(struct net_device *dev, void *data) 7354 + static int __mlxsw_sp_rif_macvlan_flush(struct net_device *dev, 7355 + struct netdev_nested_priv *priv) 7355 7356 { 7356 - struct mlxsw_sp_rif *rif = data; 7357 + struct mlxsw_sp_rif *rif = (struct mlxsw_sp_rif *)priv->data; 7357 7358 7358 7359 if (!netif_is_macvlan(dev)) 7359 7360 return 0; ··· 7365 7364 7366 7365 static int mlxsw_sp_rif_macvlan_flush(struct mlxsw_sp_rif *rif) 7367 7366 { 7367 + struct netdev_nested_priv priv = { 7368 + .data = (void *)rif, 7369 + }; 7370 + 7368 7371 if (!netif_is_macvlan_port(rif->dev)) 7369 7372 return 0; 7370 7373 7371 7374 netdev_warn(rif->dev, "Router interface is deleted. Upper macvlans will not work\n"); 7372 7375 return netdev_walk_all_upper_dev_rcu(rif->dev, 7373 - __mlxsw_sp_rif_macvlan_flush, rif); 7376 + __mlxsw_sp_rif_macvlan_flush, &priv); 7374 7377 } 7375 7378 7376 7379 static void mlxsw_sp_rif_subport_setup(struct mlxsw_sp_rif *rif,
+7 -3
drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
··· 136 136 } 137 137 138 138 static int mlxsw_sp_bridge_device_upper_rif_destroy(struct net_device *dev, 139 - void *data) 139 + struct netdev_nested_priv *priv) 140 140 { 141 - struct mlxsw_sp *mlxsw_sp = data; 141 + struct mlxsw_sp *mlxsw_sp = priv->data; 142 142 143 143 mlxsw_sp_rif_destroy_by_dev(mlxsw_sp, dev); 144 144 return 0; ··· 147 147 static void mlxsw_sp_bridge_device_rifs_destroy(struct mlxsw_sp *mlxsw_sp, 148 148 struct net_device *dev) 149 149 { 150 + struct netdev_nested_priv priv = { 151 + .data = (void *)mlxsw_sp, 152 + }; 153 + 150 154 mlxsw_sp_rif_destroy_by_dev(mlxsw_sp, dev); 151 155 netdev_walk_all_upper_dev_rcu(dev, 152 156 mlxsw_sp_bridge_device_upper_rif_destroy, 153 - mlxsw_sp); 157 + &priv); 154 158 } 155 159 156 160 static int mlxsw_sp_bridge_device_vxlan_init(struct mlxsw_sp_bridge *bridge,
+6 -3
drivers/net/ethernet/rocker/rocker_main.c
··· 3099 3099 struct rocker_port *port; 3100 3100 }; 3101 3101 3102 - static int rocker_lower_dev_walk(struct net_device *lower_dev, void *_data) 3102 + static int rocker_lower_dev_walk(struct net_device *lower_dev, 3103 + struct netdev_nested_priv *priv) 3103 3104 { 3104 - struct rocker_walk_data *data = _data; 3105 + struct rocker_walk_data *data = (struct rocker_walk_data *)priv->data; 3105 3106 int ret = 0; 3106 3107 3107 3108 if (rocker_port_dev_check_under(lower_dev, data->rocker)) { ··· 3116 3115 struct rocker_port *rocker_port_dev_lower_find(struct net_device *dev, 3117 3116 struct rocker *rocker) 3118 3117 { 3118 + struct netdev_nested_priv priv; 3119 3119 struct rocker_walk_data data; 3120 3120 3121 3121 if (rocker_port_dev_check_under(dev, rocker)) ··· 3124 3122 3125 3123 data.rocker = rocker; 3126 3124 data.port = NULL; 3127 - netdev_walk_all_lower_dev(dev, rocker_lower_dev_walk, &data); 3125 + priv.data = (void *)&data; 3126 + netdev_walk_all_lower_dev(dev, rocker_lower_dev_walk, &priv); 3128 3127 3129 3128 return data.port; 3130 3129 }
+7 -3
drivers/net/wireless/quantenna/qtnfmac/core.c
··· 671 671 return ndev->netdev_ops == &qtnf_netdev_ops; 672 672 } 673 673 674 - static int qtnf_check_br_ports(struct net_device *dev, void *data) 674 + static int qtnf_check_br_ports(struct net_device *dev, 675 + struct netdev_nested_priv *priv) 675 676 { 676 - struct net_device *ndev = data; 677 + struct net_device *ndev = (struct net_device *)priv->data; 677 678 678 679 if (dev != ndev && netdev_port_same_parent_id(dev, ndev)) 679 680 return -ENOTSUPP; ··· 687 686 { 688 687 struct net_device *ndev = netdev_notifier_info_to_dev(ptr); 689 688 const struct netdev_notifier_changeupper_info *info; 689 + struct netdev_nested_priv priv = { 690 + .data = (void *)ndev, 691 + }; 690 692 struct net_device *brdev; 691 693 struct qtnf_vif *vif; 692 694 struct qtnf_bus *bus; ··· 729 725 } else { 730 726 ret = netdev_walk_all_lower_dev(brdev, 731 727 qtnf_check_br_ports, 732 - ndev); 728 + &priv); 733 729 } 734 730 735 731 break;
+10 -6
include/linux/netdevice.h
··· 4455 4455 extern int dev_tx_weight; 4456 4456 extern int gro_normal_batch; 4457 4457 4458 + struct netdev_nested_priv { 4459 + void *data; 4460 + }; 4461 + 4458 4462 bool netdev_has_upper_dev(struct net_device *dev, struct net_device *upper_dev); 4459 4463 struct net_device *netdev_upper_get_next_dev_rcu(struct net_device *dev, 4460 4464 struct list_head **iter); ··· 4474 4470 4475 4471 int netdev_walk_all_upper_dev_rcu(struct net_device *dev, 4476 4472 int (*fn)(struct net_device *upper_dev, 4477 - void *data), 4478 - void *data); 4473 + struct netdev_nested_priv *priv), 4474 + struct netdev_nested_priv *priv); 4479 4475 4480 4476 bool netdev_has_upper_dev_all_rcu(struct net_device *dev, 4481 4477 struct net_device *upper_dev); ··· 4512 4508 struct list_head **iter); 4513 4509 int netdev_walk_all_lower_dev(struct net_device *dev, 4514 4510 int (*fn)(struct net_device *lower_dev, 4515 - void *data), 4516 - void *data); 4511 + struct netdev_nested_priv *priv), 4512 + struct netdev_nested_priv *priv); 4517 4513 int netdev_walk_all_lower_dev_rcu(struct net_device *dev, 4518 4514 int (*fn)(struct net_device *lower_dev, 4519 - void *data), 4520 - void *data); 4515 + struct netdev_nested_priv *priv), 4516 + struct netdev_nested_priv *priv); 4521 4517 4522 4518 void *netdev_adjacent_get_private(struct list_head *adj_list); 4523 4519 void *netdev_lower_get_first_private_rcu(struct net_device *dev);
+18 -8
net/bridge/br_arp_nd_proxy.c
··· 88 88 } 89 89 } 90 90 91 - static int br_chk_addr_ip(struct net_device *dev, void *data) 91 + static int br_chk_addr_ip(struct net_device *dev, 92 + struct netdev_nested_priv *priv) 92 93 { 93 - __be32 ip = *(__be32 *)data; 94 + __be32 ip = *(__be32 *)priv->data; 94 95 struct in_device *in_dev; 95 96 __be32 addr = 0; 96 97 ··· 108 107 109 108 static bool br_is_local_ip(struct net_device *dev, __be32 ip) 110 109 { 111 - if (br_chk_addr_ip(dev, &ip)) 110 + struct netdev_nested_priv priv = { 111 + .data = (void *)&ip, 112 + }; 113 + 114 + if (br_chk_addr_ip(dev, &priv)) 112 115 return true; 113 116 114 117 /* check if ip is configured on upper dev */ 115 - if (netdev_walk_all_upper_dev_rcu(dev, br_chk_addr_ip, &ip)) 118 + if (netdev_walk_all_upper_dev_rcu(dev, br_chk_addr_ip, &priv)) 116 119 return true; 117 120 118 121 return false; ··· 366 361 } 367 362 } 368 363 369 - static int br_chk_addr_ip6(struct net_device *dev, void *data) 364 + static int br_chk_addr_ip6(struct net_device *dev, 365 + struct netdev_nested_priv *priv) 370 366 { 371 - struct in6_addr *addr = (struct in6_addr *)data; 367 + struct in6_addr *addr = (struct in6_addr *)priv->data; 372 368 373 369 if (ipv6_chk_addr(dev_net(dev), addr, dev, 0)) 374 370 return 1; ··· 380 374 static bool br_is_local_ip6(struct net_device *dev, struct in6_addr *addr) 381 375 382 376 { 383 - if (br_chk_addr_ip6(dev, addr)) 377 + struct netdev_nested_priv priv = { 378 + .data = (void *)addr, 379 + }; 380 + 381 + if (br_chk_addr_ip6(dev, &priv)) 384 382 return true; 385 383 386 384 /* check if ip is configured on upper dev */ 387 - if (netdev_walk_all_upper_dev_rcu(dev, br_chk_addr_ip6, addr)) 385 + if (netdev_walk_all_upper_dev_rcu(dev, br_chk_addr_ip6, &priv)) 388 386 return true; 389 387 390 388 return false;
+13 -7
net/bridge/br_vlan.c
··· 1360 1360 } 1361 1361 1362 1362 static int br_vlan_is_bind_vlan_dev_fn(struct net_device *dev, 1363 - __always_unused void *data) 1363 + __always_unused struct netdev_nested_priv *priv) 1364 1364 { 1365 1365 return br_vlan_is_bind_vlan_dev(dev); 1366 1366 } ··· 1383 1383 }; 1384 1384 1385 1385 static int br_vlan_match_bind_vlan_dev_fn(struct net_device *dev, 1386 - void *data_in) 1386 + struct netdev_nested_priv *priv) 1387 1387 { 1388 - struct br_vlan_bind_walk_data *data = data_in; 1388 + struct br_vlan_bind_walk_data *data = priv->data; 1389 1389 int found = 0; 1390 1390 1391 1391 if (br_vlan_is_bind_vlan_dev(dev) && ··· 1403 1403 struct br_vlan_bind_walk_data data = { 1404 1404 .vid = vid, 1405 1405 }; 1406 + struct netdev_nested_priv priv = { 1407 + .data = (void *)&data, 1408 + }; 1406 1409 1407 1410 rcu_read_lock(); 1408 1411 netdev_walk_all_upper_dev_rcu(dev, br_vlan_match_bind_vlan_dev_fn, 1409 - &data); 1412 + &priv); 1410 1413 rcu_read_unlock(); 1411 1414 1412 1415 return data.result; ··· 1490 1487 }; 1491 1488 1492 1489 static int br_vlan_link_state_change_fn(struct net_device *vlan_dev, 1493 - void *data_in) 1490 + struct netdev_nested_priv *priv) 1494 1491 { 1495 - struct br_vlan_link_state_walk_data *data = data_in; 1492 + struct br_vlan_link_state_walk_data *data = priv->data; 1496 1493 1497 1494 if (br_vlan_is_bind_vlan_dev(vlan_dev)) 1498 1495 br_vlan_set_vlan_dev_state(data->br, vlan_dev); ··· 1506 1503 struct br_vlan_link_state_walk_data data = { 1507 1504 .br = br 1508 1505 }; 1506 + struct netdev_nested_priv priv = { 1507 + .data = (void *)&data, 1508 + }; 1509 1509 1510 1510 rcu_read_lock(); 1511 1511 netdev_walk_all_upper_dev_rcu(dev, br_vlan_link_state_change_fn, 1512 - &data); 1512 + &priv); 1513 1513 rcu_read_unlock(); 1514 1514 } 1515 1515
+37 -22
net/core/dev.c
··· 6812 6812 return NULL; 6813 6813 } 6814 6814 6815 - static int ____netdev_has_upper_dev(struct net_device *upper_dev, void *data) 6815 + static int ____netdev_has_upper_dev(struct net_device *upper_dev, 6816 + struct netdev_nested_priv *priv) 6816 6817 { 6817 - struct net_device *dev = data; 6818 + struct net_device *dev = (struct net_device *)priv->data; 6818 6819 6819 6820 return upper_dev == dev; 6820 6821 } ··· 6832 6831 bool netdev_has_upper_dev(struct net_device *dev, 6833 6832 struct net_device *upper_dev) 6834 6833 { 6834 + struct netdev_nested_priv priv = { 6835 + .data = (void *)upper_dev, 6836 + }; 6837 + 6835 6838 ASSERT_RTNL(); 6836 6839 6837 6840 return netdev_walk_all_upper_dev_rcu(dev, ____netdev_has_upper_dev, 6838 - upper_dev); 6841 + &priv); 6839 6842 } 6840 6843 EXPORT_SYMBOL(netdev_has_upper_dev); 6841 6844 ··· 6856 6851 bool netdev_has_upper_dev_all_rcu(struct net_device *dev, 6857 6852 struct net_device *upper_dev) 6858 6853 { 6854 + struct netdev_nested_priv priv = { 6855 + .data = (void *)upper_dev, 6856 + }; 6857 + 6859 6858 return !!netdev_walk_all_upper_dev_rcu(dev, ____netdev_has_upper_dev, 6860 - upper_dev); 6859 + &priv); 6861 6860 } 6862 6861 EXPORT_SYMBOL(netdev_has_upper_dev_all_rcu); 6863 6862 ··· 7006 6997 7007 6998 static int __netdev_walk_all_upper_dev(struct net_device *dev, 7008 6999 int (*fn)(struct net_device *dev, 7009 - void *data), 7010 - void *data) 7000 + struct netdev_nested_priv *priv), 7001 + struct netdev_nested_priv *priv) 7011 7002 { 7012 7003 struct net_device *udev, *next, *now, *dev_stack[MAX_NEST_DEV + 1]; 7013 7004 struct list_head *niter, *iter, *iter_stack[MAX_NEST_DEV + 1]; ··· 7019 7010 7020 7011 while (1) { 7021 7012 if (now != dev) { 7022 - ret = fn(now, data); 7013 + ret = fn(now, priv); 7023 7014 if (ret) 7024 7015 return ret; 7025 7016 } ··· 7055 7046 7056 7047 int netdev_walk_all_upper_dev_rcu(struct net_device *dev, 7057 7048 int (*fn)(struct net_device *dev, 7058 - void *data), 7059 - void *data) 7049 + struct netdev_nested_priv *priv), 7050 + struct netdev_nested_priv *priv) 7060 7051 { 7061 7052 struct net_device *udev, *next, *now, *dev_stack[MAX_NEST_DEV + 1]; 7062 7053 struct list_head *niter, *iter, *iter_stack[MAX_NEST_DEV + 1]; ··· 7067 7058 7068 7059 while (1) { 7069 7060 if (now != dev) { 7070 - ret = fn(now, data); 7061 + ret = fn(now, priv); 7071 7062 if (ret) 7072 7063 return ret; 7073 7064 } ··· 7103 7094 static bool __netdev_has_upper_dev(struct net_device *dev, 7104 7095 struct net_device *upper_dev) 7105 7096 { 7097 + struct netdev_nested_priv priv = { 7098 + .data = (void *)upper_dev, 7099 + }; 7100 + 7106 7101 ASSERT_RTNL(); 7107 7102 7108 7103 return __netdev_walk_all_upper_dev(dev, ____netdev_has_upper_dev, 7109 - upper_dev); 7104 + &priv); 7110 7105 } 7111 7106 7112 7107 /** ··· 7228 7215 7229 7216 int netdev_walk_all_lower_dev(struct net_device *dev, 7230 7217 int (*fn)(struct net_device *dev, 7231 - void *data), 7232 - void *data) 7218 + struct netdev_nested_priv *priv), 7219 + struct netdev_nested_priv *priv) 7233 7220 { 7234 7221 struct net_device *ldev, *next, *now, *dev_stack[MAX_NEST_DEV + 1]; 7235 7222 struct list_head *niter, *iter, *iter_stack[MAX_NEST_DEV + 1]; ··· 7240 7227 7241 7228 while (1) { 7242 7229 if (now != dev) { 7243 - ret = fn(now, data); 7230 + ret = fn(now, priv); 7244 7231 if (ret) 7245 7232 return ret; 7246 7233 } ··· 7275 7262 7276 7263 static int __netdev_walk_all_lower_dev(struct net_device *dev, 7277 7264 int (*fn)(struct net_device *dev, 7278 - void *data), 7279 - void *data) 7265 + struct netdev_nested_priv *priv), 7266 + struct netdev_nested_priv *priv) 7280 7267 { 7281 7268 struct net_device *ldev, *next, *now, *dev_stack[MAX_NEST_DEV + 1]; 7282 7269 struct list_head *niter, *iter, *iter_stack[MAX_NEST_DEV + 1]; ··· 7288 7275 7289 7276 while (1) { 7290 7277 if (now != dev) { 7291 - ret = fn(now, data); 7278 + ret = fn(now, priv); 7292 7279 if (ret) 7293 7280 return ret; 7294 7281 } ··· 7377 7364 return max_depth; 7378 7365 } 7379 7366 7380 - static int __netdev_update_upper_level(struct net_device *dev, void *data) 7367 + static int __netdev_update_upper_level(struct net_device *dev, 7368 + struct netdev_nested_priv *__unused) 7381 7369 { 7382 7370 dev->upper_level = __netdev_upper_depth(dev) + 1; 7383 7371 return 0; 7384 7372 } 7385 7373 7386 - static int __netdev_update_lower_level(struct net_device *dev, void *data) 7374 + static int __netdev_update_lower_level(struct net_device *dev, 7375 + struct netdev_nested_priv *__unused) 7387 7376 { 7388 7377 dev->lower_level = __netdev_lower_depth(dev) + 1; 7389 7378 return 0; ··· 7393 7378 7394 7379 int netdev_walk_all_lower_dev_rcu(struct net_device *dev, 7395 7380 int (*fn)(struct net_device *dev, 7396 - void *data), 7397 - void *data) 7381 + struct netdev_nested_priv *priv), 7382 + struct netdev_nested_priv *priv) 7398 7383 { 7399 7384 struct net_device *ldev, *next, *now, *dev_stack[MAX_NEST_DEV + 1]; 7400 7385 struct list_head *niter, *iter, *iter_stack[MAX_NEST_DEV + 1]; ··· 7405 7390 7406 7391 while (1) { 7407 7392 if (now != dev) { 7408 - ret = fn(now, data); 7393 + ret = fn(now, priv); 7409 7394 if (ret) 7410 7395 return ret; 7411 7396 }