X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=net%2Fipv4%2Fnetfilter%2Fip_nat_tftp.c;h=cacaab6f768c115e1e4c854ba46e4a9232c002e9;hb=c7b5ebbddf7bcd3651947760f423e3783bbe6573;hp=4b557e20ebbb82a3ed7fff072971cedb36c94eab;hpb=5273a3df6485dc2ad6aa7ddd441b9a21970f003b;p=linux-2.6.git diff --git a/net/ipv4/netfilter/ip_nat_tftp.c b/net/ipv4/netfilter/ip_nat_tftp.c index 4b557e20e..cacaab6f7 100644 --- a/net/ipv4/netfilter/ip_nat_tftp.c +++ b/net/ipv4/netfilter/ip_nat_tftp.c @@ -32,6 +32,7 @@ #include #include #include +#include MODULE_AUTHOR("Magnus Boden "); MODULE_DESCRIPTION("tftp NAT helper"); @@ -41,10 +42,8 @@ MODULE_LICENSE("GPL"); static int ports[MAX_PORTS]; static int ports_c = 0; -#ifdef MODULE_PARM -MODULE_PARM(ports,"1-" __MODULE_STRING(MAX_PORTS) "i"); +module_param_array(ports, int, ports_c, 0400); MODULE_PARM_DESC(ports, "port numbers of tftp servers"); -#endif #if 0 #define DEBUGP(format, args...) printk("%s:%s:" format, \ @@ -61,7 +60,7 @@ tftp_nat_help(struct ip_conntrack *ct, struct sk_buff **pskb) { int dir = CTINFO2DIR(ctinfo); - struct tftphdr tftph; + struct tftphdr _tftph, *tfh; struct ip_conntrack_tuple repl; if (!((hooknum == NF_IP_POST_ROUTING && dir == IP_CT_DIR_ORIGINAL) @@ -73,11 +72,13 @@ tftp_nat_help(struct ip_conntrack *ct, return NF_ACCEPT; } - if (skb_copy_bits(*pskb, (*pskb)->nh.iph->ihl*4+sizeof(struct udphdr), - &tftph, sizeof(tftph)) != 0) + tfh = skb_header_pointer(*pskb, + (*pskb)->nh.iph->ihl*4+sizeof(struct udphdr), + sizeof(_tftph), &_tftph); + if (tfh == NULL) return NF_DROP; - switch (ntohs(tftph.opcode)) { + switch (ntohs(tfh->opcode)) { /* RRQ and WRQ works the same way */ case TFTP_OPCODE_READ: case TFTP_OPCODE_WRITE: @@ -110,9 +111,12 @@ tftp_nat_expected(struct sk_buff **pskb, #if 0 const struct ip_conntrack_tuple *repl = &master->tuplehash[IP_CT_DIR_REPLY].tuple; - struct udphdr udph; + struct udphdr _udph, *uh; - if (skb_copy_bits(*pskb,(*pskb)->nh.iph->ihl*4,&udph,sizeof(udph))!=0) + uh = skb_header_pointer(*pskb, + (*pskb)->nh.iph->ihl*4, + sizeof(_udph), &_udph); + if (uh == NULL) return NF_DROP; #endif @@ -127,8 +131,8 @@ tftp_nat_expected(struct sk_buff **pskb, mr.range[0].min_ip = mr.range[0].max_ip = orig->dst.ip; DEBUGP("orig: %u.%u.%u.%u:%u <-> %u.%u.%u.%u:%u " "newsrc: %u.%u.%u.%u\n", - NIPQUAD((*pskb)->nh.iph->saddr), ntohs(udph.source), - NIPQUAD((*pskb)->nh.iph->daddr), ntohs(udph.dest), + NIPQUAD((*pskb)->nh.iph->saddr), ntohs(uh->source), + NIPQUAD((*pskb)->nh.iph->daddr), ntohs(uh->dest), NIPQUAD(orig->dst.ip)); } else { mr.range[0].min_ip = mr.range[0].max_ip = orig->src.ip; @@ -138,8 +142,8 @@ tftp_nat_expected(struct sk_buff **pskb, DEBUGP("orig: %u.%u.%u.%u:%u <-> %u.%u.%u.%u:%u " "newdst: %u.%u.%u.%u:%u\n", - NIPQUAD((*pskb)->nh.iph->saddr), ntohs(udph.source), - NIPQUAD((*pskb)->nh.iph->daddr), ntohs(udph.dest), + NIPQUAD((*pskb)->nh.iph->saddr), ntohs(uh->source), + NIPQUAD((*pskb)->nh.iph->daddr), ntohs(uh->dest), NIPQUAD(orig->src.ip), ntohs(orig->src.u.udp.port)); } @@ -164,10 +168,10 @@ static int __init init(void) int i, ret = 0; char *tmpname; - if (!ports[0]) - ports[0] = TFTP_PORT; + if (ports_c == 0) + ports[ports_c++] = TFTP_PORT; - for (i = 0 ; (i < MAX_PORTS) && ports[i] ; i++) { + for (i = 0; i < ports_c; i++) { memset(&tftp[i], 0, sizeof(struct ip_nat_helper)); tftp[i].tuple.dst.protonum = IPPROTO_UDP; @@ -196,7 +200,6 @@ static int __init init(void) fini(); return ret; } - ports_c++; } return ret; }