batman-adv: add dynamic, bridged-in TT VID detection support
PATCH 1/1 batman-adv: add dynamic, bridged-in TT VID detection support
So far, if we wanted bridge VLAN tagged frames into the mesh one would need to manually create an according VLAN interface on top of bat0 first, to trigger batman-adv to create the according structures for a VID.
With this change the VLAN from bridged-in clients is now automatically detected and added to the translation table on the fly.
Signed-off-by Linus Lüssing <[email protected]>
--- net/batman-adv/hard-interface.c | 2 +- net/batman-adv/multicast.c | 8 +- net/batman-adv/soft-interface.c | 121 ++++++++++++++++------------- net/batman-adv/soft-interface.h | 6 +- net/batman-adv/translation-table.c | 19 ++--- net/batman-adv/translation-table.h | 4 +- 6 files changed, 88 insertions(+), 72 deletions(-)
net/batman-adv/hard-interface.c +1 -1
@@ -946,7 +946,7 @@ static int batadv_hard_if_event_softif(unsigned long event,switch (event) {case NETDEV_REGISTER : bat_priv =netdev_priv (net_dev); -batadv_softif_create_vlan (bat_priv,BATADV_NO_FLAGS ); +batadv_softif_create_vlan_own (bat_priv,BATADV_NO_FLAGS );break ; }
net/batman-adv/multicast.c +5 -3
@@ -724,6 +724,7 @@ static void batadv_mcast_mla_tt_add(struct batadv_priv *bat_priv, {struct batadv_hw_addr *mcast_entry;struct hlist_node *tmp; +int ret;if (!mcast_list)return ;
@@ -733,9 +734,10 @@ static void batadv_mcast_mla_tt_add(struct batadv_priv *bat_priv, &bat_priv->mcast.mla_list))continue ; -if (!batadv_tt_local_add (bat_priv->soft_iface, - mcast_entry->addr,BATADV_NO_FLAGS , -BATADV_NULL_IFINDEX ,BATADV_NO_MARK )) + ret =batadv_tt_local_add (bat_priv->soft_iface, + mcast_entry->addr,BATADV_NO_FLAGS , +BATADV_NULL_IFINDEX ,BATADV_NO_MARK ); +if (ret <=0 )continue ;hlist_del (&mcast_entry->list);
net/batman-adv/soft-interface.c +65 -56
205 lines not on this page · raw message
net/batman-adv/soft-interface.h +5 -1
@@ -21,10 +21,14 @@ void batadv_interface_rx(struct net_device *soft_iface, struct batadv_orig_node *orig_node);bool batadv_softif_is_valid (const struct net_device *net_dev);extern struct rtnl_link_ops batadv_link_ops; -int batadv_softif_create_vlan (struct batadv_priv *bat_priv,unsigned short vid); +int batadv_softif_create_vlan_own (struct batadv_priv *bat_priv, +unsigned short vid);void batadv_softif_vlan_release (struct kref *ref);struct batadv_softif_vlan *batadv_softif_vlan_get (struct batadv_priv *bat_priv,unsigned short vid); +struct batadv_softif_vlan * +batadv_softif_vlan_get_or_create (struct batadv_priv *bat_priv, +unsigned short vid);/** * batadv_softif_vlan_put() - decrease the vlan object refcounter and
net/batman-adv/translation-table.c +10 -9
@@ -591,8 +591,8 @@ static void batadv_tt_global_free(struct batadv_priv *bat_priv,* * Return: true if the client was successfully added, false otherwise. */ -bool batadv_tt_local_add (struct net_device *soft_iface,const u8 *addr, -unsigned short vid,int ifindex,u32 mark) +int batadv_tt_local_add (struct net_device *soft_iface,const u8 *addr, +unsigned short vid,int ifindex,u32 mark) {struct batadv_priv *bat_priv =netdev_priv (soft_iface);struct batadv_tt_local_entry *tt_local;
@@ -604,10 +604,10 @@ bool batadv_tt_local_add(struct net_device *soft_iface, const u8 *addr,struct hlist_head *head;struct batadv_tt_orig_list_entry *orig_entry;int hash_added, table_size, packet_size_max; -bool ret = false;bool roamed_back = false;u8 remote_flags;u32 match_mark; +int ret =0 ;if (ifindex !=BATADV_NULL_IFINDEX ) in_dev =dev_get_by_index (net, ifindex);
@@ -658,21 +658,22 @@ bool batadv_tt_local_add(struct net_device *soft_iface, const u8 *addr,net_ratelimited_function (batadv_info, soft_iface,"Local translation table size (%i) exceeds maximum packet size (%i); Ignoring new local tt entry: %pM\n" , table_size, packet_size_max, addr); + ret = -E2BIG ; goto out; } tt_local =kmem_cache_alloc (batadv_tl_cache,GFP_ATOMIC ); -if (!tt_local) +if (!tt_local) { + ret = -ENOMEM ; goto out; + }/* increase the refcounter of the related vlan */ - vlan =batadv_softif_vlan_get (bat_priv, vid); + vlan =batadv_softif_vlan_get_or_create (bat_priv, vid);if (!vlan) { -net_ratelimited_function (batadv_info, soft_iface, -"adding TT local entry %pM to non-existent VLAN %d\n" , - addr,batadv_print_vid (vid));kmem_cache_free (batadv_tl_cache, tt_local); tt_local =NULL ; + ret = -ENOMEM ; goto out; }
@@ -769,7 +770,7 @@ bool batadv_tt_local_add(struct net_device *soft_iface, const u8 *addr,if (remote_flags ^ (tt_local->common.flags &BATADV_TT_REMOTE_MASK ))batadv_tt_local_event (bat_priv, tt_local,BATADV_NO_FLAGS ); - ret = true; + ret =1 ; out:batadv_hardif_put (in_hardif);dev_put (in_dev);
net/batman-adv/translation-table.h +2 -2
@@ -16,8 +16,8 @@#include <linux/types.h> int batadv_tt_init (struct batadv_priv *bat_priv); -bool batadv_tt_local_add (struct net_device *soft_iface,const u8 *addr, -unsigned short vid,int ifindex,u32 mark); +int batadv_tt_local_add (struct net_device *soft_iface,const u8 *addr, +unsigned short vid,int ifindex,u32 mark);u16 batadv_tt_local_remove (struct batadv_priv *bat_priv,const u8 *addr,unsigned short vid,const char *message,bool roaming);
Signature · 1 line
2.45.1