Re: PATCH: rad(8) Better PIO default lifetimes (was: Re: Improve handling of IPv6 SLAAC renumbering scenarios)

2020-04-02 Thread Florian Obser
On Fri, Mar 27, 2020 at 11:10:25PM -0300, Fernando Gont wrote:
> Florian/folks,
> 
> This is an improved version:
> 
> Essentially, if the lifetime of a prefix is not specified (i.e., the admin
> relies on the default values), the Preferred Lifetime is set to the Router
> Lifetime, and the Valid Lifetime is set to Router Lifetime * 48 (one day)
> 
> This improve the state of affairs for renumbering events on the router side.
> 

After talking to Fernando I came up with this much simpler patch:

diff --git parse.y parse.y
index 8e0a899470f..88b31364816 100644
--- parse.y
+++ parse.y
@@ -964,8 +964,8 @@ conf_get_ra_prefix(struct in6_addr *addr, int prefixlen)
if (prefix == NULL)
errx(1, "%s: calloc", __func__);
prefix->prefixlen = prefixlen;
-   prefix->vltime = ADV_VALID_LIFETIME;
-   prefix->pltime = ADV_PREFERRED_LIFETIME;
+   prefix->pltime = ra_options->router_lifetime;
+   prefix->vltime = VLTIME_PLTIME_FACTOR * prefix->pltime;
prefix->lflag = 1;
prefix->aflag = 1;
 
diff --git rad.h rad.h
index 09cc9cf204e..3d58c3558fc 100644
--- rad.h
+++ rad.h
@@ -29,8 +29,7 @@
 #defineMAX_RTR_ADV_INTERVAL600
 #defineMIN_RTR_ADV_INTERVAL200
 #defineADV_DEFAULT_LIFETIME3 * MAX_RTR_ADV_INTERVAL
-#defineADV_PREFERRED_LIFETIME  604800  /* 7 days */
-#define ADV_VALID_LIFETIME 2592000 /* 30 days */
+#defineVLTIME_PLTIME_FACTOR48
 #defineMAX_SEARCH  1025/* MAXDNAME in arpa/nameser.h */
 #defineDEFAULT_RDNS_LIFETIME   600 * 1.5
 

Other aspects of draft-gont-6man-slaac-renum are still being discussed
in the 6man WG, these numbers don't seem to be too contentious though.

On the other hand I don't think we are in a big hurry to get this in
and we can wait a bit on how this plays out. Administrators can
already set these values by themselves in rad.conf

I'm also not opposed to this and I do agree that the current defaults
from RFC 4861 are way to high (7 days prefered lifetime and 30 days
valid lifetime).

Due to hardware issues I'm currently not using rad(8). My ISP provided
cpe sends router advertisements with considerably lower lifetimes then
the rfc defaults.
The vltime is 14.5 hours and 12 seconds(?!) and the pltime 6.5 hours
and 12 seconds.

Thoughts from people who are actually running this?

Oh, and we need to update the manpage.

p.s.: And I see that tab vs. space is still messed up in the defines
even after I tried to fix it :/ Maybe I should just let that part go


-- 
I'm not entirely sure you are real.



PATCH: rad(8) Better PIO default lifetimes (was: Re: Improve handling of IPv6 SLAAC renumbering scenarios)

2020-03-27 Thread Fernando Gont

Florian/folks,

This is an improved version:

Essentially, if the lifetime of a prefix is not specified (i.e., the 
admin relies on the default values), the Preferred Lifetime is set to 
the Router Lifetime, and the Valid Lifetime is set to Router Lifetime * 
48 (one day)


This improve the state of affairs for renumbering events on the router side.


 cut here 
diff --git frontend.c frontend.c
index c932c3dfca3..fd0f16779aa 100644
--- frontend.c
+++ frontend.c
@@ -128,7 +128,8 @@ struct ra_iface_conf	*find_ra_iface_conf(struct 
ra_iface_conf_head *,

 struct ra_prefix_conf  *find_ra_prefix_conf(struct ra_prefix_conf_head*,
struct in6_addr *, int);
 voidadd_new_prefix_to_ra_iface(struct ra_iface *r,
-   struct in6_addr *, int, struct ra_prefix_conf *);
+   struct in6_addr *, int, struct ra_prefix_conf *,
+   struct ra_iface_conf *);
 voidfree_ra_iface(struct ra_iface *);
 int in6_mask2prefixlen(struct in6_addr *);
 voidget_interface_prefixes(struct ra_iface *,
@@ -858,16 +859,16 @@ merge_ra_interfaces(void)
continue;
}

-   ra_iface_conf = find_ra_iface_conf(
-   _conf->ra_iface_list, ra_iface->conf_name);
+   ra_iface_conf = 
find_ra_iface_conf(_conf->ra_iface_list,
+   ra_iface->name);

log_debug("add static prefixes for %s", ra_iface->name);

SIMPLEQ_FOREACH(ra_prefix_conf, _iface_conf->ra_prefix_list,
entry) {
add_new_prefix_to_ra_iface(ra_iface,
-   _prefix_conf->prefix,
-   ra_prefix_conf->prefixlen, ra_prefix_conf);
+   _prefix_conf->prefix, ra_prefix_conf->prefixlen,
+ra_prefix_conf, ra_iface_conf);
}

if (ra_iface_conf->autoprefix)
@@ -926,6 +927,7 @@ get_interface_prefixes(struct ra_iface *ra_iface, 
struct ra_prefix_conf

struct ifaddrs  *ifap, *ifa;
struct sockaddr_in6 *sin6;
int  prefixlen;
+   struct ra_iface_conf*ra_iface_conf;

log_debug("%s: %s", __func__, ra_iface->name);

@@ -959,8 +961,11 @@ get_interface_prefixes(struct ra_iface *ra_iface, 
struct ra_prefix_conf


mask_prefix(>sin6_addr, prefixlen);

+   ra_iface_conf = 
find_ra_iface_conf(_conf->ra_iface_list,
+   ra_iface->name);
+
add_new_prefix_to_ra_iface(ra_iface, >sin6_addr,
-   prefixlen, autoprefix);
+   prefixlen, autoprefix, ra_iface_conf);
}
freeifaddrs(ifap);
 }
@@ -982,7 +987,8 @@ find_ra_prefix_conf(struct ra_prefix_conf_head* 
head, struct in6_addr *prefix,


 void
 add_new_prefix_to_ra_iface(struct ra_iface *ra_iface, struct in6_addr 
*addr,

-int prefixlen, struct ra_prefix_conf *ra_prefix_conf)
+int prefixlen, struct ra_prefix_conf *ra_prefix_conf,
+struct ra_iface_conf *ra_iface_conf)
 {
struct ra_prefix_conf   *new_ra_prefix_conf;

@@ -992,14 +998,28 @@ add_new_prefix_to_ra_iface(struct ra_iface 
*ra_iface, struct in6_addr *addr,

return;
}

+   ra_iface_conf = find_ra_iface_conf(_conf->ra_iface_list,
+   ra_iface->name);
+
log_debug("adding %s/%d prefix", in6_to_str(addr), prefixlen);

if ((new_ra_prefix_conf = calloc(1, sizeof(*ra_prefix_conf))) == NULL)
fatal("%s", __func__);
new_ra_prefix_conf->prefix = *addr;
new_ra_prefix_conf->prefixlen = prefixlen;
-   new_ra_prefix_conf->vltime = ra_prefix_conf->vltime;
-   new_ra_prefix_conf->pltime = ra_prefix_conf->pltime;
+
+   if(ra_prefix_conf->pltime == DEFAULT_PIO_PLTIME &&
+  ra_iface_conf->ra_options.router_lifetime > DEFAULT_PIO_PLTIME) {
+   new_ra_prefix_conf->pltime =
+   ra_iface_conf->ra_options.router_lifetime;
+   new_ra_prefix_conf->vltime = new_ra_prefix_conf->pltime *
+   DFLT_VLTIME_MULT;
+   }
+   else{
+   new_ra_prefix_conf->pltime = ra_prefix_conf->pltime;
+   new_ra_prefix_conf->vltime = ra_prefix_conf->vltime;
+   }
+
new_ra_prefix_conf->aflag = ra_prefix_conf->aflag;
new_ra_prefix_conf->lflag = ra_prefix_conf->lflag;
SIMPLEQ_INSERT_TAIL(_iface->prefixes, new_ra_prefix_conf, entry);
diff --git parse.y parse.y
index bb18c3d9c9c..5c45ced6147 100644
--- parse.y
+++ parse.y
@@ -964,8 +964,8 @@ conf_get_ra_prefix(struct in6_addr *addr, int prefixlen)
if (prefix == NULL)
errx(1, "%s: calloc", __func__);
prefix->prefixlen = prefixlen;
-   prefix->vltime = 2592000;/* 30 days */
-   prefix->pltime = 604800; /* 7