summaryrefslogtreecommitdiff
path: root/src/network/networkd-dhcp6.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/network/networkd-dhcp6.c')
-rw-r--r--src/network/networkd-dhcp6.c56
1 files changed, 30 insertions, 26 deletions
diff --git a/src/network/networkd-dhcp6.c b/src/network/networkd-dhcp6.c
index 5e9535a1e7..e61eeda7d0 100644
--- a/src/network/networkd-dhcp6.c
+++ b/src/network/networkd-dhcp6.c
@@ -134,22 +134,21 @@ int dhcp6_lease_pd_prefix_lost(sd_dhcp6_client *client, Link* link) {
&lifetime_preferred,
&lifetime_valid) >= 0) {
_cleanup_free_ char *buf = NULL;
- Route *route;
+ _cleanup_(route_freep) Route *route = NULL;
if (pd_prefix_len >= 64)
continue;
(void) in_addr_to_string(AF_INET6, &pd_prefix, &buf);
- r = route_add(link, AF_INET6, &pd_prefix, pd_prefix_len, NULL, 0, 0, 0, &route);
- if (r < 0) {
- log_link_warning_errno(link, r, "Failed to add unreachable route to delete for DHCPv6 delegated subnet %s/%u: %m",
- strnull(buf),
- pd_prefix_len);
- continue;
- }
+ r = route_new(&route);
+ if (r < 0)
+ return r;
- route_update(route, NULL, 0, NULL, NULL, 0, 0, RTN_UNREACHABLE);
+ route->family = AF_INET6;
+ route->dst = pd_prefix;
+ route->dst_prefixlen = pd_prefix_len;
+ route->type = RTN_UNREACHABLE;
r = route_remove(route, link, dhcp6_route_remove_handler);
if (r < 0) {
@@ -290,20 +289,17 @@ static int dhcp6_lease_pd_prefix_acquired(sd_dhcp6_client *client, Link *link) {
strnull(buf), pd_prefix_len);
if (pd_prefix_len < 64) {
- uint32_t table;
- Route *route;
-
- table = link_get_dhcp_route_table(link);
+ _cleanup_(route_freep) Route *route = NULL;
- r = route_add(link, AF_INET6, &pd_prefix, pd_prefix_len, NULL, 0, 0, table, &route);
- if (r < 0) {
- log_link_warning_errno(link, r, "Failed to add unreachable route for DHCPv6 delegated subnet %s/%u: %m",
- strnull(buf),
- pd_prefix_len);
- continue;
- }
+ r = route_new(&route);
+ if (r < 0)
+ return r;
- route_update(route, NULL, 0, NULL, NULL, 0, 0, RTN_UNREACHABLE);
+ route->family = AF_INET6;
+ route->dst = pd_prefix;
+ route->dst_prefixlen = pd_prefix_len;
+ route->table = link_get_dhcp_route_table(link);
+ route->type = RTN_UNREACHABLE;
r = route_configure(route, link, dhcp6_route_handler);
if (r < 0) {
@@ -721,20 +717,23 @@ static int dhcp6_route_add_handler(sd_netlink *nl, sd_netlink_message *m, Link *
}
static int dhcp6_prefix_add(Manager *m, struct in6_addr *addr, Link *link) {
+ _cleanup_(route_freep) Route *route = NULL;
_cleanup_free_ struct in6_addr *a = NULL;
_cleanup_free_ char *buf = NULL;
Link *assigned_link;
- Route *route;
int r;
assert_return(m, -EINVAL);
assert_return(addr, -EINVAL);
- r = route_add(link, AF_INET6, (union in_addr_union *) addr, 64,
- NULL, 0, 0, 0, &route);
+ r = route_new(&route);
if (r < 0)
return r;
+ route->family = AF_INET6;
+ route->dst.in6 = *addr;
+ route->dst_prefixlen = 64;
+
r = route_configure(route, link, dhcp6_route_add_handler);
if (r < 0)
return r;
@@ -786,8 +785,8 @@ static int dhcp6_prefix_remove_handler(sd_netlink *nl, sd_netlink_message *m, Li
int dhcp6_prefix_remove(Manager *m, struct in6_addr *addr) {
_cleanup_free_ struct in6_addr *a = NULL;
_cleanup_(link_unrefp) Link *l = NULL;
+ _cleanup_(route_freep) Route *route = NULL;
_cleanup_free_ char *buf = NULL;
- Route *route;
int r;
assert_return(m, -EINVAL);
@@ -798,10 +797,15 @@ int dhcp6_prefix_remove(Manager *m, struct in6_addr *addr) {
return -EINVAL;
(void) sd_radv_remove_prefix(l->radv, addr, 64);
- r = route_get(l, AF_INET6, (union in_addr_union *) addr, 64, NULL, 0, 0, 0, &route);
+
+ r = route_new(&route);
if (r < 0)
return r;
+ route->family = AF_INET6;
+ route->dst.in6 = *addr;
+ route->dst_prefixlen = 64;
+
r = route_remove(route, l, dhcp6_prefix_remove_handler);
if (r < 0)
return r;