]> git.ipfire.org Git - thirdparty/libnl.git/commitdiff
cls: add rtnl_u32_get_classid() API
authorCong Wang <xiyou.wangcong@gmail.com>
Wed, 4 Mar 2015 06:05:34 +0000 (22:05 -0800)
committerThomas Haller <thaller@redhat.com>
Wed, 4 Mar 2015 19:31:37 +0000 (20:31 +0100)
[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 <xiyou.wangcong@gmail.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
include/netlink/route/cls/u32.h
lib/route/cls/u32.c
libnl-route-3.sym

index 4567e1669b0650fe92a0b3f06a0a23e17a87a3f7..151c818c907b6553e3032adae4202fd5bb7266a2 100644 (file)
@@ -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);
index 19125330a61ef802f0e3b04cf0ee255c13bc4ae1..8ffca076822d5d1e07007a027d095aa4c6db08d7 100644 (file)
@@ -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;
index 9093149adaac4ca48e8fc8cf80ea875005730029..139a4994df4defefab79626280842ef78544b197 100644 (file)
@@ -864,4 +864,5 @@ global:
        rtnl_tc_str2stat;
        rtnl_u32_add_mark;
        rtnl_u32_del_mark;
+       rtnl_u32_get_classid;
 } libnl_3;