From: Denis Fondras Subject: Re: in6_update_ifa: destination addressses and loopback interfaces To: tech@openbsd.org Date: Tue, 16 Apr 2024 15:41:57 +0200 Le Tue, Apr 16, 2024 at 03:08:35PM +0200, Florian Obser a écrit : > Destination addresses make no sense on loopback interfaces. > > While here use (variable & FLAG) or !(variable & FLAG) consistently in > in6_update_ifa(). > > I suspect this will make upcoming work slightly easier. > > OK? > OK denis@ > diff --git in6.c in6.c > index 1266354e202..6e185efb2ad 100644 > --- in6.c > +++ in6.c > @@ -565,7 +565,7 @@ in6_update_ifa(struct ifnet *ifp, struct in6_aliasreq *ifra, > * The destination address for a p2p link must have a family > * of AF_UNSPEC or AF_INET6. > */ > - if ((ifp->if_flags & IFF_POINTOPOINT) != 0 && > + if ((ifp->if_flags & IFF_POINTOPOINT) && > ifra->ifra_dstaddr.sin6_family != AF_INET6 && > ifra->ifra_dstaddr.sin6_family != AF_UNSPEC) > return (EAFNOSUPPORT); > @@ -603,19 +603,18 @@ in6_update_ifa(struct ifnet *ifp, struct in6_aliasreq *ifra, > * zone identifier. > */ > dst6 = ifra->ifra_dstaddr; > - if ((ifp->if_flags & (IFF_POINTOPOINT|IFF_LOOPBACK)) != 0 && > + if ((ifp->if_flags & IFF_POINTOPOINT) && > (dst6.sin6_family == AF_INET6)) { > error = in6_check_embed_scope(&dst6, ifp->if_index); > if (error) > return error; > } > /* > - * The destination address can be specified only for a p2p or a > - * loopback interface. If specified, the corresponding prefix length > - * must be 128. > + * The destination address can be specified only for a p2p interface. > + * If specified, the corresponding prefix length must be 128. > */ > if (ifra->ifra_dstaddr.sin6_family == AF_INET6) { > - if ((ifp->if_flags & (IFF_POINTOPOINT|IFF_LOOPBACK)) == 0) > + if (!(ifp->if_flags & IFF_POINTOPOINT)) > return (EINVAL); > if (plen != 128) > return (EINVAL); > @@ -652,7 +651,7 @@ in6_update_ifa(struct ifnet *ifp, struct in6_aliasreq *ifra, > ia6->ia_addr.sin6_family = AF_INET6; > ia6->ia_addr.sin6_len = sizeof(ia6->ia_addr); > ia6->ia6_updatetime = getuptime(); > - if ((ifp->if_flags & (IFF_POINTOPOINT | IFF_LOOPBACK)) != 0) { > + if (ifp->if_flags & IFF_POINTOPOINT) { > /* > * XXX: some functions expect that ifa_dstaddr is not > * NULL for p2p interfaces. > @@ -687,7 +686,7 @@ in6_update_ifa(struct ifnet *ifp, struct in6_aliasreq *ifra, > /* > * If a new destination address is specified, scrub the old one and > * install the new destination. Note that the interface must be > - * p2p or loopback (see the check above.) > + * p2p (see the check above.) > */ > if ((ifp->if_flags & IFF_POINTOPOINT) && dst6.sin6_family == AF_INET6 && > !IN6_ARE_ADDR_EQUAL(&dst6.sin6_addr, &ia6->ia_dstaddr.sin6_addr)) { > > -- > In my defence, I have been left unsupervised. >