1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 
3 #include "macro.h"
4 #include "networkd-link.h"
5 #include "networkd-network.h"
6 #include "qdisc.h"
7 #include "tc.h"
8 #include "tclass.h"
9 
link_request_traffic_control(Link * link)10 int link_request_traffic_control(Link *link) {
11         TClass *tclass;
12         QDisc *qdisc;
13         int r;
14 
15         assert(link);
16         assert(link->network);
17 
18         link->tc_configured = false;
19 
20         HASHMAP_FOREACH(qdisc, link->network->qdiscs_by_section) {
21                 r = link_request_qdisc(link, qdisc);
22                 if (r < 0)
23                         return r;
24         }
25 
26         HASHMAP_FOREACH(tclass, link->network->tclasses_by_section) {
27                 r = link_request_tclass(link, tclass);
28                 if (r < 0)
29                         return r;
30         }
31 
32         if (link->tc_messages == 0) {
33                 link->tc_configured = true;
34                 link_check_ready(link);
35         } else {
36                 log_link_debug(link, "Setting traffic control");
37                 link_set_state(link, LINK_STATE_CONFIGURING);
38         }
39 
40         return 0;
41 }
42