diff options
author | Jonas Johansson <jonasj76@gmail.com> | 2015-03-19 19:15:52 (GMT) |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2015-03-23 08:27:23 (GMT) |
commit | 31d7d193934ba14ac9102b6966c8863b3676e6d4 (patch) | |
tree | a5e6e74a931c196f6c7520574916861f52fb758c /lib | |
parent | c242e25c452e855d05609e57484296ecaf4763b0 (diff) | |
download | libnl-31d7d193934ba14ac9102b6966c8863b3676e6d4.zip libnl-31d7d193934ba14ac9102b6966c8863b3676e6d4.tar.gz libnl-31d7d193934ba14ac9102b6966c8863b3676e6d4.tar.bz2 |
neigh: add support for NDA_VLAN nl attribute
[thaller@redhat.com: modified patch to parse NDA_VLAN and diff vlan]
http://lists.infradead.org/pipermail/libnl/2015-March/001861.html
Signed-off-by: Jonas Johansson <jonasj76@gmail.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/route/neigh.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/route/neigh.c b/lib/route/neigh.c index 0caf6dd..1a0da93 100644 --- a/lib/route/neigh.c +++ b/lib/route/neigh.c @@ -168,6 +168,7 @@ #define NEIGH_ATTR_TYPE 0x80 #define NEIGH_ATTR_PROBES 0x100 #define NEIGH_ATTR_MASTER 0x200 +#define NEIGH_ATTR_VLAN 0x400 static struct nl_cache_ops rtnl_neigh_ops; static struct nl_object_ops neigh_obj_ops; @@ -268,6 +269,7 @@ static int neigh_compare(struct nl_object *_a, struct nl_object *_b, diff |= NEIGH_DIFF(LLADDR, nl_addr_cmp(a->n_lladdr, b->n_lladdr)); diff |= NEIGH_DIFF(DST, nl_addr_cmp(a->n_dst, b->n_dst)); diff |= NEIGH_DIFF(MASTER, a->n_master != b->n_master); + diff |= NEIGH_DIFF(VLAN, a->n_vlan != b->n_vlan); if (flags & LOOSE_COMPARISON) { diff |= NEIGH_DIFF(STATE, @@ -294,6 +296,8 @@ static const struct trans_tbl neigh_attrs[] = { __ADD(NEIGH_ATTR_FAMILY, family), __ADD(NEIGH_ATTR_TYPE, type), __ADD(NEIGH_ATTR_PROBES, probes), + __ADD(NEIGH_ATTR_MASTER, master), + __ADD(NEIGH_ATTR_VLAN, vlan), }; static char *neigh_attrs2str(int attrs, char *buf, size_t len) @@ -399,6 +403,11 @@ int rtnl_neigh_parse(struct nlmsghdr *n, struct rtnl_neigh **result) neigh->ce_mask |= NEIGH_ATTR_PROBES; } + if (tb[NDA_VLAN]) { + neigh->n_vlan = nla_get_u16(tb[NDA_VLAN]); + neigh->ce_mask |= NEIGH_ATTR_VLAN; + } + /* * Get the bridge index for AF_BRIDGE family entries */ @@ -596,6 +605,9 @@ static int build_neigh_msg(struct rtnl_neigh *tmpl, int cmd, int flags, if (tmpl->ce_mask & NEIGH_ATTR_LLADDR) NLA_PUT_ADDR(msg, NDA_LLADDR, tmpl->n_lladdr); + if (tmpl->ce_mask & NEIGH_ATTR_VLAN) + NLA_PUT_U16(msg, NDA_VLAN, tmpl->n_vlan); + *result = msg; return 0; @@ -908,6 +920,20 @@ int rtnl_neigh_get_type(struct rtnl_neigh *neigh) return -1; } +void rtnl_neigh_set_vlan(struct rtnl_neigh *neigh, int vlan) +{ + neigh->n_vlan = vlan; + neigh->ce_mask |= NEIGH_ATTR_VLAN; +} + +int rtnl_neigh_get_vlan(struct rtnl_neigh *neigh) +{ + if (neigh->ce_mask & NEIGH_ATTR_VLAN) + return neigh->n_vlan; + else + return -1; +} + /** @} */ static struct nl_object_ops neigh_obj_ops = { |