summaryrefslogtreecommitdiffstats
path: root/src/network/tc/qdisc.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 03:50:40 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 03:50:40 +0000
commitfc53809803cd2bc2434e312b19a18fa36776da12 (patch)
treeb4b43bd6538f51965ce32856e9c053d0f90919c8 /src/network/tc/qdisc.c
parentAdding upstream version 255.5. (diff)
downloadsystemd-fc53809803cd2bc2434e312b19a18fa36776da12.tar.xz
systemd-fc53809803cd2bc2434e312b19a18fa36776da12.zip
Adding upstream version 256.upstream/256
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--src/network/tc/qdisc.c58
1 files changed, 39 insertions, 19 deletions
diff --git a/src/network/tc/qdisc.c b/src/network/tc/qdisc.c
index f9b9437..38dee2c 100644
--- a/src/network/tc/qdisc.c
+++ b/src/network/tc/qdisc.c
@@ -155,8 +155,8 @@ static void qdisc_hash_func(const QDisc *qdisc, struct siphash *state) {
assert(qdisc);
assert(state);
- siphash24_compress(&qdisc->handle, sizeof(qdisc->handle), state);
- siphash24_compress(&qdisc->parent, sizeof(qdisc->parent), state);
+ siphash24_compress_typesafe(qdisc->handle, state);
+ siphash24_compress_typesafe(qdisc->parent, state);
siphash24_compress_string(qdisc_get_tca_kind(qdisc), state);
}
@@ -285,37 +285,57 @@ int link_find_qdisc(Link *link, uint32_t handle, const char *kind, QDisc **ret)
return -ENOENT;
}
-QDisc* qdisc_drop(QDisc *qdisc) {
+void qdisc_mark_recursive(QDisc *qdisc) {
TClass *tclass;
- Link *link;
assert(qdisc);
+ assert(qdisc->link);
- link = ASSERT_PTR(qdisc->link);
+ if (qdisc_is_marked(qdisc))
+ return;
- qdisc_mark(qdisc); /* To avoid stack overflow. */
+ qdisc_mark(qdisc);
- /* also drop all child classes assigned to the qdisc. */
- SET_FOREACH(tclass, link->tclasses) {
- if (tclass_is_marked(tclass))
+ /* also mark all child classes assigned to the qdisc. */
+ SET_FOREACH(tclass, qdisc->link->tclasses) {
+ if (TC_H_MAJ(tclass->classid) != qdisc->handle)
continue;
- if (TC_H_MAJ(tclass->classid) != qdisc->handle)
+ tclass_mark_recursive(tclass);
+ }
+}
+
+void link_qdisc_drop_marked(Link *link) {
+ QDisc *qdisc;
+
+ assert(link);
+
+ SET_FOREACH(qdisc, link->qdiscs) {
+ if (!qdisc_is_marked(qdisc))
continue;
- tclass_drop(tclass);
+ qdisc_unmark(qdisc);
+ qdisc_enter_removed(qdisc);
+
+ if (qdisc->state == 0) {
+ log_qdisc_debug(qdisc, link, "Forgetting");
+ qdisc_free(qdisc);
+ } else
+ log_qdisc_debug(qdisc, link, "Removed");
}
+}
- qdisc_unmark(qdisc);
- qdisc_enter_removed(qdisc);
+QDisc* qdisc_drop(QDisc *qdisc) {
+ assert(qdisc);
+ assert(qdisc->link);
- if (qdisc->state == 0) {
- log_qdisc_debug(qdisc, link, "Forgetting");
- qdisc = qdisc_free(qdisc);
- } else
- log_qdisc_debug(qdisc, link, "Removed");
+ qdisc_mark_recursive(qdisc);
+
+ /* link_qdisc_drop_marked() may invalidate qdisc, so run link_tclass_drop_marked() first. */
+ link_tclass_drop_marked(qdisc->link);
+ link_qdisc_drop_marked(qdisc->link);
- return qdisc;
+ return NULL;
}
static int qdisc_handler(sd_netlink *rtnl, sd_netlink_message *m, Request *req, Link *link, QDisc *qdisc) {