mirror of
https://github.com/kernelkit/infix.git
synced 2026-07-22 01:13:00 +02:00
Merge pull request #1553 from kernelkit/wifi-fixes2
Some important wifi fixes
This commit is contained in:
+1
-1
Submodule buildroot updated: 707ade3a89...dd816b9233
@@ -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;
|
||||
|
||||
@@ -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");
|
||||
|
||||
+5
-14
@@ -540,7 +540,6 @@ out:
|
||||
*/
|
||||
int wifi_del_iface(struct lyd_node *dif, struct dagger *net)
|
||||
{
|
||||
struct lyd_node *wifi;
|
||||
const char *ifname;
|
||||
FILE *iw;
|
||||
|
||||
@@ -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);
|
||||
|
||||
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;
|
||||
|
||||
@@ -133,7 +133,7 @@ with infamy.Test() as test:
|
||||
|
||||
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}"),
|
||||
@@ -143,30 +143,30 @@ with infamy.Test() as test:
|
||||
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()
|
||||
|
||||
@@ -186,7 +186,7 @@ with infamy.Test() as test:
|
||||
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")
|
||||
|
||||
@@ -62,6 +62,7 @@ class IsolatedMacVlans:
|
||||
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",
|
||||
@@ -86,7 +87,7 @@ class IsolatedMacVlans:
|
||||
|
||||
if self.set_up:
|
||||
self.run(["ip", "link", "set", "dev", ifname, "up"])
|
||||
|
||||
|
||||
except Exception as e:
|
||||
self.__exit__(None, None, None)
|
||||
raise e
|
||||
@@ -272,11 +273,11 @@ class IsolatedMacVlans:
|
||||
|
||||
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,
|
||||
@@ -336,9 +337,9 @@ class IsolatedMacVlan(IsolatedMacVlans):
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user