static int ipv4ll_address_lost(Link *link) {
_cleanup_(address_freep) Address *address = NULL;
- _cleanup_(route_freep) Route *route = NULL;
struct in_addr addr;
int r;
assert(link);
- link->ipv4ll_route = false;
link->ipv4ll_address = false;
r = sd_ipv4ll_get_address(link->ipv4ll, &addr);
if (r < 0)
return r;
- r = route_new(&route);
- if (r < 0)
- return log_link_error_errno(link, r, "Could not allocate route: %m");
-
- route->family = AF_INET;
- route->scope = RT_SCOPE_LINK;
- route->priority = IPV4LL_ROUTE_METRIC;
-
- r = route_remove(route, link, NULL);
- if (r < 0)
- return r;
-
link_check_ready(link);
return 0;
}
-static int ipv4ll_route_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *link) {
- int r;
-
- assert(link);
- assert(!link->ipv4ll_route);
-
- r = sd_netlink_message_get_errno(m);
- if (r < 0 && r != -EEXIST) {
- log_link_error_errno(link, r, "could not set ipv4ll route: %m");
- link_enter_failed(link);
- return 1;
- }
-
- link->ipv4ll_route = true;
-
- link_check_ready(link);
-
- return 1;
-}
-
-static int ipv4ll_route_configure(Link *link) {
- _cleanup_(route_freep) Route *route = NULL;
- int r;
-
- r = route_new(&route);
- if (r < 0)
- return r;
-
- route->family = AF_INET;
- route->scope = RT_SCOPE_LINK;
- route->protocol = RTPROT_STATIC;
- route->priority = IPV4LL_ROUTE_METRIC;
- route->table = link_get_vrf_table(link);
-
- return route_configure(route, link, ipv4ll_route_handler);
-}
-
static int ipv4ll_address_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *link) {
int r;
(void) manager_rtnl_process_address(rtnl, m, link->manager);
link->ipv4ll_address = true;
-
- r = ipv4ll_route_configure(link);
- if (r < 0) {
- log_link_error_errno(link, r, "Failed to configure ipv4ll route: %m");
- link_enter_failed(link);
- }
+ link_check_ready(link);
return 1;
}
assert(link);
link->ipv4ll_address = false;
- link->ipv4ll_route = false;
r = sd_ipv4ll_get_address(ll, &address);
if (r == -ENOENT)
if (link_has_carrier(link) || !link->network->configure_without_carrier) {
- if (link_ipv4ll_enabled(link, ADDRESS_FAMILY_IPV4) && !(link->ipv4ll_address && link->ipv4ll_route))
+ if (link_ipv4ll_enabled(link, ADDRESS_FAMILY_IPV4) && !link->ipv4ll_address)
return;
if (link_ipv6ll_enabled(link) &&
if ((link_dhcp4_enabled(link) || link_dhcp6_enabled(link)) &&
!link->dhcp4_configured &&
!link->dhcp6_configured &&
- !(link_ipv4ll_enabled(link, ADDRESS_FAMILY_FALLBACK_IPV4) && link->ipv4ll_address && link->ipv4ll_route))
+ !(link_ipv4ll_enabled(link, ADDRESS_FAMILY_FALLBACK_IPV4) && link->ipv4ll_address))
/* When DHCP is enabled, at least one protocol must provide an address, or
* an IPv4ll fallback address must be configured. */
return;
output = check_output('ip route show vrf vrf99')
print(output)
self.assertRegex(output, 'default via 192.168.5.1 dev veth99 proto dhcp src 192.168.5.')
- self.assertRegex(output, 'default dev veth99 proto static scope link')
self.assertRegex(output, '169.254.0.0/16 dev veth99 proto kernel scope link src 169.254')
self.assertRegex(output, '192.168.5.0/24 dev veth99 proto kernel scope link src 192.168.5')
self.assertRegex(output, '192.168.5.0/24 via 192.168.5.5 dev veth99 proto dhcp')