Lines Matching refs:tclass

28         _cleanup_(tclass_freep) TClass *tclass = NULL;  in tclass_new()
32 tclass = new(TClass, 1); in tclass_new()
33 if (!tclass) in tclass_new()
36 *tclass = (TClass) { in tclass_new()
42 tclass = malloc0(tclass_vtable[kind]->object_size); in tclass_new()
43 if (!tclass) in tclass_new()
46 tclass->parent = TC_H_ROOT; in tclass_new()
47 tclass->kind = kind; in tclass_new()
49 if (TCLASS_VTABLE(tclass)->init) { in tclass_new()
50 r = TCLASS_VTABLE(tclass)->init(tclass); in tclass_new()
56 *ret = TAKE_PTR(tclass); in tclass_new()
63 _cleanup_(tclass_freep) TClass *tclass = NULL; in tclass_new_static()
85 r = tclass_new(kind, &tclass); in tclass_new_static()
89 tclass->network = network; in tclass_new_static()
90 tclass->section = TAKE_PTR(n); in tclass_new_static()
91 tclass->source = NETWORK_CONFIG_SOURCE_STATIC; in tclass_new_static()
93 …shmap_ensure_put(&network->tclasses_by_section, &config_section_hash_ops, tclass->section, tclass); in tclass_new_static()
97 *ret = TAKE_PTR(tclass); in tclass_new_static()
101 TClass* tclass_free(TClass *tclass) { in tclass_free() argument
102 if (!tclass) in tclass_free()
105 if (tclass->network && tclass->section) in tclass_free()
106 hashmap_remove(tclass->network->tclasses_by_section, tclass->section); in tclass_free()
108 config_section_free(tclass->section); in tclass_free()
110 if (tclass->link) in tclass_free()
111 set_remove(tclass->link->tclasses, tclass); in tclass_free()
113 free(tclass->tca_kind); in tclass_free()
114 return mfree(tclass); in tclass_free()
117 static const char *tclass_get_tca_kind(const TClass *tclass) { in tclass_get_tca_kind() argument
118 assert(tclass); in tclass_get_tca_kind()
120 return (TCLASS_VTABLE(tclass) && TCLASS_VTABLE(tclass)->tca_kind) ? in tclass_get_tca_kind()
121 TCLASS_VTABLE(tclass)->tca_kind : tclass->tca_kind; in tclass_get_tca_kind()
124 static void tclass_hash_func(const TClass *tclass, struct siphash *state) { in tclass_hash_func() argument
125 assert(tclass); in tclass_hash_func()
128 siphash24_compress(&tclass->classid, sizeof(tclass->classid), state); in tclass_hash_func()
129 siphash24_compress(&tclass->parent, sizeof(tclass->parent), state); in tclass_hash_func()
130 siphash24_compress_string(tclass_get_tca_kind(tclass), state); in tclass_hash_func()
172 static int tclass_add(Link *link, TClass *tclass) { in tclass_add() argument
176 assert(tclass); in tclass_add()
178 r = set_ensure_put(&link->tclasses, &tclass_hash_ops, tclass); in tclass_add()
184 tclass->link = link; in tclass_add()
218 TClass *tclass; in link_find_tclass() local
222 SET_FOREACH(tclass, link->tclasses) { in link_find_tclass()
223 if (tclass->classid != classid) in link_find_tclass()
226 if (tclass->source == NETWORK_CONFIG_SOURCE_FOREIGN) in link_find_tclass()
229 if (!tclass_exists(tclass)) in link_find_tclass()
233 *ret = tclass; in link_find_tclass()
240 static void log_tclass_debug(TClass *tclass, Link *link, const char *str) { in log_tclass_debug() argument
243 assert(tclass); in log_tclass_debug()
249 (void) network_config_state_to_string_alloc(tclass->state, &state); in log_tclass_debug()
252 str, strna(network_config_source_to_string(tclass->source)), strna(state), in log_tclass_debug()
253 TC_H_MAJ(tclass->classid) >> 16, TC_H_MIN(tclass->classid), in log_tclass_debug()
254 TC_H_MAJ(tclass->parent) >> 16, TC_H_MIN(tclass->parent), in log_tclass_debug()
255 strna(tclass_get_tca_kind(tclass))); in log_tclass_debug()
258 …tclass_handler(sd_netlink *rtnl, sd_netlink_message *m, Request *req, Link *link, TClass *tclass) { in tclass_handler() argument
280 static int tclass_configure(TClass *tclass, Link *link, Request *req) { in tclass_configure() argument
284 assert(tclass); in tclass_configure()
291 log_tclass_debug(tclass, link, "Configuring"); in tclass_configure()
294 link->ifindex, tclass->classid, tclass->parent); in tclass_configure()
298 r = sd_netlink_message_append_string(m, TCA_KIND, TCLASS_VTABLE(tclass)->tca_kind); in tclass_configure()
302 if (TCLASS_VTABLE(tclass)->fill_message) { in tclass_configure()
303 r = TCLASS_VTABLE(tclass)->fill_message(link, tclass, m); in tclass_configure()
311 static bool tclass_is_ready_to_configure(TClass *tclass, Link *link) { in tclass_is_ready_to_configure() argument
312 assert(tclass); in tclass_is_ready_to_configure()
318 …return link_find_qdisc(link, tclass->classid, tclass->parent, tclass_get_tca_kind(tclass), NULL) >… in tclass_is_ready_to_configure()
321 static int tclass_process_request(Request *req, Link *link, TClass *tclass) { in tclass_process_request() argument
326 assert(tclass); in tclass_process_request()
328 if (!tclass_is_ready_to_configure(tclass, link)) in tclass_process_request()
331 r = tclass_configure(tclass, link, req); in tclass_process_request()
335 tclass_enter_configuring(tclass); in tclass_process_request()
339 int link_request_tclass(Link *link, TClass *tclass) { in link_request_tclass() argument
344 assert(tclass); in link_request_tclass()
346 if (tclass_get(link, tclass, &existing) < 0) { in link_request_tclass()
349 r = tclass_dup(tclass, &tmp); in link_request_tclass()
359 existing->source = tclass->source; in link_request_tclass()
381 TClass *tclass = NULL; in manager_rtnl_process_tclass() local
444 (void) tclass_get(link, tmp, &tclass); in manager_rtnl_process_tclass()
448 if (tclass) { in manager_rtnl_process_tclass()
449 tclass_enter_configured(tclass); in manager_rtnl_process_tclass()
450 log_tclass_debug(tclass, link, "Received remembered"); in manager_rtnl_process_tclass()
461 tclass = TAKE_PTR(tmp); in manager_rtnl_process_tclass()
467 if (tclass) { in manager_rtnl_process_tclass()
468 tclass_enter_removed(tclass); in manager_rtnl_process_tclass()
469 if (tclass->state == 0) { in manager_rtnl_process_tclass()
470 log_tclass_debug(tclass, link, "Forgetting"); in manager_rtnl_process_tclass()
471 tclass_free(tclass); in manager_rtnl_process_tclass()
473 log_tclass_debug(tclass, link, "Removed"); in manager_rtnl_process_tclass()
486 static int tclass_section_verify(TClass *tclass) { in tclass_section_verify() argument
489 assert(tclass); in tclass_section_verify()
491 if (section_is_invalid(tclass->section)) in tclass_section_verify()
494 if (TCLASS_VTABLE(tclass)->verify) { in tclass_section_verify()
495 r = TCLASS_VTABLE(tclass)->verify(tclass); in tclass_section_verify()
504 TClass *tclass; in network_drop_invalid_tclass() local
508 HASHMAP_FOREACH(tclass, network->tclasses_by_section) in network_drop_invalid_tclass()
509 if (tclass_section_verify(tclass) < 0) in network_drop_invalid_tclass()
510 tclass_free(tclass); in network_drop_invalid_tclass()
525 _cleanup_(tclass_free_or_set_invalidp) TClass *tclass = NULL; in config_parse_tclass_parent()
534 r = tclass_new_static(ltype, network, filename, section_line, &tclass); in config_parse_tclass_parent()
544 tclass->parent = TC_H_ROOT; in config_parse_tclass_parent()
546 r = parse_handle(rvalue, &tclass->parent); in config_parse_tclass_parent()
555 TAKE_PTR(tclass); in config_parse_tclass_parent()
572 _cleanup_(tclass_free_or_set_invalidp) TClass *tclass = NULL; in config_parse_tclass_classid()
581 r = tclass_new_static(ltype, network, filename, section_line, &tclass); in config_parse_tclass_classid()
591 tclass->classid = TC_H_UNSPEC; in config_parse_tclass_classid()
592 TAKE_PTR(tclass); in config_parse_tclass_classid()
596 r = parse_handle(rvalue, &tclass->classid); in config_parse_tclass_classid()
604 TAKE_PTR(tclass); in config_parse_tclass_classid()