mirror of
https://github.com/systemd/systemd.git
synced 2024-11-07 18:27:04 +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:
parent
d601b56687
commit
34c169c462
@ -621,6 +621,32 @@ _public_ int sd_radv_add_prefix(sd_radv *ra, sd_radv_prefix *p, bool dynamic) {
|
|||||||
return 0;
|
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,
|
_public_ int sd_radv_set_rdnss(sd_radv *ra, uint32_t lifetime,
|
||||||
const struct in6_addr *dns, size_t n_dns) {
|
const struct in6_addr *dns, size_t n_dns) {
|
||||||
_cleanup_free_ struct sd_radv_opt_dns *opt_rdnss = NULL;
|
_cleanup_free_ struct sd_radv_opt_dns *opt_rdnss = NULL;
|
||||||
|
@ -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_other_information(sd_radv *ra, int other);
|
||||||
int sd_radv_set_preference(sd_radv *ra, unsigned preference);
|
int sd_radv_set_preference(sd_radv *ra, unsigned preference);
|
||||||
int sd_radv_add_prefix(sd_radv *ra, sd_radv_prefix *p, bool dynamic);
|
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,
|
int sd_radv_set_rdnss(sd_radv *ra, uint32_t lifetime,
|
||||||
const struct in6_addr *dns, size_t n_dns);
|
const struct in6_addr *dns, size_t n_dns);
|
||||||
int sd_radv_set_dnssl(sd_radv *ra, uint32_t lifetime, char **search_list);
|
int sd_radv_set_dnssl(sd_radv *ra, uint32_t lifetime, char **search_list);
|
||||||
|
Loading…
Reference in New Issue
Block a user