Merge tag 'batadv-next-for-davem-20190213' of git://git.open-mesh.org/linux-merge
[sfrench/cifs-2.6.git] / net / batman-adv / soft-interface.c
index 5db5a0a4c959b796c86315832f64073b5642e46a..5cb4a2f53a2f8180551c88c53adf94d6db212288 100644 (file)
@@ -1,5 +1,5 @@
 // SPDX-License-Identifier: GPL-2.0
-/* Copyright (C) 2007-2018  B.A.T.M.A.N. contributors:
+/* Copyright (C) 2007-2019  B.A.T.M.A.N. contributors:
  *
  * Marek Lindner, Simon Wunderlich
  *
 #include <linux/string.h>
 #include <linux/types.h>
 #include <uapi/linux/batadv_packet.h>
+#include <uapi/linux/batman_adv.h>
 
 #include "bat_algo.h"
 #include "bridge_loop_avoidance.h"
 #include "debugfs.h"
 #include "distributed-arp-table.h"
 #include "gateway_client.h"
-#include "gateway_common.h"
 #include "hard-interface.h"
 #include "multicast.h"
 #include "network-coding.h"
@@ -212,6 +212,7 @@ static netdev_tx_t batadv_interface_tx(struct sk_buff *skb,
        enum batadv_forw_mode forw_mode;
        struct batadv_orig_node *mcast_single_orig = NULL;
        int network_offset = ETH_HLEN;
+       __be16 proto;
 
        if (atomic_read(&bat_priv->mesh_state) != BATADV_MESH_ACTIVE)
                goto dropped;
@@ -221,14 +222,19 @@ static netdev_tx_t batadv_interface_tx(struct sk_buff *skb,
 
        netif_trans_update(soft_iface);
        vid = batadv_get_vid(skb, 0);
+
+       skb_reset_mac_header(skb);
        ethhdr = eth_hdr(skb);
 
-       switch (ntohs(ethhdr->h_proto)) {
+       proto = ethhdr->h_proto;
+
+       switch (ntohs(proto)) {
        case ETH_P_8021Q:
                vhdr = vlan_eth_hdr(skb);
+               proto = vhdr->h_vlan_encapsulated_proto;
 
                /* drop batman-in-batman packets to prevent loops */
-               if (vhdr->h_vlan_encapsulated_proto != htons(ETH_P_BATMAN)) {
+               if (proto != htons(ETH_P_BATMAN)) {
                        network_offset += VLAN_HLEN;
                        break;
                }
@@ -256,6 +262,9 @@ static netdev_tx_t batadv_interface_tx(struct sk_buff *skb,
                        goto dropped;
        }
 
+       /* Snoop address candidates from DHCPACKs for early DAT filling */
+       batadv_dat_snoop_outgoing_dhcp_ack(bat_priv, skb, proto, vid);
+
        /* don't accept stp packets. STP does not help in meshes.
         * better use the bridge loop avoidance ...
         *