diff options
author | Johannes Berg <johannes@sipsolutions.net> | 2009-07-13 18:33:35 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2009-07-27 15:24:07 -0400 |
commit | 463d018323851a608eef52a9427b0585005c647f (patch) | |
tree | b5ad2ee6115e6b780c264022cbc20b36d22fe80c /include/net/cfg80211.h | |
parent | 5061b0c2b9066de426fbc63f1278d2210e789412 (diff) |
cfg80211: make aware of net namespaces
In order to make cfg80211/nl80211 aware of network namespaces,
we have to do the following things:
* del_virtual_intf method takes an interface index rather
than a netdev pointer - simply change this
* nl80211 uses init_net a lot, it changes to use the sender's
network namespace
* scan requests use the interface index, hold a netdev pointer
and reference instead
* we want a wiphy and its associated virtual interfaces to be
in one netns together, so
- we need to be able to change ns for a given interface, so
export dev_change_net_namespace()
- for each virtual interface set the NETIF_F_NETNS_LOCAL
flag, and clear that flag only when the wiphy changes ns,
to disallow breaking this invariant
* when a network namespace goes away, we need to reparent the
wiphy to init_net
* cfg80211 users that support creating virtual interfaces must
create them in the wiphy's namespace, currently this affects
only mac80211
The end result is that you can now switch an entire wiphy into
a different network namespace with the new command
iw phy#<idx> set netns <pid>
and all virtual interfaces will follow (or the operation fails).
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'include/net/cfg80211.h')
-rw-r--r-- | include/net/cfg80211.h | 40 |
1 files changed, 36 insertions, 4 deletions
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index a981ca8a5701..0d278777e39c 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h | |||
@@ -542,7 +542,7 @@ struct cfg80211_ssid { | |||
542 | * @ie: optional information element(s) to add into Probe Request or %NULL | 542 | * @ie: optional information element(s) to add into Probe Request or %NULL |
543 | * @ie_len: length of ie in octets | 543 | * @ie_len: length of ie in octets |
544 | * @wiphy: the wiphy this was for | 544 | * @wiphy: the wiphy this was for |
545 | * @ifidx: the interface index | 545 | * @dev: the interface |
546 | */ | 546 | */ |
547 | struct cfg80211_scan_request { | 547 | struct cfg80211_scan_request { |
548 | struct cfg80211_ssid *ssids; | 548 | struct cfg80211_ssid *ssids; |
@@ -554,7 +554,7 @@ struct cfg80211_scan_request { | |||
554 | 554 | ||
555 | /* internal */ | 555 | /* internal */ |
556 | struct wiphy *wiphy; | 556 | struct wiphy *wiphy; |
557 | int ifidx; | 557 | struct net_device *dev; |
558 | bool aborted; | 558 | bool aborted; |
559 | }; | 559 | }; |
560 | 560 | ||
@@ -845,7 +845,8 @@ struct cfg80211_bitrate_mask { | |||
845 | * @resume: wiphy device needs to be resumed | 845 | * @resume: wiphy device needs to be resumed |
846 | * | 846 | * |
847 | * @add_virtual_intf: create a new virtual interface with the given name, | 847 | * @add_virtual_intf: create a new virtual interface with the given name, |
848 | * must set the struct wireless_dev's iftype. | 848 | * must set the struct wireless_dev's iftype. Beware: You must create |
849 | * the new netdev in the wiphy's network namespace! | ||
849 | * | 850 | * |
850 | * @del_virtual_intf: remove the virtual interface determined by ifindex. | 851 | * @del_virtual_intf: remove the virtual interface determined by ifindex. |
851 | * | 852 | * |
@@ -937,7 +938,7 @@ struct cfg80211_ops { | |||
937 | int (*add_virtual_intf)(struct wiphy *wiphy, char *name, | 938 | int (*add_virtual_intf)(struct wiphy *wiphy, char *name, |
938 | enum nl80211_iftype type, u32 *flags, | 939 | enum nl80211_iftype type, u32 *flags, |
939 | struct vif_params *params); | 940 | struct vif_params *params); |
940 | int (*del_virtual_intf)(struct wiphy *wiphy, int ifindex); | 941 | int (*del_virtual_intf)(struct wiphy *wiphy, struct net_device *dev); |
941 | int (*change_virtual_intf)(struct wiphy *wiphy, | 942 | int (*change_virtual_intf)(struct wiphy *wiphy, |
942 | struct net_device *dev, | 943 | struct net_device *dev, |
943 | enum nl80211_iftype type, u32 *flags, | 944 | enum nl80211_iftype type, u32 *flags, |
@@ -1088,6 +1089,9 @@ struct cfg80211_ops { | |||
1088 | * @frag_threshold: Fragmentation threshold (dot11FragmentationThreshold); | 1089 | * @frag_threshold: Fragmentation threshold (dot11FragmentationThreshold); |
1089 | * -1 = fragmentation disabled, only odd values >= 256 used | 1090 | * -1 = fragmentation disabled, only odd values >= 256 used |
1090 | * @rts_threshold: RTS threshold (dot11RTSThreshold); -1 = RTS/CTS disabled | 1091 | * @rts_threshold: RTS threshold (dot11RTSThreshold); -1 = RTS/CTS disabled |
1092 | * @net: the network namespace this wiphy currently lives in | ||
1093 | * @netnsok: if set to false, do not allow changing the netns of this | ||
1094 | * wiphy at all | ||
1091 | */ | 1095 | */ |
1092 | struct wiphy { | 1096 | struct wiphy { |
1093 | /* assign these fields before you register the wiphy */ | 1097 | /* assign these fields before you register the wiphy */ |
@@ -1101,6 +1105,8 @@ struct wiphy { | |||
1101 | bool custom_regulatory; | 1105 | bool custom_regulatory; |
1102 | bool strict_regulatory; | 1106 | bool strict_regulatory; |
1103 | 1107 | ||
1108 | bool netnsok; | ||
1109 | |||
1104 | enum cfg80211_signal_type signal_type; | 1110 | enum cfg80211_signal_type signal_type; |
1105 | 1111 | ||
1106 | int bss_priv_size; | 1112 | int bss_priv_size; |
@@ -1139,9 +1145,35 @@ struct wiphy { | |||
1139 | /* dir in debugfs: ieee80211/<wiphyname> */ | 1145 | /* dir in debugfs: ieee80211/<wiphyname> */ |
1140 | struct dentry *debugfsdir; | 1146 | struct dentry *debugfsdir; |
1141 | 1147 | ||
1148 | #ifdef CONFIG_NET_NS | ||
1149 | /* the network namespace this phy lives in currently */ | ||
1150 | struct net *_net; | ||
1151 | #endif | ||
1152 | |||
1142 | char priv[0] __attribute__((__aligned__(NETDEV_ALIGN))); | 1153 | char priv[0] __attribute__((__aligned__(NETDEV_ALIGN))); |
1143 | }; | 1154 | }; |
1144 | 1155 | ||
1156 | #ifdef CONFIG_NET_NS | ||
1157 | static inline struct net *wiphy_net(struct wiphy *wiphy) | ||
1158 | { | ||
1159 | return wiphy->_net; | ||
1160 | } | ||
1161 | |||
1162 | static inline void wiphy_net_set(struct wiphy *wiphy, struct net *net) | ||
1163 | { | ||
1164 | wiphy->_net = net; | ||
1165 | } | ||
1166 | #else | ||
1167 | static inline struct net *wiphy_net(struct wiphy *wiphy) | ||
1168 | { | ||
1169 | return &init_net; | ||
1170 | } | ||
1171 | |||
1172 | static inline void wiphy_net_set(struct wiphy *wiphy, struct net *net) | ||
1173 | { | ||
1174 | } | ||
1175 | #endif | ||
1176 | |||
1145 | /** | 1177 | /** |
1146 | * wiphy_priv - return priv from wiphy | 1178 | * wiphy_priv - return priv from wiphy |
1147 | * | 1179 | * |