batman-adv: fix mac addr change and symmetry check
[feed/routing.git] / patches / 0002-batman-adv-Fix-change-mac-address-of-soft-iface.patch
1 From 86fa71a4985f60da5918e1f43136dae77852cdc3 Mon Sep 17 00:00:00 2001
2 From: Def <def@laposte.net>
3 Date: Thu, 20 Sep 2012 14:56:13 +0200
4 Subject: [PATCH] batman-adv: Fix change mac address of soft iface.
5
6 Into function interface_set_mac_addr, the function tt_local_add was
7 invoked before updating dev->dev_addr. The new MAC address was not
8 tagged as NoPurge.
9
10 Signed-off-by: Def <def@laposte.net>
11 ---
12 soft-interface.c | 7 +++++--
13 1 files changed, 5 insertions(+), 2 deletions(-)
14
15 diff --git a/soft-interface.c b/soft-interface.c
16 index cf26e41..b762068 100644
17 --- a/soft-interface.c
18 +++ b/soft-interface.c
19 @@ -100,18 +100,21 @@ static int batadv_interface_set_mac_addr(struct net_device *dev, void *p)
20 {
21 struct batadv_priv *bat_priv = netdev_priv(dev);
22 struct sockaddr *addr = p;
23 + uint8_t old_addr[ETH_ALEN];
24
25 if (!is_valid_ether_addr(addr->sa_data))
26 return -EADDRNOTAVAIL;
27
28 + memcpy(old_addr, dev->dev_addr, ETH_ALEN);
29 + memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN);
30 +
31 /* only modify transtable if it has been initialized before */
32 if (atomic_read(&bat_priv->mesh_state) == BATADV_MESH_ACTIVE) {
33 - batadv_tt_local_remove(bat_priv, dev->dev_addr,
34 + batadv_tt_local_remove(bat_priv, old_addr,
35 "mac address changed", false);
36 batadv_tt_local_add(dev, addr->sa_data, BATADV_NULL_IFINDEX);
37 }
38
39 - memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN);
40 dev->addr_assign_type &= ~NET_ADDR_RANDOM;
41 return 0;
42 }
43 --
44 1.7.9.1
45