On Thu, Jun 16, 2022 at 05:48:48PM +0200, Claudio Jeker wrote:
> Copy the version of the __KAME__ hack from route/show.c and more
> importantly copy the address after modifying the sa.

ok

> 
> This only affects IPv6 link local addresses which are not really used by
> bgpd. Still happy if a few more people can give this a spin.
> -- 
> :wq Claudio
> 
> ? obj
> Index: util.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/bgpd/util.c,v
> retrieving revision 1.64
> diff -u -p -r1.64 util.c
> --- util.c    16 Jun 2022 15:33:05 -0000      1.64
> +++ util.c    16 Jun 2022 15:46:09 -0000
> @@ -897,24 +897,24 @@ sa2addr(struct sockaddr *sa, struct bgpd
>               break;
>       case AF_INET6:
>               addr->aid = AID_INET6;
> -             memcpy(&addr->v6, &sa_in6->sin6_addr, sizeof(addr->v6));
>  #ifdef __KAME__
>               /*
>                * XXX thanks, KAME, for this ugliness...
>                * adopted from route/show.c
>                */
> -             if (IN6_IS_ADDR_LINKLOCAL(&sa_in6->sin6_addr) ||
> -                 IN6_IS_ADDR_MC_LINKLOCAL(&sa_in6->sin6_addr)) {
> +             if ((IN6_IS_ADDR_LINKLOCAL(&sa_in6->sin6_addr) ||
> +                 IN6_IS_ADDR_MC_LINKLOCAL(&sa_in6->sin6_addr) ||
> +                 IN6_IS_ADDR_MC_INTFACELOCAL(&sa_in6->sin6_addr)) &&
> +                 sa_in6->sin6_scope_id == 0) {
>                       uint16_t tmp16;
>                       memcpy(&tmp16, &sa_in6->sin6_addr.s6_addr[2],
>                           sizeof(tmp16));
> -                     if (tmp16 != 0) {
> -                             sa_in6->sin6_scope_id = ntohs(tmp16);
> -                             sa_in6->sin6_addr.s6_addr[2] = 0;
> -                             sa_in6->sin6_addr.s6_addr[3] = 0;
> -                     }
> +                     sa_in6->sin6_scope_id = ntohs(tmp16);
> +                     sa_in6->sin6_addr.s6_addr[2] = 0;
> +                     sa_in6->sin6_addr.s6_addr[3] = 0;
>               }
>  #endif
> +             memcpy(&addr->v6, &sa_in6->sin6_addr, sizeof(addr->v6));
>               addr->scope_id = sa_in6->sin6_scope_id; /* I hate v6 */
>               if (port)
>                       *port = ntohs(sa_in6->sin6_port);
> 

Reply via email to