netfilter 00/08: Netfilter Update
Subsystems (3)
Hi Dave,
following is a small netfilter update for 2.6.32, containing:
- various cleanups by Changli Gao, Hannes Eder and Joe Perches
- a patch from Pablo to improve TCP window tracking behaviour when connection tracking is out-of-sync with the connection endpoints.
- INPUT chain support for the xt_socket match
- a fix for dumping the revision 1 data of the conntrack match by Florian Westphal.
- Removal of some unnecessary code by myself and Eric
Please apply or pull from:
git://git.kernel.org/pub/scm/linux/kernel/git/kaber/nf-next-2.6.git master
Thanks!
include/linux/netfilter/nf_conntrack_tcp.h | 3 + net/ipv4/netfilter/arp_tables.c | 22 ++++---- net/ipv4/netfilter/ip_queue.c | 5 +- net/ipv4/netfilter/ip_tables.c | 46 +++++++++--------- net/ipv4/netfilter/ipt_CLUSTERIP.c | 20 ++++---- net/ipv4/netfilter/ipt_ECN.c | 8 ++-- net/ipv4/netfilter/ipt_LOG.c | 22 ++++---- net/ipv4/netfilter/ipt_MASQUERADE.c | 4 +- net/ipv4/netfilter/ipt_REJECT.c | 4 +- net/ipv4/netfilter/ipt_ULOG.c | 6 +- net/ipv4/netfilter/ipt_ecn.c | 4 +- net/ipv4/netfilter/iptable_mangle.c | 4 +- net/ipv4/netfilter/iptable_security.c | 4 +- net/ipv4/netfilter/nf_conntrack_proto_icmp.c | 28 +++++----- net/ipv4/netfilter/nf_nat_helper.c | 22 ++++----- net/ipv4/netfilter/nf_nat_standalone.c | 10 ++-- net/ipv6/netfilter/ip6_queue.c | 5 +- net/ipv6/netfilter/ip6_tables.c | 42 ++++++++-------- net/ipv6/netfilter/ip6t_LOG.c | 4 +- net/ipv6/netfilter/ip6t_REJECT.c | 4 +- net/ipv6/netfilter/ip6t_ah.c | 19 +++---- net/ipv6/netfilter/ip6t_frag.c | 47 ++++++++---------- net/ipv6/netfilter/ip6t_rt.c | 9 +-- net/ipv6/netfilter/ip6table_filter.c | 4 +- net/ipv6/netfilter/ip6table_mangle.c | 14 +++--- net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c | 12 ++-- net/netfilter/nf_conntrack_core.c | 14 ++++-- net/netfilter/nf_conntrack_proto_tcp.c | 51 ++++++++++++++++---- net/netfilter/nfnetlink_log.c | 3 +- net/netfilter/nfnetlink_queue.c | 3 +- net/netfilter/xt_conntrack.c | 61 +++++++----------------- net/netfilter/xt_socket.c | 6 ++- 32 files changed, 253 insertions(+), 257 deletions(-)
Changli Gao (1):
netfilter: nf_conntrack: avoid additional compare.
Eric Dumazet (1):
netfilter: remove synchronize_net() calls in ip_queue/ip6_queue
Florian Westphal (1):
netfilter: xtables: fix conntrack match v1 ipt-save output
Hannes Eder (1):
netfilter: nf_nat_helper: tidy up adjust_tcp_sequence
Jan Engelhardt (1):
netfilter: xt_socket: make module available for INPUT chain
Joe Perches (1):
netfilter: net/ipv[46]/netfilter: Move && and || to end of previous line
Pablo Neira Ayuso (1):
netfilter: nf_ct_tcp: improve out-of-sync situation in TCP tracking
Patrick McHardy (1):
netfilter: remove unneccessary checks from netlink notifiers
netfilter 01/08: xt_socket: make module available for INPUT chain
commit aa3c487f355ff1477b8369d9f0b9860387ae21d4
Author: Jan Engelhardt <[email protected]> Date: Thu Oct 29 15:35:10 2009 +0100
netfilter: xt_socket: make module available for INPUT chain
This should make it possible to test for the existence of local sockets in the INPUT path.
References: http://marc.info/?l=netfilter-devel&m=125380481517129&w=2
net/netfilter/xt_socket.c +4 -2
@@ -192,7 +192,8 @@ static struct xt_match socket_mt_reg[] __read_mostly = { .revision = 0, .family = NFPROTO_IPV4, .match = socket_mt_v0, - .hooks = 1 << NF_INET_PRE_ROUTING, + .hooks = (1 << NF_INET_PRE_ROUTING) | + (1 << NF_INET_LOCAL_IN), .me = THIS_MODULE, }, {
@@ -201,7 +202,8 @@ static struct xt_match socket_mt_reg[] __read_mostly = { .family = NFPROTO_IPV4, .match = socket_mt_v1, .matchsize = sizeof(struct xt_socket_mtinfo1), - .hooks = 1 << NF_INET_PRE_ROUTING, + .hooks = (1 << NF_INET_PRE_ROUTING) | + (1 << NF_INET_LOCAL_IN), .me = THIS_MODULE, }, };
netfilter 02/08: remove synchronize_net() calls in ip_queue/ip6_queue
In reply to Patrick McHardycommit 9481721be10a1bfd1ee9ccf507eecd7f37caa5ec
Author: Eric Dumazet <[email protected]> Date: Wed Nov 4 21:14:31 2009 +0100
netfilter: remove synchronize_net() calls in ip_queue/ip6_queue
nf_unregister_queue_handlers() already does a synchronize_rcu() call, we dont need to do it again in callers.
net/ipv4/netfilter/ip_queue.c +1 -1
@@ -622,7 +622,7 @@ cleanup_netlink_notifier: static void __exit ip_queue_fini(void) {nf_unregister_queue_handlers (&nfqh); -synchronize_net (); +ipq_flush (NULL ,0 );#ifdef CONFIG_SYSCTL
net/ipv6/netfilter/ip6_queue.c +1 -1
@@ -625,7 +625,7 @@ cleanup_netlink_notifier: static void __exit ip6_queue_fini(void) {nf_unregister_queue_handlers (&nfqh); -synchronize_net (); +ipq_flush (NULL ,0 );#ifdef CONFIG_SYSCTL
netfilter 03/08: nf_conntrack: avoid additional compare.
In reply to Patrick McHardycommit 5ae27aa2b16478a84d833ab4065798e752941c5a
Author: Changli Gao <[email protected]> Date: Thu Nov 5 14:51:31 2009 +0100
netfilter: nf_conntrack: avoid additional compare.
net/netfilter/nf_conntrack_core.c +10 -4
@@ -511,11 +511,17 @@ static noinline int early_drop(struct net *net, unsigned int hash) cnt++; } -if (ct &&unlikely (nf_ct_is_dying (ct) || - !atomic_inc_not_zero (&ct->ct_general.use))) - ct =NULL ; -if (ct || cnt >=NF_CT_EVICTION_RANGE ) +if (ct !=NULL ) { +if (likely (!nf_ct_is_dying (ct) && +atomic_inc_not_zero (&ct->ct_general.use))) +break ; +else + ct =NULL ; + } + +if (cnt >=NF_CT_EVICTION_RANGE )break ; + hash = (hash +1 ) % nf_conntrack_htable_size; }rcu_read_unlock ();
netfilter 04/08: nf_nat_helper: tidy up adjust_tcp_sequence
In reply to Patrick McHardycommit 76ac894080019c6619d3c3bf615db42a43a77f32
Author: Hannes Eder <[email protected]> Date: Thu Nov 5 15:51:19 2009 +0100
netfilter: nf_nat_helper: tidy up adjust_tcp_sequence
The variable 'other_way' gets initialized but is not read afterwards, so remove it. Pass the right arguments to a pr_debug call.
While being at tidy up a bit and it fix this checkpatch warning:
WARNING: suspect code indent for conditional statements
net/ipv4/netfilter/nf_nat_helper.c +9 -13
@@ -41,18 +41,14 @@ adjust_tcp_sequence(u32 seq,struct nf_conn *ct, enum ip_conntrack_info ctinfo) { - int dir; -struct nf_nat_seq *this_way, *other_way; + enum ip_conntrack_dir dir = CTINFO2DIR(ctinfo);struct nf_conn_nat *nat =nfct_nat (ct); +struct nf_nat_seq *this_way = &nat->seq[dir]; -pr_debug ("adjust_tcp_sequence: seq = %u, sizediff = %d\n" , seq, seq); - - dir =CTINFO2DIR (ctinfo); - - this_way = &nat->seq[dir]; - other_way = &nat->seq[!dir]; +pr_debug ("adjust_tcp_sequence: seq = %u, sizediff = %d\n" , + seq, sizediff); -pr_debug ("nf_nat_resize_packet: Seq_offset before: " ); +pr_debug ("adjust_tcp_sequence: Seq_offset before: " );DUMP_OFFSET (this_way);spin_lock_bh (&nf_nat_seqofs_lock);
@@ -63,13 +59,13 @@ adjust_tcp_sequence(u32 seq,* retransmit */ if (this_way->offset_before == this_way->offset_after ||before (this_way->correction_pos, seq)) { - this_way->correction_pos = seq; - this_way->offset_before = this_way->offset_after; - this_way->offset_after += sizediff; + this_way->correction_pos = seq; + this_way->offset_before = this_way->offset_after; + this_way->offset_after += sizediff; }spin_unlock_bh (&nf_nat_seqofs_lock); -pr_debug ("nf_nat_resize_packet: Seq_offset after: " ); +pr_debug ("adjust_tcp_sequence: Seq_offset after: " );DUMP_OFFSET (this_way); }
netfilter 05/08: remove unneccessary checks from netlink notifiers
In reply to Patrick McHardycommit dee5817e88ac8195e5938d6671f434a071e35698
Author: Patrick McHardy <[email protected]> Date: Fri Nov 6 17:04:00 2009 +0100
netfilter: remove unneccessary checks from netlink notifiers
The NETLINK_URELEASE notifier is only invoked for bound sockets, so there is no need to check ->pid again.
net/ipv4/netfilter/ip_queue.c +1 -2
@@ -497,8 +497,7 @@ ipq_rcv_nl_event(struct notifier_block *this, {struct netlink_notify *n = ptr; -if (event ==NETLINK_URELEASE && - n->protocol ==NETLINK_FIREWALL && n->pid) { +if (event ==NETLINK_URELEASE && n->protocol ==NETLINK_FIREWALL ) {write_lock_bh (&queue_lock);if ((n->net == &init_net) && (n->pid == peer_pid))__ipq_reset ();
net/ipv6/netfilter/ip6_queue.c +1 -2
@@ -499,8 +499,7 @@ ipq_rcv_nl_event(struct notifier_block *this, {struct netlink_notify *n = ptr; -if (event ==NETLINK_URELEASE && - n->protocol ==NETLINK_IP6_FW && n->pid) { +if (event ==NETLINK_URELEASE && n->protocol ==NETLINK_IP6_FW ) {write_lock_bh (&queue_lock);if ((n->net == &init_net) && (n->pid == peer_pid))__ipq_reset ();
net/netfilter/nfnetlink_log.c +1 -2
@@ -666,8 +666,7 @@ nfulnl_rcv_nl_event(struct notifier_block *this, {struct netlink_notify *n = ptr; -if (event ==NETLINK_URELEASE && - n->protocol ==NETLINK_NETFILTER && n->pid) { +if (event ==NETLINK_URELEASE && n->protocol ==NETLINK_NETFILTER ) {int i;/* destroy all instances for this pid */
net/netfilter/nfnetlink_queue.c +1 -2
@@ -574,8 +574,7 @@ nfqnl_rcv_nl_event(struct notifier_block *this, {struct netlink_notify *n = ptr; -if (event ==NETLINK_URELEASE && - n->protocol ==NETLINK_NETFILTER && n->pid) { +if (event ==NETLINK_URELEASE && n->protocol ==NETLINK_NETFILTER ) {int i;/* destroy all instances for this pid */
netfilter 06/08: nf_ct_tcp: improve out-of-sync situation in TCP tracking
In reply to Patrick McHardycommit c4832c7bbc3f7a4813347e871d7238651bf437d3
Author: Pablo Neira Ayuso <[email protected]> Date: Mon Nov 23 10:34:39 2009 +0100
netfilter: nf_ct_tcp: improve out-of-sync situation in TCP tracking
Without this patch, if we receive a SYN packet from the client while the firewall is out-of-sync, we let it go through. Then, if we see the SYN/ACK reply coming from the server, we destroy the conntrack entry and drop the packet to trigger a new retransmission. Then, the retransmision from the client is used to start a new clean session.
This patch improves the current handling. Basically, if we see an unexpected SYN packet, we annotate the TCP options. Then, if we see the reply SYN/ACK, this means that the firewall was indeed out-of-sync. Therefore, we set a clean new session from the existing entry based on the annotated values.
This patch adds two new 8-bits fields that fit in a 16-bits gap of the ip_ct_tcp structure.
This patch is particularly useful for conntrackd since the asynchronous nature of the state-synchronization allows to have backup nodes that are not perfect copies of the master. This helps to improve the recovery under some worst-case scenarios.
I have tested this by creating lots of conntrack entries in wrong state:
for ((i=1024;i<65535;i++)); do conntrack -I -p tcp -s 192.168.2.101 -d 192.168.2.2 --sport $i --dport 80 -t 800 --state ESTABLISHED -u ASSURED,SEEN_REPLY; done
Then, I make some TCP connections:
$ echo GET / | nc 192.168.2.2 80
The events show the result:
[UPDATE] tcp 6 60 SYN_RECV src=192.168.2.101 dst=192.168.2.2 sport=33220 dport=80 src=192.168.2.2 dst=192.168.2.101 sport=80 dport=33220 [ASSURED]
[UPDATE] tcp 6 432000 ESTABLISHED src=192.168.2.101 dst=192.168.2.2 sport=33220 dport=80 src=192.168.2.2 dst=192.168.2.101 sport=80 dport=33220 [ASSURED]
[UPDATE] tcp 6 120 FIN_WAIT src=192.168.2.101 dst=192.168.2.2 sport=33220 dport=80 src=192.168.2.2 dst=192.168.2.101 sport=80 dport=33220 [ASSURED]
[UPDATE] tcp 6 30 LAST_ACK src=192.168.2.101 dst=192.168.2.2 sport=33220 dport=80 src=192.168.2.2 dst=192.168.2.101 sport=80 dport=33220 [ASSURED]
[UPDATE] tcp 6 120 TIME_WAIT src=192.168.2.101 dst=192.168.2.2 sport=33220 dport=80 src=192.168.2.2 dst=192.168.2.101 sport=80 dport=33220 [ASSURED]
and tcpdump shows no retransmissions:
20:47:57.271951 IP 192.168.2.101.33221 > 192.168.2.2.www: S 435402517:435402517(0) win 5840 <mss 1460,sackOK,timestamp 4294961827 0,nop,wscale 6> 20:47:57.273538 IP 192.168.2.2.www > 192.168.2.101.33221: S 3509927945:3509927945(0) ack 435402518 win 5792 <mss 1460,sackOK,timestamp 235681024 4294961827,nop,wscale 4> 20:47:57.273608 IP 192.168.2.101.33221 > 192.168.2.2.www: . ack 3509927946 win 92 <nop,nop,timestamp 4294961827 235681024>
20:47:57.273693 IP 192.168.2.101.33221 > 192.168.2.2.www: P 435402518:435402524(6) ack 3509927946 win 92 <nop,nop,timestamp 4294961827 235681024> 20:47:57.275492 IP 192.168.2.2.www > 192.168.2.101.33221: . ack 435402524 win 362 <nop,nop,timestamp 235681024 4294961827>
20:47:57.276492 IP 192.168.2.2.www > 192.168.2.101.33221: P 3509927946:3509928082(136) ack 435402524 win 362 <nop,nop,timestamp 235681025 4294961827> 20:47:57.276515 IP 192.168.2.101.33221 > 192.168.2.2.www: . ack 3509928082 win 108 <nop,nop,timestamp 4294961828 235681025>
20:47:57.276521 IP 192.168.2.2.www > 192.168.2.101.33221: F 3509928082:3509928082(0) ack 435402524 win 362 <nop,nop,timestamp 235681025 4294961827> 20:47:57.277369 IP 192.168.2.101.33221 > 192.168.2.2.www: F 435402524:435402524(0) ack 3509928083 win 108 <nop,nop,timestamp 4294961828 235681025> 20:47:57.279491 IP 192.168.2.2.www > 192.168.2.101.33221: . ack 435402525 win 362 <nop,nop,timestamp 235681025 4294961828>
I also added a rule to log invalid packets, with no occurrences :-) .
include/linux/netfilter/nf_conntrack_tcp.h +3 -0
@@ -67,6 +67,9 @@ struct ip_ct_tcpu_int32_t last_ack;/* Last sequence number seen in opposite dir */ u_int32_t last_end;/* Last seq + len */ u_int16_t last_win;/* Last window advertisement seen in dir */ +/* For SYN packets while we may be out-of-sync */ +u_int8_t last_wscale;/* Last window scaling factor seen */ + u_int8_t last_flags; /* Last flags set */ };#endif /* __KERNEL__ */
net/netfilter/nf_conntrack_proto_tcp.c +41 -10
64 lines not on this page · raw message
netfilter 07/08: xtables: fix conntrack match v1 ipt-save output
In reply to Patrick McHardycommit 3a0429292daa0e1ec848bd26479f5e48b0d54a42
Author: Florian Westphal <[email protected]> Date: Mon Nov 23 10:43:57 2009 +0100
netfilter: xtables: fix conntrack match v1 ipt-save output
commit d6d3f08b0fd998b647a05540cedd11a067b72867 (netfilter: xtables: conntrack match revision 2) does break the v1 conntrack match iptables-save output in a subtle way.
Problem is as follows:
up = kmalloc(sizeof(*up), GFP_KERNEL);
[..]
/*
* The strategy here is to minimize the overhead of v1 matching,
* by prebuilding a v2 struct and putting the pointer into the
* v1 dataspace.
*/
memcpy(up, info, offsetof(typeof(*info), state_mask));
[..]
*(void **)info = up;
As the v2 struct pointer is saved in the match data space, it clobbers the first structure member (->origsrc_addr).
Because the _v1 match function grabs this pointer and does not actually look at the v1 origsrc, run time functionality does not break. But iptables -nvL (or iptables-save) cannot know that v1 origsrc_addr has been overloaded in this way:
$ iptables -p tcp -A OUTPUT -m conntrack --ctorigsrc 10.0.0.1 -j ACCEPT $ iptables-save
-A OUTPUT -p tcp -m conntrack --ctorigsrc 128.173.134.206 -j ACCEPT
(128.173... is the address to the v2 match structure).
To fix this, we take advantage of the fact that the v1 and v2 structures are identical with exception of the last two structure members (u8 in v1, u16 in v2).
We extract them as early as possible and prevent the v2 matching function from looking at those two members directly.
Previously reported by Michel Messerschmidt via Ben Hutchings, also see Debian Bug tracker #556587.
net/netfilter/xt_conntrack.c +17 -44
@@ -113,7 +113,8 @@ ct_proto_port_check(const struct xt_conntrack_mtinfo2 *info, }static bool -conntrack_mt (const struct sk_buff *skb,const struct xt_match_param *par) +conntrack_mt (const struct sk_buff *skb,const struct xt_match_param *par, +u16 state_mask,u16 status_mask) {const struct xt_conntrack_mtinfo2 *info = par->matchinfo;enum ip_conntrack_info ctinfo;
@@ -136,7 +137,7 @@ conntrack_mt(const struct sk_buff *skb, const struct xt_match_param *par)if (test_bit (IPS_DST_NAT_BIT , &ct->status)) statebit |=XT_CONNTRACK_STATE_DNAT ; } -if (!!(info->state_mask & statebit) ^ +if (!!(state_mask & statebit) ^ !(info->invert_flags &XT_CONNTRACK_STATE ))return false; }
@@ -172,7 +173,7 @@ conntrack_mt(const struct sk_buff *skb, const struct xt_match_param *par)return false;if ((info->match_flags &XT_CONNTRACK_STATUS ) && - (!!(info->status_mask & ct->status) ^ + (!!(status_mask & ct->status) ^ !(info->invert_flags &XT_CONNTRACK_STATUS )))return false;
@@ -192,11 +193,17 @@ conntrack_mt(const struct sk_buff *skb, const struct xt_match_param *par)static bool conntrack_mt_v1 (const struct sk_buff *skb,const struct xt_match_param *par) { -const struct xt_conntrack_mtinfo2 *const *info = par->matchinfo; -struct xt_match_param newpar = *par; +const struct xt_conntrack_mtinfo1 *info = par->matchinfo; - newpar.matchinfo = *info; -return conntrack_mt (skb, &newpar); +return conntrack_mt (skb, par, info->state_mask, info->status_mask); +} + +static bool +conntrack_mt_v2 (const struct sk_buff *skb,const struct xt_match_param *par) +{ +const struct xt_conntrack_mtinfo2 *info = par->matchinfo; + +return conntrack_mt (skb, par, info->state_mask, info->status_mask); }static bool conntrack_mt_check (const struct xt_mtchk_param *par)
@@ -209,45 +216,11 @@ static bool conntrack_mt_check(const struct xt_mtchk_param *par)return true; } -static bool conntrack_mt_check_v1 (const struct xt_mtchk_param *par) -{ -struct xt_conntrack_mtinfo1 *info = par->matchinfo; -struct xt_conntrack_mtinfo2 *up; -int ret =conntrack_mt_check (par); - -if (ret <0 ) -return ret; - - up =kmalloc (sizeof (*up),GFP_KERNEL ); -if (up ==NULL ) { -nf_ct_l3proto_module_put (par->family); -return -ENOMEM ; - } - -/* -* The strategy here is to minimize the overhead of v1 matching, -* by prebuilding a v2 struct and putting the pointer into the -* v1 dataspace. -*/ - memcpy(up, info, offsetof(typeof(*info), state_mask)); - up->state_mask = info->state_mask; - up->status_mask = info->status_mask; - *(void **)info = up; -return true; -} -static void conntrack_mt_destroy (const struct xt_mtdtor_param *par) {nf_ct_l3proto_module_put (par->family); } -static void conntrack_mt_destroy_v1 (const struct xt_mtdtor_param *par) -{ -struct xt_conntrack_mtinfo2 **info = par->matchinfo; -kfree (*info); -conntrack_mt_destroy (par); -} -static struct xt_match conntrack_mt_reg[]__read_mostly = { { .name ="conntrack" ,
@@ -255,8 +228,8 @@ static struct xt_match conntrack_mt_reg[] __read_mostly = { .family = NFPROTO_UNSPEC, .matchsize = sizeof(struct xt_conntrack_mtinfo1), .match = conntrack_mt_v1, - .checkentry = conntrack_mt_check_v1, - .destroy = conntrack_mt_destroy_v1, + .checkentry = conntrack_mt_check, + .destroy = conntrack_mt_destroy, .me = THIS_MODULE, }, {
@@ -264,7 +237,7 @@ static struct xt_match conntrack_mt_reg[] __read_mostly = { .revision = 2, .family = NFPROTO_UNSPEC, .matchsize = sizeof(struct xt_conntrack_mtinfo2), - .match = conntrack_mt, + .match = conntrack_mt_v2, .checkentry = conntrack_mt_check, .destroy = conntrack_mt_destroy, .me = THIS_MODULE,
netfilter 08/08: net/ipv[46]/netfilter: Move && and || to end of previous line
In reply to Patrick McHardycommit 3666ed1c4837fd6906da0224c5373d7a2186a193
Author: Joe Perches <[email protected]> Date: Mon Nov 23 23:17:06 2009 +0100
netfilter: net/ipv[46]/netfilter: Move && and || to end of previous line
Compile tested only.
net/ipv4/netfilter/arp_tables.c +11 -11
@@ -384,11 +384,11 @@ static int mark_source_chains(struct xt_table_info *newinfo, |= ((1 << hook) | (1 << NF_ARP_NUMHOOKS));/* Unconditional return/END. */ -if ((e->target_offset ==sizeof (struct arpt_entry ) - && (strcmp (t->target.u.user.name, -ARPT_STANDARD_TARGET ) ==0 ) - && t->verdict <0 - &&unconditional (&e->arp)) || visited) { +if ((e->target_offset ==sizeof (struct arpt_entry ) && + (strcmp (t->target.u.user.name, +ARPT_STANDARD_TARGET ) ==0 ) && + t->verdict <0 &&unconditional (&e->arp)) || + visited) {unsigned int oldpos, size; if ((strcmp(t->target.u.user.name,
@@ -427,8 +427,8 @@ static int mark_source_chains(struct xt_table_info *newinfo,int newpos = t->verdict;if (strcmp (t->target.u.user.name, -ARPT_STANDARD_TARGET ) ==0 - && newpos >=0 ) { +ARPT_STANDARD_TARGET ) ==0 && + newpos >=0 ) {if (newpos > newinfo->size -sizeof (struct arpt_entry )) { duprintf("mark_source_chains: "
@@ -559,8 +559,8 @@ static inline int check_entry_size_and_hooks(struct arpt_entry *e, {unsigned int h; -if ((unsigned long )e % __alignof__(struct arpt_entry ) !=0 - || (unsigned char *)e +sizeof (struct arpt_entry ) >= limit) { +if ((unsigned long )e % __alignof__(struct arpt_entry ) !=0 || + (unsigned char *)e +sizeof (struct arpt_entry ) >= limit) {duprintf ("Bad offset %p\n" , e);return -EINVAL ; }
@@ -1251,8 +1251,8 @@ check_compat_entry_size_and_hooks(struct compat_arpt_entry *e,int ret, off, h;duprintf ("check_compat_entry_size_and_hooks %p\n" , e); -if ((unsigned long )e % __alignof__(struct compat_arpt_entry ) !=0 - || (unsigned char *)e +sizeof (struct compat_arpt_entry ) >= limit) { +if ((unsigned long )e % __alignof__(struct compat_arpt_entry ) !=0 || + (unsigned char *)e +sizeof (struct compat_arpt_entry ) >= limit) {duprintf ("Bad offset %p, limit = %p\n" , e, limit);return -EINVAL ; }
net/ipv4/netfilter/ip_tables.c +23 -23
94 lines not on this page · raw message
net/ipv4/netfilter/ipt_CLUSTERIP.c +10 -10
@@ -303,9 +303,9 @@ clusterip_tg(struct sk_buff *skb, const struct xt_target_param *par)/* special case: ICMP error handling. conntrack distinguishes between * error messages (RELATED) and information requests (see below) */ -if (ip_hdr (skb)->protocol ==IPPROTO_ICMP - && (ctinfo ==IP_CT_RELATED - || ctinfo ==IP_CT_RELATED +IP_CT_IS_REPLY )) +if (ip_hdr (skb)->protocol ==IPPROTO_ICMP && + (ctinfo ==IP_CT_RELATED || + ctinfo ==IP_CT_RELATED +IP_CT_IS_REPLY ))return XT_CONTINUE ;/* ip_conntrack_icmp guarantees us that we only have ICMP_ECHO,
@@ -362,8 +362,8 @@ static bool clusterip_tg_check(const struct xt_tgchk_param *par)return false; } -if (e->ip.dmsk.s_addr !=htonl (0xffffffff ) - || e->ip.dst.s_addr ==0 ) { +if (e->ip.dmsk.s_addr !=htonl (0xffffffff ) || + e->ip.dst.s_addr ==0 ) {printk (KERN_ERR "CLUSTERIP: Please specify destination IP\n" );return false; }
@@ -495,14 +495,14 @@ arp_mangle(unsigned int hook,struct clusterip_config *c;/* we don't care about non-ethernet and non-ipv4 ARP */ -if (arp->ar_hrd !=htons (ARPHRD_ETHER ) - || arp->ar_pro !=htons (ETH_P_IP ) - || arp->ar_pln !=4 || arp->ar_hln !=ETH_ALEN ) +if (arp->ar_hrd !=htons (ARPHRD_ETHER ) || + arp->ar_pro !=htons (ETH_P_IP ) || + arp->ar_pln !=4 || arp->ar_hln !=ETH_ALEN )return NF_ACCEPT ;/* we only want to mangle arp requests and replies */ -if (arp->ar_op !=htons (ARPOP_REPLY ) - && arp->ar_op !=htons (ARPOP_REQUEST )) +if (arp->ar_op !=htons (ARPOP_REPLY ) && + arp->ar_op !=htons (ARPOP_REQUEST ))return NF_ACCEPT ; payload = (void *)(arp+1 );
net/ipv4/netfilter/ipt_ECN.c +4 -4
@@ -85,8 +85,8 @@ ecn_tg(struct sk_buff *skb, const struct xt_target_param *par)if (!set_ect_ip (skb, einfo))return NF_DROP ; -if (einfo->operation & (IPT_ECN_OP_SET_ECE |IPT_ECN_OP_SET_CWR ) - &&ip_hdr (skb)->protocol ==IPPROTO_TCP ) +if (einfo->operation & (IPT_ECN_OP_SET_ECE |IPT_ECN_OP_SET_CWR ) && +ip_hdr (skb)->protocol ==IPPROTO_TCP )if (!set_ect_tcp (skb, einfo))return NF_DROP ;
@@ -108,8 +108,8 @@ static bool ecn_tg_check(const struct xt_tgchk_param *par) einfo->ip_ect);return false; } -if ((einfo->operation & (IPT_ECN_OP_SET_ECE |IPT_ECN_OP_SET_CWR )) - && (e->ip.proto !=IPPROTO_TCP || (e->ip.invflags &XT_INV_PROTO ))) { +if ((einfo->operation & (IPT_ECN_OP_SET_ECE |IPT_ECN_OP_SET_CWR )) && + (e->ip.proto !=IPPROTO_TCP || (e->ip.invflags &XT_INV_PROTO ))) {printk (KERN_WARNING "ECN: cannot use TCP operations on a " "non-tcp rule\n" );return false;
net/ipv4/netfilter/ipt_LOG.c +11 -11
@@ -74,8 +74,8 @@ static void dump_packet(const struct nf_loginfo *info,if (ntohs (ih->frag_off) &IP_OFFSET )printk ("FRAG:%u " ,ntohs (ih->frag_off) &IP_OFFSET ); -if ((logflags &IPT_LOG_IPOPT ) - && ih->ihl *4 >sizeof (struct iphdr )) { +if ((logflags &IPT_LOG_IPOPT ) && + ih->ihl *4 >sizeof (struct iphdr )) {const unsigned char *op;unsigned char _opt[4 *15 -sizeof (struct iphdr )];unsigned int i, optsize;
@@ -146,8 +146,8 @@ static void dump_packet(const struct nf_loginfo *info,/* Max length: 11 "URGP=65535 " */ printk ("URGP=%u " ,ntohs (th->urg_ptr)); -if ((logflags &IPT_LOG_TCPOPT ) - && th->doff *4 >sizeof (struct tcphdr )) { +if ((logflags &IPT_LOG_TCPOPT ) && + th->doff *4 >sizeof (struct tcphdr )) {unsigned char _opt[4 *15 -sizeof (struct tcphdr )];const unsigned char *op;unsigned int i, optsize;
@@ -238,9 +238,9 @@ static void dump_packet(const struct nf_loginfo *info,printk ("TYPE=%u CODE=%u " , ich->type, ich->code);/* Max length: 25 "INCOMPLETE [65535 bytes] " */ -if (ich->type <=NR_ICMP_TYPES - && required_len[ich->type] - && skb->len-iphoff-ih->ihl*4 < required_len[ich->type]) { +if (ich->type <=NR_ICMP_TYPES && + required_len[ich->type] && + skb->len-iphoff-ih->ihl*4 < required_len[ich->type]) {printk ("INCOMPLETE [%u bytes] " , skb->len - iphoff - ih->ihl*4 );break ;
@@ -276,8 +276,8 @@ static void dump_packet(const struct nf_loginfo *info, }/* Max length: 10 "MTU=65535 " */ -if (ich->type ==ICMP_DEST_UNREACH - && ich->code ==ICMP_FRAG_NEEDED ) +if (ich->type ==ICMP_DEST_UNREACH && + ich->code ==ICMP_FRAG_NEEDED )printk ("MTU=%u " ,ntohs (ich->un.frag.mtu)); }break ;
@@ -407,8 +407,8 @@ ipt_log_packet(u_int8_t pf,if (in && !out) {/* MAC logging for input chain only. */ printk ("MAC=" ); -if (skb->dev && skb->dev->hard_header_len - && skb->mac_header != skb->network_header) { +if (skb->dev && skb->dev->hard_header_len && + skb->mac_header != skb->network_header) {int i;const unsigned char *p =skb_mac_header (skb);for (i =0 ; i < skb->dev->hard_header_len; i++,p++)
net/ipv4/netfilter/ipt_MASQUERADE.c +2 -2
@@ -59,8 +59,8 @@ masquerade_tg(struct sk_buff *skb, const struct xt_target_param *par) ct =nf_ct_get (skb, &ctinfo); nat =nfct_nat (ct); -NF_CT_ASSERT (ct && (ctinfo ==IP_CT_NEW || ctinfo ==IP_CT_RELATED - || ctinfo ==IP_CT_RELATED +IP_CT_IS_REPLY )); +NF_CT_ASSERT (ct && (ctinfo ==IP_CT_NEW || ctinfo ==IP_CT_RELATED || + ctinfo ==IP_CT_RELATED +IP_CT_IS_REPLY ));/* Source address is 0.0.0.0 - locally generated packet that is * probably not supposed to be masqueraded.
net/ipv4/netfilter/ipt_REJECT.c +2 -2
@@ -184,8 +184,8 @@ static bool reject_tg_check(const struct xt_tgchk_param *par)return false; }else if (rejinfo->with ==IPT_TCP_RESET ) {/* Must specify that it's a TCP packet */ -if (e->ip.proto !=IPPROTO_TCP - || (e->ip.invflags &XT_INV_PROTO )) { +if (e->ip.proto !=IPPROTO_TCP || + (e->ip.invflags &XT_INV_PROTO )) {printk ("ipt_REJECT: TCP_RESET invalid for non-tcp\n" );return false; }
net/ipv4/netfilter/ipt_ULOG.c +3 -3
@@ -226,9 +226,9 @@ static void ipt_ulog_packet(unsigned int hooknum,else *(pm->prefix) ='\0' ; -if (in && in->hard_header_len >0 - && skb->mac_header != skb->network_header - && in->hard_header_len <=ULOG_MAC_LEN ) { +if (in && in->hard_header_len >0 && + skb->mac_header != skb->network_header && + in->hard_header_len <=ULOG_MAC_LEN ) {memcpy (pm->mac,skb_mac_header (skb), in->hard_header_len); pm->mac_len = in->hard_header_len; }else
net/ipv4/netfilter/ipt_ecn.c +2 -2
@@ -96,8 +96,8 @@ static bool ecn_mt_check(const struct xt_mtchk_param *par)if (info->invert &IPT_ECN_OP_MATCH_MASK )return false; -if (info->operation & (IPT_ECN_OP_MATCH_ECE |IPT_ECN_OP_MATCH_CWR ) - && ip->proto !=IPPROTO_TCP ) { +if (info->operation & (IPT_ECN_OP_MATCH_ECE |IPT_ECN_OP_MATCH_CWR ) && + ip->proto !=IPPROTO_TCP ) {printk (KERN_WARNING "ipt_ecn: can't match TCP bits in rule for" " non-tcp packets\n" );return false;
net/ipv4/netfilter/iptable_mangle.c +2 -2
@@ -130,8 +130,8 @@ ipt_local_hook(unsigned int hook,u_int32_t mark;/* root is playing with raw sockets. */ -if (skb->len <sizeof (struct iphdr ) - ||ip_hdrlen (skb) <sizeof (struct iphdr )) +if (skb->len <sizeof (struct iphdr ) || +ip_hdrlen (skb) <sizeof (struct iphdr ))return NF_ACCEPT ;/* Save things which could affect route */
net/ipv4/netfilter/iptable_security.c +2 -2
@@ -94,8 +94,8 @@ ipt_local_out_hook(unsigned int hook, int (*okfn)(struct sk_buff *)) {/* Somebody is playing with raw sockets. */ -if (skb->len <sizeof (struct iphdr ) - ||ip_hdrlen (skb) <sizeof (struct iphdr )) +if (skb->len <sizeof (struct iphdr ) || +ip_hdrlen (skb) <sizeof (struct iphdr ))return NF_ACCEPT ;return ipt_do_table (skb, hook, in, out,dev_net (out)->ipv4.iptable_security);
net/ipv4/netfilter/nf_conntrack_proto_icmp.c +14 -14
@@ -54,8 +54,8 @@ static const u_int8_t invmap[] = {static bool icmp_invert_tuple (struct nf_conntrack_tuple *tuple,const struct nf_conntrack_tuple *orig) { -if (orig->dst.u.icmp.type >=sizeof (invmap) - || !invmap[orig->dst.u.icmp.type]) +if (orig->dst.u.icmp.type >=sizeof (invmap) || + !invmap[orig->dst.u.icmp.type])return false; tuple->src.u.icmp.id = orig->src.u.icmp.id;
@@ -101,8 +101,8 @@ static bool icmp_new(struct nf_conn *ct, const struct sk_buff *skb, [ICMP_ADDRESS] = 1 }; -if (ct->tuplehash[0 ].tuple.dst.u.icmp.type >=sizeof (valid_new) - || !valid_new[ct->tuplehash[0 ].tuple.dst.u.icmp.type]) { +if (ct->tuplehash[0 ].tuple.dst.u.icmp.type >=sizeof (valid_new) || + !valid_new[ct->tuplehash[0 ].tuple.dst.u.icmp.type]) {/* Can't create a new ICMP `conn' with this. */ pr_debug ("icmp: can't create new conn with type %u\n" , ct->tuplehash[0 ].tuple.dst.u.icmp.type);
@@ -201,11 +201,11 @@ icmp_error(struct net *net, struct sk_buff *skb, unsigned int dataoff, }/* Need to track icmp error message? */ -if (icmph->type !=ICMP_DEST_UNREACH - && icmph->type !=ICMP_SOURCE_QUENCH - && icmph->type !=ICMP_TIME_EXCEEDED - && icmph->type !=ICMP_PARAMETERPROB - && icmph->type !=ICMP_REDIRECT ) +if (icmph->type !=ICMP_DEST_UNREACH && + icmph->type !=ICMP_SOURCE_QUENCH && + icmph->type !=ICMP_TIME_EXCEEDED && + icmph->type !=ICMP_PARAMETERPROB && + icmph->type !=ICMP_REDIRECT )return NF_ACCEPT ;return icmp_error_message (net, skb, ctinfo, hooknum);
@@ -238,17 +238,17 @@ static const struct nla_policy icmp_nla_policy[CTA_PROTO_MAX+1] = {static int icmp_nlattr_to_tuple (struct nlattr *tb[],struct nf_conntrack_tuple *tuple) { -if (!tb[CTA_PROTO_ICMP_TYPE ] - || !tb[CTA_PROTO_ICMP_CODE ] - || !tb[CTA_PROTO_ICMP_ID ]) +if (!tb[CTA_PROTO_ICMP_TYPE ] || + !tb[CTA_PROTO_ICMP_CODE ] || + !tb[CTA_PROTO_ICMP_ID ])return -EINVAL ; tuple->dst.u.icmp.type =nla_get_u8 (tb[CTA_PROTO_ICMP_TYPE ]); tuple->dst.u.icmp.code =nla_get_u8 (tb[CTA_PROTO_ICMP_CODE ]); tuple->src.u.icmp.id =nla_get_be16 (tb[CTA_PROTO_ICMP_ID ]); -if (tuple->dst.u.icmp.type >=sizeof (invmap) - || !invmap[tuple->dst.u.icmp.type]) +if (tuple->dst.u.icmp.type >=sizeof (invmap) || + !invmap[tuple->dst.u.icmp.type])return -EINVAL ;return 0 ;
net/ipv4/netfilter/nf_nat_standalone.c +5 -5
@@ -197,11 +197,11 @@ nf_nat_out(unsigned int hooknum, (ct = nf_ct_get(skb, &ctinfo)) != NULL) {enum ip_conntrack_dir dir =CTINFO2DIR (ctinfo); -if (ct->tuplehash[dir].tuple.src.u3.ip != - ct->tuplehash[!dir].tuple.dst.u3.ip - || ct->tuplehash[dir].tuple.src.u.all != - ct->tuplehash[!dir].tuple.dst.u.all - ) +if ((ct->tuplehash[dir].tuple.src.u3.ip != + ct->tuplehash[!dir].tuple.dst.u3.ip) || + (ct->tuplehash[dir].tuple.src.u.all != + ct->tuplehash[!dir].tuple.dst.u.all) + )return ip_xfrm_me_harder (skb) ==0 ? ret :NF_DROP ; }#endif
net/ipv6/netfilter/ip6_tables.c +21 -21
84 lines not on this page · raw message
net/ipv6/netfilter/ip6t_LOG.c +2 -2
@@ -249,8 +249,8 @@ static void dump_packet(const struct nf_loginfo *info,/* Max length: 11 "URGP=65535 " */ printk ("URGP=%u " ,ntohs (th->urg_ptr)); -if ((logflags &IP6T_LOG_TCPOPT ) - && th->doff *4 >sizeof (struct tcphdr )) { +if ((logflags &IP6T_LOG_TCPOPT ) && + th->doff *4 >sizeof (struct tcphdr )) {u_int8_t _opt[60 -sizeof (struct tcphdr )];const u_int8_t *op;unsigned int i;
net/ipv6/netfilter/ip6t_REJECT.c +2 -2
@@ -223,8 +223,8 @@ static bool reject_tg6_check(const struct xt_tgchk_param *par)return false; }else if (rejinfo->with ==IP6T_TCP_RESET ) {/* Must specify that it's a TCP packet */ -if (e->ipv6.proto !=IPPROTO_TCP - || (e->ipv6.invflags &XT_INV_PROTO )) { +if (e->ipv6.proto !=IPPROTO_TCP || + (e->ipv6.invflags &XT_INV_PROTO )) {printk ("ip6t_REJECT: TCP_RESET illegal for non-tcp\n" );return false; }
net/ipv6/netfilter/ip6t_ah.c +8 -11
@@ -77,17 +77,14 @@ static bool ah_mt6(const struct sk_buff *skb, const struct xt_match_param *par) ahinfo->hdrres, ah->reserved, !(ahinfo->hdrres && ah->reserved)); -return (ah !=NULL ) - && -spi_match (ahinfo->spis[0 ], ahinfo->spis[1 ], -ntohl (ah->spi), - !!(ahinfo->invflags &IP6T_AH_INV_SPI )) - && - (!ahinfo->hdrlen || - (ahinfo->hdrlen == hdrlen) ^ - !!(ahinfo->invflags &IP6T_AH_INV_LEN )) - && - !(ahinfo->hdrres && ah->reserved); +return (ah !=NULL ) && +spi_match (ahinfo->spis[0 ], ahinfo->spis[1 ], +ntohl (ah->spi), + !!(ahinfo->invflags &IP6T_AH_INV_SPI )) && + (!ahinfo->hdrlen || + (ahinfo->hdrlen == hdrlen) ^ + !!(ahinfo->invflags &IP6T_AH_INV_LEN )) && + !(ahinfo->hdrres && ah->reserved); }static bool ah_mt6_check (const struct xt_mtchk_param *par)
net/ipv6/netfilter/ip6t_frag.c +21 -26
62 lines not on this page · raw message
net/ipv6/netfilter/ip6t_rt.c +3 -6
@@ -92,16 +92,13 @@ static bool rt_mt6(const struct sk_buff *skb, const struct xt_match_param *par) !((rtinfo->flags &IP6T_RT_RES ) && (((const struct rt0_hdr *)rh)->reserved))); - ret = (rh !=NULL ) - && + ret = (rh !=NULL ) && (segsleft_match (rtinfo->segsleft[0 ], rtinfo->segsleft[1 ], rh->segments_left, - !!(rtinfo->invflags &IP6T_RT_INV_SGS ))) - && + !!(rtinfo->invflags &IP6T_RT_INV_SGS ))) && (!(rtinfo->flags &IP6T_RT_LEN ) || ((rtinfo->hdrlen == hdrlen) ^ - !!(rtinfo->invflags &IP6T_RT_INV_LEN ))) - && + !!(rtinfo->invflags &IP6T_RT_INV_LEN ))) && (!(rtinfo->flags &IP6T_RT_TYP ) || ((rtinfo->rt_type == rh->type) ^ !!(rtinfo->invflags &IP6T_RT_INV_TYP )));
net/ipv6/netfilter/ip6table_filter.c +2 -2
@@ -79,8 +79,8 @@ ip6t_local_out_hook(unsigned int hook, {#if 0 /* root is playing with raw sockets. */ -if (skb->len <sizeof (struct iphdr ) - ||ip_hdrlen (skb) <sizeof (struct iphdr )) { +if (skb->len <sizeof (struct iphdr ) || +ip_hdrlen (skb) <sizeof (struct iphdr )) {if (net_ratelimit ())printk ("ip6t_hook: happy cracking.\n" );return NF_ACCEPT ;
net/ipv6/netfilter/ip6table_mangle.c +7 -7
@@ -102,8 +102,8 @@ ip6t_local_out_hook(unsigned int hook,#if 0 /* root is playing with raw sockets. */ -if (skb->len <sizeof (struct iphdr ) - ||ip_hdrlen (skb) <sizeof (struct iphdr )) { +if (skb->len <sizeof (struct iphdr ) || +ip_hdrlen (skb) <sizeof (struct iphdr )) {if (net_ratelimit ())printk ("ip6t_hook: happy cracking.\n" );return NF_ACCEPT ;
@@ -122,11 +122,11 @@ ip6t_local_out_hook(unsigned int hook, ret =ip6t_do_table (skb, hook, in, out,dev_net (out)->ipv6.ip6table_mangle); -if (ret !=NF_DROP && ret !=NF_STOLEN - && (memcmp (&ipv6_hdr (skb)->saddr, &saddr,sizeof (saddr)) - ||memcmp (&ipv6_hdr (skb)->daddr, &daddr,sizeof (daddr)) - || skb->mark != mark - ||ipv6_hdr (skb)->hop_limit != hop_limit)) +if (ret !=NF_DROP && ret !=NF_STOLEN && + (memcmp (&ipv6_hdr (skb)->saddr, &saddr,sizeof (saddr)) || +memcmp (&ipv6_hdr (skb)->daddr, &daddr,sizeof (daddr)) || + skb->mark != mark || +ipv6_hdr (skb)->hop_limit != hop_limit))return ip6_route_me_harder (skb) ==0 ? ret :NF_DROP ;return ret;
net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c +6 -6
@@ -244,18 +244,18 @@ static const struct nla_policy icmpv6_nla_policy[CTA_PROTO_MAX+1] = {static int icmpv6_nlattr_to_tuple (struct nlattr *tb[],struct nf_conntrack_tuple *tuple) { -if (!tb[CTA_PROTO_ICMPV6_TYPE ] - || !tb[CTA_PROTO_ICMPV6_CODE ] - || !tb[CTA_PROTO_ICMPV6_ID ]) +if (!tb[CTA_PROTO_ICMPV6_TYPE ] || + !tb[CTA_PROTO_ICMPV6_CODE ] || + !tb[CTA_PROTO_ICMPV6_ID ])return -EINVAL ; tuple->dst.u.icmp.type =nla_get_u8 (tb[CTA_PROTO_ICMPV6_TYPE ]); tuple->dst.u.icmp.code =nla_get_u8 (tb[CTA_PROTO_ICMPV6_CODE ]); tuple->src.u.icmp.id =nla_get_be16 (tb[CTA_PROTO_ICMPV6_ID ]); -if (tuple->dst.u.icmp.type <128 - || tuple->dst.u.icmp.type -128 >=sizeof (invmap) - || !invmap[tuple->dst.u.icmp.type -128 ]) +if (tuple->dst.u.icmp.type <128 || + tuple->dst.u.icmp.type -128 >=sizeof (invmap) || + !invmap[tuple->dst.u.icmp.type -128 ])return -EINVAL ;return 0 ;
David Miller
maintainerFrom: Patrick McHardy <[email protected]>
Date: Thu, 3 Dec 2009 21:19:32 +0100 (MET)
Quoted 1 line
following is a small netfilter update for 2.6.32, containing:
2.6.32 was just released, surely you mean 2.6.33 :-)
David Miller
maintainerFrom: Patrick McHardy <[email protected]>
Date: Thu, 3 Dec 2009 21:19:32 +0100 (MET)
Quoted 3 lines
Please apply or pull from:
git://git.kernel.org/pub/scm/linux/kernel/git/kaber/nf-next-2.6.gitmaster
Pulled, thanks.