executor: create netdevsim device

Create testing netdevsim instance with 4 ports.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
diff --git a/executor/common_linux.h b/executor/common_linux.h
index b564535..a62aaea 100644
--- a/executor/common_linux.h
+++ b/executor/common_linux.h
@@ -444,6 +444,14 @@
 #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 @@
 	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.
diff --git a/pkg/csource/generated.go b/pkg/csource/generated.go
index 2b91d15..bcfc0a0 100644
--- a/pkg/csource/generated.go
+++ b/pkg/csource/generated.go
@@ -1451,6 +1451,14 @@
 #define DEV_IPV4 "172.20.20.%d"
 #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);
+}
 static void initialize_netdevices(void)
 {
 #if SYZ_EXECUTOR
@@ -1541,6 +1549,8 @@
 	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++) {
 		char addr[32];
 		sprintf(addr, DEV_IPV4, i + 10);