Skip to contentSkip to conversation

netfilter: reset nf_trace in nf_reset

PATCH Applied Gao feng 2 participants 4 messages Mar 22, 2013 – Apr 1, 2013

Subsystems (4)
lore
Share & tools
lore

Gao feng

author
#0 lore raw

PATCH 1/2 netfilter: reset nf_trace in nf_reset

We forgot to clear the nf_trace of sk_buff in nf_reset, When we use veth device, this nf_trace information will be leaked from one net namespace to another net namespace.

---
 include/linux/skbuff.h | 3 +++
 1 file changed, 3 insertions(+)
include/linux/skbuff.h +3 -0
index 441f5bf..72b3967 100644
@@ -2641,6 +2641,9 @@ static inline void nf_reset(struct sk_buff *skb)
 	nf_bridge_put(skb->nf_bridge);
 	skb->nf_bridge = NULL;
 #endif
+#if IS_ENABLED(CONFIG_NETFILTER_XT_TARGET_TRACE)
+	skb->nf_trace = 0;
+#endif
 }
 
 /* Note: This doesn't put any conntrack and bridge info in dst. */
Signature · 1 line
1.7.11.7
author
#1 lore raw

PATCH 2/2 netfilter: TRACE: use IS_ENABLE to replace if defined

Inder to reduce codes, Use IS_ENABLE to replace the if defined.

---
 net/ipv4/ip_output.c           | 3 +--
 net/ipv4/netfilter/ip_tables.c | 6 ++----
 2 files changed, 3 insertions(+), 6 deletions(-)
net/ipv4/ip_output.c +1 -2
index 5e12dca..147abf5 100644
@@ -430,8 +430,7 @@ static void ip_copy_metadata(struct sk_buff *to, struct sk_buff *from)
 	to->tc_index = from->tc_index;
 #endif
 	nf_copy(to, from);
-#if defined(CONFIG_NETFILTER_XT_TARGET_TRACE) || \
-    defined(CONFIG_NETFILTER_XT_TARGET_TRACE_MODULE)
+#if IS_ENABLED(CONFIG_NETFILTER_XT_TARGET_TRACE)
 	to->nf_trace = from->nf_trace;
 #endif
 #if defined(CONFIG_IP_VS) || defined(CONFIG_IP_VS_MODULE)
net/ipv4/netfilter/ip_tables.c +2 -4
index 3efcf87..1b433aa 100644
@@ -182,8 +182,7 @@ ipt_get_target_c(const struct ipt_entry *e)
 	return ipt_get_target((struct ipt_entry *)e);
 }
 
-#if defined(CONFIG_NETFILTER_XT_TARGET_TRACE) || \
-    defined(CONFIG_NETFILTER_XT_TARGET_TRACE_MODULE)
+#if IS_ENABLED(CONFIG_NETFILTER_XT_TARGET_TRACE)
 static const char *const hooknames[] = {
 	[NF_INET_PRE_ROUTING]		= "PREROUTING",
 	[NF_INET_LOCAL_IN]		= "INPUT",
@@ -361,8 +360,7 @@ ipt_do_table(struct sk_buff *skb,
 		t = ipt_get_target(e);
 		IP_NF_ASSERT(t->u.kernel.target);
 
-#if defined(CONFIG_NETFILTER_XT_TARGET_TRACE) || \
-    defined(CONFIG_NETFILTER_XT_TARGET_TRACE_MODULE)
+#if IS_ENABLED(CONFIG_NETFILTER_XT_TARGET_TRACE)
 		/* The packet is traced: log it */
 		if (unlikely(skb->nf_trace))
 			trace_packet(skb, hook, in, out,
Signature · 1 line
1.7.11.7
maintainer Applied
#3 lore raw
In reply to Gao feng
Quoted 3 lines · Gao feng

We forgot to clear the nf_trace of sk_buff in nf_reset, When we use veth device, this nf_trace information will be leaked from one net namespace to another net namespace.

Applied to the nf tree, thanks Gao.

maintainer Applied
#2 lore raw

Re: [PATCH 2/2] netfilter: TRACE: use IS_ENABLE to replace if defined

In reply to Gao feng
Quoted 2 lines · Gao feng

Inder to reduce codes, Use IS_ENABLE to replace the if defined.

Applied, thanks.