diff options
| author | Jiri Pirko <jiri@mellanox.com> | 2019-05-17 18:02:11 +0200 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2019-10-25 13:15:56 +0200 |
| commit | 5b49e1f605a770e8f8fcdcbd1a8ff85591fc0c8e (patch) | |
| tree | 761c9bb8cef506a915bda5d68c173e779f68e106 /executor | |
| parent | d01bb02a96019cda0fa8c46e5c6d5eb66a273f17 (diff) | |
executor: create netdevsim device
Create testing netdevsim instance with 4 ports.
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Diffstat (limited to 'executor')
| -rw-r--r-- | executor/common_linux.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/executor/common_linux.h b/executor/common_linux.h index b56453510..a62aaea9c 100644 --- a/executor/common_linux.h +++ b/executor/common_linux.h @@ -444,6 +444,14 @@ static void initialize_tun(void) #define DEV_IPV6 "fe80::%02x" #define DEV_MAC 0x00aaaaaaaaaa +static void netdevsim_add(unsigned int addr, unsigned int port_count) +{ + char buf[16]; + + sprintf(buf, "%u %u", addr, port_count); + write_file("/sys/bus/netdevsim/new_device", buf); +} + // We test in a separate namespace, which does not have any network devices initially (even lo). // Create/up as many as we can. static void initialize_netdevices(void) @@ -570,6 +578,8 @@ static void initialize_netdevices(void) netlink_device_change(sock, "hsr_slave_0", true, 0, 0, 0); netlink_device_change(sock, "hsr_slave_1", true, 0, 0, 0); + netdevsim_add((int)procid, 4); + for (i = 0; i < sizeof(devices) / (sizeof(devices[0])); i++) { // Assign some unique address to devices. Some devices won't up without this. // Shift addresses by 10 because 0 subnet address can mean special things. |
