From 998973e313a680a3434c2dd23384e86ff01726f3 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Mon, 2 Sep 2024 12:55:59 +0900 Subject: [PATCH] network/qdisc: skip requesting qdisc if it is already requested --- src/network/tc/qdisc.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/network/tc/qdisc.c b/src/network/tc/qdisc.c index d372481d628..1475b4aced4 100644 --- a/src/network/tc/qdisc.c +++ b/src/network/tc/qdisc.c @@ -238,6 +238,30 @@ static int qdisc_get(Link *link, const QDisc *in, QDisc **ret) { return 0; } +static int qdisc_get_request(Link *link, const QDisc *qdisc, Request **ret) { + Request *req; + + assert(link); + assert(link->manager); + assert(qdisc); + + req = ordered_set_get( + link->manager->request_queue, + &(Request) { + .link = link, + .type = REQUEST_TYPE_TC_QDISC, + .userdata = (void*) qdisc, + .hash_func = (hash_func_t) qdisc_hash_func, + .compare_func = (compare_func_t) qdisc_compare_func, + }); + if (!req) + return -ENOENT; + + if (ret) + *ret = req; + return 0; +} + static int qdisc_attach(Link *link, QDisc *qdisc) { int r; @@ -485,6 +509,9 @@ int link_request_qdisc(Link *link, QDisc *qdisc) { assert(link); assert(qdisc); + if (qdisc_get_request(link, qdisc, NULL) >= 0) + return 0; /* already requested, skipping. */ + if (qdisc_get(link, qdisc, &existing) < 0) { _cleanup_(qdisc_unrefp) QDisc *tmp = NULL; -- 2.47.3