Lines Matching refs:network
50 static int network_resolve_netdev_one(Network *network, const char *name, NetDevKind kind, NetDev *… in network_resolve_netdev_one() argument
59 assert(network); in network_resolve_netdev_one()
60 assert(network->manager); in network_resolve_netdev_one()
61 assert(network->filename); in network_resolve_netdev_one()
71 network->filename, name); in network_resolve_netdev_one()
74 r = netdev_get(network->manager, name, &netdev); in network_resolve_netdev_one()
77 network->filename, name); in network_resolve_netdev_one()
93 network->filename, name, kind_string); in network_resolve_netdev_one()
99 static int network_resolve_stacked_netdevs(Network *network) { in network_resolve_stacked_netdevs() argument
103 assert(network); in network_resolve_stacked_netdevs()
105 HASHMAP_FOREACH_KEY(kind, name, network->stacked_netdev_names) { in network_resolve_stacked_netdevs()
108 if (network_resolve_netdev_one(network, name, PTR_TO_INT(kind), &netdev) <= 0) in network_resolve_stacked_netdevs()
111 … r = hashmap_ensure_put(&network->stacked_netdevs, &string_hash_ops, netdev->ifname, netdev); in network_resolve_stacked_netdevs()
116 network->filename, (const char *) name); in network_resolve_stacked_netdevs()
124 int network_verify(Network *network) { in network_verify() argument
127 assert(network); in network_verify()
128 assert(network->manager); in network_verify()
129 assert(network->filename); in network_verify()
131 if (net_match_is_empty(&network->match) && !network->conditions) in network_verify()
135 network->filename); in network_verify()
138 if (!condition_test_list(network->conditions, environ, NULL, NULL, NULL)) in network_verify()
141 network->filename); in network_verify()
143 if (network->keep_master) { in network_verify()
144 if (network->batadv_name) in network_verify()
146 network->filename); in network_verify()
147 if (network->bond_name) in network_verify()
149 network->filename); in network_verify()
150 if (network->bridge_name) in network_verify()
152 network->filename); in network_verify()
153 if (network->vrf_name) in network_verify()
155 network->filename); in network_verify()
157 network->batadv_name = mfree(network->batadv_name); in network_verify()
158 network->bond_name = mfree(network->bond_name); in network_verify()
159 network->bridge_name = mfree(network->bridge_name); in network_verify()
160 network->vrf_name = mfree(network->vrf_name); in network_verify()
163 …(void) network_resolve_netdev_one(network, network->batadv_name, NETDEV_KIND_BATADV, &network->bat… in network_verify()
164 … (void) network_resolve_netdev_one(network, network->bond_name, NETDEV_KIND_BOND, &network->bond); in network_verify()
165 …(void) network_resolve_netdev_one(network, network->bridge_name, NETDEV_KIND_BRIDGE, &network->bri… in network_verify()
166 … (void) network_resolve_netdev_one(network, network->vrf_name, NETDEV_KIND_VRF, &network->vrf); in network_verify()
167 r = network_resolve_stacked_netdevs(network); in network_verify()
172 network->batadv_name = mfree(network->batadv_name); in network_verify()
173 network->bond_name = mfree(network->bond_name); in network_verify()
174 network->bridge_name = mfree(network->bridge_name); in network_verify()
175 network->vrf_name = mfree(network->vrf_name); in network_verify()
176 network->stacked_netdev_names = hashmap_free_free_key(network->stacked_netdev_names); in network_verify()
178 if (network->bond) { in network_verify()
180 if (network->link_local >= 0 && network->link_local != ADDRESS_FAMILY_NO) { in network_verify()
182 network->filename); in network_verify()
183 network->link_local = ADDRESS_FAMILY_NO; in network_verify()
185 if (network->dhcp_server) { in network_verify()
187 network->filename); in network_verify()
188 network->dhcp_server = false; in network_verify()
190 if (!ordered_hashmap_isempty(network->addresses_by_section)) in network_verify()
192 network->filename); in network_verify()
193 if (!hashmap_isempty(network->routes_by_section)) in network_verify()
195 network->filename); in network_verify()
197 …network->addresses_by_section = ordered_hashmap_free_with_destructor(network->addresses_by_section… in network_verify()
198 … network->routes_by_section = hashmap_free_with_destructor(network->routes_by_section, route_free); in network_verify()
201 if (network->link_local < 0) { in network_verify()
202 network->link_local = ADDRESS_FAMILY_IPV6; in network_verify()
204 if (network->keep_master || network->bridge) in network_verify()
205 network->link_local = ADDRESS_FAMILY_NO; in network_verify()
209 HASHMAP_FOREACH(netdev, network->stacked_netdevs) { in network_verify()
222 network->link_local = ADDRESS_FAMILY_NO; in network_verify()
230 if (network->ipv6ll_address_gen_mode == IPV6_LINK_LOCAL_ADDRESSS_GEN_MODE_NONE) in network_verify()
231 SET_FLAG(network->link_local, ADDRESS_FAMILY_IPV6, false); in network_verify()
233 if (in6_addr_is_set(&network->ipv6ll_stable_secret) && in network_verify()
234 network->ipv6ll_address_gen_mode < 0) in network_verify()
235 network->ipv6ll_address_gen_mode = IPV6_LINK_LOCAL_ADDRESSS_GEN_MODE_STABLE_PRIVACY; in network_verify()
238 network->ip_forward |= network->ip_masquerade; in network_verify()
240 network_adjust_ipv6_proxy_ndp(network); in network_verify()
241 network_adjust_ipv6_accept_ra(network); in network_verify()
242 network_adjust_dhcp(network); in network_verify()
243 network_adjust_radv(network); in network_verify()
244 network_adjust_bridge_vlan(network); in network_verify()
246 if (network->mtu > 0 && network->dhcp_use_mtu) { in network_verify()
248 "Disabling UseMTU=.", network->filename); in network_verify()
249 network->dhcp_use_mtu = false; in network_verify()
252 if (network->dhcp_critical >= 0) { in network_verify()
253 if (network->keep_configuration >= 0) { in network_verify()
254 if (network->manager->keep_configuration < 0) in network_verify()
256 "Ignoring CriticalConnection=.", network->filename); in network_verify()
257 } else if (network->dhcp_critical) in network_verify()
259 network->keep_configuration = KEEP_CONFIGURATION_YES; in network_verify()
261 network->keep_configuration = KEEP_CONFIGURATION_NO; in network_verify()
264 if (!strv_isempty(network->bind_carrier)) { in network_verify()
265 … if (!IN_SET(network->activation_policy, _ACTIVATION_POLICY_INVALID, ACTIVATION_POLICY_BOUND)) in network_verify()
267 "Setting ActivationPolicy=bound.", network->filename); in network_verify()
268 network->activation_policy = ACTIVATION_POLICY_BOUND; in network_verify()
269 } else if (network->activation_policy == ACTIVATION_POLICY_BOUND) { in network_verify()
271 "Ignoring ActivationPolicy=bound.", network->filename); in network_verify()
272 network->activation_policy = ACTIVATION_POLICY_UP; in network_verify()
275 if (network->activation_policy == _ACTIVATION_POLICY_INVALID) in network_verify()
276 network->activation_policy = ACTIVATION_POLICY_UP; in network_verify()
278 if (network->activation_policy == ACTIVATION_POLICY_ALWAYS_UP) { in network_verify()
279 … if (network->ignore_carrier_loss_set && network->ignore_carrier_loss_usec < USEC_INFINITY) in network_verify()
281 "Setting IgnoreCarrierLoss=yes.", network->filename); in network_verify()
282 network->ignore_carrier_loss_set = true; in network_verify()
283 network->ignore_carrier_loss_usec = USEC_INFINITY; in network_verify()
286 if (!network->ignore_carrier_loss_set) { in network_verify()
287 network->ignore_carrier_loss_set = true; in network_verify()
288 … network->ignore_carrier_loss_usec = network->configure_without_carrier ? USEC_INFINITY : 0; in network_verify()
291 …if (IN_SET(network->activation_policy, ACTIVATION_POLICY_DOWN, ACTIVATION_POLICY_ALWAYS_DOWN, ACTI… in network_verify()
292 if (network->required_for_online < 0 || in network_verify()
293 …(network->required_for_online == true && network->activation_policy == ACTIVATION_POLICY_ALWAYS_DO… in network_verify()
294 … log_debug("%s: Setting RequiredForOnline=no because ActivationPolicy=%s.", network->filename, in network_verify()
295 activation_policy_to_string(network->activation_policy)); in network_verify()
296 network->required_for_online = false; in network_verify()
297 } else if (network->required_for_online == true) in network_verify()
299 "this may cause a delay at boot.", network->filename, in network_verify()
300 activation_policy_to_string(network->activation_policy)); in network_verify()
303 if (network->required_for_online < 0) in network_verify()
304 network->required_for_online = true; in network_verify()
306 if (network->keep_configuration < 0) in network_verify()
307 network->keep_configuration = KEEP_CONFIGURATION_NO; in network_verify()
309 if (network->ipv6_proxy_ndp == 0 && !set_isempty(network->ipv6_proxy_ndp_addresses)) { in network_verify()
310 … log_warning("%s: IPv6ProxyNDP= is disabled. Ignoring IPv6ProxyNDPAddress=.", network->filename); in network_verify()
311 … network->ipv6_proxy_ndp_addresses = set_free_free(network->ipv6_proxy_ndp_addresses); in network_verify()
314 r = network_drop_invalid_addresses(network); in network_verify()
317 network_drop_invalid_routes(network); in network_verify()
318 network_drop_invalid_nexthops(network); in network_verify()
319 network_drop_invalid_bridge_fdb_entries(network); in network_verify()
320 network_drop_invalid_bridge_mdb_entries(network); in network_verify()
321 network_drop_invalid_neighbors(network); in network_verify()
322 network_drop_invalid_address_labels(network); in network_verify()
323 network_drop_invalid_prefixes(network); in network_verify()
324 network_drop_invalid_route_prefixes(network); in network_verify()
325 network_drop_invalid_routing_policy_rules(network); in network_verify()
326 network_drop_invalid_qdisc(network); in network_verify()
327 network_drop_invalid_tclass(network); in network_verify()
328 r = sr_iov_drop_invalid_sections(UINT32_MAX, network->sr_iov_by_section); in network_verify()
331 network_drop_invalid_static_leases(network); in network_verify()
333 network_adjust_dhcp_server(network); in network_verify()
340 _cleanup_(network_unrefp) Network *network = NULL; in network_load_one()
372 network = new(Network, 1); in network_load_one()
373 if (!network) in network_load_one()
376 *network = (Network) { in network_load_one()
551 network, in network_load_one()
552 &network->stats_by_path); in network_load_one()
556 r = network_add_ipv4ll_route(network); in network_load_one()
558 … return log_warning_errno(r, "%s: Failed to add IPv4LL route: %m", network->filename); in network_load_one()
560 r = network_add_default_route_on_device(network); in network_load_one()
563 network->filename); in network_load_one()
565 r = network_verify(network); in network_load_one()
569 r = ordered_hashmap_ensure_put(networks, &string_hash_ops, network->name, network); in network_load_one()
573 TAKE_PTR(network); in network_load_one()
663 static Network *network_free(Network *network) { in network_free() argument
664 if (!network) in network_free()
667 free(network->filename); in network_free()
668 hashmap_free(network->stats_by_path); in network_free()
670 net_match_clear(&network->match); in network_free()
671 condition_free_list(network->conditions); in network_free()
673 free(network->dhcp_server_relay_agent_circuit_id); in network_free()
674 free(network->dhcp_server_relay_agent_remote_id); in network_free()
675 free(network->dhcp_server_boot_server_name); in network_free()
676 free(network->dhcp_server_boot_filename); in network_free()
678 free(network->description); in network_free()
679 free(network->dhcp_vendor_class_identifier); in network_free()
680 free(network->dhcp_mudurl); in network_free()
681 strv_free(network->dhcp_user_class); in network_free()
682 free(network->dhcp_hostname); in network_free()
683 free(network->dhcp_label); in network_free()
684 set_free(network->dhcp_deny_listed_ip); in network_free()
685 set_free(network->dhcp_allow_listed_ip); in network_free()
686 set_free(network->dhcp_request_options); in network_free()
687 set_free(network->dhcp6_request_options); in network_free()
688 free(network->dhcp6_mudurl); in network_free()
689 strv_free(network->dhcp6_user_class); in network_free()
690 strv_free(network->dhcp6_vendor_class); in network_free()
692 strv_free(network->ntp); in network_free()
693 for (unsigned i = 0; i < network->n_dns; i++) in network_free()
694 in_addr_full_free(network->dns[i]); in network_free()
695 free(network->dns); in network_free()
696 ordered_set_free(network->search_domains); in network_free()
697 ordered_set_free(network->route_domains); in network_free()
698 strv_free(network->bind_carrier); in network_free()
700 ordered_set_free(network->router_search_domains); in network_free()
701 free(network->router_dns); in network_free()
702 set_free(network->ndisc_deny_listed_router); in network_free()
703 set_free(network->ndisc_allow_listed_router); in network_free()
704 set_free(network->ndisc_deny_listed_prefix); in network_free()
705 set_free(network->ndisc_allow_listed_prefix); in network_free()
706 set_free(network->ndisc_deny_listed_route_prefix); in network_free()
707 set_free(network->ndisc_allow_listed_route_prefix); in network_free()
709 free(network->batadv_name); in network_free()
710 free(network->bridge_name); in network_free()
711 free(network->bond_name); in network_free()
712 free(network->vrf_name); in network_free()
713 hashmap_free_free_key(network->stacked_netdev_names); in network_free()
714 netdev_unref(network->bridge); in network_free()
715 netdev_unref(network->bond); in network_free()
716 netdev_unref(network->vrf); in network_free()
717 hashmap_free_with_destructor(network->stacked_netdevs, netdev_unref); in network_free()
719 set_free_free(network->ipv6_proxy_ndp_addresses); in network_free()
720 ordered_hashmap_free_with_destructor(network->addresses_by_section, address_free); in network_free()
721 hashmap_free_with_destructor(network->routes_by_section, route_free); in network_free()
722 hashmap_free_with_destructor(network->nexthops_by_section, nexthop_free); in network_free()
723 hashmap_free_with_destructor(network->bridge_fdb_entries_by_section, bridge_fdb_free); in network_free()
724 hashmap_free_with_destructor(network->bridge_mdb_entries_by_section, bridge_mdb_free); in network_free()
725 hashmap_free_with_destructor(network->neighbors_by_section, neighbor_free); in network_free()
726 hashmap_free_with_destructor(network->address_labels_by_section, address_label_free); in network_free()
727 hashmap_free_with_destructor(network->prefixes_by_section, prefix_free); in network_free()
728 hashmap_free_with_destructor(network->route_prefixes_by_section, route_prefix_free); in network_free()
729 hashmap_free_with_destructor(network->rules_by_section, routing_policy_rule_free); in network_free()
730 … hashmap_free_with_destructor(network->dhcp_static_leases_by_section, dhcp_static_lease_free); in network_free()
731 ordered_hashmap_free_with_destructor(network->sr_iov_by_section, sr_iov_free); in network_free()
732 hashmap_free_with_destructor(network->qdiscs_by_section, qdisc_free); in network_free()
733 hashmap_free_with_destructor(network->tclasses_by_section, tclass_free); in network_free()
735 free(network->name); in network_free()
737 free(network->dhcp_server_timezone); in network_free()
738 free(network->dhcp_server_uplink_name); in network_free()
739 free(network->router_uplink_name); in network_free()
740 free(network->dhcp_pd_uplink_name); in network_free()
743 free(network->dhcp_server_emit[t].addresses); in network_free()
745 set_free_free(network->dnssec_negative_trust_anchors); in network_free()
747 free(network->lldp_mudurl); in network_free()
749 ordered_hashmap_free(network->dhcp_client_send_options); in network_free()
750 ordered_hashmap_free(network->dhcp_client_send_vendor_options); in network_free()
751 ordered_hashmap_free(network->dhcp_server_send_options); in network_free()
752 ordered_hashmap_free(network->dhcp_server_send_vendor_options); in network_free()
753 ordered_hashmap_free(network->dhcp6_client_send_options); in network_free()
754 ordered_hashmap_free(network->dhcp6_client_send_vendor_options); in network_free()
755 set_free(network->dhcp_pd_tokens); in network_free()
756 set_free(network->ndisc_tokens); in network_free()
758 return mfree(network); in network_free()
761 DEFINE_TRIVIAL_REF_UNREF_FUNC(Network, network, network_free);
764 Network *network; in network_get_by_name() local
770 network = ordered_hashmap_get(manager->networks, name); in network_get_by_name()
771 if (!network) in network_get_by_name()
774 *ret = network; in network_get_by_name()
779 bool network_has_static_ipv6_configurations(Network *network) { in network_has_static_ipv6_configurations() argument
786 assert(network); in network_has_static_ipv6_configurations()
788 ORDERED_HASHMAP_FOREACH(address, network->addresses_by_section) in network_has_static_ipv6_configurations()
792 HASHMAP_FOREACH(route, network->routes_by_section) in network_has_static_ipv6_configurations()
796 HASHMAP_FOREACH(fdb, network->bridge_fdb_entries_by_section) in network_has_static_ipv6_configurations()
800 HASHMAP_FOREACH(mdb, network->bridge_mdb_entries_by_section) in network_has_static_ipv6_configurations()
804 HASHMAP_FOREACH(neighbor, network->neighbors_by_section) in network_has_static_ipv6_configurations()
808 if (!hashmap_isempty(network->address_labels_by_section)) in network_has_static_ipv6_configurations()
811 if (!hashmap_isempty(network->prefixes_by_section)) in network_has_static_ipv6_configurations()
814 if (!hashmap_isempty(network->route_prefixes_by_section)) in network_has_static_ipv6_configurations()
1177 Network *network = userdata; in config_parse_required_for_online() local
1185 assert(network); in config_parse_required_for_online()
1188 network->required_for_online = -1; in config_parse_required_for_online()
1189 network->required_operstate_for_online = LINK_OPERSTATE_RANGE_DEFAULT; in config_parse_required_for_online()
1207 network->required_for_online = required; in config_parse_required_for_online()
1208 network->required_operstate_for_online = range; in config_parse_required_for_online()
1225 Network *network = userdata; in config_parse_link_group() local
1232 assert(network); in config_parse_link_group()
1235 network->group = -1; in config_parse_link_group()
1252 network->group = group; in config_parse_link_group()
1268 Network *network = userdata; in config_parse_ignore_carrier_loss() local
1275 assert(network); in config_parse_ignore_carrier_loss()
1278 network->ignore_carrier_loss_set = false; in config_parse_ignore_carrier_loss()
1284 network->ignore_carrier_loss_set = true; in config_parse_ignore_carrier_loss()
1285 network->ignore_carrier_loss_usec = r > 0 ? USEC_INFINITY : 0; in config_parse_ignore_carrier_loss()
1296 network->ignore_carrier_loss_set = true; in config_parse_ignore_carrier_loss()
1297 network->ignore_carrier_loss_usec = usec; in config_parse_ignore_carrier_loss()