summaryrefslogtreecommitdiffhomepage
path: root/system-linux.c
diff options
context:
space:
mode:
authorHans Dedecker <dedeckeh@gmail.com>2017-03-14 21:36:39 +0100
committerHans Dedecker <dedeckeh@gmail.com>2017-03-21 22:40:54 +0100
commitb4f89847883de95126ef332aa8df886c64b16b3d (patch)
tree2a1b07036b0c4eb66890ecaf98d31f0a88d8ccd0 /system-linux.c
parent7e3b89a4d4c0b55a9b2376b88cbe72a1edc5cd82 (diff)
system-linux: parse vti specific settings as nested json data object
Parse vti specific settings ikey and okey as nested json data object. At the same time remove the now obsolete TUNNEL_ATTR_INFO attribute. Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
Diffstat (limited to 'system-linux.c')
-rw-r--r--system-linux.c29
1 files changed, 16 insertions, 13 deletions
diff --git a/system-linux.c b/system-linux.c
index b7297fd..471efff 100644
--- a/system-linux.c
+++ b/system-linux.c
@@ -2462,7 +2462,6 @@ static int system_add_vti_tunnel(const char *name, const char *kind,
struct nl_msg *nlm;
struct ifinfomsg ifi = { .ifi_family = AF_UNSPEC, };
struct blob_attr *cur;
- uint32_t ikey = 0, okey = 0;
int ret = 0;
nlm = nlmsg_alloc_simple(RTM_NEWLINK, NLM_F_REQUEST | NLM_F_REPLACE | NLM_F_CREATE);
@@ -2488,14 +2487,6 @@ static int system_add_vti_tunnel(const char *name, const char *kind,
if (link)
nla_put_u32(nlm, IFLA_VTI_LINK, link);
- if ((cur = tb[TUNNEL_ATTR_INFO]) && (blobmsg_type(cur) == BLOBMSG_TYPE_STRING)) {
- if (sscanf(blobmsg_get_string(cur), "%u,%u",
- &ikey, &okey) < 2) {
- ret = -EINVAL;
- goto failure;
- }
- }
-
if (v6) {
struct in6_addr in6buf;
if ((cur = tb[TUNNEL_ATTR_LOCAL])) {
@@ -2535,11 +2526,23 @@ static int system_add_vti_tunnel(const char *name, const char *kind,
}
- if (okey)
- nla_put_u32(nlm, IFLA_VTI_OKEY, htonl(okey));
+ if ((cur = tb[TUNNEL_ATTR_DATA])) {
+ struct blob_attr *tb_data[__VTI_DATA_ATTR_MAX];
+ uint32_t ikey = 0, okey = 0;
- if (ikey)
- nla_put_u32(nlm, IFLA_VTI_IKEY, htonl(ikey));
+ blobmsg_parse(vti_data_attr_list.params, __VTI_DATA_ATTR_MAX, tb_data,
+ blobmsg_data(cur), blobmsg_len(cur));
+
+ if ((cur = tb_data[VTI_DATA_IKEY])) {
+ if ((ikey = blobmsg_get_u32(cur)))
+ nla_put_u32(nlm, IFLA_VTI_IKEY, htonl(ikey));
+ }
+
+ if ((cur = tb_data[VTI_DATA_OKEY])) {
+ if ((okey = blobmsg_get_u32(cur)))
+ nla_put_u32(nlm, IFLA_VTI_OKEY, htonl(okey));
+ }
+ }
nla_nest_end(nlm, infodata);
nla_nest_end(nlm, linkinfo);