Skip to contentSkip to conversation

Minor Cleanups

PATCH Applied Martin Josefsson 4 participants 44 messages Nov 1, 2006 – Nov 3, 2006 2 messages not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover Minor Cleanups

The following patches clean up nf_conntrack a little bit. The first patches split out various parts into their own separate files. Then some small cleanups follow and lastly there's a small optimization.

--
/Martin

#1 lore raw

PATCH 1/11 Split out expectation handling

This patch splits out expectation handling into its own file nf_conntrack_expect.c

---
 include/net/netfilter/nf_conntrack.h        |   49 ---
 include/net/netfilter/nf_conntrack_core.h   |    7 
 include/net/netfilter/nf_conntrack_expect.h |   72 +++++
 include/net/netfilter/nf_conntrack_helper.h |   10 
 net/netfilter/Makefile                      |    2 
 net/netfilter/nf_conntrack_core.c           |  265 --------------------
 net/netfilter/nf_conntrack_expect.c         |  367 ++++++++++++++++++++++++++++
 net/netfilter/nf_conntrack_ftp.c            |    1 
 net/netfilter/nf_conntrack_netlink.c        |    1 
 net/netfilter/nf_conntrack_standalone.c     |   81 ------
 10 files changed, 454 insertions(+), 401 deletions(-)
include/net/netfilter/nf_conntrack.h +1 -48
Index: linux-2.6.19-rc3-git4.quilt/include/net/netfilter/nf_conntrack.h
===================================================================
@@ -124,44 +124,6 @@ struct nf_conn
 	char data[0];
 };
 
-struct nf_conntrack_expect
-{
-	/* Internal linked list (global expectation list) */
-	struct list_head list;
-
-	/* We expect this tuple, with the following mask */
-	struct nf_conntrack_tuple tuple, mask;
- 
-	/* Function to call after setup and insertion */
-	void (*expectfn)(struct nf_conn *new,
-			 struct nf_conntrack_expect *this);
-
-	/* The conntrack of the master connection */
-	struct nf_conn *master;
-
-	/* Timer function; deletes the expectation. */
-	struct timer_list timeout;
-
-	/* Usage count. */
-	atomic_t use;
-
-	/* Unique ID */
-	unsigned int id;
-
-	/* Flags */
-	unsigned int flags;
-
-#ifdef CONFIG_NF_NAT_NEEDED
-	/* This is the original per-proto part, used to map the
-	 * expected connection the way the recipient expects. */
-	union nf_conntrack_manip_proto saved_proto;
-	/* Direction relative to the master connection. */
-	enum ip_conntrack_dir dir;
-#endif
-};
-
-#define NF_CT_EXPECT_PERMANENT 0x1
-
 static inline struct nf_conn *
 nf_ct_tuplehash_to_ctrack(const struct nf_conntrack_tuple_hash *hash)
 {
@@ -208,16 +170,6 @@ __nf_conntrack_find(const struct nf_conn
 
 extern void nf_conntrack_hash_insert(struct nf_conn *ct);
 
-extern struct nf_conntrack_expect *
-__nf_conntrack_expect_find(const struct nf_conntrack_tuple *tuple);
-
-extern struct nf_conntrack_expect *
-nf_conntrack_expect_find(const struct nf_conntrack_tuple *tuple);
-
-extern void nf_ct_unlink_expect(struct nf_conntrack_expect *exp);
-
-extern void nf_ct_remove_expectations(struct nf_conn *ct);
-
 extern void nf_conntrack_flush(void);
 
 extern struct nf_conntrack_helper *
@@ -295,6 +247,7 @@ extern int nf_conntrack_checksum;
 #ifdef CONFIG_NF_CONNTRACK_EVENTS
 #include <linux/notifier.h>
 #include <linux/interrupt.h>
+#include <net/netfilter/nf_conntrack_expect.h>
 
 struct nf_conntrack_ecache {
 	struct nf_conn *ct;
include/net/netfilter/nf_conntrack_expect.h new file +72 -0

72 lines not on this page · raw message

net/netfilter/Makefile +1 -1
Index: linux-2.6.19-rc3-git4.quilt/net/netfilter/Makefile
===================================================================
@@ -1,5 +1,5 @@
 netfilter-objs := core.o nf_log.o nf_queue.o nf_sockopt.o
-nf_conntrack-objs	:= nf_conntrack_core.o nf_conntrack_standalone.o nf_conntrack_l3proto_generic.o nf_conntrack_proto_generic.o nf_conntrack_proto_tcp.o nf_conntrack_proto_udp.o
+nf_conntrack-objs	:= nf_conntrack_core.o nf_conntrack_standalone.o nf_conntrack_expect.o nf_conntrack_l3proto_generic.o nf_conntrack_proto_generic.o nf_conntrack_proto_tcp.o nf_conntrack_proto_udp.o
 
 obj-$(CONFIG_NETFILTER) = netfilter.o
 
net/netfilter/nf_conntrack_core.c +2 -263

301 lines not on this page · raw message

net/netfilter/nf_conntrack_expect.c new file +367 -0

367 lines not on this page · raw message

net/netfilter/nf_conntrack_ftp.c +1 -0
Index: linux-2.6.19-rc3-git4.quilt/net/netfilter/nf_conntrack_ftp.c
===================================================================
@@ -26,6 +26,7 @@
 #include <net/tcp.h>
 
 #include <net/netfilter/nf_conntrack.h>
+#include <net/netfilter/nf_conntrack_expect.h>
 #include <net/netfilter/nf_conntrack_helper.h>
 #include <linux/netfilter/nf_conntrack_ftp.h>
 
net/netfilter/nf_conntrack_netlink.c +1 -0
Index: linux-2.6.19-rc3-git4.quilt/net/netfilter/nf_conntrack_netlink.c
===================================================================
@@ -35,6 +35,7 @@
 #include <linux/netfilter.h>
 #include <net/netfilter/nf_conntrack.h>
 #include <net/netfilter/nf_conntrack_core.h>
+#include <net/netfilter/nf_conntrack_expect.h>
 #include <net/netfilter/nf_conntrack_helper.h>
 #include <net/netfilter/nf_conntrack_l3proto.h>
 #include <net/netfilter/nf_conntrack_protocol.h>
net/netfilter/nf_conntrack_standalone.c +2 -79

99 lines not on this page · raw message

include/net/netfilter/nf_conntrack_core.h +7 -0
Index: linux-2.6.19-rc3-git4.quilt/include/net/netfilter/nf_conntrack_core.h
===================================================================
@@ -13,6 +13,8 @@
 #define _NF_CONNTRACK_CORE_H
 
 #include <linux/netfilter.h>
+#include <net/netfilter/nf_conntrack_l3proto.h>
+#include <net/netfilter/nf_conntrack_protocol.h>
 
 /* This header is used to share core functionality between the
    standalone connection tracking module, and the compatibility layer's use
@@ -70,6 +72,11 @@ static inline int nf_conntrack_confirm(s
 
 extern void __nf_conntrack_attach(struct sk_buff *nskb, struct sk_buff *skb);
 
+int
+print_tuple(struct seq_file *s, const struct nf_conntrack_tuple *tuple,
+	    struct nf_conntrack_l3proto *l3proto,
+	    struct nf_conntrack_protocol *proto);
+
 extern struct list_head *nf_conntrack_hash;
 extern struct list_head nf_conntrack_expect_list;
 extern rwlock_t nf_conntrack_lock ;
include/net/netfilter/nf_conntrack_helper.h +0 -10
Index: linux-2.6.19-rc3-git4.quilt/include/net/netfilter/nf_conntrack_helper.h
===================================================================
@@ -40,14 +40,4 @@ struct nf_conntrack_helper
 extern int nf_conntrack_helper_register(struct nf_conntrack_helper *);
 extern void nf_conntrack_helper_unregister(struct nf_conntrack_helper *);
 
-/* Allocate space for an expectation: this is mandatory before calling
-   nf_conntrack_expect_related.  You will have to call put afterwards. */
-extern struct nf_conntrack_expect *
-nf_conntrack_expect_alloc(struct nf_conn *master);
-extern void nf_conntrack_expect_put(struct nf_conntrack_expect *exp);
-
-/* Add an expected connection: can have more than one per connection */
-extern int nf_conntrack_expect_related(struct nf_conntrack_expect *exp);
-extern void nf_conntrack_unexpect_related(struct nf_conntrack_expect *exp);
-
 #endif /*_NF_CONNTRACK_HELPER_H*/

--
/Martin

#2 lore raw

Re: [PATCH 01/11] Split out expectation handling

Quoted 2 lines · Martin Josefsson

This patch splits out expectation handling into its own file nf_conntrack_expect.c

Applied for 2.6.20, thanks.

#3 lore raw

PATCH 2/11 Split out helper handling

In reply to Martin Josefsson

This patch splits out handling of helpers into its own file nf_conntrack_helper.c

---
 include/net/netfilter/nf_conntrack_core.h   |    2 
 include/net/netfilter/nf_conntrack_helper.h |   10 +
 net/netfilter/Makefile                      |    2 
 net/netfilter/nf_conntrack_core.c           |  120 ----------------------
 net/netfilter/nf_conntrack_helper.c         |  152 ++++++++++++++++++++++++++++
 5 files changed, 166 insertions(+), 120 deletions(-)
include/net/netfilter/nf_conntrack_helper.h +10 -0
Index: linux-2.6.19-rc3-git4.quilt/include/net/netfilter/nf_conntrack_helper.h
===================================================================
@@ -37,6 +37,16 @@ struct nf_conntrack_helper
 	int (*to_nfattr)(struct sk_buff *skb, const struct nf_conn *ct);
 };
 
+extern struct nf_conntrack_helper *
+__nf_ct_helper_find(const struct nf_conntrack_tuple *tuple);
+
+extern struct nf_conntrack_helper *
+nf_ct_helper_find_get( const struct nf_conntrack_tuple *tuple);
+
+extern struct nf_conntrack_helper *
+__nf_conntrack_helper_find_byname(const char *name);
+
+extern void nf_ct_helper_put(struct nf_conntrack_helper *helper);
 extern int nf_conntrack_helper_register(struct nf_conntrack_helper *);
 extern void nf_conntrack_helper_unregister(struct nf_conntrack_helper *);
 
net/netfilter/nf_conntrack_core.c +1 -119

143 lines not on this page · raw message

net/netfilter/nf_conntrack_helper.c new file +152 -0

152 lines not on this page · raw message

net/netfilter/Makefile +1 -1
Index: linux-2.6.19-rc3-git4.quilt/net/netfilter/Makefile
===================================================================
@@ -1,5 +1,5 @@
 netfilter-objs := core.o nf_log.o nf_queue.o nf_sockopt.o
-nf_conntrack-objs	:= nf_conntrack_core.o nf_conntrack_standalone.o nf_conntrack_expect.o nf_conntrack_l3proto_generic.o nf_conntrack_proto_generic.o nf_conntrack_proto_tcp.o nf_conntrack_proto_udp.o
+nf_conntrack-objs	:= nf_conntrack_core.o nf_conntrack_standalone.o nf_conntrack_expect.o nf_conntrack_helper.o nf_conntrack_l3proto_generic.o nf_conntrack_proto_generic.o nf_conntrack_proto_tcp.o nf_conntrack_proto_udp.o
 
 obj-$(CONFIG_NETFILTER) = netfilter.o
 
include/net/netfilter/nf_conntrack_core.h +2 -0
Index: linux-2.6.19-rc3-git4.quilt/include/net/netfilter/nf_conntrack_core.h
===================================================================
@@ -80,4 +80,6 @@ print_tuple(struct seq_file *s, const st
 extern struct list_head *nf_conntrack_hash;
 extern struct list_head nf_conntrack_expect_list;
 extern rwlock_t nf_conntrack_lock ;
+extern struct list_head unconfirmed;
+
 #endif /* _NF_CONNTRACK_CORE_H */

--
/Martin

#4 lore raw

Re: [PATCH 02/11] Split out helper handling

Quoted 2 lines · Martin Josefsson

This patch splits out handling of helpers into its own file nf_conntrack_helper.c

Also applied.

#5 lore raw

PATCH 3/11 Split out the event cache

In reply to Martin Josefsson

This patch splits out the event cache into its own file nf_conntrack_ecache.c

---
 include/net/netfilter/nf_conntrack.h        |   81 -----------------------
 include/net/netfilter/nf_conntrack_core.h   |    1 
 include/net/netfilter/nf_conntrack_ecache.h |   95 ++++++++++++++++++++++++++++
 net/netfilter/Makefile                      |    4 -
 net/netfilter/nf_conntrack_core.c           |   67 -------------------
 net/netfilter/nf_conntrack_ecache.c         |   91 ++++++++++++++++++++++++++
 net/netfilter/nf_conntrack_ftp.c            |    1 
 net/netfilter/nf_conntrack_proto_sctp.c     |    1 
 net/netfilter/nf_conntrack_proto_tcp.c      |    1 
 net/netfilter/nf_conntrack_proto_udp.c      |    2 
 net/netfilter/nf_conntrack_standalone.c     |    2 
 11 files changed, 196 insertions(+), 150 deletions(-)
net/netfilter/nf_conntrack_ecache.c new file +91 -0
Index: linux-2.6.19-rc3-git4.quilt/net/netfilter/nf_conntrack_ecache.c
===================================================================
@@ -0,0 +1,91 @@
+/* Event cache for netfilter. */
+
+/* (C) 1999-2001 Paul `Rusty' Russell
+ * (C) 2002-2006 Netfilter Core Team <[email protected]>
+ * (C) 2003,2004 USAGI/WIDE Project <http://www.linux-ipv6.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/types.h>
+#include <linux/netfilter.h>
+#include <linux/skbuff.h>
+#include <linux/vmalloc.h>
+#include <linux/stddef.h>
+#include <linux/err.h>
+#include <linux/percpu.h>
+#include <linux/notifier.h>
+#include <linux/kernel.h>
+#include <linux/netdevice.h>
+
+#include <net/netfilter/nf_conntrack.h>
+#include <net/netfilter/nf_conntrack_l3proto.h>
+#include <net/netfilter/nf_conntrack_protocol.h>
+#include <net/netfilter/nf_conntrack_expect.h>
+#include <net/netfilter/nf_conntrack_helper.h>
+#include <net/netfilter/nf_conntrack_core.h>
+
+ATOMIC_NOTIFIER_HEAD(nf_conntrack_chain);
+ATOMIC_NOTIFIER_HEAD(nf_conntrack_expect_chain);
+
+DEFINE_PER_CPU(struct nf_conntrack_ecache, nf_conntrack_ecache);
+
+/* deliver cached events and clear cache entry - must be called with locally
+ * disabled softirqs */
+static inline void
+__nf_ct_deliver_cached_events(struct nf_conntrack_ecache *ecache)
+{
+	if (nf_ct_is_confirmed(ecache->ct) && !nf_ct_is_dying(ecache->ct)
+	    && ecache->events)
+		atomic_notifier_call_chain(&nf_conntrack_chain, ecache->events,
+				    ecache->ct);
+
+	ecache->events = 0;
+	nf_ct_put(ecache->ct);
+	ecache->ct = NULL;
+}
+
+/* Deliver all cached events for a particular conntrack. This is called
+ * by code prior to async packet handling for freeing the skb */
+void nf_ct_deliver_cached_events(const struct nf_conn *ct)
+{
+	struct nf_conntrack_ecache *ecache;
+
+	local_bh_disable();
+	ecache = &__get_cpu_var(nf_conntrack_ecache);
+	if (ecache->ct == ct)
+		__nf_ct_deliver_cached_events(ecache);
+	local_bh_enable();
+}
+
+/* Deliver cached events for old pending events, if current conntrack != old */
+void __nf_ct_event_cache_init(struct nf_conn *ct)
+{
+	struct nf_conntrack_ecache *ecache;
+
+	/* take care of delivering potentially old events */
+	ecache = &__get_cpu_var(nf_conntrack_ecache);
+	BUG_ON(ecache->ct == ct);
+	if (ecache->ct)
+		__nf_ct_deliver_cached_events(ecache);
+	/* initialize for this conntrack/packet */
+	ecache->ct = ct;
+	nf_conntrack_get(&ct->ct_general);
+}
+
+/* flush the event cache - touches other CPU's data and must not be called
+ * while packets are still passing through the code */
+void nf_ct_event_cache_flush(void)
+{
+	struct nf_conntrack_ecache *ecache;
+	int cpu;
+
+	for_each_possible_cpu(cpu) {
+		ecache = &per_cpu(nf_conntrack_ecache, cpu);
+		if (ecache->ct)
+			nf_ct_put(ecache->ct);
+	}
+}
+
include/net/netfilter/nf_conntrack.h +0 -81

87 lines not on this page · raw message

include/net/netfilter/nf_conntrack_ecache.h new file +95 -0

95 lines not on this page · raw message

net/netfilter/Makefile +3 -1
Index: linux-2.6.19-rc3-git4.quilt/net/netfilter/Makefile
===================================================================
@@ -1,5 +1,7 @@
 netfilter-objs := core.o nf_log.o nf_queue.o nf_sockopt.o
-nf_conntrack-objs	:= nf_conntrack_core.o nf_conntrack_standalone.o nf_conntrack_expect.o nf_conntrack_helper.o nf_conntrack_l3proto_generic.o nf_conntrack_proto_generic.o nf_conntrack_proto_tcp.o nf_conntrack_proto_udp.o
+
+nf_conntrack-y	:= nf_conntrack_core.o nf_conntrack_standalone.o nf_conntrack_expect.o nf_conntrack_helper.o nf_conntrack_l3proto_generic.o nf_conntrack_proto_generic.o nf_conntrack_proto_tcp.o nf_conntrack_proto_udp.o
+nf_conntrack-$(CONFIG_NF_CONNTRACK_EVENTS) += nf_conntrack_ecache.o
 
 obj-$(CONFIG_NETFILTER) = netfilter.o
 
net/netfilter/nf_conntrack_core.c +0 -67

73 lines not on this page · raw message

net/netfilter/nf_conntrack_standalone.c +1 -1
Index: linux-2.6.19-rc3-git4.quilt/net/netfilter/nf_conntrack_standalone.c
===================================================================
@@ -33,9 +33,9 @@
 #define ASSERT_WRITE_LOCK(x)
 
 #include <net/netfilter/nf_conntrack.h>
+#include <net/netfilter/nf_conntrack_core.h>
 #include <net/netfilter/nf_conntrack_l3proto.h>
 #include <net/netfilter/nf_conntrack_protocol.h>
-#include <net/netfilter/nf_conntrack_core.h>
 #include <net/netfilter/nf_conntrack_expect.h>
 #include <net/netfilter/nf_conntrack_helper.h>
 
include/net/netfilter/nf_conntrack_core.h +1 -0
Index: linux-2.6.19-rc3-git4.quilt/include/net/netfilter/nf_conntrack_core.h
===================================================================
@@ -15,6 +15,7 @@
 #include <linux/netfilter.h>
 #include <net/netfilter/nf_conntrack_l3proto.h>
 #include <net/netfilter/nf_conntrack_protocol.h>
+#include <net/netfilter/nf_conntrack_ecache.h>
 
 /* This header is used to share core functionality between the
    standalone connection tracking module, and the compatibility layer's use
net/netfilter/nf_conntrack_ftp.c +1 -0
Index: linux-2.6.19-rc3-git4.quilt/net/netfilter/nf_conntrack_ftp.c
===================================================================
@@ -27,6 +27,7 @@
 
 #include <net/netfilter/nf_conntrack.h>
 #include <net/netfilter/nf_conntrack_expect.h>
+#include <net/netfilter/nf_conntrack_ecache.h>
 #include <net/netfilter/nf_conntrack_helper.h>
 #include <linux/netfilter/nf_conntrack_ftp.h>
 
net/netfilter/nf_conntrack_proto_sctp.c +1 -0
Index: linux-2.6.19-rc3-git4.quilt/net/netfilter/nf_conntrack_proto_sctp.c
===================================================================
@@ -33,6 +33,7 @@
 
 #include <net/netfilter/nf_conntrack.h>
 #include <net/netfilter/nf_conntrack_protocol.h>
+#include <net/netfilter/nf_conntrack_ecache.h>
 
 #if 0
 #define DEBUGP(format, ...) printk(format, ## __VA_ARGS__)
net/netfilter/nf_conntrack_proto_tcp.c +1 -0
Index: linux-2.6.19-rc3-git4.quilt/net/netfilter/nf_conntrack_proto_tcp.c
===================================================================
@@ -43,6 +43,7 @@
 #include <linux/netfilter_ipv6.h>
 #include <net/netfilter/nf_conntrack.h>
 #include <net/netfilter/nf_conntrack_protocol.h>
+#include <net/netfilter/nf_conntrack_ecache.h>
 
 #if 0
 #define DEBUGP printk
net/netfilter/nf_conntrack_proto_udp.c +2 -0
Index: linux-2.6.19-rc3-git4.quilt/net/netfilter/nf_conntrack_proto_udp.c
===================================================================
@@ -22,10 +22,12 @@
 #include <linux/ipv6.h>
 #include <net/ip6_checksum.h>
 #include <net/checksum.h>
+
 #include <linux/netfilter.h>
 #include <linux/netfilter_ipv4.h>
 #include <linux/netfilter_ipv6.h>
 #include <net/netfilter/nf_conntrack_protocol.h>
+#include <net/netfilter/nf_conntrack_ecache.h>
 
 unsigned int nf_ct_udp_timeout __read_mostly = 30*HZ;
 unsigned int nf_ct_udp_timeout_stream __read_mostly = 180*HZ;

--
/Martin

#6 lore raw

Re: [PATCH 03/11] Split out the event cache

Quoted 2 lines · Martin Josefsson

This patch splits out the event cache into its own file nf_conntrack_ecache.c

Applied.

#7 lore raw

Re: [PATCH 03/11] Split out the event cache

In reply to Martin Josefsson
Quoted 2 lines · Martin Josefsson

This patch splits out the event cache into its own file nf_conntrack_ecache.c

I forgot to mention, I've added an include of nf_conntrack_ecache.h to xt_CONNMARK to fix a warning.

#8 lore raw

Re: [PATCH 03/11] Split out the event cache

Quoted 6 lines · Patrick McHardy
Quoted 2 lines · Martin Josefsson

This patch splits out the event cache into its own file nf_conntrack_ecache.c

I forgot to mention, I've added an include of nf_conntrack_ecache.h to xt_CONNMARK to fix a warning.

Ah, sorry, I have another patch where I rewrite most of the event cache, I added the include in that one...

/Martin

#9 lore raw

Re: [PATCH 03/11] Split out the event cache

In reply to Martin Josefsson

Hi,

From: Martin Josefsson <[email protected]>
Date: Wed, 01 Nov 2006 22:08:48 +0100

Quoted 14 lines

This patch splits out the event cache into its own file nf_conntrack_ecache.c

Index: linux-2.6.19-rc3-git4.quilt/include/net/netfilter/nf_conntrack_ecache.h
===================================================================

include/net/netfilter/nf_conntrack_ecache.h new file +2 -0
@@ -0,0 +1,95 @@
+/*
+ * connection tracking event cache.

include/net/netfilter/nf_conntrack_ecache.h line 12

Quoted 10 lines
include/net/netfilter/nf_conntrack_ecache.h new file +10 -0
+ */
+
+#ifndef _NF_CONNTRACK_ECACHE_H
+#define _NF_CONNTRACK_ECACHE_H
+#include <net/netfilter/nf_conntrack.h>
+
+#ifdef CONFIG_NF_CONNTRACK_EVENTS
+#include <linux/notifier.h>
+#include <linux/interrupt.h>
+#include <net/netfilter/nf_conntrack_expect.h>

This should be out of CONFIG_NF_CONNTRACK_EVENTS, to avoid build error at

include/net/netfilter/nf_conntrack_ecache.h line 90

Quoted 12 lines

....

include/net/netfilter/nf_conntrack_ecache.h new file +10 -0
+#else /* CONFIG_NF_CONNTRACK_EVENTS */
+
+static inline void nf_conntrack_event_cache(enum ip_conntrack_events event,
+					    const struct sk_buff *skb) {}
+static inline void nf_conntrack_event(enum ip_conntrack_events event,
+				      struct nf_conn *ct) {}
+static inline void nf_ct_deliver_cached_events(const struct nf_conn *ct) {}
+static inline void
+nf_conntrack_expect_event(enum ip_conntrack_expect_events event,
+			  struct nf_conntrack_expect *exp) {}

here.

-- Yasuyuki Kozakai

A message that is not in the archive (sent off-list or not yet received): [email protected]

#11 lore raw

Re: [PATCH 03/11] Split out the event cache

Quoted 7 lines · Yasuyuki KOZAKAI

include/net/netfilter/nf_conntrack_ecache.h line 12

Quoted 4 lines
include/net/netfilter/nf_conntrack_ecache.h new file +4 -0
+#ifdef CONFIG_NF_CONNTRACK_EVENTS
+#include <linux/notifier.h>
+#include <linux/interrupt.h>
+#include <net/netfilter/nf_conntrack_expect.h>

This should be out of CONFIG_NF_CONNTRACK_EVENTS, to avoid build error at

Thanks, I'll fix it up after doing a few more build tests.

#12 lore raw

Re: [PATCH 03/11] Split out the event cache

From: Patrick McHardy <[email protected]>
Date: Fri, 03 Nov 2006 13:51:14 +0100

Quoted 10 lines
Quoted 7 lines · Yasuyuki KOZAKAI

include/net/netfilter/nf_conntrack_ecache.h line 12

Quoted 4 lines
include/net/netfilter/nf_conntrack_ecache.h new file +4 -0
+#ifdef CONFIG_NF_CONNTRACK_EVENTS
+#include <linux/notifier.h>
+#include <linux/interrupt.h>
+#include <net/netfilter/nf_conntrack_expect.h>

This should be out of CONFIG_NF_CONNTRACK_EVENTS, to avoid build error at

Thanks, I'll fix it up after doing a few more build tests.

You will find missing "#include <net/netfilter/nf_conntrack_ecache.h>" in xt_CONNMARK.c. This is last error I found today.

-- Yasuyuki Kozakai

#13 lore raw

Re: [PATCH 03/11] Split out the event cache

In reply to Patrick McHardy
Quoted 10 lines · Patrick McHardy
Quoted 7 lines · Yasuyuki KOZAKAI

include/net/netfilter/nf_conntrack_ecache.h line 12

Quoted 4 lines
include/net/netfilter/nf_conntrack_ecache.h new file +4 -0
+#ifdef CONFIG_NF_CONNTRACK_EVENTS
+#include <linux/notifier.h>
+#include <linux/interrupt.h>
+#include <net/netfilter/nf_conntrack_expect.h>

This should be out of CONFIG_NF_CONNTRACK_EVENTS, to avoid build error at

Thanks, I'll fix it up after doing a few more build tests.

Sorry about the build errors etc, I'll try more .config combinations in the future.

/Martin

#14 lore raw

Re: [PATCH 03/11] Split out the event cache

Quoted 7 lines · Martin Josefsson
Quoted 1 line · Patrick McHardy

Thanks, I'll fix it up after doing a few more build tests.

Sorry about the build errors etc, I'll try more .config combinations in the future.

No problem, it happens to everyone :)

#15 lore raw

PATCH 4/11 Split out protocol handling

In reply to Martin Josefsson

This patch splits out L3/L4 protocol handling into its own file nf_conntrack_proto.c

---
 net/netfilter/Makefile                  |    2 
 net/netfilter/nf_conntrack_core.c       |   81 -----------
 net/netfilter/nf_conntrack_proto.c      |  225 ++++++++++++++++++++++++++++++++
 net/netfilter/nf_conntrack_standalone.c |  116 ----------------
 4 files changed, 226 insertions(+), 198 deletions(-)
net/netfilter/Makefile +1 -1
Index: linux-2.6.19-rc3-git4.quilt/net/netfilter/Makefile
===================================================================
@@ -1,6 +1,6 @@
 netfilter-objs := core.o nf_log.o nf_queue.o nf_sockopt.o
 
-nf_conntrack-y	:= nf_conntrack_core.o nf_conntrack_standalone.o nf_conntrack_expect.o nf_conntrack_helper.o nf_conntrack_l3proto_generic.o nf_conntrack_proto_generic.o nf_conntrack_proto_tcp.o nf_conntrack_proto_udp.o
+nf_conntrack-y	:= nf_conntrack_core.o nf_conntrack_standalone.o nf_conntrack_expect.o nf_conntrack_helper.o nf_conntrack_proto.o nf_conntrack_l3proto_generic.o nf_conntrack_proto_generic.o nf_conntrack_proto_tcp.o nf_conntrack_proto_udp.o
 nf_conntrack-$(CONFIG_NF_CONNTRACK_EVENTS) += nf_conntrack_ecache.o
 
 obj-$(CONFIG_NETFILTER) = netfilter.o
net/netfilter/nf_conntrack_core.c +0 -81

93 lines not on this page · raw message

net/netfilter/nf_conntrack_proto.c new file +225 -0

225 lines not on this page · raw message

net/netfilter/nf_conntrack_standalone.c +0 -116

128 lines not on this page · raw message

--
/Martin

#16 lore raw

Re: [PATCH 04/11] Split out protocol handling

Quoted 2 lines · Martin Josefsson

This patch splits out L3/L4 protocol handling into its own file nf_conntrack_proto.c

Also applied.

#17 lore raw

PATCH 5/11 More __read_mostly

In reply to Martin Josefsson

Place rarely written variables in the read-mostly section by using __read_mostly

---
 net/netfilter/core.c                |    4 ++--
 net/netfilter/nf_conntrack_core.c   |    4 ++--
 net/netfilter/nf_conntrack_helper.c |    2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)
net/netfilter/nf_conntrack_core.c +2 -2
Index: linux-2.6.19-rc3-git4.quilt/net/netfilter/nf_conntrack_core.c
===================================================================
@@ -73,10 +73,10 @@ DEFINE_RWLOCK(nf_conntrack_lock);
 atomic_t nf_conntrack_count = ATOMIC_INIT(0);
 
 void (*nf_conntrack_destroyed)(struct nf_conn *conntrack) = NULL;
-unsigned int nf_conntrack_htable_size __read_mostly = 0;
+unsigned int nf_conntrack_htable_size __read_mostly;
 int nf_conntrack_max __read_mostly;
 struct list_head *nf_conntrack_hash __read_mostly;
-struct nf_conn nf_conntrack_untracked;
+struct nf_conn nf_conntrack_untracked __read_mostly;
 unsigned int nf_ct_log_invalid __read_mostly;
 LIST_HEAD(unconfirmed);
 static int nf_conntrack_vmalloc __read_mostly;
net/netfilter/nf_conntrack_helper.c +1 -1
Index: linux-2.6.19-rc3-git4.quilt/net/netfilter/nf_conntrack_helper.c
===================================================================
@@ -30,7 +30,7 @@
 #include <net/netfilter/nf_conntrack_helper.h>
 #include <net/netfilter/nf_conntrack_core.h>
 
-static LIST_HEAD(helpers);
+static struct list_head helpers __read_mostly = { &(helpers), &(helpers) };
 
 struct nf_conntrack_helper *
 __nf_ct_helper_find(const struct nf_conntrack_tuple *tuple)
net/netfilter/core.c +2 -2
Index: linux-2.6.19-rc3-git4.quilt/net/netfilter/core.c
===================================================================
@@ -28,7 +28,7 @@
 
 static DEFINE_SPINLOCK(afinfo_lock);
 
-struct nf_afinfo *nf_afinfo[NPROTO];
+struct nf_afinfo *nf_afinfo[NPROTO] __read_mostly;
 EXPORT_SYMBOL(nf_afinfo);
 
 int nf_register_afinfo(struct nf_afinfo *afinfo)
@@ -54,7 +54,7 @@ EXPORT_SYMBOL_GPL(nf_unregister_afinfo);
  * of skbuffs queued for userspace, and not deregister a hook unless
  * this is zero, but that sucks.  Now, we simply check when the
  * packets come back: if the hook is gone, the packet is discarded. */
-struct list_head nf_hooks[NPROTO][NF_MAX_HOOKS];
+struct list_head nf_hooks[NPROTO][NF_MAX_HOOKS] __read_mostly;
 EXPORT_SYMBOL(nf_hooks);
 static DEFINE_SPINLOCK(nf_hook_lock);
 

--
/Martin

#18 lore raw

Re: [PATCH 05/11] More __read_mostly

net/netfilter/nf_conntrack_helper.c line 33

Quoted 10 lines · Martin Josefsson

Place rarely written variables in the read-mostly section by using __read_mostly

net/netfilter/nf_conntrack_helper.c +1 -1
@@ -30,7 +30,7 @@
 #include <net/netfilter/nf_conntrack_helper.h>
 #include <net/netfilter/nf_conntrack_core.h>
 
-static LIST_HEAD(helpers);
+static struct list_head helpers __read_mostly = { &(helpers), &(helpers) };

Applied, but I changed this to static __read_mostly LIST_HEAD(helpers).

#19 lore raw

Re: [PATCH 05/11] More __read_mostly

Quoted 9 lines · Patrick McHardy
Quoted 8 lines · Martin Josefsson

Place rarely written variables in the read-mostly section by using __read_mostly

net/netfilter/nf_conntrack_helper.c +0 -0
@@ -30,7 +30,7 @@
 #include <net/netfilter/nf_conntrack_helper.h>
 #include <net/netfilter/nf_conntrack_core.h>
 
Quoted 4 lines

net/netfilter/nf_conntrack_helper.c line 33

Quoted 2 lines
net/netfilter/nf_conntrack_helper.c +1 -1
-static LIST_HEAD(helpers);
+static struct list_head helpers __read_mostly = { &(helpers), &(helpers) };

Applied, but I changed this to static __read_mostly LIST_HEAD(helpers).

I thought I tried that and gcc barfed... maybe it was too late at night :)

/Martin

#20 lore raw

Re: [PATCH 05/11] More __read_mostly

Quoted 13 lines · Martin Josefsson
Quoted 10 lines · Patrick McHardy
Quoted 8 lines · Martin Josefsson

Place rarely written variables in the read-mostly section by using __read_mostly

net/netfilter/nf_conntrack_helper.c +0 -0
@@ -30,7 +30,7 @@
 #include <net/netfilter/nf_conntrack_helper.h>
 #include <net/netfilter/nf_conntrack_core.h>
 
Quoted 7 lines
Quoted 4 lines

net/netfilter/nf_conntrack_helper.c line 33

Quoted 2 lines
net/netfilter/nf_conntrack_helper.c +1 -1
-static LIST_HEAD(helpers);
+static struct list_head helpers __read_mostly = { &(helpers), &(helpers) };

Applied, but I changed this to static __read_mostly LIST_HEAD(helpers).

I thought I tried that and gcc barfed... maybe it was too late at night :)

It barfed at me too when I put it behind LIST_HEAD (for whatever reason), but this way compiles cleanly.

#21 lore raw

Re: [PATCH 05/11] More __read_mostly

Quoted 10 lines · Patrick McHardy
Quoted 7 lines
Quoted 4 lines

net/netfilter/nf_conntrack_helper.c line 33

Quoted 2 lines
net/netfilter/nf_conntrack_helper.c +1 -1
-static LIST_HEAD(helpers);
+static struct list_head helpers __read_mostly = { &(helpers), &(helpers) };

Applied, but I changed this to static __read_mostly LIST_HEAD(helpers).

I thought I tried that and gcc barfed... maybe it was too late at night :)

It barfed at me too when I put it behind LIST_HEAD (for whatever reason), but this way compiles cleanly.

That must have been what I tested, hacking late at night after working all day isn't so good it seems. Thanks for fixing it.

/Martin

#22 lore raw

PATCH 6/11 Rename struct nf_conntrack_protocol

In reply to Martin Josefsson

Rename 'struct nf_conntrack_protocol' to 'struct nf_conntrack_l4proto' in order to help distinguish it from 'struct nf_conntrack_l3proto'. It gets rather confusing with 'nf_conntrack_protocol'.

---
 include/net/netfilter/nf_conntrack_core.h      |   10 -
 include/net/netfilter/nf_conntrack_l3proto.h   |    4 
 include/net/netfilter/nf_conntrack_l4proto.h   |  129 +++++++++++++++++++++++++
 include/net/netfilter/nf_conntrack_protocol.h  |  129 -------------------------
 net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c |   26 ++---
 net/ipv4/netfilter/nf_conntrack_proto_icmp.c   |   12 +-
 net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c |   26 ++---
 net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c |   12 +-
 net/netfilter/nf_conntrack_core.c              |   46 ++++----
 net/netfilter/nf_conntrack_ecache.c            |    2 
 net/netfilter/nf_conntrack_expect.c            |    2 
 net/netfilter/nf_conntrack_helper.c            |    2 
 net/netfilter/nf_conntrack_l3proto_generic.c   |    4 
 net/netfilter/nf_conntrack_netlink.c           |   54 +++++-----
 net/netfilter/nf_conntrack_proto.c             |   72 ++++++-------
 net/netfilter/nf_conntrack_proto_generic.c     |    6 -
 net/netfilter/nf_conntrack_proto_sctp.c        |   26 ++---
 net/netfilter/nf_conntrack_proto_tcp.c         |   14 +-
 net/netfilter/nf_conntrack_proto_udp.c         |   14 +-
 net/netfilter/nf_conntrack_standalone.c        |   28 ++---
 20 files changed, 309 insertions(+), 309 deletions(-)
include/net/netfilter/nf_conntrack_core.h +5 -5
Index: linux-2.6.19-rc3-git4.quilt/include/net/netfilter/nf_conntrack_core.h
===================================================================
@@ -14,7 +14,7 @@
 
 #include <linux/netfilter.h>
 #include <net/netfilter/nf_conntrack_l3proto.h>
-#include <net/netfilter/nf_conntrack_protocol.h>
+#include <net/netfilter/nf_conntrack_l4proto.h>
 #include <net/netfilter/nf_conntrack_ecache.h>
 
 /* This header is used to share core functionality between the
@@ -32,7 +32,7 @@ extern struct nf_conntrack_l3proto *nf_c
 /* Like above, but you already have conntrack read lock. */
 extern struct nf_conntrack_l3proto *__nf_ct_find_l3proto(u_int16_t l3proto);
 
-struct nf_conntrack_protocol;
+struct nf_conntrack_l4proto;
 
 extern int
 nf_ct_get_tuple(const struct sk_buff *skb,
@@ -42,13 +42,13 @@ nf_ct_get_tuple(const struct sk_buff *sk
 		u_int8_t protonum,
 		struct nf_conntrack_tuple *tuple,
 		const struct nf_conntrack_l3proto *l3proto,
-		const struct nf_conntrack_protocol *protocol);
+		const struct nf_conntrack_l4proto *l4proto);
 
 extern int
 nf_ct_invert_tuple(struct nf_conntrack_tuple *inverse,
 		   const struct nf_conntrack_tuple *orig,
 		   const struct nf_conntrack_l3proto *l3proto,
-		   const struct nf_conntrack_protocol *protocol);
+		   const struct nf_conntrack_l4proto *l4proto);
 
 /* Find a connection corresponding to a tuple. */
 extern struct nf_conntrack_tuple_hash *
@@ -76,7 +76,7 @@ extern void __nf_conntrack_attach(struct
 int
 print_tuple(struct seq_file *s, const struct nf_conntrack_tuple *tuple,
 	    struct nf_conntrack_l3proto *l3proto,
-	    struct nf_conntrack_protocol *proto);
+	    struct nf_conntrack_l4proto *proto);
 
 extern struct list_head *nf_conntrack_hash;
 extern struct list_head nf_conntrack_expect_list;
include/net/netfilter/nf_conntrack_l3proto.h +2 -2
Index: linux-2.6.19-rc3-git4.quilt/include/net/netfilter/nf_conntrack_l3proto.h
===================================================================
@@ -96,13 +96,13 @@ extern void nf_ct_l3proto_put(struct nf_
 /* Existing built-in protocols */
 extern struct nf_conntrack_l3proto nf_conntrack_l3proto_ipv4;
 extern struct nf_conntrack_l3proto nf_conntrack_l3proto_ipv6;
-extern struct nf_conntrack_l3proto nf_conntrack_generic_l3proto;
+extern struct nf_conntrack_l3proto nf_conntrack_l3proto_generic;
 
 static inline struct nf_conntrack_l3proto *
 __nf_ct_l3proto_find(u_int16_t l3proto)
 {
 	if (unlikely(l3proto >= AF_MAX))
-		return &nf_conntrack_generic_l3proto;
+		return &nf_conntrack_l3proto_generic;
 	return nf_ct_l3protos[l3proto];
 }
 
include/net/netfilter/nf_conntrack_l4proto.h new file +129 -0

129 lines not on this page · raw message

include/net/netfilter/nf_conntrack_protocol.h deleted +0 -129

129 lines not on this page · raw message

net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c +13 -13
Index: linux-2.6.19-rc3-git4.quilt/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c
===================================================================
@@ -27,7 +27,7 @@
 #include <linux/netfilter_ipv4.h>
 #include <net/netfilter/nf_conntrack.h>
 #include <net/netfilter/nf_conntrack_helper.h>
-#include <net/netfilter/nf_conntrack_protocol.h>
+#include <net/netfilter/nf_conntrack_l4proto.h>
 #include <net/netfilter/nf_conntrack_l3proto.h>
 #include <net/netfilter/nf_conntrack_core.h>
 #include <net/netfilter/ipv4/nf_conntrack_ipv4.h>
@@ -429,9 +429,9 @@ struct nf_conntrack_l3proto nf_conntrack
 	.me		 = THIS_MODULE,
 };
 
-extern struct nf_conntrack_protocol nf_conntrack_protocol_tcp4;
-extern struct nf_conntrack_protocol nf_conntrack_protocol_udp4;
-extern struct nf_conntrack_protocol nf_conntrack_protocol_icmp;
+extern struct nf_conntrack_l4proto nf_conntrack_l4proto_tcp4;
+extern struct nf_conntrack_l4proto nf_conntrack_l4proto_udp4;
+extern struct nf_conntrack_l4proto nf_conntrack_l4proto_icmp;
 
 MODULE_ALIAS("nf_conntrack-" __stringify(AF_INET));
 MODULE_LICENSE("GPL");
@@ -448,19 +448,19 @@ static int __init nf_conntrack_l3proto_i
 		return ret;
 	}
 
-	ret = nf_conntrack_protocol_register(&nf_conntrack_protocol_tcp4);
+	ret = nf_conntrack_l4proto_register(&nf_conntrack_l4proto_tcp4);
 	if (ret < 0) {
 		printk("nf_conntrack_ipv4: can't register tcp.\n");
 		goto cleanup_sockopt;
 	}
 
-	ret = nf_conntrack_protocol_register(&nf_conntrack_protocol_udp4);
+	ret = nf_conntrack_l4proto_register(&nf_conntrack_l4proto_udp4);
 	if (ret < 0) {
 		printk("nf_conntrack_ipv4: can't register udp.\n");
 		goto cleanup_tcp;
 	}
 
-	ret = nf_conntrack_protocol_register(&nf_conntrack_protocol_icmp);
+	ret = nf_conntrack_l4proto_register(&nf_conntrack_l4proto_icmp);
 	if (ret < 0) {
 		printk("nf_conntrack_ipv4: can't register icmp.\n");
 		goto cleanup_udp;
@@ -495,11 +495,11 @@ static int __init nf_conntrack_l3proto_i
  cleanup_ipv4:
 	nf_conntrack_l3proto_unregister(&nf_conntrack_l3proto_ipv4);
  cleanup_icmp:
-	nf_conntrack_protocol_unregister(&nf_conntrack_protocol_icmp);
+	nf_conntrack_l4proto_unregister(&nf_conntrack_l4proto_icmp);
  cleanup_udp:
-	nf_conntrack_protocol_unregister(&nf_conntrack_protocol_udp4);
+	nf_conntrack_l4proto_unregister(&nf_conntrack_l4proto_udp4);
  cleanup_tcp:
-	nf_conntrack_protocol_unregister(&nf_conntrack_protocol_tcp4);
+	nf_conntrack_l4proto_unregister(&nf_conntrack_l4proto_tcp4);
  cleanup_sockopt:
 	nf_unregister_sockopt(&so_getorigdst);
 	return ret;
@@ -513,9 +513,9 @@ static void __exit nf_conntrack_l3proto_
 #endif
 	nf_unregister_hooks(ipv4_conntrack_ops, ARRAY_SIZE(ipv4_conntrack_ops));
 	nf_conntrack_l3proto_unregister(&nf_conntrack_l3proto_ipv4);
-	nf_conntrack_protocol_unregister(&nf_conntrack_protocol_icmp);
-	nf_conntrack_protocol_unregister(&nf_conntrack_protocol_udp4);
-	nf_conntrack_protocol_unregister(&nf_conntrack_protocol_tcp4);
+	nf_conntrack_l4proto_unregister(&nf_conntrack_l4proto_icmp);
+	nf_conntrack_l4proto_unregister(&nf_conntrack_l4proto_udp4);
+	nf_conntrack_l4proto_unregister(&nf_conntrack_l4proto_tcp4);
 	nf_unregister_sockopt(&so_getorigdst);
 }
 
net/ipv4/netfilter/nf_conntrack_proto_icmp.c +6 -6
Index: linux-2.6.19-rc3-git4.quilt/net/ipv4/netfilter/nf_conntrack_proto_icmp.c
===================================================================
@@ -22,7 +22,7 @@
 #include <net/checksum.h>
 #include <linux/netfilter_ipv4.h>
 #include <net/netfilter/nf_conntrack_tuple.h>
-#include <net/netfilter/nf_conntrack_protocol.h>
+#include <net/netfilter/nf_conntrack_l4proto.h>
 #include <net/netfilter/nf_conntrack_core.h>
 
 unsigned long nf_ct_icmp_timeout __read_mostly = 30*HZ;
@@ -152,7 +152,7 @@ icmp_error_message(struct sk_buff *skb,
 		struct icmphdr icmp;
 		struct iphdr ip;
 	} _in, *inside;
-	struct nf_conntrack_protocol *innerproto;
+	struct nf_conntrack_l4proto *innerproto;
 	struct nf_conntrack_tuple_hash *h;
 	int dataoff;
 
@@ -170,7 +170,7 @@ icmp_error_message(struct sk_buff *skb,
 		return -NF_ACCEPT;
 	}
 
-	innerproto = __nf_ct_proto_find(PF_INET, inside->ip.protocol);
+	innerproto = __nf_ct_l4proto_find(PF_INET, inside->ip.protocol);
 	dataoff = skb->nh.iph->ihl*4 + sizeof(inside->icmp);
 	/* Are they talking about one of our connections? */
 	if (!nf_ct_get_tuple(skb, dataoff, dataoff + inside->ip.ihl*4, PF_INET,
@@ -321,11 +321,11 @@ static int icmp_nfattr_to_tuple(struct n
 }
 #endif
 
-struct nf_conntrack_protocol nf_conntrack_protocol_icmp =
+struct nf_conntrack_l4proto nf_conntrack_l4proto_icmp =
 {
 	.list			= { NULL, NULL },
 	.l3proto		= PF_INET,
-	.proto			= IPPROTO_ICMP,
+	.l4proto		= IPPROTO_ICMP,
 	.name			= "icmp",
 	.pkt_to_tuple		= icmp_pkt_to_tuple,
 	.invert_tuple		= icmp_invert_tuple,
@@ -343,4 +343,4 @@ struct nf_conntrack_protocol nf_conntrac
 #endif
 };
 
-EXPORT_SYMBOL(nf_conntrack_protocol_icmp);
+EXPORT_SYMBOL(nf_conntrack_l4proto_icmp);
net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c +13 -13
Index: linux-2.6.19-rc3-git4.quilt/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c
===================================================================
@@ -33,7 +33,7 @@
 #include <linux/netfilter_ipv6.h>
 #include <net/netfilter/nf_conntrack.h>
 #include <net/netfilter/nf_conntrack_helper.h>
-#include <net/netfilter/nf_conntrack_protocol.h>
+#include <net/netfilter/nf_conntrack_l4proto.h>
 #include <net/netfilter/nf_conntrack_l3proto.h>
 #include <net/netfilter/nf_conntrack_core.h>
 
@@ -458,9 +458,9 @@ struct nf_conntrack_l3proto nf_conntrack
 	.me			= THIS_MODULE,
 };
 
-extern struct nf_conntrack_protocol nf_conntrack_protocol_tcp6;
-extern struct nf_conntrack_protocol nf_conntrack_protocol_udp6;
-extern struct nf_conntrack_protocol nf_conntrack_protocol_icmpv6;
+extern struct nf_conntrack_l4proto nf_conntrack_l4proto_tcp6;
+extern struct nf_conntrack_l4proto nf_conntrack_l4proto_udp6;
+extern struct nf_conntrack_l4proto nf_conntrack_l4proto_icmpv6;
 extern int nf_ct_frag6_init(void);
 extern void nf_ct_frag6_cleanup(void);
 
@@ -479,19 +479,19 @@ static int __init nf_conntrack_l3proto_i
 		printk("nf_conntrack_ipv6: can't initialize frag6.\n");
 		return ret;
 	}
-	ret = nf_conntrack_protocol_register(&nf_conntrack_protocol_tcp6);
+	ret = nf_conntrack_l4proto_register(&nf_conntrack_l4proto_tcp6);
 	if (ret < 0) {
 		printk("nf_conntrack_ipv6: can't register tcp.\n");
 		goto cleanup_frag6;
 	}
 
-	ret = nf_conntrack_protocol_register(&nf_conntrack_protocol_udp6);
+	ret = nf_conntrack_l4proto_register(&nf_conntrack_l4proto_udp6);
 	if (ret < 0) {
 		printk("nf_conntrack_ipv6: can't register udp.\n");
 		goto cleanup_tcp;
 	}
 
-	ret = nf_conntrack_protocol_register(&nf_conntrack_protocol_icmpv6);
+	ret = nf_conntrack_l4proto_register(&nf_conntrack_l4proto_icmpv6);
 	if (ret < 0) {
 		printk("nf_conntrack_ipv6: can't register icmpv6.\n");
 		goto cleanup_udp;
@@ -527,11 +527,11 @@ static int __init nf_conntrack_l3proto_i
  cleanup_ipv6:
 	nf_conntrack_l3proto_unregister(&nf_conntrack_l3proto_ipv6);
  cleanup_icmpv6:
-	nf_conntrack_protocol_unregister(&nf_conntrack_protocol_icmpv6);
+	nf_conntrack_l4proto_unregister(&nf_conntrack_l4proto_icmpv6);
  cleanup_udp:
-	nf_conntrack_protocol_unregister(&nf_conntrack_protocol_udp6);
+	nf_conntrack_l4proto_unregister(&nf_conntrack_l4proto_udp6);
  cleanup_tcp:
-	nf_conntrack_protocol_unregister(&nf_conntrack_protocol_tcp6);
+	nf_conntrack_l4proto_unregister(&nf_conntrack_l4proto_tcp6);
  cleanup_frag6:
 	nf_ct_frag6_cleanup();
 	return ret;
@@ -545,9 +545,9 @@ static void __exit nf_conntrack_l3proto_
 #endif
 	nf_unregister_hooks(ipv6_conntrack_ops, ARRAY_SIZE(ipv6_conntrack_ops));
 	nf_conntrack_l3proto_unregister(&nf_conntrack_l3proto_ipv6);
-	nf_conntrack_protocol_unregister(&nf_conntrack_protocol_icmpv6);
-	nf_conntrack_protocol_unregister(&nf_conntrack_protocol_udp6);
-	nf_conntrack_protocol_unregister(&nf_conntrack_protocol_tcp6);
+	nf_conntrack_l4proto_unregister(&nf_conntrack_l4proto_icmpv6);
+	nf_conntrack_l4proto_unregister(&nf_conntrack_l4proto_udp6);
+	nf_conntrack_l4proto_unregister(&nf_conntrack_l4proto_tcp6);
 	nf_ct_frag6_cleanup();
 }
 
net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c +6 -6
Index: linux-2.6.19-rc3-git4.quilt/net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c
===================================================================
@@ -29,7 +29,7 @@
 #include <linux/seq_file.h>
 #include <linux/netfilter_ipv6.h>
 #include <net/netfilter/nf_conntrack_tuple.h>
-#include <net/netfilter/nf_conntrack_protocol.h>
+#include <net/netfilter/nf_conntrack_l4proto.h>
 #include <net/netfilter/nf_conntrack_core.h>
 #include <net/netfilter/ipv6/nf_conntrack_icmpv6.h>
 
@@ -155,7 +155,7 @@ icmpv6_error_message(struct sk_buff *skb
 	struct nf_conntrack_tuple_hash *h;
 	struct icmp6hdr _hdr, *hp;
 	unsigned int inip6off;
-	struct nf_conntrack_protocol *inproto;
+	struct nf_conntrack_l4proto *inproto;
 	u_int8_t inprotonum;
 	unsigned int inprotoff;
 
@@ -185,7 +185,7 @@ icmpv6_error_message(struct sk_buff *skb
 		return -NF_ACCEPT;
 	}
 
-	inproto = __nf_ct_proto_find(PF_INET6, inprotonum);
+	inproto = __nf_ct_l4proto_find(PF_INET6, inprotonum);
 
 	/* Are they talking about one of our connections? */
 	if (!nf_ct_get_tuple(skb, inip6off, inprotoff, PF_INET6, inprotonum,
@@ -301,10 +301,10 @@ static int icmpv6_nfattr_to_tuple(struct
 }
 #endif
 
-struct nf_conntrack_protocol nf_conntrack_protocol_icmpv6 =
+struct nf_conntrack_l4proto nf_conntrack_l4proto_icmpv6 =
 {
 	.l3proto		= PF_INET6,
-	.proto			= IPPROTO_ICMPV6,
+	.l4proto		= IPPROTO_ICMPV6,
 	.name			= "icmpv6",
 	.pkt_to_tuple		= icmpv6_pkt_to_tuple,
 	.invert_tuple		= icmpv6_invert_tuple,
@@ -320,4 +320,4 @@ struct nf_conntrack_protocol nf_conntrac
 #endif
 };
 
-EXPORT_SYMBOL(nf_conntrack_protocol_icmpv6);
+EXPORT_SYMBOL(nf_conntrack_l4proto_icmpv6);
net/netfilter/nf_conntrack_core.c +23 -23

163 lines not on this page · raw message

net/netfilter/nf_conntrack_l3proto_generic.c +2 -2
Index: linux-2.6.19-rc3-git4.quilt/net/netfilter/nf_conntrack_l3proto_generic.c
===================================================================
@@ -26,7 +26,7 @@
 
 #include <linux/netfilter_ipv4.h>
 #include <net/netfilter/nf_conntrack.h>
-#include <net/netfilter/nf_conntrack_protocol.h>
+#include <net/netfilter/nf_conntrack_l4proto.h>
 #include <net/netfilter/nf_conntrack_l3proto.h>
 #include <net/netfilter/nf_conntrack_core.h>
 #include <net/netfilter/ipv4/nf_conntrack_ipv4.h>
@@ -84,7 +84,7 @@ static u_int32_t generic_get_features(co
 	return NF_CT_F_BASIC;
 }
 
-struct nf_conntrack_l3proto nf_conntrack_generic_l3proto = {
+struct nf_conntrack_l3proto nf_conntrack_l3proto_generic = {
 	.l3proto	 = PF_UNSPEC,
 	.name		 = "unknown",
 	.pkt_to_tuple	 = generic_pkt_to_tuple,
net/netfilter/nf_conntrack_netlink.c +27 -27

138 lines not on this page · raw message

net/netfilter/nf_conntrack_proto_generic.c +3 -3
Index: linux-2.6.19-rc3-git4.quilt/net/netfilter/nf_conntrack_proto_generic.c
===================================================================
@@ -15,7 +15,7 @@
 #include <linux/sched.h>
 #include <linux/timer.h>
 #include <linux/netfilter.h>
-#include <net/netfilter/nf_conntrack_protocol.h>
+#include <net/netfilter/nf_conntrack_l4proto.h>
 
 unsigned int nf_ct_generic_timeout __read_mostly = 600*HZ;
 
@@ -71,10 +71,10 @@ static int new(struct nf_conn *conntrack
 	return 1;
 }
 
-struct nf_conntrack_protocol nf_conntrack_generic_protocol =
+struct nf_conntrack_l4proto nf_conntrack_l4proto_generic =
 {
 	.l3proto		= PF_UNSPEC,
-	.proto			= 0,
+	.l4proto		= 0,
 	.name			= "unknown",
 	.pkt_to_tuple		= generic_pkt_to_tuple,
 	.invert_tuple		= generic_invert_tuple,
net/netfilter/nf_conntrack_proto_sctp.c +13 -13
Index: linux-2.6.19-rc3-git4.quilt/net/netfilter/nf_conntrack_proto_sctp.c
===================================================================
@@ -32,7 +32,7 @@
 #include <linux/interrupt.h>
 
 #include <net/netfilter/nf_conntrack.h>
-#include <net/netfilter/nf_conntrack_protocol.h>
+#include <net/netfilter/nf_conntrack_l4proto.h>
 #include <net/netfilter/nf_conntrack_ecache.h>
 
 #if 0
@@ -509,9 +509,9 @@ static int sctp_new(struct nf_conn *conn
 	return 1;
 }
 
-struct nf_conntrack_protocol nf_conntrack_protocol_sctp4 = { 
+struct nf_conntrack_l4proto nf_conntrack_l4proto_sctp4 = {
 	.l3proto	 = PF_INET,
-	.proto 		 = IPPROTO_SCTP, 
+	.l4proto 	 = IPPROTO_SCTP,
 	.name 		 = "sctp",
 	.pkt_to_tuple 	 = sctp_pkt_to_tuple, 
 	.invert_tuple 	 = sctp_invert_tuple, 
@@ -523,9 +523,9 @@ struct nf_conntrack_protocol nf_conntrac
 	.me 		 = THIS_MODULE 
 };
 
-struct nf_conntrack_protocol nf_conntrack_protocol_sctp6 = { 
+struct nf_conntrack_l4proto nf_conntrack_l4proto_sctp6 = {
 	.l3proto	 = PF_INET6,
-	.proto 		 = IPPROTO_SCTP, 
+	.l4proto 	 = IPPROTO_SCTP,
 	.name 		 = "sctp",
 	.pkt_to_tuple 	 = sctp_pkt_to_tuple, 
 	.invert_tuple 	 = sctp_invert_tuple, 
@@ -625,14 +625,14 @@ int __init nf_conntrack_proto_sctp_init(
 {
 	int ret;
 
-	ret = nf_conntrack_protocol_register(&nf_conntrack_protocol_sctp4);
+	ret = nf_conntrack_l4proto_register(&nf_conntrack_l4proto_sctp4);
 	if (ret) {
-		printk("nf_conntrack_proto_sctp4: protocol register failed\n");
+		printk("nf_conntrack_l4proto_sctp4: protocol register failed\n");
 		goto out;
 	}
-	ret = nf_conntrack_protocol_register(&nf_conntrack_protocol_sctp6);
+	ret = nf_conntrack_l4proto_register(&nf_conntrack_l4proto_sctp6);
 	if (ret) {
-		printk("nf_conntrack_proto_sctp6: protocol register failed\n");
+		printk("nf_conntrack_l4proto_sctp6: protocol register failed\n");
 		goto cleanup_sctp4;
 	}
 
@@ -648,10 +648,10 @@ int __init nf_conntrack_proto_sctp_init(
 
 #ifdef CONFIG_SYSCTL
  cleanup:
-	nf_conntrack_protocol_unregister(&nf_conntrack_protocol_sctp6);
+	nf_conntrack_l4proto_unregister(&nf_conntrack_l4proto_sctp6);
 #endif
  cleanup_sctp4:
-	nf_conntrack_protocol_unregister(&nf_conntrack_protocol_sctp4);
+	nf_conntrack_l4proto_unregister(&nf_conntrack_l4proto_sctp4);
  out:
 	DEBUGP("SCTP conntrack module loading %s\n", 
 					ret ? "failed": "succeeded");
@@ -660,8 +660,8 @@ int __init nf_conntrack_proto_sctp_init(
 
 void __exit nf_conntrack_proto_sctp_fini(void)
 {
-	nf_conntrack_protocol_unregister(&nf_conntrack_protocol_sctp6);
-	nf_conntrack_protocol_unregister(&nf_conntrack_protocol_sctp4);
+	nf_conntrack_l4proto_unregister(&nf_conntrack_l4proto_sctp6);
+	nf_conntrack_l4proto_unregister(&nf_conntrack_l4proto_sctp4);
 #ifdef CONFIG_SYSCTL
  	unregister_sysctl_table(nf_ct_sysctl_header);
 #endif
net/netfilter/nf_conntrack_proto_tcp.c +7 -7
Index: linux-2.6.19-rc3-git4.quilt/net/netfilter/nf_conntrack_proto_tcp.c
===================================================================
@@ -42,7 +42,7 @@
 #include <linux/netfilter_ipv4.h>
 #include <linux/netfilter_ipv6.h>
 #include <net/netfilter/nf_conntrack.h>
-#include <net/netfilter/nf_conntrack_protocol.h>
+#include <net/netfilter/nf_conntrack_l4proto.h>
 #include <net/netfilter/nf_conntrack_ecache.h>
 
 #if 0
@@ -1169,10 +1169,10 @@ static int nfattr_to_tcp(struct nfattr *
 }
 #endif
   
-struct nf_conntrack_protocol nf_conntrack_protocol_tcp4 =
+struct nf_conntrack_l4proto nf_conntrack_l4proto_tcp4 =
 {
 	.l3proto		= PF_INET,
-	.proto 			= IPPROTO_TCP,
+	.l4proto 		= IPPROTO_TCP,
 	.name 			= "tcp",
 	.pkt_to_tuple 		= tcp_pkt_to_tuple,
 	.invert_tuple 		= tcp_invert_tuple,
@@ -1190,10 +1190,10 @@ struct nf_conntrack_protocol nf_conntrac
 #endif
 };
 
-struct nf_conntrack_protocol nf_conntrack_protocol_tcp6 =
+struct nf_conntrack_l4proto nf_conntrack_l4proto_tcp6 =
 {
 	.l3proto		= PF_INET6,
-	.proto 			= IPPROTO_TCP,
+	.l4proto 		= IPPROTO_TCP,
 	.name 			= "tcp",
 	.pkt_to_tuple 		= tcp_pkt_to_tuple,
 	.invert_tuple 		= tcp_invert_tuple,
@@ -1211,5 +1211,5 @@ struct nf_conntrack_protocol nf_conntrac
 #endif
 };
 
-EXPORT_SYMBOL(nf_conntrack_protocol_tcp4);
-EXPORT_SYMBOL(nf_conntrack_protocol_tcp6);
+EXPORT_SYMBOL(nf_conntrack_l4proto_tcp4);
+EXPORT_SYMBOL(nf_conntrack_l4proto_tcp6);
net/netfilter/nf_conntrack_proto_udp.c +7 -7
Index: linux-2.6.19-rc3-git4.quilt/net/netfilter/nf_conntrack_proto_udp.c
===================================================================
@@ -26,7 +26,7 @@
 #include <linux/netfilter.h>
 #include <linux/netfilter_ipv4.h>
 #include <linux/netfilter_ipv6.h>
-#include <net/netfilter/nf_conntrack_protocol.h>
+#include <net/netfilter/nf_conntrack_l4proto.h>
 #include <net/netfilter/nf_conntrack_ecache.h>
 
 unsigned int nf_ct_udp_timeout __read_mostly = 30*HZ;
@@ -148,10 +148,10 @@ static int udp_error(struct sk_buff *skb
 	return NF_ACCEPT;
 }
 
-struct nf_conntrack_protocol nf_conntrack_protocol_udp4 =
+struct nf_conntrack_l4proto nf_conntrack_l4proto_udp4 =
 {
 	.l3proto		= PF_INET,
-	.proto			= IPPROTO_UDP,
+	.l4proto		= IPPROTO_UDP,
 	.name			= "udp",
 	.pkt_to_tuple		= udp_pkt_to_tuple,
 	.invert_tuple		= udp_invert_tuple,
@@ -167,10 +167,10 @@ struct nf_conntrack_protocol nf_conntrac
 #endif
 };
 
-struct nf_conntrack_protocol nf_conntrack_protocol_udp6 =
+struct nf_conntrack_l4proto nf_conntrack_l4proto_udp6 =
 {
 	.l3proto		= PF_INET6,
-	.proto			= IPPROTO_UDP,
+	.l4proto		= IPPROTO_UDP,
 	.name			= "udp",
 	.pkt_to_tuple		= udp_pkt_to_tuple,
 	.invert_tuple		= udp_invert_tuple,
@@ -186,5 +186,5 @@ struct nf_conntrack_protocol nf_conntrac
 #endif
 };
 
-EXPORT_SYMBOL(nf_conntrack_protocol_udp4);
-EXPORT_SYMBOL(nf_conntrack_protocol_udp6);
+EXPORT_SYMBOL(nf_conntrack_l4proto_udp4);
+EXPORT_SYMBOL(nf_conntrack_l4proto_udp6);
net/netfilter/nf_conntrack_standalone.c +14 -14
Index: linux-2.6.19-rc3-git4.quilt/net/netfilter/nf_conntrack_standalone.c
===================================================================
@@ -35,7 +35,7 @@
 #include <net/netfilter/nf_conntrack.h>
 #include <net/netfilter/nf_conntrack_core.h>
 #include <net/netfilter/nf_conntrack_l3proto.h>
-#include <net/netfilter/nf_conntrack_protocol.h>
+#include <net/netfilter/nf_conntrack_l4proto.h>
 #include <net/netfilter/nf_conntrack_expect.h>
 #include <net/netfilter/nf_conntrack_helper.h>
 
@@ -54,9 +54,9 @@ DECLARE_PER_CPU(struct ip_conntrack_stat
 int
 print_tuple(struct seq_file *s, const struct nf_conntrack_tuple *tuple,
 	    struct nf_conntrack_l3proto *l3proto,
-	    struct nf_conntrack_protocol *proto)
+	    struct nf_conntrack_l4proto *l4proto)
 {
-	return l3proto->print_tuple(s, tuple) || proto->print_tuple(s, tuple);
+	return l3proto->print_tuple(s, tuple) || l4proto->print_tuple(s, tuple);
 }
 
 #ifdef CONFIG_NF_CT_ACCT
@@ -135,7 +135,7 @@ static int ct_seq_show(struct seq_file *
 	const struct nf_conntrack_tuple_hash *hash = v;
 	const struct nf_conn *conntrack = nf_ct_tuplehash_to_ctrack(hash);
 	struct nf_conntrack_l3proto *l3proto;
-	struct nf_conntrack_protocol *proto;
+	struct nf_conntrack_l4proto *l4proto;
 
 	ASSERT_READ_LOCK(&nf_conntrack_lock);
 	NF_CT_ASSERT(conntrack);
@@ -148,7 +148,7 @@ static int ct_seq_show(struct seq_file *
 				       .tuple.src.l3num);
 
 	NF_CT_ASSERT(l3proto);
-	proto = __nf_ct_proto_find(conntrack->tuplehash[IP_CT_DIR_ORIGINAL]
+	l4proto = __nf_ct_l4proto_find(conntrack->tuplehash[IP_CT_DIR_ORIGINAL]
 				   .tuple.src.l3num,
 				   conntrack->tuplehash[IP_CT_DIR_ORIGINAL]
 				   .tuple.dst.protonum);
@@ -157,7 +157,7 @@ static int ct_seq_show(struct seq_file *
 	if (seq_printf(s, "%-8s %u %-8s %u %ld ",
 		       l3proto->name,
 		       conntrack->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.l3num,
-		       proto->name,
+		       l4proto->name,
 		       conntrack->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.protonum,
 		       timer_pending(&conntrack->timeout)
 		       ? (long)(conntrack->timeout.expires - jiffies)/HZ : 0) != 0)
@@ -166,11 +166,11 @@ static int ct_seq_show(struct seq_file *
 	if (l3proto->print_conntrack(s, conntrack))
 		return -ENOSPC;
 
-	if (proto->print_conntrack(s, conntrack))
+	if (l4proto->print_conntrack(s, conntrack))
 		return -ENOSPC;
 
 	if (print_tuple(s, &conntrack->tuplehash[IP_CT_DIR_ORIGINAL].tuple,
-			l3proto, proto))
+			l3proto, l4proto))
 		return -ENOSPC;
 
 	if (seq_print_counters(s, &conntrack->counters[IP_CT_DIR_ORIGINAL]))
@@ -181,7 +181,7 @@ static int ct_seq_show(struct seq_file *
 			return -ENOSPC;
 
 	if (print_tuple(s, &conntrack->tuplehash[IP_CT_DIR_REPLY].tuple,
-			l3proto, proto))
+			l3proto, l4proto))
 		return -ENOSPC;
 
 	if (seq_print_counters(s, &conntrack->counters[IP_CT_DIR_REPLY]))
@@ -655,8 +655,8 @@ EXPORT_SYMBOL(nf_ct_l3proto_try_module_g
 EXPORT_SYMBOL(nf_ct_l3proto_module_put);
 EXPORT_SYMBOL(nf_conntrack_l3proto_register);
 EXPORT_SYMBOL(nf_conntrack_l3proto_unregister);
-EXPORT_SYMBOL(nf_conntrack_protocol_register);
-EXPORT_SYMBOL(nf_conntrack_protocol_unregister);
+EXPORT_SYMBOL(nf_conntrack_l4proto_register);
+EXPORT_SYMBOL(nf_conntrack_l4proto_unregister);
 EXPORT_SYMBOL(nf_ct_invert_tuplepr);
 EXPORT_SYMBOL(nf_conntrack_destroyed);
 EXPORT_SYMBOL(need_conntrack);
@@ -665,9 +665,9 @@ EXPORT_SYMBOL(nf_conntrack_helper_unregi
 EXPORT_SYMBOL(nf_ct_iterate_cleanup);
 EXPORT_SYMBOL(__nf_ct_refresh_acct);
 EXPORT_SYMBOL(nf_ct_protos);
-EXPORT_SYMBOL(__nf_ct_proto_find);
-EXPORT_SYMBOL(nf_ct_proto_find_get);
-EXPORT_SYMBOL(nf_ct_proto_put);
+EXPORT_SYMBOL(__nf_ct_l4proto_find);
+EXPORT_SYMBOL(nf_ct_l4proto_find_get);
+EXPORT_SYMBOL(nf_ct_l4proto_put);
 EXPORT_SYMBOL(nf_ct_l3proto_find_get);
 EXPORT_SYMBOL(nf_ct_l3proto_put);
 EXPORT_SYMBOL(nf_ct_l3protos);
net/netfilter/nf_conntrack_expect.c +1 -1
Index: linux-2.6.19-rc3-git4.quilt/net/netfilter/nf_conntrack_expect.c
===================================================================
@@ -338,7 +338,7 @@ static int exp_seq_show(struct seq_file 
 		   expect->tuple.dst.protonum);
 	print_tuple(s, &expect->tuple,
 		    __nf_ct_l3proto_find(expect->tuple.src.l3num),
-		    __nf_ct_proto_find(expect->tuple.src.l3num,
+		    __nf_ct_l4proto_find(expect->tuple.src.l3num,
 				       expect->tuple.dst.protonum));
 	return seq_putc(s, '\n');
 }
net/netfilter/nf_conntrack_helper.c +1 -1
Index: linux-2.6.19-rc3-git4.quilt/net/netfilter/nf_conntrack_helper.c
===================================================================
@@ -26,7 +26,7 @@
 
 #include <net/netfilter/nf_conntrack.h>
 #include <net/netfilter/nf_conntrack_l3proto.h>
-#include <net/netfilter/nf_conntrack_protocol.h>
+#include <net/netfilter/nf_conntrack_l4proto.h>
 #include <net/netfilter/nf_conntrack_helper.h>
 #include <net/netfilter/nf_conntrack_core.h>
 
net/netfilter/nf_conntrack_ecache.c +1 -1
Index: linux-2.6.19-rc3-git4.quilt/net/netfilter/nf_conntrack_ecache.c
===================================================================
@@ -22,7 +22,7 @@
 
 #include <net/netfilter/nf_conntrack.h>
 #include <net/netfilter/nf_conntrack_l3proto.h>
-#include <net/netfilter/nf_conntrack_protocol.h>
+#include <net/netfilter/nf_conntrack_l4proto.h>
 #include <net/netfilter/nf_conntrack_expect.h>
 #include <net/netfilter/nf_conntrack_helper.h>
 #include <net/netfilter/nf_conntrack_core.h>
net/netfilter/nf_conntrack_proto.c +36 -36

182 lines not on this page · raw message

--
/Martin

#23 lore raw

Re: [PATCH 06/11] Rename struct nf_conntrack_protocol

Quoted 3 lines · Martin Josefsson

Rename 'struct nf_conntrack_protocol' to 'struct nf_conntrack_l4proto' in order to help distinguish it from 'struct nf_conntrack_l3proto'. It gets rather confusing with 'nf_conntrack_protocol'.

Applied, thanks.

Something related I wanted to do for a long time is get rid of the confusing nf_ct_foo vs. nf_conntrack_foo naming.

#24 lore raw

Re: [PATCH 06/11] Rename struct nf_conntrack_protocol

Quoted 6 lines · Patrick McHardy
Quoted 3 lines · Martin Josefsson

Rename 'struct nf_conntrack_protocol' to 'struct nf_conntrack_l4proto' in order to help distinguish it from 'struct nf_conntrack_l3proto'. It gets rather confusing with 'nf_conntrack_protocol'.

Applied, thanks.

Thanks

Quoted 2 lines

Something related I wanted to do for a long time is get rid of the confusing nf_ct_foo vs. nf_conntrack_foo naming.

Same here, it's on my todo-list but rather far down at the moment.

/Martin

#25 lore raw

Re: [PATCH 06/11] Rename struct nf_conntrack_protocol

In reply to Patrick McHardy
Quoted 2 lines · Patrick McHardy

Something related I wanted to do for a long time is get rid of the confusing nf_ct_foo vs. nf_conntrack_foo naming.

Yeees! (Including the 'nf_conn' variation as well.)

Best regards,
Jozsef
-
E-mail : [email protected], [email protected] PGP key : http://www.kfki.hu/~kadlec/pgp_public_key.txt
Address : KFKI Research Institute for Particle and Nuclear Physics

          H-1525 Budapest 114, POB. 49, Hungary
#26 lore raw

Re: [PATCH 06/11] Rename struct nf_conntrack_protocol

Quoted 8 lines · Jozsef Kadlecsik
Quoted 2 lines · Patrick McHardy

Something related I wanted to do for a long time is get rid of the confusing nf_ct_foo vs. nf_conntrack_foo naming.

Yeees! (Including the 'nf_conn' variation as well.)

Yes, that one should go as well :)

#27 lore raw

Re: [PATCH 06/11] Rename struct nf_conntrack_protocol

In reply to Martin Josefsson

Hi,

From: Martin Josefsson <[email protected]>
Date: Wed, 01 Nov 2006 22:08:51 +0100

Quoted 5 lines

Rename 'struct nf_conntrack_protocol' to 'struct nf_conntrack_l4proto' in order to help distinguish it from 'struct nf_conntrack_l3proto'. It gets rather confusing with 'nf_conntrack_protocol'.

After applied this patch, NF_CT_ASSERT(proto); in ct_seq_show() of nf_conntrack_standalone.c should be NF_CT_ASSERT(l4proto);

-- Yasuyuki Kozakai

A message that is not in the archive (sent off-list or not yet received): [email protected]

#29 lore raw

Re: [PATCH 06/11] Rename struct nf_conntrack_protocol

Quoted 2 lines · Yasuyuki KOZAKAI

After applied this patch, NF_CT_ASSERT(proto); in ct_seq_show() of nf_conntrack_standalone.c should be NF_CT_ASSERT(l4proto);

All fixed and folded into the original patches, thanks.

#30 lore raw

PATCH 7/11 More sanity checks in protocol registration/unregistration

In reply to Martin Josefsson

Add some more sanity checks when registering/unregistering l3/l4 protocols.

---
 include/net/netfilter/nf_conntrack_l3proto.h |    2 
 include/net/netfilter/nf_conntrack_l4proto.h |    2 
 net/netfilter/nf_conntrack_core.c            |    2 
 net/netfilter/nf_conntrack_proto.c           |   55 ++++++++++++++++++++++++---
 4 files changed, 52 insertions(+), 9 deletions(-)
include/net/netfilter/nf_conntrack_l3proto.h +1 -1
Index: linux-2.6.19-rc3-git4.quilt/include/net/netfilter/nf_conntrack_l3proto.h
===================================================================
@@ -86,7 +86,7 @@ extern struct nf_conntrack_l3proto *nf_c
 
 /* Protocol registration. */
 extern int nf_conntrack_l3proto_register(struct nf_conntrack_l3proto *proto);
-extern void nf_conntrack_l3proto_unregister(struct nf_conntrack_l3proto *proto);
+extern int nf_conntrack_l3proto_unregister(struct nf_conntrack_l3proto *proto);
 
 extern struct nf_conntrack_l3proto *
 nf_ct_l3proto_find_get(u_int16_t l3proto);
net/netfilter/nf_conntrack_core.c +1 -1
Index: linux-2.6.19-rc3-git4.quilt/net/netfilter/nf_conntrack_core.c
===================================================================
@@ -1199,7 +1199,7 @@ int __init nf_conntrack_init(void)
 
 	/* Don't NEED lock here, but good form anyway. */
 	write_lock_bh(&nf_conntrack_lock);
-        for (i = 0; i < PF_MAX; i++)
+        for (i = 0; i < AF_MAX; i++)
 		nf_ct_l3protos[i] = &nf_conntrack_l3proto_generic;
         write_unlock_bh(&nf_conntrack_lock);
 
include/net/netfilter/nf_conntrack_l4proto.h +1 -1
Index: linux-2.6.19-rc3-git4.quilt/include/net/netfilter/nf_conntrack_l4proto.h
===================================================================
@@ -102,7 +102,7 @@ extern void nf_ct_l4proto_put(struct nf_
 
 /* Protocol registration. */
 extern int nf_conntrack_l4proto_register(struct nf_conntrack_l4proto *proto);
-extern void nf_conntrack_l4proto_unregister(struct nf_conntrack_l4proto *proto);
+extern int nf_conntrack_l4proto_unregister(struct nf_conntrack_l4proto *proto);
 
 /* Generic netlink helpers */
 extern int nf_ct_port_tuple_to_nfattr(struct sk_buff *skb,
net/netfilter/nf_conntrack_proto.c +49 -6

102 lines not on this page · raw message

--
/Martin

#31 lore raw

Re: [PATCH 07/11] More sanity checks in protocol registration/unregistration

Quoted 1 line · Martin Josefsson

Add some more sanity checks when registering/unregistering l3/l4 protocols.

Applied.

#32 lore raw

PATCH 8/11 Remove ASSERT_{READ,WRITE}_LOCK

In reply to Martin Josefsson

Remove the usage of ASSERT_READ_LOCK/ASSERT_WRITE_LOCK in x_tables and nf_conntrack, it didn't do anything, it was just an empty define and it uglified the code.

---
 net/netfilter/nf_conntrack_core.c       |    7 -------
 net/netfilter/nf_conntrack_standalone.c |    4 ----
 2 files changed, 11 deletions(-)
net/netfilter/nf_conntrack_core.c +0 -7
Index: linux-2.6.19-rc3-git4.quilt/net/netfilter/nf_conntrack_core.c
===================================================================
@@ -47,11 +47,6 @@
 #include <linux/netdevice.h>
 #include <linux/socket.h>
 
-/* This rwlock protects the main hash table, protocol/helper/expected
-   registrations, conntrack timers*/
-#define ASSERT_READ_LOCK(x)
-#define ASSERT_WRITE_LOCK(x)
-
 #include <net/netfilter/nf_conntrack.h>
 #include <net/netfilter/nf_conntrack_l3proto.h>
 #include <net/netfilter/nf_conntrack_l4proto.h>
@@ -292,7 +287,6 @@ static void
 clean_from_lists(struct nf_conn *ct)
 {
 	DEBUGP("clean_from_lists(%p)\n", ct);
-	ASSERT_WRITE_LOCK(&nf_conntrack_lock);
 	list_del(&ct->tuplehash[IP_CT_DIR_ORIGINAL].list);
 	list_del(&ct->tuplehash[IP_CT_DIR_REPLY].list);
 
@@ -371,7 +365,6 @@ __nf_conntrack_find(const struct nf_conn
 	struct nf_conntrack_tuple_hash *h;
 	unsigned int hash = hash_conntrack(tuple);
 
-	ASSERT_READ_LOCK(&nf_conntrack_lock);
 	list_for_each_entry(h, &nf_conntrack_hash[hash], list) {
 		if (nf_ct_tuplehash_to_ctrack(h) != ignored_conntrack &&
 		    nf_ct_tuple_equal(tuple, &h->tuple)) {
net/netfilter/nf_conntrack_standalone.c +0 -4
Index: linux-2.6.19-rc3-git4.quilt/net/netfilter/nf_conntrack_standalone.c
===================================================================
@@ -29,9 +29,6 @@
 #include <linux/sysctl.h>
 #endif
 
-#define ASSERT_READ_LOCK(x)
-#define ASSERT_WRITE_LOCK(x)
-
 #include <net/netfilter/nf_conntrack.h>
 #include <net/netfilter/nf_conntrack_core.h>
 #include <net/netfilter/nf_conntrack_l3proto.h>
@@ -137,7 +134,6 @@ static int ct_seq_show(struct seq_file *
 	struct nf_conntrack_l3proto *l3proto;
 	struct nf_conntrack_l4proto *l4proto;
 
-	ASSERT_READ_LOCK(&nf_conntrack_lock);
 	NF_CT_ASSERT(conntrack);
 
 	/* we only want to print DIR_ORIGINAL */

--
/Martin

#33 lore raw

Re: [PATCH 08/11] Remove ASSERT_{READ,WRITE}_LOCK

Quoted 3 lines · Martin Josefsson

Remove the usage of ASSERT_READ_LOCK/ASSERT_WRITE_LOCK in x_tables and nf_conntrack, it didn't do anything, it was just an empty define and it uglified the code.

Fully agreed. I kept them mainly in case something similar would show up for kernel-wide use, but it doesn't looks that way and I stronly believe that readability helps a lot more to catch bugs.

BTW, the patch doesn't touch any x_tables files, did you forgot to commit them?

#34 lore raw

Re: [PATCH 08/11] Remove ASSERT_{READ,WRITE}_LOCK

Quoted 11 lines · Patrick McHardy
Quoted 3 lines · Martin Josefsson

Remove the usage of ASSERT_READ_LOCK/ASSERT_WRITE_LOCK in x_tables and nf_conntrack, it didn't do anything, it was just an empty define and it uglified the code.

Fully agreed. I kept them mainly in case something similar would show up for kernel-wide use, but it doesn't looks that way and I stronly believe that readability helps a lot more to catch bugs.

BTW, the patch doesn't touch any x_tables files, did you forgot to commit them?

I forgot to change the description when I ported the patch to a newer kernel where I think x_tables already had them removed. (my laptop with the kernel trees is suspended at home right now)

/Martin

#35 lore raw

Re: [PATCH 08/11] Remove ASSERT_{READ,WRITE}_LOCK

Quoted 9 lines · Martin Josefsson

On Fri, 3 Nov 2006, Patrick McHardy wrote:
´

Quoted 2 lines

BTW, the patch doesn't touch any x_tables files, did you forgot to commit them?

I forgot to change the description when I ported the patch to a newer kernel where I think x_tables already had them removed. (my laptop with the kernel trees is suspended at home right now)

Turns out x_tables doesn't have any :) But I killed off the remaining ones.

#36 lore raw

PATCH 9/11 Minor __nf_ct_refresh_acct() whitespace cleanup

In reply to Martin Josefsson

Minor whitespace cleanup.

---
 net/netfilter/nf_conntrack_core.c |    8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
net/netfilter/nf_conntrack_core.c +5 -3
Index: linux-2.6.19-rc3-git4.quilt/net/netfilter/nf_conntrack_core.c
===================================================================
@@ -878,9 +878,11 @@ void __nf_ct_refresh_acct(struct nf_conn
 		ct->counters[CTINFO2DIR(ctinfo)].packets++;
 		ct->counters[CTINFO2DIR(ctinfo)].bytes +=
 			skb->len - (unsigned int)(skb->nh.raw - skb->data);
-	if ((ct->counters[CTINFO2DIR(ctinfo)].packets & 0x80000000)
-	    || (ct->counters[CTINFO2DIR(ctinfo)].bytes & 0x80000000))
-		event |= IPCT_COUNTER_FILLING;
+
+		if ((ct->counters[CTINFO2DIR(ctinfo)].packets & 0x80000000)
+		    || (ct->counters[CTINFO2DIR(ctinfo)].bytes & 0x80000000)) {
+			event |= IPCT_COUNTER_FILLING;
+		}
 	}
 #endif
 

--
/Martin

#37 lore raw

PATCH 10/11 Remove unused struct list_head from protocols

In reply to Martin Josefsson

Remove unused struct list_head from struct nf_conntrack_l3proto and nf_conntrack_l4proto as all protocols are kept in arrays, not linked lists.

---
 include/net/netfilter/nf_conntrack_l3proto.h |    3 ---
 include/net/netfilter/nf_conntrack_l4proto.h |    3 ---
 net/ipv4/netfilter/nf_conntrack_proto_icmp.c |    1 -
 3 files changed, 7 deletions(-)
include/net/netfilter/nf_conntrack_l3proto.h +0 -3
Index: linux-2.6.17-git22.quilt/include/net/netfilter/nf_conntrack_l3proto.h
===================================================================
@@ -18,9 +18,6 @@ struct nfattr;
 
 struct nf_conntrack_l3proto
 {
-	/* Next pointer. */
-	struct list_head list;
-
 	/* L3 Protocol Family number. ex) PF_INET */
 	u_int16_t l3proto;
 
include/net/netfilter/nf_conntrack_l4proto.h +0 -3
Index: linux-2.6.17-git22.quilt/include/net/netfilter/nf_conntrack_l4proto.h
===================================================================
@@ -16,9 +16,6 @@ struct nfattr;
 
 struct nf_conntrack_l4proto
 {
-	/* Next pointer. */
-	struct list_head list;
-
 	/* L3 Protocol number. */
 	u_int16_t l3proto;
 
net/ipv4/netfilter/nf_conntrack_proto_icmp.c +0 -1
Index: linux-2.6.17-git22.quilt/net/ipv4/netfilter/nf_conntrack_proto_icmp.c
===================================================================
@@ -323,7 +323,6 @@ static int icmp_nfattr_to_tuple(struct n
 
 struct nf_conntrack_l4proto nf_conntrack_l4proto_icmp =
 {
-	.list			= { NULL, NULL },
 	.l3proto		= PF_INET,
 	.l4proto		= IPPROTO_ICMP,
 	.name			= "icmp",

--
/Martin

#38 lore raw

Re: [PATCH 10/11] Remove unused struct list_head from protocols

Quoted 2 lines · Martin Josefsson

Remove unused struct list_head from struct nf_conntrack_l3proto and nf_conntrack_l4proto as all protocols are kept in arrays, not linked lists.

Applied.

#39 lore raw

PATCH 11/11 Reduce timer updates in __nf_ct_refresh_acct()

In reply to Martin Josefsson

Only update the conntrack timer if there's been at least HZ jiffies since the last update. Reduces the number of del_timer/add_timer cycles from one per packet to one per connection per second (plus once for each state change of a connection)
Should handle timer wraparounds and connection timeout changes.

---
 net/netfilter/nf_conntrack_core.c |   11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
net/netfilter/nf_conntrack_core.c +8 -3
Index: linux-2.6.19-rc3-git4.quilt/net/netfilter/nf_conntrack_core.c
===================================================================
@@ -865,9 +865,14 @@ void __nf_ct_refresh_acct(struct nf_conn
 		ct->timeout.expires = extra_jiffies;
 		event = IPCT_REFRESH;
 	} else {
-		/* Need del_timer for race avoidance (may already be dying). */
-		if (del_timer(&ct->timeout)) {
-			ct->timeout.expires = jiffies + extra_jiffies;
+		unsigned long newtime = jiffies + extra_jiffies;
+
+		/* Only update the timeout if the new timeout is at least
+		   HZ jiffies from the old timeout. Need del_timer for race
+		   avoidance (may already be dying). */
+		if (newtime - ct->timeout.expires >= HZ
+		    && del_timer(&ct->timeout)) {
+			ct->timeout.expires = newtime;
 			add_timer(&ct->timeout);
 			event = IPCT_REFRESH;
 		}

--
/Martin

#40 lore raw

Re: [PATCH 11/11] Reduce timer updates in __nf_ct_refresh_acct()

Quoted 24 lines · Martin Josefsson

Only update the conntrack timer if there's been at least HZ jiffies since the last update. Reduces the number of del_timer/add_timer cycles from one per packet to one per connection per second (plus once for each state change of a connection)
Should handle timer wraparounds and connection timeout changes.

---
 net/netfilter/nf_conntrack_core.c |   11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

Index: linux-2.6.19-rc3-git4.quilt/net/netfilter/nf_conntrack_core.c
===================================================================

net/netfilter/nf_conntrack_core.c +1 -3
@@ -865,9 +865,14 @@ void __nf_ct_refresh_acct(struct nf_conn
 		ct->timeout.expires = extra_jiffies;
 		event = IPCT_REFRESH;
 	} else {
-		/* Need del_timer for race avoidance (may already be dying). */
-		if (del_timer(&ct->timeout)) {
-			ct->timeout.expires = jiffies + extra_jiffies;
+		unsigned long newtime = jiffies + extra_jiffies;

net/netfilter/nf_conntrack_core.c void __nf_ct_refresh_acct(struct nf_conn · line 878

Quoted 10 lines
net/netfilter/nf_conntrack_core.c +7 -0
+
+		/* Only update the timeout if the new timeout is at least
+		   HZ jiffies from the old timeout. Need del_timer for race
+		   avoidance (may already be dying). */
+		if (newtime - ct->timeout.expires >= HZ
+		    && del_timer(&ct->timeout)) {
+			ct->timeout.expires = newtime;
 			add_timer(&ct->timeout);
 			event = IPCT_REFRESH;
 		}

Applied, thanks. BTW, the "race avoidance" strikes me as racy, there are multiple locations where we simply do

if (del_timer(...))
ct->timeout.function(...)

and expect the conntrack to be either destroyed by the ct->timeout.function call or by the expiring timer. But without taking ip_conntrack_lock we could have:

CPU1 (refresh) CPU2

if (del_timer) [success]

				if (del_timer) [no success]
	add_timer()

which means the conntrack won't be destroyed. Did I miss something?

#41 lore raw

Re: [PATCH 11/11] Reduce timer updates in __nf_ct_refresh_acct()

Quoted 31 lines · Patrick McHardy
Quoted 10 lines
net/netfilter/nf_conntrack_core.c +1 -3
@@ -865,9 +865,14 @@ void __nf_ct_refresh_acct(struct nf_conn
 		ct->timeout.expires = extra_jiffies;
 		event = IPCT_REFRESH;
 	} else {
-		/* Need del_timer for race avoidance (may already be dying). */
-		if (del_timer(&ct->timeout)) {
-			ct->timeout.expires = jiffies + extra_jiffies;
+		unsigned long newtime = jiffies + extra_jiffies;

net/netfilter/nf_conntrack_core.c void __nf_ct_refresh_acct(struct nf_conn · line 878

Quoted 10 lines
net/netfilter/nf_conntrack_core.c +7 -0
+
+		/* Only update the timeout if the new timeout is at least
+		   HZ jiffies from the old timeout. Need del_timer for race
+		   avoidance (may already be dying). */
+		if (newtime - ct->timeout.expires >= HZ
+		    && del_timer(&ct->timeout)) {
+			ct->timeout.expires = newtime;
 			add_timer(&ct->timeout);
 			event = IPCT_REFRESH;
 		}

Applied, thanks. BTW, the "race avoidance" strikes me as racy, there are multiple locations where we simply do

if (del_timer(...))
ct->timeout.function(...)

and expect the conntrack to be either destroyed by the ct->timeout.function call or by the expiring timer. But without taking ip_conntrack_lock we could have:

Quoted 8 lines

CPU1 (refresh) CPU2

if (del_timer) [success]

				if (del_timer) [no success]
	add_timer()

which means the conntrack won't be destroyed. Did I miss something?

You are absolutely correct. I discussed this with Rusty some time ago and he thought it was fine since we mostly aim for "best effort", but I don't like it either. I have a patch that adds another variant of mod_timer() that doesn't activate an inactive timer, and use this instead of del_timer()/add_timer(). This avoids this race and reduces the number of locks taken. I'll send this patch to you after this weekend I think.

/Martin

#42 lore raw

Re: [PATCH 11/11] Reduce timer updates in __nf_ct_refresh_acct()

Quoted 22 lines · Martin Josefsson
Quoted 10 lines · Patrick McHardy

BTW, the "race avoidance" strikes me as racy,
there are multiple locations where we simply do

if (del_timer(...))
ct->timeout.function(...)

and expect the conntrack to be either destroyed by the ct->timeout.function call or by the expiring timer. But without taking ip_conntrack_lock we could have:

Quoted 8 lines

CPU1 (refresh) CPU2

if (del_timer) [success]

				if (del_timer) [no success]
	add_timer()

which means the conntrack won't be destroyed. Did I miss something?

Quoted 6 lines

You are absolutely correct. I discussed this with Rusty some time ago and he thought it was fine since we mostly aim for "best effort", but I don't like it either. I have a patch that adds another variant of mod_timer() that doesn't activate an inactive timer, and use this instead of del_timer()/add_timer(). This avoids this race and reduces the number of locks taken. I'll send this patch to you after this weekend I think.

That sounds like a good way to fix it. I think I saw that patch on the link you sent me some time ago, IIRC it touches core kernel code, so you should probably send the timer part seperately to lkml.

#43 lore raw

Re: [PATCH 11/11] Reduce timer updates in __nf_ct_refresh_acct()

Quoted 11 lines · Patrick McHardy
Quoted 6 lines

You are absolutely correct. I discussed this with Rusty some time ago and he thought it was fine since we mostly aim for "best effort", but I don't like it either. I have a patch that adds another variant of mod_timer() that doesn't activate an inactive timer, and use this instead of del_timer()/add_timer(). This avoids this race and reduces the number of locks taken. I'll send this patch to you after this weekend I think.

That sounds like a good way to fix it. I think I saw that patch on the link you sent me some time ago, IIRC it touches core kernel code, so you should probably send the timer part seperately to lkml.

Yes that's why I havn't submitted it yet, hopefully they won't scream too loudly about the changes.

/Martin

#44 lore raw

Re: [PATCH 11/11] Reduce timer updates in __nf_ct_refresh_acct()

Quoted 9 lines · Martin Josefsson
Quoted 3 lines · Patrick McHardy

That sounds like a good way to fix it. I think I saw that patch on the link you sent me some time ago, IIRC it touches core kernel code, so you should probably send the timer part seperately to lkml.

Yes that's why I havn't submitted it yet, hopefully they won't scream too loudly about the changes.

I think it makes sense in cases like conntrack to synchronize by the timers, so its a good addition IMO.

#45 lore raw

Re: [PATCH 11/11] Reduce timer updates in __nf_ct_refresh_acct()

Quoted 8 lines · Patrick McHardy
Quoted 7 lines · Martin Josefsson
Quoted 3 lines · Patrick McHardy

That sounds like a good way to fix it. I think I saw that patch on the link you sent me some time ago, IIRC it touches core kernel code, so you should probably send the timer part seperately to lkml.

Quoted 5 lines
Quoted 2 lines

Yes that's why I havn't submitted it yet, hopefully they won't scream too loudly about the changes.

I think it makes sense in cases like conntrack to synchronize by the timers, so its a good addition IMO.

Yes, in conntrack's case there's no need to take additional locks when we already try to rely on the timers for synchronization, better make that actually work and remove the extra locking. It goes in the same direction as the work I'm doing, remove atomic instructions and locks as much as possible.

/Martin