@@ -135,6 +135,19 @@ static int netvsc_open(struct net_device *net)
135135 }
136136
137137 if (vf_netdev ) {
138+ if (!net_eq (dev_net (net ), dev_net (vf_netdev ))) {
139+ ret = dev_change_net_namespace (vf_netdev , dev_net (net ),
140+ "eth%d" );
141+ if (ret )
142+ netdev_err (vf_netdev ,
143+ "Cannot move to same ns as %s: %d\n" ,
144+ net -> name , ret );
145+ else
146+ netdev_info (vf_netdev ,
147+ "Moved VF to namespace with: %s\n" ,
148+ net -> name );
149+ }
150+
138151 /* Setting synthetic device up transparently sets
139152 * slave as up. If open fails, then slave will be
140153 * still be offline (and not used).
@@ -2772,31 +2785,6 @@ static struct hv_driver netvsc_drv = {
27722785 },
27732786};
27742787
2775- /* Set VF's namespace same as the synthetic NIC */
2776- static void netvsc_event_set_vf_ns (struct net_device * ndev )
2777- {
2778- struct net_device_context * ndev_ctx = netdev_priv (ndev );
2779- struct net_device * vf_netdev ;
2780- int ret ;
2781-
2782- vf_netdev = rtnl_dereference (ndev_ctx -> vf_netdev );
2783- if (!vf_netdev )
2784- return ;
2785-
2786- if (!net_eq (dev_net (ndev ), dev_net (vf_netdev ))) {
2787- ret = dev_change_net_namespace (vf_netdev , dev_net (ndev ),
2788- "eth%d" );
2789- if (ret )
2790- netdev_err (vf_netdev ,
2791- "Cannot move to same namespace as %s: %d\n" ,
2792- ndev -> name , ret );
2793- else
2794- netdev_info (vf_netdev ,
2795- "Moved VF to namespace with: %s\n" ,
2796- ndev -> name );
2797- }
2798- }
2799-
28002788/*
28012789 * On Hyper-V, every VF interface is matched with a corresponding
28022790 * synthetic interface. The synthetic interface is presented first
@@ -2809,11 +2797,6 @@ static int netvsc_netdev_event(struct notifier_block *this,
28092797 struct net_device * event_dev = netdev_notifier_info_to_dev (ptr );
28102798 int ret = 0 ;
28112799
2812- if (event_dev -> netdev_ops == & device_ops && event == NETDEV_REGISTER ) {
2813- netvsc_event_set_vf_ns (event_dev );
2814- return NOTIFY_DONE ;
2815- }
2816-
28172800 ret = check_dev_is_matching_vf (event_dev );
28182801 if (ret != 0 )
28192802 return NOTIFY_DONE ;
0 commit comments