Skip to contentSkip to conversation

nf_conntrack tree

DISCUSSION Patrick McHardy 4 participants 14 messages Mar 16, 2005 – Mar 22, 2005 1 message not in the archive

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

I'm working on getting nf_conntrack ready for submission. To make it easier for people to participate, I've exported my tree through bitkeeper and as plain patch. It currently contains nf_conntrack as found in pomng plus a couple of ported ip_conntrack fixes:

bk://numenor.coreworks.de/nf-2.6-nfct
http://numenor.coreworks.de/~kaber

The tree and the diff will be kept up-to-date when changes are made.

In my opinion the most important issue at this time is making ip_conntrack matches and targets work properly with nf_conntrack and adding their IPv6 equivalents. Before doing the IPv6 part, I would like to get sorted out if we can share the IPv4 matches/targets between ip_conntrack and nf_conntrack.

Regards
Patrick

#1 lore raw

Hi, Patrick,

From: Patrick McHardy <[email protected]>
Date: Wed, 16 Mar 2005 01:35:32 +0100

Quoted 9 lines

I'm working on getting nf_conntrack ready for submission. To make it easier for people to participate, I've exported my tree through bitkeeper and as plain patch. It currently contains nf_conntrack as found in pomng plus a couple of ported ip_conntrack fixes:

bk://numenor.coreworks.de/nf-2.6-nfct
http://numenor.coreworks.de/~kaber

The tree and the diff will be kept up-to-date when changes are made.

Thanks. I'll look that.

Quoted 5 lines

In my opinion the most important issue at this time is making ip_conntrack matches and targets work properly with nf_conntrack and adding their IPv6 equivalents. Before doing the IPv6 part, I would like to get sorted out if we can share the IPv4 matches/targets between ip_conntrack and nf_conntrack.

There are issues to do this.
1. conflicting symbols when including ip_conntrack.h and nf_conntrack. -> easy work. We can change symbols in nf_conntrack_*.h.

2. I would not like to change UI. If ip_conntrack isn't loaded when these matches/targets are loaded, I want kernel to load ip_conntrack automatically. I suggests changes in init() as following.

int ret = -1;

if (get_symbols(need_ip_conntrack) != NULL) {
ret = ip_register_match(match_func_with_ip_conntrack);

} else if (get_symbols(need_nf_conntrack) != NULL) {
ret = ip_register_match(match_func_with_nf_conntrack);
} else
return -1;

return ret;

I don't know this usage of get_symbols() is right or not. If right, ip_conntrack will be loaded automatically in the case that ip_conntrack and nf_conntrack are not loaded.
If either of them is loaded, it will be used.

3. The symbol "ip_conntrack_untracked" which depends on ip_conntrack. state, conntrack, NOTRACK use this symbol. How about defining "void *nf_ct_untracked" in net/core/netfilter.c and set &ip_conntrack_untracked.general/&nf_conntrack_untracked.general to it when initializing ip_conntrack/nf_conntrack ?

Regards,

-----------------------------------------------------------------
Yasuyuki KOZAKAI @ USAGI Project <[email protected]>

#2 lore raw
Quoted 5 lines · Yasuyuki KOZAKAI

3. The symbol "ip_conntrack_untracked" which depends on ip_conntrack. state, conntrack, NOTRACK use this symbol. How about defining "void *nf_ct_untracked" in net/core/netfilter.c and set &ip_conntrack_untracked.general/&nf_conntrack_untracked.general to it when initializing ip_conntrack/nf_conntrack ?

Something I have in mind. I think that we could use one of the bits of nfcache explicitely mark invalid connections. If we get an invalid packet, conntrack can set the NFC_INVALID bit. That way we interpret a NULL pointer in skb->nfct as a untracked connection and kill that fake conntrack.

--
Pablo

#3 lore raw

Hi,

Quoted 7 lines · Pablo Neira
Quoted 5 lines · Yasuyuki KOZAKAI

3. The symbol "ip_conntrack_untracked" which depends on ip_conntrack. state, conntrack, NOTRACK use this symbol. How about defining "void *nf_ct_untracked" in net/core/netfilter.c and set &ip_conntrack_untracked.general/&nf_conntrack_untracked.general to it when initializing ip_conntrack/nf_conntrack ?

Quoted 5 lines

Something I have in mind. I think that we could use one of the bits of nfcache explicitely mark invalid connections. If we get an invalid packet, conntrack can set the NFC_INVALID bit. That way we interpret a NULL pointer in skb->nfct as a untracked connection and kill that fake conntrack.

When working on a conntrack-friendly TARPIT target, I added "general" glue function support in order to avoid unnecessary cross-dependency. Have a look at the attached patch.

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
include/linux/netfilter.h +7 -1
diff -urN --exclude-from=/usr/src/diff.exclude linux-2.6.9-orig/include/linux/netfilter.h linux-2.6.9-TARPIT/include/linux/netfilter.h
@@ -178,12 +178,18 @@
 ip6t_find_target_lock(const char *name, int *error, struct semaphore *mutex);
 extern inline struct arpt_target *
 arpt_find_target_lock(const char *name, int *error, struct semaphore *mutex);
-extern void (*ip_ct_attach)(struct sk_buff *, struct sk_buff *);
 
 #ifdef CONFIG_NETFILTER_DEBUG
 extern void nf_dump_skb(int pf, struct sk_buff *skb);
 #endif
 
+/* Glue functions to avoid unnecessary dependencies */
+struct nf_ip_glue_functions {
+       void (*ip_ct_attach)(struct sk_buff *, struct sk_buff *);
+       void (*ip_ct_notrack)(struct sk_buff *);
+};
+extern struct nf_ip_glue_functions nf_ip_glue;
+
 /* FIXME: Before cache is ever used, this must be implemented for real. */
 extern void nf_invalidate_cache(int pf);
 
net/core/netfilter.c +2 -7
diff -urN --exclude-from=/usr/src/diff.exclude linux-2.6.9-orig/net/core/netfilter.c linux-2.6.9-TARPIT/net/core/netfilter.c
@@ -48,6 +48,7 @@
 struct list_head nf_hooks[NPROTO][NF_MAX_HOOKS];
 static LIST_HEAD(nf_sockopts);
 static spinlock_t nf_hook_lock = SPIN_LOCK_UNLOCKED;
+struct nf_ip_glue_functions nf_ip_glue = {};
 
 /* 
  * A queue handler may be registered for each protocol.  Each is protected by
@@ -802,12 +803,6 @@
 EXPORT_SYMBOL(nf_log_unregister);
 EXPORT_SYMBOL(nf_log_packet);
 
-/* This does not belong here, but ipt_REJECT needs it if connection
-   tracking in use: without this, connection may not be in hash table,
-   and hence manufactured ICMP or RST packets will not be associated
-   with it. */
-void (*ip_ct_attach)(struct sk_buff *, struct sk_buff *);
-
 void __init netfilter_init(void)
 {
 	int i, h;
@@ -818,7 +813,7 @@
 	}
 }
 
-EXPORT_SYMBOL(ip_ct_attach);
+EXPORT_SYMBOL(nf_ip_glue);
 EXPORT_SYMBOL(ip_route_me_harder);
 EXPORT_SYMBOL(nf_getsockopt);
 EXPORT_SYMBOL(nf_hook_slow);
net/ipv4/netfilter/Kconfig +19 -0
diff -urN --exclude-from=/usr/src/diff.exclude linux-2.6.9-orig/net/ipv4/netfilter/Kconfig linux-2.6.9-TARPIT/net/ipv4/netfilter/Kconfig
@@ -412,6 +412,25 @@
 
 	  To compile it as a module, choose M here.  If unsure, say N.
 
+config IP_NF_TARGET_TARPIT
+	tristate 'TARPIT target support'
+	depends on IP_NF_FILTER
+	help
+	  Adds a TARPIT target to iptables, which captures and holds
+	  incoming TCP connections using no local per-connection resources.
+	  Connections are accepted, but immediately switched to the persist
+	  state (0 byte window), in which the remote side stops sending data
+	  and asks to continue every 60-240 seconds.  Attempts to close the
+	  connection are ignored, forcing the remote side to time out the
+	  connection in 12-24 minutes.
+	
+	  This offers similar functionality to LaBrea
+	  <http://www.hackbusters.net/LaBrea/> but doesn't require dedicated
+	  hardware or IPs.  Any TCP port that you would normally DROP or 
+	  REJECT can instead become a TARPIT.
+	  
+	  To compile it as a module, choose M here.  If unsure, say N.
+
 # NAT + specific targets
 config IP_NF_NAT
 	tristate "Full NAT"
net/ipv4/netfilter/Makefile +1 -0
diff -urN --exclude-from=/usr/src/diff.exclude linux-2.6.9-orig/net/ipv4/netfilter/Makefile linux-2.6.9-TARPIT/net/ipv4/netfilter/Makefile
@@ -70,6 +70,7 @@
 
 # targets
 obj-$(CONFIG_IP_NF_TARGET_REJECT) += ipt_REJECT.o
+obj-$(CONFIG_IP_NF_TARGET_TARPIT) += ipt_TARPIT.o
 obj-$(CONFIG_IP_NF_TARGET_TOS) += ipt_TOS.o
 obj-$(CONFIG_IP_NF_TARGET_ECN) += ipt_ECN.o
 obj-$(CONFIG_IP_NF_TARGET_DSCP) += ipt_DSCP.o
net/ipv4/netfilter/ip_conntrack_core.c +17 -3
diff -urN --exclude-from=/usr/src/diff.exclude linux-2.6.9-orig/net/ipv4/netfilter/ip_conntrack_core.c linux-2.6.9-TARPIT/net/ipv4/netfilter/ip_conntrack_core.c
@@ -1176,6 +1176,18 @@
 	nf_conntrack_get(nskb->nfct);
 }
 
+/* Used by the NOTRACK and TARPIT targets. */
+static void ip_conntrack_notrack(struct sk_buff *skb)
+{
+	/* Attach fake conntrack entry. 
+	   If there is a real ct entry correspondig to this packet, 
+	   it'll hang aroun till timing out. We don't deal with it
+	   for performance reasons. JK */
+	skb->nfct = &ip_conntrack_untracked.ct_general;
+	skb->nfctinfo = IP_CT_NEW;
+	nf_conntrack_get(skb->nfct);
+}
+
 static inline int
 do_kill(const struct ip_conntrack_tuple_hash *i,
 	int (*kill)(const struct ip_conntrack *i, void *data),
@@ -1290,7 +1302,8 @@
    supposed to kill the mall. */
 void ip_conntrack_cleanup(void)
 {
-	ip_ct_attach = NULL;
+	nf_ip_glue.ip_ct_attach = NULL;
+	nf_ip_glue.ip_ct_notrack = NULL;
 	/* This makes sure all current packets have passed through
            netfilter framework.  Roll on, two-stage module
            delete... */
@@ -1379,8 +1392,9 @@
 	for (i = 0; i < ip_conntrack_htable_size; i++)
 		INIT_LIST_HEAD(&ip_conntrack_hash[i]);
 
-	/* For use by ipt_REJECT */
-	ip_ct_attach = ip_conntrack_attach;
+	/* Set glue functions */
+	nf_ip_glue.ip_ct_attach = ip_conntrack_attach;
+	nf_ip_glue.ip_ct_notrack = ip_conntrack_notrack;
 
 	/* Set up fake conntrack:
 	    - to never be deleted, not in any hashes */
net/ipv4/netfilter/ipt_NOTRACK.c +7 -8
diff -urN --exclude-from=/usr/src/diff.exclude linux-2.6.9-orig/net/ipv4/netfilter/ipt_NOTRACK.c linux-2.6.9-TARPIT/net/ipv4/netfilter/ipt_NOTRACK.c
@@ -15,18 +15,17 @@
        const void *targinfo,
        void *userinfo)
 {
+	void (*notrack)(struct sk_buff *);
+	
 	/* Previously seen (loopback)? Ignore. */
 	if ((*pskb)->nfct != NULL)
 		return IPT_CONTINUE;
 
-	/* Attach fake conntrack entry. 
-	   If there is a real ct entry correspondig to this packet, 
-	   it'll hang aroun till timing out. We don't deal with it
-	   for performance reasons. JK */
-	(*pskb)->nfct = &ip_conntrack_untracked.ct_general;
-	(*pskb)->nfctinfo = IP_CT_NEW;
-	nf_conntrack_get((*pskb)->nfct);
-
+	/* Avoid module unload race with nf_ip_glue being NULLed out */
+	if ((notrack = nf_ip_glue.ip_ct_notrack) != NULL) {
+		mb(); /* Just to be sure: must be read before executing this */
+		notrack(*pskb);
+	}
 	return IPT_CONTINUE;
 }
 
net/ipv4/netfilter/ipt_REJECT.c +2 -2
diff -urN --exclude-from=/usr/src/diff.exclude linux-2.6.9-orig/net/ipv4/netfilter/ipt_REJECT.c linux-2.6.9-TARPIT/net/ipv4/netfilter/ipt_REJECT.c
@@ -45,8 +45,8 @@
 {
 	void (*attach)(struct sk_buff *, struct sk_buff *);
 
-	/* Avoid module unload race with ip_ct_attach being NULLed out */
-	if (skb->nfct && (attach = ip_ct_attach) != NULL) {
+	/* Avoid module unload race with nf_ip_glue being NULLed out */
+	if (skb->nfct && (attach = nf_ip_glue.ip_ct_attach) != NULL) {
 		mb(); /* Just to be sure: must be read before executing this */
 		attach(new_skb, skb);
 	}
net/ipv4/netfilter/ipt_TARPIT.c +338 -0

338 lines not on this page · raw message

#4 lore raw

Hi, Pablo and Jozsef,

Quoted 9 lines · Pablo Neira
Quoted 8 lines
Quoted 5 lines · Yasuyuki KOZAKAI

3. The symbol "ip_conntrack_untracked" which depends on ip_conntrack. state, conntrack, NOTRACK use this symbol. How about defining "void *nf_ct_untracked" in net/core/netfilter.c and set &ip_conntrack_untracked.general/&nf_conntrack_untracked.general to it when initializing ip_conntrack/nf_conntrack ?

Quoted 5 lines
Quoted 5 lines

Something I have in mind. I think that we could use one of the bits of nfcache explicitely mark invalid connections. If we get an invalid packet, conntrack can set the NFC_INVALID bit. That way we interpret a NULL pointer in skb->nfct as a untracked connection and kill that fake conntrack.

If we kill the fake conntrack, ip_conntrack cannot decide the skb should be tracked or not.

But using nfcache sounds good. Instead of NFC_INVALID, how about NFC_NOTRACK ? If NFC_NOTRACK is set, ip_conntrack can figure out that's untracked skb. And matches can distinguish between invalid skb and untracked one by checking nfcache.

From: Jozsef Kadlecsik <[email protected]>
Date: Wed, 16 Mar 2005 11:13:57 +0100 (CET)

Quoted 3 lines

When working on a conntrack-friendly TARPIT target, I added "general" glue function support in order to avoid unnecessary cross-dependency. Have a look at the attached patch.

That's useful for only NOTRACK target.
The symbol ip_conntrack_untracked remains in state and conntrack matches.

So I think that using nfcache flag is better in the current.

Regards,

-----------------------------------------------------------------
Yasuyuki KOZAKAI @ USAGI Project <[email protected]>

#6 lore raw
In reply to Yasuyuki KOZAKAI
Quoted 10 lines · Yasuyuki KOZAKAI
Quoted 5 lines

In my opinion the most important issue at this time is making ip_conntrack matches and targets work properly with nf_conntrack and adding their IPv6 equivalents. Before doing the IPv6 part, I would like to get sorted out if we can share the IPv4 matches/targets between ip_conntrack and nf_conntrack.

There are issues to do this.

	1. conflicting symbols when including ip_conntrack.h and nf_conntrack.
	   -> easy work. We can change symbols in nf_conntrack_*.h.

Yes. We could also move users of the ip_conntrack.h symbols over to the nf_conntrack.h symbols. This would allow to kill a lot of them.

Quoted 12 lines
	2. I would not like to change UI. If ip_conntrack isn't loaded when
	   these matches/targets are loaded, I want kernel to load ip_conntrack
	   automatically. I suggests changes in init() as following.

		int ret = -1;	   

		if (get_symbols(need_ip_conntrack) != NULL) {
			ret = ip_register_match(match_func_with_ip_conntrack);

		} else if (get_symbols(need_nf_conntrack) != NULL) {
			ret = ip_register_match(match_func_with_nf_conntrack);
		} else
Quoted 8 lines
			return -1;

		return ret;

	  I don't know this usage of get_symbols() is right or not.
	  If right, ip_conntrack will be loaded automatically in the case that
	  ip_conntrack and nf_conntrack are not loaded.
	  If either of them is loaded, it will be used.

Not sure if it works, but that would be a possibility.

Quoted 5 lines

3. The symbol "ip_conntrack_untracked" which depends on ip_conntrack. state, conntrack, NOTRACK use this symbol. How about defining "void *nf_ct_untracked" in net/core/netfilter.c and set &ip_conntrack_untracked.general/&nf_conntrack_untracked.general to it when initializing ip_conntrack/nf_conntrack ?

I was thinking about creating a struct nf_conntrack_common that is used in both struct ip_conntrack and nf_conntrack for things like mark, flags, ... We could then simply use a status flag for untracked. It would also help connmark/CONNMARK and a couple of others, the main problem are the tuples (needed by ipt_conntrack), the ip_conntrack tuples don't match the nf_conntrack tuples.

Regards
Patrick

#5 lore raw
In reply to Jozsef Kadlecsik
Quoted 3 lines · Jozsef Kadlecsik

When working on a conntrack-friendly TARPIT target, I added "general" glue function support in order to avoid unnecessary cross-dependency. Have a look at the attached patch.

I thought about this. I thought it would require too many glue functions that are mostly only have a single user, but actually it doesn't look so bad. ipt_conntrack (worst one AFAICT) should be ok with a struct nf_conntrack_common + two glue functions:

tuple_proto_cmp
tuple_addr_cmp(direction, src/dst)

Seems to be the best idea so far. We could also get rid of some of the uglies in net/core/netfilter.c.

Regards
Patrick

#8 lore raw
In reply to a message not in the archive

Hi,

From: Yasuyuki KOZAKAI <[email protected]>
Date: Wed, 16 Mar 2005 15:48:33 +0900 (JST)

Quoted 12 lines
	2. I would not like to change UI. If ip_conntrack isn't loaded when
	   these matches/targets are loaded, I want kernel to load ip_conntrack
	   automatically. I suggests changes in init() as following.

		int ret = -1;	   

		if (get_symbols(need_ip_conntrack) != NULL) {
			ret = ip_register_match(match_func_with_ip_conntrack);

		} else if (get_symbols(need_nf_conntrack) != NULL) {
			ret = ip_register_match(match_func_with_nf_conntrack);
		} else
Quoted 8 lines
			return -1;

		return ret;

	  I don't know this usage of get_symbols() is right or not.
	  If right, ip_conntrack will be loaded automatically in the case that
	  ip_conntrack and nf_conntrack are not loaded.
	  If either of them is loaded, it will be used.

Oh, this is bad code. What I really want to do is following. Anyway, this issue would be resolved.

static struct ipt_match helper_match = {
.name = "helper",
- .match = &match,
.checkentry = &check,
.me = THIS_MODULE,
};

static int __init init(void)
{
- need_ip_conntrack();
+ if (!request_module("ip_conntrack"))
+ helper_match.match = &ip_match;
+ } else if (!request_module("nf_conntrack"))
+ helper_match.match = &nf_match;
+ } else
+ return -1;
+
return ipt_register_match(&helper_match);
}

-----------------------------------------------------------------
Yasuyuki KOZAKAI @ USAGI Project <[email protected]>

#9 lore raw
Quoted 12 lines · Yasuyuki KOZAKAI

Oh, this is bad code. What I really want to do is following. Anyway, this issue would be resolved.

static struct ipt_match helper_match = {

(quoted diff) +0 -1
 	.name		= "helper",
-	.match		= &match,
 	.checkentry	= &check,
 	.me		= THIS_MODULE,
 };
 
 static int __init init(void)
 {

Review

Quoted 10 lines
(quoted diff) +7 -1
-	need_ip_conntrack();
+	if (!request_module("ip_conntrack"))
+		helper_match.match = &ip_match;
+	} else if (!request_module("nf_conntrack"))
+		helper_match.match = &nf_match;
+	} else
+		return -1;
+
 	return ipt_register_match(&helper_match);
 }

That won't work when nf_conntrack is already loaded. Do you think it is necessary to allow people to build both as modules? It would be easier to just force them to choose, and would probably result in more people actually using it since ip_conntrack wouldn't be used by default anymore.

Regards
Patrick

#10 lore raw

From: Patrick McHardy <[email protected]>
Date: Wed, 16 Mar 2005 20:32:54 +0100

Quoted 12 lines
Quoted 10 lines · Yasuyuki KOZAKAI

Oh, this is bad code. What I really want to do is following. Anyway, this issue would be resolved.

static struct ipt_match helper_match = {

(quoted diff) +0 -1
 	.name		= "helper",
-	.match		= &match,
 	.checkentry	= &check,
 	.me		= THIS_MODULE,
 };
Quoted 15 lines

Review

Quoted 12 lines

static int __init init(void)
{

(quoted diff) +7 -1
-	need_ip_conntrack();
+	if (!request_module("ip_conntrack"))
+		helper_match.match = &ip_match;
+	} else if (!request_module("nf_conntrack"))
+		helper_match.match = &nf_match;
+	} else
+		return -1;
+
 	return ipt_register_match(&helper_match);
 }

That won't work when nf_conntrack is already loaded. Do you think it is necessary to allow people to build both as modules?

You're right. #ifdef or other staff is needed.

Quoted 4 lines

It would
be easier to just force them to choose, and would probably result in more people actually using it since ip_conntrack wouldn't be used by default anymore.

But I want this flexibility if possible so that we can test matches/targets with ip_conntrack/nf_conntrack without recompiling.

-----------------------------------------------------------------
Yasuyuki KOZAKAI @ USAGI Project <[email protected]>

#11 lore raw
Quoted 5 lines · Yasuyuki KOZAKAI
Quoted 2 lines

That won't work when nf_conntrack is already loaded. Do you think it is necessary to allow people to build both as modules?

You're right. #ifdef or other staff is needed.

If we go the way Joszef propsed, namely having something like a global struct nf_ct_ops *, we can simply add a flag to it which specifies which conntrack is usec.

Quoted 7 lines
Quoted 4 lines

It would
be easier to just force them to choose, and would probably result in more people actually using it since ip_conntrack wouldn't be used by default anymore.

But I want this flexibility if possible so that we can test matches/targets with ip_conntrack/nf_conntrack without recompiling.

I see that it would be useful for testing, but I fear that it will result in additional complexity and bugs with little gain for users. Let's see how it works out, if it really does cause a lot of extra complexity it would prefer to only allow one at a time.

Regards
Patrick

#12 lore raw

Hi, Patrick,

OK, I agree introducing nf_ct_ops.

But in the current, it's not acceptable to introduce nf_conntrack_common as you said in other mail. I think it needs many changes to ip_conntrack and ip_nat, it may be difficult to change nf_conn structure
(e.g. optimization), and it will confuse us - What we unify is ?

My suggestion is pulling out common definitions of enum and flags to some common header files, and making {ip,nf}_conntrack*.h include them. No change to ip_conntrack_*.c is necessary.

Regards,
-----------------------------------------------------------------
Yasuyuki KOZAKAI @ USAGI Project <[email protected]>

From: Patrick McHardy <[email protected]>
Date: Wed, 16 Mar 2005 21:04:06 +0100

Quoted 27 lines
Quoted 5 lines · Yasuyuki KOZAKAI
Quoted 2 lines

That won't work when nf_conntrack is already loaded. Do you think it is necessary to allow people to build both as modules?

You're right. #ifdef or other staff is needed.

If we go the way Joszef propsed, namely having something like a global struct nf_ct_ops *, we can simply add a flag to it which specifies which conntrack is usec.

Quoted 7 lines
Quoted 4 lines

It would
be easier to just force them to choose, and would probably result in more people actually using it since ip_conntrack wouldn't be used by default anymore.

But I want this flexibility if possible so that we can test matches/targets with ip_conntrack/nf_conntrack without recompiling.

I see that it would be useful for testing, but I fear that it will result in additional complexity and bugs with little gain for users. Let's see how it works out, if it really does cause a lot of extra complexity it would prefer to only allow one at a time.

Regards
Patrick

#13 lore raw
Quoted 8 lines · Yasuyuki KOZAKAI

Hi, Patrick,

OK, I agree introducing nf_ct_ops.

But in the current, it's not acceptable to introduce nf_conntrack_common as you said in other mail. I think it needs many changes to ip_conntrack and ip_nat, it may be difficult to change nf_conn structure
(e.g. optimization), and it will confuse us - What we unify is ?

We're unifying things common to ip_conntrack and nf_conntrack, like mark, status, ... in order to keep the number of accessor functions in nf_ct_ops to a minimum.

Quoted 3 lines

My suggestion is pulling out common definitions of enum and flags to some common header files, and making {ip,nf}_conntrack*.h include them. No change to ip_conntrack_*.c is necessary.

Yes, that is one part. But some matches/targets need to get some information from the conntrack. I've made a list of what is needed, so we can talk in more concrete terms:

ipt_state:
- recognize untracked

ipt_helper:
- ct->master->helper->name

ipt_conntrack:
- recognize untracked
- tuples
- status
- expires

ipt_connmark/IPT_CONNMARK:
- mark

Creating a struct nf_conntrack_common should be ok for untracked, status, expires, mark and master->helper->name. The tuples can't be handled this way, for them we need nf_ct_ops.

Regards
Patrick

#14 lore raw

From: Patrick McHardy <[email protected]>
Date: Sun, 20 Mar 2005 17:42:57 +0100

Quoted 8 lines
Quoted 4 lines

But in the current, it's not acceptable to introduce nf_conntrack_common as you said in other mail. I think it needs many changes to ip_conntrack and ip_nat, it may be difficult to change nf_conn structure
(e.g. optimization), and it will confuse us - What we unify is ?

We're unifying things common to ip_conntrack and nf_conntrack, like mark, status, ... in order to keep the number of accessor functions in nf_ct_ops to a minimum.

It's very poor joke. Please don't mind. :)

At first, let me clarify. I imagine that your suggestion is changing definition of "struct ip_connntrack" as follow.

struct ip_conntrack {
	...
	struct nf_conntrack_common common;
	...
}

This would change many parts of ip_conntrack and we'd have to rework on this issue when we want to change some member of "struct nf_conn". I think duplicating matches/targets is better than this way.

Or what you suggest is implementing glue function which gathers the common parameters from ip_conntrack/nf_conn and put them in nf_conntrack_common structure ? This introduces a few overheads, but acceptable for me.

Quoted 3 lines

Yes, that is one part. But some matches/targets need to get some information from the conntrack. I've made a list of what is needed, so we can talk in more concrete terms:

OK,

Quoted 6 lines

ipt_state:
- recognize untracked

ipt_helper:
- ct->master->helper->name

Quoted 8 lines

ipt_conntrack:
- recognize untracked
- tuples
- status
- expires

ipt_connmark/IPT_CONNMARK:
- mark

We have to be careful about "mark". Users may enable NF_IP_CONNTRACK_MARK and disable NF_CONNTRACK_MARK.

Quoted 3 lines

Creating a struct nf_conntrack_common should be ok for untracked, status, expires, mark and master->helper->name. The tuples can't be handled this way, for them we need nf_ct_ops.

Regards,

-----------------------------------------------------------------
Yasuyuki KOZAKAI @ USAGI Project <[email protected]>