summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonas Johansson <jonasj76@gmail.com>2015-03-19 19:15:52 (GMT)
committerThomas Haller <thaller@redhat.com>2015-03-23 08:27:23 (GMT)
commit31d7d193934ba14ac9102b6966c8863b3676e6d4 (patch)
treea5e6e74a931c196f6c7520574916861f52fb758c
parentc242e25c452e855d05609e57484296ecaf4763b0 (diff)
downloadlibnl-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>
-rw-r--r--include/linux-private/linux/neighbour.h1
-rw-r--r--include/netlink-private/types.h1
-rw-r--r--include/netlink/route/neighbour.h3
-rw-r--r--lib/route/neigh.c26
-rw-r--r--libnl-route-3.sym2
5 files changed, 33 insertions, 0 deletions
diff --git a/include/linux-private/linux/neighbour.h b/include/linux-private/linux/neighbour.h
index a7003b7..c261b3c 100644
--- a/include/linux-private/linux/neighbour.h
+++ b/include/linux-private/linux/neighbour.h
@@ -20,6 +20,7 @@ enum {
NDA_LLADDR,
NDA_CACHEINFO,
NDA_PROBES,
+ NDA_VLAN,
__NDA_MAX
};
diff --git a/include/netlink-private/types.h b/include/netlink-private/types.h
index 54f06b5..013816f 100644
--- a/include/netlink-private/types.h
+++ b/include/netlink-private/types.h
@@ -220,6 +220,7 @@ struct rtnl_neigh
uint32_t n_state_mask;
uint32_t n_flag_mask;
uint32_t n_master;
+ uint16_t n_vlan;
};
diff --git a/include/netlink/route/neighbour.h b/include/netlink/route/neighbour.h
index 1d1179b..b653cff 100644
--- a/include/netlink/route/neighbour.h
+++ b/include/netlink/route/neighbour.h
@@ -74,6 +74,9 @@ extern int rtnl_neigh_get_type(struct rtnl_neigh *);
extern void rtnl_neigh_set_family(struct rtnl_neigh *, int);
extern int rtnl_neigh_get_family(struct rtnl_neigh *);
+extern void rtnl_neigh_set_vlan(struct rtnl_neigh *, int);
+extern int rtnl_neigh_get_vlan(struct rtnl_neigh *);
+
#ifdef __cplusplus
}
#endif
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 = {
diff --git a/libnl-route-3.sym b/libnl-route-3.sym
index 03b7c4e..ad2ed36 100644
--- a/libnl-route-3.sym
+++ b/libnl-route-3.sym
@@ -858,6 +858,8 @@ local:
libnl_3_2_26 {
global:
+ rtnl_neigh_get_vlan;
+ rtnl_neigh_set_vlan;
rtnl_skbedit_get_action;
rtnl_skbedit_get_mark;
rtnl_skbedit_get_priority;