From 8a9b3a23fd0153e3b3e6768d03002819c2fc50e4 Mon Sep 17 00:00:00 2001 From: Susant Sahani <145210+ssahani@users.noreply.github.com> Date: Mon, 20 Nov 2017 22:20:48 +0530 Subject: networkd: Set RoutingPolicyRule in link_configure (#7235) The RoutingPolicyRules are not added when we are calling from set_address the link->message++ and link->message-- never reaches to zero in the callback function resulting routes are never gets added. Closes #7200 --- src/network/networkd-link.c | 53 +++++++++++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c index 6e4f2635fd..bad984ef93 100644 --- a/src/network/networkd-link.c +++ b/src/network/networkd-link.c @@ -772,6 +772,36 @@ void link_check_ready(Link *link) { return; } +static int link_set_routing_policy_rule(Link *link) { + RoutingPolicyRule *rule, *rrule = NULL; + int r; + + assert(link); + assert(link->network); + + LIST_FOREACH(rules, rule, link->network->rules) { + r = routing_policy_rule_get(link->manager, rule->family, &rule->from, rule->from_prefixlen, &rule->to, + rule->to_prefixlen, rule->tos, rule->fwmark, rule->table, &rrule); + if (r == 1) { + (void) routing_policy_rule_make_local(link->manager, rrule); + continue; + } + + r = routing_policy_rule_configure(rule, link, link_routing_policy_rule_handler, false); + if (r < 0) { + log_link_warning_errno(link, r, "Could not set routing policy rules: %m"); + link_enter_failed(link); + return r; + } + + link->link_messages++; + } + + routing_policy_rule_purge(link->manager, link); + + return 0; +} + static int route_handler(sd_netlink *rtnl, sd_netlink_message *m, void *userdata) { _cleanup_link_unref_ Link *link = userdata; int r; @@ -1019,7 +1049,6 @@ static int link_set_bridge_fdb(Link *link) { } static int link_enter_set_addresses(Link *link) { - RoutingPolicyRule *rule, *rrule = NULL; AddressLabel *label; Address *ad; int r; @@ -1056,26 +1085,6 @@ static int link_enter_set_addresses(Link *link) { link->link_messages++; } - LIST_FOREACH(rules, rule, link->network->rules) { - r = routing_policy_rule_get(link->manager, rule->family, &rule->from, rule->from_prefixlen, &rule->to, - rule->to_prefixlen, rule->tos, rule->fwmark, rule->table, &rrule); - if (r == 1) { - (void) routing_policy_rule_make_local(link->manager, rrule); - continue; - } - - r = routing_policy_rule_configure(rule, link, link_routing_policy_rule_handler, false); - if (r < 0) { - log_link_warning_errno(link, r, "Could not set routing policy rules: %m"); - link_enter_failed(link); - return r; - } - - link->link_messages++; - } - - routing_policy_rule_purge(link->manager, link); - /* now that we can figure out a default address for the dhcp server, start it */ if (link_dhcp4_server_enabled(link)) { @@ -2673,6 +2682,8 @@ static int link_configure(Link *link) { return r; } + (void) link_set_routing_policy_rule(link); + if (link_has_carrier(link) || link->network->configure_without_carrier) { r = link_acquire_conf(link); if (r < 0) -- cgit v1.2.3