batman-adv: Fix potentially broken skb network header access
authorLinus Lüssing <linus.luessing@c0d3.blue>
Tue, 30 Jun 2015 21:45:26 +0000 (23:45 +0200)
committerAntonio Quartulli <antonio@meshcoding.com>
Fri, 14 Aug 2015 20:52:10 +0000 (22:52 +0200)
The two commits noted below added calls to ip_hdr() and ipv6_hdr(). They
need a correctly set skb network header.

Unfortunately we cannot rely on the device drivers to set it for us.
Therefore setting it in the beginning of the according ndo_start_xmit
handler.

Fixes: 1d8ab8d3c176 ("batman-adv: Modified forwarding behaviour for multicast packets")
Fixes: ab49886e3da7 ("batman-adv: Add IPv4 link-local/IPv6-ll-all-nodes multicast support")
Signed-off-by: Linus Lüssing <linus.luessing@c0d3.blue>
Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>
Signed-off-by: Antonio Quartulli <antonio@meshcoding.com>
net/batman-adv/soft-interface.c

index c002961da75d655deb813990f5706cf37fbd6d7d..926292d5ffa8a1d0f7ec7f97c2debce9d2965c45 100644 (file)
@@ -202,6 +202,7 @@ static int batadv_interface_tx(struct sk_buff *skb,
        int gw_mode;
        enum batadv_forw_mode forw_mode;
        struct batadv_orig_node *mcast_single_orig = NULL;
+       int network_offset = ETH_HLEN;
 
        if (atomic_read(&bat_priv->mesh_state) != BATADV_MESH_ACTIVE)
                goto dropped;
@@ -214,14 +215,18 @@ static int batadv_interface_tx(struct sk_buff *skb,
        case ETH_P_8021Q:
                vhdr = vlan_eth_hdr(skb);
 
-               if (vhdr->h_vlan_encapsulated_proto != ethertype)
+               if (vhdr->h_vlan_encapsulated_proto != ethertype) {
+                       network_offset += VLAN_HLEN;
                        break;
+               }
 
                /* fall through */
        case ETH_P_BATMAN:
                goto dropped;
        }
 
+       skb_set_network_header(skb, network_offset);
+
        if (batadv_bla_tx(bat_priv, skb, vid))
                goto dropped;