Netdev List
 help / color / mirror / Atom feed
* [PATCH 05/12] netfilter: udp proto sysctl support for net namespace
From: Gao feng @ 2012-04-17  2:56 UTC (permalink / raw)
  To: pablo; +Cc: netfilter-devel, netdev, ebiederm, serge.hallyn, dlezcano,
	Gao feng
In-Reply-To: <1334631383-12326-1-git-send-email-gaofeng@cn.fujitsu.com>

add and export four functions nf_conntrack_proto_ipv[4,6]_udp_[init,fini]
for the nf_conntrack_ipv[4,6] modules.

modify the udp_timeouts to net->ct.proto.sysctl_udp_timeouts
---
 net/netfilter/nf_conntrack_proto_udp.c |  160 +++++++++++++++++++++++++++-----
 1 files changed, 138 insertions(+), 22 deletions(-)

diff --git a/net/netfilter/nf_conntrack_proto_udp.c b/net/netfilter/nf_conntrack_proto_udp.c
index a9073dc..8e2935a 100644
--- a/net/netfilter/nf_conntrack_proto_udp.c
+++ b/net/netfilter/nf_conntrack_proto_udp.c
@@ -19,18 +19,13 @@
 #include <linux/netfilter.h>
 #include <linux/netfilter_ipv4.h>
 #include <linux/netfilter_ipv6.h>
+#include <linux/netfilter/nf_conntrack_udp.h>
 #include <net/netfilter/nf_conntrack_l4proto.h>
 #include <net/netfilter/nf_conntrack_ecache.h>
 #include <net/netfilter/nf_log.h>
 #include <net/netfilter/ipv4/nf_conntrack_ipv4.h>
 #include <net/netfilter/ipv6/nf_conntrack_ipv6.h>
 
-enum udp_conntrack {
-	UDP_CT_UNREPLIED,
-	UDP_CT_REPLIED,
-	UDP_CT_MAX
-};
-
 static unsigned int udp_timeouts[UDP_CT_MAX] = {
 	[UDP_CT_UNREPLIED]	= 30*HZ,
 	[UDP_CT_REPLIED]	= 180*HZ,
@@ -73,7 +68,7 @@ static int udp_print_tuple(struct seq_file *s,
 
 static unsigned int *udp_get_timeouts(struct net *net)
 {
-	return udp_timeouts;
+	return net->ct.proto.sysctl_udp_timeouts;
 }
 
 /* Returns verdict for packet, and may modify conntracktype */
@@ -199,8 +194,6 @@ udp_timeout_nla_policy[CTA_TIMEOUT_UDP_MAX+1] = {
 #endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */
 
 #ifdef CONFIG_SYSCTL
-static unsigned int udp_sysctl_table_users;
-static struct ctl_table_header *udp_sysctl_header;
 static struct ctl_table udp_sysctl_table[] = {
 	{
 		.procname	= "nf_conntrack_udp_timeout",
@@ -266,14 +259,6 @@ struct nf_conntrack_l4proto nf_conntrack_l4proto_udp4 __read_mostly =
 		.nla_policy	= udp_timeout_nla_policy,
 	},
 #endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */
-#ifdef CONFIG_SYSCTL
-	.ctl_table_users	= &udp_sysctl_table_users,
-	.ctl_table_header	= &udp_sysctl_header,
-	.ctl_table		= udp_sysctl_table,
-#ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT
-	.ctl_compat_table	= udp_compat_sysctl_table,
-#endif
-#endif
 };
 EXPORT_SYMBOL_GPL(nf_conntrack_l4proto_udp4);
 
@@ -304,10 +289,141 @@ struct nf_conntrack_l4proto nf_conntrack_l4proto_udp6 __read_mostly =
 		.nla_policy	= udp_timeout_nla_policy,
 	},
 #endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */
-#ifdef CONFIG_SYSCTL
-	.ctl_table_users	= &udp_sysctl_table_users,
-	.ctl_table_header	= &udp_sysctl_header,
-	.ctl_table		= udp_sysctl_table,
-#endif
 };
 EXPORT_SYMBOL_GPL(nf_conntrack_l4proto_udp6);
+
+static int nf_conntrack_proto_udp_net_init(struct net *net)
+{
+	struct ctl_table *table;
+	int i, ret = 0;
+
+#ifdef CONFIG_SYSCTL
+	if (!net->ct.proto.udp_sysctl_header) {
+		net->ct.proto.udp_table_users = 0;
+		for (i = 0; i < UDP_CT_MAX; i++)
+			net->ct.proto.sysctl_udp_timeouts[i] = udp_timeouts[i];
+		table = kmemdup(udp_sysctl_table,
+				sizeof(udp_sysctl_table),
+				GFP_KERNEL);
+		if (!table)
+			return -ENOMEM;
+		table[0].data = &net->ct.proto.
+				sysctl_udp_timeouts[UDP_CT_UNREPLIED];
+		table[1].data = &net->ct.proto.
+				sysctl_udp_timeouts[UDP_CT_REPLIED];
+	} else
+		table = net->ct.proto.udp_sysctl_header->ctl_table_arg;
+
+	ret = nf_ct_register_net_sysctl(net,
+					&net->ct.proto.udp_sysctl_header,
+					nf_net_netfilter_sysctl_path,
+					table,
+					&net->ct.proto.udp_table_users);
+	if (ret < 0) {
+		printk(KERN_ERR
+			"nf_conntrack_proto_udp:"
+			" can't register to sysctl.\n");
+		goto out_register;
+	}
+	return 0;
+out_register:
+	if (!net->ct.proto.udp_sysctl_header)
+		kfree(table);
+#else
+	for (i = 0; i < UDP_CT_MAX; i++)
+		net->ct.proto.sysctl_udp_timeouts[i] = udp_timeouts[i];
+#endif
+	return ret;
+}
+
+static void nf_conntrack_proto_udp_net_fini(struct net *net)
+{
+#ifdef CONFIG_SYSCTL
+	struct ctl_table *table;
+	table = net->ct.proto.udp_sysctl_header->ctl_table_arg;
+
+	nf_ct_unregister_net_sysctl(&net->ct.proto.udp_sysctl_header,
+				    table,
+				    &net->ct.proto.udp_table_users);
+#endif
+}
+
+static int nf_conntrack_proto_udp_compat_init(struct net *net)
+{
+	int ret = 0;
+#ifdef CONFIG_SYSCTL
+#ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT
+	struct ctl_table *compat_table;
+	compat_table = kmemdup(udp_compat_sysctl_table,
+			       sizeof(udp_compat_sysctl_table),
+			       GFP_KERNEL);
+	if (!compat_table)
+		return -ENOMEM;
+	compat_table[0].data = &net->ct.proto.
+				sysctl_udp_timeouts[UDP_CT_UNREPLIED];
+	compat_table[1].data = &net->ct.proto.
+				sysctl_udp_timeouts[UDP_CT_REPLIED];
+
+	ret = nf_ct_register_net_sysctl(net, 
+					&net->ct.proto.udp_compat_header,
+					nf_net_ipv4_netfilter_sysctl_path,
+					compat_table,
+					NULL);
+	if (ret < 0) {
+		printk(KERN_ERR
+			"nf_conntrack_proto_udp:"
+			" can't register to compat sysctl.\n");
+		goto out_register;
+	}
+	return 0;
+out_register:
+	kfree(compat_table);
+#endif
+#endif
+	return ret;
+}
+
+static void nf_conntrack_proto_udp_compat_fini(struct net *net)
+{
+#ifdef CONFIG_SYSCTL
+#ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT
+	struct ctl_table *compat_table;
+	compat_table = net->ct.proto.udp_compat_header->ctl_table_arg;
+	nf_ct_unregister_net_sysctl(&net->ct.proto.udp_compat_header,
+				    compat_table,
+				    NULL);
+#endif
+#endif
+}
+
+int nf_conntrack_proto_ipv4_udp_init(struct net *net)
+{
+	int ret = 0;
+	ret = nf_conntrack_proto_udp_net_init(net);
+	if (ret < 0)
+		return ret;
+	ret = nf_conntrack_proto_udp_compat_init(net);
+	if (ret < 0)
+		nf_conntrack_proto_udp_net_fini(net);
+	return ret;
+}
+EXPORT_SYMBOL_GPL(nf_conntrack_proto_ipv4_udp_init);
+
+void nf_conntrack_proto_ipv4_udp_fini(struct net *net)
+{
+	nf_conntrack_proto_udp_compat_fini(net);
+	nf_conntrack_proto_udp_net_fini(net);
+}
+EXPORT_SYMBOL_GPL(nf_conntrack_proto_ipv4_udp_fini);
+
+int nf_conntrack_proto_ipv6_udp_init(struct net *net)
+{
+	return nf_conntrack_proto_udp_net_init(net);
+}
+EXPORT_SYMBOL_GPL(nf_conntrack_proto_ipv6_udp_init);
+
+void nf_conntrack_proto_ipv6_udp_fini(struct net *net)
+{
+	return nf_conntrack_proto_udp_net_fini(net);
+}
+EXPORT_SYMBOL_GPL(nf_conntrack_proto_ipv6_udp_fini);
-- 
1.7.7.6

^ permalink raw reply related

* [PATCH 04/12] netfilter: tcp proto sysctl support for net namespace
From: Gao feng @ 2012-04-17  2:56 UTC (permalink / raw)
  To: pablo; +Cc: netfilter-devel, netdev, ebiederm, serge.hallyn, dlezcano,
	Gao feng
In-Reply-To: <1334631383-12326-1-git-send-email-gaofeng@cn.fujitsu.com>

add and export four functions nf_conntrack_proto_ipv[4,6]_tcp_[init,fini]
for the nf_conntrack_ipv[4,6] modules.

modify the tcp_timeouts to net->ct.proto.sysctl_tcp_timeouts,
and use net->ct.proto.sysctl_tcp* to replace nf_ct_tcp*.

Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
---
 net/netfilter/nf_conntrack_proto_tcp.c |  275 ++++++++++++++++++++++++++-----
 1 files changed, 230 insertions(+), 45 deletions(-)

diff --git a/net/netfilter/nf_conntrack_proto_tcp.c b/net/netfilter/nf_conntrack_proto_tcp.c
index 361eade..da0d240 100644
--- a/net/netfilter/nf_conntrack_proto_tcp.c
+++ b/net/netfilter/nf_conntrack_proto_tcp.c
@@ -720,7 +720,7 @@ static bool tcp_in_window(const struct nf_conn *ct,
 	} else {
 		res = false;
 		if (sender->flags & IP_CT_TCP_FLAG_BE_LIBERAL ||
-		    nf_ct_tcp_be_liberal)
+		    net->ct.proto.sysctl_tcp_be_liberal)
 			res = true;
 		if (!res && LOG_INVALID(net, IPPROTO_TCP))
 			nf_log_packet(pf, 0, skb, NULL, NULL, NULL,
@@ -815,7 +815,7 @@ static int tcp_error(struct net *net, struct nf_conn *tmpl,
 
 static unsigned int *tcp_get_timeouts(struct net *net)
 {
-	return tcp_timeouts;
+	return net->ct.proto.sysctl_tcp_timeouts;
 }
 
 /* Returns verdict for packet, or -1 for invalid. */
@@ -1019,7 +1019,7 @@ static int tcp_packet(struct nf_conn *ct,
 	    && new_state == TCP_CONNTRACK_FIN_WAIT)
 		ct->proto.tcp.seen[dir].flags |= IP_CT_TCP_FLAG_CLOSE_INIT;
 
-	if (ct->proto.tcp.retrans >= nf_ct_tcp_max_retrans &&
+	if (ct->proto.tcp.retrans >= net->ct.proto.sysctl_tcp_max_retrans &&
 	    timeouts[new_state] > timeouts[TCP_CONNTRACK_RETRANS])
 		timeout = timeouts[TCP_CONNTRACK_RETRANS];
 	else if ((ct->proto.tcp.seen[0].flags | ct->proto.tcp.seen[1].flags) &
@@ -1062,6 +1062,7 @@ static bool tcp_new(struct nf_conn *ct, const struct sk_buff *skb,
 		    unsigned int dataoff, unsigned int *timeouts)
 {
 	enum tcp_conntrack new_state;
+	struct net *net = nf_ct_net(ct);
 	const struct tcphdr *th;
 	struct tcphdr _tcph;
 	const struct ip_ct_tcp_state *sender = &ct->proto.tcp.seen[0];
@@ -1092,7 +1093,7 @@ static bool tcp_new(struct nf_conn *ct, const struct sk_buff *skb,
 			ct->proto.tcp.seen[0].td_end;
 
 		tcp_options(skb, dataoff, th, &ct->proto.tcp.seen[0]);
-	} else if (nf_ct_tcp_loose == 0) {
+	} else if (net->ct.proto.sysctl_tcp_loose == 0) {
 		/* Don't try to pick up connections. */
 		return false;
 	} else {
@@ -1352,96 +1353,104 @@ static const struct nla_policy tcp_timeout_nla_policy[CTA_TIMEOUT_TCP_MAX+1] = {
 #endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */
 
 #ifdef CONFIG_SYSCTL
-static unsigned int tcp_sysctl_table_users;
-static struct ctl_table_header *tcp_sysctl_header;
 static struct ctl_table tcp_sysctl_table[] = {
 	{
 		.procname	= "nf_conntrack_tcp_timeout_syn_sent",
-		.data		= &tcp_timeouts[TCP_CONNTRACK_SYN_SENT],
+		.data		= &init_net.ct.proto.
+				sysctl_tcp_timeouts[TCP_CONNTRACK_SYN_SENT],
 		.maxlen		= sizeof(unsigned int),
 		.mode		= 0644,
 		.proc_handler	= proc_dointvec_jiffies,
 	},
 	{
 		.procname	= "nf_conntrack_tcp_timeout_syn_recv",
-		.data		= &tcp_timeouts[TCP_CONNTRACK_SYN_RECV],
+		.data		= &init_net.ct.proto.
+				sysctl_tcp_timeouts[TCP_CONNTRACK_SYN_RECV],
 		.maxlen		= sizeof(unsigned int),
 		.mode		= 0644,
 		.proc_handler	= proc_dointvec_jiffies,
 	},
 	{
 		.procname	= "nf_conntrack_tcp_timeout_established",
-		.data		= &tcp_timeouts[TCP_CONNTRACK_ESTABLISHED],
+		.data		= &init_net.ct.proto.
+				sysctl_tcp_timeouts[TCP_CONNTRACK_ESTABLISHED],
 		.maxlen		= sizeof(unsigned int),
 		.mode		= 0644,
 		.proc_handler	= proc_dointvec_jiffies,
 	},
 	{
 		.procname	= "nf_conntrack_tcp_timeout_fin_wait",
-		.data		= &tcp_timeouts[TCP_CONNTRACK_FIN_WAIT],
+		.data		= &init_net.ct.proto.
+				sysctl_tcp_timeouts[TCP_CONNTRACK_FIN_WAIT],
 		.maxlen		= sizeof(unsigned int),
 		.mode		= 0644,
 		.proc_handler	= proc_dointvec_jiffies,
 	},
 	{
 		.procname	= "nf_conntrack_tcp_timeout_close_wait",
-		.data		= &tcp_timeouts[TCP_CONNTRACK_CLOSE_WAIT],
+		.data		= &init_net.ct.proto.
+				sysctl_tcp_timeouts[TCP_CONNTRACK_CLOSE_WAIT],
 		.maxlen		= sizeof(unsigned int),
 		.mode		= 0644,
 		.proc_handler	= proc_dointvec_jiffies,
 	},
 	{
 		.procname	= "nf_conntrack_tcp_timeout_last_ack",
-		.data		= &tcp_timeouts[TCP_CONNTRACK_LAST_ACK],
+		.data		= &init_net.ct.proto.
+				sysctl_tcp_timeouts[TCP_CONNTRACK_LAST_ACK],
 		.maxlen		= sizeof(unsigned int),
 		.mode		= 0644,
 		.proc_handler	= proc_dointvec_jiffies,
 	},
 	{
 		.procname	= "nf_conntrack_tcp_timeout_time_wait",
-		.data		= &tcp_timeouts[TCP_CONNTRACK_TIME_WAIT],
+		.data		= &init_net.ct.proto.
+				sysctl_tcp_timeouts[TCP_CONNTRACK_TIME_WAIT],
 		.maxlen		= sizeof(unsigned int),
 		.mode		= 0644,
 		.proc_handler	= proc_dointvec_jiffies,
 	},
 	{
 		.procname	= "nf_conntrack_tcp_timeout_close",
-		.data		= &tcp_timeouts[TCP_CONNTRACK_CLOSE],
+		.data		= &init_net.ct.proto.
+				sysctl_tcp_timeouts[TCP_CONNTRACK_CLOSE],
 		.maxlen		= sizeof(unsigned int),
 		.mode		= 0644,
 		.proc_handler	= proc_dointvec_jiffies,
 	},
 	{
 		.procname	= "nf_conntrack_tcp_timeout_max_retrans",
-		.data		= &tcp_timeouts[TCP_CONNTRACK_RETRANS],
+		.data		= &init_net.ct.proto.
+				sysctl_tcp_timeouts[TCP_CONNTRACK_RETRANS],
 		.maxlen		= sizeof(unsigned int),
 		.mode		= 0644,
 		.proc_handler	= proc_dointvec_jiffies,
 	},
 	{
 		.procname	= "nf_conntrack_tcp_timeout_unacknowledged",
-		.data		= &tcp_timeouts[TCP_CONNTRACK_UNACK],
+		.data		= &init_net.ct.proto.
+				sysctl_tcp_timeouts[TCP_CONNTRACK_UNACK],
 		.maxlen		= sizeof(unsigned int),
 		.mode		= 0644,
 		.proc_handler	= proc_dointvec_jiffies,
 	},
 	{
 		.procname	= "nf_conntrack_tcp_loose",
-		.data		= &nf_ct_tcp_loose,
+		.data		= &init_net.ct.proto.sysctl_tcp_loose,
 		.maxlen		= sizeof(unsigned int),
 		.mode		= 0644,
 		.proc_handler	= proc_dointvec,
 	},
 	{
 		.procname       = "nf_conntrack_tcp_be_liberal",
-		.data           = &nf_ct_tcp_be_liberal,
+		.data           = &init_net.ct.proto.sysctl_tcp_be_liberal,
 		.maxlen         = sizeof(unsigned int),
 		.mode           = 0644,
 		.proc_handler   = proc_dointvec,
 	},
 	{
 		.procname	= "nf_conntrack_tcp_max_retrans",
-		.data		= &nf_ct_tcp_max_retrans,
+		.data		= &init_net.ct.proto.sysctl_tcp_max_retrans,
 		.maxlen		= sizeof(unsigned int),
 		.mode		= 0644,
 		.proc_handler	= proc_dointvec,
@@ -1453,91 +1462,101 @@ static struct ctl_table tcp_sysctl_table[] = {
 static struct ctl_table tcp_compat_sysctl_table[] = {
 	{
 		.procname	= "ip_conntrack_tcp_timeout_syn_sent",
-		.data		= &tcp_timeouts[TCP_CONNTRACK_SYN_SENT],
+		.data		= &init_net.ct.proto.
+				sysctl_tcp_timeouts[TCP_CONNTRACK_SYN_SENT],
 		.maxlen		= sizeof(unsigned int),
 		.mode		= 0644,
 		.proc_handler	= proc_dointvec_jiffies,
 	},
 	{
 		.procname	= "ip_conntrack_tcp_timeout_syn_sent2",
-		.data		= &tcp_timeouts[TCP_CONNTRACK_SYN_SENT2],
+		.data		= &init_net.ct.proto.
+				sysctl_tcp_timeouts[TCP_CONNTRACK_SYN_SENT2],
 		.maxlen		= sizeof(unsigned int),
 		.mode		= 0644,
 		.proc_handler	= proc_dointvec_jiffies,
 	},
 	{
 		.procname	= "ip_conntrack_tcp_timeout_syn_recv",
-		.data		= &tcp_timeouts[TCP_CONNTRACK_SYN_RECV],
+		.data		= &init_net.ct.proto.
+				sysctl_tcp_timeouts[TCP_CONNTRACK_SYN_RECV],
 		.maxlen		= sizeof(unsigned int),
 		.mode		= 0644,
 		.proc_handler	= proc_dointvec_jiffies,
 	},
 	{
 		.procname	= "ip_conntrack_tcp_timeout_established",
-		.data		= &tcp_timeouts[TCP_CONNTRACK_ESTABLISHED],
+		.data		= &init_net.ct.proto.
+				sysctl_tcp_timeouts[TCP_CONNTRACK_ESTABLISHED],
 		.maxlen		= sizeof(unsigned int),
 		.mode		= 0644,
 		.proc_handler	= proc_dointvec_jiffies,
 	},
 	{
 		.procname	= "ip_conntrack_tcp_timeout_fin_wait",
-		.data		= &tcp_timeouts[TCP_CONNTRACK_FIN_WAIT],
+		.data		= &init_net.ct.proto.
+				sysctl_tcp_timeouts[TCP_CONNTRACK_FIN_WAIT],
 		.maxlen		= sizeof(unsigned int),
 		.mode		= 0644,
 		.proc_handler	= proc_dointvec_jiffies,
 	},
 	{
 		.procname	= "ip_conntrack_tcp_timeout_close_wait",
-		.data		= &tcp_timeouts[TCP_CONNTRACK_CLOSE_WAIT],
+		.data		= &init_net.ct.proto.
+				sysctl_tcp_timeouts[TCP_CONNTRACK_CLOSE_WAIT],
 		.maxlen		= sizeof(unsigned int),
 		.mode		= 0644,
 		.proc_handler	= proc_dointvec_jiffies,
 	},
 	{
 		.procname	= "ip_conntrack_tcp_timeout_last_ack",
-		.data		= &tcp_timeouts[TCP_CONNTRACK_LAST_ACK],
+		.data		= &init_net.ct.proto.
+				sysctl_tcp_timeouts[TCP_CONNTRACK_LAST_ACK],
 		.maxlen		= sizeof(unsigned int),
 		.mode		= 0644,
 		.proc_handler	= proc_dointvec_jiffies,
 	},
 	{
 		.procname	= "ip_conntrack_tcp_timeout_time_wait",
-		.data		= &tcp_timeouts[TCP_CONNTRACK_TIME_WAIT],
+		.data		= &init_net.ct.proto.
+				sysctl_tcp_timeouts[TCP_CONNTRACK_TIME_WAIT],
 		.maxlen		= sizeof(unsigned int),
 		.mode		= 0644,
 		.proc_handler	= proc_dointvec_jiffies,
 	},
 	{
 		.procname	= "ip_conntrack_tcp_timeout_close",
-		.data		= &tcp_timeouts[TCP_CONNTRACK_CLOSE],
+		.data		= &init_net.ct.proto.
+				sysctl_tcp_timeouts[TCP_CONNTRACK_CLOSE],
 		.maxlen		= sizeof(unsigned int),
 		.mode		= 0644,
 		.proc_handler	= proc_dointvec_jiffies,
 	},
 	{
 		.procname	= "ip_conntrack_tcp_timeout_max_retrans",
-		.data		= &tcp_timeouts[TCP_CONNTRACK_RETRANS],
+		.data		= &init_net.ct.proto.
+				sysctl_tcp_timeouts[TCP_CONNTRACK_RETRANS],
 		.maxlen		= sizeof(unsigned int),
 		.mode		= 0644,
 		.proc_handler	= proc_dointvec_jiffies,
 	},
 	{
 		.procname	= "ip_conntrack_tcp_loose",
-		.data		= &nf_ct_tcp_loose,
+		.data		= &init_net.ct.proto.sysctl_tcp_loose,
 		.maxlen		= sizeof(unsigned int),
 		.mode		= 0644,
 		.proc_handler	= proc_dointvec,
 	},
 	{
 		.procname	= "ip_conntrack_tcp_be_liberal",
-		.data		= &nf_ct_tcp_be_liberal,
+		.data		= &init_net.ct.proto.sysctl_tcp_be_liberal,
 		.maxlen		= sizeof(unsigned int),
 		.mode		= 0644,
 		.proc_handler	= proc_dointvec,
 	},
 	{
 		.procname	= "ip_conntrack_tcp_max_retrans",
-		.data		= &nf_ct_tcp_max_retrans,
+		.data		= &init_net.ct.proto.sysctl_tcp_max_retrans,
 		.maxlen		= sizeof(unsigned int),
 		.mode		= 0644,
 		.proc_handler	= proc_dointvec,
@@ -1579,14 +1598,6 @@ struct nf_conntrack_l4proto nf_conntrack_l4proto_tcp4 __read_mostly =
 		.nla_policy	= tcp_timeout_nla_policy,
 	},
 #endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */
-#ifdef CONFIG_SYSCTL
-	.ctl_table_users	= &tcp_sysctl_table_users,
-	.ctl_table_header	= &tcp_sysctl_header,
-	.ctl_table		= tcp_sysctl_table,
-#ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT
-	.ctl_compat_table	= tcp_compat_sysctl_table,
-#endif
-#endif
 };
 EXPORT_SYMBOL_GPL(nf_conntrack_l4proto_tcp4);
 
@@ -1622,10 +1633,184 @@ struct nf_conntrack_l4proto nf_conntrack_l4proto_tcp6 __read_mostly =
 		.nla_policy	= tcp_timeout_nla_policy,
 	},
 #endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */
-#ifdef CONFIG_SYSCTL
-	.ctl_table_users	= &tcp_sysctl_table_users,
-	.ctl_table_header	= &tcp_sysctl_header,
-	.ctl_table		= tcp_sysctl_table,
-#endif
 };
 EXPORT_SYMBOL_GPL(nf_conntrack_l4proto_tcp6);
+
+static int nf_conntrack_proto_tcp_net_init(struct net *net)
+{
+	struct ctl_table *table;
+	int i, ret;
+
+#ifdef CONFIG_SYSCTL
+	if (!net->ct.proto.tcp_sysctl_header) {
+		for (i = 0; i < TCP_CONNTRACK_TIMEOUT_MAX; i++)
+			net->ct.proto.sysctl_tcp_timeouts[i] = tcp_timeouts[i];
+		net->ct.proto.sysctl_tcp_loose = nf_ct_tcp_loose;
+		net->ct.proto.sysctl_tcp_be_liberal = nf_ct_tcp_be_liberal;
+		net->ct.proto.sysctl_tcp_max_retrans = nf_ct_tcp_max_retrans;
+		net->ct.proto.tcp_table_users = 0;	
+        	table = kmemdup(tcp_sysctl_table,
+				sizeof(tcp_sysctl_table),
+				GFP_KERNEL);
+        	if (!table) 
+                	return -ENOMEM;
+
+		table[0].data = &net->ct.proto.
+				sysctl_tcp_timeouts[TCP_CONNTRACK_SYN_SENT];
+		table[1].data = &net->ct.proto.
+				sysctl_tcp_timeouts[TCP_CONNTRACK_SYN_RECV];
+		table[2].data = &net->ct.proto.
+				sysctl_tcp_timeouts[TCP_CONNTRACK_ESTABLISHED];
+		table[3].data = &net->ct.proto.
+				sysctl_tcp_timeouts[TCP_CONNTRACK_FIN_WAIT];
+		table[4].data = &net->ct.proto.
+				sysctl_tcp_timeouts[TCP_CONNTRACK_CLOSE_WAIT];
+		table[5].data = &net->ct.proto.
+				sysctl_tcp_timeouts[TCP_CONNTRACK_LAST_ACK];
+		table[6].data = &net->ct.proto.
+				sysctl_tcp_timeouts[TCP_CONNTRACK_TIME_WAIT];
+		table[7].data = &net->ct.proto.
+				sysctl_tcp_timeouts[TCP_CONNTRACK_CLOSE];
+		table[8].data = &net->ct.proto.
+				sysctl_tcp_timeouts[TCP_CONNTRACK_RETRANS];
+		table[9].data = &net->ct.proto.
+				sysctl_tcp_timeouts[TCP_CONNTRACK_UNACK];
+		table[10].data = &net->ct.proto.sysctl_tcp_loose;
+		table[11].data = &net->ct.proto.sysctl_tcp_be_liberal;
+		table[12].data = &net->ct.proto.sysctl_tcp_max_retrans;
+	} else
+		table = net->ct.proto.tcp_sysctl_header->ctl_table_arg;
+	ret = nf_ct_register_net_sysctl(net,
+					&net->ct.proto.tcp_sysctl_header,
+					nf_net_netfilter_sysctl_path,
+					table,
+					&net->ct.proto.tcp_table_users);
+	if (ret < 0) {
+		printk(KERN_ERR
+			"nf_conntrack_proto_tcp:"
+			" can't register to sysctl.\n");
+		goto out_register;
+	}
+	return 0;
+out_register:
+	if (!net->ct.proto.tcp_sysctl_header)
+		kfree(table);
+#else
+	for (i = 0; i < TCP_CONNTRACK_TIMEOUT_MAX; i++)
+		net->ct.proto.sysctl_tcp_timeouts[i] = tcp_timeouts[i];
+	net->ct.proto.sysctl_tcp_loose = nf_ct_tcp_loose;
+	net->ct.proto.sysctl_tcp_be_liberal = nf_ct_tcp_be_liberal;
+	net->ct.proto.sysctl_tcp_max_retrans = nf_ct_tcp_max_retrans;
+#endif
+	return ret;
+}
+
+static void nf_conntrack_proto_tcp_net_fini(struct net *net)
+{
+#ifdef CONFIG_SYSCTL
+	struct ctl_table *table;
+	table = net->ct.proto.tcp_sysctl_header->ctl_table_arg;
+
+	nf_ct_unregister_net_sysctl(&net->ct.proto.tcp_sysctl_header,
+				    table,
+				    &net->ct.proto.tcp_table_users);
+#endif
+}
+
+static int nf_conntrack_proto_tcp_compat_init(struct net *net)
+{
+	int ret = 0;
+#ifdef CONFIG_SYSCTL
+#ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT
+	struct ctl_table *compat_table;
+	compat_table = kmemdup(tcp_compat_sysctl_table,
+			       sizeof(tcp_compat_sysctl_table),
+			       GFP_KERNEL);
+	if (!compat_table) 
+		return -ENOMEM;
+        
+	compat_table[0].data = &net->ct.proto.
+				sysctl_tcp_timeouts[TCP_CONNTRACK_SYN_SENT];
+	compat_table[1].data = &net->ct.proto.
+				sysctl_tcp_timeouts[TCP_CONNTRACK_SYN_SENT2];
+	compat_table[2].data = &net->ct.proto.
+				sysctl_tcp_timeouts[TCP_CONNTRACK_SYN_RECV];
+	compat_table[3].data = &net->ct.proto.
+				sysctl_tcp_timeouts[TCP_CONNTRACK_ESTABLISHED];
+	compat_table[4].data = &net->ct.proto.
+				sysctl_tcp_timeouts[TCP_CONNTRACK_FIN_WAIT];
+	compat_table[5].data = &net->ct.proto.
+				sysctl_tcp_timeouts[TCP_CONNTRACK_CLOSE_WAIT];
+	compat_table[6].data = &net->ct.proto.
+				sysctl_tcp_timeouts[TCP_CONNTRACK_LAST_ACK];
+	compat_table[7].data = &net->ct.proto.
+				sysctl_tcp_timeouts[TCP_CONNTRACK_TIME_WAIT];
+	compat_table[8].data = &net->ct.proto.
+				sysctl_tcp_timeouts[TCP_CONNTRACK_CLOSE];
+	compat_table[9].data = &net->ct.proto.
+				sysctl_tcp_timeouts[TCP_CONNTRACK_RETRANS];
+	compat_table[10].data = &net->ct.proto.sysctl_tcp_loose;
+	compat_table[11].data = &net->ct.proto.sysctl_tcp_be_liberal;
+	compat_table[12].data = &net->ct.proto.sysctl_tcp_max_retrans;
+	ret = nf_ct_register_net_sysctl(net,
+					&net->ct.proto.tcp_compat_header,
+					nf_net_ipv4_netfilter_sysctl_path,
+					compat_table, NULL);
+	if (ret < 0) {
+		printk(KERN_ERR
+			"nf_conntrack_proto_tcp:"
+			" can't register to compat sysctl.\n");
+		goto out_register;
+	}
+	return 0;
+out_register:
+	kfree(compat_table);
+#endif
+#endif
+	return ret;
+}
+
+static void nf_conntrack_proto_tcp_compat_fini(struct net *net)
+{
+#ifdef CONFIG_SYSCTL
+#ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT
+	struct ctl_table *compat_table;
+	compat_table = net->ct.proto.tcp_compat_header->ctl_table_arg;
+	nf_ct_unregister_net_sysctl(&net->ct.proto.tcp_compat_header,
+				    compat_table,
+				    NULL);
+#endif
+#endif
+}
+
+int nf_conntrack_proto_ipv4_tcp_init(struct net *net)
+{
+	int ret = 0;
+	ret = nf_conntrack_proto_tcp_net_init(net);
+	if (ret < 0)
+		return ret;
+	ret = nf_conntrack_proto_tcp_compat_init(net);
+	if (ret < 0)
+		nf_conntrack_proto_tcp_net_fini(net);
+	return ret;
+}
+EXPORT_SYMBOL_GPL(nf_conntrack_proto_ipv4_tcp_init);
+
+void nf_conntrack_proto_ipv4_tcp_fini(struct net *net)
+{
+	nf_conntrack_proto_tcp_net_fini(net);
+	nf_conntrack_proto_tcp_compat_fini(net);
+}
+EXPORT_SYMBOL_GPL(nf_conntrack_proto_ipv4_tcp_fini);
+
+int nf_conntrack_proto_ipv6_tcp_init(struct net *net)
+{
+	return nf_conntrack_proto_tcp_net_init(net);
+}
+EXPORT_SYMBOL_GPL(nf_conntrack_proto_ipv6_tcp_init);
+
+void nf_conntrack_proto_ipv6_tcp_fini(struct net *net)
+{
+	nf_conntrack_proto_tcp_net_fini(net);
+}
+EXPORT_SYMBOL_GPL(nf_conntrack_proto_ipv6_tcp_fini);
-- 
1.7.7.6

^ permalink raw reply related

* Re: pull request: linux-can 2012-04-16
From: David Miller @ 2012-04-17  3:46 UTC (permalink / raw)
  To: mkl; +Cc: netdev, linux-can, kernel
In-Reply-To: <1334605388-1549-1-git-send-email-mkl@pengutronix.de>

From: Marc Kleine-Budde <mkl@pengutronix.de>
Date: Mon, 16 Apr 2012 21:43:07 +0200

> Hello David,
> 
> there's a fix targetting net/master from Jesper Juhl, fixing a mem leak
> in the error path of the pcan_usb_pro driver. 
> 
> redards,
> Marc
> 
> The following changes since commit 8a9a0ea6032186e3030419262678d652b88bf6a8:
> 
>   net/ethernet: ks8851_mll fix rx frame buffer overflow (2012-04-14 15:21:27 -0400)
> 
> are available in the git repository at:
>   git://gitorious.org/linux-can/linux-can.git master

Pulled, thanks.

^ permalink raw reply

* Re: pull request: linux-can-next 2012-04-16
From: David Miller @ 2012-04-17  3:48 UTC (permalink / raw)
  To: mkl; +Cc: netdev, linux-can, kernel
In-Reply-To: <1334604746-24556-1-git-send-email-mkl@pengutronix.de>

From: Marc Kleine-Budde <mkl@pengutronix.de>
Date: Mon, 16 Apr 2012 21:32:24 +0200

> Hello David,
> 
> first round of linux-can updates for net-next, including a sparse warning
> fix and the conversion of the pci drivers to use module_pci_driver.
> 
> The following changes since commit f4f9f6e75d67ddfcfea79a2108217bc654aef3af:
> 
>   tcp: restore formatting of macros for tcp_skb_cb sacked field (2012-04-16 14:38:16 -0400)
> 
> are available in the git repository at:
>   git://gitorious.org/linux-can/linux-can-next.git master

Also pulled, thanks.

^ permalink raw reply

* Re: [PATCH -next] hippi: fix printk format in rrunner.c
From: David Miller @ 2012-04-17  3:48 UTC (permalink / raw)
  To: rdunlap; +Cc: sfr, linux-next, linux-kernel, netdev, linux-hippi, jes, akpm
In-Reply-To: <4F8CC0ED.2000006@xenotime.net>

From: Randy Dunlap <rdunlap@xenotime.net>
Date: Mon, 16 Apr 2012 18:01:33 -0700

> From: Randy Dunlap <rdunlap@xenotime.net>
> 
> Fix printk format warning (from i386 build):
> 
> drivers/net/hippi/rrunner.c:146:9: warning: format '%08llx' expects type 'long long unsigned int', but argument 3 has type 'resource_size_t'
> 
> Signed-off-by: Randy Dunlap <rdunlap@xenotime.net>

I'll apply this, thanks Randy.

^ permalink raw reply

* Re: [PATCH] net_sched: gred: Fix oops in gred_dump() in WRED mode
From: David Miller @ 2012-04-17  3:51 UTC (permalink / raw)
  To: david.ward; +Cc: netdev
In-Reply-To: <1334529106-5035-1-git-send-email-david.ward@ll.mit.edu>

From: David Ward <david.ward@ll.mit.edu>
Date: Sun, 15 Apr 2012 18:31:45 -0400

> A parameter set exists for WRED mode, called wred_set, to hold the same
> values for qavg and qidlestart across all VQs. The WRED mode values had
> been previously held in the VQ for the default DP. After these values
> were moved to wred_set, the VQ for the default DP was no longer created
> automatically (so that it could be omitted on purpose, to have packets
> in the default DP enqueued directly to the device without using RED).
> 
> However, gred_dump() was overlooked during that change; in WRED mode it
> still reads qavg/qidlestart from the VQ for the default DP, which might
> not even exist. As a result, this command sequence will cause an oops:
> 
> tc qdisc add dev $DEV handle $HANDLE parent $PARENT gred setup \
>     DPs 3 default 2 grio
> tc qdisc change dev $DEV handle $HANDLE gred DP 0 prio 8 $RED_OPTIONS
> tc qdisc change dev $DEV handle $HANDLE gred DP 1 prio 8 $RED_OPTIONS
> 
> This fixes gred_dump() in WRED mode to use the values held in wred_set.
> 
> Signed-off-by: David Ward <david.ward@ll.mit.edu>

Applied and queued up for -stable, thanks David.

^ permalink raw reply

* Re: [PATCH v2] net_sched: red: Make minor corrections to comments
From: David Miller @ 2012-04-17  3:53 UTC (permalink / raw)
  To: david.ward; +Cc: netdev
In-Reply-To: <1334582242-3754-1-git-send-email-david.ward@ll.mit.edu>

From: David Ward <david.ward@ll.mit.edu>
Date: Mon, 16 Apr 2012 09:17:22 -0400

> Signed-off-by: David Ward <david.ward@ll.mit.edu>

Applied, thanks David.

^ permalink raw reply

* Re: [PATCH] net: usb: smsc75xx: fix mtu
From: David Miller @ 2012-04-17  3:54 UTC (permalink / raw)
  To: fillods; +Cc: netdev, steve.glendinning
In-Reply-To: <20120415213829.GI5277@charybde.local>

From: Stephane Fillod <fillods@users.sf.net>
Date: Sun, 15 Apr 2012 23:38:29 +0200

> Make smsc75xx recalculate the hard_mtu after adjusting the
> hard_header_len.
> 
> Without this, usbnet adjusts the MTU down to 1492 bytes, and the host is
> unable to receive standard 1500-byte frames from the device.
> 
> Inspired by same fix on cdc_eem 78fb72f7936c01d5b426c03a691eca082b03f2b9.
> 
> Tested on ARM/Omap3 with EVB-LAN7500-LC.
> 
> Signed-off-by: Stephane Fillod <fillods@users.sf.net>

Applied, thanks.

^ permalink raw reply

* Re: [PATCH net] dummy: Add ndo_uninit().
From: David Miller @ 2012-04-17  3:57 UTC (permalink / raw)
  To: shimoda.hiroaki; +Cc: netdev
In-Reply-To: <20120416082601.ac00a86d.shimoda.hiroaki@gmail.com>

From: Hiroaki SHIMODA <shimoda.hiroaki@gmail.com>
Date: Mon, 16 Apr 2012 08:26:01 +0900

> In register_netdevice(), when ndo_init() is successful and later
> some error occurred, ndo_uninit() will be called.
> So dummy deivce is desirable to implement ndo_uninit() method
> to free percpu stats for this case.
> And, ndo_uninit() is also called along with dev->destructor() when
> device is unregistered, so in order to prevent dev->dstats from
> being freed twice, dev->destructor is modified to free_netdev().
> 
> Signed-off-by: Hiroaki SHIMODA <shimoda.hiroaki@gmail.com>

Applied and queued up for -stable, thanks.

^ permalink raw reply

* Re: [PATCH 6/6] vhost_net: don't poll on -EFAULT
From: Michael S. Tsirkin @ 2012-04-17  4:57 UTC (permalink / raw)
  To: Jason Wang; +Cc: netdev, xma, davem, linux-kernel, ebiederm
In-Reply-To: <4F8CE305.9090100@redhat.com>

On Tue, Apr 17, 2012 at 11:27:01AM +0800, Jason Wang wrote:
> On 04/16/2012 09:39 PM, Michael S. Tsirkin wrote:
> >On Mon, Apr 16, 2012 at 04:28:10PM +0800, Jason Wang wrote:
> >>>  On 04/16/2012 03:16 PM, Michael S. Tsirkin wrote:
> >>>>  >On Mon, Apr 16, 2012 at 02:08:33PM +0800, Jason Wang wrote:
> >>>>>  >>Currently, we restart tx polling unconditionally when sendmsg()
> >>>>>  >>fails. This would cause unnecessary wakeups of vhost wokers as it's
> >>>>>  >>only needed when the socket send buffer were exceeded.
> >>>>  >Why is this a problem?
> >>>  >  This issue is when guest driver is able to hit the
> >>-EFAULT, vhost
> >>>  discard the the descriptor and restart the polling. This would wake
> >>>  vhost thread and repeat the loop again which waste cpu.
> >Does same thing happen if we get an error from copy from user?
> >
> 
> Right, so do you think it makes sense that we only restart polling
> on -EAGAIN or -ENOBUFS?

Sounds OK. BTW how do you test this?

-- 
MST

^ permalink raw reply

* Re: [PATCH] net/ipv4:Remove two memleak reports by kmemeleak_not_leak
From: Eric Dumazet @ 2012-04-17  5:18 UTC (permalink / raw)
  To: majianpeng; +Cc: netdev
In-Reply-To: <201204170941274843290@gmail.com>

On Tue, 2012-04-17 at 09:41 +0800, majianpeng wrote:
> From 582ed93b990e88110287ed0388bcb9057b1b8591 Mon Sep 17 00:00:00 2001
> From: majianpeng <majianpeng@gmail.com>
> Date: Tue, 17 Apr 2012 09:36:26 +0800
> Subject: [PATCH] net/ipv4:Remove two memleak reports by kmemeleak_not_leak.
> 
> 
> Signed-off-by: majianpeng <majianpeng@gmail.com>
> ---
>  net/ipv4/route.c |    8 ++++++--
>  1 files changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/net/ipv4/route.c b/net/ipv4/route.c
> index 167ea10..1984c82 100644
> --- a/net/ipv4/route.c
> +++ b/net/ipv4/route.c
> @@ -3504,7 +3504,11 @@ int __init ip_rt_init(void)
>   * this nonsense will go away.
>   */
>  void __init ip_static_sysctl_init(void)
> -{
> -	register_sysctl_paths(ipv4_path, ipv4_skeleton);
> +{
> +	struct ctl_table_header *ctl_header;
> +
> +	ctl_header = register_sysctl_paths(ipv4_path, ipv4_skeleton);
> +	if (ctl_header)
> +		kmemleak_not_leak(ctl_header);
>  }
>  #endif

No need for this temp var and conditional.

Just :

	kmemleak_not_leak(register_sysctl_paths(ipv4_path, ipv4_skeleton));

^ permalink raw reply

* Re: Re: [PATCH] net/ipv4:Remove two memleak reports bykmemeleak_not_leak
From: majianpeng @ 2012-04-17  5:22 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: netdev
In-Reply-To: <1334639930.2472.4.camel@edumazet-glaptop>

Thanks,I will correct it and resent the patch.

------------------				 
majianpeng
2012-04-17

-------------------------------------------------------------
发件人:Eric Dumazet
发送日期:2012-04-17 13:18:54
收件人:majianpeng
抄送:netdev
主题:Re: [PATCH] net/ipv4:Remove two memleak reports bykmemeleak_not_leak

On Tue, 2012-04-17 at 09:41 +0800, majianpeng wrote:
> From 582ed93b990e88110287ed0388bcb9057b1b8591 Mon Sep 17 00:00:00 2001
> From: majianpeng <majianpeng@gmail.com>
> Date: Tue, 17 Apr 2012 09:36:26 +0800
> Subject: [PATCH] net/ipv4:Remove two memleak reports by kmemeleak_not_leak.
> 
> 
> Signed-off-by: majianpeng <majianpeng@gmail.com>
> ---
>  net/ipv4/route.c |    8 ++++++--
>  1 files changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/net/ipv4/route.c b/net/ipv4/route.c
> index 167ea10..1984c82 100644
> --- a/net/ipv4/route.c
> +++ b/net/ipv4/route.c
> @@ -3504,7 +3504,11 @@ int __init ip_rt_init(void)
>   * this nonsense will go away.
>   */
>  void __init ip_static_sysctl_init(void)
> -{
> -	register_sysctl_paths(ipv4_path, ipv4_skeleton);
> +{
> +	struct ctl_table_header *ctl_header;
> +
> +	ctl_header = register_sysctl_paths(ipv4_path, ipv4_skeleton);
> +	if (ctl_header)
> +		kmemleak_not_leak(ctl_header);
>  }
>  #endif

No need for this temp var and conditional.

Just :

	kmemleak_not_leak(register_sysctl_paths(ipv4_path, ipv4_skeleton));




^ permalink raw reply

* [PATCH] net/ipv4:Remove two memleak reports by kmemeleak_not_leak.
From: majianpeng @ 2012-04-17  5:33 UTC (permalink / raw)
  To: eric.dumazet; +Cc: netdev

>From fe9ae7e12cc7bdc56705eb504facb71aa86dfe65 Mon Sep 17 00:00:00 2001
From: majianpeng <majianpeng@gmail.com>
Date: Tue, 17 Apr 2012 13:29:55 +0800
Subject: [PATCH] net/ipv4:Remove two memleak reports by kmemeleak_not_leak.


Signed-off-by: majianpeng <majianpeng@gmail.com>
---
 net/ipv4/route.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 167ea10..dd15648 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -3505,6 +3505,6 @@ int __init ip_rt_init(void)
  */
 void __init ip_static_sysctl_init(void)
 {
-	register_sysctl_paths(ipv4_path, ipv4_skeleton);
+	kmemleak_not_leak(register_sysctl_paths(ipv4_path, ipv4_skeleton));
 }
 #endif
-- 
1.7.5.4

 				
--------------
majianpeng
2012-04-17

^ permalink raw reply related

* Re: [PATCH 3/6] macvtap: zerocopy: validate vector length before pinning user pages
From: Eric Dumazet @ 2012-04-17  5:33 UTC (permalink / raw)
  To: Jason Wang; +Cc: netdev, xma, davem, linux-kernel, mst, ebiederm
In-Reply-To: <4F8BD68F.7070708@redhat.com>

On Mon, 2012-04-16 at 16:21 +0800, Jason Wang wrote:
> Hi:
> On 04/16/2012 02:53 PM, Eric Dumazet wrote:
> 	if ((num_pages != size) ||
> >>   		    (num_pages>  MAX_SKB_FRAGS - skb_shinfo(skb)->nr_frags))
> >>
> > Hi Jason
> >
> > Why is -EFAULT the right error code ?
> 
> E2BIG or is there any error code you prefer?

Might be good yes.

However it sounds strange user cant write any size he wants (and kernel
needs to build several skbs to fulfill user request)

^ permalink raw reply

* Re: [PATCH] net/ipv4:Remove two memleak reports by kmemeleak_not_leak.
From: Eric Dumazet @ 2012-04-17  5:34 UTC (permalink / raw)
  To: majianpeng; +Cc: netdev
In-Reply-To: <201204171333149372727@gmail.com>

On Tue, 2012-04-17 at 13:33 +0800, majianpeng wrote:
> From fe9ae7e12cc7bdc56705eb504facb71aa86dfe65 Mon Sep 17 00:00:00 2001
> From: majianpeng <majianpeng@gmail.com>
> Date: Tue, 17 Apr 2012 13:29:55 +0800
> Subject: [PATCH] net/ipv4:Remove two memleak reports by kmemeleak_not_leak.
> 
> 
> Signed-off-by: majianpeng <majianpeng@gmail.com>
> ---
>  net/ipv4/route.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/net/ipv4/route.c b/net/ipv4/route.c
> index 167ea10..dd15648 100644
> --- a/net/ipv4/route.c
> +++ b/net/ipv4/route.c
> @@ -3505,6 +3505,6 @@ int __init ip_rt_init(void)
>   */
>  void __init ip_static_sysctl_init(void)
>  {
> -	register_sysctl_paths(ipv4_path, ipv4_skeleton);
> +	kmemleak_not_leak(register_sysctl_paths(ipv4_path, ipv4_skeleton));
>  }
>  #endif

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

Thanks

^ permalink raw reply

* Re: [PATCH 3/6] macvtap: zerocopy: validate vector length before pinning user pages
From: Michael S. Tsirkin @ 2012-04-17  5:43 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: Jason Wang, netdev, xma, davem, linux-kernel, ebiederm
In-Reply-To: <1334640808.2472.6.camel@edumazet-glaptop>

On Tue, Apr 17, 2012 at 07:33:28AM +0200, Eric Dumazet wrote:
> On Mon, 2012-04-16 at 16:21 +0800, Jason Wang wrote:
> > Hi:
> > On 04/16/2012 02:53 PM, Eric Dumazet wrote:
> > 	if ((num_pages != size) ||
> > >>   		    (num_pages>  MAX_SKB_FRAGS - skb_shinfo(skb)->nr_frags))
> > >>
> > > Hi Jason
> > >
> > > Why is -EFAULT the right error code ?
> > 
> > E2BIG or is there any error code you prefer?
> 
> Might be good yes.
> 
> However it sounds strange user cant write any size he wants (and kernel
> needs to build several skbs to fulfill user request)

We never supported arbitrary length writes:
macvtap is exactly like packet sockets in this regard.

-- 
MST

^ permalink raw reply

* Re: [PATCH 6/6] vhost_net: don't poll on -EFAULT
From: Jason Wang @ 2012-04-17  5:54 UTC (permalink / raw)
  To: Michael S. Tsirkin; +Cc: netdev, xma, davem, linux-kernel, ebiederm
In-Reply-To: <20120417045736.GA31278@redhat.com>

On 04/17/2012 12:57 PM, Michael S. Tsirkin wrote:
> On Tue, Apr 17, 2012 at 11:27:01AM +0800, Jason Wang wrote:
>> On 04/16/2012 09:39 PM, Michael S. Tsirkin wrote:
>>> On Mon, Apr 16, 2012 at 04:28:10PM +0800, Jason Wang wrote:
>>>>>   On 04/16/2012 03:16 PM, Michael S. Tsirkin wrote:
>>>>>>   >On Mon, Apr 16, 2012 at 02:08:33PM +0800, Jason Wang wrote:
>>>>>>>   >>Currently, we restart tx polling unconditionally when sendmsg()
>>>>>>>   >>fails. This would cause unnecessary wakeups of vhost wokers as it's
>>>>>>>   >>only needed when the socket send buffer were exceeded.
>>>>>>   >Why is this a problem?
>>>>>   >   This issue is when guest driver is able to hit the
>>>> -EFAULT, vhost
>>>>>   discard the the descriptor and restart the polling. This would wake
>>>>>   vhost thread and repeat the loop again which waste cpu.
>>> Does same thing happen if we get an error from copy from user?
>>>
>> Right, so do you think it makes sense that we only restart polling
>> on -EAGAIN or -ENOBUFS?
> Sounds OK. BTW how do you test this?
>

Not very hard, w/o this patch, we can see almost 100% cpu utilization 
for vhost thread if guest hit EFAULT or EINVAL. With this patch, the cpu 
utilization should be very low I think.

^ permalink raw reply

* [PATCH] net/core:Remove  memleak reports bykmemeleak_not_leak.
From: majianpeng @ 2012-04-17  5:58 UTC (permalink / raw)
  To: davem; +Cc: netdev

>From 40131df5df1850b6d0a653f23698b13047c640ec Mon Sep 17 00:00:00 2001
From: majianpeng <majianpeng@gmail.com>
Date: Tue, 17 Apr 2012 13:55:39 +0800
Subject: [PATCH] net/core:Remove  memleak reports bykmemeleak_not_leak.


Signed-off-by: majianpeng <majianpeng@gmail.com>
---
 net/core/sysctl_net_core.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
index 0c28508..cee5991 100644
--- a/net/core/sysctl_net_core.c
+++ b/net/core/sysctl_net_core.c
@@ -256,7 +256,7 @@ static __init int sysctl_core_init(void)
 {
 	static struct ctl_table empty[1];
 
-	register_sysctl_paths(net_core_path, empty);
+	kmemleak_not_leak(register_sysctl_paths(net_core_path, empty));
 	register_net_sysctl_rotable(net_core_path, net_core_table);
 	return register_pernet_subsys(&sysctl_core_ops);
 }
-- 
1.7.5.4

 				
--------------
majianpeng
2012-04-17

^ permalink raw reply related

* Re: [PATCH 6/6] vhost_net: don't poll on -EFAULT
From: Michael S. Tsirkin @ 2012-04-17  6:07 UTC (permalink / raw)
  To: Jason Wang; +Cc: netdev, xma, davem, linux-kernel, ebiederm
In-Reply-To: <4F8D05AF.4000309@redhat.com>

On Tue, Apr 17, 2012 at 01:54:55PM +0800, Jason Wang wrote:
> On 04/17/2012 12:57 PM, Michael S. Tsirkin wrote:
> >On Tue, Apr 17, 2012 at 11:27:01AM +0800, Jason Wang wrote:
> >>On 04/16/2012 09:39 PM, Michael S. Tsirkin wrote:
> >>>On Mon, Apr 16, 2012 at 04:28:10PM +0800, Jason Wang wrote:
> >>>>>  On 04/16/2012 03:16 PM, Michael S. Tsirkin wrote:
> >>>>>>  >On Mon, Apr 16, 2012 at 02:08:33PM +0800, Jason Wang wrote:
> >>>>>>>  >>Currently, we restart tx polling unconditionally when sendmsg()
> >>>>>>>  >>fails. This would cause unnecessary wakeups of vhost wokers as it's
> >>>>>>>  >>only needed when the socket send buffer were exceeded.
> >>>>>>  >Why is this a problem?
> >>>>>  >   This issue is when guest driver is able to hit the
> >>>>-EFAULT, vhost
> >>>>>  discard the the descriptor and restart the polling. This would wake
> >>>>>  vhost thread and repeat the loop again which waste cpu.
> >>>Does same thing happen if we get an error from copy from user?
> >>>
> >>Right, so do you think it makes sense that we only restart polling
> >>on -EAGAIN or -ENOBUFS?
> >Sounds OK. BTW how do you test this?
> >
> 
> Not very hard, w/o this patch, we can see almost 100% cpu
> utilization for vhost thread if guest hit EFAULT or EINVAL. With
> this patch, the cpu utilization should be very low I think.

Yes but do you have a test that makes guest hit EFAULT or EINVAL?

^ permalink raw reply

* [PATCH] set fake_rtable's dst to NULL to avoid kernel Oops.
From: Peter Huang (Peng) @ 2012-04-17  6:22 UTC (permalink / raw)
  To: shemminger, 'David S. Miller', netdev
  Cc: eric.dumazet, linux-kernel, ctrix+debianbugs, peter.huangpeng,
	peter.huangpeng, harry.majun

When bridge is deleted before tap/vif device's delete, kernel may encounter an oops because of NULL reference to fake_rtable's dst.
Set fake_rtable's dst to NULL before sending packets out can solve this problem.


Acked-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: Peter Huang <peter.huangpeng@huawei.com>
---
include/linux/netfilter_bridge.h |    8 ++++++++
 net/bridge/br_forward.c          |    1 +
 net/bridge/br_netfilter.c        |    6 +-----
 3 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/include/linux/netfilter_bridge.h b/include/linux/netfilter_bridge.h
index 0ddd161..70744fe 100644
--- a/include/linux/netfilter_bridge.h
+++ b/include/linux/netfilter_bridge.h
@@ -104,9 +104,17 @@ struct bridge_skb_cb {
 	} daddr;
 };
 
+static inline void br_drop_fake_rtable(struct sk_buff *skb) {
+	struct dst_entry *dst = skb_dst(skb);
+	/* abuse fact that only fake_rtable has DST_NOPEER set */
+	if (dst && (dst->flags & DST_NOPEER))
+		skb_dst_drop(skb);
+}
+
 #else
 #define nf_bridge_maybe_copy_header(skb)	(0)
 #define nf_bridge_pad(skb)			(0)
+#define br_drop_fake_rtable(skb)		(0)
 #endif /* CONFIG_BRIDGE_NETFILTER */
 
 #endif /* __KERNEL__ */
diff --git a/net/bridge/br_forward.c b/net/bridge/br_forward.c index 61f6534..a2098e3 100644
--- a/net/bridge/br_forward.c
+++ b/net/bridge/br_forward.c
@@ -47,6 +47,7 @@ int br_dev_queue_push_xmit(struct sk_buff *skb)
 		kfree_skb(skb);
 	} else {
 		skb_push(skb, ETH_HLEN);
+		br_drop_fake_rtable(skb);
 		dev_queue_xmit(skb);
 	}
 
diff --git a/net/bridge/br_netfilter.c b/net/bridge/br_netfilter.c index dec4f38..946dcb0 100644
--- a/net/bridge/br_netfilter.c
+++ b/net/bridge/br_netfilter.c
@@ -694,11 +694,7 @@ static unsigned int br_nf_local_in(unsigned int hook, struct sk_buff *skb,
 				   const struct net_device *out,
 				   int (*okfn)(struct sk_buff *))
 {
-	struct rtable *rt = skb_rtable(skb);
-
-	if (rt && rt == bridge_parent_rtable(in))
-		skb_dst_drop(skb);
-
+	br_drop_fake_rtable(skb);
 	return NF_ACCEPT;
 }
--------------------------------
Peter Huang(peng)

^ permalink raw reply related

* Re: [PATCH 6/6] vhost_net: don't poll on -EFAULT
From: Jason Wang @ 2012-04-17  6:30 UTC (permalink / raw)
  To: Michael S. Tsirkin; +Cc: netdev, xma, davem, linux-kernel, ebiederm
In-Reply-To: <20120417060752.GB20674@redhat.com>

On 04/17/2012 02:07 PM, Michael S. Tsirkin wrote:
> On Tue, Apr 17, 2012 at 01:54:55PM +0800, Jason Wang wrote:
>> On 04/17/2012 12:57 PM, Michael S. Tsirkin wrote:
>>> On Tue, Apr 17, 2012 at 11:27:01AM +0800, Jason Wang wrote:
>>>> On 04/16/2012 09:39 PM, Michael S. Tsirkin wrote:
>>>>> On Mon, Apr 16, 2012 at 04:28:10PM +0800, Jason Wang wrote:
>>>>>>>   On 04/16/2012 03:16 PM, Michael S. Tsirkin wrote:
>>>>>>>>   >On Mon, Apr 16, 2012 at 02:08:33PM +0800, Jason Wang wrote:
>>>>>>>>>   >>Currently, we restart tx polling unconditionally when sendmsg()
>>>>>>>>>   >>fails. This would cause unnecessary wakeups of vhost wokers as it's
>>>>>>>>>   >>only needed when the socket send buffer were exceeded.
>>>>>>>>   >Why is this a problem?
>>>>>>>   >    This issue is when guest driver is able to hit the
>>>>>> -EFAULT, vhost
>>>>>>>   discard the the descriptor and restart the polling. This would wake
>>>>>>>   vhost thread and repeat the loop again which waste cpu.
>>>>> Does same thing happen if we get an error from copy from user?
>>>>>
>>>> Right, so do you think it makes sense that we only restart polling
>>>> on -EAGAIN or -ENOBUFS?
>>> Sounds OK. BTW how do you test this?
>>>
>> Not very hard, w/o this patch, we can see almost 100% cpu
>> utilization for vhost thread if guest hit EFAULT or EINVAL. With
>> this patch, the cpu utilization should be very low I think.
> Yes but do you have a test that makes guest hit EFAULT or EINVAL?

Looks like we can do this by supplying an invalid hdr_len in vnet header 
as tap does the check for this.
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* Re: [PATCH 3/6] macvtap: zerocopy: validate vector length before pinning user pages
From: Michael S. Tsirkin @ 2012-04-17  6:19 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: Jason Wang, netdev, xma, davem, linux-kernel, ebiederm
In-Reply-To: <1334559183.28012.45.camel@edumazet-glaptop>

On Mon, Apr 16, 2012 at 08:53:03AM +0200, Eric Dumazet wrote:
> On Mon, 2012-04-16 at 14:08 +0800, Jason Wang wrote:
> > Currently we do not validate the vector length before calling
> > get_user_pages_fast(), host stack would be easily overflowed by
> > malicious guest driver who give us a descriptor with length greater
> > than MAX_SKB_FRAGS. Solve this problem by checking the free entries
> > before trying to pin user pages.
> > 
> > Signed-off-by: Jason Wang <jasowang@redhat.com>
> > ---
> >  drivers/net/macvtap.c |    2 ++
> >  1 files changed, 2 insertions(+), 0 deletions(-)
> > 
> > diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
> > index 7cb2684..d197a78 100644
> > --- a/drivers/net/macvtap.c
> > +++ b/drivers/net/macvtap.c
> > @@ -529,6 +529,8 @@ static int zerocopy_sg_from_iovec(struct sk_buff *skb, const struct iovec *from,
> >  		}
> >  		base = (unsigned long)from->iov_base + offset;
> >  		size = ((base & ~PAGE_MASK) + len + ~PAGE_MASK) >> PAGE_SHIFT;
> > +		if (i + size >= MAX_SKB_FRAGS)
> > +			return -EFAULT;
> >  		num_pages = get_user_pages_fast(base, size, 0, &page[i]);
> >  		if ((num_pages != size) ||
> >  		    (num_pages > MAX_SKB_FRAGS - skb_shinfo(skb)->nr_frags))
> > 
> 
> Hi Jason
> 
> Why is -EFAULT the right error code ?


skb_copy_datagram_from_iovec return -EFAULT on iovs
that are too large, too, so this is at least consistent.

-- 
MST

^ permalink raw reply

* [PATCH] SFC: Default to 'n' for Solarflare device.
From: Tao Ma @ 2012-04-17  7:33 UTC (permalink / raw)
  To: netdev; +Cc: linux-net-drivers, Ben Hutchings

From: Tao Ma <boyu.mt@taobao.com>

We make oldconfig every time when a new kernel arrives, but
if we don't have such a device(I guess this is the most common
case for a new device), the default value should be 'n' so
that the kernel size we build doesn't grow up too much quickly.
For anyone who has the device, it is OK for them to turn it on
by themselves. And it goes with these Solarflare devices.

Cc: Ben Hutchings <bhutchings@solarflare.com>
Signed-off-by: Tao Ma <boyu.mt@taobao.com>
---
 drivers/net/ethernet/sfc/Kconfig |    3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/sfc/Kconfig b/drivers/net/ethernet/sfc/Kconfig
index fb3cbc2..bb643c4 100644
--- a/drivers/net/ethernet/sfc/Kconfig
+++ b/drivers/net/ethernet/sfc/Kconfig
@@ -14,7 +14,6 @@ config SFC
 config SFC_MTD
 	bool "Solarflare SFC4000/SFC9000-family MTD support"
 	depends on SFC && MTD && !(SFC=y && MTD=m)
-	default y
 	---help---
 	  This exposes the on-board flash and/or EEPROM as MTD devices
 	  (e.g. /dev/mtd1).  This is required to update the firmware or
@@ -22,14 +21,12 @@ config SFC_MTD
 config SFC_MCDI_MON
 	bool "Solarflare SFC9000-family hwmon support"
 	depends on SFC && HWMON && !(SFC=y && HWMON=m)
-	default y
 	----help---
 	  This exposes the on-board firmware-managed sensors as a
 	  hardware monitor device.
 config SFC_SRIOV
 	bool "Solarflare SFC9000-family SR-IOV support"
 	depends on SFC && PCI_IOV
-	default y
 	---help---
 	  This enables support for the SFC9000 I/O Virtualization
 	  features, allowing accelerated network performance in
-- 
1.7.6.1

^ permalink raw reply related

* Re: Netlink, route monitoring, RTM_DELROUTE not issued for ppp peer address. Bug or feature?
From: David Lamparter @ 2012-04-17  8:24 UTC (permalink / raw)
  To: Stian Skjelstad
  Cc: Denys Fedoryshchenko, Stephen Hemminger, eric.dumazet,
	stephen.hemminger, netdev
In-Reply-To: <2f6d1271c8c6811acbbc5b2603c72115.squirrel@nlc.no>

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

On Mon, Apr 16, 2012 at 10:21:46PM +0200, Stian Skjelstad wrote:
> > It looks like "correct" behavior should not harm existing programs that
> > much (just there will be netlink message to delete route that are
> > already deleted by program, e.g. quagga), but looking to code,
> > implementing this feature will make significant overhead and in some
> > cases it can be harmful.
> > For example if full view BGP interface dropped, it is hundreds of
> > thousands netlink messages. So seems better i will listen to
> > address/link changes also and keep routing table in memory.
> > So better seems to keep as is.

Yes, this concern is quite real, I'd very much like to avoid processing
400000 DELROUTE messages that add exactly 0 additional meaning since it
can be inferred from the interface going down.

> If I understand correct, the "missing" RTM_DELROUTE messages actually
> comes from something similar to "ip route flush dev eth0".
> 
> If the amount of traffic is a worry, couldn't there be a RTM_FLUSHROUTE or
> a special RTM_DELROUTE message that tells that all routes for a given
> device is removed?

The interface-down message has exactly these semantics. I don't know
if/where this is documented, but adding a new message seems superfluous
to me, especially at this point where compatibility is a concern.
(The ip route flush command deletes routes individually btw.)

-David

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 230 bytes --]

^ permalink raw reply

* RE: [PATCH 04/37] atl1c: remove VPD register
From: Huang, Xiong @ 2012-04-17  8:36 UTC (permalink / raw)
  To: Ben Hutchings
  Cc: David Miller, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, qca-linux-team, nic-devel
In-Reply-To: <1334413369.7150.422.camel@deadeye>

Ok, I will update it. thanks a lot

-Xiong
________________________________________
发件人: Ben Hutchings [bhutchings@solarflare.com]
发送时间: 2012年4月14日 22:22
收件人: Huang, Xiong
Cc: David Miller; netdev@vger.kernel.org; linux-kernel@vger.kernel.org; qca-linux-team; nic-devel
主题: RE: [PATCH 04/37] atl1c: remove VPD register

On Sat, 2012-04-14 at 09:12 +0000, Huang, Xiong wrote:
>
> > -----Original Message-----
> > From: David Miller [mailto:davem@davemloft.net]
> > Sent: Saturday, April 14, 2012 8:46
> > To: Huang, Xiong
> > Cc: netdev@vger.kernel.org; linux-kernel@vger.kernel.org; qca-linux-team; nic-
> > devel
> > Subject: Re: [PATCH 04/37] atl1c: remove VPD register
> >
> > From: xiong <xiong@qca.qualcomm.com>
> > Date: Fri, 13 Apr 2012 08:14:29 +0800
> >
> > > VPD register is only used for L1(devid=PCI_DEVICE_ID_ATTANSIC_L1) to
> > > access external NV-memory.
> > > l1c & later chip doesn't use it any more.
> > >
> > > Signed-off-by: xiong <xiong@qca.qualcomm.com>
> > > Tested-by: Liu David <dwliu@qca.qualcomm.com>
> >
> > You just broke ethtool register dumps with this change.
> >
> > Now, all the initial registers are reported offset by one entry, yet the last two are
> > still reported in their original spots.
> >
> > This layout is exposed to userspace, and interpreted by tools, and you cannot
> > change it.
> >
> > If this register always reports some value, you should just keep it there in the
> > dumps.
> >
> The VPD register doesn't report anything :(, just a dummy register now.
> we don't have any special tools in userspace to explain the dumped registers.
> Actually the purpose of dumping these registers via ethtool is just for debug.
[...]

Of course, the whole purpose of the operation is for debugging.  But you
should bump the dump version number (currently 0) every time you change
the offsets of registers in the dump.

Ben.

--
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.


^ permalink raw reply


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