Skip to contentSkip to conversation

Made ct_sync running with 2.6.15.4...

PATCH Maximilian Wilhelm 2 participants 4 messages Mar 11, 2006 – Apr 4, 2006

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

Hi!

I'm building a firewall solution for my departement and found ct_sync at [42] while searching for a statefull failover solution.

I saw that the patches and the module code were written for kernel version 2.6.10 and experienced rather big trouble patching kernel version 2.6.15.4 :-/

So I began to update the files and got a running version of ct_sync which is now running some days on my test firewalls and is working well after some failovers.
The only thing I'm worrying about were many ct entries I produced by nmap -sP <net behing the firewall>
which did not vanish after 10++ hours. I had to reboot to get rid of the connections.

What I did:

1. branches/netfilter-ha/linux-2.6/patches
* make patches fit to 2.6.15.4 by "Index"-lines
* removed hunks/patches which are allready in vanilla kernel
* made the rest of the patches fit to newest vanilla kernel by diff-by-eyes
* added ip_conntrack_hash_insert_nolock.patch (copied from

     linux-2.6-multigroup)

* added ip_conntrack_hash_insert_lock.patck to add a non-locking function.

2. branches/netfilter-ha/linux-2.6/ct_sync
* Exchangened some things to fit to newest kernel
(All these changes are more or less guessed by looking what has been
changed in the upstream netfilter code between 2.6.10 and 2.6.15.4.)

- WRITE_LOCK -> write_lock_bh
- WRITE_UNLOCK -> write_unlock_bh
- READ_LOCK -> read_lock_bh
- READ_UNLOCK -> read_unlock_bh

- __ip_ct_find_helper_by_name -> __ip_conntrack_helper_find_byname

- ct->nat.info.initialized -> ct->status & IPS_NAT_DONE_MASK

- h->ctrack -> tuplehash_to_ctrack(h)

Let's come to some more interesting changes... :)

As 'ct->nat.num_manips' and 'ct->nat.manips' have been removed I had to fix the occurences in ct_sync, but how?
I had a look at the linux-2.6-multigroup version of ct_sync and tried to "adjust" my version of ct_sync accordingly.
So I just removed the parts with 'ct->nat.manips' and so on. I have the impression, that it works :)

Again cheated with linux-2.6-multigroup I replaced 'place_in_hashes' with 'ip_nat_hash_insert'.

As 'ip_ct_selective_cleanup' does not exist anymore and google told me, that I should not use it for runtime reasons I switched to 'ip_conntrack_cleanup' at init time, which should have the same effect. As it was not needed anymore I removed 'kill_all'.

Because of __ip_conntrack_hash_insert(ct) being static and made me trouble while EXPORTing and requires hash_conntrack, which I didn't want to EXPORT I created ip_conntrack_hash_insert_nolock(ct) in ip_conntrack_core.c and EXPORTed it.

I would like someone who knows this code better than me (Harald?) to have a look at my changes and comment on it.
As an absolutly newbie in C and netfilter code I'm hoping I did not too much bad things :)

Attached you could find my patches against the patches and the ct_sync code each file to be patched as one patch.

Ciao
Max

[42] http://svn.netfilter.org/netfilter/branches/netfilter-ha/linux-2.6/

Signature · 4 lines
|           |                 Follow the white penguin.
|  |\/|  |  |-----------------------------------------------------------.
|  |  |/\|  |  Rechnerbetrieb Mathematik  |   Meine Baustellen:  TSM    |
|           |  Universitaet Paderborn     |   Hostmaster, Linux, LDAP   |
ct_sync.h +2 -1
Index: ct_sync.h
===================================================================
@@ -159,7 +159,9 @@
 	#ifdef CONFIG_IP_NF_NAT_NEEDED
 	int				nat_initialized;
 	__u8				nat_num_manips;
+#if 0
 	struct ip_nat_info_manip 	nat_manips[IP_NAT_MAX_MANIPS];
+#endif
 	char				nat_helper[CT_SYNC_NATHELPERSIZE];
 	union ip_conntrack_nat_help	nat_help;
 	struct ip_nat_seq		nat_seq[IP_CT_DIR_MAX];
@@ -183,7 +185,6 @@
 	struct ip_conntrack_tuple	tuple, mask;	/* expectation tuple and mask */
 	__u32				seq;		/* sequence number */
 	union ip_conntrack_expect_proto	proto;		/* protocol specific info */
-	union ip_conntrack_expect_help	help;		/* expectation helper specific info */
 };
 
 #ifdef __KERNEL__
ct_sync_main.c +31 -225

444 lines not on this page · raw message

ct_notifier_pkt.patch +67 -362

514 lines not on this page · raw message

ct_sync_config_and_makefile.patch +15 -15
Index: ct_sync_config_and_makefile.patch
===================================================================
@@ -1,10 +1,10 @@
-Index: linux-2.6.10-ctsync/net/ipv4/netfilter/Makefile
+Index: netfilter-2.6.14/net/ipv4/netfilter/Makefile
 ===================================================================
---- linux-2.6.10-ctsync.orig/net/ipv4/netfilter/Makefile	2005-07-19 11:26:32.516195604 +0200
-+++ linux-2.6.10-ctsync/net/ipv4/netfilter/Makefile	2005-07-19 11:27:42.791714055 +0200
-@@ -16,6 +16,9 @@
- ipfwadm-objs		:= $(ip_nf_compat-objs) ipfwadm_core.o
- ipchains-objs		:= $(ip_nf_compat-objs) ipchains_core.o
+--- netfilter-2.6.14.orig/net/ipv4/netfilter/Makefile	2005-09-18 12:58:03.203433272 +0200
++++ netfilter-2.6.14/net/ipv4/netfilter/Makefile	2005-10-04 16:23:02.759253880 +0200
+@@ -10,6 +10,9 @@
+ ip_conntrack-objs	:= ip_conntrack_standalone.o ip_conntrack_core.o ip_conntrack_proto_generic.o ip_conntrack_proto_tcp.o ip_conntrack_proto_udp.o ip_conntrack_proto_icmp.o
+ iptable_nat-objs	:= ip_nat_standalone.o ip_nat_rule.o ip_nat_core.o ip_nat_helper.o ip_nat_proto_unknown.o ip_nat_proto_tcp.o ip_nat_proto_udp.o ip_nat_proto_icmp.o
  
 +# conntrack state synchronization
 +ct_sync-objs		:= ct_sync_main.o ct_sync_proto.o ct_sync_sock.o
@@ -12,20 +12,20 @@
  # connection tracking
  obj-$(CONFIG_IP_NF_CONNTRACK) += ip_conntrack.o
  
-@@ -101,3 +104,5 @@
- obj-$(CONFIG_IP_NF_COMPAT_IPFWADM) += ipfwadm.o
+@@ -103,3 +113,5 @@
  
- obj-$(CONFIG_IP_NF_QUEUE) += ip_queue.o
+ # l3 independent conntrack
+ obj-$(CONFIG_NF_CONNTRACK_IPV4) += nf_conntrack_ipv4.o
 +
 +obj-$(CONFIG_IP_NF_CT_SYNC) += ct_sync.o
-Index: linux-2.6.10-ctsync/net/ipv4/netfilter/Kconfig
+Index: netfilter-2.6.14/net/ipv4/netfilter/Kconfig
 ===================================================================
---- linux-2.6.10-ctsync.orig/net/ipv4/netfilter/Kconfig	2005-07-19 11:26:32.516195604 +0200
-+++ linux-2.6.10-ctsync/net/ipv4/netfilter/Kconfig	2005-07-19 11:30:00.179497725 +0200
-@@ -742,5 +742,23 @@
- 	  
- 	  IF unsure, say `N'.
+--- netfilter-2.6.14.orig/net/ipv4/netfilter/Kconfig	2005-09-18 12:58:02.826490576 +0200
++++ netfilter-2.6.14/net/ipv4/netfilter/Kconfig	2005-10-04 16:22:22.487376136 +0200
+@@ -852,5 +852,23 @@
  
+ 	  To compile it as a module, choose M here.  If unsure, say N.
+ 
 +config IP_NF_CT_SYNC
 +	tristate "Connection tracking state synchronization"
 +	depends on IP_NF_CONNTRACK_EVENTS
export_ip_conntrack_clean_from_lists.patch +26 -17

70 lines not on this page · raw message

net/ipv4/netfilter/ip_conntrack_core.max.c renamed from net/ipv4/netfilter/ip_conntrack_core.c +1 -0
@@ -1388,6 +1388,7 @@
 			    ip_conntrack_htable_size);
 	nf_unregister_sockopt(&so_getorigdst);
 }
+EXPORT_SYMBOL_GPL(ip_conntrack_cleanup);
 
 static struct list_head *alloc_hashtable(int size, int *vmalloced)
 {
export_ip_conntrack_find.patch +5 -30
Index: export_ip_conntrack_find.patch
===================================================================
@@ -1,20 +1,8 @@
-Index: linux-2.6.10/net/ipv4/netfilter/ip_conntrack_standalone.c
+Index: linux-2.6.15.4/include/linux/netfilter_ipv4/ip_conntrack_core.h
 ===================================================================
---- linux-2.6.10.orig/net/ipv4/netfilter/ip_conntrack_standalone.c	2005-01-10 20:53:51.796295368 +0100
-+++ linux-2.6.10/net/ipv4/netfilter/ip_conntrack_standalone.c	2005-01-10 20:54:00.490973576 +0100
-@@ -914,6 +914,7 @@
- EXPORT_SYMBOL(ip_conntrack_hash);
- EXPORT_SYMBOL(ip_conntrack_untracked);
- EXPORT_SYMBOL_GPL(ip_conntrack_find_get);
-+EXPORT_SYMBOL_GPL(__ip_conntrack_find);
- EXPORT_SYMBOL_GPL(ip_conntrack_put);
- #ifdef CONFIG_IP_NF_NAT_NEEDED
- EXPORT_SYMBOL(ip_conntrack_tcp_update);
-Index: linux-2.6.10/include/linux/netfilter_ipv4/ip_conntrack_core.h
-===================================================================
---- linux-2.6.10.orig/include/linux/netfilter_ipv4/ip_conntrack_core.h	2005-01-10 20:41:44.022933736 +0100
-+++ linux-2.6.10/include/linux/netfilter_ipv4/ip_conntrack_core.h	2005-01-10 20:54:00.492973272 +0100
-@@ -34,6 +34,11 @@
+--- linux-2.6.15.4.orig/include/linux/netfilter_ipv4/ip_conntrack_core.h	2005-01-10 20:41:44.022933736 +0100
++++ linux-2.6.15.4/include/linux/netfilter_ipv4/ip_conntrack_core.h	2005-01-10 20:54:00.492973272 +0100
+@@ -36,6 +36,11 @@
  ip_conntrack_find_get(const struct ip_conntrack_tuple *tuple,
  		      const struct ip_conntrack *ignored_conntrack);
  
@@ -23,19 +11,6 @@
 +__ip_conntrack_find(const struct ip_conntrack_tuple *tuple,
 +		    const struct ip_conntrack *ignored_conntrack);
 +
- extern int __ip_conntrack_confirm(struct sk_buff *skb);
+ extern int __ip_conntrack_confirm(struct sk_buff **pskb);
  
  /* Confirm a connection: returns NF_DROP if packet must be dropped. */
-Index: linux-2.6.10/net/ipv4/netfilter/ip_conntrack_core.c
-===================================================================
---- linux-2.6.10.orig/net/ipv4/netfilter/ip_conntrack_core.c	2005-01-10 20:53:51.801294608 +0100
-+++ linux-2.6.10/net/ipv4/netfilter/ip_conntrack_core.c	2005-01-10 20:54:00.497972512 +0100
-@@ -354,7 +354,7 @@
- 		&& ip_ct_tuple_equal(tuple, &i->tuple);
- }
- 
--static struct ip_conntrack_tuple_hash *
-+struct ip_conntrack_tuple_hash *
- __ip_conntrack_find(const struct ip_conntrack_tuple *tuple,
- 		    const struct ip_conntrack *ignored_conntrack)
- {
export_ip_nat_lock_and_hash.patch +60 -11

72 lines not on this page · raw message

include/linux/netfilter_ipv4/ip_conntrack.max.h renamed from include/linux/netfilter_ipv4/ip_conntrack.h +3 -0
@@ -270,6 +270,9 @@
 
 extern void ip_conntrack_hash_insert(struct ip_conntrack *ct);
 
+/* Non-Locking ip_conntrack_hash_insert for ct_sync */
+extern void ip_conntrack_hash_insert_nolock(struct ip_conntrack *ct);
+
 extern struct ip_conntrack_expect *
 __ip_conntrack_expect_find(const struct ip_conntrack_tuple *tuple);
 
net/ipv4/netfilter/ip_conntrack_core.max.c renamed from net/ipv4/netfilter/ip_conntrack_core.c +11 -0
@@ -437,6 +437,17 @@
 	write_unlock_bh(&ip_conntrack_lock);
 }
 
+/* Non-Locking ip_conntrack_hash_insert for ct_sync */
+void ip_conntrack_hash_insert_nolock(struct ip_conntrack *ct)
+{
+	unsigned int hash, repl_hash;
+
+	hash = hash_conntrack(&ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple);
+	repl_hash = hash_conntrack(&ct->tuplehash[IP_CT_DIR_REPLY].tuple);
+
+	__ip_conntrack_hash_insert(ct, hash, repl_hash);
+}
+
 /* Confirm a connection given skb; places it in hash table */
 int
 __ip_conntrack_confirm(struct sk_buff **pskb)
net/ipv4/netfilter/ip_conntrack_standalone.max.c renamed from net/ipv4/netfilter/ip_conntrack_standalone.c +1 -0
@@ -1018,6 +1018,7 @@
 EXPORT_SYMBOL_GPL(ip_conntrack_alloc);
 EXPORT_SYMBOL_GPL(ip_conntrack_free);
 EXPORT_SYMBOL_GPL(ip_conntrack_hash_insert);
+EXPORT_SYMBOL_GPL(ip_conntrack_hash_insert_nolock);
 
 EXPORT_SYMBOL_GPL(ip_ct_remove_expectations);
 
pf_packet.patch +2 -164

175 lines not on this page · raw message

series +3 -6
Index: series
===================================================================
@@ -1,11 +1,8 @@
 ct_notifier_pkt.patch 
 pf_packet.patch 
-pf_packet_remove_warning.patch 
-export_ip_conntrack_helpers.patch 
-export_ip_nat_helpers.patch 
 export_ip_conntrack_find.patch 
-export_ip_nat_lock_and_hash.patch 
+export_ip_nat_lock_and_hash.patch
 export_ip_conntrack_clean_from_lists.patch 
-conntrack_hash_manip.patch 
-conntrack_alloc.patch 
+export_ip_conntrack_cleanup.patch
+ip_conntrack_hash_insert_nolock.patch
 ct_sync_config_and_makefile.patch
#1 lore raw

Hi,

Quoted 3 lines · Maximilian Wilhelm

I saw that the patches and the module code were written for kernel version 2.6.10 and experienced rather big trouble patching kernel version 2.6.15.4 :-/

Sure, the linux-2.6 branch in Subversion is pretty old and largely
unmaintained. The whole ct_sync project is pretty much dead.

Quoted 4 lines

The only thing I'm worrying about were many ct entries I produced by nmap -sP <net behing the firewall>
which did not vanish after 10++ hours. I had to reboot to get rid of the connections.

This is a known problem, at least back when I was doing some testing
with ct_sync I experienced the same. Unfortunately I did not manage to find the cause of this bug...

Quoted 1 line

What I did:

A few generic comments about the attached patches: don't send per-file
patches. Divide your changes into logically structured patches. If it's not possible or not very meaningful (just as in this case) then send a single diff appliable using 'patch -p1'.

Another thing is that you've pretty much garbled the quilt patchset. For
example ct_notifier_pkt.patch is not necessary anymore for 2.6.14 and up, so you should have removed that patch completely from the tree instead of just removing basically everything from that patch. pf_packet.patch is also similar, although it is still a bit different as it's not included in mainline kernel and thus a forward-port would be necessary to provide the same functionality.

Quoted 4 lines

I would like someone who knows this code better than me (Harald?) to have a look at my changes and comment on it.
As an absolutly newbie in C and netfilter code I'm hoping I did not too much bad things :)

No, not at all, after all it _seems_ to be working for you :)

However, merging these changes to SVN would still need some more work.
As the number of people working on ct_sync is very close to zero at the moment, I think that all effort should be concentrated on a single branch of the code. Because Harald has already put significant effort into providing support for active-active setups I think that we should try and get the linux-2.6-multigroup branch working first. Holger Eitzenberger was also doing some tests using that version and provided multiple fixes for problems he had found.

So I don't think we should put significant amount of work into updating
the old 2.6.10 branch. Instead, please give the -multigroup branch a try and provide feedback. Of course if you think you have the time to prepare an easily-committable patch for the linux-2.6 branch of ct_sync I'll be more than happy to update the SVN repository. I'm just unwilling to spend a significant amount of time updating that old branch.

Signature · 1 line
 KOVACS Krisztian
#2 lore raw

Am Sonntag, den 19. März hub KOVACS Krisztian folgendes in die Tasten:

Hi!

Quoted 7 lines · Maximilian Wilhelm
Quoted 3 lines

I saw that the patches and the module code were written for kernel version 2.6.10 and experienced rather big trouble patching kernel version 2.6.15.4 :-/

Sure, the linux-2.6 branch in Subversion is pretty old and largely
unmaintained. The whole ct_sync project is pretty much dead.

Hmm, sad. :-(
It's a great software and working very well in my test net here.

Quoted 11 lines
Quoted 4 lines

The only thing I'm worrying about were many ct entries I produced by nmap -sP <net behing the firewall>
which did not vanish after 10++ hours. I had to reboot to get rid of the connections.

This is a known problem, at least back when I was doing some testing
with ct_sync I experienced the same. Unfortunately I did not manage to find the cause of this bug...

Quoted 6 lines
Quoted 1 line

What I did:

A few generic comments about the attached patches: don't send per-file
patches. Divide your changes into logically structured patches. If it's not possible or not very meaningful (just as in this case) then send a single diff appliable using 'patch -p1'.

Ok, noticed :)
(This was the first time I hacked something as large as ct_sync/netfilter.)

Quoted 4 lines

Another thing is that you've pretty much garbled the quilt patchset. For
example ct_notifier_pkt.patch is not necessary anymore for 2.6.14 and up, so you should have removed that patch completely from the tree instead of just removing basically everything from that patch.

Ok, I did so now.
I will provide a new patch and place it at [42]

As I said, I'm not into the code and don't anything about earlier changes in the netfilter code.
That's the reason I wanted someone with more knowledege to have a look at my patches. :)

Quoted 4 lines

pf_packet.patch is
also similar, although it is still a bit different as it's not included in mainline kernel and thus a forward-port would be necessary to provide the same functionality.

Any suggestions what to be done here?

Quoted 6 lines
Quoted 4 lines

I would like someone who knows this code better than me (Harald?) to have a look at my changes and comment on it.
As an absolutly newbie in C and netfilter code I'm hoping I did not too much bad things :)

No, not at all, after all it _seems_ to be working for you :)

Yes, pretty well :)

Quoted 9 lines

However, merging these changes to SVN would still need some more work.
As the number of people working on ct_sync is very close to zero at the moment, I think that all effort should be concentrated on a single branch of the code. Because Harald has already put significant effort into providing support for active-active setups I think that we should try and get the linux-2.6-multigroup branch working first. Holger Eitzenberger was also doing some tests using that version and provided multiple fixes for problems he had found.

Quoted 3 lines

So I don't think we should put significant amount of work into updating
the old 2.6.10 branch. Instead, please give the -multigroup branch a try and provide feedback.

Ok, I will give it a try.

Quoted 3 lines

Of course if you think you have the time to prepare
an easily-committable patch for the linux-2.6 branch of ct_sync I'll be more than happy to update the SVN repository.

What has to be done to achieve an "easily-committable patch"? If you give me some hints about which patches aren't used anymore I will remove them

Quoted 2 lines

I'm just unwilling to spend
a significant amount of time updating that old branch.

Sure.

[42] http://vvv.barbarossa.name/files/ct_sync

Ciao
Max

Signature · 4 lines
|           |                 Follow the white penguin.
|  |\/|  |  |-----------------------------------------------------------.
|  |  |/\|  |  Rechnerbetrieb Mathematik  |   Meine Baustellen:  TSM    |
|           |  Universitaet Paderborn     |   Hostmaster, Linux, LDAP   | 
#3 lore raw

ct_sync-multigroup (was: Re: Made ct_sync running with 2.6.15.4...)

In reply to KOVACS Krisztian

Am Sonntag, den 19. M?rz hub KOVACS Krisztian folgendes in die Tasten:

Hi!

[...]

Quoted 9 lines

However, merging these changes to SVN would still need some more work.
As the number of people working on ct_sync is very close to zero at the moment, I think that all effort should be concentrated on a single branch of the code. Because Harald has already put significant effort into providing support for active-active setups I think that we should try and get the linux-2.6-multigroup branch working first. Holger Eitzenberger was also doing some tests using that version and provided multiple fixes for problems he had found.

Quoted 3 lines

So I don't think we should put significant amount of work into updating
the old 2.6.10 branch. Instead, please give the -multigroup branch a try and provide feedback.

I wanted to give it a shot and updated most of the patches to fit to 2.6.17-rc1 (as in the git version of linus kernel from some hours ago). A diff against the svn.netfilter.org version can be found at [42].

I'm experiencing some lack of "knowledge" about the newest *tables -> x_tables chances and want to ask if someone allready has put some effort into updating the patches/code.

If someone did, I would love to get/test/use the updates :)

If not, I will try to fix this myself these days, but I don't know if I will be able to do so even though git makes things easier.

Quoted 4 lines

Of course if you think you have the time to prepare
an easily-committable patch for the linux-2.6 branch of ct_sync I'll be more than happy to update the SVN repository. I'm just unwilling to spend a significant amount of time updating that old branch.

At [42] there are still working patches for the "plain" ct_sync branch :) (I splitted the patch in -fix and -cleanup)

[42] http://vvv.barbarossa.name/files/ct_sync/

Ciao
Max

Signature · 1 line
	Follow the white penguin.