On Fri, Mar 27, 2020 at 12:24:27PM -0600, Theo de Raadt wrote:
> +#ifndef MIN
> +#define        MIN(_a,_b) ((_a) < (_b) ? (_a) : (_b))
> 
> Please use MINIMUM() for the name, as elsewhere.  You also don't need the _.
> 

diff --git engine.c engine.c
index 8f2c4297225..f461708af77 100644
--- engine.c
+++ engine.c
@@ -91,6 +91,11 @@
 #define ND6_PRIV_VALID_LIFETIME                172800  /* 2 days */
 #define ND6_PRIV_PREFERRED_LIFETIME    86400   /* 1 day */
 
+/* derive valid from prefered lifetime (draft-gont-6man-slaac-renum) */
+#define        VLTIME_FROM_PLTIME_FACTOR       48
+
+#define        MINIMUM(a, b) ((a) < (b) ? (a) : (b))
+
 enum if_state {
        IF_DOWN,
        IF_DELAY,
@@ -1271,8 +1276,11 @@ parse_ra(struct slaacd_iface *iface, struct imsg_ra *ra)
                            ND_OPT_PI_FLAG_ONLINK;
                        prefix->autonomous = prf->nd_opt_pi_flags_reserved &
                            ND_OPT_PI_FLAG_AUTO;
-                       prefix->vltime = ntohl(prf->nd_opt_pi_valid_time);
-                       prefix->pltime = ntohl(prf->nd_opt_pi_preferred_time);
+                       prefix->pltime = MINIMUM(radv->router_lifetime,
+                           ntohl(prf->nd_opt_pi_preferred_time));
+                       prefix->vltime =
+                           MINIMUM(ntohl(prf->nd_opt_pi_valid_time),
+                           VLTIME_FROM_PLTIME_FACTOR * prefix->pltime);
                        if (radv->min_lifetime > prefix->pltime)
                                radv->min_lifetime = prefix->pltime;
 


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

Reply via email to