]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network/tc: support Parent=X:0 for qdiscs
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 7 Oct 2023 06:09:13 +0000 (15:09 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 7 Oct 2023 12:35:16 +0000 (21:35 +0900)
When the minor part of the parent handle is zero, let's check if the
corresponding qdisc exists, rather than tc class.

src/network/tc/qdisc.c
src/network/tc/qdisc.h
src/network/tc/tclass.c

index 193d241c5c1f63cd62932d27fad93bdbca42a143..f20f410497b2291a7865dfc791aeff38667964ac 100644 (file)
@@ -262,20 +262,15 @@ static void log_qdisc_debug(QDisc *qdisc, Link *link, const char *str) {
                        strna(qdisc_get_tca_kind(qdisc)));
 }
 
-int link_find_qdisc(Link *link, uint32_t handle, uint32_t parent, const char *kind, QDisc **ret) {
+int link_find_qdisc(Link *link, uint32_t handle, const char *kind, QDisc **ret) {
         QDisc *qdisc;
 
         assert(link);
 
-        handle = TC_H_MAJ(handle);
-
         SET_FOREACH(qdisc, link->qdiscs) {
                 if (qdisc->handle != handle)
                         continue;
 
-                if (qdisc->parent != parent)
-                        continue;
-
                 if (!qdisc_exists(qdisc))
                         continue;
 
@@ -378,9 +373,15 @@ static bool qdisc_is_ready_to_configure(QDisc *qdisc, Link *link) {
                 return false;
 
         /* TC_H_CLSACT == TC_H_INGRESS */
-        if (!IN_SET(qdisc->parent, TC_H_ROOT, TC_H_CLSACT) &&
-            link_find_tclass(link, qdisc->parent, NULL) < 0)
-                return false;
+        if (!IN_SET(qdisc->parent, TC_H_ROOT, TC_H_CLSACT)) {
+                if (TC_H_MIN(qdisc->parent) == 0) {
+                        if (link_find_qdisc(link, qdisc->parent, NULL, NULL) < 0)
+                                return false;
+                } else {
+                        if (link_find_tclass(link, qdisc->parent, NULL) < 0)
+                                return false;
+                }
+        }
 
         if (QDISC_VTABLE(qdisc) &&
             QDISC_VTABLE(qdisc)->is_ready &&
index 86db44763bf29d7640184bb601ebb3479a6144fc..a62b9413eca6e97d2f4a9b7f096f1bbd351c24e3 100644 (file)
@@ -79,7 +79,7 @@ int qdisc_new_static(QDiscKind kind, Network *network, const char *filename, uns
 
 QDisc* qdisc_drop(QDisc *qdisc);
 
-int link_find_qdisc(Link *link, uint32_t handle, uint32_t parent, const char *kind, QDisc **qdisc);
+int link_find_qdisc(Link *link, uint32_t handle, const char *kind, QDisc **qdisc);
 
 int link_request_qdisc(Link *link, QDisc *qdisc);
 
index abc9d7c14556c61d4bbd2c5cafd2aaa284055c8d..0a5fec02343e3f221e61e47b2cd6e0e31d5552e3 100644 (file)
@@ -339,7 +339,7 @@ static bool tclass_is_ready_to_configure(TClass *tclass, Link *link) {
         if (!IN_SET(link->state, LINK_STATE_CONFIGURING, LINK_STATE_CONFIGURED))
                 return false;
 
-        return link_find_qdisc(link, tclass->classid, tclass->parent, tclass_get_tca_kind(tclass), NULL) >= 0;
+        return link_find_qdisc(link, TC_H_MAJ(tclass->classid), tclass_get_tca_kind(tclass), NULL) >= 0;
 }
 
 static int tclass_process_request(Request *req, Link *link, TClass *tclass) {