1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-07 09:56:51 +03:00

radv: Add function to remove prefixes

As DHCPv6 leases may expire at some point, the delegated prefixes
have to be removed. Add a prefix removal function to the Router
Advertisement handling code.
This commit is contained in:
Patrik Flykt 2018-01-04 15:11:56 +02:00
parent d601b56687
commit 34c169c462
2 changed files with 28 additions and 0 deletions

View File

@ -621,6 +621,32 @@ _public_ int sd_radv_add_prefix(sd_radv *ra, sd_radv_prefix *p, bool dynamic) {
return 0;
}
_public_ sd_radv_prefix *sd_radv_remove_prefix(sd_radv *ra,
struct in6_addr *prefix,
uint8_t prefixlen) {
sd_radv_prefix *cur, *next;
assert_return(ra, NULL);
assert_return(prefix, NULL);
LIST_FOREACH_SAFE(prefix, cur, next, ra->prefixes) {
if (prefixlen != cur->opt.prefixlen)
continue;
if (!in_addr_equal(AF_INET6,
(union in_addr_union *)prefix,
(union in_addr_union *)&cur->opt.in6_addr))
continue;
LIST_REMOVE(prefix, ra->prefixes, cur);
ra->n_prefixes--;
break;
}
return cur;
}
_public_ int sd_radv_set_rdnss(sd_radv *ra, uint32_t lifetime,
const struct in6_addr *dns, size_t n_dns) {
_cleanup_free_ struct sd_radv_opt_dns *opt_rdnss = NULL;

View File

@ -64,6 +64,8 @@ int sd_radv_set_managed_information(sd_radv *ra, int managed);
int sd_radv_set_other_information(sd_radv *ra, int other);
int sd_radv_set_preference(sd_radv *ra, unsigned preference);
int sd_radv_add_prefix(sd_radv *ra, sd_radv_prefix *p, bool dynamic);
sd_radv_prefix *sd_radv_remove_prefix(sd_radv *ra, struct in6_addr *prefix,
uint8_t prefixlen);
int sd_radv_set_rdnss(sd_radv *ra, uint32_t lifetime,
const struct in6_addr *dns, size_t n_dns);
int sd_radv_set_dnssl(sd_radv *ra, uint32_t lifetime, char **search_list);