@@ -135,6 +135,19 @@ static int netvsc_open(struct net_device *net)
135
135
}
136
136
137
137
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
+
138
151
/* Setting synthetic device up transparently sets
139
152
* slave as up. If open fails, then slave will be
140
153
* still be offline (and not used).
@@ -2772,31 +2785,6 @@ static struct hv_driver netvsc_drv = {
2772
2785
},
2773
2786
};
2774
2787
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
-
2800
2788
/*
2801
2789
* On Hyper-V, every VF interface is matched with a corresponding
2802
2790
* synthetic interface. The synthetic interface is presented first
@@ -2809,11 +2797,6 @@ static int netvsc_netdev_event(struct notifier_block *this,
2809
2797
struct net_device * event_dev = netdev_notifier_info_to_dev (ptr );
2810
2798
int ret = 0 ;
2811
2799
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
-
2817
2800
ret = check_dev_is_matching_vf (event_dev );
2818
2801
if (ret != 0 )
2819
2802
return NOTIFY_DONE ;
0 commit comments