diff --git a/README.org b/README.org index 48eccf5..88906a6 100644 --- a/README.org +++ b/README.org @@ -90,6 +90,7 @@ module: labn-munet-config | | +--rw to string | | +--rw ip? string | | +--rw ipv6? string + | | +--rw mac? string | | +--rw name? string | | +--rw hostintf? string | | +--rw physical? string @@ -202,6 +203,7 @@ module: labn-munet-config | | +--rw to string | | +--rw ip? string | | +--rw ipv6? string + | | +--rw mac? string | | +--rw name? string | | +--rw hostintf? string | | +--rw physical? string @@ -834,6 +836,10 @@ munet> type string; description "IPv6 address and mask for the connection (interface)."; } + leaf mac { + type string; + description "Mac address for the connection (interface)."; + } leaf name { type string; description "Name for the connection (interface name)."; diff --git a/doc/source/config.rst b/doc/source/config.rst index 5a52482..74c9104 100644 --- a/doc/source/config.rst +++ b/doc/source/config.rst @@ -211,6 +211,8 @@ Tree diagram for node connections:: | +--rw connections* [to] | | +--rw to string | | +--rw ip? string + | | +--rw ipv6? string + | | +--rw mac? string | | +--rw name? string | | +--rw hostintf? string | | +--rw physical? string diff --git a/munet/munet-schema.json b/munet/munet-schema.json index 5147c5e..784214b 100644 --- a/munet/munet-schema.json +++ b/munet/munet-schema.json @@ -225,6 +225,9 @@ "ipv6": { "type": "string" }, + "mac": { + "type": "string" + }, "name": { "type": "string" }, @@ -710,6 +713,9 @@ "ipv6": { "type": "string" }, + "mac": { + "type": "string" + }, "name": { "type": "string" }, diff --git a/munet/native.py b/munet/native.py index f9e7d8c..c5ba397 100644 --- a/munet/native.py +++ b/munet/native.py @@ -3298,8 +3298,15 @@ async def add_native_link(self, node1, node2, c1=None, c2=None): pass elif "physical" not in c1 and not node1.is_vm: node1.set_intf_constraints(if1, **c1) + mac1 = c1.get("mac", None) + if mac1: + node1.intf_ip_cmd(if1, f"ip link set dev {if1} address {mac1}") if "physical" not in c2 and not node2.is_vm: node2.set_intf_constraints(if2, **c2) + mac2 = c2.get("mac", None) + if mac2: + node2.intf_ip_cmd(if2, f"ip link set dev {if2} address {mac2}") + def add_l3_node(self, name, config=None, **kwargs): """Add a node to munet.""" diff --git a/tests/basic/munet.yaml b/tests/basic/munet.yaml index 5e83cad..b6cd4af 100644 --- a/tests/basic/munet.yaml +++ b/tests/basic/munet.yaml @@ -55,6 +55,7 @@ topology: - to: "r2" ip: "192.168.202.1/31" ipv6: "fd00::1/127" + mac: "02:AA:AA:AA:AA:AA" remote-name: "p2p2" mtu: 9000 cmd: | diff --git a/tests/basic/test_basic_topology.py b/tests/basic/test_basic_topology.py index 688426c..f1e5935 100644 --- a/tests/basic/test_basic_topology.py +++ b/tests/basic/test_basic_topology.py @@ -103,6 +103,9 @@ async def test_basic_config(unet_perfunc): o = await r3.async_cmd_raises("ping -w1 -c1 fe8f:ffff:33::1") logging.debug("r3 ping lo (fe8f:ffff:33::1) output: %s", o) + o = await r3.async_cmd_raises("ip link show | grep 02:aa:aa:aa:aa:aa") + logging.debug("r3 check for link mac (02:aa:aa:aa:aa:aa) output: %s", o) + @pytest.mark.parametrize("ipv6", [False, True]) @pytest.mark.parametrize("unet_perfunc", [False, True], indirect=["unet_perfunc"])