]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network/qdisc: skip requesting qdisc if it is already requested
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 2 Sep 2024 03:55:59 +0000 (12:55 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 2 Sep 2024 05:12:49 +0000 (14:12 +0900)
src/network/tc/qdisc.c

index d372481d6280b5bd3dcf9a3da7e49057cb769a44..1475b4aced4de714296fad753a6b6f1ac24cd924 100644 (file)
@@ -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;