aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2018-07-18 16:50:12 -0400
committerDavid S. Miller <davem@davemloft.net>2018-07-18 16:50:12 -0400
commit9640ccce30055dea452d12172932ad7e07b59976 (patch)
tree70fba612556fc63479bec5a6d57904b0c68862b5
parent53189183909f392c2aff1177565eabbfc48b8524 (diff)
parenta44ebeff6bbd6ef50db41b4195fca87b21aefd20 (diff)
Merge tag 'batadv-net-for-davem-20180717' of git://git.open-mesh.org/linux-merge
Simon Wunderlich says: ==================== Here are some batman-adv fixes: - Fix gateway refcounting in BATMAN IV and V, by Sven Eckelmann (2 patches) - Fix debugfs paths when renaming interfaces, by Sven Eckelmann (2 patches) - Fix TT flag issues, by Linus Luessing (2 patches) ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--net/batman-adv/bat_iv_ogm.c4
-rw-r--r--net/batman-adv/bat_v.c4
-rw-r--r--net/batman-adv/debugfs.c40
-rw-r--r--net/batman-adv/debugfs.h11
-rw-r--r--net/batman-adv/hard-interface.c37
-rw-r--r--net/batman-adv/translation-table.c7
6 files changed, 93 insertions, 10 deletions
diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
index be09a9883825..73bf6a93a3cf 100644
--- a/net/batman-adv/bat_iv_ogm.c
+++ b/net/batman-adv/bat_iv_ogm.c
@@ -2732,7 +2732,7 @@ static int batadv_iv_gw_dump_entry(struct sk_buff *msg, u32 portid, u32 seq,
2732{ 2732{
2733 struct batadv_neigh_ifinfo *router_ifinfo = NULL; 2733 struct batadv_neigh_ifinfo *router_ifinfo = NULL;
2734 struct batadv_neigh_node *router; 2734 struct batadv_neigh_node *router;
2735 struct batadv_gw_node *curr_gw; 2735 struct batadv_gw_node *curr_gw = NULL;
2736 int ret = 0; 2736 int ret = 0;
2737 void *hdr; 2737 void *hdr;
2738 2738
@@ -2780,6 +2780,8 @@ static int batadv_iv_gw_dump_entry(struct sk_buff *msg, u32 portid, u32 seq,
2780 ret = 0; 2780 ret = 0;
2781 2781
2782out: 2782out:
2783 if (curr_gw)
2784 batadv_gw_node_put(curr_gw);
2783 if (router_ifinfo) 2785 if (router_ifinfo)
2784 batadv_neigh_ifinfo_put(router_ifinfo); 2786 batadv_neigh_ifinfo_put(router_ifinfo);
2785 if (router) 2787 if (router)
diff --git a/net/batman-adv/bat_v.c b/net/batman-adv/bat_v.c
index ec93337ee259..6baec4e68898 100644
--- a/net/batman-adv/bat_v.c
+++ b/net/batman-adv/bat_v.c
@@ -927,7 +927,7 @@ static int batadv_v_gw_dump_entry(struct sk_buff *msg, u32 portid, u32 seq,
927{ 927{
928 struct batadv_neigh_ifinfo *router_ifinfo = NULL; 928 struct batadv_neigh_ifinfo *router_ifinfo = NULL;
929 struct batadv_neigh_node *router; 929 struct batadv_neigh_node *router;
930 struct batadv_gw_node *curr_gw; 930 struct batadv_gw_node *curr_gw = NULL;
931 int ret = 0; 931 int ret = 0;
932 void *hdr; 932 void *hdr;
933 933
@@ -995,6 +995,8 @@ static int batadv_v_gw_dump_entry(struct sk_buff *msg, u32 portid, u32 seq,
995 ret = 0; 995 ret = 0;
996 996
997out: 997out:
998 if (curr_gw)
999 batadv_gw_node_put(curr_gw);
998 if (router_ifinfo) 1000 if (router_ifinfo)
999 batadv_neigh_ifinfo_put(router_ifinfo); 1001 batadv_neigh_ifinfo_put(router_ifinfo);
1000 if (router) 1002 if (router)
diff --git a/net/batman-adv/debugfs.c b/net/batman-adv/debugfs.c
index 4229b01ac7b5..87479c60670e 100644
--- a/net/batman-adv/debugfs.c
+++ b/net/batman-adv/debugfs.c
@@ -19,6 +19,7 @@
19#include "debugfs.h" 19#include "debugfs.h"
20#include "main.h" 20#include "main.h"
21 21
22#include <linux/dcache.h>
22#include <linux/debugfs.h> 23#include <linux/debugfs.h>
23#include <linux/err.h> 24#include <linux/err.h>
24#include <linux/errno.h> 25#include <linux/errno.h>
@@ -344,6 +345,25 @@ out:
344} 345}
345 346
346/** 347/**
348 * batadv_debugfs_rename_hardif() - Fix debugfs path for renamed hardif
349 * @hard_iface: hard interface which was renamed
350 */
351void batadv_debugfs_rename_hardif(struct batadv_hard_iface *hard_iface)
352{
353 const char *name = hard_iface->net_dev->name;
354 struct dentry *dir;
355 struct dentry *d;
356
357 dir = hard_iface->debug_dir;
358 if (!dir)
359 return;
360
361 d = debugfs_rename(dir->d_parent, dir, dir->d_parent, name);
362 if (!d)
363 pr_err("Can't rename debugfs dir to %s\n", name);
364}
365
366/**
347 * batadv_debugfs_del_hardif() - delete the base directory for a hard interface 367 * batadv_debugfs_del_hardif() - delete the base directory for a hard interface
348 * in debugfs. 368 * in debugfs.
349 * @hard_iface: hard interface which is deleted. 369 * @hard_iface: hard interface which is deleted.
@@ -414,6 +434,26 @@ out:
414} 434}
415 435
416/** 436/**
437 * batadv_debugfs_rename_meshif() - Fix debugfs path for renamed softif
438 * @dev: net_device which was renamed
439 */
440void batadv_debugfs_rename_meshif(struct net_device *dev)
441{
442 struct batadv_priv *bat_priv = netdev_priv(dev);
443 const char *name = dev->name;
444 struct dentry *dir;
445 struct dentry *d;
446
447 dir = bat_priv->debug_dir;
448 if (!dir)
449 return;
450
451 d = debugfs_rename(dir->d_parent, dir, dir->d_parent, name);
452 if (!d)
453 pr_err("Can't rename debugfs dir to %s\n", name);
454}
455
456/**
417 * batadv_debugfs_del_meshif() - Remove interface dependent debugfs entries 457 * batadv_debugfs_del_meshif() - Remove interface dependent debugfs entries
418 * @dev: netdev struct of the soft interface 458 * @dev: netdev struct of the soft interface
419 */ 459 */
diff --git a/net/batman-adv/debugfs.h b/net/batman-adv/debugfs.h
index 37b069698b04..08a592ffbee5 100644
--- a/net/batman-adv/debugfs.h
+++ b/net/batman-adv/debugfs.h
@@ -30,8 +30,10 @@ struct net_device;
30void batadv_debugfs_init(void); 30void batadv_debugfs_init(void);
31void batadv_debugfs_destroy(void); 31void batadv_debugfs_destroy(void);
32int batadv_debugfs_add_meshif(struct net_device *dev); 32int batadv_debugfs_add_meshif(struct net_device *dev);
33void batadv_debugfs_rename_meshif(struct net_device *dev);
33void batadv_debugfs_del_meshif(struct net_device *dev); 34void batadv_debugfs_del_meshif(struct net_device *dev);
34int batadv_debugfs_add_hardif(struct batadv_hard_iface *hard_iface); 35int batadv_debugfs_add_hardif(struct batadv_hard_iface *hard_iface);
36void batadv_debugfs_rename_hardif(struct batadv_hard_iface *hard_iface);
35void batadv_debugfs_del_hardif(struct batadv_hard_iface *hard_iface); 37void batadv_debugfs_del_hardif(struct batadv_hard_iface *hard_iface);
36 38
37#else 39#else
@@ -49,6 +51,10 @@ static inline int batadv_debugfs_add_meshif(struct net_device *dev)
49 return 0; 51 return 0;
50} 52}
51 53
54static inline void batadv_debugfs_rename_meshif(struct net_device *dev)
55{
56}
57
52static inline void batadv_debugfs_del_meshif(struct net_device *dev) 58static inline void batadv_debugfs_del_meshif(struct net_device *dev)
53{ 59{
54} 60}
@@ -60,6 +66,11 @@ int batadv_debugfs_add_hardif(struct batadv_hard_iface *hard_iface)
60} 66}
61 67
62static inline 68static inline
69void batadv_debugfs_rename_hardif(struct batadv_hard_iface *hard_iface)
70{
71}
72
73static inline
63void batadv_debugfs_del_hardif(struct batadv_hard_iface *hard_iface) 74void batadv_debugfs_del_hardif(struct batadv_hard_iface *hard_iface)
64{ 75{
65} 76}
diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
index c405d15befd6..2f0d42f2f913 100644
--- a/net/batman-adv/hard-interface.c
+++ b/net/batman-adv/hard-interface.c
@@ -989,6 +989,32 @@ void batadv_hardif_remove_interfaces(void)
989 rtnl_unlock(); 989 rtnl_unlock();
990} 990}
991 991
992/**
993 * batadv_hard_if_event_softif() - Handle events for soft interfaces
994 * @event: NETDEV_* event to handle
995 * @net_dev: net_device which generated an event
996 *
997 * Return: NOTIFY_* result
998 */
999static int batadv_hard_if_event_softif(unsigned long event,
1000 struct net_device *net_dev)
1001{
1002 struct batadv_priv *bat_priv;
1003
1004 switch (event) {
1005 case NETDEV_REGISTER:
1006 batadv_sysfs_add_meshif(net_dev);
1007 bat_priv = netdev_priv(net_dev);
1008 batadv_softif_create_vlan(bat_priv, BATADV_NO_FLAGS);
1009 break;
1010 case NETDEV_CHANGENAME:
1011 batadv_debugfs_rename_meshif(net_dev);
1012 break;
1013 }
1014
1015 return NOTIFY_DONE;
1016}
1017
992static int batadv_hard_if_event(struct notifier_block *this, 1018static int batadv_hard_if_event(struct notifier_block *this,
993 unsigned long event, void *ptr) 1019 unsigned long event, void *ptr)
994{ 1020{
@@ -997,12 +1023,8 @@ static int batadv_hard_if_event(struct notifier_block *this,
997 struct batadv_hard_iface *primary_if = NULL; 1023 struct batadv_hard_iface *primary_if = NULL;
998 struct batadv_priv *bat_priv; 1024 struct batadv_priv *bat_priv;
999 1025
1000 if (batadv_softif_is_valid(net_dev) && event == NETDEV_REGISTER) { 1026 if (batadv_softif_is_valid(net_dev))
1001 batadv_sysfs_add_meshif(net_dev); 1027 return batadv_hard_if_event_softif(event, net_dev);
1002 bat_priv = netdev_priv(net_dev);
1003 batadv_softif_create_vlan(bat_priv, BATADV_NO_FLAGS);
1004 return NOTIFY_DONE;
1005 }
1006 1028
1007 hard_iface = batadv_hardif_get_by_netdev(net_dev); 1029 hard_iface = batadv_hardif_get_by_netdev(net_dev);
1008 if (!hard_iface && (event == NETDEV_REGISTER || 1030 if (!hard_iface && (event == NETDEV_REGISTER ||
@@ -1051,6 +1073,9 @@ static int batadv_hard_if_event(struct notifier_block *this,
1051 if (batadv_is_wifi_hardif(hard_iface)) 1073 if (batadv_is_wifi_hardif(hard_iface))
1052 hard_iface->num_bcasts = BATADV_NUM_BCASTS_WIRELESS; 1074 hard_iface->num_bcasts = BATADV_NUM_BCASTS_WIRELESS;
1053 break; 1075 break;
1076 case NETDEV_CHANGENAME:
1077 batadv_debugfs_rename_hardif(hard_iface);
1078 break;
1054 default: 1079 default:
1055 break; 1080 break;
1056 } 1081 }
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
index 3986551397ca..12a2b7d21376 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -1705,7 +1705,9 @@ static bool batadv_tt_global_add(struct batadv_priv *bat_priv,
1705 ether_addr_copy(common->addr, tt_addr); 1705 ether_addr_copy(common->addr, tt_addr);
1706 common->vid = vid; 1706 common->vid = vid;
1707 1707
1708 common->flags = flags; 1708 if (!is_multicast_ether_addr(common->addr))
1709 common->flags = flags & (~BATADV_TT_SYNC_MASK);
1710
1709 tt_global_entry->roam_at = 0; 1711 tt_global_entry->roam_at = 0;
1710 /* node must store current time in case of roaming. This is 1712 /* node must store current time in case of roaming. This is
1711 * needed to purge this entry out on timeout (if nobody claims 1713 * needed to purge this entry out on timeout (if nobody claims
@@ -1768,7 +1770,8 @@ static bool batadv_tt_global_add(struct batadv_priv *bat_priv,
1768 * TT_CLIENT_TEMP, therefore they have to be copied in the 1770 * TT_CLIENT_TEMP, therefore they have to be copied in the
1769 * client entry 1771 * client entry
1770 */ 1772 */
1771 common->flags |= flags & (~BATADV_TT_SYNC_MASK); 1773 if (!is_multicast_ether_addr(common->addr))
1774 common->flags |= flags & (~BATADV_TT_SYNC_MASK);
1772 1775
1773 /* If there is the BATADV_TT_CLIENT_ROAM flag set, there is only 1776 /* If there is the BATADV_TT_CLIENT_ROAM flag set, there is only
1774 * one originator left in the list and we previously received a 1777 * one originator left in the list and we previously received a