ROUTE_TARGET,
ROUTE_MASK,
ROUTE_GATEWAY,
- ROUTE_DEVICE,
ROUTE_METRIC,
ROUTE_MTU,
__ROUTE_MAX
[ROUTE_TARGET] = { .name = "target", .type = BLOBMSG_TYPE_STRING },
[ROUTE_MASK] = { .name = "netmask", .type = BLOBMSG_TYPE_STRING },
[ROUTE_GATEWAY] = { .name = "gateway", .type = BLOBMSG_TYPE_STRING },
- [ROUTE_DEVICE] = { .name = "device", .type = BLOBMSG_TYPE_STRING },
[ROUTE_METRIC] = { .name = "metric", .type = BLOBMSG_TYPE_INT32 },
[ROUTE_MTU] = { .name = "mtu", .type = BLOBMSG_TYPE_INT32 },
};
struct blob_attr *tb[__ROUTE_MAX], *cur;
struct device_route *route;
int af = v6 ? AF_INET6 : AF_INET;
- bool config = false;
blobmsg_parse(route_attr, __ROUTE_MAX, tb, blobmsg_data(attr), blobmsg_data_len(attr));
- if (!tb[ROUTE_GATEWAY] && !tb[ROUTE_DEVICE])
- return;
-
if (!iface) {
if ((cur = tb[ROUTE_INTERFACE]) == NULL)
return;
return;
ip = &iface->config_ip;
- config = true;
} else {
ip = &iface->proto_ip;
}
DPRINTF("Failed to parse route gateway: %s\n", (char *) blobmsg_data(cur));
goto error;
}
+ } else {
+ route->flags |= DEVADDR_DEVICE;
}
if ((cur = tb[ROUTE_METRIC]) != NULL)
if ((cur = tb[ROUTE_MTU]) != NULL)
route->mtu = blobmsg_get_u32(cur);
- if (!config && (cur = tb[ROUTE_DEVICE]) != NULL)
- route->device = device_get(blobmsg_data(cur), true);
-
vlist_add(&ip->route, &route->node);
return;
struct nl_msg *msg;
- dev = addr->device;
- if (dev) {
- if (!dev->ifindex)
- return -1;
-
- ifa.ifa_index = dev->ifindex;
- }
-
msg = nlmsg_alloc_simple(cmd, 0);
if (!msg)
return -1;
if (cmd == RTM_NEWROUTE)
flags |= NLM_F_CREATE | NLM_F_REPLACE;
- dev = route->device;
- if (dev) {
- if (!dev->ifindex)
- return -1;
-
- ifindex = dev->ifindex;
- }
-
msg = nlmsg_alloc_simple(cmd, flags);
if (!msg)
return -1;