diff options
author | Volodymyr Bendiuga <volodymyr.bendiuga@westermo.se> | 2016-03-02 08:59:07 (GMT) |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2022-03-10 09:58:24 (GMT) |
commit | b3333e0f7802f985ed2998b42f2544b70976cd00 (patch) | |
tree | b6454f57c41d3afcdcc8be4b750641538922bedd /lib/route | |
parent | 9a391880b54e42f0069bfd998a506d8132e7fcdd (diff) | |
download | libnl-b3333e0f7802f985ed2998b42f2544b70976cd00.zip libnl-b3333e0f7802f985ed2998b42f2544b70976cd00.tar.gz libnl-b3333e0f7802f985ed2998b42f2544b70976cd00.tar.bz2 |
route/qdisc: allow fetching qdiscs by their kind
API:
rtnl_qdisc_get_by_kind()
This function allows getting qdisc based on
its kind, i.e. tbf, htb, cbq, etc.
Signed-off-by: Volodymyr Bendiuga <volodymyr.bendiuga@westermo.se>
https://github.com/thom311/libnl/pull/244
Diffstat (limited to 'lib/route')
-rw-r--r-- | lib/route/qdisc.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/lib/route/qdisc.c b/lib/route/qdisc.c index 2488d66..62c4390 100644 --- a/lib/route/qdisc.c +++ b/lib/route/qdisc.c @@ -397,6 +397,38 @@ struct rtnl_qdisc *rtnl_qdisc_get_by_parent(struct nl_cache *cache, } /** + * Search qdisc by kind + * @arg cache Qdisc cache + * @arg ifindex Interface index + * @arg kind Qdisc kind (tbf, htb, cbq, etc) + * + * Searches a qdisc cache previously allocated with rtnl_qdisc_alloc_cache() + * and searches for a qdisc matching the interface index and kind. + * + * The reference counter is incremented before returning the qdisc, therefore + * the reference must be given back with rtnl_qdisc_put() after usage. + * + * @return pointer to qdisc inside the cache or NULL if no match was found. + */ +struct rtnl_qdisc *rtnl_qdisc_get_by_kind(struct nl_cache *cache, + int ifindex, char *kind) +{ + struct rtnl_qdisc *q; + + if (cache->c_ops != &rtnl_qdisc_ops) + return NULL; + + nl_list_for_each_entry(q, &cache->c_items, ce_list) { + if ((q->q_ifindex == ifindex) && (!strcmp(q->q_kind, kind))) { + nl_object_get((struct nl_object *) q); + return q; + } + } + + return NULL; +} + +/** * Search qdisc by interface index and handle * @arg cache Qdisc cache * @arg ifindex Interface index |