linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH mac80211-next] nl80211: Allow set network namespace by fd
@ 2015-01-12 14:34 Vadim Kochan
  2015-01-14  8:47 ` Johannes Berg
  2015-01-23  9:51 ` Johannes Berg
  0 siblings, 2 replies; 8+ messages in thread
From: Vadim Kochan @ 2015-01-12 14:34 UTC (permalink / raw)
  To: johannes; +Cc: linux-wireless, Vadim Kochan

From: Vadim Kochan <vadim4j@gmail.com>

Added new NL80211_ATTR_NETNS_FD which allows to
set namespace via nl80211 by fd.

Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
---
 include/uapi/linux/nl80211.h |  2 ++
 net/core/net_namespace.c     |  1 +
 net/wireless/nl80211.c       | 16 +++++++++++-----
 3 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index a963d48..47757cb 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -2098,6 +2098,8 @@ enum nl80211_attrs {
 
 	NL80211_ATTR_SURVEY_RADIO_STATS,
 
+	NL80211_ATTR_NETNS_FD,
+
 	/* add attributes here, update the policy in nl80211.c */
 
 	__NL80211_ATTR_AFTER_LAST,
diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
index 7f15517..5d5ee8f 100644
--- a/net/core/net_namespace.c
+++ b/net/core/net_namespace.c
@@ -361,6 +361,7 @@ struct net *get_net_ns_by_fd(int fd)
 	return ERR_PTR(-EINVAL);
 }
 #endif
+EXPORT_SYMBOL_GPL(get_net_ns_by_fd);
 
 struct net *get_net_ns_by_pid(pid_t pid)
 {
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 7c2ce26..dfa3284 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -397,6 +397,7 @@ static const struct nla_policy nl80211_policy[NUM_NL80211_ATTR] = {
 	[NL80211_ATTR_SMPS_MODE] = { .type = NLA_U8 },
 	[NL80211_ATTR_MAC_MASK] = { .len = ETH_ALEN },
 	[NL80211_ATTR_WIPHY_SELF_MANAGED_REG] = { .type = NLA_FLAG },
+	[NL80211_ATTR_NETNS_FD] = { .type = NLA_U32 },
 };
 
 /* policy for the key attributes */
@@ -7744,14 +7745,19 @@ static int nl80211_wiphy_netns(struct sk_buff *skb, struct genl_info *info)
 	struct cfg80211_registered_device *rdev = info->user_ptr[0];
 	struct net *net;
 	int err;
-	u32 pid;
 
-	if (!info->attrs[NL80211_ATTR_PID])
-		return -EINVAL;
+	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]);
 
-	pid = nla_get_u32(info->attrs[NL80211_ATTR_PID]);
+		net = get_net_ns_by_fd(fd);
+	} else {
+		return -EINVAL;
+	}
 
-	net = get_net_ns_by_pid(pid);
 	if (IS_ERR(net))
 		return PTR_ERR(net);
 
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH mac80211-next] nl80211: Allow set network namespace by fd
  2015-01-12 14:34 [PATCH mac80211-next] nl80211: Allow set network namespace by fd Vadim Kochan
@ 2015-01-14  8:47 ` Johannes Berg
  2015-01-19 14:34   ` Vadim Kochan
  2015-01-23  9:51 ` Johannes Berg
  1 sibling, 1 reply; 8+ messages in thread
From: Johannes Berg @ 2015-01-14  8:47 UTC (permalink / raw)
  To: Vadim Kochan, Eric W. Biederman; +Cc: linux-wireless, netdev

On Mon, 2015-01-12 at 16:34 +0200, Vadim Kochan wrote:

> --- a/net/core/net_namespace.c
> +++ b/net/core/net_namespace.c
> @@ -361,6 +361,7 @@ struct net *get_net_ns_by_fd(int fd)
>  	return ERR_PTR(-EINVAL);
>  }
>  #endif
> +EXPORT_SYMBOL_GPL(get_net_ns_by_fd);

Does this seem OK? Vadim is adding support for using the ns-by-fd in
nl80211, which can be a module as part of cfg80211.

johannes


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH mac80211-next] nl80211: Allow set network namespace by fd
  2015-01-14  8:47 ` Johannes Berg
@ 2015-01-19 14:34   ` Vadim Kochan
  2015-01-22 11:32     ` Vadim Kochan
  0 siblings, 1 reply; 8+ messages in thread
From: Vadim Kochan @ 2015-01-19 14:34 UTC (permalink / raw)
  To: Johannes Berg; +Cc: Vadim Kochan, Eric W. Biederman, linux-wireless, netdev

On Wed, Jan 14, 2015 at 09:47:26AM +0100, Johannes Berg wrote:
> On Mon, 2015-01-12 at 16:34 +0200, Vadim Kochan wrote:
> 
> > --- a/net/core/net_namespace.c
> > +++ b/net/core/net_namespace.c
> > @@ -361,6 +361,7 @@ struct net *get_net_ns_by_fd(int fd)
> >  	return ERR_PTR(-EINVAL);
> >  }
> >  #endif
> > +EXPORT_SYMBOL_GPL(get_net_ns_by_fd);
> 
> Does this seem OK? Vadim is adding support for using the ns-by-fd in
> nl80211, which can be a module as part of cfg80211.
> 
> johannes
> 
PING ... in case if this email was missed ...

Thanks,

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH mac80211-next] nl80211: Allow set network namespace by fd
  2015-01-19 14:34   ` Vadim Kochan
@ 2015-01-22 11:32     ` Vadim Kochan
  2015-01-22 11:50       ` Johannes Berg
  0 siblings, 1 reply; 8+ messages in thread
From: Vadim Kochan @ 2015-01-22 11:32 UTC (permalink / raw)
  To: Johannes Berg; +Cc: Vadim Kochan, Eric W. Biederman, linux-wireless, netdev

On Mon, Jan 19, 2015 at 04:34:57PM +0200, Vadim Kochan wrote:
> On Wed, Jan 14, 2015 at 09:47:26AM +0100, Johannes Berg wrote:
> > On Mon, 2015-01-12 at 16:34 +0200, Vadim Kochan wrote:
> > 
> > > --- a/net/core/net_namespace.c
> > > +++ b/net/core/net_namespace.c
> > > @@ -361,6 +361,7 @@ struct net *get_net_ns_by_fd(int fd)
> > >  	return ERR_PTR(-EINVAL);
> > >  }
> > >  #endif
> > > +EXPORT_SYMBOL_GPL(get_net_ns_by_fd);
> > 
> > Does this seem OK? Vadim is adding support for using the ns-by-fd in
> > nl80211, which can be a module as part of cfg80211.
> > 
> > johannes
> > 
> PING ... in case if this email was missed ...
> 
> Thanks,

Hi Johannes,

Does it mean that patch will be rejected in case if no one answer on
this ?:)

Thanks,

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH mac80211-next] nl80211: Allow set network namespace by fd
  2015-01-22 11:32     ` Vadim Kochan
@ 2015-01-22 11:50       ` Johannes Berg
  0 siblings, 0 replies; 8+ messages in thread
From: Johannes Berg @ 2015-01-22 11:50 UTC (permalink / raw)
  To: Vadim Kochan; +Cc: Eric W. Biederman, linux-wireless, netdev

On Thu, 2015-01-22 at 13:32 +0200, Vadim Kochan wrote:
> On Mon, Jan 19, 2015 at 04:34:57PM +0200, Vadim Kochan wrote:
> > On Wed, Jan 14, 2015 at 09:47:26AM +0100, Johannes Berg wrote:
> > > On Mon, 2015-01-12 at 16:34 +0200, Vadim Kochan wrote:
> > > 
> > > > --- a/net/core/net_namespace.c
> > > > +++ b/net/core/net_namespace.c
> > > > @@ -361,6 +361,7 @@ struct net *get_net_ns_by_fd(int fd)
> > > >  	return ERR_PTR(-EINVAL);
> > > >  }
> > > >  #endif
> > > > +EXPORT_SYMBOL_GPL(get_net_ns_by_fd);
> > > 
> > > Does this seem OK? Vadim is adding support for using the ns-by-fd in
> > > nl80211, which can be a module as part of cfg80211.
> > > 
> > > johannes
> > > 
> > PING ... in case if this email was missed ...
> > 
> > Thanks,
> 
> Hi Johannes,
> 
> Does it mean that patch will be rejected in case if no one answer on
> this ?:)

Nah, I'll eventually take it :)

johannes


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH mac80211-next] nl80211: Allow set network namespace by fd
  2015-01-12 14:34 [PATCH mac80211-next] nl80211: Allow set network namespace by fd Vadim Kochan
  2015-01-14  8:47 ` Johannes Berg
@ 2015-01-23  9:51 ` Johannes Berg
  2015-01-23 10:50   ` Vadim Kochan
  1 sibling, 1 reply; 8+ messages in thread
From: Johannes Berg @ 2015-01-23  9:51 UTC (permalink / raw)
  To: Vadim Kochan; +Cc: linux-wireless

On Mon, 2015-01-12 at 16:34 +0200, Vadim Kochan wrote:
> From: Vadim Kochan <vadim4j@gmail.com>
> 
> Added new NL80211_ATTR_NETNS_FD which allows to
> set namespace via nl80211 by fd.

Applied.

johannes


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH mac80211-next] nl80211: Allow set network namespace by fd
  2015-01-23  9:51 ` Johannes Berg
@ 2015-01-23 10:50   ` Vadim Kochan
  2015-01-23 11:06     ` Johannes Berg
  0 siblings, 1 reply; 8+ messages in thread
From: Vadim Kochan @ 2015-01-23 10:50 UTC (permalink / raw)
  To: Johannes Berg; +Cc: Vadim Kochan, linux-wireless

On Fri, Jan 23, 2015 at 10:51:44AM +0100, Johannes Berg wrote:
> On Mon, 2015-01-12 at 16:34 +0200, Vadim Kochan wrote:
> > From: Vadim Kochan <vadim4j@gmail.com>
> > 
> > Added new NL80211_ATTR_NETNS_FD which allows to
> > set namespace via nl80211 by fd.
> 
> Applied.
> 
> johannes
> 

Hi,

I have changes for 'iw' for setting netns by name in the same way as it
works in 'ip link set dev XXX netns <NAME>', so it uses /var/run/netns
path by default or absolute path if it sees "/" in the netns name.

So may be I will send the patch as RFC just to see a feedback ?

Thanks,

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH mac80211-next] nl80211: Allow set network namespace by fd
  2015-01-23 10:50   ` Vadim Kochan
@ 2015-01-23 11:06     ` Johannes Berg
  0 siblings, 0 replies; 8+ messages in thread
From: Johannes Berg @ 2015-01-23 11:06 UTC (permalink / raw)
  To: Vadim Kochan; +Cc: linux-wireless

On Fri, 2015-01-23 at 12:50 +0200, Vadim Kochan wrote:

> I have changes for 'iw' for setting netns by name in the same way as it
> works in 'ip link set dev XXX netns <NAME>', so it uses /var/run/netns
> path by default or absolute path if it sees "/" in the netns name.
> 
> So may be I will send the patch as RFC just to see a feedback ?

Sure, sounds good.

johannes


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2015-01-23 11:07 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-12 14:34 [PATCH mac80211-next] nl80211: Allow set network namespace by fd Vadim Kochan
2015-01-14  8:47 ` Johannes Berg
2015-01-19 14:34   ` Vadim Kochan
2015-01-22 11:32     ` Vadim Kochan
2015-01-22 11:50       ` Johannes Berg
2015-01-23  9:51 ` Johannes Berg
2015-01-23 10:50   ` Vadim Kochan
2015-01-23 11:06     ` Johannes Berg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).