Netfilter: Adrian Bunk's Cleanup Patches
Subsystems (2)
PATCH 7/8 Netfilter: Adrian Bunk's Cleanup Patches
Name: Adrian Bunk's Cleanup Patches
Adrian Bunk's cleanup patch, updated for after all the Rusty patches.
Date: Wed, 15 Dec 2004 02:19:31 +0100
From: Adrian Bunk <[email protected]>
To: [email protected]
Cc: [email protected], [email protected], [email protected]
Subject: [2.6 patch] net/ipv4/netfilter/: misc possible cleanups
Message-ID: <[email protected]>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
User-Agent: Mutt/1.5.6+20040907i
Sender: [email protected]
Precedence: bulk
X-Mailing-List: [email protected]
X-Evolution-Source: mbox:/var/spool/mail/rusty
Content-Transfer-Encoding: 8bit
The patch below contains the following possible cleanups:
- make some needlessly global code static
- remove the following unused global functions:
- ip_conntrack_core.c: ip_conntrack_expect_find_get
- ip_conntrack_core.c: ip_conntrack_unexpect_related
- ip_nat_standalone.c: ip_nat_protocol_register
- ip_nat_standalone.c: ip_nat_protocol_unregister
- ip_nat_helper.c: ip_nat_find_helper
- ipfwadm_core.c: ip_acct_ctl
- remove the following variables that never change their values:
- ip_conntrack_ftp.c: ip_conntrack_ftp
- ip_conntrack_irc.c: ip_conntrack_irc
- remove the following unneeded EXPORT_SYMBOL's:
- ip_conntrack_standalone.c: ip_ct_find_helper
- ip_conntrack_standalone.c: ip_conntrack_unexpect_related
- ip_conntrack_standalone.c: ip_conntrack_expect_list
- ip_conntrack_standalone.c: ip_conntrack_put
- ip_nat_standalone.c: ip_nat_protocol_register
- ip_nat_standalone.c: ip_nat_protocol_unregister
- ip_nat_standalone.c: ip_nat_find_helper
- remove the following unneeded EXPORT_SYMBOL_GPL:
- ip_conntrack_standalone.c: ip_conntrack_expect_find_get
Please comment on which of these changes are correct and which conflict with pending patches.
diffstat output:
include/linux/netfilter_ipv4/ip_conntrack.h | 7 include/linux/netfilter_ipv4/ip_conntrack_helper.h | 4 include/linux/netfilter_ipv4/ip_nat_core.h | 4 include/linux/netfilter_ipv4/ip_nat_helper.h | 3 include/linux/netfilter_ipv4/ip_nat_protocol.h | 4 include/linux/netfilter_ipv4/ipfwadm_core.h | 9 - net/ipv4/netfilter/ip_conntrack_core.c | 28 --- net/ipv4/netfilter/ip_conntrack_ftp.c | 3 net/ipv4/netfilter/ip_conntrack_irc.c | 8 net/ipv4/netfilter/ip_conntrack_proto_sctp.c | 20 +- net/ipv4/netfilter/ip_conntrack_standalone.c | 5 net/ipv4/netfilter/ip_nat_core.c | 94 +++++------ net/ipv4/netfilter/ip_nat_helper.c | 14 - net/ipv4/netfilter/ip_nat_standalone.c | 30 --- net/ipv4/netfilter/ipchains_core.c | 22 +- net/ipv4/netfilter/ipfwadm_core.c | 108 +++---------- net/ipv4/netfilter/ipt_CLUSTERIP.c | 2 net/ipv4/netfilter/ipt_ULOG.c | 4 net/ipv4/netfilter/ipt_hashlimit.c | 2 net/ipv4/netfilter/ipt_recent.c | 2 20 files changed, 111 insertions(+), 262 deletions(-)
net/ipv4/netfilter/ip_nat_core.c +25 -25
@@ -288,6 +288,31 @@ [NF_IP_LOCAL_IN] = NF_IP_LOCAL_OUT, }; +static void replace_in_hashes (struct ip_conntrack *conntrack, +struct ip_nat_info *info) +{ +/* Source has changed, so replace in hashes. */ +unsigned int srchash + =hash_by_src (&conntrack->tuplehash[IP_CT_DIR_ORIGINAL ] + .tuple.src, + conntrack->tuplehash[IP_CT_DIR_ORIGINAL ] + .tuple.dst.protonum); +MUST_BE_WRITE_LOCKED (&ip_nat_lock); +list_move (&info->bysource, &bysource[srchash]); +} + +static void place_in_hashes (struct ip_conntrack *conntrack, +struct ip_nat_info *info) +{ +unsigned int srchash + =hash_by_src (&conntrack->tuplehash[IP_CT_DIR_ORIGINAL ] + .tuple.src, + conntrack->tuplehash[IP_CT_DIR_ORIGINAL ] + .tuple.dst.protonum); +MUST_BE_WRITE_LOCKED (&ip_nat_lock); +list_add (&info->bysource, &bysource[srchash]); +} + unsigned int ip_nat_setup_info(struct ip_conntrack *conntrack, const struct ip_nat_range *range,
@@ -411,31 +436,6 @@return NF_ACCEPT ; } -void replace_in_hashes (struct ip_conntrack *conntrack, -struct ip_nat_info *info) -{ -/* Source has changed, so replace in hashes. */ -unsigned int srchash - =hash_by_src (&conntrack->tuplehash[IP_CT_DIR_ORIGINAL ] - .tuple.src, - conntrack->tuplehash[IP_CT_DIR_ORIGINAL ] - .tuple.dst.protonum); -MUST_BE_WRITE_LOCKED (&ip_nat_lock); -list_move (&info->bysource, &bysource[srchash]); -} - -void place_in_hashes (struct ip_conntrack *conntrack, -struct ip_nat_info *info) -{ -unsigned int srchash - =hash_by_src (&conntrack->tuplehash[IP_CT_DIR_ORIGINAL ] - .tuple.src, - conntrack->tuplehash[IP_CT_DIR_ORIGINAL ] - .tuple.dst.protonum); -MUST_BE_WRITE_LOCKED (&ip_nat_lock); -list_add (&info->bysource, &bysource[srchash]); -} -/* Returns true if succeeded. */ static int manip_pkt(u_int16_t proto,
net/ipv4/netfilter/ip_nat_helper.c +1 -1
@@ -47,7 +47,7 @@#define DUMP_OFFSET (x)#endif -DECLARE_LOCK (ip_nat_seqofs_lock); +static DECLARE_LOCK (ip_nat_seqofs_lock);/* Setup TCP sequence correction given this change at this sequence */ static inline void
net/ipv4/netfilter/ip_conntrack_standalone.c +0 -1
@@ -905,7 +905,6 @@EXPORT_SYMBOL (ip_ct_refresh_acct);EXPORT_SYMBOL (ip_ct_protos);EXPORT_SYMBOL (ip_ct_find_proto); -EXPORT_SYMBOL (ip_ct_find_helper);EXPORT_SYMBOL (ip_conntrack_expect_alloc);EXPORT_SYMBOL (ip_conntrack_expect_free);EXPORT_SYMBOL (ip_conntrack_expect_related);
net/ipv4/netfilter/ip_conntrack_ftp.c +1 -2
@@ -29,7 +29,6 @@static char ftp_buffer[65536 ];static DECLARE_LOCK (ip_ftp_lock); -struct module *ip_conntrack_ftp =THIS_MODULE ;#define MAX_PORTS 8static int ports[MAX_PORTS ];
@@ -477,7 +476,7 @@ ftp[i].mask.dst.protonum =0xFFFF ; ftp[i].max_expected =1 ; ftp[i].timeout =5 *60 ;/* 5 minutes */ - ftp[i].me = ip_conntrack_ftp; + ftp[i].me =THIS_MODULE ; ftp[i].help = help; tmpname = &ftp_names[i][0 ];
net/ipv4/netfilter/ip_nat_standalone.c +0 -30
@@ -271,33 +271,6 @@ .priority = NF_IP_PRI_NAT_SRC, }; -/* Protocol registration. */ -int ip_nat_protocol_register (struct ip_nat_protocol *proto) -{ -int ret =0 ; - -WRITE_LOCK (&ip_nat_lock); -if (ip_nat_protos[proto->protonum] != &ip_nat_unknown_protocol) { - ret = -EBUSY ; - goto out; - } - ip_nat_protos[proto->protonum] = proto; - out: -WRITE_UNLOCK (&ip_nat_lock); -return ret; -} - -/* Noone stores the protocol anywhere; simply delete it. */ -void ip_nat_protocol_unregister (struct ip_nat_protocol *proto) -{ -WRITE_LOCK (&ip_nat_lock); - ip_nat_protos[proto->protonum] = &ip_nat_unknown_protocol; -WRITE_UNLOCK (&ip_nat_lock); - -/* Someone could be still looking at the proto in a bh. */ -synchronize_net (); -} -static int init_or_cleanup (int init) {int ret =0 ;
@@ -369,15 +342,12 @@module_exit (fini);EXPORT_SYMBOL (ip_nat_setup_info); -EXPORT_SYMBOL (ip_nat_protocol_register); -EXPORT_SYMBOL (ip_nat_protocol_unregister);EXPORT_SYMBOL (ip_nat_helper_register);EXPORT_SYMBOL (ip_nat_helper_unregister);EXPORT_SYMBOL (ip_nat_cheat_check);EXPORT_SYMBOL (ip_nat_mangle_tcp_packet);EXPORT_SYMBOL (ip_nat_mangle_udp_packet);EXPORT_SYMBOL (ip_nat_used_tuple); -EXPORT_SYMBOL (ip_nat_find_helper);EXPORT_SYMBOL (__ip_nat_find_helper);EXPORT_SYMBOL (ip_nat_follow_master);MODULE_LICENSE ("GPL" );
net/ipv4/netfilter/ipt_CLUSTERIP.c +1 -1
@@ -66,7 +66,7 @@/* clusterip_lock protects the clusterip_configs list _AND_ the configurable * data within all structurses (num_local_nodes, local_nodes[]) */ -DECLARE_RWLOCK (clusterip_lock); +static DECLARE_RWLOCK (clusterip_lock);#ifdef CONFIG_PROC_FS static struct file_operations clusterip_proc_fops;
net/ipv4/netfilter/ip_conntrack_irc.c +1 -3
@@ -63,8 +63,6 @@static char *dccprotos[] = {"SEND " ,"CHAT " ,"MOVE " ,"TSEND " ,"SCHAT " };#define MINMATCHLEN 5 -struct module *ip_conntrack_irc =THIS_MODULE ; -#if 0 #define DEBUGP(format, args...) printk(KERN_DEBUG "%s:%s:" format, \ __FILE__, __FUNCTION__ , ## args)
@@ -270,7 +268,7 @@ hlpr->mask.dst.protonum =0xFFFF ; hlpr->max_expected = max_dcc_channels; hlpr->timeout = dcc_timeout; - hlpr->me = ip_conntrack_irc; + hlpr->me =THIS_MODULE ; hlpr->help = help; tmpname = &irc_names[i][0 ];
include/linux/netfilter_ipv4/ip_nat_protocol.h +0 -4
@@ -48,10 +48,6 @@#define MAX_IP_NAT_PROTO 256extern struct ip_nat_protocol *ip_nat_protos[MAX_IP_NAT_PROTO ]; -/* Protocol registration. */ -extern int ip_nat_protocol_register (struct ip_nat_protocol *proto); -extern void ip_nat_protocol_unregister (struct ip_nat_protocol *proto); -static inline struct ip_nat_protocol *ip_nat_find_proto (u_int8_t protocol) {return ip_nat_protos[protocol];
net/ipv4/netfilter/ip_conntrack_proto_sctp.c +8 -8
@@ -58,13 +58,13 @@#define HOURS * 60 MINS#define DAYS * 24 HOURS -unsigned long ip_ct_sctp_timeout_closed = 10 SECS; -unsigned long ip_ct_sctp_timeout_cookie_wait = 3 SECS; -unsigned long ip_ct_sctp_timeout_cookie_echoed = 3 SECS; -unsigned long ip_ct_sctp_timeout_established = 5 DAYS; -unsigned long ip_ct_sctp_timeout_shutdown_sent = 300 SECS / 1000; -unsigned long ip_ct_sctp_timeout_shutdown_recd = 300 SECS / 1000; -unsigned long ip_ct_sctp_timeout_shutdown_ack_sent = 3 SECS; +static unsigned long ip_ct_sctp_timeout_closed = 10 SECS; +static unsigned long ip_ct_sctp_timeout_cookie_wait = 3 SECS; +static unsigned long ip_ct_sctp_timeout_cookie_echoed = 3 SECS; +static unsigned long ip_ct_sctp_timeout_established = 5 DAYS; +static unsigned long ip_ct_sctp_timeout_shutdown_sent = 300 SECS / 1000; +static unsigned long ip_ct_sctp_timeout_shutdown_recd = 300 SECS / 1000; +static unsigned long ip_ct_sctp_timeout_shutdown_ack_sent = 3 SECS;static unsigned long * sctp_timeouts[] = {NULL ,/* SCTP_CONNTRACK_NONE */
@@ -494,7 +494,7 @@return 1 ; } -struct ip_conntrack_protocol ip_conntrack_protocol_sctp = { +static struct ip_conntrack_protocol ip_conntrack_protocol_sctp = { .proto =IPPROTO_SCTP , .name ="sctp" , .pkt_to_tuple = sctp_pkt_to_tuple,
include/linux/netfilter_ipv4/ip_nat_core.h +0 -4
@@ -19,9 +19,5 @@unsigned int hooknum, int dir); -extern void replace_in_hashes (struct ip_conntrack *conntrack, -struct ip_nat_info *info); -extern void place_in_hashes (struct ip_conntrack *conntrack, -struct ip_nat_info *info);#endif /* _IP_NAT_CORE_H */
include/linux/netfilter_ipv4/ip_conntrack_helper.h +0 -3
@@ -29,9 +29,6 @@extern int ip_conntrack_helper_register (struct ip_conntrack_helper *);extern void ip_conntrack_helper_unregister (struct ip_conntrack_helper *); -extern struct ip_conntrack_helper *ip_ct_find_helper (const struct ip_conntrack_tuple *tuple); - -/* Allocate space for an expectation: this is mandatory before calling ip_conntrack_expect_related. */ extern struct ip_conntrack_expect *ip_conntrack_expect_alloc (void );
net/ipv4/netfilter/ip_conntrack_core.c +2 -2
@@ -78,7 +78,7 @@ DEFINE_PER_CPU(struct ip_conntrack_stat, ip_conntrack_stat); -inline void +void ip_conntrack_put (struct ip_conntrack *ct) {IP_NF_ASSERT (ct);
@@ -440,7 +440,7 @@return ip_ct_tuple_mask_cmp (rtuple, &i->tuple, &i->mask); } -struct ip_conntrack_helper *ip_ct_find_helper (const struct ip_conntrack_tuple *tuple) +static struct ip_conntrack_helper *ip_ct_find_helper (const struct ip_conntrack_tuple *tuple) { return LIST_FIND(&helpers, helper_cmp, struct ip_conntrack_helper *,
net/ipv4/netfilter/ipt_ULOG.c +2 -2
@@ -100,7 +100,7 @@static ulog_buff_t ulog_buffers[ULOG_MAXNLGROUPS ];/* array of buffers */ static struct sock *nflognl;/* our socket */ -DECLARE_LOCK (ulog_lock);/* spinlock */ +static DECLARE_LOCK (ulog_lock);/* spinlock */ /* send one ulog_buff_t to userspace */ static void ulog_send (unsigned int nlgroupnum)
@@ -140,7 +140,7 @@UNLOCK_BH (&ulog_lock); } -struct sk_buff *ulog_alloc_skb (unsigned int size) +static struct sk_buff *ulog_alloc_skb (unsigned int size) {struct sk_buff *skb;
net/ipv4/netfilter/ipt_hashlimit.c +1 -1
@@ -97,7 +97,7 @@struct list_head hash[0 ];/* hashtable itself */ }; -DECLARE_RWLOCK (hashlimit_lock);/* protects htables list */ +static DECLARE_RWLOCK (hashlimit_lock);/* protects htables list */ static LIST_HEAD (hashlimit_htables);static kmem_cache_t *hashlimit_cachep;