[NETFILTER]: Simplify netbios helper

Don't parse the packet, the data is already available in the conntrack
structure.

Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by Patrick McHardy and committed by David S. Miller e7fa1bd9 5cb30640

+7 -12
+7 -12
net/ipv4/netfilter/ip_conntrack_netbios_ns.c
··· 23 23 #include <linux/inetdevice.h> 24 24 #include <linux/in.h> 25 25 #include <linux/ip.h> 26 - #include <linux/udp.h> 27 26 #include <net/route.h> 28 27 29 28 #include <linux/netfilter.h> 30 29 #include <linux/netfilter_ipv4.h> 31 30 #include <linux/netfilter_ipv4/ip_conntrack.h> 32 31 #include <linux/netfilter_ipv4/ip_conntrack_helper.h> 32 + 33 + #define NMBD_PORT 137 33 34 34 35 MODULE_AUTHOR("Patrick McHardy <kaber@trash.net>"); 35 36 MODULE_DESCRIPTION("NetBIOS name service broadcast connection tracking helper"); ··· 45 44 { 46 45 struct ip_conntrack_expect *exp; 47 46 struct iphdr *iph = (*pskb)->nh.iph; 48 - struct udphdr _uh, *uh; 49 47 struct rtable *rt = (struct rtable *)(*pskb)->dst; 50 48 struct in_device *in_dev; 51 49 u_int32_t mask = 0; ··· 72 72 if (mask == 0) 73 73 goto out; 74 74 75 - uh = skb_header_pointer(*pskb, iph->ihl * 4, sizeof(_uh), &_uh); 76 - BUG_ON(uh == NULL); 77 - 78 75 exp = ip_conntrack_expect_alloc(ct); 79 76 if (exp == NULL) 80 77 goto out; 81 - memset(&exp->tuple, 0, sizeof(exp->tuple)); 82 - exp->tuple.src.ip = iph->daddr & mask; 83 - exp->tuple.dst.ip = iph->saddr; 84 - exp->tuple.dst.u.udp.port = uh->source; 85 - exp->tuple.dst.protonum = IPPROTO_UDP; 86 78 87 - memset(&exp->mask, 0, sizeof(exp->mask)); 79 + exp->tuple = ct->tuplehash[IP_CT_DIR_REPLY].tuple; 80 + exp->tuple.src.u.udp.port = ntohs(NMBD_PORT); 81 + 88 82 exp->mask.src.ip = mask; 83 + exp->mask.src.u.udp.port = 0xFFFF; 89 84 exp->mask.dst.ip = 0xFFFFFFFF; 90 85 exp->mask.dst.u.udp.port = 0xFFFF; 91 86 exp->mask.dst.protonum = 0xFF; ··· 102 107 .src = { 103 108 .u = { 104 109 .udp = { 105 - .port = __constant_htons(137), 110 + .port = __constant_htons(NMBD_PORT), 106 111 } 107 112 } 108 113 },