X-Git-Url: https://git.rohieb.name/openwrt.git/blobdiff_plain/29b1cd327d3658f39af9db68943a6c205fac602d..0874d0071557e22e37ace65cdbccdbf373a86a4c:/package/swconfig/src/swlib.c diff --git a/package/swconfig/src/swlib.c b/package/swconfig/src/swlib.c index 8a9fd7a29..c2316d068 100644 --- a/package/swconfig/src/swlib.c +++ b/package/swconfig/src/swlib.c @@ -368,11 +368,26 @@ int swlib_set_attr_string(struct switch_dev *dev, struct switch_attr *a, int por ptr = (char *)str; while(ptr && *ptr) { + while(*ptr && isspace(*ptr)) + ptr++; + + if (!*ptr) + break; + + if (!isdigit(*ptr)) + return -1; + + if (val.len >= dev->ports) + return -1; + ports[val.len].flags = 0; ports[val.len].id = strtoul(ptr, &ptr, 10); while(*ptr && !isspace(*ptr)) { if (*ptr == 't') ports[val.len].flags |= SWLIB_PORT_FLAG_TAGGED; + else + return -1; + ptr++; } if (*ptr) @@ -586,6 +601,8 @@ add_switch(struct nl_msg *msg, void *arg) dev->ports = nla_get_u32(tb[SWITCH_ATTR_PORTS]); if (tb[SWITCH_ATTR_VLANS]) dev->vlans = nla_get_u32(tb[SWITCH_ATTR_VLANS]); + if (tb[SWITCH_ATTR_CPU_PORT]) + dev->cpu_port = nla_get_u32(tb[SWITCH_ATTR_CPU_PORT]); if (!sa->head) { sa->head = dev;