Compare commits

..

No commits in common. "a1b24ee147454390e9d557a94a848f59ca662c82" and "df80c98cdece42c6b49f4c9adc45017b0b0582c6" have entirely different histories.

5 changed files with 17 additions and 25 deletions

View File

@ -2254,8 +2254,9 @@ IPv6Token=prefixstable:2002:da8:1::</programlisting></para>
<varlistentry>
<term><varname>RouterLifetimeSec=</varname></term>
<listitem><para>Takes a timespan. Configures the IPv6 router lifetime in seconds. When set to
0, the host is not acting as a router. Defaults to 30 minutes.</para>
<listitem><para>Takes a timespan. Configures the IPv6 router lifetime in seconds. If set,
this host also announces itself in Router Advertisements as an IPv6
router for the network link. When unset, the host is not acting as a router.</para>
</listitem>
</varlistentry>

View File

@ -466,14 +466,14 @@ _public_ int sd_radv_set_hop_limit(sd_radv *ra, uint8_t hop_limit) {
return 0;
}
_public_ int sd_radv_set_router_lifetime(sd_radv *ra, uint16_t router_lifetime) {
_public_ int sd_radv_set_router_lifetime(sd_radv *ra, uint32_t router_lifetime) {
assert_return(ra, -EINVAL);
if (ra->state != SD_RADV_STATE_IDLE)
return -EBUSY;
/* RFC 4191, Section 2.2, "...If the Router Lifetime is zero, the preference value MUST be set
* to (00) by the sender..." */
/* RFC 4191, Section 2.2, "...If the Router Lifetime is zero, the
preference value MUST be set to (00) by the sender..." */
if (router_lifetime == 0 &&
(ra->flags & (0x3 << 3)) != (SD_NDISC_PREFERENCE_MEDIUM << 3))
return -ETIME;
@ -506,20 +506,17 @@ _public_ int sd_radv_set_other_information(sd_radv *ra, int other) {
}
_public_ int sd_radv_set_preference(sd_radv *ra, unsigned preference) {
int r = 0;
assert_return(ra, -EINVAL);
assert_return(IN_SET(preference,
SD_NDISC_PREFERENCE_LOW,
SD_NDISC_PREFERENCE_MEDIUM,
SD_NDISC_PREFERENCE_HIGH), -EINVAL);
/* RFC 4191, Section 2.2, "...If the Router Lifetime is zero, the preference value MUST be set
* to (00) by the sender..." */
if (ra->lifetime == 0 && preference != SD_NDISC_PREFERENCE_MEDIUM)
return -EINVAL;
ra->flags = (ra->flags & ~(0x3 << 3)) | (preference << 3);
return 0;
return r;
}
_public_ int sd_radv_add_prefix(sd_radv *ra, sd_radv_prefix *p, int dynamic) {

View File

@ -379,7 +379,6 @@ int network_load_one(Manager *manager, OrderedHashmap **networks, const char *fi
.dhcp_server_emit_router = true,
.dhcp_server_emit_timezone = true,
.router_lifetime_usec = 30 * USEC_PER_MINUTE,
.router_emit_dns = true,
.router_emit_domains = true,

View File

@ -641,7 +641,6 @@ static bool link_radv_enabled(Link *link) {
}
int radv_configure(Link *link) {
uint16_t router_lifetime;
RoutePrefix *q;
Prefix *p;
int r;
@ -676,20 +675,16 @@ int radv_configure(Link *link) {
if (r < 0)
return r;
/* a value of UINT16_MAX represents infinity, 0x0 means this host is not a router */
if (link->network->router_lifetime_usec == USEC_INFINITY)
router_lifetime = UINT16_MAX;
else if (link->network->router_lifetime_usec > (UINT16_MAX - 1) * USEC_PER_SEC)
router_lifetime = UINT16_MAX - 1;
else
router_lifetime = DIV_ROUND_UP(link->network->router_lifetime_usec, USEC_PER_SEC);
r = sd_radv_set_router_lifetime(link->radv, router_lifetime);
/* a value of 0xffffffff represents infinity, 0x0 means this host is
not a router */
r = sd_radv_set_router_lifetime(link->radv,
DIV_ROUND_UP(link->network->router_lifetime_usec, USEC_PER_SEC));
if (r < 0)
return r;
if (router_lifetime > 0) {
r = sd_radv_set_preference(link->radv, link->network->router_preference);
if (link->network->router_lifetime_usec > 0) {
r = sd_radv_set_preference(link->radv,
link->network->router_preference);
if (r < 0)
return r;
}

View File

@ -56,7 +56,7 @@ int sd_radv_set_ifindex(sd_radv *ra, int interface_index);
int sd_radv_set_mac(sd_radv *ra, const struct ether_addr *mac_addr);
int sd_radv_set_mtu(sd_radv *ra, uint32_t mtu);
int sd_radv_set_hop_limit(sd_radv *ra, uint8_t hop_limit);
int sd_radv_set_router_lifetime(sd_radv *ra, uint16_t router_lifetime);
int sd_radv_set_router_lifetime(sd_radv *ra, uint32_t router_lifetime);
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);