From: Jiri Pirko jiri@mellanox.com
Kernel exposes an interface primary used by bridge to work with FDB entries. However, other devices (for example SR-IOV drivers) implement this as well making this not bridge-specific.
Allow task to work with the bridge FDB entries. This is implemented simply by calling "bridge" utility. This may be later on changed to pyroute2 implementation, alas it does not implement PF_BRIDGE Netlink at the moment.
Signed-off-by: Jiri Pirko jiri@mellanox.com --- lnst/Controller/Machine.py | 8 ++++++++ lnst/Controller/Task.py | 8 ++++++++ lnst/Slave/BridgeTool.py | 17 +++++++++++++++++ lnst/Slave/NetTestSlave.py | 18 ++++++++++++++++++ 4 files changed, 51 insertions(+)
diff --git a/lnst/Controller/Machine.py b/lnst/Controller/Machine.py index b457c3c..12f8757 100644 --- a/lnst/Controller/Machine.py +++ b/lnst/Controller/Machine.py @@ -772,6 +772,14 @@ class Interface(object): self._machine._rpc_call_x(self._netns, "del_br_vlan", self._id, br_vlan_info)
+ def add_br_fdb(self, br_fdb_info): + self._machine._rpc_call_x(self._netns, "add_br_fdb", + self._id, br_fdb_info) + + def del_br_fdb(self, br_fdb_info): + self._machine._rpc_call_x(self._netns, "del_br_fdb", + self._id, br_fdb_info) + class StaticInterface(Interface): """ Static interface
diff --git a/lnst/Controller/Task.py b/lnst/Controller/Task.py index 3c5b71d..e47b025 100644 --- a/lnst/Controller/Task.py +++ b/lnst/Controller/Task.py @@ -520,6 +520,14 @@ class InterfaceAPI(object): "untagged": untagged, "self": self, "master": master})
+ def add_br_fdb(_self, hwaddr, self=False, master=False, vlan_tci=None): + _self._if.add_br_fdb({"hwaddr": hwaddr, "self": self, "master": master, + "vlan_id": vlan_tci}) + + def del_br_fdb(_self, hwaddr, self=False, master=False, vlan_tci=None): + _self._if.del_br_fdb({"hwaddr": hwaddr, "self": self, "master": master, + "vlan_id": vlan_tci}) + class ModuleAPI(object): """ An API class representing a module. """
diff --git a/lnst/Slave/BridgeTool.py b/lnst/Slave/BridgeTool.py index 017ed1e..1d87cd9 100644 --- a/lnst/Slave/BridgeTool.py +++ b/lnst/Slave/BridgeTool.py @@ -34,3 +34,20 @@ class BridgeTool:
def del_vlan(self, br_vlan_info): return self._add_del_vlan("del", br_vlan_info) + + def _add_del_fdb(self, op, br_fdb_info): + cmd = "bridge fdb %s %s dev %s" % (op, br_fdb_info["hwaddr"], + self._dev_name) + if br_fdb_info["self"]: + cmd += " self" + if br_fdb_info["master"]: + cmd += " master" + if br_fdb_info["vlan_id"]: + cmd += " vlan %s" % br_fdb_info["vlan_id"] + exec_cmd(cmd) + + def add_fdb(self, br_fdb_info): + return self._add_del_fdb("add", br_fdb_info) + + def del_fdb(self, br_fdb_info): + return self._add_del_fdb("del", br_fdb_info) diff --git a/lnst/Slave/NetTestSlave.py b/lnst/Slave/NetTestSlave.py index df28a6a..dc58e1c 100644 --- a/lnst/Slave/NetTestSlave.py +++ b/lnst/Slave/NetTestSlave.py @@ -711,6 +711,24 @@ class SlaveMethods: brt.del_vlan(br_vlan_info) return True
+ def add_br_fdb(self, if_id, br_fdb_info): + dev = self._if_manager.get_mapped_device(if_id) + if not dev: + logging.error("Device with id '%s' not found." % if_id) + return False + brt = BridgeTool(dev.get_name()) + brt.add_fdb(br_fdb_info) + return True + + def del_br_fdb(self, if_id, br_fdb_info): + dev = self._if_manager.get_mapped_device(if_id) + if not dev: + logging.error("Device with id '%s' not found." % if_id) + return False + brt = BridgeTool(dev.get_name()) + brt.del_fdb(br_fdb_info) + return True + class ServerHandler(ConnectionHandler): def __init__(self, addr): super(ServerHandler, self).__init__()