]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - net/bridge/br_netfilter.c
net: fix race condition in several drivers when reading stats
[karo-tx-linux.git] / net / bridge / br_netfilter.c
index 20fa719889eea3bd86725c88b39bd1be5cad91aa..68e8f364bbf8e01fbae9134eb98a24fa676d0e51 100644 (file)
@@ -111,7 +111,13 @@ static inline __be16 pppoe_proto(const struct sk_buff *skb)
         pppoe_proto(skb) == htons(PPP_IPV6) && \
         brnf_filter_pppoe_tagged)
 
-static void fake_update_pmtu(struct dst_entry *dst, u32 mtu)
+static void fake_update_pmtu(struct dst_entry *dst, struct sock *sk,
+                            struct sk_buff *skb, u32 mtu)
+{
+}
+
+static void fake_redirect(struct dst_entry *dst, struct sock *sk,
+                         struct sk_buff *skb)
 {
 }
 
@@ -120,7 +126,9 @@ static u32 *fake_cow_metrics(struct dst_entry *dst, unsigned long old)
        return NULL;
 }
 
-static struct neighbour *fake_neigh_lookup(const struct dst_entry *dst, const void *daddr)
+static struct neighbour *fake_neigh_lookup(const struct dst_entry *dst,
+                                          struct sk_buff *skb,
+                                          const void *daddr)
 {
        return NULL;
 }
@@ -134,6 +142,7 @@ static struct dst_ops fake_dst_ops = {
        .family =               AF_INET,
        .protocol =             cpu_to_be16(ETH_P_IP),
        .update_pmtu =          fake_update_pmtu,
+       .redirect =             fake_redirect,
        .cow_metrics =          fake_cow_metrics,
        .neigh_lookup =         fake_neigh_lookup,
        .mtu =                  fake_mtu,
@@ -373,19 +382,29 @@ static int br_nf_pre_routing_finish_bridge(struct sk_buff *skb)
        if (!skb->dev)
                goto free_skb;
        dst = skb_dst(skb);
-       neigh = dst_get_neighbour_noref(dst);
-       if (neigh->hh.hh_len) {
-               neigh_hh_bridge(&neigh->hh, skb);
-               skb->dev = nf_bridge->physindev;
-               return br_handle_frame_finish(skb);
-       } else {
-               /* the neighbour function below overwrites the complete
-                * MAC header, so we save the Ethernet source address and
-                * protocol number. */
-               skb_copy_from_linear_data_offset(skb, -(ETH_HLEN-ETH_ALEN), skb->nf_bridge->data, ETH_HLEN-ETH_ALEN);
-               /* tell br_dev_xmit to continue with forwarding */
-               nf_bridge->mask |= BRNF_BRIDGED_DNAT;
-               return neigh->output(neigh, skb);
+       neigh = dst_neigh_lookup_skb(dst, skb);
+       if (neigh) {
+               int ret;
+
+               if (neigh->hh.hh_len) {
+                       neigh_hh_bridge(&neigh->hh, skb);
+                       skb->dev = nf_bridge->physindev;
+                       ret = br_handle_frame_finish(skb);
+               } else {
+                       /* the neighbour function below overwrites the complete
+                        * MAC header, so we save the Ethernet source address and
+                        * protocol number.
+                        */
+                       skb_copy_from_linear_data_offset(skb,
+                                                        -(ETH_HLEN-ETH_ALEN),
+                                                        skb->nf_bridge->data,
+                                                        ETH_HLEN-ETH_ALEN);
+                       /* tell br_dev_xmit to continue with forwarding */
+                       nf_bridge->mask |= BRNF_BRIDGED_DNAT;
+                       ret = neigh->output(neigh, skb);
+               }
+               neigh_release(neigh);
+               return ret;
        }
 free_skb:
        kfree_skb(skb);