summaryrefslogtreecommitdiff
path: root/vlan.c
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@nbd.name>2021-06-19 08:55:10 +0200
committerFelix Fietkau <nbd@nbd.name>2021-06-19 09:16:51 +0200
commit013a1171e9b0df4f458fb87bbfb3bf8c9602ce6b (patch)
tree5fd6de9bf2af2dbdd650d8e9f5a5883c85914da9 /vlan.c
parent7f30b02013f2fcd69bef52d12597b232aaefcfed (diff)
downloadnetifd-013a1171e9b0df4f458fb87bbfb3bf8c9602ce6b.tar.gz
device: do not treat devices with non-digit characters after . as vlan devices
Fixes corner cases related to AP WDS station interfaces Signed-off-by: Felix Fietkau <nbd@nbd.name>
Diffstat (limited to 'vlan.c')
-rw-r--r--vlan.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/vlan.c b/vlan.c
index 459c907..401cc94 100644
--- a/vlan.c
+++ b/vlan.c
@@ -14,6 +14,7 @@
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
+#include <ctype.h>
#include "netifd.h"
#include "system.h"
@@ -238,18 +239,23 @@ error:
static char *split_vlan(char *s)
{
+retry:
s = strchr(s, '.');
if (!s)
- goto out;
+ return NULL;
+
+ if (!isdigit(s[1])) {
+ s++;
+ goto retry;
+ }
*s = 0;
s++;
-out:
return s;
}
-struct device *get_vlan_device_chain(const char *ifname, bool create)
+struct device *get_vlan_device_chain(const char *ifname, int create)
{
struct device *dev = NULL;
char *buf, *s, *next;
@@ -259,23 +265,19 @@ struct device *get_vlan_device_chain(const char *ifname, bool create)
return NULL;
s = split_vlan(buf);
- dev = device_get(buf, create);
+ dev = __device_get(buf, create, false);
if (!dev)
- goto error;
+ goto out;
- do {
+ while (s) {
next = split_vlan(s);
dev = get_vlan_device(dev, s, create);
if (!dev)
- goto error;
+ break;
s = next;
- if (!s)
- goto out;
- } while (1);
+ }
-error:
- dev = NULL;
out:
free(buf);
return dev;