[PATCH v2] route/cls: Support setting of selector fields
Sushma Sitaram
sushma.sitaram at intel.com
Fri Oct 21 14:06:39 PDT 2016
Enables to set the shift, offset, mask and flags of the position to next header
Signed-off-by: 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..116d4c6 100644
--- a/libnl-route-3.sym
+++ b/libnl-route-3.sym
@@ -964,5 +964,6 @@ global:
rtnl_link_macvlan_macmode2str;
rtnl_link_macvlan_set_macmode;
rtnl_link_macvlan_str2macmode;
+ rtnl_u32_set_selector;
} libnl_3_2_28;
More information about the libnl
mailing list