]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/blobdiff - net/ipv4/netfilter/ip_conntrack_tftp.c
[NETFILTER]: x_tables: remove duplicate of xt_prefix
[mirror_ubuntu-hirsute-kernel.git] / net / ipv4 / netfilter / ip_conntrack_tftp.c
index 7e33d3bed5e3831e8b0a57ed06de304e3144b707..afc6809a38886e764778941c08debdf66c66b461 100644 (file)
@@ -33,7 +33,7 @@ MODULE_PARM_DESC(ports, "port numbers of tftp servers");
 
 #if 0
 #define DEBUGP(format, args...) printk("%s:%s:" format, \
-                                       __FILE__, __FUNCTION__ , ## args)
+                                      __FILE__, __FUNCTION__ , ## args)
 #else
 #define DEBUGP(format, args...)
 #endif
@@ -50,9 +50,10 @@ static int tftp_help(struct sk_buff **pskb,
        struct tftphdr _tftph, *tfh;
        struct ip_conntrack_expect *exp;
        unsigned int ret = NF_ACCEPT;
+       typeof(ip_nat_tftp_hook) ip_nat_tftp;
 
        tfh = skb_header_pointer(*pskb,
-                                (*pskb)->nh.iph->ihl*4+sizeof(struct udphdr),
+                                ip_hdrlen(*pskb) + sizeof(struct udphdr),
                                 sizeof(_tftph), &_tftph);
        if (tfh == NULL)
                return NF_ACCEPT;
@@ -70,10 +71,10 @@ static int tftp_help(struct sk_buff **pskb,
                        return NF_DROP;
 
                exp->tuple = ct->tuplehash[IP_CT_DIR_REPLY].tuple;
-               exp->mask.src.ip = 0xffffffff;
+               exp->mask.src.ip = htonl(0xffffffff);
                exp->mask.src.u.udp.port = 0;
-               exp->mask.dst.ip = 0xffffffff;
-               exp->mask.dst.u.udp.port = 0xffff;
+               exp->mask.dst.ip = htonl(0xffffffff);
+               exp->mask.dst.u.udp.port = htons(0xffff);
                exp->mask.dst.protonum = 0xff;
                exp->expectfn = NULL;
                exp->flags = 0;
@@ -81,8 +82,9 @@ static int tftp_help(struct sk_buff **pskb,
                DEBUGP("expect: ");
                DUMP_TUPLE(&exp->tuple);
                DUMP_TUPLE(&exp->mask);
-               if (ip_nat_tftp_hook)
-                       ret = ip_nat_tftp_hook(pskb, ctinfo, exp);
+               ip_nat_tftp = rcu_dereference(ip_nat_tftp_hook);
+               if (ip_nat_tftp)
+                       ret = ip_nat_tftp(pskb, ctinfo, exp);
                else if (ip_conntrack_expect_related(exp) != 0)
                        ret = NF_DROP;
                ip_conntrack_expect_put(exp);
@@ -111,7 +113,7 @@ static void ip_conntrack_tftp_fini(void)
                DEBUGP("unregistering helper for port %d\n",
                        ports[i]);
                ip_conntrack_helper_unregister(&tftp[i]);
-       } 
+       }
 }
 
 static int __init ip_conntrack_tftp_init(void)
@@ -129,7 +131,7 @@ static int __init ip_conntrack_tftp_init(void)
                tftp[i].tuple.dst.protonum = IPPROTO_UDP;
                tftp[i].tuple.src.u.udp.port = htons(ports[i]);
                tftp[i].mask.dst.protonum = 0xFF;
-               tftp[i].mask.src.u.udp.port = 0xFFFF;
+               tftp[i].mask.src.u.udp.port = htons(0xFFFF);
                tftp[i].max_expected = 1;
                tftp[i].timeout = 5 * 60; /* 5 minutes */
                tftp[i].me = THIS_MODULE;