]> git.karo-electronics.de Git - mv-sheeva.git/blobdiff - net/ipv4/netfilter/nf_nat_proto_gre.c
Merge branch 'for-2.6.34' of git://linux-nfs.org/~bfields/linux
[mv-sheeva.git] / net / ipv4 / netfilter / nf_nat_proto_gre.c
index a1e4da16da2e8a411fc39b6009c4b4f1151d0a09..d7e89201351e90d01bbbac1666e913f90e036dbf 100644 (file)
@@ -36,26 +36,8 @@ MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Harald Welte <laforge@gnumonks.org>");
 MODULE_DESCRIPTION("Netfilter NAT protocol helper module for GRE");
 
-/* is key in given range between min and max */
-static int
-gre_in_range(const struct nf_conntrack_tuple *tuple,
-            enum nf_nat_manip_type maniptype,
-            const union nf_conntrack_man_proto *min,
-            const union nf_conntrack_man_proto *max)
-{
-       __be16 key;
-
-       if (maniptype == IP_NAT_MANIP_SRC)
-               key = tuple->src.u.gre.key;
-       else
-               key = tuple->dst.u.gre.key;
-
-       return ntohs(key) >= ntohs(min->gre.key) &&
-              ntohs(key) <= ntohs(max->gre.key);
-}
-
 /* generate unique tuple ... */
-static int
+static bool
 gre_unique_tuple(struct nf_conntrack_tuple *tuple,
                 const struct nf_nat_range *range,
                 enum nf_nat_manip_type maniptype,
@@ -68,7 +50,7 @@ gre_unique_tuple(struct nf_conntrack_tuple *tuple,
        /* If there is no master conntrack we are not PPTP,
           do not change tuples */
        if (!ct->master)
-               return 0;
+               return false;
 
        if (maniptype == IP_NAT_MANIP_SRC)
                keyptr = &tuple->src.u.gre.key;
@@ -89,20 +71,20 @@ gre_unique_tuple(struct nf_conntrack_tuple *tuple,
        for (i = 0; i < range_size; i++, key++) {
                *keyptr = htons(min + key % range_size);
                if (!nf_nat_used_tuple(tuple, ct))
-                       return 1;
+                       return true;
        }
 
        pr_debug("%p: no NAT mapping\n", ct);
-       return 0;
+       return false;
 }
 
 /* manipulate a GRE packet according to maniptype */
-static int
+static bool
 gre_manip_pkt(struct sk_buff *skb, unsigned int iphdroff,
              const struct nf_conntrack_tuple *tuple,
              enum nf_nat_manip_type maniptype)
 {
-       struct gre_hdr *greh;
+       const struct gre_hdr *greh;
        struct gre_hdr_pptp *pgreh;
        const struct iphdr *iph = (struct iphdr *)(skb->data + iphdroff);
        unsigned int hdroff = iphdroff + iph->ihl * 4;
@@ -110,7 +92,7 @@ gre_manip_pkt(struct sk_buff *skb, unsigned int iphdroff,
        /* pgreh includes two optional 32bit fields which are not required
         * to be there.  That's where the magic '8' comes from */
        if (!skb_make_writable(skb, hdroff + sizeof(*pgreh) - 8))
-               return 0;
+               return false;
 
        greh = (void *)skb->data + hdroff;
        pgreh = (struct gre_hdr_pptp *)greh;
@@ -118,7 +100,7 @@ gre_manip_pkt(struct sk_buff *skb, unsigned int iphdroff,
        /* we only have destination manip of a packet, since 'source key'
         * is not present in the packet itself */
        if (maniptype != IP_NAT_MANIP_DST)
-               return 1;
+               return true;
        switch (greh->version) {
        case GRE_VERSION_1701:
                /* We do not currently NAT any GREv0 packets.
@@ -130,21 +112,20 @@ gre_manip_pkt(struct sk_buff *skb, unsigned int iphdroff,
                break;
        default:
                pr_debug("can't nat unknown GRE version\n");
-               return 0;
+               return false;
        }
-       return 1;
+       return true;
 }
 
 static const struct nf_nat_protocol gre = {
-       .name                   = "GRE",
        .protonum               = IPPROTO_GRE,
        .me                     = THIS_MODULE,
        .manip_pkt              = gre_manip_pkt,
-       .in_range               = gre_in_range,
+       .in_range               = nf_nat_proto_in_range,
        .unique_tuple           = gre_unique_tuple,
 #if defined(CONFIG_NF_CT_NETLINK) || defined(CONFIG_NF_CT_NETLINK_MODULE)
-       .range_to_nlattr        = nf_nat_port_range_to_nlattr,
-       .nlattr_to_range        = nf_nat_port_nlattr_to_range,
+       .range_to_nlattr        = nf_nat_proto_range_to_nlattr,
+       .nlattr_to_range        = nf_nat_proto_nlattr_to_range,
 #endif
 };