patchlets patch submission
Subsystems (2)
I did some work on fixing the conntrack pom addons for the lockhelp.h patch (2.6.13 support essentially). I think I got everything setup except for 2 files.
Attached is all my work in patch form against a full kernel source. I have a feeling you'd prefer I sent this in some other format or in some other structure of a diff. This is my first time contributing so just let me know how you'd prefer this in the future.
What's left is:
- rtsp (part of rsh)
- pptp (only the conntrack part)
- nat-hook symbols missing in quake3 and talk conntrack
I made some attempt at both of these, but I'm not sure how well I did. You should obviously check my work.
I'm willing to do more, so just let me know what I can do and how I did so far.
Thanks,
Cory
include/linux/netfilter_ipv4/ip_conntrack_pptp.h +1 -2
@@ -50,8 +50,7 @@#ifdef __KERNEL__ -#include <linux/netfilter_ipv4/lockhelp.h> -DECLARE_LOCK_EXTERN (ip_pptp_lock); +extern spinlock_t ip_pptp_lock;#define IP_CONNTR_PPTP PPTP_CONTROL_PORT
include/linux/netfilter_ipv4/ip_conntrack_talk.h +1 -2
@@ -4,10 +4,9 @@#ifdef __KERNEL__#include <linux/in.h> -#include <linux/netfilter_ipv4/lockhelp.h> /* Protects talk part of conntracks */ -DECLARE_LOCK_EXTERN (ip_talk_lock); +extern spinlock_t ip_talk_lock;#endif
net/ipv4/netfilter/ip_conntrack_h323.c +4 -5
@@ -117,7 +117,7 @@NIPQUAD (ct->tuplehash[!dir].tuple.src.ip), NIPQUAD((*pskb)->nh.iph->saddr), ntohs(data_port)); - exp =ip_conntrack_expect_alloc (); + exp =ip_conntrack_expect_alloc (ct);if (exp ==NULL ) { ret =NF_ACCEPT ; goto out;
@@ -134,18 +134,17 @@ { 0xFFFFFFFF, { .tcp = { 0xFFFF } }, 0xFF }}); exp->expectfn =NULL ; - exp->master = ct;if (ip_nat_h245_hook !=NULL ) { ret =ip_nat_h245_hook (pskb, ctinfo, i, exp); }else {/* Can't expect this? Best to drop packet now. */ -if (ip_conntrack_expect_related (exp) !=0 ) { -ip_conntrack_expect_free (exp); +if (ip_conntrack_expect_related (exp) !=0 ) ret =NF_DROP ; - }else +else ret =NF_ACCEPT ; +ip_conntrack_expect_put (exp); }break ;
net/ipv4/netfilter/ip_conntrack_h323_h225.c +8 -8
@@ -108,7 +108,7 @@ }if (ret && ip == ct->tuplehash[dir].tuple.src.ip) {/* match found: create an expectation */ - exp =ip_conntrack_expect_alloc (); + exp =ip_conntrack_expect_alloc (ct);if (exp ==NULL )return NF_ACCEPT ;
@@ -123,7 +123,6 @@ { 0xFFFFFFFF, { .tcp = { 0xFFFF } }, 0xFF }}); exp->expectfn = ip_conntrack_h245_expect; - exp->master = ct;/* call NAT hook and register expectation */ if (ip_nat_h225_hook !=NULL ) {
@@ -131,12 +130,13 @@ exp); }else {/* Can't expect this? Best to drop packet now. */ -if (ip_conntrack_expect_related (exp) !=0 ) { -ip_conntrack_expect_free (exp); -return NF_DROP ; - }else { -return NF_ACCEPT ; - } +if (ip_conntrack_expect_related (exp) !=0 ) + ret =NF_DROP ; +else + ret =NF_ACCEPT ; + +ip_conntrack_expect_put (exp); +return ret; } } }
net/ipv4/netfilter/ip_conntrack_h323_h245.c +24 -18
104 lines not on this page · raw message
net/ipv4/netfilter/ip_conntrack_mms.c +2 -3
@@ -255,7 +255,7 @@DEBUGP ("ip_conntrack_mms: tcph->seq = %u\n" , tcph->seq); - exp =ip_conntrack_expect_alloc (); + exp =ip_conntrack_expect_alloc (ct);if (!exp) { ret =NF_DROP ; goto out;
@@ -280,12 +280,11 @@ { { 0xFFFFFFFF, { 0 } }, { 0xFFFFFFFF, { .tcp = { 0xFFFF } }, 0xFF }}); exp->expectfn =NULL ; - exp->master = ct;if (ip_nat_mms_hook) ret =ip_nat_mms_hook (pskb, ctinfo, exp_mms_info, exp);else if (ip_conntrack_expect_related (exp) !=0 ) { -ip_conntrack_expect_free (exp); +ip_conntrack_expect_put (exp); ret =NF_DROP ; } goto out;
net/ipv4/netfilter/ip_conntrack_pptp.c +7 -9
@@ -51,7 +51,6 @@#include <net/checksum.h> #include <net/tcp.h> -#include <linux/netfilter_ipv4/lockhelp.h> #include <linux/netfilter_ipv4/ip_conntrack.h> #include <linux/netfilter_ipv4/ip_conntrack_core.h> #include <linux/netfilter_ipv4/ip_conntrack_helper.h>
@@ -64,7 +63,7 @@MODULE_AUTHOR ("Harald Welte <[email protected]>" );MODULE_DESCRIPTION ("Netfilter connection tracking helper module for PPTP" ); -DECLARE_LOCK (ip_pptp_lock); +DEFINE_SPINLOCK (ip_pptp_lock); int (*ip_nat_pptp_hook_outbound)(struct sk_buff **pskb,
@@ -234,7 +233,7 @@ exp_reply =ip_conntrack_expect_alloc ();if (exp_reply ==NULL ) { -ip_conntrack_expect_free (exp_orig); +ip_conntrack_expect_put (exp_orig);return 1 ; }
@@ -247,7 +246,6 @@ exp_orig->mask.dst.ip =0xffffffff ; exp_orig->mask.dst.protonum =0xff ; - exp_orig->master = master; exp_orig->expectfn = pptp_expectfn; exp_orig->dir =IP_CT_DIR_ORIGINAL ;
@@ -266,8 +264,8 @@DUMP_TUPLE (&exp_orig->tuple);if (ip_conntrack_expect_related (exp_orig) !=0 ) { -ip_conntrack_expect_free (exp_orig); -ip_conntrack_expect_free (exp_reply); +ip_conntrack_expect_put (exp_orig); +ip_conntrack_expect_put (exp_reply);DEBUGP ("cannot expect_related()\n" );return 1 ; }
@@ -277,7 +275,7 @@if (ip_conntrack_expect_related (exp_reply) !=0 ) {ip_conntrack_unexpect_related (exp_orig); -ip_conntrack_expect_free (exp_reply); +ip_conntrack_expect_put (exp_reply);DEBUGP ("cannot expect_related()\n" );return 1 ; }
@@ -711,7 +709,7 @@ oldsstate = info->sstate; oldcstate = info->cstate; -LOCK_BH (&ip_pptp_lock); +spin_lock_bh (&ip_pptp_lock); nexthdr_off +=sizeof (_pptph);/* FIXME: We just blindly assume that the control connection is always
@@ -726,7 +724,7 @@ ctinfo);DEBUGP ("sstate: %d->%d, cstate: %d->%d\n" , oldsstate, info->sstate, oldcstate, info->cstate); -UNLOCK_BH (&ip_pptp_lock); +spin_unlock_bh (&ip_pptp_lock);return ret; }
net/ipv4/netfilter/ip_conntrack_proto_gre.c +13 -12
@@ -32,11 +32,12 @@#include <linux/in.h> #include <linux/list.h> -#include <linux/netfilter_ipv4/lockhelp.h> +DEFINE_RWLOCK (ip_ct_gre_lock); -DECLARE_RWLOCK (ip_ct_gre_lock); -#define ASSERT_READ_LOCK (x) MUST_BE_READ_LOCKED(&ip_ct_gre_lock) -#define ASSERT_WRITE_LOCK (x) MUST_BE_WRITE_LOCKED(&ip_ct_gre_lock) +/* ip_conntrack_lock protects the main hash table, protocol/helper/expected +registrations, conntrack timers*/ +#define ASSERT_READ_LOCK (x) +#define ASSERT_WRITE_LOCK (x)#include <linux/netfilter_ipv4/listhelp.h> #include <linux/netfilter_ipv4/ip_conntrack_protocol.h>
@@ -82,12 +83,12 @@struct ip_ct_gre_keymap *km;u_int32_t key =0 ; -READ_LOCK (&ip_ct_gre_lock); +read_lock_bh (&ip_ct_gre_lock); km =LIST_FIND (&gre_keymap_list, gre_key_cmpfn, struct ip_ct_gre_keymap *, t);if (km) key = km->tuple.src.u.gre.key; -READ_UNLOCK (&ip_ct_gre_lock); +read_unlock_bh (&ip_ct_gre_lock);DEBUGP ("lookup src key 0x%x up key for " , key);DUMP_TUPLE_GRE (t);
@@ -155,9 +156,9 @@DEBUGP ("adding new entry %p: " , km);DUMP_TUPLE_GRE (&km->tuple); -WRITE_LOCK (&ip_ct_gre_lock); +write_lock_bh (&ip_ct_gre_lock);list_append (&gre_keymap_list, km); -WRITE_UNLOCK (&ip_ct_gre_lock); +write_unlock_bh (&ip_ct_gre_lock);return 0 ; }
@@ -172,7 +173,7 @@return ; } -WRITE_LOCK (&ip_ct_gre_lock); +write_lock_bh (&ip_ct_gre_lock);if (ct->help.ct_pptp_info.keymap_orig) {DEBUGP ("removing %p from list\n" , ct->help.ct_pptp_info.keymap_orig);
@@ -187,7 +188,7 @@kfree (ct->help.ct_pptp_info.keymap_reply); ct->help.ct_pptp_info.keymap_reply =NULL ; } -WRITE_UNLOCK (&ip_ct_gre_lock); +write_unlock_bh (&ip_ct_gre_lock); }
@@ -351,13 +352,13 @@struct list_head *pos, *n;/* delete all keymap entries */ -WRITE_LOCK (&ip_ct_gre_lock); +write_lock_bh (&ip_ct_gre_lock);list_for_each_safe (pos, n, &gre_keymap_list) {DEBUGP ("deleting keymap %p at module unload time\n" , pos);list_del (pos);kfree (pos); } -WRITE_UNLOCK (&ip_ct_gre_lock); +write_unlock_bh (&ip_ct_gre_lock);ip_conntrack_protocol_unregister (&gre); }
net/ipv4/netfilter/ip_conntrack_quake3.c +5 -4
@@ -40,7 +40,7 @@MODULE_PARM_DESC (ports,"port numbers of Quake III master servers" );static char quake3_buffer[65536 ]; -static DECLARE_LOCK (quake3_buffer_lock); +static DEFINE_SPINLOCK (quake3_buffer_lock);static unsigned int (*ip_nat_quake3_hook)(struct ip_conntrack_expect *exp);
@@ -89,7 +89,7 @@if (dataoff >= (*pskb)->len)return NF_ACCEPT ; -LOCK_BH (&quake3_buffer_lock); +spin_lock_bh (&quake3_buffer_lock); qb_ptr =skb_header_pointer (*pskb, dataoff, (*pskb)->len - dataoff, quake3_buffer);BUG_ON (qb_ptr ==NULL );
@@ -110,7 +110,7 @@ NIPQUAD(*ip), ntohs(*port));#endif - exp =ip_conntrack_expect_alloc (); + exp =ip_conntrack_expect_alloc (ct);if (!exp) { ret =NF_DROP ; goto out;
@@ -131,7 +131,7 @@if (ip_nat_quake3_hook) ret =ip_nat_quake3_hook (exp);else if (ip_conntrack_expect_related (exp) !=0 ) { -ip_conntrack_expect_free (exp); +ip_conntrack_expect_put (exp); ret =NF_DROP ; } goto out;
@@ -139,6 +139,7 @@ } out: +spin_unlock_bh (&quake3_buffer_lock);return ret; }
net/ipv4/netfilter/ip_conntrack_rsh.c +2 -2
@@ -209,7 +209,7 @@return NF_ACCEPT ; } - exp =ip_conntrack_expect_alloc (); + exp =ip_conntrack_expect_alloc (ct);if (!exp) { ret =NF_DROP ; goto out;
@@ -238,7 +238,7 @@if (ip_nat_rsh_hook) ret =ip_nat_rsh_hook (pskb, ctinfo, rb_ptr - data, exp);else if (ip_conntrack_expect_related (exp) !=0 ) { -ip_conntrack_expect_free (exp); +ip_conntrack_expect_put (exp); ret =NF_DROP ; }
net/ipv4/netfilter/ip_conntrack_rtsp.c +5 -7
@@ -31,7 +31,6 @@#include <net/checksum.h> #include <net/tcp.h> -#include <linux/netfilter_ipv4/lockhelp.h> #include <linux/netfilter_ipv4/ip_conntrack_helper.h> #include <linux/netfilter_ipv4/ip_conntrack_rtsp.h>
@@ -70,7 +69,7 @@MODULE_PARM_DESC (setup_timeout,"timeout on for unestablished data channels" );static char rtsp_buffer[65536 ]; -static DECLARE_LOCK (rtsp_buffer_lock); +static DEFINE_SPINLOCK (rtsp_buffer_lock); unsigned int (*ip_nat_rtsp_hook)(struct sk_buff **pskb, enum ip_conntrack_info ctinfo,
@@ -338,14 +337,13 @@ expinfo.loport, expinfo.hiport); - exp =ip_conntrack_expect_alloc (); + exp =ip_conntrack_expect_alloc (ct);if (!exp) { ret =NF_DROP ; goto out; }//exp->seq = ntohl(tcph->seq) + hdrsoff; /* mark all the headers */ - exp->master = ct;//exp.help.exp_rtsp_info.len = hdrslen; exp->tuple.src.ip = ct->tuplehash[!dir].tuple.src.ip;
@@ -369,7 +367,7 @@ ret =ip_nat_rtsp_hook (pskb, ctinfo, &expinfo, exp); else if (ip_conntrack_expect_related(exp) != 0) {INFOP ("ip_conntrack_expect_related failed\n" ); -ip_conntrack_expect_free (exp); +ip_conntrack_expect_put (exp); ret =NF_DROP ; } goto out;
@@ -415,7 +413,7 @@if (dataoff >= (*pskb)->len)return NF_ACCEPT ; -LOCK_BH (&rtsp_buffer_lock); +spin_lock_bh (&rtsp_buffer_lock); rb_ptr =skb_header_pointer (*pskb, dataoff, (*pskb)->len - dataoff, rtsp_buffer);BUG_ON (rb_ptr ==NULL );
@@ -443,7 +441,7 @@break ; } -UNLOCK_BH (&rtsp_buffer_lock); +spin_unlock_bh (&rtsp_buffer_lock);return ret; }
net/ipv4/netfilter/ip_conntrack_talk.c +11 -13
@@ -56,7 +56,6 @@#include <net/checksum.h> #include <net/udp.h> -#include <linux/netfilter_ipv4/lockhelp.h> #include <linux/netfilter_ipv4/ip_conntrack.h> #include <linux/netfilter_ipv4/ip_conntrack_core.h> #include <linux/netfilter_ipv4/ip_conntrack_helper.h>
@@ -77,7 +76,8 @@MODULE_PARM_DESC (ntalk2,"support ntalk2 protocol" );static char talk_buffer[65536 ]; -static DECLARE_LOCK (talk_buffer_lock); +static DEFINE_SPINLOCK (talk_buffer_lock); + unsigned int (*ip_nat_talk_resp_hook)(struct sk_buff **pskb, struct ip_conntrack_expect *exp,
@@ -130,7 +130,7 @@if (!(answer ==SUCCESS && type == mode))return NF_ACCEPT ; - exp =ip_conntrack_expect_alloc (); + exp =ip_conntrack_expect_alloc (ct);if (exp ==NULL ) {return NF_DROP ; }
@@ -154,7 +154,6 @@ { 0xFFFFFFFF, { .tcp = { 0xFFFF } }, 0xFF }}); exp->expectfn = talk_expectfn[talk_port -TALK_PORT ]; - exp->master = ct; DEBUGP("ip_ct_talk_help_response: callee client " "%u.%u.%u.%u:%u -> caller daemon %u.%u.%u.%u:%u!\n",
@@ -167,7 +166,7 @@ ret =ip_nat_talk_resp_hook (pskb, exp, type, answer, addr); else if (ip_conntrack_expect_related(exp) != 0) { -ip_conntrack_expect_free (exp); +ip_conntrack_expect_put (exp); ret =NF_DROP ; } }else if (type ==LOOK_UP ) {
@@ -188,7 +187,6 @@ { { 0xFFFFFFFF, { 0 } }, { 0xFFFFFFFF, { 0xFFFF }, 0xFF }}); exp->expectfn =NULL ; - exp->master = ct; DEBUGP("ip_ct_talk_help_response: callee client " "%u.%u.%u.%u:%u -> caller client %u.%u.%u.%u:%u!\n",
@@ -201,7 +199,7 @@ ret =ip_nat_talk_resp_hook (pskb, exp, type, answer, addr); else if (ip_conntrack_expect_related(exp) != 0) { -ip_conntrack_expect_free (exp); +ip_conntrack_expect_put (exp); ret =NF_DROP ; } }
@@ -247,7 +245,7 @@if (dataoff >= (*pskb)->len)return NF_ACCEPT ; -LOCK_BH (&talk_buffer_lock); +spin_lock_bh (&talk_buffer_lock); tb_ptr =skb_header_pointer (*pskb, dataoff, (*pskb)->len - dataoff, talk_buffer);BUG_ON (tb_ptr ==NULL );
@@ -317,7 +315,7 @@ sizeof(struct ntalk_response), sizeof(struct ntalk2_response)); ret =NF_ACCEPT ; } -UNLOCK_BH (&talk_buffer_lock); +spin_unlock_bh (&talk_buffer_lock);return ret; }
@@ -368,18 +366,18 @@ struct ip_conntrack_expect *exp) {DEBUGP ("ip_conntrack_talk: calling talk_expectfn for ct %p\n" , ct); -WRITE_LOCK (&ip_conntrack_lock); +write_lock_bh (&ip_conntrack_lock); ct->helper = &lookup_helpers[0 ]; -WRITE_UNLOCK (&ip_conntrack_lock); +write_unlock_bh (&ip_conntrack_lock); }void ip_ct_ntalk_expect (struct ip_conntrack *ct,struct ip_conntrack_expect *exp) {DEBUGP ("ip_conntrack_talk: calling ntalk_expectfn for ct %p\n" , ct); -WRITE_LOCK (&ip_conntrack_lock); +write_lock_bh (&ip_conntrack_lock); ct->helper = &lookup_helpers[1 ]; -WRITE_UNLOCK (&ip_conntrack_lock); +write_unlock_bh (&ip_conntrack_lock); } static int help(struct sk_buff **pskb,
net/ipv4/netfilter/ip_nat_h323.c +2 -6
@@ -107,10 +107,8 @@break ; } -if (port ==0 ) { -ip_conntrack_expect_free (exp); +if (port ==0 )return NF_DROP ; - } newdata.port =htons (port);
@@ -155,10 +153,8 @@break ; } -if (port ==0 ) { -ip_conntrack_expect_free (exp); +if (port ==0 )return NF_DROP ; - } newdata.port =htons (port);
net/ipv4/netfilter/ip_nat_mms.c +1 -3
@@ -114,10 +114,8 @@ } } -if (port ==0 ) { -ip_conntrack_expect_free (expect); +if (port ==0 )return NF_DROP ; - } sprintf(buffer, "\\\\%u.%u.%u.%u\\%s\\%u", NIPQUAD(newip),
net/ipv4/netfilter/ip_nat_pptp.c +0 -2
@@ -223,7 +223,6 @@DEBUGP ("successfully registered expect\n" ); }else {DEBUGP ("can't expect_related(expect_orig)\n" ); -ip_conntrack_expect_free (expect_orig);return 1 ; }
@@ -242,7 +241,6 @@ }else {DEBUGP ("can't expect_related(expect_reply)\n" );ip_conntrack_unexpect_related (expect_orig); -ip_conntrack_expect_free (expect_reply);return 1 ; }
net/ipv4/netfilter/ip_nat_quake3.c +1 -3
@@ -72,10 +72,8 @@ exp->expectfn = ip_nat_follow_master;//exp->dir = !dir; -if (ip_conntrack_expect_related (exp) !=0 ) { -ip_conntrack_expect_free (exp); +if (ip_conntrack_expect_related (exp) !=0 )return NF_DROP ; - }return NF_ACCEPT ; }
net/ipv4/netfilter/ip_nat_talk.c +1 -3
@@ -193,10 +193,8 @@break ; } } -if (port ==0 ) { -ip_conntrack_expect_free (exp); +if (port ==0 )return NF_DROP ; - }if (!mangle_packet (pskb, ct, newip,htons (port), addr,NULL )) {ip_conntrack_unexpect_related (exp);
net/ipv4/netfilter/ip_set.c +43 -43
305 lines not on this page · raw message
net/ipv4/netfilter/ipt_u32.c +5 -6
@@ -105,7 +105,6 @@#include <linux/netfilter_ipv4/ipt_u32.h> #include <linux/netfilter_ipv4/ip_tables.h> -#include <linux/netfilter_ipv4/lockhelp.h> /* #include <asm-i386/timex.h> for timing */
@@ -115,7 +114,7 @@/* This is slow, but it's simple. --RR */ static char u32_buffer[65536 ]; -static DECLARE_LOCK (u32_lock); +static DEFINE_SPINLOCK (u32_lock); static int match(const struct sk_buff *skb,
@@ -136,7 +135,7 @@u_int32_t AttPos; -LOCK_BH (&u32_lock); +spin_lock_bh (&u32_lock); head =skb_header_pointer (skb,0 , skb->len, u32_buffer);BUG_ON (head ==NULL );
@@ -148,7 +147,7 @@ AttPos =0 ; pos = data->tests[testind].location[0 ].number;if (AttPos + pos +3 > skb->len || AttPos + pos <0 ){ -UNLOCK_BH (&u32_lock); +spin_unlock_bh (&u32_lock);return 0 ; } val = (base[pos]<<24) + (base[pos+1]<<16) +
@@ -190,13 +189,13 @@/* cycles2 = get_cycles(); printk("failed %d in %d cycles\n", testind, cycles2-cycles1); */ -UNLOCK_BH (&u32_lock); +spin_unlock_bh (&u32_lock);return 0 ; } }/* cycles2 = get_cycles(); printk("succeeded in %d cycles\n", cycles2-cycles1); */ -UNLOCK_BH (&u32_lock); +spin_unlock_bh (&u32_lock);return 1 ; }
net/mpls/af_mpls.c +9 -4
@@ -34,6 +34,12 @@static kmem_cache_t *mpls_sk_cachep; +static struct proto mpls_proto = { + .name ="MPLS" , + .owner =THIS_MODULE , + .obj_size =sizeof (struct mpls_sock ), +}; +struct proto_ops mpls_sk_ops = { .family =PF_MPLS , .owner =THIS_MODULE ,
@@ -81,16 +87,15 @@ sock->state =SS_UNCONNECTED ; sock->ops = &mpls_sk_ops; - sk =sk_alloc (PF_INET ,GFP_KERNEL ,sizeof (struct sock ), - mpls_sk_cachep); + sk =sk_alloc (PF_INET ,GFP_KERNEL , &mpls_proto, +sizeof (struct sock ));if (!sk)return -1 ;sock_init_data (sock, sk); -sk_set_owner (sk,THIS_MODULE ); +sock_reset_flag (sk,SOCK_ZAPPED ); sk->sk_destruct = mpls_sock_destruct; - sk->sk_zapped =0 ; sk->sk_family =PF_MPLS ; sk->sk_protocol =0 ; sk->sk_backlog_rcv = sk->sk_prot->backlog_rcv;
Please ignore the trailing MPLS work in this patch. It's not relevant to this list and I did not mean to include it.
Thanks,
Cory
Quoted 22 lines · Cory Visi
I did some work on fixing the conntrack pom addons for the
lockhelp.hpatch (2.6.13 support essentially). I think I got everything setup except for 2 files.Attached is all my work in patch form against a full kernel source. I have a feeling you'd prefer I sent this in some other format or in some other structure of a diff. This is my first time contributing so just let me know how you'd prefer this in the future.
What's left is:
- rtsp (part of rsh)
- pptp (only the conntrack part)
- nat-hook symbols missing in quake3 and talk conntrackI made some attempt at both of these, but I'm not sure how well I did. You should obviously check my work.
I'm willing to do more, so just let me know what I can do and how I did so far.
Thanks,
Cory