[PATCH] neigh: add support for NDA_VLAN nl attribute
Jonas Johansson
jonasj76 at gmail.com
Thu Mar 19 12:15:52 PDT 2015
Signed-off-by: Jonas Johansson <jonasj76 at gmail.com>
---
include/linux-private/linux/neighbour.h | 1 +
include/netlink-private/types.h | 1 +
include/netlink/route/neighbour.h | 3 +++
lib/route/neigh.c | 18 ++++++++++++++++++
4 files changed, 23 insertions(+)
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..b830dc3 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;
@@ -596,6 +597,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 +912,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 = {
--
2.3.1
More information about the libnl
mailing list