]> err.no Git - linux-2.6/blobdiff - net/ipv4/netfilter/ip_nat_proto_udp.c
Merge branch 'for-2.6.20' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris...
[linux-2.6] / net / ipv4 / netfilter / ip_nat_proto_udp.c
index c4906e1aa24a01027db952b38bccc2bea57f202e..4bbec7730d18b3fbbec444aee353bf0b07dc41dd 100644 (file)
@@ -24,7 +24,7 @@ udp_in_range(const struct ip_conntrack_tuple *tuple,
             const union ip_conntrack_manip_proto *min,
             const union ip_conntrack_manip_proto *max)
 {
-       u_int16_t port;
+       __be16 port;
 
        if (maniptype == IP_NAT_MANIP_SRC)
                port = tuple->src.u.udp.port;
@@ -42,7 +42,7 @@ udp_unique_tuple(struct ip_conntrack_tuple *tuple,
                 const struct ip_conntrack *conntrack)
 {
        static u_int16_t port;
-       u_int16_t *portptr;
+       __be16 *portptr;
        unsigned int range_size, min, i;
 
        if (maniptype == IP_NAT_MANIP_SRC)
@@ -91,8 +91,8 @@ udp_manip_pkt(struct sk_buff **pskb,
        struct iphdr *iph = (struct iphdr *)((*pskb)->data + iphdroff);
        struct udphdr *hdr;
        unsigned int hdroff = iphdroff + iph->ihl*4;
-       u32 oldip, newip;
-       u16 *portptr, newport;
+       __be32 oldip, newip;
+       __be16 *portptr, newport;
 
        if (!skb_make_writable(pskb, hdroff + sizeof(*hdr)))
                return 0;
@@ -113,47 +113,18 @@ udp_manip_pkt(struct sk_buff **pskb,
                newport = tuple->dst.u.udp.port;
                portptr = &hdr->dest;
        }
-       if (hdr->check) /* 0 is a special case meaning no checksum */
-               hdr->check = ip_nat_cheat_check(~oldip, newip,
-                                       ip_nat_cheat_check(*portptr ^ 0xFFFF,
-                                                          newport,
-                                                          hdr->check));
-       *portptr = newport;
-       return 1;
-}
-
-static unsigned int
-udp_print(char *buffer,
-         const struct ip_conntrack_tuple *match,
-         const struct ip_conntrack_tuple *mask)
-{
-       unsigned int len = 0;
-
-       if (mask->src.u.udp.port)
-               len += sprintf(buffer + len, "srcpt=%u ",
-                              ntohs(match->src.u.udp.port));
-
 
-       if (mask->dst.u.udp.port)
-               len += sprintf(buffer + len, "dstpt=%u ",
-                              ntohs(match->dst.u.udp.port));
-
-       return len;
-}
-
-static unsigned int
-udp_print_range(char *buffer, const struct ip_nat_range *range)
-{
-       if (range->min.udp.port != 0 || range->max.udp.port != 0xFFFF) {
-               if (range->min.udp.port == range->max.udp.port)
-                       return sprintf(buffer, "port %u ",
-                                      ntohs(range->min.udp.port));
-               else
-                       return sprintf(buffer, "ports %u-%u ",
-                                      ntohs(range->min.udp.port),
-                                      ntohs(range->max.udp.port));
+       if (hdr->check || (*pskb)->ip_summed == CHECKSUM_PARTIAL) {
+               hdr->check = nf_proto_csum_update(*pskb, ~oldip, newip,
+                                                 hdr->check, 1);
+               hdr->check = nf_proto_csum_update(*pskb,
+                                                 *portptr ^ htons(0xFFFF), newport,
+                                                 hdr->check, 0);
+               if (!hdr->check)
+                       hdr->check = -1;
        }
-       else return 0;
+       *portptr = newport;
+       return 1;
 }
 
 struct ip_nat_protocol ip_nat_protocol_udp = {
@@ -163,8 +134,6 @@ struct ip_nat_protocol ip_nat_protocol_udp = {
        .manip_pkt              = udp_manip_pkt,
        .in_range               = udp_in_range,
        .unique_tuple           = udp_unique_tuple,
-       .print                  = udp_print,
-       .print_range            = udp_print_range,
 #if defined(CONFIG_IP_NF_CONNTRACK_NETLINK) || \
     defined(CONFIG_IP_NF_CONNTRACK_NETLINK_MODULE)
        .range_to_nfattr        = ip_nat_port_range_to_nfattr,