Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.org
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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).";
Expand Down
2 changes: 2 additions & 0 deletions doc/source/config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions munet/munet-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,9 @@
"ipv6": {
"type": "string"
},
"mac": {
"type": "string"
},
"name": {
"type": "string"
},
Expand Down Expand Up @@ -710,6 +713,9 @@
"ipv6": {
"type": "string"
},
"mac": {
"type": "string"
},
"name": {
"type": "string"
},
Expand Down
7 changes: 7 additions & 0 deletions munet/native.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down
1 change: 1 addition & 0 deletions tests/basic/munet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
3 changes: 3 additions & 0 deletions tests/basic/test_basic_topology.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"])
Expand Down
Loading