netfilter 00/04: netfilter fixes
Subsystems (3)
Hi Dave,
following are four netfilter fixes for 2.6.31:
- Jesper's rcu_barrier() patch to fix conntrack module unload races
- a patch to fix false positives in TCP conntrack unacknowledged data detection, resulting in very short timeout values
- a missing linux/types.h include in xt_osf.h
- a fix for a conntrack match regression introduced with the last revision:
the state member in the configuration struct isn't able to hold all valid values. This unfortunately needs a new revision.
Please apply or pull from:
git://git.kernel.org/pub/scm/linux/kernel/git/kaber/nf-2.6.git master
Thanks!
include/linux/netfilter/xt_conntrack.h | 13 ++++++ include/linux/netfilter/xt_osf.h | 2 + include/net/netfilter/nf_conntrack.h | 4 +- net/ipv4/netfilter/nf_nat_helper.c | 17 +++++--- net/netfilter/nf_conntrack_expect.c | 4 +- net/netfilter/nf_conntrack_extend.c | 2 +- net/netfilter/nf_conntrack_proto_tcp.c | 6 +- net/netfilter/xt_conntrack.c | 66 +++++++++++++++++++++++++++++--- 8 files changed, 95 insertions(+), 19 deletions(-)
Jan Engelhardt (1):
netfilter: xtables: conntrack match revision 2
Jaswinder Singh Rajput (1):
netfilter: headers_check fix: linux/netfilter/xt_osf.h
Jesper Dangaard Brouer (1):
nf_conntrack: Use rcu_barrier()
Patrick McHardy (1):
netfilter: tcp conntrack: fix unacknowledged data detection with NAT
nf_conntrack 01/04: Use rcu_barrier()
commit 308ff823ebd749a94d3b6ac26b95bc0eb114c39e
Author: Jesper Dangaard Brouer <[email protected]> Date: Thu Jun 25 16:32:52 2009 +0200
nf_conntrack: Use rcu_barrier()
RCU barriers, rcu_barrier(), is inserted two places.
In nf_conntrack_expect.c nf_conntrack_expect_fini() before the kmem_cache_destroy(). Firstly to make sure the callback to the nf_ct_expect_free_rcu() code is still around. Secondly because I'm unsure about the consequence of having in flight nf_ct_expect_free_rcu/kmem_cache_free() calls while doing a kmem_cache_destroy() slab destroy.
And in nf_conntrack_extend.c nf_ct_extend_unregister(), inorder to wait for completion of callbacks to __nf_ct_ext_free_rcu(), which is invoked by __nf_ct_ext_add(). It might be more efficient to call rcu_barrier() in nf_conntrack_core.c nf_conntrack_cleanup_net(), but thats make it more difficult to read the code (as the callback code in located in nf_conntrack_extend.c).
net/netfilter/nf_conntrack_expect.c +3 -1
@@ -617,8 +617,10 @@ err1:void nf_conntrack_expect_fini (struct net *net) {exp_proc_remove (net); -if (net_eq (net, &init_net)) +if (net_eq (net, &init_net)) { +rcu_barrier ();/* Wait for call_rcu() before destroy */ kmem_cache_destroy (nf_ct_expect_cachep); + }nf_ct_free_hashtable (net->ct.expect_hash, net->ct.expect_vmalloc, nf_ct_expect_hsize); }
net/netfilter/nf_conntrack_extend.c +1 -1
@@ -186,6 +186,6 @@ void nf_ct_extend_unregister(struct nf_ct_ext_type *type)rcu_assign_pointer (nf_ct_ext_types[type->id],NULL );update_alloc_size (type);mutex_unlock (&nf_ct_ext_type_mutex); -synchronize_rcu (); +rcu_barrier ();/* Wait for completion of call_rcu()'s */ }EXPORT_SYMBOL_GPL (nf_ct_extend_unregister);
netfilter 02/04: tcp conntrack: fix unacknowledged data detection with NAT
In reply to Patrick McHardycommit a3a9f79e361e864f0e9d75ebe2a0cb43d17c4272
Author: Patrick McHardy <[email protected]> Date: Mon Jun 29 14:07:56 2009 +0200
netfilter: tcp conntrack: fix unacknowledged data detection with NAT
When NAT helpers change the TCP packet size, the highest seen sequence number needs to be corrected. This is currently only done upwards, when the packet size is reduced the sequence number is unchanged. This causes TCP conntrack to falsely detect unacknowledged data and decrease the timeout.
Fix by updating the highest seen sequence number in both directions after packet mangling.
include/net/netfilter/nf_conntrack.h +2 -2
@@ -258,8 +258,8 @@ static inline bool nf_ct_kill(struct nf_conn *ct)/* Update TCP window tracking data when NAT mangles the packet */ extern void nf_conntrack_tcp_update (const struct sk_buff *skb,unsigned int dataoff, -struct nf_conn *ct, -int dir); +struct nf_conn *ct,int dir, +s16 offset);/* Fake conntrack entry for untracked connections */ extern struct nf_conn nf_conntrack_untracked;
net/ipv4/netfilter/nf_nat_helper.c +11 -6
@@ -191,7 +191,8 @@ nf_nat_mangle_tcp_packet(struct sk_buff *skb, ct, ctinfo);/* Tell TCP window tracking about seq change */ nf_conntrack_tcp_update (skb,ip_hdrlen (skb), - ct,CTINFO2DIR (ctinfo)); + ct,CTINFO2DIR (ctinfo), + (int )rep_len - (int )match_len);nf_conntrack_event_cache (IPCT_NATSEQADJ , ct); }
@@ -377,6 +378,7 @@ nf_nat_seq_adjust(struct sk_buff *skb,struct tcphdr *tcph;int dir;__be32 newseq, newack; +s16 seqoff, ackoff;struct nf_conn_nat *nat =nfct_nat (ct);struct nf_nat_seq *this_way, *other_way;
@@ -390,15 +392,18 @@ nf_nat_seq_adjust(struct sk_buff *skb, tcph = (void *)skb->data +ip_hdrlen (skb);if (after (ntohl (tcph->seq), this_way->correction_pos)) - newseq =htonl (ntohl (tcph->seq) + this_way->offset_after); + seqoff = this_way->offset_after;else - newseq =htonl (ntohl (tcph->seq) + this_way->offset_before); + seqoff = this_way->offset_before;if (after (ntohl (tcph->ack_seq) - other_way->offset_before, other_way->correction_pos)) - newack =htonl (ntohl (tcph->ack_seq) - other_way->offset_after); + ackoff = other_way->offset_after;else - newack =htonl (ntohl (tcph->ack_seq) - other_way->offset_before); + ackoff = other_way->offset_before; + + newseq =htonl (ntohl (tcph->seq) + seqoff); + newack =htonl (ntohl (tcph->ack_seq) - ackoff);inet_proto_csum_replace4 (&tcph->check, skb, tcph->seq, newseq,0 );inet_proto_csum_replace4 (&tcph->check, skb, tcph->ack_seq, newack,0 );
@@ -413,7 +418,7 @@ nf_nat_seq_adjust(struct sk_buff *skb,if (!nf_nat_sack_adjust (skb, tcph, ct, ctinfo))return 0 ; -nf_conntrack_tcp_update (skb,ip_hdrlen (skb), ct, dir); +nf_conntrack_tcp_update (skb,ip_hdrlen (skb), ct, dir, seqoff);return 1 ; }
net/netfilter/nf_conntrack_proto_tcp.c +3 -3
@@ -720,8 +720,8 @@ static bool tcp_in_window(const struct nf_conn *ct,/* Caller must linearize skb at tcp header. */ void nf_conntrack_tcp_update (const struct sk_buff *skb,unsigned int dataoff, -struct nf_conn *ct, -int dir) +struct nf_conn *ct,int dir, +s16 offset) {const struct tcphdr *tcph = (const void *)skb->data + dataoff;const struct ip_ct_tcp_state *sender = &ct->proto.tcp.seen[dir];
@@ -734,7 +734,7 @@ void nf_conntrack_tcp_update(const struct sk_buff *skb,/* * We have to worry for the ack in the reply packet only... */ -if (after (end, ct->proto.tcp.seen[dir].td_end)) +if (ct->proto.tcp.seen[dir].td_end + offset == end) ct->proto.tcp.seen[dir].td_end = end; ct->proto.tcp.last_end = end;spin_unlock_bh (&ct->lock);
netfilter 03/04: headers_check fix: linux/netfilter/xt_osf.h
In reply to Patrick McHardycommit 8a3af79361e85db6fec4173ef1916322471c19e3
Author: Jaswinder Singh Rajput <[email protected]> Date: Mon Jun 29 14:28:27 2009 +0200
netfilter: headers_check fix: linux/netfilter/xt_osf.h
fix the following 'make headers_check' warnings:
usr/include/linux/netfilter/xt_osf.h:40: found __[us]{8,16,32,64} type without #include <linux/types.h>
include/linux/netfilter/xt_osf.h +2 -0
@@ -20,6 +20,8 @@#ifndef _XT_OSF_H#define _XT_OSF_H +#include <linux/types.h> +#define MAXGENRELEN 32#define XT_OSF_GENRE (1<<0)
netfilter 04/04: xtables: conntrack match revision 2
In reply to Patrick McHardycommit d6d3f08b0fd998b647a05540cedd11a067b72867
Author: Jan Engelhardt <[email protected]> Date: Mon Jun 29 14:31:46 2009 +0200
netfilter: xtables: conntrack match revision 2
As reported by Philip, the UNTRACKED state bit does not fit within the 8-bit state_mask member. Enlarge state_mask and give status_mask a few more bits too.
References: http://markmail.org/thread/b7eg6aovfh4agyz7
include/linux/netfilter/xt_conntrack.h +13 -0
@@ -81,4 +81,17 @@ struct xt_conntrack_mtinfo1 { __u8 state_mask, status_mask; }; +struct xt_conntrack_mtinfo2 { +union nf_inet_addr origsrc_addr, origsrc_mask; +union nf_inet_addr origdst_addr, origdst_mask; +union nf_inet_addr replsrc_addr, replsrc_mask; +union nf_inet_addr repldst_addr, repldst_mask; +__u32 expires_min, expires_max; +__u16 l4proto; +__be16 origsrc_port, origdst_port; +__be16 replsrc_port, repldst_port; +__u16 match_flags, invert_flags; +__u16 state_mask, status_mask; +}; +#endif /*_XT_CONNTRACK_H*/
net/netfilter/xt_conntrack.c +60 -6
125 lines not on this page · raw message
PATCH 1/1 MAINTAINERS: Add NETFILTER git
In reply to Patrick McHardyQuoted 1 line · Patrick McHardy
git://git.kernel.org/pub/scm/linux/kernel/git/kaber/nf-2.6.git
Do you think this should be added to MAINTAINERS?
MAINTAINERS +1 -0
@@ -4044,6 +4044,7 @@ L: [email protected] L: [email protected] W: http://www.netfilter.org/ W: http://www.iptables.org/ +T: git://git.kernel.org/pub/scm/linux/kernel/git/kaber/nf-2.6.git S: Supported F: include/linux/netfilter* F: include/linux/netfilter/
David Miller
maintainerFrom: Patrick McHardy <[email protected]>
Date: Mon, 29 Jun 2009 16:20:13 +0200 (MEST)
Quoted 5 lines
Please apply or pull from:
git://git.kernel.org/pub/scm/linux/kernel/git/kaber/nf-2.6.gitmasterThanks!
Pulled, thanks a lot Patrick!
Patrick McHardy
AppliedRe: [PATCH] MAINTAINERS: Add NETFILTER git
In reply to Joe PerchesQuoted 4 lines · Joe Perches
Quoted 1 line · Patrick McHardy
git://git.kernel.org/pub/scm/linux/kernel/git/kaber/nf-2.6.gitDo you think this should be added to
MAINTAINERS?
Applied, thanks.