On Mon, Jan 18, 2021 at 06:41:26PM +0100, Florian Obser wrote:
> 
>     
> This is not an api that seems to have caught on (especially the
> AF_INET6 variant), maybe we can get rid of it entirely.
> 
> (I also suspect that the AF_INET6 version is broken on FreeBSD and
> NetBSD as well as mac osx.)
> 
> OK?

ok tb

> 
> diff --git parse.y parse.y
> index 8f32f11250d..36e5af8be76 100644
> --- parse.y
> +++ parse.y
> @@ -260,17 +260,28 @@ ra_ifaceoptsl   : NO AUTO PREFIX {
>               | PREFIX STRING {
>                       struct in6_addr  addr;
>                       int              prefixlen;
> +                     char            *p;
> +                     const char      *errstr;
>  
>                       memset(&addr, 0, sizeof(addr));
> -                     prefixlen = inet_net_pton(AF_INET6, $2, &addr,
> -                         sizeof(addr));
> -                     if (prefixlen == -1) {
> -                             yyerror("error parsing prefix");
> +                     p = strchr($2, '/');
> +                     if (p != NULL) {
> +                             *p++ = '\0';
> +                             prefixlen = strtonum(p, 0, 128, &errstr);
> +                             if (errstr != NULL) {
> +                                     yyerror("error parsing prefix "
> +                                         "\"%s/%s\"", $2, p);
> +                                     free($2);
> +                                     YYERROR;
> +                             }
> +                     } else
> +                             prefixlen = 64;
> +                     if(inet_pton(AF_INET6, $2, &addr) == 0) {
> +                             yyerror("error parsing prefix \"%s/%d\"", $2,
> +                                 prefixlen);
>                               free($2);
>                               YYERROR;
>                       }
> -                     if (prefixlen == 128 && strchr($2, '/') == NULL)
> -                             prefixlen = 64;
>                       mask_prefix(&addr, prefixlen);
>                       ra_prefix_conf = conf_get_ra_prefix(&addr, prefixlen);
>               } ra_prefix_block {
> diff --git printconf.c printconf.c
> index d42890da518..feabd83de94 100644
> --- printconf.c
> +++ printconf.c
> @@ -102,7 +102,7 @@ print_config(struct rad_conf *conf)
>  {
>       struct ra_iface_conf    *iface;
>       struct ra_prefix_conf   *prefix;
> -     char                     buf[INET6_ADDRSTRLEN], *bufp;
> +     char                     buf[INET6_ADDRSTRLEN];
>  
>       print_ra_options("", &conf->ra_options);
>       printf("\n");
> @@ -120,9 +120,9 @@ print_config(struct rad_conf *conf)
>                       printf("\tno auto prefix\n");
>  
>               SIMPLEQ_FOREACH(prefix, &iface->ra_prefix_list, entry) {
> -                     bufp = inet_net_ntop(AF_INET6, &prefix->prefix,
> -                         prefix->prefixlen, buf, sizeof(buf));
> -                     printf("\tprefix %s {\n", bufp);
> +                     printf("\tprefix %s/%d {\n", inet_ntop(AF_INET6,
> +                         &prefix->prefix, buf, sizeof(buf)),
> +                         prefix->prefixlen);
>                       print_prefix_options("\t\t", prefix);
>                       printf("\t}\n");
>               }
> 
> 
> -- 
> I'm not entirely sure you are real.
> 

Reply via email to