Skip to contentSkip to conversation

netfilter: netfilter fixes for 2.6.39-rc7

PATCH In review [email protected] 3 participants 15 messages May 10, 2011 – May 15, 2011

Subsystems (5)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

cover netfilter: netfilter fixes for 2.6.39-rc7

From: Pablo Neira Ayuso <[email protected]>

Hi Dave,

following are eight netfilter fixes for 2.6.39-rc7, containing:

- one fix for ebtables compat

- a couple of fixes for netfilter IPv6 targets from Fernando Luis Vazquez

- a couple of fixes for IPVS things that were pushed into 2.6.39-rc1

- revert one patch for the conntrack match

- fix timestamp support in ctnetlink for newly created conntracks

Please pull from:

git://1984.lsi.us.es/net-2.6 pablo/nf-2.6-updates

Thanks!

Eric Dumazet (1):
netfilter: fix ebtables compat support

Fernando Luis Vazquez Cao (2):
netfilter: IPv6: initialize TOS field in REJECT target module
netfilter: IPv6: fix DSCP mangle code

Florian Westphal (1):
netfilter: ebtables: only call xt_compat_add_offset once per rule

Hans Schillstrom (2):
IPVS: Change of socket usage to enable name space exit.
IPVS: init and cleanup restructuring

Pablo Neira Ayuso (2):
netfilter: ctnetlink: fix timestamp support for new conntracks
netfilter: revert a2361c8735e07322023aedc36e4938b35af31eb0

 include/net/ip_vs.h                  |   17 +++++
 net/bridge/netfilter/ebtables.c      |   64 +++---------------
 net/ipv6/netfilter/ip6t_REJECT.c     |    4 +-
 net/netfilter/ipvs/ip_vs_app.c       |   15 +----
 net/netfilter/ipvs/ip_vs_conn.c      |   12 +---
 net/netfilter/ipvs/ip_vs_core.c      |  103 ++++++++++++++++++++++++++---
 net/netfilter/ipvs/ip_vs_ctl.c       |  120 ++++++++++++++++++++++++++++-----
 net/netfilter/ipvs/ip_vs_est.c       |   14 +---
 net/netfilter/ipvs/ip_vs_proto.c     |   11 +---
 net/netfilter/ipvs/ip_vs_sync.c      |   65 ++++++++++--------
 net/netfilter/nf_conntrack_netlink.c |    4 +
 net/netfilter/x_tables.c             |    4 +-
 net/netfilter/xt_conntrack.c         |    5 --
 13 files changed, 278 insertions(+), 160 deletions(-)
Signature · 1 line
1.7.2.3
author maintainer
#1 lore raw

PATCH 1/8 netfilter: ctnetlink: fix timestamp support for new conntracks

From: Pablo Neira Ayuso <[email protected]>

This patch fixes the missing initialization of the start time if the timestamp support is enabled.

libnetfilter_conntrack/utils# conntrack -E &
libnetfilter_conntrack/utils# ./conntrack_create
tcp 6 109 ESTABLISHED src=1.1.1.1 dst=2.2.2.2 sport=1025 dport=21 packets=0 bytes=0 [UNREPLIED] src=2.2.2.2 dst=1.1.1.1 sport=21 dport=1025 packets=0 bytes=0 mark=0 delta-time=1303296401 use=2

---
 net/netfilter/nf_conntrack_netlink.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
net/netfilter/nf_conntrack_netlink.c +4 -0
index 30bf8a1..482e90c 100644
@@ -1334,6 +1334,7 @@ ctnetlink_create_conntrack(struct net *net, u16 zone,
 	struct nf_conn *ct;
 	int err = -EINVAL;
 	struct nf_conntrack_helper *helper;
+	struct nf_conn_tstamp *tstamp;
 
 	ct = nf_conntrack_alloc(net, zone, otuple, rtuple, GFP_ATOMIC);
 	if (IS_ERR(ct))
@@ -1451,6 +1452,9 @@ ctnetlink_create_conntrack(struct net *net, u16 zone,
 		__set_bit(IPS_EXPECTED_BIT, &ct->status);
 		ct->master = master_ct;
 	}
+	tstamp = nf_conn_tstamp_find(ct);
+	if (tstamp)
+		tstamp->start = ktime_to_ns(ktime_get_real());
 
 	add_timer(&ct->timeout);
 	nf_conntrack_hash_insert(ct);
Signature · 1 line
1.7.2.3
author maintainer
#2 lore raw

PATCH 2/8 netfilter: fix ebtables compat support

In reply to [email protected]

From: Eric Dumazet <[email protected]>

commit 255d0dc34068a976 (netfilter: x_table: speedup compat operations) made ebtables not working anymore.

1) xt_compat_calc_jump() is not an exact match lookup
2) compat_table_info() has a typo in xt_compat_init_offsets() call
3) compat_do_replace() misses a xt_compat_init_offsets() call

---
 net/bridge/netfilter/ebtables.c |    3 ++-
 net/netfilter/x_tables.c        |    4 ++--
 2 files changed, 4 insertions(+), 3 deletions(-)
net/bridge/netfilter/ebtables.c +2 -1
index 893669c..9707079 100644
@@ -1766,7 +1766,7 @@ static int compat_table_info(const struct ebt_table_info *info,
 
 	newinfo->entries_size = size;
 
-	xt_compat_init_offsets(AF_INET, info->nentries);
+	xt_compat_init_offsets(NFPROTO_BRIDGE, info->nentries);
 	return EBT_ENTRY_ITERATE(entries, size, compat_calc_entry, info,
 							entries, newinfo);
 }
@@ -2240,6 +2240,7 @@ static int compat_do_replace(struct net *net, void __user *user,
 
 	xt_compat_lock(NFPROTO_BRIDGE);
 
+	xt_compat_init_offsets(NFPROTO_BRIDGE, tmp.nentries);
 	ret = compat_copy_entries(entries_tmp, tmp.entries_size, &state);
 	if (ret < 0)
 		goto out_unlock;
net/netfilter/x_tables.c +2 -2
index a9adf4c..8a025a5 100644
@@ -455,6 +455,7 @@ void xt_compat_flush_offsets(u_int8_t af)
 		vfree(xt[af].compat_tab);
 		xt[af].compat_tab = NULL;
 		xt[af].number = 0;
+		xt[af].cur = 0;
 	}
 }
 EXPORT_SYMBOL_GPL(xt_compat_flush_offsets);
@@ -473,8 +474,7 @@ int xt_compat_calc_jump(u_int8_t af, unsigned int offset)
 		else
 			return mid ? tmp[mid - 1].delta : 0;
 	}
-	WARN_ON_ONCE(1);
-	return 0;
+	return left ? tmp[left - 1].delta : 0;
 }
 EXPORT_SYMBOL_GPL(xt_compat_calc_jump);
 
Signature · 1 line
1.7.2.3
author maintainer
#3 lore raw

Re: [PATCH 2/8] netfilter: fix ebtables compat support

I'll pass this to -stable, let me know if you don't want to happen.

Quoted 60 lines · On 10/05/11 12:05, [email protected] wrote:

From: Eric Dumazet <[email protected]>

commit 255d0dc34068a976 (netfilter: x_table: speedup compat operations) made ebtables not working anymore.

1) xt_compat_calc_jump() is not an exact match lookup
2) compat_table_info() has a typo in xt_compat_init_offsets() call
3) compat_do_replace() misses a xt_compat_init_offsets() call

---
 net/bridge/netfilter/ebtables.c |    3 ++-
 net/netfilter/x_tables.c        |    4 ++--
 2 files changed, 4 insertions(+), 3 deletions(-)
net/bridge/netfilter/ebtables.c +2 -1
index 893669c..9707079 100644
@@ -1766,7 +1766,7 @@ static int compat_table_info(const struct ebt_table_info *info,
 
 	newinfo->entries_size = size;
 
-	xt_compat_init_offsets(AF_INET, info->nentries);
+	xt_compat_init_offsets(NFPROTO_BRIDGE, info->nentries);
 	return EBT_ENTRY_ITERATE(entries, size, compat_calc_entry, info,
 							entries, newinfo);
 }
@@ -2240,6 +2240,7 @@ static int compat_do_replace(struct net *net, void __user *user,
 
 	xt_compat_lock(NFPROTO_BRIDGE);
 
+	xt_compat_init_offsets(NFPROTO_BRIDGE, tmp.nentries);
 	ret = compat_copy_entries(entries_tmp, tmp.entries_size, &state);
 	if (ret < 0)
 		goto out_unlock;
net/netfilter/x_tables.c +2 -2
index a9adf4c..8a025a5 100644
@@ -455,6 +455,7 @@ void xt_compat_flush_offsets(u_int8_t af)
 		vfree(xt[af].compat_tab);
 		xt[af].compat_tab = NULL;
 		xt[af].number = 0;
+		xt[af].cur = 0;
 	}
 }
 EXPORT_SYMBOL_GPL(xt_compat_flush_offsets);
@@ -473,8 +474,7 @@ int xt_compat_calc_jump(u_int8_t af, unsigned int offset)
 		else
 			return mid ? tmp[mid - 1].delta : 0;
 	}
-	WARN_ON_ONCE(1);
-	return 0;
+	return left ? tmp[left - 1].delta : 0;
 }
 EXPORT_SYMBOL_GPL(xt_compat_calc_jump);
 
author maintainer
#4 lore raw

PATCH 3/8 netfilter: ebtables: only call xt_compat_add_offset once per rule

In reply to [email protected]

From: Florian Westphal <[email protected]>

The optimizations in commit 255d0dc34068a976 (netfilter: x_table: speedup compat operations) assume that xt_compat_add_offset is called once per rule.

ebtables however called it for each match/target found in a rule.

The match/watcher/target parser already returns the needed delta, so it is sufficient to move the xt_compat_add_offset call to a more reasonable location.

While at it, also get rid of the unused COMPAT iterator macros.

---
 net/bridge/netfilter/ebtables.c |   61 ++++++---------------------------------
 1 files changed, 9 insertions(+), 52 deletions(-)
net/bridge/netfilter/ebtables.c +9 -52
index 9707079..1a92b36 100644
@@ -1882,7 +1882,7 @@ static int compat_mtw_from_user(struct compat_ebt_entry_mwt *mwt,
 	struct xt_match *match;
 	struct xt_target *wt;
 	void *dst = NULL;
-	int off, pad = 0, ret = 0;
+	int off, pad = 0;
 	unsigned int size_kern, entry_offset, match_size = mwt->match_size;
 
 	strlcpy(name, mwt->u.name, sizeof(name));
@@ -1935,13 +1935,6 @@ static int compat_mtw_from_user(struct compat_ebt_entry_mwt *mwt,
 		break;
 	}
 
-	if (!dst) {
-		ret = xt_compat_add_offset(NFPROTO_BRIDGE, entry_offset,
-					off + ebt_compat_entry_padsize());
-		if (ret < 0)
-			return ret;
-	}
-
 	state->buf_kern_offset += match_size + off;
 	state->buf_user_offset += match_size;
 	pad = XT_ALIGN(size_kern) - size_kern;
@@ -2016,50 +2009,6 @@ static int ebt_size_mwt(struct compat_ebt_entry_mwt *match32,
 	return growth;
 }
 
-#define EBT_COMPAT_WATCHER_ITERATE(e, fn, args...)          \
-({                                                          \
-	unsigned int __i;                                   \
-	int __ret = 0;                                      \
-	struct compat_ebt_entry_mwt *__watcher;             \
-	                                                    \
-	for (__i = e->watchers_offset;                      \
-	     __i < (e)->target_offset;                      \
-	     __i += __watcher->watcher_size +               \
-	     sizeof(struct compat_ebt_entry_mwt)) {         \
-		__watcher = (void *)(e) + __i;              \
-		__ret = fn(__watcher , ## args);            \
-		if (__ret != 0)                             \
-			break;                              \
-	}                                                   \
-	if (__ret == 0) {                                   \
-		if (__i != (e)->target_offset)              \
-			__ret = -EINVAL;                    \
-	}                                                   \
-	__ret;                                              \
-})
-
-#define EBT_COMPAT_MATCH_ITERATE(e, fn, args...)            \
-({                                                          \
-	unsigned int __i;                                   \
-	int __ret = 0;                                      \
-	struct compat_ebt_entry_mwt *__match;               \
-	                                                    \
-	for (__i = sizeof(struct ebt_entry);                \
-	     __i < (e)->watchers_offset;                    \
-	     __i += __match->match_size +                   \
-	     sizeof(struct compat_ebt_entry_mwt)) {         \
-		__match = (void *)(e) + __i;                \
-		__ret = fn(__match , ## args);              \
-		if (__ret != 0)                             \
-			break;                              \
-	}                                                   \
-	if (__ret == 0) {                                   \
-		if (__i != (e)->watchers_offset)            \
-			__ret = -EINVAL;                    \
-	}                                                   \
-	__ret;                                              \
-})
-
 /* called for all ebt_entry structures. */
 static int size_entry_mwt(struct ebt_entry *entry, const unsigned char *base,
 			  unsigned int *total,
@@ -2132,6 +2081,14 @@ static int size_entry_mwt(struct ebt_entry *entry, const unsigned char *base,
 		}
 	}
 
+	if (state->buf_kern_start == NULL) {
+		unsigned int offset = buf_start - (char *) base;
+
+		ret = xt_compat_add_offset(NFPROTO_BRIDGE, offset, new_offset);
+		if (ret < 0)
+			return ret;
+	}
+
 	startoff = state->buf_user_offset - startoff;
 
 	BUG_ON(*total < startoff);
Signature · 1 line
1.7.2.3
author maintainer
#5 lore raw

PATCH 4/8 IPVS: Change of socket usage to enable name space exit.

In reply to [email protected]

From: Hans Schillstrom <[email protected]>

If the sync daemons run in a name space while it crashes
or get killed, there is no way to stop them except for a reboot. When all patches are there, ip_vs_core will handle register_pernet_(), i.e. ip_vs_sync_init() and ip_vs_sync_cleanup() will be removed.

Kernel threads should not increment the use count of a socket. By calling sk_change_net() after creating a socket this is avoided. sock_release cant be used intead sk_release_kernel() should be used.

Thanks Eric W Biederman for your advices.

---
 net/netfilter/ipvs/ip_vs_core.c |    2 +-
 net/netfilter/ipvs/ip_vs_sync.c |   58 +++++++++++++++++++++++++--------------
 2 files changed, 38 insertions(+), 22 deletions(-)
net/netfilter/ipvs/ip_vs_core.c +1 -1
index 07accf6..a0791dc 100644
@@ -1896,7 +1896,7 @@ static int __net_init __ip_vs_init(struct net *net)
 
 static void __net_exit __ip_vs_cleanup(struct net *net)
 {
-	IP_VS_DBG(10, "ipvs netns %d released\n", net_ipvs(net)->gen);
+	IP_VS_DBG(2, "ipvs netns %d released\n", net_ipvs(net)->gen);
 }
 
 static struct pernet_operations ipvs_core_ops = {
net/netfilter/ipvs/ip_vs_sync.c +37 -21

146 lines not on this page · raw message

Signature · 1 line
1.7.2.3
author maintainer
#6 lore raw

PATCH 5/8 IPVS: init and cleanup restructuring

In reply to [email protected]

From: Hans Schillstrom <[email protected]>

DESCRIPTION
This patch tries to restore the initial init and cleanup sequences that was before namspace patch.
Netns also requires action when net devices unregister which has never been implemented. I.e this patch also covers when a device moves into a network namespace, and has to be released.

IMPLEMENTATION
The number of calls to register_pernet_device have been reduced to one for the ip_vs.ko
Schedulers still have their own calls.

This patch adds a function __ip_vs_service_cleanup() and an enable flag for the netfilter hooks.

The nf hooks will be enabled when the first service is loaded and never disabled again, except when a namespace exit starts.

---
 include/net/ip_vs.h              |   17 +++++
 net/netfilter/ipvs/ip_vs_app.c   |   15 +----
 net/netfilter/ipvs/ip_vs_conn.c  |   12 +---
 net/netfilter/ipvs/ip_vs_core.c  |  101 +++++++++++++++++++++++++++++---
 net/netfilter/ipvs/ip_vs_ctl.c   |  120 ++++++++++++++++++++++++++++++++------
 net/netfilter/ipvs/ip_vs_est.c   |   14 +----
 net/netfilter/ipvs/ip_vs_proto.c |   11 +---
 net/netfilter/ipvs/ip_vs_sync.c  |   13 +---
 8 files changed, 223 insertions(+), 80 deletions(-)
include/net/ip_vs.h +17 -0
index d516f00..86aefed 100644
@@ -791,6 +791,7 @@ struct ip_vs_app {
 /* IPVS in network namespace */
 struct netns_ipvs {
 	int			gen;		/* Generation */
+	int			enable;		/* enable like nf_hooks do */
 	/*
 	 *	Hash table: for real service lookups
 	 */
@@ -1089,6 +1090,22 @@ ip_vs_control_add(struct ip_vs_conn *cp, struct ip_vs_conn *ctl_cp)
 	atomic_inc(&ctl_cp->n_control);
 }
 
+/*
+ * IPVS netns init & cleanup functions
+ */
+extern int __ip_vs_estimator_init(struct net *net);
+extern int __ip_vs_control_init(struct net *net);
+extern int __ip_vs_protocol_init(struct net *net);
+extern int __ip_vs_app_init(struct net *net);
+extern int __ip_vs_conn_init(struct net *net);
+extern int __ip_vs_sync_init(struct net *net);
+extern void __ip_vs_conn_cleanup(struct net *net);
+extern void __ip_vs_app_cleanup(struct net *net);
+extern void __ip_vs_protocol_cleanup(struct net *net);
+extern void __ip_vs_control_cleanup(struct net *net);
+extern void __ip_vs_estimator_cleanup(struct net *net);
+extern void __ip_vs_sync_cleanup(struct net *net);
+extern void __ip_vs_service_cleanup(struct net *net);
 
 /*
  *      IPVS application functions
net/netfilter/ipvs/ip_vs_app.c +3 -12
index 2dc6de1..51f3af7 100644
@@ -576,7 +576,7 @@ static const struct file_operations ip_vs_app_fops = {
 };
 #endif
 
-static int __net_init __ip_vs_app_init(struct net *net)
+int __net_init __ip_vs_app_init(struct net *net)
 {
 	struct netns_ipvs *ipvs = net_ipvs(net);
 
@@ -585,26 +585,17 @@ static int __net_init __ip_vs_app_init(struct net *net)
 	return 0;
 }
 
-static void __net_exit __ip_vs_app_cleanup(struct net *net)
+void __net_exit __ip_vs_app_cleanup(struct net *net)
 {
 	proc_net_remove(net, "ip_vs_app");
 }
 
-static struct pernet_operations ip_vs_app_ops = {
-	.init = __ip_vs_app_init,
-	.exit = __ip_vs_app_cleanup,
-};
-
 int __init ip_vs_app_init(void)
 {
-	int rv;
-
-	rv = register_pernet_subsys(&ip_vs_app_ops);
-	return rv;
+	return 0;
 }
 
 
 void ip_vs_app_cleanup(void)
 {
-	unregister_pernet_subsys(&ip_vs_app_ops);
 }
net/netfilter/ipvs/ip_vs_conn.c +2 -10
index c97bd45..d3fd91b 100644
@@ -1258,22 +1258,17 @@ int __net_init __ip_vs_conn_init(struct net *net)
 	return 0;
 }
 
-static void __net_exit __ip_vs_conn_cleanup(struct net *net)
+void __net_exit __ip_vs_conn_cleanup(struct net *net)
 {
 	/* flush all the connection entries first */
 	ip_vs_conn_flush(net);
 	proc_net_remove(net, "ip_vs_conn");
 	proc_net_remove(net, "ip_vs_conn_sync");
 }
-static struct pernet_operations ipvs_conn_ops = {
-	.init = __ip_vs_conn_init,
-	.exit = __ip_vs_conn_cleanup,
-};
 
 int __init ip_vs_conn_init(void)
 {
 	int idx;
-	int retc;
 
 	/* Compute size and mask */
 	ip_vs_conn_tab_size = 1 << ip_vs_conn_tab_bits;
@@ -1309,17 +1304,14 @@ int __init ip_vs_conn_init(void)
 		rwlock_init(&__ip_vs_conntbl_lock_array[idx].l);
 	}
 
-	retc = register_pernet_subsys(&ipvs_conn_ops);
-
 	/* calculate the random value for connection hash */
 	get_random_bytes(&ip_vs_conn_rnd, sizeof(ip_vs_conn_rnd));
 
-	return retc;
+	return 0;
 }
 
 void ip_vs_conn_cleanup(void)
 {
-	unregister_pernet_subsys(&ipvs_conn_ops);
 	/* Release the empty cache */
 	kmem_cache_destroy(ip_vs_conn_cachep);
 	vfree(ip_vs_conn_tab);
net/netfilter/ipvs/ip_vs_core.c +92 -9

216 lines not on this page · raw message

net/netfilter/ipvs/ip_vs_ctl.c +101 -19

183 lines not on this page · raw message

net/netfilter/ipvs/ip_vs_est.c +3 -11
index 8c8766c..508cce9 100644
@@ -192,7 +192,7 @@ void ip_vs_read_estimator(struct ip_vs_stats_user *dst,
 	dst->outbps = (e->outbps + 0xF) >> 5;
 }
 
-static int __net_init __ip_vs_estimator_init(struct net *net)
+int __net_init __ip_vs_estimator_init(struct net *net)
 {
 	struct netns_ipvs *ipvs = net_ipvs(net);
 
@@ -203,24 +203,16 @@ static int __net_init __ip_vs_estimator_init(struct net *net)
 	return 0;
 }
 
-static void __net_exit __ip_vs_estimator_exit(struct net *net)
+void __net_exit __ip_vs_estimator_cleanup(struct net *net)
 {
 	del_timer_sync(&net_ipvs(net)->est_timer);
 }
-static struct pernet_operations ip_vs_app_ops = {
-	.init = __ip_vs_estimator_init,
-	.exit = __ip_vs_estimator_exit,
-};
 
 int __init ip_vs_estimator_init(void)
 {
-	int rv;
-
-	rv = register_pernet_subsys(&ip_vs_app_ops);
-	return rv;
+	return 0;
 }
 
 void ip_vs_estimator_cleanup(void)
 {
-	unregister_pernet_subsys(&ip_vs_app_ops);
 }
net/netfilter/ipvs/ip_vs_proto.c +2 -9
index 17484a4..eb86028 100644
@@ -316,7 +316,7 @@ ip_vs_tcpudp_debug_packet(int af, struct ip_vs_protocol *pp,
 /*
  * per network name-space init
  */
-static int __net_init __ip_vs_protocol_init(struct net *net)
+int __net_init __ip_vs_protocol_init(struct net *net)
 {
 #ifdef CONFIG_IP_VS_PROTO_TCP
 	register_ip_vs_proto_netns(net, &ip_vs_protocol_tcp);
@@ -336,7 +336,7 @@ static int __net_init __ip_vs_protocol_init(struct net *net)
 	return 0;
 }
 
-static void __net_exit __ip_vs_protocol_cleanup(struct net *net)
+void __net_exit __ip_vs_protocol_cleanup(struct net *net)
 {
 	struct netns_ipvs *ipvs = net_ipvs(net);
 	struct ip_vs_proto_data *pd;
@@ -349,11 +349,6 @@ static void __net_exit __ip_vs_protocol_cleanup(struct net *net)
 	}
 }
 
-static struct pernet_operations ipvs_proto_ops = {
-	.init = __ip_vs_protocol_init,
-	.exit = __ip_vs_protocol_cleanup,
-};
-
 int __init ip_vs_protocol_init(void)
 {
 	char protocols[64];
@@ -382,7 +377,6 @@ int __init ip_vs_protocol_init(void)
 	REGISTER_PROTOCOL(&ip_vs_protocol_esp);
 #endif
 	pr_info("Registered protocols (%s)\n", &protocols[2]);
-	return register_pernet_subsys(&ipvs_proto_ops);
 
 	return 0;
 }
@@ -393,7 +387,6 @@ void ip_vs_protocol_cleanup(void)
 	struct ip_vs_protocol *pp;
 	int i;
 
-	unregister_pernet_subsys(&ipvs_proto_ops);
 	/* unregister all the ipvs protocols */
 	for (i = 0; i < IP_VS_PROTO_TAB_SIZE; i++) {
 		while ((pp = ip_vs_proto_table[i]) != NULL)
net/netfilter/ipvs/ip_vs_sync.c +3 -10
index 0cce953..e292e5b 100644
@@ -1663,7 +1663,7 @@ int stop_sync_thread(struct net *net, int state)
 /*
  * Initialize data struct for each netns
  */
-static int __net_init __ip_vs_sync_init(struct net *net)
+int __net_init __ip_vs_sync_init(struct net *net)
 {
 	struct netns_ipvs *ipvs = net_ipvs(net);
 
@@ -1677,7 +1677,7 @@ static int __net_init __ip_vs_sync_init(struct net *net)
 	return 0;
 }
 
-static void __ip_vs_sync_cleanup(struct net *net)
+void __ip_vs_sync_cleanup(struct net *net)
 {
 	int retc;
 
@@ -1690,18 +1690,11 @@ static void __ip_vs_sync_cleanup(struct net *net)
 		pr_err("Failed to stop Backup Daemon\n");
 }
 
-static struct pernet_operations ipvs_sync_ops = {
-	.init = __ip_vs_sync_init,
-	.exit = __ip_vs_sync_cleanup,
-};
-
-
 int __init ip_vs_sync_init(void)
 {
-	return register_pernet_device(&ipvs_sync_ops);
+	return 0;
 }
 
 void ip_vs_sync_cleanup(void)
 {
-	unregister_pernet_device(&ipvs_sync_ops);
 }
Signature · 1 line
1.7.2.3
author maintainer
#7 lore raw

PATCH 6/8 netfilter: IPv6: initialize TOS field in REJECT target module

In reply to [email protected]

From: Fernando Luis Vazquez Cao <[email protected]>

The IPv6 header is not zeroed out in alloc_skb so we must initialize it properly unless we want to see IPv6 packets with random TOS fields floating around. The current implementation resets the flow label but this could be changed if deemed necessary.

We stumbled upon this issue when trying to apply a mangle rule to the RST packet generated by the REJECT target module.

---
 net/ipv6/netfilter/ip6t_REJECT.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
net/ipv6/netfilter/ip6t_REJECT.c +3 -1
index 28e7448..a5a4c5d 100644
@@ -45,6 +45,8 @@ static void send_reset(struct net *net, struct sk_buff *oldskb)
 	int tcphoff, needs_ack;
 	const struct ipv6hdr *oip6h = ipv6_hdr(oldskb);
 	struct ipv6hdr *ip6h;
+#define DEFAULT_TOS_VALUE	0x0U
+	const __u8 tclass = DEFAULT_TOS_VALUE;
 	struct dst_entry *dst = NULL;
 	u8 proto;
 	struct flowi6 fl6;
@@ -124,7 +126,7 @@ static void send_reset(struct net *net, struct sk_buff *oldskb)
 	skb_put(nskb, sizeof(struct ipv6hdr));
 	skb_reset_network_header(nskb);
 	ip6h = ipv6_hdr(nskb);
-	ip6h->version = 6;
+	*(__be32 *)ip6h =  htonl(0x60000000 | (tclass << 20));
 	ip6h->hop_limit = ip6_dst_hoplimit(dst);
 	ip6h->nexthdr = IPPROTO_TCP;
 	ipv6_addr_copy(&ip6h->saddr, &oip6h->daddr);
Signature · 1 line
1.7.2.3
#8 lore raw

Re: [PATCH 6/8] netfilter: IPv6: initialize TOS field in REJECT target module

Hi Pablo,

Thank you for taking care of these patches, I really appreciate it.

I noticed that they have just been picked up by Linus. Could we get them into the -stable and -longterm trees too?

1ed2f73d90fb49bcf5704aee7e9084adb882bfc5 (netfilter: IPv6: fix DSCP mangle code) 4319cc0cf5bb894b7368008cdf6dd20eb8868018 (netfilter: IPv6: initialize TOS field in REJECT target module)

Regards,
Fernando

Quoted 38 lines · On Tue, 2011-05-10 at 12:05 +0200, [email protected] wrote:

From: Fernando Luis Vazquez Cao <[email protected]>

The IPv6 header is not zeroed out in alloc_skb so we must initialize it properly unless we want to see IPv6 packets with random TOS fields floating around. The current implementation resets the flow label but this could be changed if deemed necessary.

We stumbled upon this issue when trying to apply a mangle rule to the RST packet generated by the REJECT target module.

---
 net/ipv6/netfilter/ip6t_REJECT.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
net/ipv6/netfilter/ip6t_REJECT.c +3 -1
index 28e7448..a5a4c5d 100644
@@ -45,6 +45,8 @@ static void send_reset(struct net *net, struct sk_buff *oldskb)
 	int tcphoff, needs_ack;
 	const struct ipv6hdr *oip6h = ipv6_hdr(oldskb);
 	struct ipv6hdr *ip6h;
+#define DEFAULT_TOS_VALUE	0x0U
+	const __u8 tclass = DEFAULT_TOS_VALUE;
 	struct dst_entry *dst = NULL;
 	u8 proto;
 	struct flowi6 fl6;
@@ -124,7 +126,7 @@ static void send_reset(struct net *net, struct sk_buff *oldskb)
 	skb_put(nskb, sizeof(struct ipv6hdr));
 	skb_reset_network_header(nskb);
 	ip6h = ipv6_hdr(nskb);
-	ip6h->version = 6;
+	*(__be32 *)ip6h =  htonl(0x60000000 | (tclass << 20));
 	ip6h->hop_limit = ip6_dst_hoplimit(dst);
 	ip6h->nexthdr = IPPROTO_TCP;
 	ipv6_addr_copy(&ip6h->saddr, &oip6h->daddr);
author maintainer
#9 lore raw

Re: [PATCH 6/8] netfilter: IPv6: initialize TOS field in REJECT target module

Quoted 9 lines · Fernando Luis Vázquez Cao

Hi Pablo,

Thank you for taking care of these patches, I really appreciate it.

I noticed that they have just been picked up by Linus. Could we get them into the -stable and -longterm trees too?

1ed2f73d90fb49bcf5704aee7e9084adb882bfc5 (netfilter: IPv6: fix DSCP mangle code) 4319cc0cf5bb894b7368008cdf6dd20eb8868018 (netfilter: IPv6: initialize TOS field in REJECT target module)

OK, I'll pass them to -stable as soon as I find some spare time. --
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#10 lore raw

Re: [PATCH 6/8] netfilter: IPv6: initialize TOS field in REJECT target module

Quoted 10 lines · Pablo Neira Ayuso
Quoted 7 lines · Fernando Luis Vázquez Cao

Thank you for taking care of these patches, I really appreciate it.

I noticed that they have just been picked up by Linus. Could we get them into the -stable and -longterm trees too?

1ed2f73d90fb49bcf5704aee7e9084adb882bfc5 (netfilter: IPv6: fix DSCP mangle code) 4319cc0cf5bb894b7368008cdf6dd20eb8868018 (netfilter: IPv6: initialize TOS field in REJECT target module)

OK, I'll pass them to -stable as soon as I find some spare time.

Thank you Pablo. By doing so they are more likely to trickle down to enterprise distributions and Debian, which we are using.

--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

author maintainer
#11 lore raw

PATCH 7/8 netfilter: IPv6: fix DSCP mangle code

In reply to [email protected]

From: Fernando Luis Vazquez Cao <[email protected]>

The mask indicates the bits one wants to zero out, so it needs to be inverted before applying to the original TOS field.

---
 net/netfilter/xt_DSCP.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
net/netfilter/xt_DSCP.c +1 -1
index 0a22919..ae82716 100644
@@ -99,7 +99,7 @@ tos_tg6(struct sk_buff *skb, const struct xt_action_param *par)
 	u_int8_t orig, nv;
 
 	orig = ipv6_get_dsfield(iph);
-	nv   = (orig & info->tos_mask) ^ info->tos_value;
+	nv   = (orig & ~info->tos_mask) ^ info->tos_value;
 
 	if (orig != nv) {
 		if (!skb_make_writable(skb, sizeof(struct iphdr)))
Signature · 1 line
1.7.2.3
author maintainer
#12 lore raw

PATCH 8/8 netfilter: revert a2361c8735e07322023aedc36e4938b35af31eb0

In reply to [email protected]

From: Pablo Neira Ayuso <[email protected]>

This patch reverts a2361c8735e07322023aedc36e4938b35af31eb0:
"[PATCH] netfilter: xt_conntrack: warn about use in raw table"

Florian Wesphal says:
"... when the packet was sent from the local machine the skb already has ->nfct attached, and -m conntrack seems to do the right thing."

---
 net/netfilter/xt_DSCP.c      |    2 +-
 net/netfilter/xt_conntrack.c |    5 -----
 2 files changed, 1 insertions(+), 6 deletions(-)
net/netfilter/xt_DSCP.c +1 -1
index ae82716..0a22919 100644
@@ -99,7 +99,7 @@ tos_tg6(struct sk_buff *skb, const struct xt_action_param *par)
 	u_int8_t orig, nv;
 
 	orig = ipv6_get_dsfield(iph);
-	nv   = (orig & ~info->tos_mask) ^ info->tos_value;
+	nv   = (orig & info->tos_mask) ^ info->tos_value;
 
 	if (orig != nv) {
 		if (!skb_make_writable(skb, sizeof(struct iphdr)))
net/netfilter/xt_conntrack.c +0 -5
index 481a86f..61805d7 100644
@@ -272,11 +272,6 @@ static int conntrack_mt_check(const struct xt_mtchk_param *par)
 {
 	int ret;
 
-	if (strcmp(par->table, "raw") == 0) {
-		pr_info("state is undetermined at the time of raw table\n");
-		return -EINVAL;
-	}
-
 	ret = nf_ct_l3proto_try_module_get(par->family);
 	if (ret < 0)
 		pr_info("cannot load conntrack support for proto=%u\n",
Signature · 1 line
1.7.2.3
author maintainer Acked-by Jan Engelhardt on v1 8/8
#13 lore raw

Re: [PATCH 8/8] netfilter: revert a2361c8735e07322023aedc36e4938b35af31eb0

Quoted 9 lines · On 10/05/11 12:05, [email protected] wrote:

From: Pablo Neira Ayuso <[email protected]>

This patch reverts a2361c8735e07322023aedc36e4938b35af31eb0:
"[PATCH] netfilter: xt_conntrack: warn about use in raw table"

Florian Wesphal says:
"... when the packet was sent from the local machine the skb already has ->nfct attached, and -m conntrack seems to do the right thing."

Sorry, the description and the patch doesn't match, the correct patch is attached. I have pushed this to my branch.

Quoted 1 line

From 93bbce1ad0cd788190dd7d6c17d289f771fe3d0d Mon Sep 17 00:00:00 2001

From: Pablo Neira Ayuso <[email protected]>
Date: Tue, 10 May 2011 12:13:36 +0200
Subject: [PATCH] netfilter: revert a2361c8735e07322023aedc36e4938b35af31eb0

This patch reverts a2361c8735e07322023aedc36e4938b35af31eb0:
"[PATCH] netfilter: xt_conntrack: warn about use in raw table"

Florian Wesphal says:
"... when the packet was sent from the local machine the skb already has ->nfct attached, and -m conntrack seems to do the right thing."

---
 net/netfilter/xt_conntrack.c |    5 -----
 1 files changed, 0 insertions(+), 5 deletions(-)
net/netfilter/xt_conntrack.c +0 -5
index 481a86f..61805d7 100644
@@ -272,11 +272,6 @@ static int conntrack_mt_check(const struct xt_mtchk_param *par)
 {
 	int ret;
 
-	if (strcmp(par->table, "raw") == 0) {
-		pr_info("state is undetermined at the time of raw table\n");
-		return -EINVAL;
-	}
-
 	ret = nf_ct_l3proto_try_module_get(par->family);
 	if (ret < 0)
 		pr_info("cannot load conntrack support for proto=%u\n",
Signature · 1 line
1.7.2.3