diff options
author | Susant Sahani <145210+ssahani@users.noreply.github.com> | 2017-11-20 22:20:48 +0530 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2017-11-20 17:50:48 +0100 |
commit | 8a9b3a23fd0153e3b3e6768d03002819c2fc50e4 (patch) | |
tree | adbbeaf9b715a8ccecdace3eca7b14b4396bbc1f /src | |
parent | 9990ea0e59373c02b6bd64a5a4c860d2579f77db (diff) | |
download | systemd-8a9b3a23fd0153e3b3e6768d03002819c2fc50e4.tar.gz systemd-8a9b3a23fd0153e3b3e6768d03002819c2fc50e4.tar.bz2 systemd-8a9b3a23fd0153e3b3e6768d03002819c2fc50e4.zip |
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
Diffstat (limited to 'src')
-rw-r--r-- | src/network/networkd-link.c | 53 |
1 files changed, 32 insertions, 21 deletions
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) |