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

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'udp_tunnel-remove-rtnl_lock-dependency'

Stanislav Fomichev says:

====================
udp_tunnel: remove rtnl_lock dependency

Recently bnxt had to grow back a bunch of rtnl dependencies because
of udp_tunnel's infra. Add separate (global) mutext to protect
udp_tunnel state.
====================

Link: https://patch.msgid.link/20250616162117.287806-1-stfomichev@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

+176 -172
+1 -2
drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
··· 10219 10219 10220 10220 static const struct udp_tunnel_nic_info bnx2x_udp_tunnels = { 10221 10221 .sync_table = bnx2x_udp_tunnel_sync, 10222 - .flags = UDP_TUNNEL_NIC_INFO_MAY_SLEEP | 10223 - UDP_TUNNEL_NIC_INFO_OPEN_ONLY, 10222 + .flags = UDP_TUNNEL_NIC_INFO_OPEN_ONLY, 10224 10223 .tables = { 10225 10224 { .n_entries = 1, .tunnel_types = UDP_TUNNEL_TYPE_VXLAN, }, 10226 10225 { .n_entries = 1, .tunnel_types = UDP_TUNNEL_TYPE_GENEVE, },
+9 -33
drivers/net/ethernet/broadcom/bnxt/bnxt.c
··· 14055 14055 netdev_unlock(bp->dev); 14056 14056 } 14057 14057 14058 - /* Same as bnxt_lock_sp() with additional rtnl_lock */ 14059 - static void bnxt_rtnl_lock_sp(struct bnxt *bp) 14060 - { 14061 - clear_bit(BNXT_STATE_IN_SP_TASK, &bp->state); 14062 - rtnl_lock(); 14063 - netdev_lock(bp->dev); 14064 - } 14065 - 14066 - static void bnxt_rtnl_unlock_sp(struct bnxt *bp) 14067 - { 14068 - set_bit(BNXT_STATE_IN_SP_TASK, &bp->state); 14069 - netdev_unlock(bp->dev); 14070 - rtnl_unlock(); 14071 - } 14072 - 14073 14058 /* Only called from bnxt_sp_task() */ 14074 14059 static void bnxt_reset(struct bnxt *bp, bool silent) 14075 14060 { 14076 - bnxt_rtnl_lock_sp(bp); 14061 + bnxt_lock_sp(bp); 14077 14062 if (test_bit(BNXT_STATE_OPEN, &bp->state)) 14078 14063 bnxt_reset_task(bp, silent); 14079 - bnxt_rtnl_unlock_sp(bp); 14064 + bnxt_unlock_sp(bp); 14080 14065 } 14081 14066 14082 14067 /* Only called from bnxt_sp_task() */ ··· 14069 14084 { 14070 14085 int i; 14071 14086 14072 - bnxt_rtnl_lock_sp(bp); 14087 + bnxt_lock_sp(bp); 14073 14088 if (!test_bit(BNXT_STATE_OPEN, &bp->state)) { 14074 - bnxt_rtnl_unlock_sp(bp); 14089 + bnxt_unlock_sp(bp); 14075 14090 return; 14076 14091 } 14077 14092 /* Disable and flush TPA before resetting the RX ring */ ··· 14110 14125 } 14111 14126 if (bp->flags & BNXT_FLAG_TPA) 14112 14127 bnxt_set_tpa(bp, true); 14113 - bnxt_rtnl_unlock_sp(bp); 14128 + bnxt_unlock_sp(bp); 14114 14129 } 14115 14130 14116 14131 static void bnxt_fw_fatal_close(struct bnxt *bp) ··· 15002 15017 bp->fw_reset_state = BNXT_FW_RESET_STATE_OPENING; 15003 15018 fallthrough; 15004 15019 case BNXT_FW_RESET_STATE_OPENING: 15005 - while (!rtnl_trylock()) { 15020 + while (!netdev_trylock(bp->dev)) { 15006 15021 bnxt_queue_fw_reset_work(bp, HZ / 10); 15007 15022 return; 15008 15023 } 15009 - netdev_lock(bp->dev); 15010 15024 rc = bnxt_open(bp->dev); 15011 15025 if (rc) { 15012 15026 netdev_err(bp->dev, "bnxt_open() failed during FW reset\n"); 15013 15027 bnxt_fw_reset_abort(bp, rc); 15014 15028 netdev_unlock(bp->dev); 15015 - rtnl_unlock(); 15016 15029 goto ulp_start; 15017 15030 } 15018 15031 ··· 15030 15047 bnxt_dl_health_fw_status_update(bp, true); 15031 15048 } 15032 15049 netdev_unlock(bp->dev); 15033 - rtnl_unlock(); 15034 15050 bnxt_ulp_start(bp, 0); 15035 15051 bnxt_reenable_sriov(bp); 15036 15052 netdev_lock(bp->dev); ··· 15555 15573 static const struct udp_tunnel_nic_info bnxt_udp_tunnels = { 15556 15574 .set_port = bnxt_udp_tunnel_set_port, 15557 15575 .unset_port = bnxt_udp_tunnel_unset_port, 15558 - .flags = UDP_TUNNEL_NIC_INFO_MAY_SLEEP | 15559 - UDP_TUNNEL_NIC_INFO_OPEN_ONLY, 15576 + .flags = UDP_TUNNEL_NIC_INFO_OPEN_ONLY, 15560 15577 .tables = { 15561 15578 { .n_entries = 1, .tunnel_types = UDP_TUNNEL_TYPE_VXLAN, }, 15562 15579 { .n_entries = 1, .tunnel_types = UDP_TUNNEL_TYPE_GENEVE, }, ··· 15563 15582 }, bnxt_udp_tunnels_p7 = { 15564 15583 .set_port = bnxt_udp_tunnel_set_port, 15565 15584 .unset_port = bnxt_udp_tunnel_unset_port, 15566 - .flags = UDP_TUNNEL_NIC_INFO_MAY_SLEEP | 15567 - UDP_TUNNEL_NIC_INFO_OPEN_ONLY, 15585 + .flags = UDP_TUNNEL_NIC_INFO_OPEN_ONLY, 15568 15586 .tables = { 15569 15587 { .n_entries = 1, .tunnel_types = UDP_TUNNEL_TYPE_VXLAN, }, 15570 15588 { .n_entries = 1, .tunnel_types = UDP_TUNNEL_TYPE_GENEVE, }, ··· 15978 15998 rc); 15979 15999 napi_enable_locked(&bnapi->napi); 15980 16000 bnxt_db_nq_arm(bp, &cpr->cp_db, cpr->cp_raw_cons); 15981 - netif_close(dev); 16001 + bnxt_reset_task(bp, true); 15982 16002 return rc; 15983 16003 } 15984 16004 ··· 16794 16814 struct bnxt *bp = netdev_priv(dev); 16795 16815 int rc = 0; 16796 16816 16797 - rtnl_lock(); 16798 16817 netdev_lock(dev); 16799 16818 rc = pci_enable_device(bp->pdev); 16800 16819 if (rc) { ··· 16838 16859 16839 16860 resume_exit: 16840 16861 netdev_unlock(bp->dev); 16841 - rtnl_unlock(); 16842 16862 bnxt_ulp_start(bp, rc); 16843 16863 if (!rc) 16844 16864 bnxt_reenable_sriov(bp); ··· 17003 17025 int err; 17004 17026 17005 17027 netdev_info(bp->dev, "PCI Slot Resume\n"); 17006 - rtnl_lock(); 17007 17028 netdev_lock(netdev); 17008 17029 17009 17030 err = bnxt_hwrm_func_qcaps(bp); ··· 17020 17043 netif_device_attach(netdev); 17021 17044 17022 17045 netdev_unlock(netdev); 17023 - rtnl_unlock(); 17024 17046 bnxt_ulp_start(bp, err); 17025 17047 if (!err) 17026 17048 bnxt_reenable_sriov(bp);
+1 -2
drivers/net/ethernet/emulex/benet/be_main.c
··· 4031 4031 static const struct udp_tunnel_nic_info be_udp_tunnels = { 4032 4032 .set_port = be_vxlan_set_port, 4033 4033 .unset_port = be_vxlan_unset_port, 4034 - .flags = UDP_TUNNEL_NIC_INFO_MAY_SLEEP | 4035 - UDP_TUNNEL_NIC_INFO_OPEN_ONLY, 4034 + .flags = UDP_TUNNEL_NIC_INFO_OPEN_ONLY, 4036 4035 .tables = { 4037 4036 { .n_entries = 1, .tunnel_types = UDP_TUNNEL_TYPE_VXLAN, }, 4038 4037 },
-1
drivers/net/ethernet/intel/i40e/i40e_main.c
··· 15895 15895 15896 15896 pf->udp_tunnel_nic.set_port = i40e_udp_tunnel_set_port; 15897 15897 pf->udp_tunnel_nic.unset_port = i40e_udp_tunnel_unset_port; 15898 - pf->udp_tunnel_nic.flags = UDP_TUNNEL_NIC_INFO_MAY_SLEEP; 15899 15898 pf->udp_tunnel_nic.shared = &pf->udp_tunnel_shared; 15900 15899 pf->udp_tunnel_nic.tables[0].n_entries = I40E_MAX_PF_UDP_OFFLOAD_PORTS; 15901 15900 pf->udp_tunnel_nic.tables[0].tunnel_types = UDP_TUNNEL_TYPE_VXLAN |
-1
drivers/net/ethernet/intel/ice/ice_main.c
··· 4767 4767 4768 4768 pf->hw.udp_tunnel_nic.set_port = ice_udp_tunnel_set_port; 4769 4769 pf->hw.udp_tunnel_nic.unset_port = ice_udp_tunnel_unset_port; 4770 - pf->hw.udp_tunnel_nic.flags = UDP_TUNNEL_NIC_INFO_MAY_SLEEP; 4771 4770 pf->hw.udp_tunnel_nic.shared = &pf->hw.udp_tunnel_shared; 4772 4771 if (pf->hw.tnl.valid_count[TNL_VXLAN]) { 4773 4772 pf->hw.udp_tunnel_nic.tables[0].n_entries =
+1 -2
drivers/net/ethernet/mellanox/mlx4/en_netdev.c
··· 2670 2670 2671 2671 static const struct udp_tunnel_nic_info mlx4_udp_tunnels = { 2672 2672 .sync_table = mlx4_udp_tunnel_sync, 2673 - .flags = UDP_TUNNEL_NIC_INFO_MAY_SLEEP | 2674 - UDP_TUNNEL_NIC_INFO_IPV4_ONLY, 2673 + .flags = UDP_TUNNEL_NIC_INFO_IPV4_ONLY, 2675 2674 .tables = { 2676 2675 { .n_entries = 1, .tunnel_types = UDP_TUNNEL_TYPE_VXLAN, }, 2677 2676 },
+1 -2
drivers/net/ethernet/mellanox/mlx5/core/en_main.c
··· 5351 5351 5352 5352 priv->nic_info.set_port = mlx5e_vxlan_set_port; 5353 5353 priv->nic_info.unset_port = mlx5e_vxlan_unset_port; 5354 - priv->nic_info.flags = UDP_TUNNEL_NIC_INFO_MAY_SLEEP | 5355 - UDP_TUNNEL_NIC_INFO_STATIC_IANA_VXLAN; 5354 + priv->nic_info.flags = UDP_TUNNEL_NIC_INFO_STATIC_IANA_VXLAN; 5356 5355 priv->nic_info.tables[0].tunnel_types = UDP_TUNNEL_TYPE_VXLAN; 5357 5356 /* Don't count the space hard-coded to the IANA port */ 5358 5357 priv->nic_info.tables[0].n_entries =
+1 -2
drivers/net/ethernet/netronome/nfp/nfp_net_common.c
··· 2394 2394 2395 2395 static const struct udp_tunnel_nic_info nfp_udp_tunnels = { 2396 2396 .sync_table = nfp_udp_tunnel_sync, 2397 - .flags = UDP_TUNNEL_NIC_INFO_MAY_SLEEP | 2398 - UDP_TUNNEL_NIC_INFO_OPEN_ONLY, 2397 + .flags = UDP_TUNNEL_NIC_INFO_OPEN_ONLY, 2399 2398 .tables = { 2400 2399 { 2401 2400 .n_entries = NFP_NET_N_VXLAN_PORTS,
-3
drivers/net/ethernet/qlogic/qede/qede_filter.c
··· 987 987 988 988 static const struct udp_tunnel_nic_info qede_udp_tunnels_both = { 989 989 .sync_table = qede_udp_tunnel_sync, 990 - .flags = UDP_TUNNEL_NIC_INFO_MAY_SLEEP, 991 990 .tables = { 992 991 { .n_entries = 1, .tunnel_types = UDP_TUNNEL_TYPE_VXLAN, }, 993 992 { .n_entries = 1, .tunnel_types = UDP_TUNNEL_TYPE_GENEVE, }, 994 993 }, 995 994 }, qede_udp_tunnels_vxlan = { 996 995 .sync_table = qede_udp_tunnel_sync, 997 - .flags = UDP_TUNNEL_NIC_INFO_MAY_SLEEP, 998 996 .tables = { 999 997 { .n_entries = 1, .tunnel_types = UDP_TUNNEL_TYPE_VXLAN, }, 1000 998 }, 1001 999 }, qede_udp_tunnels_geneve = { 1002 1000 .sync_table = qede_udp_tunnel_sync, 1003 - .flags = UDP_TUNNEL_NIC_INFO_MAY_SLEEP, 1004 1001 .tables = { 1005 1002 { .n_entries = 1, .tunnel_types = UDP_TUNNEL_TYPE_GENEVE, }, 1006 1003 },
-1
drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c
··· 486 486 487 487 static const struct udp_tunnel_nic_info qlcnic_udp_tunnels = { 488 488 .sync_table = qlcnic_udp_tunnel_sync, 489 - .flags = UDP_TUNNEL_NIC_INFO_MAY_SLEEP, 490 489 .tables = { 491 490 { .n_entries = 1, .tunnel_types = UDP_TUNNEL_TYPE_VXLAN, }, 492 491 },
-1
drivers/net/ethernet/sfc/ef10.c
··· 3985 3985 static const struct udp_tunnel_nic_info efx_ef10_udp_tunnels = { 3986 3986 .set_port = efx_ef10_udp_tnl_set_port, 3987 3987 .unset_port = efx_ef10_udp_tnl_unset_port, 3988 - .flags = UDP_TUNNEL_NIC_INFO_MAY_SLEEP, 3989 3988 .tables = { 3990 3989 { 3991 3990 .n_entries = 16,
+4 -3
drivers/net/geneve.c
··· 41 41 /* per-network namespace private data for this module */ 42 42 struct geneve_net { 43 43 struct list_head geneve_list; 44 + /* sock_list is protected by rtnl lock */ 44 45 struct list_head sock_list; 45 46 }; 46 47 ··· 1181 1180 struct geneve_net *gn = net_generic(net, geneve_net_id); 1182 1181 struct geneve_sock *gs; 1183 1182 1184 - rcu_read_lock(); 1185 - list_for_each_entry_rcu(gs, &gn->sock_list, list) { 1183 + ASSERT_RTNL(); 1184 + 1185 + list_for_each_entry(gs, &gn->sock_list, list) { 1186 1186 if (push) { 1187 1187 udp_tunnel_push_rx_port(dev, gs->sock, 1188 1188 UDP_TUNNEL_TYPE_GENEVE); ··· 1192 1190 UDP_TUNNEL_TYPE_GENEVE); 1193 1191 } 1194 1192 } 1195 - rcu_read_unlock(); 1196 1193 } 1197 1194 1198 1195 /* Initialize the device structure. */
-2
drivers/net/netdevsim/netdevsim.h
··· 131 131 struct nsim_macsec macsec; 132 132 struct { 133 133 u32 inject_error; 134 - u32 sleep; 135 134 u32 __ports[2][NSIM_UDP_TUNNEL_N_PORTS]; 136 135 u32 (*ports)[NSIM_UDP_TUNNEL_N_PORTS]; 137 136 struct dentry *ddir; ··· 341 342 bool ipv4_only; 342 343 bool shared; 343 344 bool static_iana_vxlan; 344 - u32 sleep; 345 345 } udp_ports; 346 346 struct nsim_dev_psample *psample; 347 347 u16 esw_mode;
-12
drivers/net/netdevsim/udp_tunnels.c
··· 18 18 ret = -ns->udp_ports.inject_error; 19 19 ns->udp_ports.inject_error = 0; 20 20 21 - if (ns->udp_ports.sleep) 22 - msleep(ns->udp_ports.sleep); 23 - 24 21 if (!ret) { 25 22 if (ns->udp_ports.ports[table][entry]) { 26 23 WARN(1, "entry already in use\n"); ··· 44 47 ret = -ns->udp_ports.inject_error; 45 48 ns->udp_ports.inject_error = 0; 46 49 47 - if (ns->udp_ports.sleep) 48 - msleep(ns->udp_ports.sleep); 49 50 if (!ret) { 50 51 u32 val = be16_to_cpu(ti->port) << 16 | ti->type; 51 52 ··· 107 112 struct net_device *dev = file->private_data; 108 113 struct netdevsim *ns = netdev_priv(dev); 109 114 110 - rtnl_lock(); 111 115 if (dev->reg_state == NETREG_REGISTERED) { 112 116 memset(ns->udp_ports.ports, 0, sizeof(ns->udp_ports.__ports)); 113 117 udp_tunnel_nic_reset_ntf(dev); 114 118 } 115 - rtnl_unlock(); 116 119 117 120 return count; 118 121 } ··· 165 172 GFP_KERNEL); 166 173 if (!info) 167 174 return -ENOMEM; 168 - ns->udp_ports.sleep = nsim_dev->udp_ports.sleep; 169 175 170 176 if (nsim_dev->udp_ports.sync_all) { 171 177 info->set_port = NULL; ··· 173 181 info->sync_table = NULL; 174 182 } 175 183 176 - if (ns->udp_ports.sleep) 177 - info->flags |= UDP_TUNNEL_NIC_INFO_MAY_SLEEP; 178 184 if (nsim_dev->udp_ports.open_only) 179 185 info->flags |= UDP_TUNNEL_NIC_INFO_OPEN_ONLY; 180 186 if (nsim_dev->udp_ports.ipv4_only) ··· 207 217 &nsim_dev->udp_ports.shared); 208 218 debugfs_create_bool("udp_ports_static_iana_vxlan", 0600, nsim_dev->ddir, 209 219 &nsim_dev->udp_ports.static_iana_vxlan); 210 - debugfs_create_u32("udp_ports_sleep", 0600, nsim_dev->ddir, 211 - &nsim_dev->udp_ports.sleep); 212 220 }
+14 -21
drivers/net/vxlan/vxlan_core.c
··· 1485 1485 1486 1486 static bool __vxlan_sock_release_prep(struct vxlan_sock *vs) 1487 1487 { 1488 - struct vxlan_net *vn; 1488 + ASSERT_RTNL(); 1489 1489 1490 1490 if (!vs) 1491 1491 return false; 1492 1492 if (!refcount_dec_and_test(&vs->refcnt)) 1493 1493 return false; 1494 1494 1495 - vn = net_generic(sock_net(vs->sock->sk), vxlan_net_id); 1496 - spin_lock(&vn->sock_lock); 1497 1495 hlist_del_rcu(&vs->hlist); 1498 1496 udp_tunnel_notify_del_rx_port(vs->sock, 1499 1497 (vs->flags & VXLAN_F_GPE) ? 1500 1498 UDP_TUNNEL_TYPE_VXLAN_GPE : 1501 1499 UDP_TUNNEL_TYPE_VXLAN); 1502 - spin_unlock(&vn->sock_lock); 1503 1500 1504 1501 return true; 1505 1502 } ··· 2854 2857 2855 2858 static void vxlan_vs_del_dev(struct vxlan_dev *vxlan) 2856 2859 { 2857 - struct vxlan_net *vn = net_generic(vxlan->net, vxlan_net_id); 2860 + ASSERT_RTNL(); 2858 2861 2859 - spin_lock(&vn->sock_lock); 2860 2862 hlist_del_init_rcu(&vxlan->hlist4.hlist); 2861 2863 #if IS_ENABLED(CONFIG_IPV6) 2862 2864 hlist_del_init_rcu(&vxlan->hlist6.hlist); 2863 2865 #endif 2864 - spin_unlock(&vn->sock_lock); 2865 2866 } 2866 2867 2867 2868 static void vxlan_vs_add_dev(struct vxlan_sock *vs, struct vxlan_dev *vxlan, 2868 2869 struct vxlan_dev_node *node) 2869 2870 { 2870 - struct vxlan_net *vn = net_generic(vxlan->net, vxlan_net_id); 2871 2871 __be32 vni = vxlan->default_dst.remote_vni; 2872 2872 2873 + ASSERT_RTNL(); 2874 + 2873 2875 node->vxlan = vxlan; 2874 - spin_lock(&vn->sock_lock); 2875 2876 hlist_add_head_rcu(&node->hlist, vni_head(vs, vni)); 2876 - spin_unlock(&vn->sock_lock); 2877 2877 } 2878 2878 2879 2879 /* Setup stats when device is created */ ··· 3295 3301 struct vxlan_net *vn = net_generic(net, vxlan_net_id); 3296 3302 unsigned int i; 3297 3303 3298 - spin_lock(&vn->sock_lock); 3304 + ASSERT_RTNL(); 3305 + 3299 3306 for (i = 0; i < PORT_HASH_SIZE; ++i) { 3300 - hlist_for_each_entry_rcu(vs, &vn->sock_list[i], hlist) { 3307 + hlist_for_each_entry(vs, &vn->sock_list[i], hlist) { 3301 3308 unsigned short type; 3302 3309 3303 3310 if (vs->flags & VXLAN_F_GPE) ··· 3312 3317 udp_tunnel_drop_rx_port(dev, vs->sock, type); 3313 3318 } 3314 3319 } 3315 - spin_unlock(&vn->sock_lock); 3316 3320 } 3317 3321 3318 3322 /* Initialize the device structure. */ ··· 3542 3548 __be16 port, u32 flags, 3543 3549 int ifindex) 3544 3550 { 3545 - struct vxlan_net *vn = net_generic(net, vxlan_net_id); 3546 3551 struct vxlan_sock *vs; 3547 3552 struct socket *sock; 3548 3553 unsigned int h; 3549 3554 struct udp_tunnel_sock_cfg tunnel_cfg; 3555 + 3556 + ASSERT_RTNL(); 3550 3557 3551 3558 vs = kzalloc(sizeof(*vs), GFP_KERNEL); 3552 3559 if (!vs) ··· 3566 3571 refcount_set(&vs->refcnt, 1); 3567 3572 vs->flags = (flags & VXLAN_F_RCV_FLAGS); 3568 3573 3569 - spin_lock(&vn->sock_lock); 3570 3574 hlist_add_head_rcu(&vs->hlist, vs_head(net, port)); 3571 3575 udp_tunnel_notify_add_rx_port(sock, 3572 3576 (vs->flags & VXLAN_F_GPE) ? 3573 3577 UDP_TUNNEL_TYPE_VXLAN_GPE : 3574 3578 UDP_TUNNEL_TYPE_VXLAN); 3575 - spin_unlock(&vn->sock_lock); 3576 3579 3577 3580 /* Mark socket as an encapsulation socket. */ 3578 3581 memset(&tunnel_cfg, 0, sizeof(tunnel_cfg)); ··· 3594 3601 3595 3602 static int __vxlan_sock_add(struct vxlan_dev *vxlan, bool ipv6) 3596 3603 { 3597 - struct vxlan_net *vn = net_generic(vxlan->net, vxlan_net_id); 3598 3604 bool metadata = vxlan->cfg.flags & VXLAN_F_COLLECT_METADATA; 3599 3605 struct vxlan_sock *vs = NULL; 3600 3606 struct vxlan_dev_node *node; 3601 3607 int l3mdev_index = 0; 3608 + 3609 + ASSERT_RTNL(); 3602 3610 3603 3611 if (vxlan->cfg.remote_ifindex) 3604 3612 l3mdev_index = l3mdev_master_upper_ifindex_by_index( 3605 3613 vxlan->net, vxlan->cfg.remote_ifindex); 3606 3614 3607 3615 if (!vxlan->cfg.no_share) { 3608 - spin_lock(&vn->sock_lock); 3616 + rcu_read_lock(); 3609 3617 vs = vxlan_find_sock(vxlan->net, ipv6 ? AF_INET6 : AF_INET, 3610 3618 vxlan->cfg.dst_port, vxlan->cfg.flags, 3611 3619 l3mdev_index); 3612 3620 if (vs && !refcount_inc_not_zero(&vs->refcnt)) { 3613 - spin_unlock(&vn->sock_lock); 3621 + rcu_read_unlock(); 3614 3622 return -EBUSY; 3615 3623 } 3616 - spin_unlock(&vn->sock_lock); 3624 + rcu_read_unlock(); 3617 3625 } 3618 3626 if (!vs) 3619 3627 vs = vxlan_socket_create(vxlan->net, ipv6, ··· 4888 4894 unsigned int h; 4889 4895 4890 4896 INIT_LIST_HEAD(&vn->vxlan_list); 4891 - spin_lock_init(&vn->sock_lock); 4892 4897 vn->nexthop_notifier_block.notifier_call = vxlan_nexthop_event; 4893 4898 4894 4899 for (h = 0; h < PORT_HASH_SIZE; ++h)
+1 -1
drivers/net/vxlan/vxlan_private.h
··· 19 19 /* per-network namespace private data for this module */ 20 20 struct vxlan_net { 21 21 struct list_head vxlan_list; 22 + /* sock_list is protected by rtnl lock */ 22 23 struct hlist_head sock_list[PORT_HASH_SIZE]; 23 - spinlock_t sock_lock; 24 24 struct notifier_block nexthop_notifier_block; 25 25 }; 26 26
+7 -11
drivers/net/vxlan/vxlan_vnifilter.c
··· 40 40 struct vxlan_vni_node *v, 41 41 bool del) 42 42 { 43 - struct vxlan_net *vn = net_generic(vxlan->net, vxlan_net_id); 44 43 struct vxlan_dev_node *node; 45 44 struct vxlan_sock *vs; 46 45 47 - spin_lock(&vn->sock_lock); 46 + ASSERT_RTNL(); 47 + 48 48 if (del) { 49 49 if (!hlist_unhashed(&v->hlist4.hlist)) 50 50 hlist_del_init_rcu(&v->hlist4.hlist); ··· 52 52 if (!hlist_unhashed(&v->hlist6.hlist)) 53 53 hlist_del_init_rcu(&v->hlist6.hlist); 54 54 #endif 55 - goto out; 55 + return; 56 56 } 57 57 58 58 #if IS_ENABLED(CONFIG_IPV6) ··· 67 67 node = &v->hlist4; 68 68 hlist_add_head_rcu(&node->hlist, vni_head(vs, v->vni)); 69 69 } 70 - out: 71 - spin_unlock(&vn->sock_lock); 72 70 } 73 71 74 72 void vxlan_vs_add_vnigrp(struct vxlan_dev *vxlan, 75 73 struct vxlan_sock *vs, 76 74 bool ipv6) 77 75 { 78 - struct vxlan_net *vn = net_generic(vxlan->net, vxlan_net_id); 79 76 struct vxlan_vni_group *vg = rtnl_dereference(vxlan->vnigrp); 80 77 struct vxlan_vni_node *v, *tmp; 81 78 struct vxlan_dev_node *node; 82 79 80 + ASSERT_RTNL(); 81 + 83 82 if (!vg) 84 83 return; 85 84 86 - spin_lock(&vn->sock_lock); 87 85 list_for_each_entry_safe(v, tmp, &vg->vni_list, vlist) { 88 86 #if IS_ENABLED(CONFIG_IPV6) 89 87 if (ipv6) ··· 92 94 node->vxlan = vxlan; 93 95 hlist_add_head_rcu(&node->hlist, vni_head(vs, v->vni)); 94 96 } 95 - spin_unlock(&vn->sock_lock); 96 97 } 97 98 98 99 void vxlan_vs_del_vnigrp(struct vxlan_dev *vxlan) 99 100 { 100 101 struct vxlan_vni_group *vg = rtnl_dereference(vxlan->vnigrp); 101 - struct vxlan_net *vn = net_generic(vxlan->net, vxlan_net_id); 102 102 struct vxlan_vni_node *v, *tmp; 103 + 104 + ASSERT_RTNL(); 103 105 104 106 if (!vg) 105 107 return; 106 108 107 - spin_lock(&vn->sock_lock); 108 109 list_for_each_entry_safe(v, tmp, &vg->vni_list, vlist) { 109 110 hlist_del_init_rcu(&v->hlist4.hlist); 110 111 #if IS_ENABLED(CONFIG_IPV6) 111 112 hlist_del_init_rcu(&v->hlist6.hlist); 112 113 #endif 113 114 } 114 - spin_unlock(&vn->sock_lock); 115 115 } 116 116 117 117 static void vxlan_vnifilter_stats_get(const struct vxlan_vni_node *vninode,
+63 -24
include/net/udp_tunnel.h
··· 130 130 void udp_tunnel_notify_add_rx_port(struct socket *sock, unsigned short type); 131 131 void udp_tunnel_notify_del_rx_port(struct socket *sock, unsigned short type); 132 132 133 - static inline void udp_tunnel_get_rx_info(struct net_device *dev) 134 - { 135 - ASSERT_RTNL(); 136 - if (!(dev->features & NETIF_F_RX_UDP_TUNNEL_PORT)) 137 - return; 138 - call_netdevice_notifiers(NETDEV_UDP_TUNNEL_PUSH_INFO, dev); 139 - } 140 - 141 - static inline void udp_tunnel_drop_rx_info(struct net_device *dev) 142 - { 143 - ASSERT_RTNL(); 144 - if (!(dev->features & NETIF_F_RX_UDP_TUNNEL_PORT)) 145 - return; 146 - call_netdevice_notifiers(NETDEV_UDP_TUNNEL_DROP_INFO, dev); 147 - } 148 - 149 133 /* Transmit the skb using UDP encapsulation. */ 150 134 void udp_tunnel_xmit_skb(struct rtable *rt, struct sock *sk, struct sk_buff *skb, 151 135 __be32 src, __be32 dst, __u8 tos, __u8 ttl, ··· 206 222 #define UDP_TUNNEL_NIC_MAX_TABLES 4 207 223 208 224 enum udp_tunnel_nic_info_flags { 209 - /* Device callbacks may sleep */ 210 - UDP_TUNNEL_NIC_INFO_MAY_SLEEP = BIT(0), 211 225 /* Device only supports offloads when it's open, all ports 212 226 * will be removed before close and re-added after open. 213 227 */ 214 - UDP_TUNNEL_NIC_INFO_OPEN_ONLY = BIT(1), 228 + UDP_TUNNEL_NIC_INFO_OPEN_ONLY = BIT(0), 215 229 /* Device supports only IPv4 tunnels */ 216 - UDP_TUNNEL_NIC_INFO_IPV4_ONLY = BIT(2), 230 + UDP_TUNNEL_NIC_INFO_IPV4_ONLY = BIT(1), 217 231 /* Device has hard-coded the IANA VXLAN port (4789) as VXLAN. 218 232 * This port must not be counted towards n_entries of any table. 219 233 * Driver will not receive any callback associated with port 4789. 220 234 */ 221 - UDP_TUNNEL_NIC_INFO_STATIC_IANA_VXLAN = BIT(3), 235 + UDP_TUNNEL_NIC_INFO_STATIC_IANA_VXLAN = BIT(2), 222 236 }; 223 237 224 238 struct udp_tunnel_nic; ··· 307 325 size_t (*dump_size)(struct net_device *dev, unsigned int table); 308 326 int (*dump_write)(struct net_device *dev, unsigned int table, 309 327 struct sk_buff *skb); 328 + void (*assert_locked)(struct net_device *dev); 329 + void (*lock)(struct net_device *dev); 330 + void (*unlock)(struct net_device *dev); 310 331 }; 311 332 312 333 #ifdef CONFIG_INET ··· 338 353 udp_tunnel_nic_set_port_priv(struct net_device *dev, unsigned int table, 339 354 unsigned int idx, u8 priv) 340 355 { 341 - if (udp_tunnel_nic_ops) 356 + if (udp_tunnel_nic_ops) { 357 + udp_tunnel_nic_ops->lock(dev); 342 358 udp_tunnel_nic_ops->set_port_priv(dev, table, idx, priv); 359 + udp_tunnel_nic_ops->unlock(dev); 360 + } 361 + } 362 + 363 + static inline void udp_tunnel_nic_assert_locked(struct net_device *dev) 364 + { 365 + if (udp_tunnel_nic_ops) 366 + udp_tunnel_nic_ops->assert_locked(dev); 367 + } 368 + 369 + static inline void udp_tunnel_nic_lock(struct net_device *dev) 370 + { 371 + if (udp_tunnel_nic_ops) 372 + udp_tunnel_nic_ops->lock(dev); 373 + } 374 + 375 + static inline void udp_tunnel_nic_unlock(struct net_device *dev) 376 + { 377 + if (udp_tunnel_nic_ops) 378 + udp_tunnel_nic_ops->unlock(dev); 343 379 } 344 380 345 381 static inline void ··· 402 396 static inline size_t 403 397 udp_tunnel_nic_dump_size(struct net_device *dev, unsigned int table) 404 398 { 399 + size_t ret; 400 + 405 401 if (!udp_tunnel_nic_ops) 406 402 return 0; 407 - return udp_tunnel_nic_ops->dump_size(dev, table); 403 + 404 + udp_tunnel_nic_ops->lock(dev); 405 + ret = udp_tunnel_nic_ops->dump_size(dev, table); 406 + udp_tunnel_nic_ops->unlock(dev); 407 + 408 + return ret; 408 409 } 409 410 410 411 static inline int 411 412 udp_tunnel_nic_dump_write(struct net_device *dev, unsigned int table, 412 413 struct sk_buff *skb) 413 414 { 415 + int ret; 416 + 414 417 if (!udp_tunnel_nic_ops) 415 418 return 0; 416 - return udp_tunnel_nic_ops->dump_write(dev, table, skb); 419 + 420 + udp_tunnel_nic_ops->lock(dev); 421 + ret = udp_tunnel_nic_ops->dump_write(dev, table, skb); 422 + udp_tunnel_nic_ops->unlock(dev); 423 + 424 + return ret; 417 425 } 426 + 427 + static inline void udp_tunnel_get_rx_info(struct net_device *dev) 428 + { 429 + ASSERT_RTNL(); 430 + if (!(dev->features & NETIF_F_RX_UDP_TUNNEL_PORT)) 431 + return; 432 + udp_tunnel_nic_assert_locked(dev); 433 + call_netdevice_notifiers(NETDEV_UDP_TUNNEL_PUSH_INFO, dev); 434 + } 435 + 436 + static inline void udp_tunnel_drop_rx_info(struct net_device *dev) 437 + { 438 + ASSERT_RTNL(); 439 + if (!(dev->features & NETIF_F_RX_UDP_TUNNEL_PORT)) 440 + return; 441 + udp_tunnel_nic_assert_locked(dev); 442 + call_netdevice_notifiers(NETDEV_UDP_TUNNEL_DROP_INFO, dev); 443 + } 444 + 418 445 #endif
+2 -2
net/core/dev.c
··· 3179 3179 3180 3180 if (dev->reg_state == NETREG_REGISTERED || 3181 3181 dev->reg_state == NETREG_UNREGISTERING) { 3182 - ASSERT_RTNL(); 3183 3182 netdev_ops_assert_locked(dev); 3184 3183 3185 3184 rc = netdev_queue_update_kobjects(dev, dev->real_num_tx_queues, ··· 3228 3229 return -EINVAL; 3229 3230 3230 3231 if (dev->reg_state == NETREG_REGISTERED) { 3231 - ASSERT_RTNL(); 3232 3232 netdev_ops_assert_locked(dev); 3233 3233 3234 3234 rc = net_rx_queue_update_kobjects(dev, dev->real_num_rx_queues, ··· 10769 10771 * *before* calling udp_tunnel_get_rx_info, 10770 10772 * but *after* calling udp_tunnel_drop_rx_info. 10771 10773 */ 10774 + udp_tunnel_nic_lock(dev); 10772 10775 if (features & NETIF_F_RX_UDP_TUNNEL_PORT) { 10773 10776 dev->features = features; 10774 10777 udp_tunnel_get_rx_info(dev); 10775 10778 } else { 10776 10779 udp_tunnel_drop_rx_info(dev); 10777 10780 } 10781 + udp_tunnel_nic_unlock(dev); 10778 10782 } 10779 10783 10780 10784 if (diff & NETIF_F_HW_VLAN_CTAG_FILTER) {
+10 -6
net/ipv4/udp_tunnel_core.c
··· 134 134 struct udp_tunnel_info ti; 135 135 struct net_device *dev; 136 136 137 + ASSERT_RTNL(); 138 + 137 139 ti.type = type; 138 140 ti.sa_family = sk->sk_family; 139 141 ti.port = inet_sk(sk)->inet_sport; 140 142 141 - rcu_read_lock(); 142 - for_each_netdev_rcu(net, dev) { 143 + for_each_netdev(net, dev) { 144 + udp_tunnel_nic_lock(dev); 143 145 udp_tunnel_nic_add_port(dev, &ti); 146 + udp_tunnel_nic_unlock(dev); 144 147 } 145 - rcu_read_unlock(); 146 148 } 147 149 EXPORT_SYMBOL_GPL(udp_tunnel_notify_add_rx_port); 148 150 ··· 156 154 struct udp_tunnel_info ti; 157 155 struct net_device *dev; 158 156 157 + ASSERT_RTNL(); 158 + 159 159 ti.type = type; 160 160 ti.sa_family = sk->sk_family; 161 161 ti.port = inet_sk(sk)->inet_sport; 162 162 163 - rcu_read_lock(); 164 - for_each_netdev_rcu(net, dev) { 163 + for_each_netdev(net, dev) { 164 + udp_tunnel_nic_lock(dev); 165 165 udp_tunnel_nic_del_port(dev, &ti); 166 + udp_tunnel_nic_unlock(dev); 166 167 } 167 - rcu_read_unlock(); 168 168 } 169 169 EXPORT_SYMBOL_GPL(udp_tunnel_notify_del_rx_port); 170 170
+60 -18
net/ipv4/udp_tunnel_nic.c
··· 29 29 * struct udp_tunnel_nic - UDP tunnel port offload state 30 30 * @work: async work for talking to hardware from process context 31 31 * @dev: netdev pointer 32 + * @lock: protects all fields 32 33 * @need_sync: at least one port start changed 33 34 * @need_replay: space was freed, we need a replay of all ports 34 35 * @work_pending: @work is currently scheduled ··· 41 40 struct work_struct work; 42 41 43 42 struct net_device *dev; 43 + 44 + struct mutex lock; 44 45 45 46 u8 need_sync:1; 46 47 u8 need_replay:1; ··· 301 298 static void 302 299 udp_tunnel_nic_device_sync(struct net_device *dev, struct udp_tunnel_nic *utn) 303 300 { 304 - const struct udp_tunnel_nic_info *info = dev->udp_tunnel_nic_info; 305 - bool may_sleep; 306 - 307 301 if (!utn->need_sync) 308 302 return; 309 303 310 - /* Drivers which sleep in the callback need to update from 311 - * the workqueue, if we come from the tunnel driver's notification. 312 - */ 313 - may_sleep = info->flags & UDP_TUNNEL_NIC_INFO_MAY_SLEEP; 314 - if (!may_sleep) 315 - __udp_tunnel_nic_device_sync(dev, utn); 316 - if (may_sleep || utn->need_replay) { 317 - queue_work(udp_tunnel_nic_workqueue, &utn->work); 318 - utn->work_pending = 1; 319 - } 304 + queue_work(udp_tunnel_nic_workqueue, &utn->work); 305 + utn->work_pending = 1; 320 306 } 321 307 322 308 static bool ··· 546 554 struct udp_tunnel_nic *utn; 547 555 unsigned int i, j; 548 556 549 - ASSERT_RTNL(); 550 - 551 557 utn = dev->udp_tunnel_nic; 552 558 if (!utn) 553 559 return; 560 + 561 + mutex_lock(&utn->lock); 554 562 555 563 utn->need_sync = false; 556 564 for (i = 0; i < utn->n_tables; i++) ··· 561 569 562 570 entry->flags &= ~(UDP_TUNNEL_NIC_ENTRY_DEL | 563 571 UDP_TUNNEL_NIC_ENTRY_OP_FAIL); 564 - /* We don't release rtnl across ops */ 572 + /* We don't release utn lock across ops */ 565 573 WARN_ON(entry->flags & UDP_TUNNEL_NIC_ENTRY_FROZEN); 566 574 if (!entry->use_cnt) 567 575 continue; ··· 571 579 } 572 580 573 581 __udp_tunnel_nic_device_sync(dev, utn); 582 + 583 + mutex_unlock(&utn->lock); 574 584 } 575 585 576 586 static size_t ··· 637 643 return -EMSGSIZE; 638 644 } 639 645 646 + static void __udp_tunnel_nic_assert_locked(struct net_device *dev) 647 + { 648 + struct udp_tunnel_nic *utn; 649 + 650 + utn = dev->udp_tunnel_nic; 651 + if (utn) 652 + lockdep_assert_held(&utn->lock); 653 + } 654 + 655 + static void __udp_tunnel_nic_lock(struct net_device *dev) 656 + { 657 + struct udp_tunnel_nic *utn; 658 + 659 + utn = dev->udp_tunnel_nic; 660 + if (utn) 661 + mutex_lock(&utn->lock); 662 + } 663 + 664 + static void __udp_tunnel_nic_unlock(struct net_device *dev) 665 + { 666 + struct udp_tunnel_nic *utn; 667 + 668 + utn = dev->udp_tunnel_nic; 669 + if (utn) 670 + mutex_unlock(&utn->lock); 671 + } 672 + 640 673 static const struct udp_tunnel_nic_ops __udp_tunnel_nic_ops = { 641 674 .get_port = __udp_tunnel_nic_get_port, 642 675 .set_port_priv = __udp_tunnel_nic_set_port_priv, ··· 672 651 .reset_ntf = __udp_tunnel_nic_reset_ntf, 673 652 .dump_size = __udp_tunnel_nic_dump_size, 674 653 .dump_write = __udp_tunnel_nic_dump_write, 654 + .assert_locked = __udp_tunnel_nic_assert_locked, 655 + .lock = __udp_tunnel_nic_lock, 656 + .unlock = __udp_tunnel_nic_unlock, 675 657 }; 676 658 677 659 static void ··· 734 710 container_of(work, struct udp_tunnel_nic, work); 735 711 736 712 rtnl_lock(); 713 + mutex_lock(&utn->lock); 714 + 737 715 utn->work_pending = 0; 738 716 __udp_tunnel_nic_device_sync(utn->dev, utn); 739 717 740 718 if (utn->need_replay) 741 719 udp_tunnel_nic_replay(utn->dev, utn); 720 + 721 + mutex_unlock(&utn->lock); 742 722 rtnl_unlock(); 743 723 } 744 724 ··· 758 730 return NULL; 759 731 utn->n_tables = n_tables; 760 732 INIT_WORK(&utn->work, udp_tunnel_nic_device_sync_work); 733 + mutex_init(&utn->lock); 761 734 762 735 for (i = 0; i < n_tables; i++) { 763 736 utn->entries[i] = kcalloc(info->tables[i].n_entries, ··· 850 821 dev_hold(dev); 851 822 dev->udp_tunnel_nic = utn; 852 823 853 - if (!(info->flags & UDP_TUNNEL_NIC_INFO_OPEN_ONLY)) 824 + if (!(info->flags & UDP_TUNNEL_NIC_INFO_OPEN_ONLY)) { 825 + udp_tunnel_nic_lock(dev); 854 826 udp_tunnel_get_rx_info(dev); 827 + udp_tunnel_nic_unlock(dev); 828 + } 855 829 856 830 return 0; 857 831 } ··· 863 831 udp_tunnel_nic_unregister(struct net_device *dev, struct udp_tunnel_nic *utn) 864 832 { 865 833 const struct udp_tunnel_nic_info *info = dev->udp_tunnel_nic_info; 834 + 835 + udp_tunnel_nic_lock(dev); 866 836 867 837 /* For a shared table remove this dev from the list of sharing devices 868 838 * and if there are other devices just detach. ··· 875 841 list_for_each_entry(node, &info->shared->devices, list) 876 842 if (node->dev == dev) 877 843 break; 878 - if (list_entry_is_head(node, &info->shared->devices, list)) 844 + if (list_entry_is_head(node, &info->shared->devices, list)) { 845 + udp_tunnel_nic_unlock(dev); 879 846 return; 847 + } 880 848 881 849 list_del(&node->list); 882 850 kfree(node); ··· 888 852 if (first) { 889 853 udp_tunnel_drop_rx_info(dev); 890 854 utn->dev = first->dev; 855 + udp_tunnel_nic_unlock(dev); 891 856 goto release_dev; 892 857 } 893 858 ··· 899 862 * from the work which we will boot immediately. 900 863 */ 901 864 udp_tunnel_nic_flush(dev, utn); 865 + udp_tunnel_nic_unlock(dev); 902 866 903 867 /* Wait for the work to be done using the state, netdev core will 904 868 * retry unregister until we give up our reference on this device. ··· 948 910 return NOTIFY_DONE; 949 911 950 912 if (event == NETDEV_UP) { 913 + udp_tunnel_nic_lock(dev); 951 914 WARN_ON(!udp_tunnel_nic_is_empty(dev, utn)); 952 915 udp_tunnel_get_rx_info(dev); 916 + udp_tunnel_nic_unlock(dev); 953 917 return NOTIFY_OK; 954 918 } 955 919 if (event == NETDEV_GOING_DOWN) { 920 + udp_tunnel_nic_lock(dev); 956 921 udp_tunnel_nic_flush(dev, utn); 922 + udp_tunnel_nic_unlock(dev); 957 923 return NOTIFY_OK; 958 924 } 959 925
+1 -22
tools/testing/selftests/drivers/net/netdevsim/udp_tunnel_nic.sh
··· 266 266 echo $NSIM_ID > /sys/bus/netdevsim/new_device 267 267 else 268 268 echo 1 > $NSIM_DEV_DFS/udp_ports_open_only 269 - echo 1 > $NSIM_DEV_DFS/udp_ports_sleep 270 269 echo 1 > $NSIM_DEV_SYS/new_port 271 270 fi 272 271 NSIM_NETDEV=`get_netdev_name old_netdevs` ··· 349 350 port=0 350 351 echo $NSIM_ID > /sys/bus/netdevsim/new_device 351 352 echo 0 > $NSIM_DEV_SYS/del_port 352 - echo 1000 > $NSIM_DEV_DFS/udp_ports_sleep 353 353 echo 0 > $NSIM_DEV_SYS/new_port 354 354 NSIM_NETDEV=`get_netdev_name old_netdevs` 355 355 356 356 msg="create VxLANs" 357 - exp0=( 0 0 0 0 ) # sleep is longer than out wait 358 - new_vxlan vxlan0 10000 $NSIM_NETDEV 359 - 360 - modprobe -r vxlan 361 - modprobe -r udp_tunnel 362 - 363 - msg="remove tunnels" 364 - exp0=( 0 0 0 0 ) 365 - check_tables 366 - 367 - msg="create VxLANs" 368 - exp0=( 0 0 0 0 ) # sleep is longer than out wait 357 + exp0=( `mke 10000 1` 0 0 0 ) 369 358 new_vxlan vxlan0 10000 $NSIM_NETDEV 370 359 371 360 exp0=( 0 0 0 0 ) ··· 415 428 for port in 0 1; do 416 429 if [ $port -ne 0 ]; then 417 430 echo 1 > $NSIM_DEV_DFS/udp_ports_open_only 418 - echo 1 > $NSIM_DEV_DFS/udp_ports_sleep 419 431 fi 420 432 421 433 echo $port > $NSIM_DEV_SYS/new_port ··· 472 486 for port in 0 1; do 473 487 if [ $port -ne 0 ]; then 474 488 echo 1 > $NSIM_DEV_DFS/udp_ports_open_only 475 - echo 1 > $NSIM_DEV_DFS/udp_ports_sleep 476 489 fi 477 490 478 491 echo $port > $NSIM_DEV_SYS/new_port ··· 528 543 for port in 0 1; do 529 544 if [ $port -ne 0 ]; then 530 545 echo 1 > $NSIM_DEV_DFS/udp_ports_open_only 531 - echo 1 > $NSIM_DEV_DFS/udp_ports_sleep 532 546 fi 533 547 534 548 echo $port > $NSIM_DEV_SYS/new_port ··· 557 573 for port in 0 1; do 558 574 if [ $port -ne 0 ]; then 559 575 echo 1 > $NSIM_DEV_DFS/udp_ports_open_only 560 - echo 1 > $NSIM_DEV_DFS/udp_ports_sleep 561 576 fi 562 577 563 578 echo $port > $NSIM_DEV_SYS/new_port ··· 617 634 for port in 0 1; do 618 635 if [ $port -ne 0 ]; then 619 636 echo 1 > $NSIM_DEV_DFS/udp_ports_open_only 620 - echo 1 > $NSIM_DEV_DFS/udp_ports_sleep 621 637 fi 622 638 623 639 echo $port > $NSIM_DEV_SYS/new_port ··· 672 690 for port in 0 1; do 673 691 if [ $port -ne 0 ]; then 674 692 echo 1 > $NSIM_DEV_DFS/udp_ports_open_only 675 - echo 1 > $NSIM_DEV_DFS/udp_ports_sleep 676 693 fi 677 694 678 695 echo $port > $NSIM_DEV_SYS/new_port ··· 731 750 for port in 0 1; do 732 751 if [ $port -ne 0 ]; then 733 752 echo 1 > $NSIM_DEV_DFS/udp_ports_open_only 734 - echo 1 > $NSIM_DEV_DFS/udp_ports_sleep 735 753 fi 736 754 737 755 echo $port > $NSIM_DEV_SYS/new_port ··· 789 809 echo 0 > $NSIM_DEV_SYS/del_port 790 810 791 811 echo 0 > $NSIM_DEV_DFS/udp_ports_open_only 792 - echo 1 > $NSIM_DEV_DFS/udp_ports_sleep 793 812 echo 1 > $NSIM_DEV_DFS/udp_ports_shared 794 813 795 814 old_netdevs=$(ls /sys/class/net)