Lines Matching refs:qdisc
46 _cleanup_(qdisc_freep) QDisc *qdisc = NULL; in qdisc_new()
50 qdisc = new(QDisc, 1); in qdisc_new()
51 if (!qdisc) in qdisc_new()
54 *qdisc = (QDisc) { in qdisc_new()
60 qdisc = malloc0(qdisc_vtable[kind]->object_size); in qdisc_new()
61 if (!qdisc) in qdisc_new()
64 qdisc->parent = TC_H_ROOT; in qdisc_new()
65 qdisc->kind = kind; in qdisc_new()
67 if (QDISC_VTABLE(qdisc)->init) { in qdisc_new()
68 r = QDISC_VTABLE(qdisc)->init(qdisc); in qdisc_new()
74 *ret = TAKE_PTR(qdisc); in qdisc_new()
81 _cleanup_(qdisc_freep) QDisc *qdisc = NULL; in qdisc_new_static()
107 r = qdisc_new(kind, &qdisc); in qdisc_new_static()
112 qdisc->handle = existing->handle; in qdisc_new_static()
113 qdisc->parent = existing->parent; in qdisc_new_static()
114 qdisc->tca_kind = TAKE_PTR(existing->tca_kind); in qdisc_new_static()
119 qdisc->network = network; in qdisc_new_static()
120 qdisc->section = TAKE_PTR(n); in qdisc_new_static()
121 qdisc->source = NETWORK_CONFIG_SOURCE_STATIC; in qdisc_new_static()
123 …= hashmap_ensure_put(&network->qdiscs_by_section, &config_section_hash_ops, qdisc->section, qdisc); in qdisc_new_static()
127 *ret = TAKE_PTR(qdisc); in qdisc_new_static()
131 QDisc* qdisc_free(QDisc *qdisc) { in qdisc_free() argument
132 if (!qdisc) in qdisc_free()
135 if (qdisc->network && qdisc->section) in qdisc_free()
136 hashmap_remove(qdisc->network->qdiscs_by_section, qdisc->section); in qdisc_free()
138 config_section_free(qdisc->section); in qdisc_free()
140 if (qdisc->link) in qdisc_free()
141 set_remove(qdisc->link->qdiscs, qdisc); in qdisc_free()
143 free(qdisc->tca_kind); in qdisc_free()
144 return mfree(qdisc); in qdisc_free()
147 static const char *qdisc_get_tca_kind(const QDisc *qdisc) { in qdisc_get_tca_kind() argument
148 assert(qdisc); in qdisc_get_tca_kind()
150 return (QDISC_VTABLE(qdisc) && QDISC_VTABLE(qdisc)->tca_kind) ? in qdisc_get_tca_kind()
151 QDISC_VTABLE(qdisc)->tca_kind : qdisc->tca_kind; in qdisc_get_tca_kind()
154 static void qdisc_hash_func(const QDisc *qdisc, struct siphash *state) { in qdisc_hash_func() argument
155 assert(qdisc); in qdisc_hash_func()
158 siphash24_compress(&qdisc->handle, sizeof(qdisc->handle), state); in qdisc_hash_func()
159 siphash24_compress(&qdisc->parent, sizeof(qdisc->parent), state); in qdisc_hash_func()
160 siphash24_compress_string(qdisc_get_tca_kind(qdisc), state); in qdisc_hash_func()
202 static int qdisc_add(Link *link, QDisc *qdisc) { in qdisc_add() argument
206 assert(qdisc); in qdisc_add()
208 r = set_ensure_put(&link->qdiscs, &qdisc_hash_ops, qdisc); in qdisc_add()
214 qdisc->link = link; in qdisc_add()
247 static void log_qdisc_debug(QDisc *qdisc, Link *link, const char *str) { in log_qdisc_debug() argument
250 assert(qdisc); in log_qdisc_debug()
256 (void) network_config_state_to_string_alloc(qdisc->state, &state); in log_qdisc_debug()
259 str, strna(network_config_source_to_string(qdisc->source)), strna(state), in log_qdisc_debug()
260 TC_H_MAJ(qdisc->handle) >> 16, TC_H_MIN(qdisc->handle), in log_qdisc_debug()
261 TC_H_MAJ(qdisc->parent) >> 16, TC_H_MIN(qdisc->parent), in log_qdisc_debug()
262 strna(qdisc_get_tca_kind(qdisc))); in log_qdisc_debug()
266 QDisc *qdisc; in link_find_qdisc() local
272 SET_FOREACH(qdisc, link->qdiscs) { in link_find_qdisc()
273 if (qdisc->handle != handle) in link_find_qdisc()
276 if (qdisc->parent != parent) in link_find_qdisc()
279 if (qdisc->source == NETWORK_CONFIG_SOURCE_FOREIGN) in link_find_qdisc()
282 if (!qdisc_exists(qdisc)) in link_find_qdisc()
285 if (kind && !streq_ptr(kind, qdisc_get_tca_kind(qdisc))) in link_find_qdisc()
289 *ret = qdisc; in link_find_qdisc()
296 …nt qdisc_handler(sd_netlink *rtnl, sd_netlink_message *m, Request *req, Link *link, QDisc *qdisc) { in qdisc_handler() argument
318 static int qdisc_configure(QDisc *qdisc, Link *link, Request *req) { in qdisc_configure() argument
322 assert(qdisc); in qdisc_configure()
329 log_qdisc_debug(qdisc, link, "Configuring"); in qdisc_configure()
332 link->ifindex, qdisc->handle, qdisc->parent); in qdisc_configure()
336 r = sd_netlink_message_append_string(m, TCA_KIND, qdisc_get_tca_kind(qdisc)); in qdisc_configure()
340 if (QDISC_VTABLE(qdisc) && QDISC_VTABLE(qdisc)->fill_message) { in qdisc_configure()
341 r = QDISC_VTABLE(qdisc)->fill_message(link, qdisc, m); in qdisc_configure()
349 static bool qdisc_is_ready_to_configure(QDisc *qdisc, Link *link) { in qdisc_is_ready_to_configure() argument
350 assert(qdisc); in qdisc_is_ready_to_configure()
356 if (IN_SET(qdisc->parent, TC_H_ROOT, TC_H_CLSACT)) /* TC_H_CLSACT == TC_H_INGRESS */ in qdisc_is_ready_to_configure()
359 return link_find_tclass(link, qdisc->parent, NULL) >= 0; in qdisc_is_ready_to_configure()
362 static int qdisc_process_request(Request *req, Link *link, QDisc *qdisc) { in qdisc_process_request() argument
367 assert(qdisc); in qdisc_process_request()
369 if (!qdisc_is_ready_to_configure(qdisc, link)) in qdisc_process_request()
372 r = qdisc_configure(qdisc, link, req); in qdisc_process_request()
376 qdisc_enter_configuring(qdisc); in qdisc_process_request()
380 int link_request_qdisc(Link *link, QDisc *qdisc) { in link_request_qdisc() argument
385 assert(qdisc); in link_request_qdisc()
387 if (qdisc_get(link, qdisc, &existing) < 0) { in link_request_qdisc()
390 r = qdisc_dup(qdisc, &tmp); in link_request_qdisc()
400 existing->source = qdisc->source; in link_request_qdisc()
422 QDisc *qdisc = NULL; in manager_rtnl_process_qdisc() local
485 (void) qdisc_get(link, tmp, &qdisc); in manager_rtnl_process_qdisc()
489 if (qdisc) { in manager_rtnl_process_qdisc()
490 qdisc_enter_configured(qdisc); in manager_rtnl_process_qdisc()
491 log_qdisc_debug(qdisc, link, "Received remembered"); in manager_rtnl_process_qdisc()
502 qdisc = TAKE_PTR(tmp); in manager_rtnl_process_qdisc()
508 if (qdisc) { in manager_rtnl_process_qdisc()
509 qdisc_enter_removed(qdisc); in manager_rtnl_process_qdisc()
510 if (qdisc->state == 0) { in manager_rtnl_process_qdisc()
511 log_qdisc_debug(qdisc, link, "Forgetting"); in manager_rtnl_process_qdisc()
512 qdisc_free(qdisc); in manager_rtnl_process_qdisc()
514 log_qdisc_debug(qdisc, link, "Removed"); in manager_rtnl_process_qdisc()
527 static int qdisc_section_verify(QDisc *qdisc, bool *has_root, bool *has_clsact) { in qdisc_section_verify() argument
530 assert(qdisc); in qdisc_section_verify()
534 if (section_is_invalid(qdisc->section)) in qdisc_section_verify()
537 if (QDISC_VTABLE(qdisc) && QDISC_VTABLE(qdisc)->verify) { in qdisc_section_verify()
538 r = QDISC_VTABLE(qdisc)->verify(qdisc); in qdisc_section_verify()
543 if (qdisc->parent == TC_H_ROOT) { in qdisc_section_verify()
548 qdisc->section->filename, qdisc->section->line); in qdisc_section_verify()
550 } else if (qdisc->parent == TC_H_CLSACT) { /* TC_H_CLSACT == TC_H_INGRESS */ in qdisc_section_verify()
555 qdisc->section->filename, qdisc->section->line); in qdisc_section_verify()
564 QDisc *qdisc; in network_drop_invalid_qdisc() local
568 HASHMAP_FOREACH(qdisc, network->qdiscs_by_section) in network_drop_invalid_qdisc()
569 if (qdisc_section_verify(qdisc, &has_root, &has_clsact) < 0) in network_drop_invalid_qdisc()
570 qdisc_free(qdisc); in network_drop_invalid_qdisc()
585 _cleanup_(qdisc_free_or_set_invalidp) QDisc *qdisc = NULL; in config_parse_qdisc_parent()
594 r = qdisc_new_static(ltype, network, filename, section_line, &qdisc); in config_parse_qdisc_parent()
604 qdisc->parent = TC_H_ROOT; in config_parse_qdisc_parent()
606 qdisc->parent = TC_H_CLSACT; in config_parse_qdisc_parent()
607 qdisc->handle = TC_H_MAKE(TC_H_CLSACT, 0); in config_parse_qdisc_parent()
609 qdisc->parent = TC_H_INGRESS; in config_parse_qdisc_parent()
610 qdisc->handle = TC_H_MAKE(TC_H_INGRESS, 0); in config_parse_qdisc_parent()
612 r = parse_handle(rvalue, &qdisc->parent); in config_parse_qdisc_parent()
622 r = free_and_strdup(&qdisc->tca_kind, rvalue); in config_parse_qdisc_parent()
626 qdisc->tca_kind = mfree(qdisc->tca_kind); in config_parse_qdisc_parent()
628 TAKE_PTR(qdisc); in config_parse_qdisc_parent()
645 _cleanup_(qdisc_free_or_set_invalidp) QDisc *qdisc = NULL; in config_parse_qdisc_handle()
655 r = qdisc_new_static(ltype, network, filename, section_line, &qdisc); in config_parse_qdisc_handle()
665 qdisc->handle = TC_H_UNSPEC; in config_parse_qdisc_handle()
666 TAKE_PTR(qdisc); in config_parse_qdisc_handle()
678 qdisc->handle = (uint32_t) n << 16; in config_parse_qdisc_handle()
679 TAKE_PTR(qdisc); in config_parse_qdisc_handle()