: 2.6.15 netfilter update
Subsystems (3)
cover : 2.6.15 netfilter update
Hi Dave,
following are my queued netfilter patches for 2.6.15. Most notable is the ctnetlink port to nf_conntrack, besides that there are a number of cleanup patches and small fixes and three of the uncontroversial preparation patches from my IPsec patchset. The remaining IPsec patches will follow in the next days. Please apply, thanks.
Jesper Juhl:
[NETFILTER]: Decrease number of pointer derefs in nfnetlink_queue.c [NETFILTER]: Decrease number of pointer derefs in nf_conntrack_core.c
Pablo Neira Ayuso:
[NETFILTER]: ctnetlink: remove bogus checks in ICMP protocol at dumping [NETFILTER]: ctnetlink: propagate ctnetlink_dump_tuples_proto return value back [NETFILTER]: ctnetlink: use u_int32_t instead of unsigned int [NETFILTER]: ctnetlink: ctnetlink_event cleanup
[NETFILTER]: ctnetlink: fix conntrack mark race
[NETFILTER]: ctnetlink: remove unused variable
[NETFILTER]: Add ctnetlink port for nf_conntrack
[NETFILTER]: Filter dumped entries based on the layer 3 protocol number
Patrick McHardy:
[NETFILTER]: Fix module_param types and permissions [NETFILTER]: ctnetlink: Fix dumping of helper name [NETFILTER]: Remove okfn usage in ip_vs_core.c
[NETFILTER]: Call POST_ROUTING hook before fragmentation [NETFILTER]: Export ip6_masked_addrcmp, don't pass IPv6 addresses on stack [NETFILTER]: nf_conntrack_l3proto_ipv4.c needs net/route.h
Yasuyuki Kozakai:
[NETFILTER]: ctnetlink: Add sanity checkings for ICMP [NETFILTER]: make ipv6_find_hdr() find transport protocol header
PATCH 1/18 : Decrease number of pointer derefs in nfnetlink_queue.c
[NETFILTER]: Decrease number of pointer derefs in nfnetlink_queue.c
Benefits of the patch:
- Fewer pointer dereferences should make the code slightly faster.
- Size of generated code is smaller
- improved readability
---
commit d0fc264ffbc6c3886020dc2ef60d4aa1cecec51c
tree 5ff03f582e6f3e9f8e82e8032f4141cd8c9db727
parent 4f1291de22905b4c0c029dd6f682d2b7bf28b9c1
author Jesper Juhl <[email protected]> Thu, 05 Jan 2006 02:51:36 +0100 committer Patrick McHardy <[email protected]> Thu, 05 Jan 2006 02:51:36 +0100
net/netfilter/nfnetlink_queue.c | 79 ++++++++++++++++++++++----------------- 1 files changed, 44 insertions(+), 35 deletions(-)
net/netfilter/nfnetlink_queue.c +44 -35
@@ -345,6 +345,10 @@ nfqnl_build_packet_message(struct nfqnl_struct nfqnl_msg_packet_hdr pmsg;struct nlmsghdr *nlh;struct nfgenmsg *nfmsg; +struct nf_info *entinf = entry->info; +struct sk_buff *entskb = entry->skb; +struct net_device *indev; +struct net_device *outdev;unsigned int tmp_uint;QDEBUG ("entered\n" );
@@ -361,6 +365,8 @@ nfqnl_build_packet_message(struct nfqnl_ +NLMSG_SPACE (sizeof (struct nfqnl_msg_packet_hw )) +NLMSG_SPACE (sizeof (struct nfqnl_msg_packet_timestamp )); + outdev = entinf->outdev; +spin_lock_bh (&queue->lock);switch (queue->copy_mode) {
@@ -370,15 +376,15 @@ nfqnl_build_packet_message(struct nfqnl_break ;case NFQNL_COPY_PACKET : -if (entry->skb->ip_summed ==CHECKSUM_HW && - (*errp =skb_checksum_help (entry->skb, - entry->info->outdev ==NULL ))) { +if (entskb->ip_summed ==CHECKSUM_HW && + (*errp =skb_checksum_help (entskb, + outdev ==NULL ))) {spin_unlock_bh (&queue->lock);return NULL ; }if (queue->copy_range ==0 - || queue->copy_range > entry->skb->len) - data_len = entry->skb->len; + || queue->copy_range > entskb->len) + data_len = entskb->len;else data_len = queue->copy_range;
@@ -402,29 +408,30 @@ nfqnl_build_packet_message(struct nfqnl_NFNL_SUBSYS_QUEUE <<8 |NFQNL_MSG_PACKET , sizeof(struct nfgenmsg)); nfmsg =NLMSG_DATA (nlh); - nfmsg->nfgen_family = entry->info->pf; + nfmsg->nfgen_family = entinf->pf; nfmsg->version =NFNETLINK_V0 ; nfmsg->res_id =htons (queue->queue_num); pmsg.packet_id =htonl (entry->id); - pmsg.hw_protocol =htons (entry->skb->protocol); - pmsg.hook = entry->info->hook; + pmsg.hw_protocol =htons (entskb->protocol); + pmsg.hook = entinf->hook;NFA_PUT (skb,NFQA_PACKET_HDR ,sizeof (pmsg), &pmsg); -if (entry->info->indev) { - tmp_uint =htonl (entry->info->indev->ifindex); + indev = entinf->indev; +if (indev) { + tmp_uint =htonl (indev->ifindex);#ifndef CONFIG_BRIDGE_NETFILTER NFA_PUT (skb,NFQA_IFINDEX_INDEV ,sizeof (tmp_uint), &tmp_uint);#else -if (entry->info->pf ==PF_BRIDGE ) { +if (entinf->pf ==PF_BRIDGE ) {/* Case 1: indev is physical input device, we need to * look for bridge group (when called from * netfilter_bridge) */ NFA_PUT (skb,NFQA_IFINDEX_PHYSINDEV ,sizeof (tmp_uint), &tmp_uint);/* this is the bridge group "brX" */ - tmp_uint =htonl (entry->info->indev->br_port->br->dev->ifindex); + tmp_uint =htonl (indev->br_port->br->dev->ifindex);NFA_PUT (skb,NFQA_IFINDEX_INDEV ,sizeof (tmp_uint), &tmp_uint); }else {
@@ -432,9 +439,9 @@ nfqnl_build_packet_message(struct nfqnl_* physical device (when called from ipv4) */ NFA_PUT (skb,NFQA_IFINDEX_INDEV ,sizeof (tmp_uint), &tmp_uint); -if (entry->skb->nf_bridge - && entry->skb->nf_bridge->physindev) { - tmp_uint =htonl (entry->skb->nf_bridge->physindev->ifindex); +if (entskb->nf_bridge + && entskb->nf_bridge->physindev) { + tmp_uint =htonl (entskb->nf_bridge->physindev->ifindex);NFA_PUT (skb,NFQA_IFINDEX_PHYSINDEV ,sizeof (tmp_uint), &tmp_uint); }
@@ -442,19 +449,19 @@ nfqnl_build_packet_message(struct nfqnl_#endif } -if (entry->info->outdev) { - tmp_uint =htonl (entry->info->outdev->ifindex); +if (outdev) { + tmp_uint =htonl (outdev->ifindex);#ifndef CONFIG_BRIDGE_NETFILTER NFA_PUT (skb,NFQA_IFINDEX_OUTDEV ,sizeof (tmp_uint), &tmp_uint);#else -if (entry->info->pf ==PF_BRIDGE ) { +if (entinf->pf ==PF_BRIDGE ) {/* Case 1: outdev is physical output device, we need to * look for bridge group (when called from * netfilter_bridge) */ NFA_PUT (skb,NFQA_IFINDEX_PHYSOUTDEV ,sizeof (tmp_uint), &tmp_uint);/* this is the bridge group "brX" */ - tmp_uint =htonl (entry->info->outdev->br_port->br->dev->ifindex); + tmp_uint =htonl (outdev->br_port->br->dev->ifindex);NFA_PUT (skb,NFQA_IFINDEX_OUTDEV ,sizeof (tmp_uint), &tmp_uint); }else {
@@ -462,9 +469,9 @@ nfqnl_build_packet_message(struct nfqnl_* physical output device (when called from ipv4) */ NFA_PUT (skb,NFQA_IFINDEX_OUTDEV ,sizeof (tmp_uint), &tmp_uint); -if (entry->skb->nf_bridge - && entry->skb->nf_bridge->physoutdev) { - tmp_uint =htonl (entry->skb->nf_bridge->physoutdev->ifindex); +if (entskb->nf_bridge + && entskb->nf_bridge->physoutdev) { + tmp_uint =htonl (entskb->nf_bridge->physoutdev->ifindex);NFA_PUT (skb,NFQA_IFINDEX_PHYSOUTDEV ,sizeof (tmp_uint), &tmp_uint); }
@@ -472,27 +479,27 @@ nfqnl_build_packet_message(struct nfqnl_#endif } -if (entry->skb->nfmark) { - tmp_uint =htonl (entry->skb->nfmark); +if (entskb->nfmark) { + tmp_uint =htonl (entskb->nfmark);NFA_PUT (skb,NFQA_MARK ,sizeof (u_int32_t), &tmp_uint); } -if (entry->info->indev && entry->skb->dev - && entry->skb->dev->hard_header_parse) { +if (indev && entskb->dev + && entskb->dev->hard_header_parse) {struct nfqnl_msg_packet_hw phw; phw.hw_addrlen = - entry->skb->dev->hard_header_parse (entry->skb, + entskb->dev->hard_header_parse (entskb, phw.hw_addr); phw.hw_addrlen =htons (phw.hw_addrlen);NFA_PUT (skb,NFQA_HWADDR ,sizeof (phw), &phw); } -if (entry->skb->tstamp.off_sec) { +if (entskb->tstamp.off_sec) {struct nfqnl_msg_packet_timestamp ts; - ts.sec =cpu_to_be64 (entry->skb->tstamp.off_sec); - ts.usec =cpu_to_be64 (entry->skb->tstamp.off_usec); + ts.sec =cpu_to_be64 (entskb->tstamp.off_sec); + ts.usec =cpu_to_be64 (entskb->tstamp.off_usec);NFA_PUT (skb,NFQA_TIMESTAMP ,sizeof (ts), &ts); }
@@ -510,7 +517,7 @@ nfqnl_build_packet_message(struct nfqnl_ nfa->nfa_type =NFQA_PAYLOAD ; nfa->nfa_len = size; -if (skb_copy_bits (entry->skb,0 ,NFA_DATA (nfa), data_len)) +if (skb_copy_bits (entskb,0 ,NFA_DATA (nfa), data_len))BUG (); }
@@ -667,12 +674,14 @@ nfqnl_set_mode(struct nfqnl_instance *qustatic int dev_cmp (struct nfqnl_queue_entry *entry,unsigned long ifindex) { -if (entry->info->indev) -if (entry->info->indev->ifindex == ifindex) +struct nf_info *entinf = entry->info; + +if (entinf->indev) +if (entinf->indev->ifindex == ifindex)return 1 ; -if (entry->info->outdev) -if (entry->info->outdev->ifindex == ifindex) +if (entinf->outdev) +if (entinf->outdev->ifindex == ifindex)return 1 ;return 0 ;
PATCH 2/18 : Decrease number of pointer derefs in nf_conntrack_core.c
In reply to Patrick McHardy[NETFILTER]: Decrease number of pointer derefs in nf_conntrack_core.c
Benefits of the patch:
- Fewer pointer dereferences should make the code slightly faster.
- Size of generated code is smaller
- improved readability
---
commit 2cc96aa2efb6f3950c9a506eed4c7cab5d8de076
tree 6c418e18f4d385a8340381cd67cf82c62961fd24
parent d0fc264ffbc6c3886020dc2ef60d4aa1cecec51c
author Jesper Juhl <[email protected]> Thu, 05 Jan 2006 02:51:54 +0100 committer Patrick McHardy <[email protected]> Thu, 05 Jan 2006 02:51:54 +0100
net/netfilter/nf_conntrack_core.c | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-)
net/netfilter/nf_conntrack_core.c +4 -3
@@ -1129,6 +1129,7 @@ static inline int refresh_timer(struct nint nf_conntrack_expect_related (struct nf_conntrack_expect *expect) {struct nf_conntrack_expect *i; +struct nf_conn *master = expect->master;int ret;DEBUGP ("nf_conntrack_expect_related %p\n" , related_to);
@@ -1149,9 +1150,9 @@ int nf_conntrack_expect_related(struct n } }/* Will be over limit? */ -if (expect->master->helper->max_expected && - expect->master->expecting >= expect->master->helper->max_expected) -evict_oldest_expect (expect->master); +if (master->helper->max_expected && + master->expecting >= master->helper->max_expected) +evict_oldest_expect (master);nf_conntrack_expect_insert (expect);nf_conntrack_expect_event (IPEXP_NEW , expect);
PATCH 3/18 : ctnetlink: remove bogus checks in ICMP protocol at dumping
In reply to Patrick McHardy[NETFILTER]: ctnetlink: remove bogus checks in ICMP protocol at dumping
---
commit da3dc79a37546feb6572bff1a36b23830c799c58
tree dd6f197522094a1a9360f42454d7d0de23701ecd
parent 2cc96aa2efb6f3950c9a506eed4c7cab5d8de076
author Pablo Neira Ayuso <[email protected]> Thu, 05 Jan 2006 02:52:57 +0100 committer Patrick McHardy <[email protected]> Thu, 05 Jan 2006 02:52:57 +0100
net/ipv4/netfilter/ip_conntrack_proto_icmp.c | 4 ---- 1 files changed, 0 insertions(+), 4 deletions(-)
net/ipv4/netfilter/ip_conntrack_proto_icmp.c +0 -4
@@ -279,10 +279,6 @@ static int icmp_tuple_to_nfattr(struct sNFA_PUT (skb,CTA_PROTO_ICMP_CODE ,sizeof (u_int8_t), &t->dst.u.icmp.code); -if (t->dst.u.icmp.type >=sizeof (valid_new) - || !valid_new[t->dst.u.icmp.type]) -return -EINVAL ; -return 0 ; nfattr_failure:
PATCH 4/18 : ctnetlink: Add sanity checkings for ICMP
In reply to Patrick McHardy[NETFILTER]: ctnetlink: Add sanity checkings for ICMP
---
commit f067059d5e3d09c6679d860eb8c283df7f0f3420
tree 705f9f9add15dd8aff99e0ab45884c91af74348e
parent da3dc79a37546feb6572bff1a36b23830c799c58
author Yasuyuki Kozakai <[email protected]> Thu, 05 Jan 2006 02:54:00 +0100 committer Patrick McHardy <[email protected]> Thu, 05 Jan 2006 02:54:00 +0100
net/ipv4/netfilter/ip_conntrack_proto_icmp.c | 43 +++++++++++++++----------- 1 files changed, 24 insertions(+), 19 deletions(-)
net/ipv4/netfilter/ip_conntrack_proto_icmp.c +24 -19
@@ -47,20 +47,21 @@ static int icmp_pkt_to_tuple(const strucreturn 1 ; } +/* Add 1; spaces filled with 0. */ +static const u_int8_t invmap[] = { + [ICMP_ECHO ] =ICMP_ECHOREPLY +1 , + [ICMP_ECHOREPLY ] =ICMP_ECHO +1 , + [ICMP_TIMESTAMP ] =ICMP_TIMESTAMPREPLY +1 , + [ICMP_TIMESTAMPREPLY ] =ICMP_TIMESTAMP +1 , + [ICMP_INFO_REQUEST ] =ICMP_INFO_REPLY +1 , + [ICMP_INFO_REPLY ] =ICMP_INFO_REQUEST +1 , + [ICMP_ADDRESS ] =ICMP_ADDRESSREPLY +1 , + [ICMP_ADDRESSREPLY ] =ICMP_ADDRESS +1 +}; +static int icmp_invert_tuple (struct ip_conntrack_tuple *tuple,const struct ip_conntrack_tuple *orig) { -/* Add 1; spaces filled with 0. */ -static const u_int8_t invmap[] - = { [ICMP_ECHO ] =ICMP_ECHOREPLY +1 , - [ICMP_ECHOREPLY ] =ICMP_ECHO +1 , - [ICMP_TIMESTAMP ] =ICMP_TIMESTAMPREPLY +1 , - [ICMP_TIMESTAMPREPLY ] =ICMP_TIMESTAMP +1 , - [ICMP_INFO_REQUEST ] =ICMP_INFO_REPLY +1 , - [ICMP_INFO_REPLY ] =ICMP_INFO_REQUEST +1 , - [ICMP_ADDRESS ] =ICMP_ADDRESSREPLY +1 , - [ICMP_ADDRESSREPLY ] =ICMP_ADDRESS +1 }; -if (orig->dst.u.icmp.type >=sizeof (invmap) || !invmap[orig->dst.u.icmp.type])return 0 ;
@@ -110,17 +111,17 @@ static int icmp_packet(struct ip_conntrareturn NF_ACCEPT ; } -static const u_int8_t valid_new[] = { - [ICMP_ECHO ] =1 , - [ICMP_TIMESTAMP ] =1 , - [ICMP_INFO_REQUEST ] =1 , - [ICMP_ADDRESS ] =1 -}; -/* Called when a new connection for this protocol found. */ static int icmp_new (struct ip_conntrack *conntrack,const struct sk_buff *skb) { +static const u_int8_t valid_new[] = { + [ICMP_ECHO ] =1 , + [ICMP_TIMESTAMP ] =1 , + [ICMP_INFO_REQUEST ] =1 , + [ICMP_ADDRESS ] =1 + }; +if (conntrack->tuplehash[0 ].tuple.dst.u.icmp.type >=sizeof (valid_new) || !valid_new[conntrack->tuplehash[0 ].tuple.dst.u.icmp.type]) {/* Can't create a new ICMP `conn' with this. */
@@ -291,7 +292,7 @@ static int icmp_nfattr_to_tuple(struct nif (!tb[CTA_PROTO_ICMP_TYPE -1 ] || !tb[CTA_PROTO_ICMP_CODE -1 ] || !tb[CTA_PROTO_ICMP_ID -1 ]) -return -1 ; +return -EINVAL ; tuple->dst.u.icmp.type = *(u_int8_t *)NFA_DATA (tb[CTA_PROTO_ICMP_TYPE -1 ]);
@@ -300,6 +301,10 @@ static int icmp_nfattr_to_tuple(struct n tuple->src.u.icmp.id = *(u_int16_t *)NFA_DATA (tb[CTA_PROTO_ICMP_ID -1 ]); +if (tuple->dst.u.icmp.type >=sizeof (invmap) + || !invmap[tuple->dst.u.icmp.type]) +return -EINVAL ; + return 0; }#endif
PATCH 5/18 : ctnetlink: propagate ctnetlink_dump_tuples_proto return value back
In reply to Patrick McHardy[NETFILTER]: ctnetlink: propagate ctnetlink_dump_tuples_proto return value back
---
commit c1dbf7cb5f9690b9bb12dc0707278376760e4839
tree 52427c40ad1f88b57bde7aafb91c9ba2adb8d938
parent f067059d5e3d09c6679d860eb8c283df7f0f3420
author Pablo Neira Ayuso <[email protected]> Thu, 05 Jan 2006 02:54:30 +0100 committer Patrick McHardy <[email protected]> Thu, 05 Jan 2006 02:54:30 +0100
net/ipv4/netfilter/ip_conntrack_netlink.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-)
net/ipv4/netfilter/ip_conntrack_netlink.c +3 -2
@@ -79,6 +79,7 @@ ctnetlink_dump_tuples(struct sk_buff *sk const struct ip_conntrack_tuple *tuple) {struct nfattr *nest_parms; +int ret; nest_parms =NFA_NEST (skb,CTA_TUPLE_IP );NFA_PUT (skb,CTA_IP_V4_SRC ,sizeof (u_int32_t), &tuple->src.ip);
@@ -86,10 +87,10 @@ ctnetlink_dump_tuples(struct sk_buff *skNFA_NEST_END (skb, nest_parms); nest_parms =NFA_NEST (skb,CTA_TUPLE_PROTO ); -ctnetlink_dump_tuples_proto (skb, tuple); + ret =ctnetlink_dump_tuples_proto (skb, tuple);NFA_NEST_END (skb, nest_parms); -return 0 ; +return ret; nfattr_failure:return -1 ;
PATCH 6/18 : ctnetlink: use u_int32_t instead of unsigned int
In reply to Patrick McHardy[NETFILTER]: ctnetlink: use u_int32_t instead of unsigned int
---
commit 4cf0ebc33ac486730b4af5657f683673c25ee599
tree 084b7be976ae7aba4ce2707a66f76c01dff13431
parent c1dbf7cb5f9690b9bb12dc0707278376760e4839
author Pablo Neira Ayuso <[email protected]> Thu, 05 Jan 2006 02:54:58 +0100 committer Patrick McHardy <[email protected]> Thu, 05 Jan 2006 02:54:58 +0100
net/ipv4/netfilter/ip_conntrack_netlink.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
net/ipv4/netfilter/ip_conntrack_netlink.c +1 -1
@@ -230,7 +230,7 @@ nfattr_failure:static inline int ctnetlink_dump_use (struct sk_buff *skb,const struct ip_conntrack *ct) { -unsigned int use =htonl (atomic_read (&ct->ct_general.use)); +u_int32_t use =htonl (atomic_read (&ct->ct_general.use));NFA_PUT (skb,CTA_USE ,sizeof (u_int32_t), &use);return 0 ;
PATCH 7/18 : ctnetlink: ctnetlink_event cleanup
In reply to Patrick McHardy[NETFILTER]: ctnetlink: ctnetlink_event cleanup
Cleanup: Use 'else if' instead of a ugly 'goto' statement.
---
commit d1e28c10106f0f49384d3f4e4303a2944d977e86
tree a89a207ba2caa1d4cebda6e086c4d5c089cb9036
parent 4cf0ebc33ac486730b4af5657f683673c25ee599
author Pablo Neira Ayuso <[email protected]> Thu, 05 Jan 2006 02:55:15 +0100 committer Patrick McHardy <[email protected]> Thu, 05 Jan 2006 02:55:15 +0100
net/ipv4/netfilter/ip_conntrack_netlink.c | 15 ++++----------- 1 files changed, 4 insertions(+), 11 deletions(-)
net/ipv4/netfilter/ip_conntrack_netlink.c +4 -11
@@ -312,29 +312,22 @@ static int ctnetlink_conntrack_event(strif (events &IPCT_DESTROY ) { type =IPCTNL_MSG_CT_DELETE ; group =NFNLGRP_CONNTRACK_DESTROY ; - goto alloc_skb; - } -if (events & (IPCT_NEW |IPCT_RELATED )) { + }else if (events & (IPCT_NEW |IPCT_RELATED )) { type =IPCTNL_MSG_CT_NEW ; flags =NLM_F_CREATE |NLM_F_EXCL ;/* dump everything */ events = ~0UL ; group =NFNLGRP_CONNTRACK_NEW ; - goto alloc_skb; - } -if (events & (IPCT_STATUS | + }else if (events & (IPCT_STATUS |IPCT_PROTOINFO |IPCT_HELPER |IPCT_HELPINFO |IPCT_NATINFO )) { type =IPCTNL_MSG_CT_NEW ; group =NFNLGRP_CONNTRACK_UPDATE ; - goto alloc_skb; - } + }else +return NOTIFY_DONE ; -return NOTIFY_DONE ; - -alloc_skb:/* FIXME: Check if there are any listeners before, don't hurt performance */ skb =alloc_skb (NLMSG_GOODSIZE ,GFP_ATOMIC );
PATCH 8/18 : ctnetlink: fix conntrack mark race
In reply to Patrick McHardy[NETFILTER]: ctnetlink: fix conntrack mark race
Set conntrack mark before it is in hashes.
---
commit d83898b5b202d40e7ab16170143661d99b7f5a0e
tree ab89cb82ff71fdb801788aa5387f167c44b27c0f
parent d1e28c10106f0f49384d3f4e4303a2944d977e86
author Pablo Neira Ayuso <[email protected]> Thu, 05 Jan 2006 02:55:36 +0100 committer Patrick McHardy <[email protected]> Thu, 05 Jan 2006 02:55:36 +0100
net/ipv4/netfilter/ip_conntrack_netlink.c | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-)
net/ipv4/netfilter/ip_conntrack_netlink.c +5 -5
@@ -1031,6 +1031,11 @@ ctnetlink_create_conntrack(struct nfattrreturn err; } +#if defined(CONFIG_IP_NF_CONNTRACK_MARK ) +if (cda[CTA_MARK -1 ]) + ct->mark =ntohl (*(u_int32_t *)NFA_DATA (cda[CTA_MARK -1 ])); +#endif + ct->helper =ip_conntrack_helper_find_get (rtuple);add_timer (&ct->timeout);
@@ -1039,11 +1044,6 @@ ctnetlink_create_conntrack(struct nfattrif (ct->helper)ip_conntrack_helper_put (ct->helper); -#if defined(CONFIG_IP_NF_CONNTRACK_MARK ) -if (cda[CTA_MARK -1 ]) - ct->mark =ntohl (*(u_int32_t *)NFA_DATA (cda[CTA_MARK -1 ])); -#endif -DEBUGP ("conntrack with id %u inserted\n" , ct->id);return 0 ;
PATCH 9/18 : ctnetlink: remove unused variable
In reply to Patrick McHardy[NETFILTER]: ctnetlink: remove unused variable
---
commit 1227b054c63788ad08053b0af4435df9fb65a6bb
tree eade765b1c62946537e89d9030cb93b0d515ee2f
parent d83898b5b202d40e7ab16170143661d99b7f5a0e
author Pablo Neira Ayuso <[email protected]> Thu, 05 Jan 2006 02:55:55 +0100 committer Patrick McHardy <[email protected]> Thu, 05 Jan 2006 02:55:55 +0100
net/ipv4/netfilter/ip_conntrack_netlink.c | 2 -- 1 files changed, 0 insertions(+), 2 deletions(-)
net/ipv4/netfilter/ip_conntrack_netlink.c +0 -2
@@ -1203,7 +1203,6 @@ static int ctnetlink_expect_event(structunsigned int type;unsigned char *b;int flags =0 ; -u16 proto;if (events &IPEXP_NEW ) { type =IPCTNL_MSG_EXP_NEW ;
@@ -1230,7 +1229,6 @@ static int ctnetlink_expect_event(struct goto nfattr_failure; nlh->nlmsg_len = skb->tail - b; - proto = exp->tuple.dst.protonum;nfnetlink_send (skb,0 ,NFNLGRP_CONNTRACK_EXP_NEW ,0 );return NOTIFY_DONE ;
PATCH 10/18 : Add ctnetlink port for nf_conntrack
In reply to Patrick McHardy[NETFILTER]: Add ctnetlink port for nf_conntrack
---
commit 61f61d46374f12a54086fe865242a3f248961d6e
tree 30acfbd25e30f1c46b65a35f8cb8a119686f78a4
parent 1227b054c63788ad08053b0af4435df9fb65a6bb
author Pablo Neira Ayuso <[email protected]> Thu, 05 Jan 2006 02:56:59 +0100 committer Patrick McHardy <[email protected]> Thu, 05 Jan 2006 02:56:59 +0100
include/linux/netfilter/nfnetlink_conntrack.h | 3 include/net/netfilter/nf_conntrack.h | 31 include/net/netfilter/nf_conntrack_helper.h | 2 include/net/netfilter/nf_conntrack_l3proto.h | 15 include/net/netfilter/nf_conntrack_protocol.h | 26 net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c | 47 + net/ipv4/netfilter/nf_conntrack_proto_icmp.c | 97 + net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c | 47 + net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c | 77 + net/netfilter/Kconfig | 7 net/netfilter/Makefile | 3 net/netfilter/nf_conntrack_core.c | 232 +++ net/netfilter/nf_conntrack_netlink.c | 1642 ++++++++++++++++++++++++ net/netfilter/nf_conntrack_proto_tcp.c | 71 + net/netfilter/nf_conntrack_proto_udp.c | 10 net/netfilter/nf_conntrack_standalone.c | 42 - 16 files changed, 2289 insertions(+), 63 deletions(-)
include/linux/netfilter/nfnetlink_conntrack.h +3 -0
@@ -64,6 +64,9 @@ enum ctattr_l4proto {CTA_PROTO_ICMP_ID ,CTA_PROTO_ICMP_TYPE ,CTA_PROTO_ICMP_CODE , +CTA_PROTO_ICMPV6_ID , +CTA_PROTO_ICMPV6_TYPE , +CTA_PROTO_ICMPV6_CODE , __CTA_PROTO_MAX };#define CTA_PROTO_MAX (__CTA_PROTO_MAX - 1)
include/net/netfilter/nf_conntrack.h +31 -0
@@ -94,6 +94,9 @@ struct nf_conn/* Current number of expected connections */ unsigned int expecting; +/* Unique ID that identifies this conntrack*/ +unsigned int id; +/* Helper. if any */ struct nf_conntrack_helper *helper;
@@ -140,6 +143,9 @@ struct nf_conntrack_expect/* Usage count. */ atomic_t use; +/* Unique ID */ +unsigned int id; +/* Flags */ unsigned int flags;
@@ -190,6 +196,31 @@ static inline void nf_ct_put(struct nf_cnf_conntrack_put (&ct->ct_general); } +extern struct nf_conntrack_tuple_hash * +__nf_conntrack_find (const struct nf_conntrack_tuple *tuple, +const struct nf_conn *ignored_conntrack); + +extern void nf_conntrack_hash_insert (struct nf_conn *ct); + +extern struct nf_conntrack_expect * +__nf_conntrack_expect_find (const struct nf_conntrack_tuple *tuple); + +extern struct nf_conntrack_expect * +nf_conntrack_expect_find (const struct nf_conntrack_tuple *tuple); + +extern void nf_ct_unlink_expect (struct nf_conntrack_expect *exp); + +extern void nf_ct_remove_expectations (struct nf_conn *ct); + +extern void nf_conntrack_flush (void ); + +extern struct nf_conntrack_helper * +nf_ct_helper_find_get (const struct nf_conntrack_tuple *tuple); +extern void nf_ct_helper_put (struct nf_conntrack_helper *helper); + +extern struct nf_conntrack_helper * +__nf_conntrack_helper_find_byname (const char *name); +/* call to create an explicit dependency on nf_conntrack. */ extern void need_nf_conntrack (void );
include/net/netfilter/nf_conntrack_helper.h +2 -0
@@ -33,6 +33,8 @@ struct nf_conntrack_helperunsigned int protoff, struct nf_conn *ct, enum ip_conntrack_info conntrackinfo); + +int (*to_nfattr)(struct sk_buff *skb,const struct nf_conn *ct); };extern int nf_conntrack_helper_register (struct nf_conntrack_helper *);
include/net/netfilter/nf_conntrack_l3proto.h +14 -1
@@ -14,6 +14,8 @@#include <linux/seq_file.h> #include <net/netfilter/nf_conntrack.h> +struct nfattr ; +struct nf_conntrack_l3proto {/* Next pointer. */
@@ -70,6 +72,12 @@ struct nf_conntrack_l3protou_int32_t (*get_features)(const struct nf_conntrack_tuple *tuple); +int (*tuple_to_nfattr)(struct sk_buff *skb, +const struct nf_conntrack_tuple *t); + +int (*nfattr_to_tuple)(struct nfattr *tb[], +struct nf_conntrack_tuple *t); +/* Module (if any) which this is connected to. */ struct module *me; };
@@ -81,11 +89,16 @@ extern int nf_conntrack_l3proto_registerextern void nf_conntrack_l3proto_unregister (struct nf_conntrack_l3proto *proto);static inline struct nf_conntrack_l3proto * -nf_ct_find_l3proto (u_int16_t l3proto) +__nf_ct_l3proto_find (u_int16_t l3proto) {return nf_ct_l3protos[l3proto]; } +extern struct nf_conntrack_l3proto * +nf_ct_l3proto_find_get (u_int16_t l3proto); + +extern void nf_ct_l3proto_put (struct nf_conntrack_l3proto *p); +/* Existing built-in protocols */ extern struct nf_conntrack_l3proto nf_conntrack_l3proto_ipv4;extern struct nf_conntrack_l3proto nf_conntrack_l3proto_ipv6;
include/net/netfilter/nf_conntrack_protocol.h +25 -1
@@ -12,6 +12,7 @@#include <net/netfilter/nf_conntrack.h> struct seq_file ; +struct nfattr ;struct nf_conntrack_protocol {
@@ -66,6 +67,18 @@ struct nf_conntrack_protocolenum ip_conntrack_info *ctinfo, int pf, unsigned int hooknum); +/* convert protoinfo to nfnetink attributes */ +int (*to_nfattr)(struct sk_buff *skb,struct nfattr *nfa, +const struct nf_conn *ct); + +/* convert nfnetlink attributes to protoinfo */ +int (*from_nfattr)(struct nfattr *tb[],struct nf_conn *ct); + +int (*tuple_to_nfattr)(struct sk_buff *skb, +const struct nf_conntrack_tuple *t); +int (*nfattr_to_tuple)(struct nfattr *tb[], +struct nf_conntrack_tuple *t); +/* Module (if any) which this is connected to. */ struct module *me; };
@@ -80,12 +93,23 @@ extern struct nf_conntrack_protocol nf_cextern struct nf_conntrack_protocol **nf_ct_protos[PF_MAX ];extern struct nf_conntrack_protocol * -nf_ct_find_proto (u_int16_t l3proto,u_int8_t protocol); +__nf_ct_proto_find (u_int16_t l3proto,u_int8_t protocol); + +extern struct nf_conntrack_protocol * +nf_ct_proto_find_get (u_int16_t l3proto,u_int8_t protocol); + +extern void nf_ct_proto_put (struct nf_conntrack_protocol *p);/* Protocol registration. */ extern int nf_conntrack_protocol_register (struct nf_conntrack_protocol *proto);extern void nf_conntrack_protocol_unregister (struct nf_conntrack_protocol *proto); +/* Generic netlink helpers */ +extern int nf_ct_port_tuple_to_nfattr (struct sk_buff *skb, +const struct nf_conntrack_tuple *tuple); +extern int nf_ct_port_nfattr_to_tuple (struct nfattr *tb[], +struct nf_conntrack_tuple *t); +/* Log invalid packets */ extern unsigned int nf_ct_log_invalid;
net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c +47 -0
59 lines not on this page · raw message
net/ipv4/netfilter/nf_conntrack_proto_icmp.c +79 -18
130 lines not on this page · raw message
net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c +47 -0
59 lines not on this page · raw message
net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c +68 -9
104 lines not on this page · raw message
net/netfilter/Kconfig +7 -0
@@ -95,4 +95,11 @@ config NF_CONNTRACK_FTP To compile it as a module, choose M here. If unsure, say N. +config NF_CT_NETLINK + tristate 'Connection tracking netlink interface (EXPERIMENTAL)' + depends on EXPERIMENTAL && NF_CONNTRACK && NETFILTER_NETLINK + depends on NF_CONNTRACK!=y || NETFILTER_NETLINK!=m + help + This option enables support for a netlink-based userspace interface + endmenu
net/netfilter/Makefile +3 -0
@@ -13,3 +13,6 @@ obj-$(CONFIG_NF_CONNTRACK_FTP) += nf_con # SCTP protocol connection tracking obj-$(CONFIG_NF_CT_PROTO_SCTP) += nf_conntrack_proto_sctp.o + +# netlink interface for nf_conntrack +obj-$(CONFIG_NF_CT_NETLINK) += nf_conntrack_netlink.o
net/netfilter/nf_conntrack_core.c +208 -24
390 lines not on this page · raw message
net/netfilter/nf_conntrack_netlink.c new file +1642 -0
1,642 lines not on this page · raw message
net/netfilter/nf_conntrack_proto_tcp.c +71 -0
89 lines not on this page · raw message
net/netfilter/nf_conntrack_proto_udp.c +10 -0
@@ -196,6 +196,11 @@ struct nf_conntrack_protocol nf_conntrac .packet = udp_packet, .new = udp_new, .error = udp_error4, +#if defined(CONFIG_NF_CT_NETLINK ) || \ + defined(CONFIG_NF_CT_NETLINK_MODULE ) + .tuple_to_nfattr = nf_ct_port_tuple_to_nfattr, + .nfattr_to_tuple = nf_ct_port_nfattr_to_tuple, +#endif }; struct nf_conntrack_protocol nf_conntrack_protocol_udp6 =
@@ -210,6 +215,11 @@ struct nf_conntrack_protocol nf_conntrac .packet = udp_packet, .new = udp_new, .error = udp_error6, +#if defined(CONFIG_NF_CT_NETLINK ) || \ + defined(CONFIG_NF_CT_NETLINK_MODULE ) + .tuple_to_nfattr = nf_ct_port_tuple_to_nfattr, + .nfattr_to_tuple = nf_ct_port_nfattr_to_tuple, +#endif };EXPORT_SYMBOL (nf_conntrack_protocol_udp4);
net/netfilter/nf_conntrack_standalone.c +32 -10
65 lines not on this page · raw message
PATCH 11/18 : Filter dumped entries based on the layer 3 protocol number
In reply to Patrick McHardy[NETFILTER]: Filter dumped entries based on the layer 3 protocol number
Dump entries of a given Layer 3 protocol number.
---
commit d5c7bf63c8ae6153ecdf70add3f5b935d4b088a1
tree 648df16ff36e9395298e7e9bcddfebf2e06b325e
parent 61f61d46374f12a54086fe865242a3f248961d6e
author Pablo Neira Ayuso <[email protected]> Thu, 05 Jan 2006 02:58:02 +0100 committer Patrick McHardy <[email protected]> Thu, 05 Jan 2006 02:58:02 +0100
net/netfilter/nf_conntrack_netlink.c | 23 +++++++++++++++++------ 1 files changed, 17 insertions(+), 6 deletions(-)
net/netfilter/nf_conntrack_netlink.c +17 -6
@@ -400,6 +400,8 @@ static int ctnetlink_done(struct netlinkreturn 0 ; } +#define L3PROTO (ct) ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.l3num +static int ctnetlink_dump_table (struct sk_buff *skb,struct netlink_callback *cb) {
@@ -407,6 +409,8 @@ ctnetlink_dump_table(struct sk_buff *skbstruct nf_conntrack_tuple_hash *h;struct list_head *i;u_int32_t *id = (u_int32_t *) &cb->args[1 ]; +struct nfgenmsg *nfmsg =NLMSG_DATA (cb->nlh); +u_int8_t l3proto = nfmsg->nfgen_family;DEBUGP ("entered %s, last bucket=%lu id=%u\n" , __FUNCTION__, cb->args[0 ], *id);
@@ -418,6 +422,11 @@ ctnetlink_dump_table(struct sk_buff *skbif (DIRECTION (h) !=IP_CT_DIR_ORIGINAL )continue ; ct =nf_ct_tuplehash_to_ctrack (h); +/* Dump entries of a given L3 protocol number. +* If it is not specified, ie. l3proto == 0, +* then dump everything. */ +if (l3proto &&L3PROTO (ct) != l3proto) +continue ;if (ct->id <= *id)continue ; if (ctnetlink_fill_info(skb, NETLINK_CB(cb->skb).pid,
@@ -444,6 +453,8 @@ ctnetlink_dump_table_w(struct sk_buff *sstruct nf_conntrack_tuple_hash *h;struct list_head *i;u_int32_t *id = (u_int32_t *) &cb->args[1 ]; +struct nfgenmsg *nfmsg =NLMSG_DATA (cb->nlh); +u_int8_t l3proto = nfmsg->nfgen_family;DEBUGP ("entered %s, last bucket=%u id=%u\n" , __FUNCTION__, cb->args[0 ], *id);
@@ -455,6 +466,8 @@ ctnetlink_dump_table_w(struct sk_buff *sif (DIRECTION (h) !=IP_CT_DIR_ORIGINAL )continue ; ct =nf_ct_tuplehash_to_ctrack (h); +if (l3proto &&L3PROTO (ct) != l3proto) +continue ;if (ct->id <= *id)continue ; if (ctnetlink_fill_info(skb, NETLINK_CB(cb->skb).pid,
@@ -750,9 +763,6 @@ ctnetlink_get_conntrack(struct sock *ctnif (nlh->nlmsg_flags &NLM_F_DUMP ) {u32 rlen; -if (nfmsg->nfgen_family !=AF_INET ) -return -EAFNOSUPPORT ; -if (NFNL_MSG_TYPE (nlh->nlmsg_type) ==IPCTNL_MSG_CT_GET_CTRZERO ) {#ifdef CONFIG_NF_CT_ACCT
@@ -1251,12 +1261,16 @@ ctnetlink_exp_dump_table(struct sk_buffstruct nf_conntrack_expect *exp =NULL ;struct list_head *i;u_int32_t *id = (u_int32_t *) &cb->args[0 ]; +struct nfgenmsg *nfmsg =NLMSG_DATA (cb->nlh); +u_int8_t l3proto = nfmsg->nfgen_family;DEBUGP ("entered %s, last id=%llu\n" , __FUNCTION__, *id);read_lock_bh (&nf_conntrack_lock);list_for_each_prev (i, &nf_conntrack_expect_list) { exp = (struct nf_conntrack_expect *) i; +if (l3proto && exp->tuple.src.l3num != l3proto) +continue ;if (exp->id <= *id)continue ; if (ctnetlink_exp_fill_info(skb, NETLINK_CB(cb->skb).pid,
@@ -1298,9 +1312,6 @@ ctnetlink_get_expect(struct sock *ctnl,if (nlh->nlmsg_flags &NLM_F_DUMP ) {u32 rlen; -if (nfmsg->nfgen_family !=AF_INET ) -return -EAFNOSUPPORT ; -if ((*errp =netlink_dump_start (ctnl, skb, nlh, ctnetlink_exp_dump_table, ctnetlink_done)) !=0 )
PATCH 12/18 : Fix module_param types and permissions
In reply to Patrick McHardy[NETFILTER]: Fix module_param types and permissions
Fix netfilter module_param types and permissions. Also fix an off-by-one in the ipt_ULOG nlbufsiz < 128k check.
---
commit f771b92e29f4a46b7e5cd506f2584bfae187ba6a
tree 642b66e4f1ea352ed02a28880215dfe553d4d007
parent d5c7bf63c8ae6153ecdf70add3f5b935d4b088a1
author Patrick McHardy <[email protected]> Thu, 05 Jan 2006 02:58:23 +0100 committer Patrick McHardy <[email protected]> Thu, 05 Jan 2006 02:58:23 +0100
net/ipv4/netfilter/ip_conntrack_amanda.c | 2 +- net/ipv4/netfilter/ip_conntrack_ftp.c | 2 +- net/ipv4/netfilter/ip_conntrack_irc.c | 10 +++------- net/ipv4/netfilter/ip_conntrack_netbios_ns.c | 2 +- net/ipv4/netfilter/ipt_ULOG.c | 10 +++++----- net/ipv4/netfilter/ipt_recent.c | 20 ++++++++++---------- net/netfilter/nf_conntrack_ftp.c | 2 +- 7 files changed, 22 insertions(+), 26 deletions(-)
net/ipv4/netfilter/ip_conntrack_amanda.c +1 -1
@@ -36,7 +36,7 @@ static unsigned int master_timeout = 300MODULE_AUTHOR ("Brian J. Murrell <[email protected]>" );MODULE_DESCRIPTION ("Amanda connection tracking module" );MODULE_LICENSE ("GPL" ); -module_param (master_timeout, int,0600 ); +module_param (master_timeout, uint,0600 );MODULE_PARM_DESC (master_timeout,"timeout for the master connection" );static const char *conns[] = {"DATA " ,"MESG " ,"INDEX " };
net/ipv4/netfilter/ip_conntrack_ftp.c +1 -1
@@ -34,7 +34,7 @@ static int ports_c;module_param_array (ports, ushort, &ports_c,0400 );static int loose; -module_param (loose, int,0600 ); +module_param (loose, bool,0600 ); unsigned int (*ip_nat_ftp_hook)(struct sk_buff **pskb, enum ip_conntrack_info ctinfo,
net/ipv4/netfilter/ip_conntrack_irc.c +3 -7
@@ -36,7 +36,7 @@#define MAX_PORTS 8static unsigned short ports[MAX_PORTS ];static int ports_c; -static int max_dcc_channels =8 ; +static unsigned int max_dcc_channels =8 ;static unsigned int dcc_timeout =300 ;/* This is slow, but it's simple. --RR */ static char *irc_buffer;
@@ -54,9 +54,9 @@ MODULE_DESCRIPTION("IRC (DCC) connectionMODULE_LICENSE ("GPL" );module_param_array (ports, ushort, &ports_c,0400 );MODULE_PARM_DESC (ports,"port numbers of IRC servers" ); -module_param (max_dcc_channels, int,0400 ); +module_param (max_dcc_channels, uint,0400 );MODULE_PARM_DESC (max_dcc_channels,"max number of expected DCC channels per IRC session" ); -module_param (dcc_timeout, int,0400 ); +module_param (dcc_timeout, uint,0400 );MODULE_PARM_DESC (dcc_timeout,"timeout on for unestablished DCC channels" );static const char *dccprotos[] = {"SEND " ,"CHAT " ,"MOVE " ,"TSEND " ,"SCHAT " };
@@ -254,10 +254,6 @@ static int __init init(void)printk ("ip_conntrack_irc: max_dcc_channels must be a positive integer\n" );return -EBUSY ; } -if (dcc_timeout <0 ) { -printk ("ip_conntrack_irc: dcc_timeout must be a positive integer\n" ); -return -EBUSY ; - } irc_buffer =kmalloc (65536 ,GFP_KERNEL );if (!irc_buffer)
net/ipv4/netfilter/ip_conntrack_netbios_ns.c +1 -1
@@ -37,7 +37,7 @@ MODULE_DESCRIPTION("NetBIOS name serviceMODULE_LICENSE ("GPL" );static unsigned int timeout =3 ; -module_param (timeout, int,0600 ); +module_param (timeout, uint,0400 );MODULE_PARM_DESC (timeout,"timeout for master connection/replies in seconds" ); static int help(struct sk_buff **pskb,
net/ipv4/netfilter/ipt_ULOG.c +5 -5
@@ -77,15 +77,15 @@ MODULE_ALIAS_NET_PF_PROTO(PF_NETLINK, NE #define PRINTR(format, args...) do { if (net_ratelimit()) printk(format , ## args); } while (0)static unsigned int nlbufsiz =4096 ; -module_param (nlbufsiz, uint,0600 );/* FIXME: Check size < 128k --RR */ +module_param (nlbufsiz, uint,0400 );MODULE_PARM_DESC (nlbufsiz,"netlink buffer size" );static unsigned int flushtimeout =10 ; -module_param (flushtimeout, int,0600 ); +module_param (flushtimeout, uint,0600 );MODULE_PARM_DESC (flushtimeout,"buffer flush timeout (hundredths of a second)" ); -static unsigned int nflog =1 ; -module_param (nflog, int,0400 ); +static int nflog =1 ; +module_param (nflog, bool,0400 );MODULE_PARM_DESC (nflog,"register as internal netfilter logging module" );/* global data structures */
@@ -376,7 +376,7 @@ static int __init init(void)DEBUGP ("ipt_ULOG: init module\n" ); -if (nlbufsiz >=128 *1024 ) { +if (nlbufsiz >128 *1024 ) {printk ("Netlink buffer has to be <= 128kB\n" );return -EINVAL ; }
net/ipv4/netfilter/ipt_recent.c +10 -10
@@ -24,10 +24,10 @@#define HASH_LOG 9/* Defaults, these can be overridden on the module command-line. */ -static int ip_list_tot =100 ; -static int ip_pkt_list_tot =20 ; -static int ip_list_hash_size =0 ; -static int ip_list_perms =0644 ; +static unsigned int ip_list_tot =100 ; +static unsigned int ip_pkt_list_tot =20 ; +static unsigned int ip_list_hash_size =0 ; +static unsigned int ip_list_perms =0644 ;#ifdef DEBUG static int debug =1 ;#endif
@@ -38,13 +38,13 @@ KERN_INFO RECENT_NAME " " RECENT_VER ":MODULE_AUTHOR ("Stephen Frost <[email protected]>" );MODULE_DESCRIPTION ("IP tables recently seen matching module " RECENT_VER );MODULE_LICENSE ("GPL" ); -module_param (ip_list_tot, int,0400 ); -module_param (ip_pkt_list_tot, int,0400 ); -module_param (ip_list_hash_size, int,0400 ); -module_param (ip_list_perms, int,0400 ); +module_param (ip_list_tot, uint,0400 ); +module_param (ip_pkt_list_tot, uint,0400 ); +module_param (ip_list_hash_size, uint,0400 ); +module_param (ip_list_perms, uint,0400 );#ifdef DEBUG -module_param (debug, int,0600 ); -MODULE_PARM_DESC (debug,"debugging level, defaults to 1" ); +module_param (debug, bool,0600 ); +MODULE_PARM_DESC (debug,"enable debugging output" );#endif MODULE_PARM_DESC (ip_list_tot,"number of IPs to remember per list" );MODULE_PARM_DESC (ip_pkt_list_tot,"number of packets per IP to remember" );
net/netfilter/nf_conntrack_ftp.c +1 -1
@@ -44,7 +44,7 @@ static unsigned int ports_c;module_param_array (ports, ushort, &ports_c,0400 );static int loose; -module_param (loose, int,0600 ); +module_param (loose, bool,0600 ); unsigned int (*nf_nat_ftp_hook)(struct sk_buff **pskb, enum ip_conntrack_info ctinfo,
PATCH 13/18 : ctnetlink: Fix dumping of helper name
In reply to Patrick McHardy[NETFILTER]: ctnetlink: Fix dumping of helper name
Properly dump the helper name instead of internal kernel data. Based on patch by Marcus Sundberg <[email protected]>.
---
commit 10ee519ab7a421aa8a6fc62af197e7bdbd547b3e
tree 7e2970bdeaee1e44e72ee27f1e90cace28522319
parent f771b92e29f4a46b7e5cd506f2584bfae187ba6a
author Patrick McHardy <[email protected]> Thu, 05 Jan 2006 02:58:46 +0100 committer Patrick McHardy <[email protected]> Thu, 05 Jan 2006 02:58:46 +0100
include/linux/netfilter/nfnetlink_conntrack.h | 2 -- net/ipv4/netfilter/ip_conntrack_netlink.c | 2 +- 2 files changed, 1 insertions(+), 3 deletions(-)
include/linux/netfilter/nfnetlink_conntrack.h +0 -2
@@ -131,6 +131,4 @@ enum ctattr_help { };#define CTA_HELP_MAX (__CTA_HELP_MAX - 1) -#define CTA_HELP_MAXNAMESIZE 32 -#endif /* _IPCONNTRACK_NETLINK_H */
net/ipv4/netfilter/ip_conntrack_netlink.c +1 -1
@@ -161,7 +161,7 @@ ctnetlink_dump_helpinfo(struct sk_buff *return 0 ; nest_helper =NFA_NEST (skb,CTA_HELP ); -NFA_PUT (skb,CTA_HELP_NAME ,CTA_HELP_MAXNAMESIZE , &ct->helper->name); +NFA_PUT (skb,CTA_HELP_NAME ,strlen (ct->helper->name), ct->helper->name);if (ct->helper->to_nfattr) ct->helper->to_nfattr (skb, ct);
PATCH 14/18 : Remove okfn usage in ip_vs_core.c
In reply to Patrick McHardy[NETFILTER]: Remove okfn usage in ip_vs_core.c
okfn should only be used from different contexts to avoid deep call chains, i.e. by nf_queue.
---
commit 512a75394473e444f2276a3f7fd2c131df5d67d2
tree a69377e98cc3027a1e45b67377b54c0d181515f6
parent 10ee519ab7a421aa8a6fc62af197e7bdbd547b3e
author Patrick McHardy <[email protected]> Thu, 05 Jan 2006 03:07:18 +0100 committer Patrick McHardy <[email protected]> Thu, 05 Jan 2006 03:07:18 +0100
net/ipv4/ipvs/ip_vs_core.c | 5 +---- 1 files changed, 1 insertions(+), 4 deletions(-)
net/ipv4/ipvs/ip_vs_core.c +1 -4
@@ -532,11 +532,8 @@ static unsigned int ip_vs_post_routing(u {if (!((*pskb)->ipvs_property))return NF_ACCEPT ; -/* The packet was sent from IPVS, exit this chain */ - (*okfn)(*pskb); - -return NF_STOLEN ; +return NF_STOP ; }u16 ip_vs_checksum_complete (struct sk_buff *skb,int offset)
PATCH 15/18 : Call POST_ROUTING hook before fragmentation
In reply to Patrick McHardy[NETFILTER]: Call POST_ROUTING hook before fragmentation
Call POST_ROUTING hook before fragmentation to get rid of the okfn use in ip_refrag and save the useless fragmentation/defragmentation step when NAT is used.
The patch introduces one user-visible change, the POSTROUTING chain in the mangle table gets entire packets, not fragments, which should simplify use of the MARK and CLASSIFY targets for queueing as a nice side-effect.
---
commit 08d7c2719c70f5819768203f17db35934236469b
tree ba94685ebe63dd495ab0cb1cff120d1b3763b938
parent 512a75394473e444f2276a3f7fd2c131df5d67d2
author Patrick McHardy <[email protected]> Thu, 05 Jan 2006 03:16:21 +0100 committer Patrick McHardy <[email protected]> Thu, 05 Jan 2006 03:16:21 +0100
include/net/ip.h | 1 - net/ipv4/ip_output.c | 30 +++++++++++------------- net/ipv4/netfilter/ip_conntrack_standalone.c | 26 +-------------------- net/ipv4/netfilter/ip_nat_standalone.c | 17 -------------- net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c | 26 +-------------------- 5 files changed, 16 insertions(+), 84 deletions(-)
include/net/ip.h +0 -1
@@ -317,7 +317,6 @@ enum ip_defrag_usersIP_DEFRAG_CALL_RA_CHAIN ,IP_DEFRAG_CONNTRACK_IN ,IP_DEFRAG_CONNTRACK_OUT , -IP_DEFRAG_NAT_OUT ,IP_DEFRAG_VS_IN ,IP_DEFRAG_VS_OUT ,IP_DEFRAG_VS_FWD
net/ipv4/ip_output.c +14 -16
@@ -202,13 +202,11 @@ static inline int ip_finish_output2(strustatic inline int ip_finish_output (struct sk_buff *skb) { -struct net_device *dev = skb->dst->dev; - - skb->dev = dev; - skb->protocol =htons (ETH_P_IP ); - -return NF_HOOK (PF_INET ,NF_IP_POST_ROUTING , skb,NULL , dev, - ip_finish_output2); +if (skb->len >dst_mtu (skb->dst) && + !(skb_shinfo (skb)->ufo_size ||skb_shinfo (skb)->tso_size)) +return ip_fragment (skb, ip_finish_output2); +else +return ip_finish_output2 (skb); }int ip_mc_output (struct sk_buff *skb)
@@ -265,21 +263,21 @@ int ip_mc_output(struct sk_buff *skb) newskb->dev, ip_dev_loopback_xmit); } -if (skb->len >dst_mtu (&rt->u.dst)) -return ip_fragment (skb, ip_finish_output); -else -return ip_finish_output (skb); +return NF_HOOK (PF_INET ,NF_IP_POST_ROUTING , skb,NULL , skb->dev, + ip_finish_output); }int ip_output (struct sk_buff *skb) { +struct net_device *dev = skb->dst->dev; +IP_INC_STATS (IPSTATS_MIB_OUTREQUESTS ); -if (skb->len >dst_mtu (skb->dst) && - !(skb_shinfo (skb)->ufo_size ||skb_shinfo (skb)->tso_size)) -return ip_fragment (skb, ip_finish_output); -else -return ip_finish_output (skb); + skb->dev = dev; + skb->protocol =htons (ETH_P_IP ); + +return NF_HOOK (PF_INET ,NF_IP_POST_ROUTING , skb,NULL , dev, + ip_finish_output); }int ip_queue_xmit (struct sk_buff *skb,int ipfragok)
net/ipv4/netfilter/ip_conntrack_standalone.c +1 -25
@@ -451,30 +451,6 @@ static unsigned int ip_conntrack_defrag(return NF_ACCEPT ; } -static unsigned int ip_refrag (unsigned int hooknum, -struct sk_buff **pskb, -const struct net_device *in, -const struct net_device *out, -int (*okfn)(struct sk_buff *)) -{ -struct rtable *rt = (struct rtable *)(*pskb)->dst; - -/* We've seen it coming out the other side: confirm */ -if (ip_confirm (hooknum, pskb, in, out, okfn) !=NF_ACCEPT ) -return NF_DROP ; - -/* Local packets are never produced too large for their -interface. We degfragment them at LOCAL_OUT, however, -so we have to refragment them here. */ -if ((*pskb)->len >dst_mtu (&rt->u.dst) && - !skb_shinfo (*pskb)->tso_size) { -/* No hook can be after us, so this should be OK. */ -ip_fragment (*pskb, okfn); -return NF_STOLEN ; - } -return NF_ACCEPT ; -} - static unsigned int ip_conntrack_local(unsigned int hooknum, struct sk_buff **pskb, const struct net_device *in,
@@ -544,7 +520,7 @@ static struct nf_hook_ops ip_conntrack_h/* Refragmenter; last chance. */ static struct nf_hook_ops ip_conntrack_out_ops = { - .hook = ip_refrag, + .hook = ip_confirm, .owner =THIS_MODULE , .pf =PF_INET , .hooknum =NF_IP_POST_ROUTING ,
net/ipv4/netfilter/ip_nat_standalone.c +0 -17
@@ -190,23 +190,6 @@ ip_nat_out(unsigned int hooknum, || (*pskb)->nh.iph->ihl * 4 < sizeof(struct iphdr))return NF_ACCEPT ; -/* We can hit fragment here; forwarded packets get -defragmented by connection tracking coming in, then -fragmented (grr) by the forward code. - -In future: If we have nfct != NULL, AND we have NAT -initialized, AND there is no helper, then we can do full -NAPT on the head, and IP-address-only NAT on the rest. - -I'm starting to have nightmares about fragments. */ - -if ((*pskb)->nh.iph->frag_off &htons (IP_MF |IP_OFFSET )) { - *pskb =ip_ct_gather_frags (*pskb,IP_DEFRAG_NAT_OUT ); - -if (!*pskb) -return NF_STOLEN ; - } -return ip_nat_fn (hooknum, pskb, in, out, okfn); }
net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c +1 -25
@@ -181,30 +181,6 @@ static unsigned int ipv4_conntrack_defrareturn NF_ACCEPT ; } -static unsigned int ipv4_refrag (unsigned int hooknum, -struct sk_buff **pskb, -const struct net_device *in, -const struct net_device *out, -int (*okfn)(struct sk_buff *)) -{ -struct rtable *rt = (struct rtable *)(*pskb)->dst; - -/* We've seen it coming out the other side: confirm */ -if (ipv4_confirm (hooknum, pskb, in, out, okfn) !=NF_ACCEPT ) -return NF_DROP ; - -/* Local packets are never produced too large for their -interface. We degfragment them at LOCAL_OUT, however, -so we have to refragment them here. */ -if ((*pskb)->len >dst_mtu (&rt->u.dst) && - !skb_shinfo (*pskb)->tso_size) { -/* No hook can be after us, so this should be OK. */ -ip_fragment (*pskb, okfn); -return NF_STOLEN ; - } -return NF_ACCEPT ; -} - static unsigned int ipv4_conntrack_in(unsigned int hooknum, struct sk_buff **pskb, const struct net_device *in,
@@ -284,7 +260,7 @@ static struct nf_hook_ops ipv4_conntrack/* Refragmenter; last chance. */ static struct nf_hook_ops ipv4_conntrack_out_ops = { - .hook = ipv4_refrag, + .hook = ipv4_confirm, .owner =THIS_MODULE , .pf =PF_INET , .hooknum =NF_IP_POST_ROUTING ,
PATCH 16/18 : make ipv6_find_hdr() find transport protocol header
In reply to Patrick McHardy[NETFILTER]: make ipv6_find_hdr() find transport protocol header
The original ipv6_find_hdr() finds the specified header in IPv6 packets. This makes it possible to get transport header so that we can kill similar loop in ip6_match_packet().
---
commit 5ce8af1e153cd5a08089d6cb00a79f39773d67a4
tree 1b79f16aadc82f49f147cc88a48b036be5286828
parent 08d7c2719c70f5819768203f17db35934236469b
author Yasuyuki Kozakai <[email protected]> Thu, 05 Jan 2006 03:30:49 +0100 committer Patrick McHardy <[email protected]> Thu, 05 Jan 2006 03:30:49 +0100
include/linux/netfilter_ipv6/ip6_tables.h | 2 - net/ipv6/netfilter/ip6_tables.c | 106 +++++++++++------------------ net/ipv6/netfilter/ip6t_ah.c | 2 - net/ipv6/netfilter/ip6t_dst.c | 4 + net/ipv6/netfilter/ip6t_esp.c | 2 - net/ipv6/netfilter/ip6t_frag.c | 2 - net/ipv6/netfilter/ip6t_hbh.c | 4 + net/ipv6/netfilter/ip6t_rt.c | 2 - 8 files changed, 49 insertions(+), 75 deletions(-)
include/linux/netfilter_ipv6/ip6_tables.h +1 -1
@@ -474,7 +474,7 @@ extern unsigned int ip6t_do_table(structextern int ip6t_ext_hdr (u8 nexthdr);/* find specified header and get offset to it */ extern int ipv6_find_hdr (const struct sk_buff *skb,unsigned int *offset, -u8 target); +int target,unsigned short *fragoff);#define IP6T_ALIGN (s) (((s) + (__alignof__(struct ip6t_entry)-1)) & ~(__alignof__(struct ip6t_entry)-1))
net/ipv6/netfilter/ip6_tables.c +40 -66
150 lines not on this page · raw message
net/ipv6/netfilter/ip6t_ah.c +1 -1
@@ -54,7 +54,7 @@ match(const struct sk_buff *skb,unsigned int ptr;unsigned int hdrlen =0 ; -if (ipv6_find_hdr (skb, &ptr,NEXTHDR_AUTH ) <0 ) +if (ipv6_find_hdr (skb, &ptr,NEXTHDR_AUTH ,NULL ) <0 )return 0 ; ah =skb_header_pointer (skb, ptr,sizeof (_ah), &_ah);
net/ipv6/netfilter/ip6t_dst.c +2 -2
@@ -71,9 +71,9 @@ match(const struct sk_buff *skb,unsigned int optlen;#if HOPBYHOP -if (ipv6_find_hdr (skb, &ptr,NEXTHDR_HOP ) <0 ) +if (ipv6_find_hdr (skb, &ptr,NEXTHDR_HOP ,NULL ) <0 ) #else - if (ipv6_find_hdr(skb, &ptr, NEXTHDR_DEST) < 0) + if (ipv6_find_hdr(skb, &ptr, NEXTHDR_DEST, NULL) < 0)#endif return 0 ;
net/ipv6/netfilter/ip6t_esp.c +1 -1
@@ -56,7 +56,7 @@ match(const struct sk_buff *skb,/* Make sure this isn't an evil packet */ /*DEBUGP("ipv6_esp entered \n");*/ -if (ipv6_find_hdr (skb, &ptr,NEXTHDR_ESP ) <0 ) +if (ipv6_find_hdr (skb, &ptr,NEXTHDR_ESP ,NULL ) <0 )return 0 ; eh =skb_header_pointer (skb, ptr,sizeof (_esp), &_esp);
net/ipv6/netfilter/ip6t_frag.c +1 -1
@@ -52,7 +52,7 @@ match(const struct sk_buff *skb,const struct ip6t_frag *fraginfo = matchinfo;unsigned int ptr; -if (ipv6_find_hdr (skb, &ptr,NEXTHDR_FRAGMENT ) <0 ) +if (ipv6_find_hdr (skb, &ptr,NEXTHDR_FRAGMENT ,NULL ) <0 )return 0 ; fh =skb_header_pointer (skb, ptr,sizeof (_frag), &_frag);
net/ipv6/netfilter/ip6t_hbh.c +2 -2
@@ -71,9 +71,9 @@ match(const struct sk_buff *skb,unsigned int optlen;#if HOPBYHOP -if (ipv6_find_hdr (skb, &ptr,NEXTHDR_HOP ) <0 ) +if (ipv6_find_hdr (skb, &ptr,NEXTHDR_HOP ,NULL ) <0 ) #else - if (ipv6_find_hdr(skb, &ptr, NEXTHDR_DEST) < 0) + if (ipv6_find_hdr(skb, &ptr, NEXTHDR_DEST, NULL) < 0)#endif return 0 ;
net/ipv6/netfilter/ip6t_rt.c +1 -1
@@ -58,7 +58,7 @@ match(const struct sk_buff *skb,unsigned int ret =0 ;struct in6_addr *ap, _addr; -if (ipv6_find_hdr (skb, &ptr,NEXTHDR_ROUTING ) <0 ) +if (ipv6_find_hdr (skb, &ptr,NEXTHDR_ROUTING ,NULL ) <0 )return 0 ; rh =skb_header_pointer (skb, ptr,sizeof (_route), &_route);
PATCH 17/18 : Export ip6_masked_addrcmp, don't pass IPv6 addresses on stack
In reply to Patrick McHardy[NETFILTER]: Export ip6_masked_addrcmp, don't pass IPv6 addresses on stack
---
commit 24cd0baad0ca24fbc94f1af8e731c17afdfcfd71
tree f2fa0bd1455fa4550d7eb917d48ee3c268acf175
parent 5ce8af1e153cd5a08089d6cb00a79f39773d67a4
author Patrick McHardy <[email protected]> Thu, 05 Jan 2006 03:32:01 +0100 committer Patrick McHardy <[email protected]> Thu, 05 Jan 2006 03:32:01 +0100
include/linux/netfilter_ipv6/ip6_tables.h | 4 ++++ net/ipv6/netfilter/ip6_tables.c | 18 ++++++++++-------- 2 files changed, 14 insertions(+), 8 deletions(-)
include/linux/netfilter_ipv6/ip6_tables.h +4 -0
@@ -476,6 +476,10 @@ extern int ip6t_ext_hdr(u8 nexthdr);extern int ipv6_find_hdr (const struct sk_buff *skb,unsigned int *offset,int target,unsigned short *fragoff); +extern int ip6_masked_addrcmp (const struct in6_addr *addr1, +const struct in6_addr *mask, +const struct in6_addr *addr2); +#define IP6T_ALIGN (s) (((s) + (__alignof__(struct ip6t_entry)-1)) & ~(__alignof__(struct ip6t_entry)-1))#endif /*__KERNEL__*/
net/ipv6/netfilter/ip6_tables.c +10 -8
@@ -119,13 +119,14 @@ static LIST_HEAD(ip6t_tables);#define up (x) do { printk("UP:%u:" #x "\n", __LINE__); up(x); } while(0)#endif -static int ip6_masked_addrcmp (struct in6_addr addr1,struct in6_addr mask, -struct in6_addr addr2) +int +ip6_masked_addrcmp (const struct in6_addr *addr1,const struct in6_addr *mask, +const struct in6_addr *addr2) {int i;for ( i =0 ; i <16 ; i++){ -if ((addr1.s6_addr[i] & mask.s6_addr[i]) != - (addr2.s6_addr[i] & mask.s6_addr[i])) +if ((addr1->s6_addr[i] & mask->s6_addr[i]) != + (addr2->s6_addr[i] & mask->s6_addr[i]))return 1 ; }return 0 ;
@@ -159,10 +160,10 @@ ip6_packet_match(const struct sk_buff *s#define FWINV (bool,invflg) ((bool) ^ !!(ip6info->invflags & invflg)) -if (FWINV (ip6_masked_addrcmp (ipv6->saddr,ip6info->smsk,ip6info->src), -IP6T_INV_SRCIP ) - ||FWINV (ip6_masked_addrcmp (ipv6->daddr,ip6info->dmsk,ip6info->dst), -IP6T_INV_DSTIP )) { +if (FWINV (ip6_masked_addrcmp (&ipv6->saddr, &ip6info->smsk, + &ip6info->src),IP6T_INV_SRCIP ) + ||FWINV (ip6_masked_addrcmp (&ipv6->daddr, &ip6info->dmsk, + &ip6info->dst),IP6T_INV_DSTIP )) {dprintf ("Source or dest mismatch.\n" );/* dprintf("SRC: %u. Mask: %u. Target: %u.%s\n", ip->saddr,
@@ -2131,6 +2132,7 @@ EXPORT_SYMBOL(ip6t_register_target);EXPORT_SYMBOL (ip6t_unregister_target);EXPORT_SYMBOL (ip6t_ext_hdr);EXPORT_SYMBOL (ipv6_find_hdr); +EXPORT_SYMBOL (ip6_masked_addrcmp);module_init (init);module_exit (fini);
PATCH 18/18 : nf_conntrack_l3proto_ipv4.c needs net/route.h
In reply to Patrick McHardy[NETFILTER]: nf_conntrack_l3proto_ipv4.c needs net/route.h
CC [M] net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.o net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c: In function 'ipv4_refrag':net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c:198: error: dereferencing pointer to incomplete type make[3]: *** [net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.o] Error 1
---
commit b3a15f5d0c42e1e8d62af29befbec373fbc225a9
tree b20ed9974bcffd63b84beb40b275910b3ca449b4
parent 727822f9fd9970d84b78d6016677ea1d348f5cfd
author Patrick McHardy <[email protected]> Thu, 05 Jan 2006 01:42:19 +0100 committer Patrick McHardy <[email protected]> Thu, 05 Jan 2006 01:42:19 +0100
net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c +1 -0
@@ -22,6 +22,7 @@#include <linux/skbuff.h> #include <linux/icmp.h> #include <linux/sysctl.h> +#include <net/route.h> #include <net/ip.h> #include <linux/netfilter_ipv4.h>