[PATCH] route/cls: Support setting of selector fields

Sushma Sitaram sushma.sitaram at intel.com
Wed Sep 28 11:59:57 PDT 2016


Enables to set the shift, offset, mask and flags of the position to next header

Signed-off-by Sushma Sitaram: Sushma Sitaram <sushma.sitaram at intel.com>
---
 include/netlink/route/cls/u32.h |    1 +
 lib/route/cls/u32.c             |   30 ++++++++++++++++++++++++++++++
 libnl-route-3.sym               |    1 +
 3 files changed, 32 insertions(+)

diff --git a/include/netlink/route/cls/u32.h b/include/netlink/route/cls/u32.h
index 151c818..7475443 100644
--- a/include/netlink/route/cls/u32.h
+++ b/include/netlink/route/cls/u32.h
@@ -28,6 +28,7 @@ extern int	rtnl_u32_set_divisor(struct rtnl_cls *, uint32_t);
 extern int	rtnl_u32_set_link(struct rtnl_cls *, uint32_t);
 extern int	rtnl_u32_set_hashtable(struct rtnl_cls *, uint32_t);
 extern int	rtnl_u32_set_hashmask(struct rtnl_cls *, uint32_t, uint32_t);
+extern int	rtnl_u32_set_selector(struct rtnl_cls *, int, uint32_t, char, uint16_t, char);
 extern int	rtnl_u32_set_cls_terminal(struct rtnl_cls *);
 
 extern int	rtnl_u32_set_flags(struct rtnl_cls *, int);
diff --git a/lib/route/cls/u32.c b/lib/route/cls/u32.c
index 8ffca07..765a6d1 100644
--- a/lib/route/cls/u32.c
+++ b/lib/route/cls/u32.c
@@ -491,6 +491,36 @@ int rtnl_u32_set_hashmask(struct rtnl_cls *cls, uint32_t hashmask, uint32_t offs
 	return 0;
 }
 
+int rtnl_u32_set_selector(struct rtnl_cls *cls, int offoff, uint32_t offmask, char offshift, uint16_t off, char flags)
+{
+	struct rtnl_u32 *u;
+	struct tc_u32_sel *sel;
+	int err;
+
+	offmask = ntohs(offmask);
+
+	if (!(u = (struct rtnl_u32 *) rtnl_tc_data(TC_CAST(cls))))
+		return -NLE_NOMEM;
+
+	sel = u32_selector_alloc(u);
+	if (!sel)
+		return -NLE_NOMEM;
+
+	err = nl_data_append(u->cu_selector, NULL, sizeof(struct tc_u32_key));
+	if(err < 0)
+	return err;
+
+	sel = u32_selector(u);
+
+	sel->offoff = offoff;
+	sel->offmask = offmask;
+	sel->offshift = offshift;
+	sel->flags |= TC_U32_VAROFFSET;
+	sel->off = off;
+	sel->flags |= flags;
+	return 0;
+}
+
 int rtnl_u32_set_cls_terminal(struct rtnl_cls *cls)
 {
 	struct rtnl_u32 *u;
diff --git a/libnl-route-3.sym b/libnl-route-3.sym
index 448a617..2fc0dfa 100644
--- a/libnl-route-3.sym
+++ b/libnl-route-3.sym
@@ -830,6 +830,7 @@ global:
 	rtnl_u32_set_flags;
 	rtnl_u32_set_handle;
 	rtnl_u32_set_hashmask;
+	rtnl_u32_set_selector;
 	rtnl_u32_set_hashtable;
 	rtnl_u32_set_link;
 




More information about the libnl mailing list