static void
handle_hotplug_msg(char *data, int size)
{
- const char *subsystem = NULL, *interface = NULL;
+ const char *subsystem = NULL, *interface = NULL, *interface_old = NULL;
char *cur, *end, *sep;
struct device *dev;
int skip;
- bool add;
+ bool add, move = false;
if (!strncmp(data, "add@", 4))
add = true;
else if (!strncmp(data, "remove@", 7))
add = false;
+ else if (!strncmp(data, "move@", 5)) {
+ add = true;
+ move = true;
+ }
else
return;
subsystem = sep + 1;
if (strcmp(subsystem, "net") != 0)
return;
+ } else if (!strcmp(cur, "DEVPATH_OLD")) {
+ interface_old = strrchr(sep + 1, '/');
+ if (interface_old)
+ interface_old++;
}
- if (subsystem && interface)
+ }
+
+ if (subsystem && interface) {
+ if (move && interface_old)
+ goto move;
+ else
goto found;
}
+
return;
+move:
+ dev = device_find(interface_old);
+ if (!dev)
+ goto found;
+
+ if (dev->type != &simple_device_type)
+ goto found;
+
+ device_set_present(dev, false);
+
found:
dev = device_find(interface);
if (!dev)
}
if (!system_get_neigh4locktime(dev, buf, sizeof(buf))) {
- s->neigh4locktime = strtoul(buf, NULL, 0);
+ s->neigh4locktime = strtol(buf, NULL, 0);
s->flags |= DEV_OPT_NEIGHLOCKTIME;
}
}
static void
-system_if_set_rps_xps_val(const char *path, int val)
+system_if_set_rps_xps_val(const char *path, char *fmt, int val)
{
char val_buf[8];
glob_t gl;
if (glob(path, 0, NULL, &gl))
return;
- snprintf(val_buf, sizeof(val_buf), "%x", val);
+ snprintf(val_buf, sizeof(val_buf), fmt, val);
for (i = 0; i < gl.gl_pathc; i++)
system_set_sysctl(gl.gl_pathv[i], val_buf);
system_if_apply_rps_xps(struct device *dev, struct device_settings *s)
{
long n_cpus = sysconf(_SC_NPROCESSORS_ONLN);
- int val;
+ int val, rps_val, rps_flow_cnt, xps_val;
if (n_cpus < 2)
return;
val = (1 << n_cpus) - 1;
+ rps_val = s->rps_val ? s->rps_val : val;
snprintf(dev_buf, sizeof(dev_buf), "/sys/class/net/%s/queues/*/rps_cpus", dev->ifname);
- system_if_set_rps_xps_val(dev_buf, s->rps ? val : 0);
+ system_if_set_rps_xps_val(dev_buf, "%x", s->rps ? rps_val : 0);
+
+ rps_flow_cnt = s->rps_flow_cnt ? s->rps_flow_cnt : 0;
+ snprintf(dev_buf, sizeof(dev_buf), "/sys/class/net/%s/queues/*/rps_flow_cnt", dev->ifname);
+ system_if_set_rps_xps_val(dev_buf, "%d", s->rps ? rps_flow_cnt : 0);
+ xps_val = s->xps_val ? s->xps_val : val;
snprintf(dev_buf, sizeof(dev_buf), "/sys/class/net/%s/queues/*/xps_cpus", dev->ifname);
- system_if_set_rps_xps_val(dev_buf, s->xps ? val : 0);
+ system_if_set_rps_xps_val(dev_buf, "%x", s->xps ? xps_val : 0);
}
void
system_set_neigh6reachabletime(dev, buf);
}
if (s->flags & DEV_OPT_NEIGHLOCKTIME & apply_mask) {
- snprintf(buf, sizeof(buf), "%u", s->neigh4locktime);
+ snprintf(buf, sizeof(buf), "%d", s->neigh4locktime);
system_set_neigh4locktime(dev, buf);
}
if (s->flags & DEV_OPT_NEIGHGCSTALETIME & apply_mask) {
}
#ifdef IFLA_IPTUN_FMR_MAX
- if ((cur = tb[TUNNEL_ATTR_FMRS])) {
+ if ((cur = tb[TUNNEL_ATTR_DATA])) {
struct nlattr *fmrs = nla_nest_start(nlm, IFLA_IPTUN_FMRS);
+ struct blob_attr *dcur;
+ unsigned drem, fmrcnt = 0;
- struct blob_attr *fmr;
- unsigned rem, fmrcnt = 0;
- blobmsg_for_each_attr(fmr, cur, rem) {
- if (blobmsg_type(fmr) != BLOBMSG_TYPE_STRING)
+ blobmsg_for_each_attr(dcur, cur, drem) {
+ if (blobmsg_type(dcur) != BLOBMSG_TYPE_ARRAY ||
+ strcmp(blobmsg_name(dcur), "fmrs") ||
+ blobmsg_check_array(dcur, BLOBMSG_TYPE_UNSPEC) <= 0)
continue;
- unsigned ip4len, ip6len, ealen, offset = 6;
- char ip6buf[48];
- char ip4buf[16];
+ struct blob_attr *rcur;
+ unsigned rrem;
+ blobmsg_for_each_attr(rcur, dcur, rrem) {
+ struct blob_attr *tb_fmr[__FMR_DATA_ATTR_MAX], *tb_cur;
+ struct in6_addr ip6prefix;
+ struct in_addr ip4prefix;
+ unsigned ip4len, ip6len, ealen, offset;
+
+ blobmsg_parse(fmr_data_attr_list.params, __FMR_DATA_ATTR_MAX, tb_fmr,
+ blobmsg_data(rcur), blobmsg_len(rcur));
+
+ if (!(tb_cur = tb_fmr[FMR_DATA_PREFIX6]) ||
+ !parse_ip_and_netmask(AF_INET6,
+ blobmsg_data(tb_cur), &ip6prefix,
+ &ip6len)) {
+ ret = -EINVAL;
+ goto failure;
+ }
- if (sscanf(blobmsg_get_string(fmr), "%47[^/]/%u,%15[^/]/%u,%u,%u",
- ip6buf, &ip6len, ip4buf, &ip4len, &ealen, &offset) < 5) {
- ret = -EINVAL;
- goto failure;
- }
+ if (!(tb_cur = tb_fmr[FMR_DATA_PREFIX4]) ||
+ !parse_ip_and_netmask(AF_INET,
+ blobmsg_data(tb_cur), &ip4prefix,
+ &ip4len)) {
+ ret = -EINVAL;
+ goto failure;
+ }
- struct in6_addr ip6prefix;
- struct in_addr ip4prefix;
- if (inet_pton(AF_INET6, ip6buf, &ip6prefix) != 1 ||
- inet_pton(AF_INET, ip4buf, &ip4prefix) != 1) {
- ret = -EINVAL;
- goto failure;
- }
+ if (!(tb_cur = tb_fmr[FMR_DATA_EALEN])) {
+ ret = -EINVAL;
+ goto failure;
+ }
+ ealen = blobmsg_get_u32(tb_cur);
+
+ if (!(tb_cur = tb_fmr[FMR_DATA_OFFSET])) {
+ ret = -EINVAL;
+ goto failure;
+ }
+ offset = blobmsg_get_u32(tb_cur);
- struct nlattr *rule = nla_nest_start(nlm, ++fmrcnt);
+ struct nlattr *rule = nla_nest_start(nlm, ++fmrcnt);
- nla_put(nlm, IFLA_IPTUN_FMR_IP6_PREFIX, sizeof(ip6prefix), &ip6prefix);
- nla_put(nlm, IFLA_IPTUN_FMR_IP4_PREFIX, sizeof(ip4prefix), &ip4prefix);
- nla_put_u8(nlm, IFLA_IPTUN_FMR_IP6_PREFIX_LEN, ip6len);
- nla_put_u8(nlm, IFLA_IPTUN_FMR_IP4_PREFIX_LEN, ip4len);
- nla_put_u8(nlm, IFLA_IPTUN_FMR_EA_LEN, ealen);
- nla_put_u8(nlm, IFLA_IPTUN_FMR_OFFSET, offset);
+ nla_put(nlm, IFLA_IPTUN_FMR_IP6_PREFIX, sizeof(ip6prefix), &ip6prefix);
+ nla_put(nlm, IFLA_IPTUN_FMR_IP4_PREFIX, sizeof(ip4prefix), &ip4prefix);
+ nla_put_u8(nlm, IFLA_IPTUN_FMR_IP6_PREFIX_LEN, ip6len);
+ nla_put_u8(nlm, IFLA_IPTUN_FMR_IP4_PREFIX_LEN, ip4len);
+ nla_put_u8(nlm, IFLA_IPTUN_FMR_EA_LEN, ealen);
+ nla_put_u8(nlm, IFLA_IPTUN_FMR_OFFSET, offset);
- nla_nest_end(nlm, rule);
+ nla_nest_end(nlm, rule);
+ }
}
-
nla_nest_end(nlm, fmrs);
}
#endif