Netdev List
 help / color / mirror / Atom feed
* [PATCH 0/4] generic netlink namespace awareness
From: Johannes Berg @ 2009-07-10 19:51 UTC (permalink / raw)
  To: netdev-u79uwXL29TY76Z2rM5mHXA
  Cc: linux-wireless-u79uwXL29TY76Z2rM5mHXA, tgraf-G/eBtMaohhA,
	Eric W. Biederman

This patch series makes generic netlink network namespace
aware, in some way, paving the way for making wireless
completely netns aware (which I will submit to John's tree).

The required changes are basically some preparations in
core netlink, a change to make it possible to iterate net
namespaces under just RCU (which may be useful elsewhere in
the future), the actual genetlink patch and finally also
exporting get_net_ns_by_pid() which wireless will need.

The last patch (for get_net_ns_by_pid) could go through
the wireless tree as well, but I've put it in here since
it touches core code. The others probably shouldn't go
through the wireless tree since they touch more than that.

The first patch in this series fixes the last remaining
problem I had with the generic netlink one, the patches
are actually unchanged from the previous submission other
than adding patch 1 in front.

johannes

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* [PATCH 2/4] net: make namespace iteration possible under RCU
From: Johannes Berg @ 2009-07-10 19:51 UTC (permalink / raw)
  To: netdev-u79uwXL29TY76Z2rM5mHXA
  Cc: linux-wireless-u79uwXL29TY76Z2rM5mHXA, tgraf-G/eBtMaohhA,
	Eric W. Biederman
In-Reply-To: <20090710195131.504091075@sipsolutions.net>

[-- Attachment #1: 028-netns-rcu.patch --]
[-- Type: text/plain, Size: 2589 bytes --]

All we need to take care of is using proper RCU list
add/del primitives and inserting a synchronize_rcu()
at one place to make sure the exit notifiers are run
after everybody has stopped iterating the list.

Signed-off-by: Johannes Berg <johannes-cdvu00un1VgdHxzADdlk8Q@public.gmane.org>
---
 include/net/net_namespace.h |    3 +++
 net/core/net_namespace.c    |   14 +++++++++++---
 2 files changed, 14 insertions(+), 3 deletions(-)

--- wireless-testing.orig/include/net/net_namespace.h	2009-07-07 04:14:39.000000000 +0200
+++ wireless-testing/include/net/net_namespace.h	2009-07-07 12:17:17.000000000 +0200
@@ -211,6 +211,9 @@ static inline struct net *read_pnet(stru
 #define for_each_net(VAR)				\
 	list_for_each_entry(VAR, &net_namespace_list, list)
 
+#define for_each_net_rcu(VAR)				\
+	list_for_each_entry_rcu(VAR, &net_namespace_list, list)
+
 #ifdef CONFIG_NET_NS
 #define __net_init
 #define __net_exit
--- wireless-testing.orig/net/core/net_namespace.c	2009-07-07 03:43:35.000000000 +0200
+++ wireless-testing/net/core/net_namespace.c	2009-07-07 12:18:19.000000000 +0200
@@ -6,6 +6,7 @@
 #include <linux/delay.h>
 #include <linux/sched.h>
 #include <linux/idr.h>
+#include <linux/rculist.h>
 #include <net/net_namespace.h>
 #include <net/netns/generic.h>
 
@@ -127,7 +128,7 @@ static struct net *net_create(void)
 	rv = setup_net(net);
 	if (rv == 0) {
 		rtnl_lock();
-		list_add_tail(&net->list, &net_namespace_list);
+		list_add_tail_rcu(&net->list, &net_namespace_list);
 		rtnl_unlock();
 	}
 	mutex_unlock(&net_mutex);
@@ -156,9 +157,16 @@ static void cleanup_net(struct work_stru
 
 	/* Don't let anyone else find us. */
 	rtnl_lock();
-	list_del(&net->list);
+	list_del_rcu(&net->list);
 	rtnl_unlock();
 
+	/*
+	 * Another CPU might be rcu-iterating the list, wait for it.
+	 * This needs to be before calling the exit() notifiers, so
+	 * the rcu_barrier() below isn't sufficient alone.
+	 */
+	synchronize_rcu();
+
 	/* Run all of the network namespace exit methods */
 	list_for_each_entry_reverse(ops, &pernet_list, list) {
 		if (ops->exit)
@@ -219,7 +227,7 @@ static int __init net_ns_init(void)
 		panic("Could not setup the initial network namespace");
 
 	rtnl_lock();
-	list_add_tail(&init_net.list, &net_namespace_list);
+	list_add_tail_rcu(&init_net.list, &net_namespace_list);
 	rtnl_unlock();
 
 	mutex_unlock(&net_mutex);

-- 

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* [PATCH 3/4] genetlink: make netns aware
From: Johannes Berg @ 2009-07-10 19:51 UTC (permalink / raw)
  To: netdev-u79uwXL29TY76Z2rM5mHXA
  Cc: linux-wireless-u79uwXL29TY76Z2rM5mHXA, tgraf-G/eBtMaohhA,
	Eric W. Biederman
In-Reply-To: <20090710195131.504091075@sipsolutions.net>

[-- Attachment #1: 029-genl-netns.patch --]
[-- Type: text/plain, Size: 20230 bytes --]

This makes generic netlink network namespace aware. No
generic netlink families except for the controller family
are made namespace aware, they need to be checked one by
one and then set the family->netnsok member to true.

A new function genlmsg_multicast_netns() is introduced to
allow sending a multicast message in a given namespace,
for example when it applies to an object that lives in
that namespace, a new function genlmsg_multicast_allns()
to send a message to all network namespaces (for objects
that do not have an associated netns).

The function genlmsg_multicast() is changed to multicast
the message in just init_net, which is currently correct
for all generic netlink families since they only work in
init_net right now. Some will later want to work in all
net namespaces because they do not care about the netns
at all -- those will have to be converted to use one of
the new functions genlmsg_multicast_allns() or
genlmsg_multicast_netns() whenever they are made netns
aware in some way.

After this patch families can easily decide whether or
not they should be available in all net namespaces. Many
genl families us it for objects not related to networking
and should therefore be available in all namespaces, but
that will have to be done on a per family basis.

Note that this doesn't touch on the checkpoint/restart
problem where network namespaces could be used, genl
families and multicast groups are numbered globally and
I see no easy way of changing that, especially since it
must be possible to multicast to all network namespaces
for those families that do not care about netns.

Signed-off-by: Johannes Berg <johannes-cdvu00un1VgdHxzADdlk8Q@public.gmane.org>
---
 fs/dlm/netlink.c               |    2 
 include/net/genetlink.h        |   66 +++++++++++++-
 include/net/net_namespace.h    |    2 
 kernel/taskstats.c             |   10 +-
 net/irda/irnetlink.c           |    2 
 net/netfilter/ipvs/ip_vs_ctl.c |    2 
 net/netlink/genetlink.c        |  186 ++++++++++++++++++++++++++++++++---------
 net/tipc/netlink.c             |    2 
 net/wireless/nl80211.c         |   14 +--
 9 files changed, 223 insertions(+), 63 deletions(-)

--- wireless-testing.orig/include/net/genetlink.h	2009-07-08 14:11:56.000000000 +0200
+++ wireless-testing/include/net/genetlink.h	2009-07-08 15:01:54.000000000 +0200
@@ -3,6 +3,7 @@
 
 #include <linux/genetlink.h>
 #include <net/netlink.h>
+#include <net/net_namespace.h>
 
 /**
  * struct genl_multicast_group - generic netlink multicast group
@@ -27,6 +28,8 @@ struct genl_multicast_group
  * @name: name of family
  * @version: protocol version
  * @maxattr: maximum number of attributes supported
+ * @netnsok: set to true if the family can handle network
+ *	namespaces and should be presented in all of them
  * @attrbuf: buffer to store parsed attributes
  * @ops_list: list of all assigned operations
  * @family_list: family list
@@ -39,6 +42,7 @@ struct genl_family
 	char			name[GENL_NAMSIZ];
 	unsigned int		version;
 	unsigned int		maxattr;
+	bool			netnsok;
 	struct nlattr **	attrbuf;	/* private */
 	struct list_head	ops_list;	/* private */
 	struct list_head	family_list;	/* private */
@@ -62,8 +66,32 @@ struct genl_info
 	struct genlmsghdr *	genlhdr;
 	void *			userhdr;
 	struct nlattr **	attrs;
+#ifdef CONFIG_NET_NS
+	struct net *		_net;
+#endif
 };
 
+#ifdef CONFIG_NET_NS
+static inline struct net *genl_info_net(struct genl_info *info)
+{
+	return info->_net;
+}
+
+static inline void genl_info_net_set(struct genl_info *info, struct net *net)
+{
+	info->_net = net;
+}
+#else
+static inline struct net *genl_info_net(struct genl_info *info)
+{
+	return &init_net;
+}
+
+static inline void genl_info_net_set(struct genl_info *info, struct net *net)
+{
+}
+#endif
+
 /**
  * struct genl_ops - generic netlink operations
  * @cmd: command identifier
@@ -98,8 +126,6 @@ extern int genl_register_mc_group(struct
 extern void genl_unregister_mc_group(struct genl_family *family,
 				     struct genl_multicast_group *grp);
 
-extern struct sock *genl_sock;
-
 /**
  * genlmsg_put - Add generic netlink header to netlink message
  * @skb: socket buffer holding the message
@@ -170,7 +196,21 @@ static inline void genlmsg_cancel(struct
 }
 
 /**
- * genlmsg_multicast - multicast a netlink message
+ * genlmsg_multicast_netns - multicast a netlink message to a specific netns
+ * @net: the net namespace
+ * @skb: netlink message as socket buffer
+ * @pid: own netlink pid to avoid sending to yourself
+ * @group: multicast group id
+ * @flags: allocation flags
+ */
+static inline int genlmsg_multicast_netns(struct net *net, struct sk_buff *skb,
+					  u32 pid, unsigned int group, gfp_t flags)
+{
+	return nlmsg_multicast(net->genl_sock, skb, pid, group, flags);
+}
+
+/**
+ * genlmsg_multicast - multicast a netlink message to the default netns
  * @skb: netlink message as socket buffer
  * @pid: own netlink pid to avoid sending to yourself
  * @group: multicast group id
@@ -179,17 +219,29 @@ static inline void genlmsg_cancel(struct
 static inline int genlmsg_multicast(struct sk_buff *skb, u32 pid,
 				    unsigned int group, gfp_t flags)
 {
-	return nlmsg_multicast(genl_sock, skb, pid, group, flags);
+	return genlmsg_multicast_netns(&init_net, skb, pid, group, flags);
 }
 
 /**
+ * genlmsg_multicast_allns - multicast a netlink message to all net namespaces
+ * @skb: netlink message as socket buffer
+ * @pid: own netlink pid to avoid sending to yourself
+ * @group: multicast group id
+ * @flags: allocation flags
+ *
+ * This function must hold the RTNL or rcu_read_lock().
+ */
+int genlmsg_multicast_allns(struct sk_buff *skb, u32 pid,
+			    unsigned int group, gfp_t flags);
+
+/**
  * genlmsg_unicast - unicast a netlink message
  * @skb: netlink message as socket buffer
  * @pid: netlink pid of the destination socket
  */
-static inline int genlmsg_unicast(struct sk_buff *skb, u32 pid)
+static inline int genlmsg_unicast(struct net *net, struct sk_buff *skb, u32 pid)
 {
-	return nlmsg_unicast(genl_sock, skb, pid);
+	return nlmsg_unicast(net->genl_sock, skb, pid);
 }
 
 /**
@@ -199,7 +251,7 @@ static inline int genlmsg_unicast(struct
  */
 static inline int genlmsg_reply(struct sk_buff *skb, struct genl_info *info)
 {
-	return genlmsg_unicast(skb, info->snd_pid);
+	return genlmsg_unicast(genl_info_net(info), skb, info->snd_pid);
 }
 
 /**
--- wireless-testing.orig/net/netlink/genetlink.c	2009-07-08 14:11:55.000000000 +0200
+++ wireless-testing/net/netlink/genetlink.c	2009-07-08 15:01:54.000000000 +0200
@@ -18,8 +18,6 @@
 #include <net/sock.h>
 #include <net/genetlink.h>
 
-struct sock *genl_sock = NULL;
-
 static DEFINE_MUTEX(genl_mutex); /* serialization of message processing */
 
 static inline void genl_lock(void)
@@ -175,10 +173,31 @@ int genl_register_mc_group(struct genl_f
 		mc_groups_longs++;
 	}
 
-	err = netlink_change_ngroups(genl_sock,
-				     mc_groups_longs * BITS_PER_LONG);
-	if (err)
-		goto out;
+	if (family->netnsok) {
+		struct net *net;
+
+		rcu_read_lock();
+		for_each_net_rcu(net) {
+			err = netlink_change_ngroups(net->genl_sock,
+					mc_groups_longs * BITS_PER_LONG);
+			if (err) {
+				/*
+				 * No need to roll back, can only fail if
+				 * memory allocation fails and then the
+				 * number of _possible_ groups has been
+				 * increased on some sockets which is ok.
+				 */
+				rcu_read_unlock();
+				goto out;
+			}
+		}
+		rcu_read_unlock();
+	} else {
+		err = netlink_change_ngroups(init_net.genl_sock,
+					     mc_groups_longs * BITS_PER_LONG);
+		if (err)
+			goto out;
+	}
 
 	grp->id = id;
 	set_bit(id, mc_groups);
@@ -195,8 +214,14 @@ EXPORT_SYMBOL(genl_register_mc_group);
 static void __genl_unregister_mc_group(struct genl_family *family,
 				       struct genl_multicast_group *grp)
 {
+	struct net *net;
 	BUG_ON(grp->family != family);
-	netlink_clear_multicast_users(genl_sock, grp->id);
+
+	rcu_read_lock();
+	for_each_net_rcu(net)
+		netlink_clear_multicast_users(net->genl_sock, grp->id);
+	rcu_read_unlock();
+
 	clear_bit(grp->id, mc_groups);
 	list_del(&grp->list);
 	genl_ctrl_event(CTRL_CMD_DELMCAST_GRP, grp);
@@ -467,6 +492,7 @@ static int genl_rcv_msg(struct sk_buff *
 {
 	struct genl_ops *ops;
 	struct genl_family *family;
+	struct net *net = sock_net(skb->sk);
 	struct genl_info info;
 	struct genlmsghdr *hdr = nlmsg_data(nlh);
 	int hdrlen, err;
@@ -475,6 +501,10 @@ static int genl_rcv_msg(struct sk_buff *
 	if (family == NULL)
 		return -ENOENT;
 
+	/* this family doesn't exist in this netns */
+	if (!family->netnsok && !net_eq(net, &init_net))
+		return -ENOENT;
+
 	hdrlen = GENL_HDRLEN + family->hdrsize;
 	if (nlh->nlmsg_len < nlmsg_msg_size(hdrlen))
 		return -EINVAL;
@@ -492,7 +522,7 @@ static int genl_rcv_msg(struct sk_buff *
 			return -EOPNOTSUPP;
 
 		genl_unlock();
-		err = netlink_dump_start(genl_sock, skb, nlh,
+		err = netlink_dump_start(net->genl_sock, skb, nlh,
 					 ops->dumpit, ops->done);
 		genl_lock();
 		return err;
@@ -514,6 +544,7 @@ static int genl_rcv_msg(struct sk_buff *
 	info.genlhdr = nlmsg_data(nlh);
 	info.userhdr = nlmsg_data(nlh) + GENL_HDRLEN;
 	info.attrs = family->attrbuf;
+	genl_info_net_set(&info, net);
 
 	return ops->doit(skb, &info);
 }
@@ -534,6 +565,7 @@ static struct genl_family genl_ctrl = {
 	.name = "nlctrl",
 	.version = 0x2,
 	.maxattr = CTRL_ATTR_MAX,
+	.netnsok = true,
 };
 
 static int ctrl_fill_info(struct genl_family *family, u32 pid, u32 seq,
@@ -650,6 +682,7 @@ static int ctrl_dumpfamily(struct sk_buf
 
 	int i, n = 0;
 	struct genl_family *rt;
+	struct net *net = sock_net(skb->sk);
 	int chains_to_skip = cb->args[0];
 	int fams_to_skip = cb->args[1];
 
@@ -658,6 +691,8 @@ static int ctrl_dumpfamily(struct sk_buf
 			continue;
 		n = 0;
 		list_for_each_entry(rt, genl_family_chain(i), family_list) {
+			if (!rt->netnsok && !net_eq(net, &init_net))
+				continue;
 			if (++n < fams_to_skip)
 				continue;
 			if (ctrl_fill_info(rt, NETLINK_CB(cb->skb).pid,
@@ -729,6 +764,7 @@ static int ctrl_getfamily(struct sk_buff
 	if (info->attrs[CTRL_ATTR_FAMILY_ID]) {
 		u16 id = nla_get_u16(info->attrs[CTRL_ATTR_FAMILY_ID]);
 		res = genl_family_find_byid(id);
+		err = -ENOENT;
 	}
 
 	if (info->attrs[CTRL_ATTR_FAMILY_NAME]) {
@@ -736,49 +772,61 @@ static int ctrl_getfamily(struct sk_buff
 
 		name = nla_data(info->attrs[CTRL_ATTR_FAMILY_NAME]);
 		res = genl_family_find_byname(name);
+		err = -ENOENT;
 	}
 
-	if (res == NULL) {
-		err = -ENOENT;
-		goto errout;
+	if (res == NULL)
+		return err;
+
+	if (!res->netnsok && !net_eq(genl_info_net(info), &init_net)) {
+		/* family doesn't exist here */
+		return -ENOENT;
 	}
 
 	msg = ctrl_build_family_msg(res, info->snd_pid, info->snd_seq,
 				    CTRL_CMD_NEWFAMILY);
-	if (IS_ERR(msg)) {
-		err = PTR_ERR(msg);
-		goto errout;
-	}
+	if (IS_ERR(msg))
+		return PTR_ERR(msg);
 
-	err = genlmsg_reply(msg, info);
-errout:
-	return err;
+	return genlmsg_reply(msg, info);
 }
 
 static int genl_ctrl_event(int event, void *data)
 {
 	struct sk_buff *msg;
+	struct genl_family *family;
+	struct genl_multicast_group *grp;
 
-	if (genl_sock == NULL)
+	/* genl is still initialising */
+	if (!init_net.genl_sock)
 		return 0;
 
 	switch (event) {
 	case CTRL_CMD_NEWFAMILY:
 	case CTRL_CMD_DELFAMILY:
-		msg = ctrl_build_family_msg(data, 0, 0, event);
-		if (IS_ERR(msg))
-			return PTR_ERR(msg);
-
-		genlmsg_multicast(msg, 0, GENL_ID_CTRL, GFP_KERNEL);
+		family = data;
+		msg = ctrl_build_family_msg(family, 0, 0, event);
 		break;
 	case CTRL_CMD_NEWMCAST_GRP:
 	case CTRL_CMD_DELMCAST_GRP:
+		grp = data;
+		family = grp->family;
 		msg = ctrl_build_mcgrp_msg(data, 0, 0, event);
-		if (IS_ERR(msg))
-			return PTR_ERR(msg);
-
-		genlmsg_multicast(msg, 0, GENL_ID_CTRL, GFP_KERNEL);
 		break;
+	default:
+		return -EINVAL;
+	}
+
+	if (IS_ERR(msg))
+		return PTR_ERR(msg);
+
+	if (!family->netnsok) {
+		genlmsg_multicast_netns(&init_net, msg, 0,
+					GENL_ID_CTRL, GFP_KERNEL);
+	} else {
+		rcu_read_lock();
+		genlmsg_multicast_allns(msg, 0, GENL_ID_CTRL, GFP_ATOMIC);
+		rcu_read_unlock();
 	}
 
 	return 0;
@@ -795,6 +843,33 @@ static struct genl_multicast_group notif
 	.name		= "notify",
 };
 
+static int __net_init genl_pernet_init(struct net *net)
+{
+	/* we'll bump the group number right afterwards */
+	net->genl_sock = netlink_kernel_create(net, NETLINK_GENERIC, 0,
+					       genl_rcv, &genl_mutex,
+					       THIS_MODULE);
+
+	if (!net->genl_sock && net_eq(net, &init_net))
+		panic("GENL: Cannot initialize generic netlink\n");
+
+	if (!net->genl_sock)
+		return -ENOMEM;
+
+	return 0;
+}
+
+static void __net_exit genl_pernet_exit(struct net *net)
+{
+	netlink_kernel_release(net->genl_sock);
+	net->genl_sock = NULL;
+}
+
+static struct pernet_operations genl_pernet_ops = {
+	.init = genl_pernet_init,
+	.exit = genl_pernet_exit,
+};
+
 static int __init genl_init(void)
 {
 	int i, err;
@@ -804,36 +879,67 @@ static int __init genl_init(void)
 
 	err = genl_register_family(&genl_ctrl);
 	if (err < 0)
-		goto errout;
+		goto problem;
 
 	err = genl_register_ops(&genl_ctrl, &genl_ctrl_ops);
 	if (err < 0)
-		goto errout_register;
+		goto problem;
 
 	netlink_set_nonroot(NETLINK_GENERIC, NL_NONROOT_RECV);
 
-	/* we'll bump the group number right afterwards */
-	genl_sock = netlink_kernel_create(&init_net, NETLINK_GENERIC, 0,
-					  genl_rcv, &genl_mutex, THIS_MODULE);
-	if (genl_sock == NULL)
-		panic("GENL: Cannot initialize generic netlink\n");
+	err = register_pernet_subsys(&genl_pernet_ops);
+	if (err)
+		goto problem;
 
 	err = genl_register_mc_group(&genl_ctrl, &notify_grp);
 	if (err < 0)
-		goto errout_register;
+		goto problem;
 
 	return 0;
 
-errout_register:
-	genl_unregister_family(&genl_ctrl);
-errout:
+problem:
 	panic("GENL: Cannot register controller: %d\n", err);
 }
 
 subsys_initcall(genl_init);
 
-EXPORT_SYMBOL(genl_sock);
 EXPORT_SYMBOL(genl_register_ops);
 EXPORT_SYMBOL(genl_unregister_ops);
 EXPORT_SYMBOL(genl_register_family);
 EXPORT_SYMBOL(genl_unregister_family);
+
+static int genlmsg_mcast(struct sk_buff *skb, u32 pid, unsigned long group,
+			 gfp_t flags)
+{
+	struct sk_buff *tmp;
+	struct net *net, *prev = NULL;
+	int err;
+
+	for_each_net_rcu(net) {
+		if (prev) {
+			tmp = skb_clone(skb, flags);
+			if (!tmp) {
+				err = -ENOMEM;
+				goto error;
+			}
+			err = nlmsg_multicast(prev->genl_sock, tmp,
+					      pid, group, flags);
+			if (err)
+				goto error;
+		}
+
+		prev = net;
+	}
+
+	return nlmsg_multicast(prev->genl_sock, skb, pid, group, flags);
+ error:
+	kfree_skb(skb);
+	return err;
+}
+
+int genlmsg_multicast_allns(struct sk_buff *skb, u32 pid, unsigned int group,
+			    gfp_t flags)
+{
+	return genlmsg_mcast(skb, pid, group, flags);
+}
+EXPORT_SYMBOL(genlmsg_multicast_allns);
--- wireless-testing.orig/fs/dlm/netlink.c	2009-07-08 14:11:55.000000000 +0200
+++ wireless-testing/fs/dlm/netlink.c	2009-07-08 15:01:54.000000000 +0200
@@ -63,7 +63,7 @@ static int send_data(struct sk_buff *skb
 		return rv;
 	}
 
-	return genlmsg_unicast(skb, listener_nlpid);
+	return genlmsg_unicast(&init_net, skb, listener_nlpid);
 }
 
 static int user_cmd(struct sk_buff *skb, struct genl_info *info)
--- wireless-testing.orig/kernel/taskstats.c	2009-07-08 14:11:56.000000000 +0200
+++ wireless-testing/kernel/taskstats.c	2009-07-08 15:01:54.000000000 +0200
@@ -108,7 +108,7 @@ static int prepare_reply(struct genl_inf
 /*
  * Send taskstats data in @skb to listener with nl_pid @pid
  */
-static int send_reply(struct sk_buff *skb, pid_t pid)
+static int send_reply(struct sk_buff *skb, struct genl_info *info)
 {
 	struct genlmsghdr *genlhdr = nlmsg_data(nlmsg_hdr(skb));
 	void *reply = genlmsg_data(genlhdr);
@@ -120,7 +120,7 @@ static int send_reply(struct sk_buff *sk
 		return rc;
 	}
 
-	return genlmsg_unicast(skb, pid);
+	return genlmsg_reply(skb, info);
 }
 
 /*
@@ -150,7 +150,7 @@ static void send_cpu_listeners(struct sk
 			if (!skb_next)
 				break;
 		}
-		rc = genlmsg_unicast(skb_cur, s->pid);
+		rc = genlmsg_unicast(&init_net, skb_cur, s->pid);
 		if (rc == -ECONNREFUSED) {
 			s->valid = 0;
 			delcount++;
@@ -418,7 +418,7 @@ static int cgroupstats_user_cmd(struct s
 		goto err;
 	}
 
-	rc = send_reply(rep_skb, info->snd_pid);
+	rc = send_reply(rep_skb, info);
 
 err:
 	fput_light(file, fput_needed);
@@ -487,7 +487,7 @@ free_return_rc:
 	} else
 		goto err;
 
-	return send_reply(rep_skb, info->snd_pid);
+	return send_reply(rep_skb, info);
 err:
 	nlmsg_free(rep_skb);
 	return rc;
--- wireless-testing.orig/net/irda/irnetlink.c	2009-07-08 14:11:55.000000000 +0200
+++ wireless-testing/net/irda/irnetlink.c	2009-07-08 15:01:54.000000000 +0200
@@ -115,7 +115,7 @@ static int irda_nl_get_mode(struct sk_bu
 
 	genlmsg_end(msg, hdr);
 
-	return genlmsg_unicast(msg, info->snd_pid);
+	return genlmsg_reply(msg, info);
 
  err_out:
 	nlmsg_free(msg);
--- wireless-testing.orig/net/netfilter/ipvs/ip_vs_ctl.c	2009-07-08 14:11:55.000000000 +0200
+++ wireless-testing/net/netfilter/ipvs/ip_vs_ctl.c	2009-07-08 15:01:55.000000000 +0200
@@ -3231,7 +3231,7 @@ static int ip_vs_genl_get_cmd(struct sk_
 	}
 
 	genlmsg_end(msg, reply);
-	ret = genlmsg_unicast(msg, info->snd_pid);
+	ret = genlmsg_reply(msg, info);
 	goto out;
 
 nla_put_failure:
--- wireless-testing.orig/net/tipc/netlink.c	2009-07-08 14:11:55.000000000 +0200
+++ wireless-testing/net/tipc/netlink.c	2009-07-08 15:01:55.000000000 +0200
@@ -62,7 +62,7 @@ static int handle_cmd(struct sk_buff *sk
 		rep_nlh = nlmsg_hdr(rep_buf);
 		memcpy(rep_nlh, req_nlh, hdr_space);
 		rep_nlh->nlmsg_len = rep_buf->len;
-		genlmsg_unicast(rep_buf, NETLINK_CB(skb).pid);
+		genlmsg_unicast(&init_net, rep_buf, NETLINK_CB(skb).pid);
 	}
 
 	return 0;
--- wireless-testing.orig/net/wireless/nl80211.c	2009-07-08 14:12:35.000000000 +0200
+++ wireless-testing/net/wireless/nl80211.c	2009-07-08 15:01:55.000000000 +0200
@@ -596,7 +596,7 @@ static int nl80211_get_wiphy(struct sk_b
 
 	cfg80211_unlock_rdev(dev);
 
-	return genlmsg_unicast(msg, info->snd_pid);
+	return genlmsg_reply(msg, info);
 
  out_free:
 	nlmsg_free(msg);
@@ -922,7 +922,7 @@ static int nl80211_get_interface(struct 
 	dev_put(netdev);
 	cfg80211_unlock_rdev(dev);
 
-	return genlmsg_unicast(msg, info->snd_pid);
+	return genlmsg_reply(msg, info);
 
  out_free:
 	nlmsg_free(msg);
@@ -1236,7 +1236,7 @@ static int nl80211_get_key(struct sk_buf
 		goto nla_put_failure;
 
 	genlmsg_end(msg, hdr);
-	err = genlmsg_unicast(msg, info->snd_pid);
+	err = genlmsg_reply(msg, info);
 	goto out;
 
  nla_put_failure:
@@ -1811,7 +1811,7 @@ static int nl80211_get_station(struct sk
 				 dev, mac_addr, &sinfo) < 0)
 		goto out_free;
 
-	err = genlmsg_unicast(msg, info->snd_pid);
+	err = genlmsg_reply(msg, info);
 	goto out;
 
  out_free:
@@ -2280,7 +2280,7 @@ static int nl80211_get_mpath(struct sk_b
 				 dev, dst, next_hop, &pinfo) < 0)
 		goto out_free;
 
-	err = genlmsg_unicast(msg, info->snd_pid);
+	err = genlmsg_reply(msg, info);
 	goto out;
 
  out_free:
@@ -2629,7 +2629,7 @@ static int nl80211_get_mesh_params(struc
 			cur_params.dot11MeshHWMPnetDiameterTraversalTime);
 	nla_nest_end(msg, pinfoattr);
 	genlmsg_end(msg, hdr);
-	err = genlmsg_unicast(msg, info->snd_pid);
+	err = genlmsg_reply(msg, info);
 	goto out;
 
  nla_put_failure:
@@ -2817,7 +2817,7 @@ static int nl80211_get_reg(struct sk_buf
 	nla_nest_end(msg, nl_reg_rules);
 
 	genlmsg_end(msg, hdr);
-	err = genlmsg_unicast(msg, info->snd_pid);
+	err = genlmsg_reply(msg, info);
 	goto out;
 
 nla_put_failure:
--- wireless-testing.orig/include/net/net_namespace.h	2009-07-08 15:01:53.000000000 +0200
+++ wireless-testing/include/net/net_namespace.h	2009-07-08 15:01:55.000000000 +0200
@@ -26,6 +26,7 @@ struct net_device;
 struct sock;
 struct ctl_table_header;
 struct net_generic;
+struct sock;
 
 struct net {
 	atomic_t		count;		/* To decided when the network
@@ -57,6 +58,7 @@ struct net {
 	spinlock_t		rules_mod_lock;
 
 	struct sock 		*rtnl;			/* rtnetlink socket */
+	struct sock		*genl_sock;
 
 	struct netns_core	core;
 	struct netns_mib	mib;

-- 

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* [PATCH 4/4] net: move and export get_net_ns_by_pid
From: Johannes Berg @ 2009-07-10 19:51 UTC (permalink / raw)
  To: netdev-u79uwXL29TY76Z2rM5mHXA
  Cc: linux-wireless-u79uwXL29TY76Z2rM5mHXA, tgraf-G/eBtMaohhA,
	Eric W. Biederman
In-Reply-To: <20090710195131.504091075@sipsolutions.net>

[-- Attachment #1: 030-netns-export-get-by-pid.patch --]
[-- Type: text/plain, Size: 2903 bytes --]

The function get_net_ns_by_pid(), to get a network
namespace from a pid_t, will be required in cfg80211
as well. Therefore, let's move it to net_namespace.c
and export it. We can't make it a static inline in
the !NETNS case because it needs to verify that the
given pid even exists (and return -ESRCH).

Signed-off-by: Johannes Berg <johannes-cdvu00un1VgdHxzADdlk8Q@public.gmane.org>
---
 include/net/net_namespace.h |    2 ++
 net/core/net_namespace.c    |   21 +++++++++++++++++++++
 net/core/rtnetlink.c        |   21 +--------------------
 3 files changed, 24 insertions(+), 20 deletions(-)

--- wireless-testing.orig/include/net/net_namespace.h	2009-07-07 12:18:30.000000000 +0200
+++ wireless-testing/include/net/net_namespace.h	2009-07-07 12:25:42.000000000 +0200
@@ -111,6 +111,8 @@ static inline struct net *copy_net_ns(un
 
 extern struct list_head net_namespace_list;
 
+extern struct net *get_net_ns_by_pid(pid_t pid);
+
 #ifdef CONFIG_NET_NS
 extern void __put_net(struct net *net);
 
--- wireless-testing.orig/net/core/net_namespace.c	2009-07-07 12:18:19.000000000 +0200
+++ wireless-testing/net/core/net_namespace.c	2009-07-07 12:25:42.000000000 +0200
@@ -7,6 +7,7 @@
 #include <linux/sched.h>
 #include <linux/idr.h>
 #include <linux/rculist.h>
+#include <linux/nsproxy.h>
 #include <net/net_namespace.h>
 #include <net/netns/generic.h>
 
@@ -201,6 +202,26 @@ struct net *copy_net_ns(unsigned long fl
 }
 #endif
 
+struct net *get_net_ns_by_pid(pid_t pid)
+{
+	struct task_struct *tsk;
+	struct net *net;
+
+	/* Lookup the network namespace */
+	net = ERR_PTR(-ESRCH);
+	rcu_read_lock();
+	tsk = find_task_by_vpid(pid);
+	if (tsk) {
+		struct nsproxy *nsproxy;
+		nsproxy = task_nsproxy(tsk);
+		if (nsproxy)
+			net = get_net(nsproxy->net_ns);
+	}
+	rcu_read_unlock();
+	return net;
+}
+EXPORT_SYMBOL_GPL(get_net_ns_by_pid);
+
 static int __init net_ns_init(void)
 {
 	struct net_generic *ng;
--- wireless-testing.orig/net/core/rtnetlink.c	2009-07-07 12:15:29.000000000 +0200
+++ wireless-testing/net/core/rtnetlink.c	2009-07-07 12:25:42.000000000 +0200
@@ -35,7 +35,6 @@
 #include <linux/security.h>
 #include <linux/mutex.h>
 #include <linux/if_addr.h>
-#include <linux/nsproxy.h>
 
 #include <asm/uaccess.h>
 #include <asm/system.h>
@@ -52,6 +51,7 @@
 #include <net/pkt_sched.h>
 #include <net/fib_rules.h>
 #include <net/rtnetlink.h>
+#include <net/net_namespace.h>
 
 struct rtnl_link
 {
@@ -725,25 +725,6 @@ static const struct nla_policy ifla_info
 	[IFLA_INFO_DATA]	= { .type = NLA_NESTED },
 };
 
-static struct net *get_net_ns_by_pid(pid_t pid)
-{
-	struct task_struct *tsk;
-	struct net *net;
-
-	/* Lookup the network namespace */
-	net = ERR_PTR(-ESRCH);
-	rcu_read_lock();
-	tsk = find_task_by_vpid(pid);
-	if (tsk) {
-		struct nsproxy *nsproxy;
-		nsproxy = task_nsproxy(tsk);
-		if (nsproxy)
-			net = get_net(nsproxy->net_ns);
-	}
-	rcu_read_unlock();
-	return net;
-}

^ permalink raw reply

* [PATCH 1/4] netlink: use call_rcu for netlink_change_ngroups
From: Johannes Berg @ 2009-07-10 19:51 UTC (permalink / raw)
  To: netdev; +Cc: linux-wireless, tgraf, Eric W. Biederman
In-Reply-To: <20090710195131.504091075@sipsolutions.net>

[-- Attachment #1: 027-netlink-groups-realloc-rcu.patch --]
[-- Type: text/plain, Size: 3189 bytes --]

For the network namespace work in generic netlink I need
to be able to call this function under rcu_read_lock(),
otherwise the locking becomes a nightmare and more locks
would be needed. Instead, just embed a struct rcu_head
(actually a struct listeners_rcu_head that also carries
the pointer to the memory block) into the listeners
memory so we can use call_rcu() instead of synchronising
and then freeing. No rcu_barrier() is needed since this
code cannot be modular.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
---
 net/netlink/af_netlink.c |   34 ++++++++++++++++++++++++++++++----
 1 file changed, 30 insertions(+), 4 deletions(-)

--- wireless-testing.orig/net/netlink/af_netlink.c	2009-07-10 20:36:53.000000000 +0200
+++ wireless-testing/net/netlink/af_netlink.c	2009-07-10 20:51:40.000000000 +0200
@@ -83,6 +83,11 @@ struct netlink_sock {
 	struct module		*module;
 };
 
+struct listeners_rcu_head {
+	struct rcu_head rcu_head;
+	void *ptr;
+};
+
 #define NETLINK_KERNEL_SOCKET	0x1
 #define NETLINK_RECV_PKTINFO	0x2
 #define NETLINK_BROADCAST_SEND_ERROR	0x4
@@ -1487,7 +1492,8 @@ netlink_kernel_create(struct net *net, i
 	if (groups < 32)
 		groups = 32;
 
-	listeners = kzalloc(NLGRPSZ(groups), GFP_KERNEL);
+	listeners = kzalloc(NLGRPSZ(groups) + sizeof(struct listeners_rcu_head),
+			    GFP_KERNEL);
 	if (!listeners)
 		goto out_sock_release;
 
@@ -1535,6 +1541,14 @@ netlink_kernel_release(struct sock *sk)
 EXPORT_SYMBOL(netlink_kernel_release);
 
 
+static void netlink_free_old_listeners(struct rcu_head *rcu_head)
+{
+	struct listeners_rcu_head *lrh;
+
+	lrh = container_of(rcu_head, struct listeners_rcu_head, rcu_head);
+	kfree(lrh->ptr);
+}
+
 /**
  * netlink_change_ngroups - change number of multicast groups
  *
@@ -1550,6 +1564,7 @@ EXPORT_SYMBOL(netlink_kernel_release);
 int netlink_change_ngroups(struct sock *sk, unsigned int groups)
 {
 	unsigned long *listeners, *old = NULL;
+	struct listeners_rcu_head *old_rcu_head;
 	struct netlink_table *tbl = &nl_table[sk->sk_protocol];
 	int err = 0;
 
@@ -1558,7 +1573,9 @@ int netlink_change_ngroups(struct sock *
 
 	netlink_table_grab();
 	if (NLGRPSZ(tbl->groups) < NLGRPSZ(groups)) {
-		listeners = kzalloc(NLGRPSZ(groups), GFP_ATOMIC);
+		listeners = kzalloc(NLGRPSZ(groups) +
+				    sizeof(struct listeners_rcu_head),
+				    GFP_ATOMIC);
 		if (!listeners) {
 			err = -ENOMEM;
 			goto out_ungrab;
@@ -1566,13 +1583,22 @@ int netlink_change_ngroups(struct sock *
 		old = tbl->listeners;
 		memcpy(listeners, old, NLGRPSZ(tbl->groups));
 		rcu_assign_pointer(tbl->listeners, listeners);
+		/*
+		 * Free the old memory after an RCU grace period so we
+		 * don't leak it. We use call_rcu() here in order to be
+		 * able to call this function from atomic contexts. The
+		 * allocation of this memory will have reserved enough
+		 * space for struct listeners_rcu_head at the end.
+		 */
+		old_rcu_head = (void *)(tbl->listeners +
+					NLGRPLONGS(tbl->groups));
+		old_rcu_head->ptr = old;
+		call_rcu(&old_rcu_head->rcu_head, netlink_free_old_listeners);
 	}
 	tbl->groups = groups;
 
  out_ungrab:
 	netlink_table_ungrab();
-	synchronize_rcu();
-	kfree(old);
 	return err;
 }
 

-- 


^ permalink raw reply

* pull request: wireless-next-2.6 2009-07-10
From: John W. Linville @ 2009-07-10 19:48 UTC (permalink / raw)
  To: davem; +Cc: linux-wireless, netdev

Dave,

Here is the usual tsunami of wireless stuff at this stage of the
development cycle for the next release.  Included are the usual
driver updates (including movement of orinoco towards cfg80211)
and many mac80211 improvements.

Please let me know if there are problems!

Thanks,

John

---

Individual patches are available here:

	http://www.kernel.org/pub/linux/kernel/people/linville/wireless-next-2.6/

---

The following changes since commit e5a8a896f5180f2950695d2d0b79db348d200ca4:
  David S. Miller (1):
        Merge branch 'master' of master.kernel.org:/.../davem/net-2.6

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless-next-2.6.git master

Andrey Yurovsky (4):
      libertas: remove ps_supported flag, use fwcapinfo
      libertas: copy WPA keys to priv when associating
      libertas: correct card cleanup order in SPI driver
      libertas: fix card cleanup order in SDIO driver

Ari Kauppi (2):
      wl12xx: Fix incorrect warning message.
      wl12xx: Fix CMD_TEST regression via netlink.

Bob Copeland (7):
      ath5k: cleanup ath5k_hw struct
      ath5k: enable hardware LEDs
      ath5k: send buffered frames after the beacon
      ath5k: rework beacon configuration
      ath: remove unnecessary return in ath_regd_get_band_ctl
      ath5k: do not release irq across suspend/resume
      ath5k: write PCU registers on initial reset

Christian Lamparter (14):
      ar9170usb: module link in sysfs
      p54: redo rx_status into skb->cb
      p54: Move eeprom code
      p54: Move eeprom header
      p54: Move firmware code
      p54: Move LED code
      p54: Move LMAC interface definitions
      p54: Move mac80211 glue code
      p54: Move TX/RX code
      p54: Modify p54 files for new organization
      p54: two endian fixes
      p54spi: remove dead code and definitions
      p54usb: fix stalls caused by urb allocation failures
      p54: fix queue stall due to underrun

David Kilroy (24):
      cfg80211: add wrapper function to get wiphy from priv pointer
      cfg80211: Advertise ciphers via WE according to driver capability
      cfg80211: allow drivers that can't scan for specific ssids
      cfg80211: set WE encoding size based on available ciphers
      cfg80211: infer WPA and WPA2 support from TKIP and CCMP
      orinoco: Move firmware capability determination into hw.c
      orinoco: Move card reading code into hw.c
      orinoco: Move FID allocation to hw.c
      orinoco: use dev_err in early initialisation routines
      orinoco: firmware helpers should use dev_err and friends
      orinoco: Replace net_device with orinoco_private in driver interfaces
      orinoco: initialise independently of netdev
      orinoco: Change set_tkip to use orinoco_private instead of hermes_t
      orinoco: initiate cfg80211 conversion
      orinoco: make firmware download less verbose
      orinoco: move netdev interface creation to main driver
      airport: store irq in card private structure
      orinoco: Handle suspend/restore in core driver
      orinoco: provide generic commit function
      orinoco: convert mode setting to cfg80211
      orinoco: convert scanning to cfg80211
      orinoco: convert giwrange to cfg80211
      orinoco: remove WE nickname support
      orinoco: fix printk format specifier for size_t arguments

Gabor Juhos (2):
      ath9k: remove unnecessary clearing of SC_OP_WAIT_{BEACON,CAB} flags
      ath9k: remove ath_rx_ps_back_to_sleep helper

Helmut Schaa (1):
      mac80211: shorten the passive dwell time for sw scans

Hin-Tak Leung (1):
      zd1211rw: sort vid/pid pairs by numerical value

Ivo van Doorn (1):
      rt2x00: use wiphy rfkill interface

Jiri Slaby (2):
      ath5k: remove permissions from debugfs files
      ath9k: remove permissions from debugfs files

Joe Perches (2):
      drivers/net/wireless: Use PCI_VDEVICE
      drivers/net/wireless/ath/ath9k: Remove unnecessary semicolons

Johannes Berg (54):
      cfg80211: pass netdev to change_virtual_intf
      cfg80211: issue netlink notification when scan starts
      rt2x00: remove skb->do_not_encrypt usage
      mac80211: push rx status into skb->cb
      mac80211: improve per-sta debugfs
      cfg80211: prohibit scanning the same channel more than once
      mac80211_hwsim: clean up the skb before passing it back
      cfg80211: send wext MLME-MICHAELMICFAILURE.indication
      wext: allow returning NULL stats
      mac80211: fix todo lock
      wext: default to y
      cfg80211: move break statement to correct place
      nl80211: clean up function definitions
      cfg80211: use proper allocation flags
      cfg80211: remove wireless_dev->bssid
      mac80211: tell SME about real auth state
      wext: constify extra argument to wireless_send_event
      cfg80211: introduce nl80211 testmode command
      mac80211: remove an unused function declaration
      wireless: define AKM suites
      cfg80211: emulate connect with auth/assoc
      cfg80211: managed mode wext compatibility
      cfg80211: implement iwpower
      cfg80211: implement IWAP for WDS
      cfg80211: implement IWRATE
      cfg80211: implement get_wireless_stats
      mac80211: re-add HT disabling
      mac80211: remove auth algorithm retry
      mac80211: remove dead code, clean up
      cfg80211: send events for userspace SME
      cfg80211: reset auth algorithm
      cfg80211: assimilate and export ieee80211_bss_get_ie
      cfg80211: keep track of BSSes
      cfg80211: refuse authenticating to same BSSID twice
      nl80211: limit to one pairwise cipher for associate()
      cfg80211: fix giwrange
      iwlwifi: make software queue assignment more efficient
      iwlwifi: scan requested channels only
      iwlwifi: fix aggregation limit
      rfkill: prep for rfkill API changes
      cfg80211: let SME control reassociation vs. association
      mac80211: remove dead code from mlme
      mac80211: rework MLME for multiple authentications
      mac80211: refactor the WEP code to be directly usable
      cfg80211: fix netdev down problem
      cfg80211: dont use union for wext
      cfg80211: mlme API must be able to sleep
      cfg80211: warn again on spurious deauth
      cfg80211: properly name driver locking
      cfg80211: fix MFP bug, sparse warnings
      cfg80211: fix locking
      cfg80211: clean up naming once and for all
      cfg80211: disallow configuring unsupported interfaces
      hwsim: make testmode_cmd static

John W. Linville (1):
      mac80211_hwsim: fix-up build damage from removal of skb->dst

Jussi Kivilinna (3):
      rndis_wlan: convert get/set frag/rts to cfg80211
      usbnet: Add stop function pointer to 'struct rndis_data'.
      rndis_wlan: convert set/get txpower to cfg80211

Juuso Oikarinen (4):
      wl12xx: removed chipset interrupt source configuration from fw wakeup
      wl12xx: Moved wl1251 TX path implementation into chip specific files
      wl12xx: Add support for block reading from a fixed register address
      wl12xx: Use chipset specific join commands

Kalle Valo (20):
      wl12xx: cmd and acx interface rework
      wl12xx: reserver buffer for read32()/write32() in struct wl12xx
      wl12xx: fix error handling in wl12xx_probe()
      wl12xx: reserve buffer for partition command in struct wl12xx
      wl12xx: allocate buffer spi read/write command buffer kzalloc()
      wl12xx: allocate buffer the spi busy word from struct wl12xx
      wl12xx: use wl12xx_mem_read32() to read the rx counter
      wl12xx: fix rx descriptor use
      wl12xx: protect wl12xx_op_set_rts_threshold()
      wl12xx: optimise elp wakeup and sleep calls
      wl12xx: check if elp wakeup failed
      wl12xx: enable ELP mode
      wl12xx: rename wl1251.c wl1251_ops.c
      wl12xx: rename driver to wl1251
      wl1251: remove wl1271_setup()
      wl1251: add wl1251 prefix to all 1251 files
      wl1251: rename wl12xx.h to wl1251.h
      wl12xx: remove unused wl12xx_hw_init_mem_config()
      wl1251: use wl1251 prefix everywhere
      wl1251: fix a checkpatch warning

Luciano Coelho (6):
      wl12xx: add wl12xx_spi_reg_read() and wl12xx_spi_reg_write() functions
      wl12xx: moved firmware version reading routine to chip-specific functions
      wl12xx: add support for new WL1271 chip revision
      wl12xx: add support for fixed address in wl12xx_spi_read
      wl12xx: pass the wake up condition when configuring the wake up event
      wl1251: change psm enabled/disabled info to debug

Luis R. Rodriguez (1):
      ath9k: differentiate quality reporting between legacy and HT configurations

Mohamed Abbas (1):
      iwlwifi: Check HW ready before prepare card.

Reinette Chatre (3):
      iwlagn: re-enable PS support for iwlagn
      iwlwifi: add utility to print buffer when error occurs
      iwlwifi: always print buffer when error condition occurs

Roel Kluin (1):
      wireless: remove redundant tests on unsigned

Samuel Ortiz (6):
      iwmc3200wifi: invalidate keys when changing the BSSID
      iwmc3200wifi: handling wifi_if_ntfy responses
      iwmc3200wifi: cfg80211 key hooks implemetation
      iwmc3200wifi: cache keys when interface is down
      cfg80211: connect/disconnect API
      cfg80211: check for current_bss from giwrate

Senthil Balasubramanian (4):
      ath9k: remove unnecessary STATION mode check.
      ath9k: stop ani when the STA gets disconnected.
      ath9k: race condition in SCANNING state check during ANI calibration
      ath9k: Handle different TX and RX streams properly.

Tomas Winkler (2):
      iwlwifi: drop sw_crypto from hw_params.
      iwlwifi: unify iwl_setup_rxon_timing

Vasanthakumar Thiagarajan (4):
      ath9k: Nuke unneccesary helper function to see if aggr is active
      ath9k: Remove unnecessary count for addba attempt
      ath9k: downgrade ASSERT() in ath_clone_txbuf()
      ath9k: Make sure we configure a non-zero beacon interval

Vidhya Govindan (1):
      wl12xx: Assign value to rx msdu lifetime variable

Wey-Yi Guy (3):
      iwlwifi: modify sensitivity value for 5150
      iwlwifi: no need to refer to max_nrg_cck range value
      iwlwifi: remove disable_tx_power for device > 4965

Zhu Yi (5):
      iwmc3200wifi: change coexist periodic calibration flag
      iwmc3200wifi: rfkill cleanup
      iwmc3200wifi: replace netif_rx with netif_rx_ni
      iwmc3200wifi: simplify calibration map
      iwmc3200wifi: remove B0 hardware support

 drivers/net/usb/usbnet.c                           |   14 +
 drivers/net/wireless/adm8211.c                     |    3 +-
 drivers/net/wireless/at76c50x-usb.c                |    3 +-
 drivers/net/wireless/ath/ar9170/main.c             |    6 +-
 drivers/net/wireless/ath/ar9170/usb.c              |    2 +-
 drivers/net/wireless/ath/ath5k/ath5k.h             |   21 +-
 drivers/net/wireless/ath/ath5k/attach.c            |    3 +
 drivers/net/wireless/ath/ath5k/base.c              |  130 +-
 drivers/net/wireless/ath/ath5k/base.h              |   10 +-
 drivers/net/wireless/ath/ath5k/debug.c             |    8 +-
 drivers/net/wireless/ath/ath5k/phy.c               |    7 +-
 drivers/net/wireless/ath/ath5k/qcu.c               |    1 -
 drivers/net/wireless/ath/ath5k/reset.c             |    1 -
 drivers/net/wireless/ath/ath9k/ath9k.h             |    2 +-
 drivers/net/wireless/ath/ath9k/beacon.c            |   15 +-
 drivers/net/wireless/ath/ath9k/debug.c             |   10 +-
 drivers/net/wireless/ath/ath9k/eeprom.c            |    2 -
 drivers/net/wireless/ath/ath9k/hw.c                |    2 +-
 drivers/net/wireless/ath/ath9k/main.c              |   62 +-
 drivers/net/wireless/ath/ath9k/recv.c              |   67 +-
 drivers/net/wireless/ath/ath9k/xmit.c              |   33 +-
 drivers/net/wireless/ath/regd.c                    |    2 -
 drivers/net/wireless/b43/xmit.c                    |    3 +-
 drivers/net/wireless/b43legacy/xmit.c              |    3 +-
 drivers/net/wireless/ipw2x00/ipw2200.c             |   10 +-
 drivers/net/wireless/iwlwifi/iwl-3945.c            |    6 +-
 drivers/net/wireless/iwlwifi/iwl-4965.c            |    2 +-
 drivers/net/wireless/iwlwifi/iwl-5000.c            |   29 +-
 drivers/net/wireless/iwlwifi/iwl-agn.c             |   74 +-
 drivers/net/wireless/iwlwifi/iwl-calib.c           |    7 +-
 drivers/net/wireless/iwlwifi/iwl-commands.h        |    4 +-
 drivers/net/wireless/iwlwifi/iwl-core.c            |   63 +-
 drivers/net/wireless/iwlwifi/iwl-core.h            |    3 +-
 drivers/net/wireless/iwlwifi/iwl-debug.h           |    6 +
 drivers/net/wireless/iwlwifi/iwl-debugfs.c         |    9 +-
 drivers/net/wireless/iwlwifi/iwl-dev.h             |    2 +-
 drivers/net/wireless/iwlwifi/iwl-rx.c              |    5 +-
 drivers/net/wireless/iwlwifi/iwl-scan.c            |   31 +-
 drivers/net/wireless/iwlwifi/iwl-tx.c              |   16 +-
 drivers/net/wireless/iwlwifi/iwl3945-base.c        |   88 +-
 drivers/net/wireless/iwmc3200wifi/cfg80211.c       |  235 ++-
 drivers/net/wireless/iwmc3200wifi/commands.c       |  116 +-
 drivers/net/wireless/iwmc3200wifi/commands.h       |    7 +-
 drivers/net/wireless/iwmc3200wifi/eeprom.c         |    4 -
 drivers/net/wireless/iwmc3200wifi/fw.c             |   21 +-
 drivers/net/wireless/iwmc3200wifi/iwm.h            |   32 +-
 drivers/net/wireless/iwmc3200wifi/lmac.h           |    4 +
 drivers/net/wireless/iwmc3200wifi/main.c           |   38 +-
 drivers/net/wireless/iwmc3200wifi/netdev.c         |   27 +-
 drivers/net/wireless/iwmc3200wifi/rx.c             |   36 +-
 drivers/net/wireless/iwmc3200wifi/sdio.c           |    6 +-
 drivers/net/wireless/iwmc3200wifi/umac.h           |    2 +
 drivers/net/wireless/iwmc3200wifi/wext.c           |  352 +---
 drivers/net/wireless/libertas/assoc.c              |    6 +
 drivers/net/wireless/libertas/dev.h                |    1 -
 drivers/net/wireless/libertas/if_cs.c              |    3 -
 drivers/net/wireless/libertas/if_sdio.c            |    5 +-
 drivers/net/wireless/libertas/if_spi.c             |    8 +-
 drivers/net/wireless/libertas/if_usb.c             |    3 +-
 drivers/net/wireless/libertas/wext.c               |    2 +-
 drivers/net/wireless/libertas_tf/main.c            |    3 +-
 drivers/net/wireless/mac80211_hwsim.c              |   81 +-
 drivers/net/wireless/mwl8k.c                       |    3 +-
 drivers/net/wireless/orinoco/Kconfig               |    1 +
 drivers/net/wireless/orinoco/Makefile              |    2 +-
 drivers/net/wireless/orinoco/airport.c             |   98 +-
 drivers/net/wireless/orinoco/cfg.c                 |  162 ++
 drivers/net/wireless/orinoco/cfg.h                 |   15 +
 drivers/net/wireless/orinoco/fw.c                  |   41 +-
 drivers/net/wireless/orinoco/hermes.c              |    2 +-
 drivers/net/wireless/orinoco/hermes.h              |    2 +-
 drivers/net/wireless/orinoco/hermes_dld.c          |   50 +-
 drivers/net/wireless/orinoco/hw.c                  |  668 +++++-
 drivers/net/wireless/orinoco/hw.h                  |   11 +-
 drivers/net/wireless/orinoco/main.c                | 1133 +++------
 drivers/net/wireless/orinoco/main.h                |    3 +-
 drivers/net/wireless/orinoco/orinoco.h             |   49 +-
 drivers/net/wireless/orinoco/orinoco_cs.c          |   96 +-
 drivers/net/wireless/orinoco/orinoco_nortel.c      |   38 +-
 drivers/net/wireless/orinoco/orinoco_pci.c         |   38 +-
 drivers/net/wireless/orinoco/orinoco_pci.h         |   57 +-
 drivers/net/wireless/orinoco/orinoco_plx.c         |   38 +-
 drivers/net/wireless/orinoco/orinoco_tmd.c         |   38 +-
 drivers/net/wireless/orinoco/scan.c                |  291 ++--
 drivers/net/wireless/orinoco/scan.h                |   21 +-
 drivers/net/wireless/orinoco/spectrum_cs.c         |   96 +-
 drivers/net/wireless/orinoco/wext.c                |  878 +------
 drivers/net/wireless/p54/Makefile                  |    3 +
 drivers/net/wireless/p54/eeprom.c                  |  564 ++++
 drivers/net/wireless/p54/eeprom.h                  |  226 ++
 drivers/net/wireless/p54/fwio.c                    |  698 +++++
 drivers/net/wireless/p54/led.c                     |  163 ++
 drivers/net/wireless/p54/lmac.h                    |  551 ++++
 drivers/net/wireless/p54/main.c                    |  607 +++++
 drivers/net/wireless/p54/p54.h                     |  148 +-
 drivers/net/wireless/p54/p54common.c               | 2688 --------------------
 drivers/net/wireless/p54/p54common.h               |  644 -----
 drivers/net/wireless/p54/p54pci.c                  |    9 +-
 drivers/net/wireless/p54/p54spi.c                  |   50 +-
 drivers/net/wireless/p54/p54usb.c                  |   42 +-
 drivers/net/wireless/p54/txrx.c                    |  826 ++++++
 drivers/net/wireless/prism54/islpci_hotplug.c      |    4 +-
 drivers/net/wireless/rndis_wlan.c                  |  298 ++--
 drivers/net/wireless/rt2x00/Kconfig                |    8 -
 drivers/net/wireless/rt2x00/Makefile               |    1 -
 drivers/net/wireless/rt2x00/rt2400pci.c            |    7 +-
 drivers/net/wireless/rt2x00/rt2500pci.c            |    7 +-
 drivers/net/wireless/rt2x00/rt2500usb.c            |    7 +-
 drivers/net/wireless/rt2x00/rt2800usb.c            |    7 +-
 drivers/net/wireless/rt2x00/rt2x00.h               |   13 +-
 drivers/net/wireless/rt2x00/rt2x00crypto.c         |    6 +-
 drivers/net/wireless/rt2x00/rt2x00dev.c            |    5 +-
 drivers/net/wireless/rt2x00/rt2x00lib.h            |   21 +-
 drivers/net/wireless/rt2x00/rt2x00mac.c            |   12 +-
 drivers/net/wireless/rt2x00/rt2x00rfkill.c         |  127 -
 drivers/net/wireless/rt2x00/rt61pci.c              |    7 +-
 drivers/net/wireless/rt2x00/rt73usb.c              |    7 +-
 drivers/net/wireless/rtl818x/rtl8180_dev.c         |    5 +-
 drivers/net/wireless/rtl818x/rtl8187_dev.c         |    3 +-
 drivers/net/wireless/wl12xx/Kconfig                |   17 +-
 drivers/net/wireless/wl12xx/Makefile               |    9 +-
 drivers/net/wireless/wl12xx/acx.c                  |  689 -----
 drivers/net/wireless/wl12xx/cmd.c                  |  353 ---
 drivers/net/wireless/wl12xx/reg.h                  |    1 -
 drivers/net/wireless/wl12xx/wl1251.h               |  479 +++-
 drivers/net/wireless/wl12xx/wl1251_acx.c           |  840 ++++++
 .../net/wireless/wl12xx/{acx.h => wl1251_acx.h}    |  199 +--
 .../net/wireless/wl12xx/{boot.c => wl1251_boot.c}  |  114 +-
 .../net/wireless/wl12xx/{boot.h => wl1251_boot.h}  |   12 +-
 drivers/net/wireless/wl12xx/wl1251_cmd.c           |  428 ++++
 .../net/wireless/wl12xx/{cmd.h => wl1251_cmd.h}    |  194 ++-
 .../wl12xx/{debugfs.c => wl1251_debugfs.c}         |   60 +-
 .../wl12xx/{debugfs.h => wl1251_debugfs.h}         |   16 +-
 .../wireless/wl12xx/{event.c => wl1251_event.c}    |   54 +-
 .../wireless/wl12xx/{event.h => wl1251_event.h}    |   12 +-
 .../net/wireless/wl12xx/{init.c => wl1251_init.c}  |   78 +-
 .../net/wireless/wl12xx/{init.h => wl1251_init.h}  |   27 +-
 .../net/wireless/wl12xx/{main.c => wl1251_main.c}  |  638 +++--
 drivers/net/wireless/wl12xx/wl1251_netlink.c       |  679 +++++
 .../wl12xx/{debugfs.h => wl1251_netlink.h}         |   15 +-
 .../net/wireless/wl12xx/{wl1251.c => wl1251_ops.c} |  297 ++-
 drivers/net/wireless/wl12xx/wl1251_ops.h           |  165 ++
 drivers/net/wireless/wl12xx/{ps.c => wl1251_ps.c}  |   64 +-
 drivers/net/wireless/wl12xx/{ps.h => wl1251_ps.h}  |   18 +-
 drivers/net/wireless/wl12xx/{rx.c => wl1251_rx.c}  |   90 +-
 drivers/net/wireless/wl12xx/{rx.h => wl1251_rx.h}  |   22 +-
 .../net/wireless/wl12xx/{spi.c => wl1251_spi.c}    |  179 +-
 .../net/wireless/wl12xx/{spi.h => wl1251_spi.h}    |   62 +-
 drivers/net/wireless/wl12xx/{tx.c => wl1251_tx.c}  |  124 +-
 drivers/net/wireless/wl12xx/{tx.h => wl1251_tx.h}  |   21 +-
 drivers/net/wireless/wl12xx/wl12xx.h               |  409 ---
 drivers/net/wireless/zd1211rw/zd_mac.c             |    3 +-
 drivers/net/wireless/zd1211rw/zd_usb.c             |   73 +-
 drivers/staging/agnx/xmit.c                        |    3 +-
 drivers/staging/stlc45xx/stlc45xx.c                |    3 +-
 drivers/staging/winbond/wb35rx.c                   |    3 +-
 include/linux/ieee80211.h                          |    4 +
 include/linux/nl80211.h                            |   96 +
 include/linux/rfkill.h                             |   14 +
 include/linux/usb/usbnet.h                         |    3 +
 include/net/cfg80211.h                             |  460 +++-
 include/net/iw_handler.h                           |    2 +-
 include/net/mac80211.h                             |   34 +-
 net/mac80211/Kconfig                               |   16 -
 net/mac80211/cfg.c                                 |  216 +-
 net/mac80211/debugfs_netdev.c                      |   46 -
 net/mac80211/debugfs_sta.c                         |   98 +-
 net/mac80211/event.c                               |   23 +-
 net/mac80211/ibss.c                                |    6 +-
 net/mac80211/ieee80211_i.h                         |  148 +-
 net/mac80211/iface.c                               |   30 +-
 net/mac80211/key.c                                 |   28 +-
 net/mac80211/main.c                                |    5 +-
 net/mac80211/mesh.c                                |    6 +-
 net/mac80211/mesh.h                                |    3 +-
 net/mac80211/mlme.c                                | 1637 +++++-------
 net/mac80211/rx.c                                  |  103 +-
 net/mac80211/scan.c                                |   29 +-
 net/mac80211/sta_info.h                            |   17 +
 net/mac80211/wep.c                                 |   52 +-
 net/mac80211/wep.h                                 |    4 -
 net/mac80211/wext.c                                |  450 +---
 net/mac80211/wpa.c                                 |    3 +-
 net/rfkill/core.c                                  |   10 +-
 net/wireless/Kconfig                               |   43 +-
 net/wireless/Makefile                              |    4 +-
 net/wireless/core.c                                |  385 ++-
 net/wireless/core.h                                |  184 ++-
 net/wireless/debugfs.c                             |   14 +-
 net/wireless/debugfs.h                             |    8 +-
 net/wireless/ibss.c                                |  158 +-
 net/wireless/mlme.c                                |  581 ++++-
 net/wireless/nl80211.c                             | 1110 ++++++---
 net/wireless/nl80211.h                             |   71 +-
 net/wireless/reg.c                                 |   48 +-
 net/wireless/scan.c                                |   75 +-
 net/wireless/sme.c                                 |  792 ++++++
 net/wireless/util.c                                |   21 +
 net/wireless/wext-compat.c                         |  496 ++++-
 net/wireless/wext-sme.c                            |  380 +++
 net/wireless/wext.c                                |   11 +-
 201 files changed, 15590 insertions(+), 12136 deletions(-)
 create mode 100644 drivers/net/wireless/orinoco/cfg.c
 create mode 100644 drivers/net/wireless/orinoco/cfg.h
 create mode 100644 drivers/net/wireless/p54/eeprom.c
 create mode 100644 drivers/net/wireless/p54/eeprom.h
 create mode 100644 drivers/net/wireless/p54/fwio.c
 create mode 100644 drivers/net/wireless/p54/led.c
 create mode 100644 drivers/net/wireless/p54/lmac.h
 create mode 100644 drivers/net/wireless/p54/main.c
 delete mode 100644 drivers/net/wireless/p54/p54common.c
 delete mode 100644 drivers/net/wireless/p54/p54common.h
 create mode 100644 drivers/net/wireless/p54/txrx.c
 delete mode 100644 drivers/net/wireless/rt2x00/rt2x00rfkill.c
 delete mode 100644 drivers/net/wireless/wl12xx/acx.c
 delete mode 100644 drivers/net/wireless/wl12xx/cmd.c
 create mode 100644 drivers/net/wireless/wl12xx/wl1251_acx.c
 rename drivers/net/wireless/wl12xx/{acx.h => wl1251_acx.h} (86%)
 rename drivers/net/wireless/wl12xx/{boot.c => wl1251_boot.c} (67%)
 rename drivers/net/wireless/wl12xx/{boot.h => wl1251_boot.h} (78%)
 create mode 100644 drivers/net/wireless/wl12xx/wl1251_cmd.c
 rename drivers/net/wireless/wl12xx/{cmd.h => wl1251_cmd.h} (60%)
 rename drivers/net/wireless/wl12xx/{debugfs.c => wl1251_debugfs.c} (92%)
 copy drivers/net/wireless/wl12xx/{debugfs.h => wl1251_debugfs.h} (74%)
 rename drivers/net/wireless/wl12xx/{event.c => wl1251_event.c} (59%)
 rename drivers/net/wireless/wl12xx/{event.h => wl1251_event.h} (94%)
 rename drivers/net/wireless/wl12xx/{init.c => wl1251_init.c} (55%)
 rename drivers/net/wireless/wl12xx/{init.h => wl1251_init.h} (55%)
 rename drivers/net/wireless/wl12xx/{main.c => wl1251_main.c} (60%)
 create mode 100644 drivers/net/wireless/wl12xx/wl1251_netlink.c
 rename drivers/net/wireless/wl12xx/{debugfs.h => wl1251_netlink.h} (73%)
 rename drivers/net/wireless/wl12xx/{wl1251.c => wl1251_ops.c} (66%)
 create mode 100644 drivers/net/wireless/wl12xx/wl1251_ops.h
 rename drivers/net/wireless/wl12xx/{ps.c => wl1251_ps.c} (55%)
 rename drivers/net/wireless/wl12xx/{ps.h => wl1251_ps.h} (72%)
 rename drivers/net/wireless/wl12xx/{rx.c => wl1251_rx.c} (68%)
 rename drivers/net/wireless/wl12xx/{rx.h => wl1251_rx.h} (89%)
 rename drivers/net/wireless/wl12xx/{spi.c => wl1251_spi.c} (63%)
 rename drivers/net/wireless/wl12xx/{spi.h => wl1251_spi.h} (61%)
 rename drivers/net/wireless/wl12xx/{tx.c => wl1251_tx.c} (79%)
 rename drivers/net/wireless/wl12xx/{tx.h => wl1251_tx.h} (93%)
 delete mode 100644 drivers/net/wireless/wl12xx/wl12xx.h
 create mode 100644 net/wireless/sme.c
 create mode 100644 net/wireless/wext-sme.c

Omnibus patch available here:

	http://www.kernel.org/pub/linux/kernel/people/linville/wireless-next-2.6-2009-07-10.patch.bz2

-- 
John W. Linville		Someday the world will need a hero, and you
linville@tuxdriver.com			might be all we have.  Be ready.
			¡Viva Honduras Libre!

^ permalink raw reply

* Re: pull request: wireless-next-2.6 2009-07-10
From: David Miller @ 2009-07-10 20:51 UTC (permalink / raw)
  To: linville-2XuSBdqkA4R54TAoqtyWWQ
  Cc: linux-wireless-u79uwXL29TY76Z2rM5mHXA,
	netdev-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <20090710194822.GH2825-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org>

From: "John W. Linville" <linville-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org>
Date: Fri, 10 Jul 2009 15:48:22 -0400

> Here is the usual tsunami of wireless stuff at this stage of the
> development cycle for the next release.  Included are the usual
> driver updates (including movement of orinoco towards cfg80211)
> and many mac80211 improvements.
> 
> Please let me know if there are problems!

Pulled and pushed back out to kernel.org, thanks!
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* [PATCH] pcnet_cs: add odd location support for write_asic function
From: Ken Kawasaki @ 2009-07-11  0:02 UTC (permalink / raw)
  To: netdev
In-Reply-To: <20090405094907.5f6a5fea.ken_kawasaki@spring.nifty.jp>


Currently, no one passes odd location to the write_asic function.
But this patch add odd location support for future usage of this
feature.


Signed-off-by: Ken Kawasaki <ken_kawasaki@spring.nifty.jp>

---

--- linux-2.6.31-rc1/drivers/net/pcmcia/pcnet_cs.c.orig	2009-06-27 10:15:47.000000000 +0900
+++ linux-2.6.31-rc1/drivers/net/pcmcia/pcnet_cs.c	2009-07-04 10:32:44.000000000 +0900
@@ -886,9 +886,10 @@ static void write_asic(unsigned int ioad
 		outb_p(EE_ASIC|EE_CS|EE_DI|dataval, ee_addr);
 	}
 	// sync
-	outb(EE_ASIC|EE_CS, ee_addr);
-	outb(EE_ASIC|EE_CS|EE_CK, ee_addr);
-	outb(EE_ASIC|EE_CS, ee_addr);
+	dataval = (location & 1) ? EE_DO : 0;
+	outb(EE_ASIC|EE_CS|dataval, ee_addr);
+	outb(EE_ASIC|EE_CS|dataval|EE_CK, ee_addr);
+	outb(EE_ASIC|EE_CS|dataval, ee_addr);
 
 	for (i = 15; i >= 0; i--) {
 		dataval = (asic_data & (1 << i)) ? EE_ADOT : 0;

^ permalink raw reply

* [PATCH 15/15] dropmon: remove duplicated #include
From: Huang Weiyi @ 2009-07-11  1:33 UTC (permalink / raw)
  To: davem; +Cc: netdev, Huang Weiyi

Remove duplicated #include('s) in
  include/linux/net_dropmon.h

Signed-off-by: Huang Weiyi <weiyi.huang@gmail.com>
---
 include/linux/net_dropmon.h |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/include/linux/net_dropmon.h b/include/linux/net_dropmon.h
index 3ceb0cc..2a73946 100644
--- a/include/linux/net_dropmon.h
+++ b/include/linux/net_dropmon.h
@@ -3,7 +3,6 @@
 
 #include <linux/types.h>
 #include <linux/netlink.h>
-#include <linux/types.h>
 
 struct net_dm_drop_point {
 	__u8 pc[8];
-- 
1.6.1.2


^ permalink raw reply related

* Re: [PATCH] pcnet_cs: add odd location support for write_asic function
From: David Miller @ 2009-07-11  3:26 UTC (permalink / raw)
  To: ken_kawasaki; +Cc: netdev
In-Reply-To: <20090711090213.94a771d3.ken_kawasaki@spring.nifty.jp>

From: Ken Kawasaki <ken_kawasaki@spring.nifty.jp>
Date: Sat, 11 Jul 2009 09:02:13 +0900

> Currently, no one passes odd location to the write_asic function.
> But this patch add odd location support for future usage of this
> feature.
> 
> 
> Signed-off-by: Ken Kawasaki <ken_kawasaki@spring.nifty.jp>

"Who" in the future will use this feature and why do they
need it?

Ideally, you should submit this patch at the same time as
the other patch which adds a need for it.

^ permalink raw reply

* Re: [PATCH] don't touch bridge sysfs in container.
From: Ken-ichirou MATSUZAWA @ 2009-07-11  3:59 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: Ken-ichirou MATSUZAWA, netdev
In-Reply-To: <20090709142317.542c51a4@nehalam>

 Hello,

At Thu, 9 Jul 2009 14:23:17 -0700,
Stephen Hemminger wrote:

> Without tagged sysfs, how could bridge interface work in other containers?

I start thinking I try odd things or I'm not asking right questions.
No one can see what I'm trying in my poor English, please let me explain...

----

base host		terminal A		terminal B
			# ./ns_exec -cn /bin/sh
			# echo $$
			2421
						# ./ns_exec -cn /bin/sh
						# echo $$
						2425
# ip link add type veth
# ip link set veth0 netns 2421
# ip link set veth1 netns 2425
# ip link add type veth
# ip link set veth1 netns 2421
# ip link set veth0 up
			# ip link set veth0 up
			# ip link set veth1 up
			# brctl addbr br0
			# brctl addif br0 veth0
			# brctl addif br0 veth1
			# ip link set br0 up
						# ip link set veth1 up
						# ip addr add 192.168.1.10/24 dev veth1
# ip addr add 192.168.1.1/24 dev veth0
# ping 192.168.1.10

----

I want to play with ebtables, qdisc and something stuff like that in
terminal A. until tagged sysfs merged, we should not try those on present
container system?

Thanks in advance.

Signed-off-by: Ken-ichirou MATSUZAWA

---
 net/bridge/br_if.c |   34 +++++++++++++++++++++++-----------
 1 files changed, 23 insertions(+), 11 deletions(-)

diff --git a/net/bridge/br_if.c b/net/bridge/br_if.c
index 8a96672..ea97d2e 100644
--- a/net/bridge/br_if.c
+++ b/net/bridge/br_if.c
@@ -107,7 +107,8 @@ static void destroy_nbp(struct net_bridge_port *p)
 	p->dev = NULL;
 	dev_put(dev);
 
-	kobject_put(&p->kobj);
+        if (dev_net(dev) == &init_net)
+		kobject_put(&p->kobj);
 }
 
 static void destroy_nbp_rcu(struct rcu_head *head)
@@ -148,7 +149,8 @@ static void del_nbp(struct net_bridge_port *p)
 	rcu_assign_pointer(dev->br_port, NULL);
 
 	kobject_uevent(&p->kobj, KOBJ_REMOVE);
-	kobject_del(&p->kobj);
+        if (dev_net(br->dev) == &init_net)
+		kobject_del(&p->kobj);
 
 	call_rcu(&p->rcu, destroy_nbp_rcu);
 }
@@ -164,7 +166,9 @@ static void del_br(struct net_bridge *br)
 
 	del_timer_sync(&br->gc_timer);
 
-	br_sysfs_delbr(br->dev);
+        if (dev_net(br->dev) == &init_net)
+                br_sysfs_delbr(br->dev);
+
 	unregister_netdevice(br->dev);
 }
 
@@ -283,6 +287,9 @@ int br_add_bridge(struct net *net, const char *name)
 	if (ret)
 		goto out_free;
 
+        if (dev_net(dev) != &init_net)
+                goto out;
+
 	ret = br_sysfs_addbr(dev);
 	if (ret)
 		unregister_netdevice(dev);
@@ -387,18 +394,22 @@ int br_add_if(struct net_bridge *br, struct net_device *dev)
 	if (err)
 		goto put_back;
 
-	err = kobject_init_and_add(&p->kobj, &brport_ktype, &(dev->dev.kobj),
-				   SYSFS_BRIDGE_PORT_ATTR);
-	if (err)
-		goto err0;
+        if (dev_net(br->dev) == &init_net) {
+		err = kobject_init_and_add(&p->kobj, &brport_ktype, &(dev->dev.kobj),
+					   SYSFS_BRIDGE_PORT_ATTR);
+		if (err)
+			goto err0;
+	}
 
 	err = br_fdb_insert(br, p, dev->dev_addr);
 	if (err)
 		goto err1;
 
-	err = br_sysfs_addif(p);
-	if (err)
-		goto err2;
+        if (dev_net(br->dev) == &init_net) {
+                err = br_sysfs_addif(p);
+                if (err)
+                        goto err2;
+        }
 
 	rcu_assign_pointer(dev->br_port, p);
 	dev_disable_lro(dev);
@@ -424,7 +435,8 @@ int br_add_if(struct net_bridge *br, struct net_device *dev)
 err2:
 	br_fdb_delete_by_port(br, p, 1);
 err1:
-	kobject_del(&p->kobj);
+        if (dev_net(br->dev) == &init_net)
+		kobject_del(&p->kobj);
 err0:
 	dev_set_promiscuity(dev, -1);
 put_back:
-- 
1.5.6.5


^ permalink raw reply related

* Re: weird problem
From: Jarek Poplawski @ 2009-07-11  6:24 UTC (permalink / raw)
  To: Paweł Staszewski
  Cc: Eric Dumazet, Eric Dumazet, Linux Network Development list
In-Reply-To: <20090710144754.GA25385@ami.dom.local>

On Fri, Jul 10, 2009 at 04:47:54PM +0200, Jarek Poplawski wrote:
> On Fri, Jul 10, 2009 at 01:59:00AM +0200, Paweł Staszewski wrote:
> > Today i make other tests with change of  
> > /proc/sys/net/ipv4/rt_cache_rebuild_count and kernel 2.6.30.1
> >
> > And when rt_cache_rebuild_count is set to "-1" i have always load on  
> > x86_64 machine approx 40-50% of each cpu where network card is binded by  
> > irq_aff
> >
> > when rt_cache_rebuild_count is set to more than "-1" i have 15 to 20 sec  
> > of 1 to 3% cpu and after 40-50% cpu
> ...
> 
> Here is one more patch for testing (with caution!). It adds possibility
> to turn off cache disabling (so it should even more resemble 2.6.28)
> after setting: rt_cache_rebuild_count = 0
> 
> I'd like you to try this patch:
> 1) together with the previous patch and "rt_cache_rebuild_count = 0"
>    to check if there is still the difference wrt. 2.6.28; Btw., let
>    me know which /proc/sys/net/ipv4/route/* settings do you need to
>    change and why
> 
> 2) alone (without the previous patch) and "rt_cache_rebuild_count = 0"
> 
> 3) if it's possible to try 2.6.30.1 without these patches, but with
>    default /proc/sys/net/ipv4/route/* settings, and higher
>    rt_cache_rebuild_count, e.g. 100; I'm interested if/how long it
>    takes to trigger higher cpu load and the warning "... rebuilds is
>    over limit, route caching disabled"; (Btw., I wonder why you didn't
>    mention about these or maybe also other route caching warnings?)

Here is take 2 to respect setting "rt_cache_rebuild_count = 0" even
after cache rebuild counter has been increased earlier. (Btw, don't
forget about this setting after going back to vanilla kernel.)

Jarek P.
--- (debugging patch #2 take 2; apply to 2.6.30.1 or 2.6.29.6)


 net/ipv4/route.c |   21 ++++++++++++++-------
 1 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 278f46f..f74db20 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -678,8 +678,9 @@ static inline u32 rt_score(struct rtable *rt)
 
 static inline bool rt_caching(const struct net *net)
 {
-	return net->ipv4.current_rt_cache_rebuild_count <=
-		net->ipv4.sysctl_rt_cache_rebuild_count;
+	return (net->ipv4.current_rt_cache_rebuild_count <=
+		net->ipv4.sysctl_rt_cache_rebuild_count) ||
+	       net->ipv4.sysctl_rt_cache_rebuild_count == 0;
 }
 
 static inline bool compare_hash_inputs(const struct flowi *fl1,
@@ -1181,12 +1182,18 @@ restart:
 	} else {
 		if (chain_length > rt_chain_length_max) {
 			struct net *net = dev_net(rt->u.dst.dev);
-			int num = ++net->ipv4.current_rt_cache_rebuild_count;
-			if (!rt_caching(dev_net(rt->u.dst.dev))) {
-				printk(KERN_WARNING "%s: %d rebuilds is over limit, route caching disabled\n",
-					rt->u.dst.dev->name, num);
+
+			if (net->ipv4.sysctl_rt_cache_rebuild_count > 0) {
+				int num = ++net->ipv4.current_rt_cache_rebuild_count;
+
+				if (!rt_caching(net))
+					printk(KERN_WARNING
+					       "%s: %d rebuilds is over limit, "
+					       "route caching disabled\n",
+					       rt->u.dst.dev->name, num);
+
+				rt_emergency_hash_rebuild(net);
 			}
-			rt_emergency_hash_rebuild(dev_net(rt->u.dst.dev));
 		}
 	}
 

^ permalink raw reply related

* [PATCH 4/5] drivers/net: Move a dereference below a NULL test
From: Julia Lawall @ 2009-07-11  7:50 UTC (permalink / raw)
  To: maxk, vtun, netdev, linux-kernel, kernel-janitors

From: Julia Lawall <julia@diku.dk>

If the NULL test is necessary, then the dereference should be moved below
the NULL test.

The semantic patch that makes this change is as follows:
(http://www.emn.fr/x-info/coccinelle/)

// <smpl>
@@
type T;
expression E;
identifier i,fld;
statement S;
@@

- T i = E->fld;
+ T i;
  ... when != E
      when != i
  if (E == NULL) S
+ i = E->fld;
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>

---
 drivers/net/tun.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff -u -p a/drivers/net/tun.c b/drivers/net/tun.c
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -486,11 +486,12 @@ static unsigned int tun_chr_poll(struct 
 {
 	struct tun_file *tfile = file->private_data;
 	struct tun_struct *tun = __tun_get(tfile);
-	struct sock *sk = tun->sk;
+	struct sock *sk;
 	unsigned int mask = 0;
 
 	if (!tun)
 		return POLLERR;
+	sk = tun->sk;
 
 	DBG(KERN_INFO "%s: tun_chr_poll\n", tun->dev->name);
 

^ permalink raw reply

* need help with wireless netns crash
From: Johannes Berg @ 2009-07-11  8:47 UTC (permalink / raw)
  To: Eric W. Biederman; +Cc: netdev

[-- Attachment #1: Type: text/plain, Size: 6175 bytes --]

Hi,

can somebody explain this comment to me?

 * Use these carefully.  If you implement a network device and it
 * needs per network namespace operations use device pernet operations,
 * otherwise use pernet subsys operations.
 *
 * This is critically important.  Most of the network code cleanup
 * runs with the assumption that dev_remove_pack has been called so no
 * new packets will arrive during and after the cleanup functions have
 * been called.  dev_remove_pack is not per namespace so instead the
 * guarantee of no more packets arriving in a network namespace is
 * provided by ensuring that all network devices and all sockets have
 * left the network namespace before the cleanup methods are called.
 *
 * For the longest time the ipv4 icmp code was registered as a pernet
 * device which caused kernel oops, and panics during network
 * namespace cleanup.   So please don't get this wrong.

I was running with this patch:
http://johannes.sipsolutions.net/patches/kernel/all/LATEST/NNN-cfg80211-netns.patch

and if I use pernet_subsys I sometimes run into this warning and the
crash below, but if I use pernet_device I don't -- and would like to
understand why.


[  732.092471] WARNING: at kernel/sysctl.c:2120 unregister_sysctl_table+0xb9/0x120()
[  732.096093] Hardware name: 
[  732.097069] Pid: 38, comm: netns Tainted: G        W  2.6.31-rc2-wl #407
[  732.099415] Call Trace:
[  732.103391]  [<ffffffff810520a6>] warn_slowpath_common+0x76/0xd0
[  732.105880]  [<ffffffff81052114>] warn_slowpath_null+0x14/0x20
[  732.108047]  [<ffffffff8105c429>] unregister_sysctl_table+0xb9/0x120
[  732.118549]  [<ffffffff813ab845>] __devinet_sysctl_unregister+0x25/0x40
[  732.120890]  [<ffffffff813ab8ec>] inetdev_destroy+0x8c/0x100
[  732.123037]  [<ffffffff813abe66>] inetdev_event+0x156/0x280
[  732.124939]  [<ffffffff81072ad5>] notifier_call_chain+0x65/0xa0
[  732.126959]  [<ffffffff81072be6>] raw_notifier_call_chain+0x16/0x20
[  732.129096]  [<ffffffff813618b6>] dev_change_net_namespace+0xc6/0x2b0
[  732.137437]  [<ffffffff813c7c9f>] cfg80211_switch_netns+0x5f/0x130
[  732.141569]  [<ffffffff813c7def>] cfg80211_pernet_exit+0x7f/0xa0
[  732.143656]  [<ffffffff8135a83e>] cleanup_net+0x5e/0xb0
[  732.145507]  [<ffffffff81067ae5>] run_workqueue+0x165/0x2a0
[  732.149376]  [<ffffffff81067ccf>] worker_thread+0xaf/0x130
[  732.155473]  [<ffffffff8106d136>] kthread+0xa6/0xb0
[  732.157144]  [<ffffffff8100c99a>] child_rip+0xa/0x20

and this error (sometimes _both_ but not always):

[  139.352125] general protection fault: 0000 [#1] PREEMPT SMP DEBUG_PAGEALLOC
[  139.354812] last sysfs file: /sys/devices/virtual/mac80211_hwsim/hwsim0/phy0/index
[  139.357859] CPU 3 
[  139.358769] Pid: 38, comm: netns Tainted: G        W  2.6.31-rc2-wl #408 
[  139.361542] RIP: 0010:[<ffffffff813b4e71>]  [<ffffffff813b4e71>] fib_magic+0x81/0xd0
[  139.361939] RSP: 0018:ffff88001fa79a10  EFLAGS: 00010202
[  139.361939] RAX: ffff88001ee75b18 RBX: 0000000000000019 RCX: 0000000000000000
[  139.361939] RDX: 6b6b6b6b6b6b6b6b RSI: 0000000000000003 RDI: ffff88001fa79a70
[  139.361939] RBP: ffff88001fa79a90 R08: 000000000000000c R09: ffff88001e4a0000
[  139.361939] R10: 0000000000000001 R11: ffff88001fa79a10 R12: 000000000100000a
[  139.361939] R13: 0000000000000018 R14: ffff88001e490cd8 R15: 000000000100000a
[  139.361939] FS:  0000000000000000(0000) GS:ffff880003d91000(0000) knlGS:0000000000000000
[  139.361939] CS:  0010 DS: 0018 ES: 0018 CR0: 000000008005003b
[  139.361939] CR2: 00007fced319b098 CR3: 000000001edb2000 CR4: 00000000000006e0
[  139.361939] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
[  139.361939] DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
[  139.361939] Process netns (pid: 38, threadinfo ffff88001fa78000, task ffff88001fa70000)
[  139.361939] Stack:
[  139.361939]  0000000100020018 0000000a00000000 0000000300000000 0000000000000000
[  139.361939] <0> 000000000100000a 0000000000000000 0000000000000000 0000000000000000
[  139.361939] <0> 00000c0000000000 0000000000000000 ffff88001e4a0000 0000000000000000
[  139.361939] Call Trace:
[  139.361939]  [<ffffffff813b5870>] fib_del_ifaddr+0x60/0x220
[  139.361939]  [<ffffffff813b5a98>] fib_inetaddr_event+0x68/0xb0
[  139.361939]  [<ffffffff81072ad5>] notifier_call_chain+0x65/0xa0
[  139.361939]  [<ffffffff81072de3>] __blocking_notifier_call_chain+0x63/0x90
[  139.361939]  [<ffffffff81072e26>] blocking_notifier_call_chain+0x16/0x20
[  139.361939]  [<ffffffff813ab589>] __inet_del_ifa+0xa9/0x220
[  139.361939]  [<ffffffff813ab8ba>] inetdev_destroy+0x5a/0x100
[  139.361939]  [<ffffffff813abe66>] inetdev_event+0x156/0x280
[  139.361939]  [<ffffffff81072ad5>] notifier_call_chain+0x65/0xa0
[  139.361939]  [<ffffffff81072be6>] raw_notifier_call_chain+0x16/0x20
[  139.361939]  [<ffffffff813618b6>] dev_change_net_namespace+0xc6/0x2b0
[  139.361939]  [<ffffffff813c7c9f>] cfg80211_switch_netns+0x5f/0x130
[  139.361939]  [<ffffffff813c7def>] cfg80211_pernet_exit+0x7f/0xa0
[  139.361939]  [<ffffffff8135a83e>] cleanup_net+0x5e/0xb0
[  139.361939]  [<ffffffff81067ae5>] run_workqueue+0x165/0x2a0
[  139.361939]  [<ffffffff81067ccf>] worker_thread+0xaf/0x130
[  139.361939]  [<ffffffff8106d136>] kthread+0xa6/0xb0
[  139.361939]  [<ffffffff8100c99a>] child_rip+0xa/0x20



It seems the problem is that during the netns removal notification I
reparent interfaces to init_net? I suppose I could just rely on that
happening automatically by unsetting only the NETNS_LOCAL flag for them
at this point? Or is this maybe too late and I need to be doing this
earlier, in some pre-removal callback?

And ... should they actually be reparented to init_net anyway? It seems
they should go to the parent of the ns if such a concept exists, since
namespaces would seem to follow the task hierarchy? If I create a netns
and from _within_ that create yet another netns it would seem that the
outer netns would get its interfaces back when the inner done goes away,
rather than its parent task's netns getting them.

Any help appreciated!

johannes

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

^ permalink raw reply

* Re: need help with wireless netns crash
From: Eric W. Biederman @ 2009-07-11  9:08 UTC (permalink / raw)
  To: Johannes Berg; +Cc: netdev
In-Reply-To: <1247302033.30647.72.camel@johannes.local>

Johannes Berg <johannes@sipsolutions.net> writes:

> Hi,
>
> can somebody explain this comment to me?
>
>  * Use these carefully.  If you implement a network device and it
>  * needs per network namespace operations use device pernet operations,
>  * otherwise use pernet subsys operations.
>  *
>  * This is critically important.  Most of the network code cleanup
>  * runs with the assumption that dev_remove_pack has been called so no
>  * new packets will arrive during and after the cleanup functions have
>  * been called.  dev_remove_pack is not per namespace so instead the
>  * guarantee of no more packets arriving in a network namespace is
>  * provided by ensuring that all network devices and all sockets have
>  * left the network namespace before the cleanup methods are called.
>  *
>  * For the longest time the ipv4 icmp code was registered as a pernet
>  * device which caused kernel oops, and panics during network
>  * namespace cleanup.   So please don't get this wrong.
>
> I was running with this patch:
> http://johannes.sipsolutions.net/patches/kernel/all/LATEST/NNN-cfg80211-netns.patch
>
> and if I use pernet_subsys I sometimes run into this warning and the
> crash below, but if I use pernet_device I don't -- and would like to
> understand why.
>
>
> [  732.092471] WARNING: at kernel/sysctl.c:2120 unregister_sysctl_table+0xb9/0x120()
> [  732.096093] Hardware name: 
> [  732.097069] Pid: 38, comm: netns Tainted: G        W  2.6.31-rc2-wl #407
> [  732.099415] Call Trace:
> [  732.103391]  [<ffffffff810520a6>] warn_slowpath_common+0x76/0xd0
> [  732.105880]  [<ffffffff81052114>] warn_slowpath_null+0x14/0x20
> [  732.108047]  [<ffffffff8105c429>] unregister_sysctl_table+0xb9/0x120
> [  732.118549]  [<ffffffff813ab845>] __devinet_sysctl_unregister+0x25/0x40
> [  732.120890]  [<ffffffff813ab8ec>] inetdev_destroy+0x8c/0x100
> [  732.123037]  [<ffffffff813abe66>] inetdev_event+0x156/0x280
> [  732.124939]  [<ffffffff81072ad5>] notifier_call_chain+0x65/0xa0
> [  732.126959]  [<ffffffff81072be6>] raw_notifier_call_chain+0x16/0x20
> [  732.129096]  [<ffffffff813618b6>] dev_change_net_namespace+0xc6/0x2b0
> [  732.137437]  [<ffffffff813c7c9f>] cfg80211_switch_netns+0x5f/0x130
> [  732.141569]  [<ffffffff813c7def>] cfg80211_pernet_exit+0x7f/0xa0
> [  732.143656]  [<ffffffff8135a83e>] cleanup_net+0x5e/0xb0
> [  732.145507]  [<ffffffff81067ae5>] run_workqueue+0x165/0x2a0
> [  732.149376]  [<ffffffff81067ccf>] worker_thread+0xaf/0x130
> [  732.155473]  [<ffffffff8106d136>] kthread+0xa6/0xb0
> [  732.157144]  [<ffffffff8100c99a>] child_rip+0xa/0x20
>
> and this error (sometimes _both_ but not always):
>
> [  139.352125] general protection fault: 0000 [#1] PREEMPT SMP DEBUG_PAGEALLOC
> [  139.354812] last sysfs file: /sys/devices/virtual/mac80211_hwsim/hwsim0/phy0/index
> [  139.357859] CPU 3 
> [  139.358769] Pid: 38, comm: netns Tainted: G        W  2.6.31-rc2-wl #408 
> [  139.361542] RIP: 0010:[<ffffffff813b4e71>]  [<ffffffff813b4e71>] fib_magic+0x81/0xd0
> [  139.361939] RSP: 0018:ffff88001fa79a10  EFLAGS: 00010202
> [  139.361939] RAX: ffff88001ee75b18 RBX: 0000000000000019 RCX: 0000000000000000
> [  139.361939] RDX: 6b6b6b6b6b6b6b6b RSI: 0000000000000003 RDI: ffff88001fa79a70
> [  139.361939] RBP: ffff88001fa79a90 R08: 000000000000000c R09: ffff88001e4a0000
> [  139.361939] R10: 0000000000000001 R11: ffff88001fa79a10 R12: 000000000100000a
> [  139.361939] R13: 0000000000000018 R14: ffff88001e490cd8 R15: 000000000100000a
> [  139.361939] FS:  0000000000000000(0000) GS:ffff880003d91000(0000) knlGS:0000000000000000
> [  139.361939] CS:  0010 DS: 0018 ES: 0018 CR0: 000000008005003b
> [  139.361939] CR2: 00007fced319b098 CR3: 000000001edb2000 CR4: 00000000000006e0
> [  139.361939] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
> [  139.361939] DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
> [  139.361939] Process netns (pid: 38, threadinfo ffff88001fa78000, task ffff88001fa70000)
> [  139.361939] Stack:
> [  139.361939]  0000000100020018 0000000a00000000 0000000300000000 0000000000000000
> [  139.361939] <0> 000000000100000a 0000000000000000 0000000000000000 0000000000000000
> [  139.361939] <0> 00000c0000000000 0000000000000000 ffff88001e4a0000 0000000000000000
> [  139.361939] Call Trace:
> [  139.361939]  [<ffffffff813b5870>] fib_del_ifaddr+0x60/0x220
> [  139.361939]  [<ffffffff813b5a98>] fib_inetaddr_event+0x68/0xb0
> [  139.361939]  [<ffffffff81072ad5>] notifier_call_chain+0x65/0xa0
> [  139.361939]  [<ffffffff81072de3>] __blocking_notifier_call_chain+0x63/0x90
> [  139.361939]  [<ffffffff81072e26>] blocking_notifier_call_chain+0x16/0x20
> [  139.361939]  [<ffffffff813ab589>] __inet_del_ifa+0xa9/0x220
> [  139.361939]  [<ffffffff813ab8ba>] inetdev_destroy+0x5a/0x100
> [  139.361939]  [<ffffffff813abe66>] inetdev_event+0x156/0x280
> [  139.361939]  [<ffffffff81072ad5>] notifier_call_chain+0x65/0xa0
> [  139.361939]  [<ffffffff81072be6>] raw_notifier_call_chain+0x16/0x20
> [  139.361939]  [<ffffffff813618b6>] dev_change_net_namespace+0xc6/0x2b0
> [  139.361939]  [<ffffffff813c7c9f>] cfg80211_switch_netns+0x5f/0x130
> [  139.361939]  [<ffffffff813c7def>] cfg80211_pernet_exit+0x7f/0xa0
> [  139.361939]  [<ffffffff8135a83e>] cleanup_net+0x5e/0xb0
> [  139.361939]  [<ffffffff81067ae5>] run_workqueue+0x165/0x2a0
> [  139.361939]  [<ffffffff81067ccf>] worker_thread+0xaf/0x130
> [  139.361939]  [<ffffffff8106d136>] kthread+0xa6/0xb0
> [  139.361939]  [<ffffffff8100c99a>] child_rip+0xa/0x20
>
>
>
> It seems the problem is that during the netns removal notification I
> reparent interfaces to init_net? I suppose I could just rely on that
> happening automatically by unsetting only the NETNS_LOCAL flag for them
> at this point? Or is this maybe too late and I need to be doing this
> earlier, in some pre-removal callback?

>
> And ... should they actually be reparented to init_net anyway? It seems
> they should go to the parent of the ns if such a concept exists, since
> namespaces would seem to follow the task hierarchy? If I create a netns
> and from _within_ that create yet another netns it would seem that the
> outer netns would get its interfaces back when the inner done goes away,
> rather than its parent task's netns getting them.

Reparenting to init_net happens for real network devices because we
don't know what to do with them and there is no true hierarchy of
network namespaces.  Virtual network devices at least ones that implement
rtnl_link_ops->dellink we destroy automatically.


> Any help appreciated!

The code for moving a network device between namespaces during
exit is in default_device_exit.  If NETIF_F_NETNS_LOCAL is set
it shouldn't trigger.


It sounds like you have both network device and subsystem level
cleanup.

In which case you probably want to split the code and use both
register_pernet_device and register_pernet_subsystem.

As for the initial comment.  Things are setup so that all network
devices are removed from a network namespace before subsystem level
cleanup happens.  This prevents all sorts of nasty cleanup races
with packets flying while a network namespace is being destroyed.

Hope that helps. If not I will try and take a more indepth look
in a bit.

Eric

^ permalink raw reply

* Re: need help with wireless netns crash
From: Johannes Berg @ 2009-07-11  9:22 UTC (permalink / raw)
  To: Eric W. Biederman; +Cc: netdev
In-Reply-To: <m11vonsi1p.fsf@fess.ebiederm.org>

On Sat, 2009-07-11 at 02:08 -0700, Eric W. Biederman wrote:

> > And ... should they actually be reparented to init_net anyway? It seems
> > they should go to the parent of the ns if such a concept exists, since
> > namespaces would seem to follow the task hierarchy? If I create a netns
> > and from _within_ that create yet another netns it would seem that the
> > outer netns would get its interfaces back when the inner done goes away,
> > rather than its parent task's netns getting them.
> 
> Reparenting to init_net happens for real network devices because we
> don't know what to do with them and there is no true hierarchy of
> network namespaces.  Virtual network devices at least ones that implement
> rtnl_link_ops->dellink we destroy automatically.

Right, I could try to destroy them too, but not all wireless interfaces
can be destroyed. Seemed easier to just move them all.

As for the hierarchy -- I would think it follows the task hierarchy? Not
that it matters to me at all where they go when the netns dies!

> The code for moving a network device between namespaces during
> exit is in default_device_exit.  If NETIF_F_NETNS_LOCAL is set
> it shouldn't trigger.

Right. I set that flag on my interfaces because we have this kind of
hierarchy:

wireless hw (phy0)
	- interface 1
	- interface 2
	- ...

and we want them all to be in the same netns together -- so I set the
flag to disallow moving, and provide a new tool (iw phy0 set netns pid)
to set the netns for the entire group.

(and each wireless hw only shows up in one netns too, due to the generic
netlink support for that kind of thing I did recently)

> It sounds like you have both network device and subsystem level
> cleanup.
> 
> In which case you probably want to split the code and use both
> register_pernet_device and register_pernet_subsystem.
> 
> As for the initial comment.  Things are setup so that all network
> devices are removed from a network namespace before subsystem level
> cleanup happens.  This prevents all sorts of nasty cleanup races
> with packets flying while a network namespace is being destroyed.
> 
> Hope that helps. If not I will try and take a more indepth look
> in a bit.

Based on that explanation, I think I really should use the device
notifier. The only thing I do is manually do the reparenting:

static void __net_exit cfg80211_pernet_exit(struct net *net)
{
        struct cfg80211_registered_device *rdev;

        rtnl_lock();
        mutex_lock(&cfg80211_mutex);
        list_for_each_entry(rdev, &cfg80211_rdev_list, list) {
                if (net_eq(wiphy_net(&rdev->wiphy), net))
                        WARN_ON(cfg80211_switch_netns(rdev, &init_net));
        }
        mutex_unlock(&cfg80211_mutex);
        rtnl_unlock();
}

cfg80211_switch_netns() moves the entire group of the wireless hw
abstraction and its associated interfaces.

Thanks for the explanation. Now I think I understand the comment too,
but before it wasn't really clear to me. How about the patch below to
the explanation?

johannes

From: Johannes Berg <johannes@sipsolutions.net>
Subject: explain netns notifiers a little better

Eric explained this to me -- and afterwards the comment
made sense, but not before. Add the the critical point
about interfaces having to be gone from the netns before
subsys notifiers are called.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
---
 include/net/net_namespace.h |   16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

--- wireless-testing.orig/include/net/net_namespace.h	2009-07-11 11:18:20.000000000 +0200
+++ wireless-testing/include/net/net_namespace.h	2009-07-11 11:20:49.000000000 +0200
@@ -239,13 +239,15 @@ struct pernet_operations {
  * needs per network namespace operations use device pernet operations,
  * otherwise use pernet subsys operations.
  *
- * This is critically important.  Most of the network code cleanup
- * runs with the assumption that dev_remove_pack has been called so no
- * new packets will arrive during and after the cleanup functions have
- * been called.  dev_remove_pack is not per namespace so instead the
- * guarantee of no more packets arriving in a network namespace is
- * provided by ensuring that all network devices and all sockets have
- * left the network namespace before the cleanup methods are called.
+ * Network interfaces need to be removed from a dying netns _before_
+ * subsys notifiers can be called, as most of the network code cleanup
+ * (which is done from subsys notifiers) runs with the assumption that
+ * dev_remove_pack has been called so no new packets will arrive during
+ * and after the cleanup functions have been called.  dev_remove_pack
+ * is not per namespace so instead the guarantee of no more packets
+ * arriving in a network namespace is provided by ensuring that all
+ * network devices and all sockets have left the network namespace
+ * before the cleanup methods are called.
  *
  * For the longest time the ipv4 icmp code was registered as a pernet
  * device which caused kernel oops, and panics during network



^ permalink raw reply

* [PATCH] sit: fix regression: do not release skb->dst before xmit
From: Sascha Hlusiak @ 2009-07-11 13:01 UTC (permalink / raw)
  To: netdev; +Cc: berni, Sascha Hlusiak

The sit module makes use of skb->dst in it's xmit function,
so since 93f154b594fe47 sit tunnels are broken, because the
flag IFF_XMIT_DST_RELEASE is not unset.

This patch unsets that flag for sit devices to fix this
regression.

Signed-off-by: Sascha Hlusiak <contact@saschahlusiak.de>
---
 net/ipv6/sit.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
index 68e5230..98b7327 100644
--- a/net/ipv6/sit.c
+++ b/net/ipv6/sit.c
@@ -1018,6 +1018,7 @@ static void ipip6_tunnel_setup(struct net_device *dev)
 	dev->hard_header_len 	= LL_MAX_HEADER + sizeof(struct iphdr);
 	dev->mtu		= ETH_DATA_LEN - sizeof(struct iphdr);
 	dev->flags		= IFF_NOARP;
+	dev->priv_flags	       &= ~IFF_XMIT_DST_RELEASE;
 	dev->iflink		= 0;
 	dev->addr_len		= 4;
 	dev->features		|= NETIF_F_NETNS_LOCAL;
-- 
1.6.3.3


^ permalink raw reply related

* Re: [PATCH] sit: fix regression: do not release skb->dst before xmit
From: Eric Dumazet @ 2009-07-11 13:24 UTC (permalink / raw)
  To: Sascha Hlusiak; +Cc: netdev, berni
In-Reply-To: <1247317289-27867-1-git-send-email-contact@saschahlusiak.de>

Sascha Hlusiak a écrit :
> The sit module makes use of skb->dst in it's xmit function,
> so since 93f154b594fe47 sit tunnels are broken, because the
> flag IFF_XMIT_DST_RELEASE is not unset.
> 
> This patch unsets that flag for sit devices to fix this
> regression.
> 
> Signed-off-by: Sascha Hlusiak <contact@saschahlusiak.de>

Acked-by: Eric Dumazet <eric.dumazet@gmail.com>

> ---
>  net/ipv6/sit.c |    1 +
>  1 files changed, 1 insertions(+), 0 deletions(-)
> 
> diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
> index 68e5230..98b7327 100644
> --- a/net/ipv6/sit.c
> +++ b/net/ipv6/sit.c
> @@ -1018,6 +1018,7 @@ static void ipip6_tunnel_setup(struct net_device *dev)
>  	dev->hard_header_len 	= LL_MAX_HEADER + sizeof(struct iphdr);
>  	dev->mtu		= ETH_DATA_LEN - sizeof(struct iphdr);
>  	dev->flags		= IFF_NOARP;
> +	dev->priv_flags	       &= ~IFF_XMIT_DST_RELEASE;
>  	dev->iflink		= 0;
>  	dev->addr_len		= 4;
>  	dev->features		|= NETIF_F_NETNS_LOCAL;


^ permalink raw reply

* Re: [patch 1/2] net, bridge: align br_nf_ops assignment
From: Cyrill Gorcunov @ 2009-07-11 14:30 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: bridge, netdev, David Miller
In-Reply-To: <20090709125500.5f8cf2a0@nehalam>

[Stephen Hemminger - Thu, Jul 09, 2009 at 12:55:00PM -0700]
| On Sat, 04 Jul 2009 10:11:57 +0400
| Cyrill Gorcunov <gorcunov@openvz.org> wrote:
| 
| > No functional change -- just for easier reading.
| > 
| > Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
| > ---
| >  net/bridge/br_netfilter.c |   96 ++++++++++++++++++++++++++--------------------
| >  1 file changed, 56 insertions(+), 40 deletions(-)
| > 
| 
| 
| Acked-by: Stephen Hemminger <shemminger@vyatta.com>
| 
| -- 
| 

Thanks for review Stephen. Will you pick them up?

	-- Cyrill

^ permalink raw reply

* [PATCH] net:  Fix sk reference counting in ip_push_pending_frames and ip6_push_pending_frames
From: John Dykstra @ 2009-07-11 17:46 UTC (permalink / raw)
  To: netdev, eric.dumazet

Commit 2b85a34e911bf483c27cfdd124aeb1605145dc80 "net: No more expensive
sock_hold()/sock_put() on each tx" used sk_wmem_alloc rather than the struct sock reference
count to track in-flight transmit-path packets.  However, it missed the __sock_put() calls
in ip_push_pending_frames() and ip6_push_pending_frames().  This results in too-small
reference counts when UDP or RAW sockets are used to send more than one MTU of data.  This 
in turn could lead to struct sock being freed and reused while it is still part of an
active socket.

A wide variety of socket symptoms may be fixed by this patch.  It also fixes one cause 
of WARN_ON's in sk_del_node_init() and sk_nulls_del_node_init_rcu().

Signed-off-by: John Dykstra <john.dykstra1@gmail.com>
---
 net/ipv4/ip_output.c  |    1 -
 net/ipv6/ip6_output.c |    1 -
 2 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
index 2470262..7d08210 100644
--- a/net/ipv4/ip_output.c
+++ b/net/ipv4/ip_output.c
@@ -1243,7 +1243,6 @@ int ip_push_pending_frames(struct sock *sk)
 		skb->len += tmp_skb->len;
 		skb->data_len += tmp_skb->len;
 		skb->truesize += tmp_skb->truesize;
-		__sock_put(tmp_skb->sk);
 		tmp_skb->destructor = NULL;
 		tmp_skb->sk = NULL;
 	}
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index 7c76e3d..87f8419 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -1484,7 +1484,6 @@ int ip6_push_pending_frames(struct sock *sk)
 		skb->len += tmp_skb->len;
 		skb->data_len += tmp_skb->len;
 		skb->truesize += tmp_skb->truesize;
-		__sock_put(tmp_skb->sk);
 		tmp_skb->destructor = NULL;
 		tmp_skb->sk = NULL;
 	}
-- 
1.5.4.3




^ permalink raw reply related

* Re: [PATCH] net:  Fix sk reference counting in ip_push_pending_frames and ip6_push_pending_frames
From: Eric Dumazet @ 2009-07-11 19:39 UTC (permalink / raw)
  To: John Dykstra; +Cc: netdev, eric.dumazet
In-Reply-To: <1247334370.7128.6.camel@Maple>

John Dykstra a écrit :
> Commit 2b85a34e911bf483c27cfdd124aeb1605145dc80 "net: No more expensive
> sock_hold()/sock_put() on each tx" used sk_wmem_alloc rather than the struct sock reference
> count to track in-flight transmit-path packets.  However, it missed the __sock_put() calls
> in ip_push_pending_frames() and ip6_push_pending_frames().  This results in too-small
> reference counts when UDP or RAW sockets are used to send more than one MTU of data.  This 
> in turn could lead to struct sock being freed and reused while it is still part of an
> active socket.
> 
> A wide variety of socket symptoms may be fixed by this patch.  It also fixes one cause 
> of WARN_ON's in sk_del_node_init() and sk_nulls_del_node_init_rcu().
> 
> Signed-off-by: John Dykstra <john.dykstra1@gmail.com>

Nice, but are you aware same patch was already posted, and is waiting for David
approval ?

http://patchwork.ozlabs.org/patch/29618/


> ---
>  net/ipv4/ip_output.c  |    1 -
>  net/ipv6/ip6_output.c |    1 -
>  2 files changed, 0 insertions(+), 2 deletions(-)
> 
> diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
> index 2470262..7d08210 100644
> --- a/net/ipv4/ip_output.c
> +++ b/net/ipv4/ip_output.c
> @@ -1243,7 +1243,6 @@ int ip_push_pending_frames(struct sock *sk)
>  		skb->len += tmp_skb->len;
>  		skb->data_len += tmp_skb->len;
>  		skb->truesize += tmp_skb->truesize;
> -		__sock_put(tmp_skb->sk);
>  		tmp_skb->destructor = NULL;
>  		tmp_skb->sk = NULL;
>  	}
> diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
> index 7c76e3d..87f8419 100644
> --- a/net/ipv6/ip6_output.c
> +++ b/net/ipv6/ip6_output.c
> @@ -1484,7 +1484,6 @@ int ip6_push_pending_frames(struct sock *sk)
>  		skb->len += tmp_skb->len;
>  		skb->data_len += tmp_skb->len;
>  		skb->truesize += tmp_skb->truesize;
> -		__sock_put(tmp_skb->sk);
>  		tmp_skb->destructor = NULL;
>  		tmp_skb->sk = NULL;
>  	}


^ permalink raw reply

* Re: [PATCH] net:  Fix sk reference counting in ip_push_pending_frames and ip6_push_pending_frames
From: John Dykstra @ 2009-07-11 20:00 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: netdev
In-Reply-To: <4A58EA7B.1000604@gmail.com>

On Sat, 2009-07-11 at 21:39 +0200, Eric Dumazet wrote:
> John Dykstra a écrit :
> > Commit 2b85a34e911bf483c27cfdd124aeb1605145dc80 "net: No more
> expensive
> > sock_hold()/sock_put() on each tx" used sk_wmem_alloc rather than
> the struct sock reference
> > count to track in-flight transmit-path packets.  However, it missed
> the __sock_put() calls
> > in ip_push_pending_frames() and ip6_push_pending_frames().  This
> results in too-small
> > reference counts when UDP or RAW sockets are used to send more than
> one MTU of data.  This 
> > in turn could lead to struct sock being freed and reused while it is
> still part of an
> > active socket.
> > 
> > A wide variety of socket symptoms may be fixed by this patch.  It
> also fixes one cause 
> > of WARN_ON's in sk_del_node_init() and sk_nulls_del_node_init_rcu().
> > 
> > Signed-off-by: John Dykstra <john.dykstra1@gmail.com>
> 
> Nice, but are you aware same patch was already posted, and is waiting
> for David
> approval ?
> 
> http://patchwork.ozlabs.org/patch/29618/

<sigh>  No, I wasn't.  It took me a while to track down where the
reference counts were going wrong, and during that time I wasn't
tracking netdev traffic.

At least it's fixed.

  --  John


^ permalink raw reply

* Re: [PATCH] drivers/net/bonding: Adjust constant name
From: Jay Vosburgh @ 2009-07-11 20:03 UTC (permalink / raw)
  To: Julia Lawall
  Cc: bonding-devel, linux-kernel, kernel-janitors, David S. Miller,
	netdev
In-Reply-To: <Pine.LNX.4.64.0907111006090.29592@ask.diku.dk>


From: Julia Lawall <julia@diku.dk>

AD_SHORT_TIMEOUT and AD_STATE_LACP_ACTIVITY have the same value, but
AD_STATE_LACP_ACTIVITY better reflects the intended semantics.

[ J adds: AD_STATE_LACP_ACTIVITY is a value defined by the standard, and
should be set here in accordance with 802.3ad 43.4.12; AD_SHORT_TIMEOUT
is a constant specific to the Linux 802.3ad implementation that happens
to have the same value ]

The semantic match that finds this problem is as follows:
(http://www.emn.fr/x-info/coccinelle/)

// <smpl>
@@
struct port_params p;
@@
* p.port_state |= AD_SHORT_TIMEOUT
// </smpl>


Signed-off-by: Julia Lawall <julia@diku.dk>
Signed-off-by: Jay Vosburgh <fubar@us.ibm.com>

---
 drivers/net/bonding/bond_3ad.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/bonding/bond_3ad.c b/drivers/net/bonding/bond_3ad.c
index d4b5708..88a1446 100644
--- a/drivers/net/bonding/bond_3ad.c
+++ b/drivers/net/bonding/bond_3ad.c
@@ -1109,7 +1109,8 @@ static void ad_rx_machine(struct lacpdu *lacpdu, struct port *port)
 			//mux machine in case of EXPIRED even if LINK_DOWN didn't arrive for the port.
 			port->partner_oper.port_state &= ~AD_STATE_SYNCHRONIZATION;
 			port->sm_vars &= ~AD_PORT_MATCHED;
-			port->partner_oper.port_state |= AD_SHORT_TIMEOUT;
+			port->partner_oper.port_state |=
+				AD_STATE_LACP_ACTIVITY;
 			port->sm_rx_timer_counter = __ad_timer_to_ticks(AD_CURRENT_WHILE_TIMER, (u16)(AD_SHORT_TIMEOUT));
 			port->actor_oper_port_state |= AD_STATE_EXPIRED;
 			break;

^ permalink raw reply related

* Re: need help with wireless netns crash
From: Eric W. Biederman @ 2009-07-11 20:26 UTC (permalink / raw)
  To: Johannes Berg; +Cc: netdev
In-Reply-To: <1247304161.30647.83.camel@johannes.local>

Johannes Berg <johannes@sipsolutions.net> writes:
> From: Johannes Berg <johannes@sipsolutions.net>
> Subject: explain netns notifiers a little better
>
> Eric explained this to me -- and afterwards the comment
> made sense, but not before. Add the the critical point
> about interfaces having to be gone from the netns before
> subsys notifiers are called.
>
> Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
> ---
>  include/net/net_namespace.h |   16 +++++++++-------
>  1 file changed, 9 insertions(+), 7 deletions(-)
>
> --- wireless-testing.orig/include/net/net_namespace.h	2009-07-11 11:18:20.000000000 +0200
> +++ wireless-testing/include/net/net_namespace.h	2009-07-11 11:20:49.000000000 +0200
> @@ -239,13 +239,15 @@ struct pernet_operations {
>   * needs per network namespace operations use device pernet operations,
>   * otherwise use pernet subsys operations.
>   *
> - * This is critically important.  Most of the network code cleanup
> - * runs with the assumption that dev_remove_pack has been called so no
> - * new packets will arrive during and after the cleanup functions have
> - * been called.  dev_remove_pack is not per namespace so instead the
> - * guarantee of no more packets arriving in a network namespace is
> - * provided by ensuring that all network devices and all sockets have
> - * left the network namespace before the cleanup methods are called.
> + * Network interfaces need to be removed from a dying netns _before_
> + * subsys notifiers can be called, as most of the network code cleanup
> + * (which is done from subsys notifiers) runs with the assumption that
> + * dev_remove_pack has been called so no new packets will arrive during
> + * and after the cleanup functions have been called.  dev_remove_pack
> + * is not per namespace so instead the guarantee of no more packets
> + * arriving in a network namespace is provided by ensuring that all
> + * network devices and all sockets have left the network namespace
> + * before the cleanup methods are called.
>   *
>   * For the longest time the ipv4 icmp code was registered as a pernet
>   * device which caused kernel oops, and panics during network

That seems like a reasonable cleanup to the wording.

Eric


^ permalink raw reply

* [PATCH] move am79c961's probe function to .devinit.text
From: Uwe Kleine-König @ 2009-07-11 20:52 UTC (permalink / raw)
  To: Greg KH, linux-kernel; +Cc: Roel Kluin, Russell King, netdev, Andrew Morton
In-Reply-To: <1247345591-22643-1-git-send-email-u.kleine-koenig@pengutronix.de>

A pointer to am79c961_probe is passed to the core via
platform_driver_register and so the function must not disappear when the
.init sections are discarded.  Otherwise (if also having HOTPLUG=y)
unbinding and binding a device to the driver via sysfs will result in an
oops as does a device being registered late.

An alternative to this patch is using platform_driver_probe instead of
platform_driver_register plus removing the pointer to the probe function
from the struct platform_driver.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Cc: Roel Kluin <12o3l@tiscali.nl>
Cc: Russell King <rmk+kernel@arm.linux.org.uk>
Cc: netdev@vger.kernel.org
Cc: Andrew Morton <akpm@linux-foundation.org>
---
 drivers/net/arm/am79c961a.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/net/arm/am79c961a.c b/drivers/net/arm/am79c961a.c
index 627bc75..51b19f2 100644
--- a/drivers/net/arm/am79c961a.c
+++ b/drivers/net/arm/am79c961a.c
@@ -680,7 +680,7 @@ static const struct net_device_ops am79c961_netdev_ops = {
 #endif
 };
 
-static int __init am79c961_probe(struct platform_device *pdev)
+static int __devinit am79c961_probe(struct platform_device *pdev)
 {
 	struct resource *res;
 	struct net_device *dev;
-- 
1.6.3.1


^ permalink raw reply related


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox