Skip to content
Merged
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
2 changes: 1 addition & 1 deletion buildroot
26 changes: 24 additions & 2 deletions src/confd/src/hardware.c
Original file line number Diff line number Diff line change
Expand Up @@ -1379,8 +1379,32 @@ int hardware_change(sr_session_ctx_t *session, struct lyd_node *config, struct l
* all radio configs, so band edits and radio add/remove both apply.
*/
if (wifi_changed && event == SR_EV_DONE) {
struct lyd_node *cifs;
glob_t gl = { 0 };
size_t i;

/* Need to remove old hostapd config files, for radios not used anymore */
cifs = lydx_get_descendant(config, "interfaces", "interface", NULL);
if (glob("/etc/hostapd-*.conf", 0, NULL, &gl) == 0) {
for (i = 0; i < gl.gl_pathc; i++) {
char radio[64], **aps = NULL;
int n = 0, j;

if (sscanf(gl.gl_pathv[i], "/etc/hostapd-%63[^.].conf", radio) != 1)
continue;
wifi_find_radio_aps(cifs, radio, &aps, &n);
for (j = 0; j < n; j++)
free(aps[j]);
free(aps);
if (!n) {
unlink(gl.gl_pathv[i]);
erasef(HOSTAPD_CONF_NEXT, radio);
}
}
globfree(&gl);
}

gl = (glob_t){ 0 };
if (glob("/etc/hostapd-*.conf", 0, NULL, &gl) == 0 && gl.gl_pathc > 0) {
FILE *fp;

Expand All @@ -1389,8 +1413,6 @@ int hardware_change(sr_session_ctx_t *session, struct lyd_node *config, struct l
ERRNO("Could not open " HOSTAPD_SERVICE);
rc = SR_ERR_INTERNAL;
} else {
size_t i;

fprintf(fp, "# Generated by confd, do not edit.\n");
fprintf(fp, "service <!> name:hostapd \\\n");
fprintf(fp, "\t[2345] hostapd -P /run/hostapd.pid");
Expand Down
19 changes: 5 additions & 14 deletions src/confd/src/if-wifi.c
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,6 @@ int wifi_add_iface(struct lyd_node *cif, struct dagger *net)
*/
int wifi_del_iface(struct lyd_node *dif, struct dagger *net)
{
struct lyd_node *wifi;
const char *ifname;
FILE *iw;

Expand All @@ -553,22 +552,14 @@ int wifi_del_iface(struct lyd_node *dif, struct dagger *net)
}

fprintf(iw, "# Generated by Infix confd - WiFi Interface Deletion\n");

erasef(WPA_SUPPLICANT_CONF, ifname);
fprintf(iw, "initctl -bfq disable mesh@%s\n", ifname);
fprintf(iw, "initctl -bfq disable wifi@%s\n", ifname);
Comment thread
troglobit marked this conversation as resolved.

fprintf(iw, "ip link set %s down\n", ifname);
fprintf(iw, "iw dev %s disconnect 2>/dev/null\n", ifname);
fprintf(iw, "iw dev %s del 2>/dev/null || ip link del %s 2>/dev/null || true\n", ifname, ifname);

wifi = lydx_get_child(dif, "wifi");
if (wifi) {
int mode = wifi_get_mode(wifi);

if (mode == wifi_mesh) {
erasef(WPA_SUPPLICANT_CONF, ifname);
fprintf(iw, "initctl -bfq disable mesh@%s\n", ifname);
} else if (mode != wifi_ap) {
erasef(WPA_SUPPLICANT_CONF, ifname);
fprintf(iw, "initctl -bfq disable wifi@%s\n", ifname);
}
}
fclose(iw);

return SR_ERR_OK;
Expand Down
28 changes: 14 additions & 14 deletions test/case/interfaces/static_multicast_filters/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def set_static_multicast_filter(target, address, port):

print("Starting IPv4 multicast sender")
with mcast.MCastSender(send_ns, ipv4_multicast_group):

with test.step("Verify that 224.1.1.1 is flooded to host:data2 and host:data3"):
infamy.parallel(
lambda: receive_ns.must_receive(f"ip dst {ipv4_multicast_group}"),
Expand All @@ -143,30 +143,30 @@ def set_static_multicast_filter(target, address, port):
set_static_multicast_filter(target, ipv4_multicast_group, mreceive)
until(lambda: iface.exist_bridge_multicast_filter(target, ipv4_multicast_group, mreceive, "br0"))

with test.step("Verify that the group is still forwarded to host:data2"):
receive_ns.must_receive(f"ip dst {ipv4_multicast_group}")
with test.step("Verify that the group is still forwarded to host:data2"):
receive_ns.must_receive(f"ip dst {ipv4_multicast_group}")

with test.step("Verify that the group is no longer forwarded to host:data3"):
nojoin_ns.must_not_receive(f"ip dst {ipv4_multicast_group}")
with test.step("Verify that the group is no longer forwarded to host:data3"):
nojoin_ns.must_not_receive(f"ip dst {ipv4_multicast_group}")

with test.step("Start MAC multicast sender on host:data1, group 01:00:00:01:02:03"):

print("Starting MAC multicast sender")
with mcast.MacMCastSender(send_ns, mac_multicast_group):

with test.step("Verify MAC multicast 01:00:00:01:02:03 is flooded to host:data2 and host:data3"):
infamy.parallel(
lambda: receive_ns.must_receive(f"ether dst {mac_multicast_group}"),
lambda: nojoin_ns.must_receive(f"ether dst {mac_multicast_group}"))

with test.step("Enable MAC multicast filter on host:data2, group 01:00:00:01:02:03"):
set_static_multicast_filter(target, mac_multicast_group, mreceive)
until(lambda: iface.exist_bridge_multicast_filter(target, mac_multicast_group, mreceive, "br0"))
with test.step("Verify that the MAC group is still forwarded to host:data2"):
receive_ns.must_receive(f"ether dst {mac_multicast_group}"),
with test.step("Verify that the MAC group is no longer forwarded to host:data3"):
nojoin_ns.must_not_receive(f"ether dst {mac_multicast_group}")

with test.step("Verify that the MAC group is still forwarded to host:data2"):
receive_ns.must_receive(f"ether dst {mac_multicast_group}")

with test.step("Verify that the MAC group is no longer forwarded to host:data3"):
nojoin_ns.must_not_receive(f"ether dst {mac_multicast_group}")

test.succeed()
2 changes: 1 addition & 1 deletion test/case/routing/ospf_unnumbered_interface/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ def config_target2(target, link):
with test.step("Verify there are no OSPF HELLO packets on PC:data"):
assert(route.ospf_get_interface_passive(R1, "0.0.0.0", R1data))
print("Verify that no hello packets are recieved from passive interfaces")
ns0.must_not_receive("ip proto 89", timeout=15) # Default hello time 10s
ns0.must_not_receive("ip proto 89", duration=15) # Default hello time 10s

with test.step("Test connectivity from PC:data to 192.168.200.1"):
ns0.must_reach("192.168.200.1")
Expand Down
13 changes: 7 additions & 6 deletions test/infamy/netns.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ def __init__(self, ifmap, lo=True, set_up=True, mode="passthru"):
self.ifmap, self.lo, self.set_up = ifmap, lo, set_up
self.mode = mode
self.ping_timeout = env.ENV.attr("ping_timeout", 5)
self.default_receive_duration = env.ENV.attr("default_receive_duration", 10)

def start(self):
self.sleeper = subprocess.Popen(["unshare", "-r", "-n", "sh", "-c",
Expand All @@ -86,7 +87,7 @@ def start(self):

if self.set_up:
self.run(["ip", "link", "set", "dev", ifname, "up"])

except Exception as e:
self.__exit__(None, None, None)
raise e
Expand Down Expand Up @@ -272,11 +273,11 @@ def must_not_reach(self, *args, **kwargs):

raise Exception(res)

def must_receive(self, expr, ifname, timeout=None, must=True):
timeout = timeout if timeout else self.ping_timeout
def must_receive(self, expr, ifname, duration=None, must=True):
duration = duration if duration else self.default_receive_duration

tshark = self.run(["tshark", "-nl", f"-i{ifname}",
f"-aduration:{timeout}", "-c1", expr],
f"-aduration:{duration}", "-c1", expr],
stdin=subprocess.DEVNULL,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
Expand Down Expand Up @@ -336,9 +337,9 @@ def addip(self, addr, prefix_length=24, proto="ipv4"):
return super().addip(ifname=self._ifname, addr=addr,
prefix_length=prefix_length, proto=proto)

def must_receive(self, expr, timeout=None, ifname=None, must=True):
def must_receive(self, expr, duration=None, ifname=None, must=True):
ifname = ifname if ifname else self._ifname
return super().must_receive(expr=expr, ifname=ifname, timeout=timeout, must=must)
return super().must_receive(expr=expr, ifname=ifname, duration=duration, must=must)

def pcap(self, expr, ifname=None):
ifname = ifname if ifname else self._ifname
Expand Down