From d8f080d94fa9cf5e977f8805446ac7ef39f82d31 Mon Sep 17 00:00:00 2001 From: Cong Wang Date: Tue, 3 Mar 2015 22:05:34 -0800 Subject: [PATCH] cls: add rtnl_u32_get_classid() API [thaller@redhat.com: modified patch to use rtnl_tc_data_peek()] http://lists.infradead.org/pipermail/libnl/2015-March/001841.html Signed-off-by: Cong Wang Signed-off-by: Thomas Haller --- include/netlink/route/cls/u32.h | 1 + lib/route/cls/u32.c | 14 ++++++++++++++ libnl-route-3.sym | 1 + 3 files changed, 16 insertions(+) diff --git a/include/netlink/route/cls/u32.h b/include/netlink/route/cls/u32.h index 4567e16..151c818 100644 --- a/include/netlink/route/cls/u32.h +++ b/include/netlink/route/cls/u32.h @@ -23,6 +23,7 @@ extern "C" { extern void rtnl_u32_set_handle(struct rtnl_cls *, int, int, int); extern int rtnl_u32_set_classid(struct rtnl_cls *, uint32_t); +extern int rtnl_u32_get_classid(struct rtnl_cls *, uint32_t *); 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); diff --git a/lib/route/cls/u32.c b/lib/route/cls/u32.c index 1912533..8ffca07 100644 --- a/lib/route/cls/u32.c +++ b/lib/route/cls/u32.c @@ -415,6 +415,20 @@ int rtnl_u32_set_classid(struct rtnl_cls *cls, uint32_t classid) return 0; } +int rtnl_u32_get_classid(struct rtnl_cls *cls, uint32_t *classid) +{ + struct rtnl_u32 *u; + + if (!(u = rtnl_tc_data_peek(TC_CAST(cls)))) + return -NLE_INVAL; + + if (!(u->cu_mask & U32_ATTR_CLASSID)) + return -NLE_INVAL; + + *classid = u->cu_classid; + return 0; +} + int rtnl_u32_set_divisor(struct rtnl_cls *cls, uint32_t divisor) { struct rtnl_u32 *u; diff --git a/libnl-route-3.sym b/libnl-route-3.sym index 9093149..139a499 100644 --- a/libnl-route-3.sym +++ b/libnl-route-3.sym @@ -864,4 +864,5 @@ global: rtnl_tc_str2stat; rtnl_u32_add_mark; rtnl_u32_del_mark; + rtnl_u32_get_classid; } libnl_3; -- 2.40.0