mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-08 07:38:10 +00:00
nl80211: Allow set network namespace by fd
Added new NL80211_ATTR_NETNS_FD which allows to set namespace via nl80211 by fd. Signed-off-by: Vadim Kochan <vadim4j@gmail.com> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
This commit is contained in:
parent
fa7e1fbcb5
commit
4b681c82d2
3 changed files with 14 additions and 5 deletions
|
@ -2098,6 +2098,8 @@ enum nl80211_attrs {
|
||||||
|
|
||||||
NL80211_ATTR_SURVEY_RADIO_STATS,
|
NL80211_ATTR_SURVEY_RADIO_STATS,
|
||||||
|
|
||||||
|
NL80211_ATTR_NETNS_FD,
|
||||||
|
|
||||||
/* add attributes here, update the policy in nl80211.c */
|
/* add attributes here, update the policy in nl80211.c */
|
||||||
|
|
||||||
__NL80211_ATTR_AFTER_LAST,
|
__NL80211_ATTR_AFTER_LAST,
|
||||||
|
|
|
@ -361,6 +361,7 @@ struct net *get_net_ns_by_fd(int fd)
|
||||||
return ERR_PTR(-EINVAL);
|
return ERR_PTR(-EINVAL);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
EXPORT_SYMBOL_GPL(get_net_ns_by_fd);
|
||||||
|
|
||||||
struct net *get_net_ns_by_pid(pid_t pid)
|
struct net *get_net_ns_by_pid(pid_t pid)
|
||||||
{
|
{
|
||||||
|
|
|
@ -397,6 +397,7 @@ static const struct nla_policy nl80211_policy[NUM_NL80211_ATTR] = {
|
||||||
[NL80211_ATTR_SMPS_MODE] = { .type = NLA_U8 },
|
[NL80211_ATTR_SMPS_MODE] = { .type = NLA_U8 },
|
||||||
[NL80211_ATTR_MAC_MASK] = { .len = ETH_ALEN },
|
[NL80211_ATTR_MAC_MASK] = { .len = ETH_ALEN },
|
||||||
[NL80211_ATTR_WIPHY_SELF_MANAGED_REG] = { .type = NLA_FLAG },
|
[NL80211_ATTR_WIPHY_SELF_MANAGED_REG] = { .type = NLA_FLAG },
|
||||||
|
[NL80211_ATTR_NETNS_FD] = { .type = NLA_U32 },
|
||||||
};
|
};
|
||||||
|
|
||||||
/* policy for the key attributes */
|
/* policy for the key attributes */
|
||||||
|
@ -7762,14 +7763,19 @@ static int nl80211_wiphy_netns(struct sk_buff *skb, struct genl_info *info)
|
||||||
struct cfg80211_registered_device *rdev = info->user_ptr[0];
|
struct cfg80211_registered_device *rdev = info->user_ptr[0];
|
||||||
struct net *net;
|
struct net *net;
|
||||||
int err;
|
int err;
|
||||||
u32 pid;
|
|
||||||
|
|
||||||
if (!info->attrs[NL80211_ATTR_PID])
|
if (info->attrs[NL80211_ATTR_PID]) {
|
||||||
|
u32 pid = nla_get_u32(info->attrs[NL80211_ATTR_PID]);
|
||||||
|
|
||||||
|
net = get_net_ns_by_pid(pid);
|
||||||
|
} else if (info->attrs[NL80211_ATTR_NETNS_FD]) {
|
||||||
|
u32 fd = nla_get_u32(info->attrs[NL80211_ATTR_NETNS_FD]);
|
||||||
|
|
||||||
|
net = get_net_ns_by_fd(fd);
|
||||||
|
} else {
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
pid = nla_get_u32(info->attrs[NL80211_ATTR_PID]);
|
|
||||||
|
|
||||||
net = get_net_ns_by_pid(pid);
|
|
||||||
if (IS_ERR(net))
|
if (IS_ERR(net))
|
||||||
return PTR_ERR(net);
|
return PTR_ERR(net);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue