diff options
author | David Ahern <dsa@cumulusnetworks.com> | 2015-11-25 19:14:14 (GMT) |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2015-12-07 10:41:35 (GMT) |
commit | 1b2c247571c748a422864f9122bd16cb20e37f83 (patch) | |
tree | dfa3486784e211e81eb94af44b84962e5accbb15 /lib/route/link.c | |
parent | 7bbd09d9410f5fc0d22f00db26306234a50217a2 (diff) | |
download | libnl-1b2c247571c748a422864f9122bd16cb20e37f83.zip libnl-1b2c247571c748a422864f9122bd16cb20e37f83.tar.gz libnl-1b2c247571c748a422864f9122bd16cb20e37f83.tar.bz2 |
link: add AF operation to append attributes to a GETLINK message
Upcoming bridge patch wants to add IFLA_EXT_MASK attribute to RTM_GETLINK
requests to retrieve VLAN data. Expand request message to a full ifinfomsg
header and call to hook to append attributes if it exists for an address
family.
Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
[thaller@redhat.com: fix memleak in link_request_update()]
Signed-off-by: Thomas Haller <thaller@redhat.com>
Diffstat (limited to 'lib/route/link.c')
-rw-r--r-- | lib/route/link.c | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/lib/route/link.c b/lib/route/link.c index cfe3779..768b899 100644 --- a/lib/route/link.c +++ b/lib/route/link.c @@ -657,8 +657,32 @@ errout: static int link_request_update(struct nl_cache *cache, struct nl_sock *sk) { int family = cache->c_iarg1; + struct ifinfomsg hdr = { .ifi_family = family }; + struct rtnl_link_af_ops *ops; + struct nl_msg *msg; + int err; + + msg = nlmsg_alloc_simple(RTM_GETLINK, NLM_F_DUMP); + if (!msg) + return -NLE_NOMEM; + + err = -NLE_MSGSIZE; + if (nlmsg_append(msg, &hdr, sizeof(hdr), NLMSG_ALIGNTO) < 0) + goto nla_put_failure; - return nl_rtgen_request(sk, RTM_GETLINK, family, NLM_F_DUMP); + ops = rtnl_link_af_ops_lookup(family); + if (ops && ops->ao_get_af) { + err = ops->ao_get_af(msg); + if (err) + goto nla_put_failure; + } + err = nl_send_auto(sk, msg); + if (err > 0) + err = 0; + +nla_put_failure: + nlmsg_free(msg); + return err; } static void link_dump_line(struct nl_object *obj, struct nl_dump_params *p) |