]> bbs.cooldavid.org Git - net-next-2.6.git/blobdiff - net/bridge/br_netfilter.c
[BRIDGE]: faster compare for link local addresses
[net-next-2.6.git] / net / bridge / br_netfilter.c
index 7712d76f06ba8b22ba394d57d7e0d007034fe383..ebe740f6b902b3e378fe89cd7e5397471239e718 100644 (file)
@@ -48,8 +48,8 @@
 
 #define skb_origaddr(skb)       (((struct bridge_skb_cb *) \
                                 (skb->nf_bridge->data))->daddr.ipv4)
-#define store_orig_dstaddr(skb)         (skb_origaddr(skb) = (skb)->nh.iph->daddr)
-#define dnat_took_place(skb)    (skb_origaddr(skb) != (skb)->nh.iph->daddr)
+#define store_orig_dstaddr(skb)         (skb_origaddr(skb) = ip_hdr(skb)->daddr)
+#define dnat_took_place(skb)    (skb_origaddr(skb) != ip_hdr(skb)->daddr)
 
 #ifdef CONFIG_SYSCTL
 static struct ctl_table_header *brnf_sysctl_header;
@@ -61,7 +61,7 @@ static int brnf_filter_vlan_tagged __read_mostly = 1;
 #define brnf_filter_vlan_tagged 1
 #endif
 
-static __be16 inline vlan_proto(const struct sk_buff *skb)
+static inline __be16 vlan_proto(const struct sk_buff *skb)
 {
        return vlan_eth_hdr(skb)->h_vlan_encapsulated_proto;
 }
@@ -265,7 +265,7 @@ static int br_nf_pre_routing_finish_bridge(struct sk_buff *skb)
 static int br_nf_pre_routing_finish(struct sk_buff *skb)
 {
        struct net_device *dev = skb->dev;
-       struct iphdr *iph = skb->nh.iph;
+       struct iphdr *iph = ip_hdr(skb);
        struct nf_bridge_info *nf_bridge = skb->nf_bridge;
        int err;
 
@@ -374,7 +374,8 @@ static int check_hbh_len(struct sk_buff *skb)
 {
        unsigned char *raw = (u8 *) (skb->nh.ipv6h + 1);
        u32 pkt_len;
-       int off = raw - skb->nh.raw;
+       const unsigned char *nh = skb_network_header(skb);
+       int off = raw - nh;
        int len = (raw[1] + 1) << 3;
 
        if ((raw + len) - skb->data > skb_headlen(skb))
@@ -384,9 +385,9 @@ static int check_hbh_len(struct sk_buff *skb)
        len -= 2;
 
        while (len > 0) {
-               int optlen = skb->nh.raw[off + 1] + 2;
+               int optlen = nh[off + 1] + 2;
 
-               switch (skb->nh.raw[off]) {
+               switch (nh[off]) {
                case IPV6_TLV_PAD0:
                        optlen = 1;
                        break;
@@ -395,9 +396,9 @@ static int check_hbh_len(struct sk_buff *skb)
                        break;
 
                case IPV6_TLV_JUMBO:
-                       if (skb->nh.raw[off + 1] != 4 || (off & 3) != 2)
+                       if (nh[off + 1] != 4 || (off & 3) != 2)
                                goto bad;
-                       pkt_len = ntohl(*(__be32 *) (skb->nh.raw + off + 2));
+                       pkt_len = ntohl(*(__be32 *) (nh + off + 2));
                        if (pkt_len <= IPV6_MAXPLEN ||
                            skb->nh.ipv6h->payload_len)
                                goto bad;
@@ -406,6 +407,7 @@ static int check_hbh_len(struct sk_buff *skb)
                        if (pskb_trim_rcsum(skb,
                                            pkt_len + sizeof(struct ipv6hdr)))
                                goto bad;
+                       nh = skb_network_header(skb);
                        break;
                default:
                        if (optlen > len)
@@ -518,14 +520,14 @@ static unsigned int br_nf_pre_routing(unsigned int hook, struct sk_buff **pskb,
        if (!pskb_may_pull(skb, sizeof(struct iphdr)))
                goto inhdr_error;
 
-       iph = skb->nh.iph;
+       iph = ip_hdr(skb);
        if (iph->ihl < 5 || iph->version != 4)
                goto inhdr_error;
 
        if (!pskb_may_pull(skb, 4 * iph->ihl))
                goto inhdr_error;
 
-       iph = skb->nh.iph;
+       iph = ip_hdr(skb);
        if (ip_fast_csum((__u8 *) iph, iph->ihl) != 0)
                goto inhdr_error;
 
@@ -753,7 +755,8 @@ static unsigned int br_nf_post_routing(unsigned int hook, struct sk_buff **pskb,
 #ifdef CONFIG_NETFILTER_DEBUG
        /* Be very paranoid. This probably won't happen anymore, but let's
         * keep the check just to be sure... */
-       if (skb->mac.raw < skb->head || skb->mac.raw + ETH_HLEN > skb->data) {
+       if (skb_mac_header(skb) < skb->head ||
+           skb_mac_header(skb) + ETH_HLEN > skb->data) {
                printk(KERN_CRIT "br_netfilter: Argh!! br_nf_post_routing: "
                       "bad mac.raw pointer.\n");
                goto print_error;
@@ -808,7 +811,7 @@ print_error:
                if (realoutdev)
                        printk("[%s]", realoutdev->name);
        }
-       printk(" head:%p, raw:%p, data:%p\n", skb->head, skb->mac.raw,
+       printk(" head:%p, raw:%p, data:%p\n", skb->head, skb_mac_header(skb),
               skb->data);
        dump_stack();
        return NF_ACCEPT;