summaryrefslogtreecommitdiffstats
path: root/src/network/tc/tc.c
blob: 8a1c5b3a3b3a12ca94acaa695ab7f089bedbe06f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/* SPDX-License-Identifier: LGPL-2.1-or-later */

#include "macro.h"
#include "networkd-link.h"
#include "networkd-network.h"
#include "qdisc.h"
#include "tc.h"
#include "tclass.h"

int link_request_traffic_control(Link *link) {
        TClass *tclass;
        QDisc *qdisc;
        int r;

        assert(link);
        assert(link->network);

        link->tc_configured = false;

        HASHMAP_FOREACH(qdisc, link->network->qdiscs_by_section) {
                r = link_request_qdisc(link, qdisc);
                if (r < 0)
                        return r;
        }

        HASHMAP_FOREACH(tclass, link->network->tclasses_by_section) {
                r = link_request_tclass(link, tclass);
                if (r < 0)
                        return r;
        }

        if (link->tc_messages == 0) {
                link->tc_configured = true;
                link_check_ready(link);
        } else {
                log_link_debug(link, "Setting traffic control");
                link_set_state(link, LINK_STATE_CONFIGURING);
        }

        return 0;
}