netfilter cosmetic changes
Subsystems (2)
PATCH 1/1 netfilter cosmetic changes
Hi Dave!
I decided to merge the cosmetic changes into one big patch. They are meant to be incremental to the 7 fixes I've sent you already.
- The 04_newnat-udp-helper patch submitted to 2.4.20 introduced an unused variable. This patch gets rid of it.
- Removes dead code in case CONFIG_SYSCTL is not defined
- Change order of NFC_ defines in netfilter.h to be more logical. Add comment that <= 0x2000 are already used
- Removes some old outdated comments
- Removes an obslete check (master_ct() checks for ct->master, no need for the caller to do it before).
- Remove some unneeded initializiations / memsets
- Clean up some ip_conntrack_core code (use some common macro instead of reimplementing list iteration again).
include/linux/netfilter.h +3 -2
@@ -19,9 +19,10 @@#define NF_REPEAT 4#define NF_MAX_VERDICT NF_REPEAT -/* Generic cache responses from hook functions. */ -#define NFC_ALTERED 0x8000 +/* Generic cache responses from hook functions. +<= 0x2000 is used for protocol-flags. */ #define NFC_UNKNOWN 0x4000 +#define NFC_ALTERED 0x8000#ifdef __KERNEL__#include <linux/config.h>
net/ipv4/netfilter/ip_conntrack_core.c +5 -15
@@ -264,9 +264,7 @@DEBUGP ("remove_expectations(%p)\n" , ct); -for (exp_entry = ct->sibling_list.next; - exp_entry != &ct->sibling_list; exp_entry = next) { - next = exp_entry->next; +list_for_each_safe (exp_entry, next, &ct->sibling_list) { exp = list_entry(exp_entry, struct ip_conntrack_expect, expected_list);
@@ -313,7 +311,7 @@IP_NF_ASSERT (atomic_read (&nfct->use) ==0 );IP_NF_ASSERT (!timer_pending (&ct->timeout)); -if (ct->master &&master_ct (ct)) +if (master_ct (ct))ip_conntrack_put (master_ct (ct));/* To make sure we don't get any weird locking issues here:
@@ -695,9 +693,6 @@INIT_LIST_HEAD (&conntrack->sibling_list); -/* Mark clearly that it's not in the hash table. */ - conntrack->tuplehash[IP_CT_DIR_ORIGINAL ].list.next =NULL ; -WRITE_LOCK (&ip_conntrack_lock);/* Need finding and deleting of expected ONLY if we win race */ READ_LOCK (&ip_conntrack_expect_tuple_lock);
@@ -1036,18 +1031,11 @@return -ENOMEM ; } -/* Zero out the new structure, then fill out it with the data */ DEBUGP ("new expectation %p of conntrack %p\n" , new, related_to); -memset (new,0 ,sizeof (*expect)); -INIT_LIST_HEAD (&new->list); -INIT_LIST_HEAD (&new->expected_list);memcpy (new, expect,sizeof (*expect)); new->expectant = related_to; new->sibling =NULL ; -/* increase usage count. This sucks. The memset above overwrites -* old usage count [if still present] and we increase to one. Only -* works because everything is done under ip_conntrack_lock() */ -atomic_inc (&new->use); +atomic_set (&new->use,1 );/* add to expected list for this connection */ list_add (&new->expected_list, &related_to->sibling_list);
@@ -1486,8 +1474,10 @@ ip_ct_attach = ip_conntrack_attach;return ret; +#ifdef CONFIG_SYSCTL err_free_ct_cachep:kmem_cache_destroy (ip_conntrack_cachep); +#endif /*CONFIG_SYSCTL*/ err_free_hash:vfree (ip_conntrack_hash); err_unreg_sockopt:
net/ipv4/netfilter/ip_conntrack_ftp.c +0 -1
@@ -405,7 +405,6 @@ ports[0 ] =FTP_PORT ;for (i =0 ; (i <MAX_PORTS ) && ports[i]; i++) { -memset (&ftp[i],0 ,sizeof (struct ip_conntrack_helper )); ftp[i].tuple.src.u.tcp.port =htons (ports[i]); ftp[i].tuple.dst.protonum =IPPROTO_TCP ; ftp[i].mask.src.u.tcp.port =0xFFFF ;
net/ipv4/netfilter/ip_conntrack_irc.c +0 -2
@@ -259,8 +259,6 @@for (i =0 ; (i <MAX_PORTS ) && ports[i]; i++) { hlpr = &irc_helpers[i]; -memset (hlpr,0 , -sizeof (struct ip_conntrack_helper )); hlpr->tuple.src.u.tcp.port =htons (ports[i]); hlpr->tuple.dst.protonum =IPPROTO_TCP ; hlpr->mask.src.u.tcp.port =0xFFFF ;
net/ipv4/netfilter/ip_nat_ftp.c +0 -3
@@ -306,9 +306,6 @@ ports[0 ] =FTP_PORT ;for (i =0 ; (i <MAX_PORTS ) && ports[i]; i++) { - -memset (&ftp[i],0 ,sizeof (struct ip_nat_helper )); - ftp[i].tuple.dst.protonum =IPPROTO_TCP ; ftp[i].tuple.src.u.tcp.port =htons (ports[i]); ftp[i].mask.dst.protonum =0xFFFF ;
net/ipv4/netfilter/ip_nat_helper.c +0 -1
@@ -84,7 +84,6 @@ iph = (*skb)->nh.iph;if (iph->protocol ==IPPROTO_TCP ) {struct tcphdr *tcph = (void *)iph + iph->ihl*4 ; -void *data = (void *)tcph + tcph->doff*4 ;DEBUGP ("ip_nat_resize_packet: Seq_offset before: " );DUMP_OFFSET (this_way);
net/ipv4/netfilter/ip_nat_irc.c +0 -3
@@ -243,9 +243,6 @@for (i =0 ; (i <MAX_PORTS ) && ports[i] !=0 ; i++) { hlpr = &ip_nat_irc_helpers[i]; -memset (hlpr,0 , -sizeof (struct ip_nat_helper )); - hlpr->tuple.dst.protonum =IPPROTO_TCP ; hlpr->tuple.src.u.tcp.port =htons (ports[i]); hlpr->mask.src.u.tcp.port =0xFFFF ;
net/ipv4/netfilter/ipt_ULOG.c +0 -1
@@ -322,7 +322,6 @@/* initialize ulog_buffers */ for (i =0 ; i <ULOG_MAXNLGROUPS ; i++) { -memset (&ulog_buffers[i],0 ,sizeof (ulog_buff_t));init_timer (&ulog_buffers[i].timer); ulog_buffers[i].timer.function = ulog_timer; ulog_buffers[i].timer.data = i;
Please apply, thanks.
Signature · 5 lines
- Harald Welte <[email protected]> http://www.netfilter.org/ ============================================================================ "Fragmentation is like classful addressing -- an interesting early architectural error that shows how much experimentation was going on while IP was being designed." -- Paul Vixie