diff options
author | d0u9 <d0u9.su@outlook.com> | 2018-01-15 08:35:50 (GMT) |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2018-01-18 06:51:23 (GMT) |
commit | ca02edd1014234e1260d6d7ff4f51ddb9d6f54f2 (patch) | |
tree | 6bf3375b8a5a2d89aaa15403d933c8f82f2ef26b | |
parent | 2b11ab02ce24476f96c22b18e27f3737559010a2 (diff) | |
download | libnl-ca02edd1014234e1260d6d7ff4f51ddb9d6f54f2.zip libnl-ca02edd1014234e1260d6d7ff4f51ddb9d6f54f2.tar.gz libnl-ca02edd1014234e1260d6d7ff4f51ddb9d6f54f2.tar.bz2 |
Add new function for setting ifindex and parent of a classifier cache.
It is not good to give classifier cache users only one chance to
set interface index and parent handle when allocte new cache.
Sometimes we want to reuse classifier cache to reduce the overhead
of allocating new memory everytime a new cache is created.
-rw-r--r-- | include/netlink/route/classifier.h | 2 | ||||
-rw-r--r-- | lib/route/cls.c | 18 | ||||
-rw-r--r-- | libnl-route-3.sym | 1 |
3 files changed, 21 insertions, 0 deletions
diff --git a/include/netlink/route/classifier.h b/include/netlink/route/classifier.h index a8c1179..82a691f 100644 --- a/include/netlink/route/classifier.h +++ b/include/netlink/route/classifier.h @@ -27,6 +27,8 @@ extern void rtnl_cls_put(struct rtnl_cls *); extern int rtnl_cls_alloc_cache(struct nl_sock *, int, uint32_t, struct nl_cache **); +extern void rtnl_cls_cache_set_tcm_params(struct nl_cache *, int, uint32_t); + extern int rtnl_cls_build_add_request(struct rtnl_cls *, int, struct nl_msg **); extern int rtnl_cls_add(struct nl_sock *, struct rtnl_cls *, int); diff --git a/lib/route/cls.c b/lib/route/cls.c index a423b10..2aaabfc 100644 --- a/lib/route/cls.c +++ b/lib/route/cls.c @@ -345,6 +345,24 @@ int rtnl_cls_alloc_cache(struct nl_sock *sk, int ifindex, uint32_t parent, return 0; } +/** + * Set interface index and parent handle for classifier cache. + * @arg cache Pointer to cache + * @arg parent Parent qdisc/traffic class class + * + * Set the interface index and parent handle of a classifier cache. + * This is useful for reusing some existed classifier cache to reduce + * the overhead introduced by memory allocation. + * + * @return void. + */ +void rtnl_cls_cache_set_tcm_params(struct nl_cache *cache, + int ifindex, uint32_t parent) +{ + cache->c_iarg1 = ifindex; + cache->c_iarg2 = parent; +} + /** @} */ static void cls_dump_line(struct rtnl_tc *tc, struct nl_dump_params *p) diff --git a/libnl-route-3.sym b/libnl-route-3.sym index 3cee113..04ff11b 100644 --- a/libnl-route-3.sym +++ b/libnl-route-3.sym @@ -151,6 +151,7 @@ global: rtnl_cls_add; rtnl_cls_alloc; rtnl_cls_alloc_cache; + rtnl_cls_cache_set_tcm_params; rtnl_cls_build_add_request; rtnl_cls_build_change_request; rtnl_cls_build_delete_request; |