On 11/05/18 00:11, Sven Eckelmann wrote: [...]
@@ -683,9 +690,14 @@ static int batadv_interface_add_vid(struct net_device
*dev, __be16 proto,
* flag. This must be added again, even if the vlan object already * exists, because the entry was deleted by kill_vid() */
- batadv_tt_local_add(bat_priv->soft_iface,
bat_priv->soft_iface->dev_addr, vid,
BATADV_NULL_IFINDEX, BATADV_NO_MARK);
- client_added = batadv_tt_local_add(bat_priv->soft_iface,
bat_priv->soft_iface->dev_addr, vid,
BATADV_NULL_IFINDEX, BATADV_NO_MARK);
- if (!client_added) {
batadv_softif_destroy_vlan(bat_priv, vlan);
return -ENOENT;
- }
This looks quite fragile to me. Wouldn't that mean that the vlan would also not be created later? When I remember it correctly, then batadv_interface_add_vid is the only one which would create the internal vlan entries in the first place (beside this odd call in batadv_hard_if_event). The VLAN functionality would therefore be completely broken when such a problem happens.
- batadv_interface_add_vid is called
- vlan is added
- local entry is not added for this vlan
3.1. vlan is removed again 4. node tries to communicate over this vlan
A failure of this function will cause a failure of the ndo_vlan_rx_add_vid() call made by the kernel/netlink API which in turns will reach the userspace.
Ideally any userspace application that attempted to create the VLAN should be in charge of re-attempting the creation again (I believe).
About your point 4, this should not be possible, because in case of error the bat0.X interface won't be created by the kernel at all. no?
Btw. it is really odd to see code shared between batadv_interface_add_vid and batadv_softif_create_vlan. Especially because batadv_interface_add_vid calls batadv_softif_create_vlan.
This can probably be re-arranged a bit in the master branch.
Cheers,