]> err.no Git - linux-2.6/blobdiff - net/ipv4/netfilter/nf_nat_proto_gre.c
Merge git://git.infradead.org/battery-2.6
[linux-2.6] / net / ipv4 / netfilter / nf_nat_proto_gre.c
index e5a34c17d9271e21708efda147d7bc079e9f86ab..2e40cc83526aaccfb9f27fba36f392cd6061f0cd 100644 (file)
@@ -36,13 +36,6 @@ MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Harald Welte <laforge@gnumonks.org>");
 MODULE_DESCRIPTION("Netfilter NAT protocol helper module for GRE");
 
-#if 0
-#define DEBUGP(format, args...) printk(KERN_DEBUG "%s:%s: " format, __FILE__, \
-                                      __FUNCTION__, ## args)
-#else
-#define DEBUGP(x, args...)
-#endif
-
 /* is key in given range between min and max */
 static int
 gre_in_range(const struct nf_conntrack_tuple *tuple,
@@ -72,13 +65,18 @@ gre_unique_tuple(struct nf_conntrack_tuple *tuple,
        __be16 *keyptr;
        unsigned int min, i, range_size;
 
+       /* If there is no master conntrack we are not PPTP,
+          do not change tuples */
+       if (!conntrack->master)
+               return 0;
+
        if (maniptype == IP_NAT_MANIP_SRC)
                keyptr = &tuple->src.u.gre.key;
        else
                keyptr = &tuple->dst.u.gre.key;
 
        if (!(range->flags & IP_NAT_RANGE_PROTO_SPECIFIED)) {
-               DEBUGP("%p: NATing GRE PPTP\n", conntrack);
+               pr_debug("%p: NATing GRE PPTP\n", conntrack);
                min = 1;
                range_size = 0xffff;
        } else {
@@ -86,7 +84,7 @@ gre_unique_tuple(struct nf_conntrack_tuple *tuple,
                range_size = ntohs(range->max.gre.key) - min + 1;
        }
 
-       DEBUGP("min = %u, range_size = %u\n", min, range_size);
+       pr_debug("min = %u, range_size = %u\n", min, range_size);
 
        for (i = 0; i < range_size; i++, key++) {
                *keyptr = htons(min + key % range_size);
@@ -94,7 +92,7 @@ gre_unique_tuple(struct nf_conntrack_tuple *tuple,
                        return 1;
        }
 
-       DEBUGP("%p: no NAT mapping\n", conntrack);
+       pr_debug("%p: no NAT mapping\n", conntrack);
        return 0;
 }
 
@@ -122,25 +120,16 @@ gre_manip_pkt(struct sk_buff **pskb, unsigned int iphdroff,
        if (maniptype != IP_NAT_MANIP_DST)
                return 1;
        switch (greh->version) {
-       case 0:
-               if (!greh->key) {
-                       DEBUGP("can't nat GRE w/o key\n");
-                       break;
-               }
-               if (greh->csum) {
-                       /* FIXME: Never tested this code... */
-                       nf_proto_csum_replace4(gre_csum(greh), *pskb,
-                                              *(gre_key(greh)),
-                                              tuple->dst.u.gre.key, 0);
-               }
-               *(gre_key(greh)) = tuple->dst.u.gre.key;
+       case GRE_VERSION_1701:
+               /* We do not currently NAT any GREv0 packets.
+                * Try to behave like "nf_nat_proto_unknown" */
                break;
        case GRE_VERSION_PPTP:
-               DEBUGP("call_id -> 0x%04x\n", ntohs(tuple->dst.u.gre.key));
+               pr_debug("call_id -> 0x%04x\n", ntohs(tuple->dst.u.gre.key));
                pgreh->call_id = tuple->dst.u.gre.key;
                break;
        default:
-               DEBUGP("can't nat unknown GRE version\n");
+               pr_debug("can't nat unknown GRE version\n");
                return 0;
        }
        return 1;