On Mon, Aug 14, 2017 at 05:53:10PM +0000, Florian Obser wrote:
> After we stopped processing router advertisements in the kernel
> sppp_update_ip6_addr() became the last user of n6_are_prefix_equal().
> Since it compares /128 prefixes it doesn't need all the bells and
> whistles and can be converted to a memcmp. Remove the new unused
> n6_are_prefix_equal().
> 
> OK?

OK bluhm@

> 
> diff --git net/if_spppsubr.c net/if_spppsubr.c
> index 4b541535bda..89e3f1b5713 100644
> --- net/if_spppsubr.c
> +++ net/if_spppsubr.c
> @@ -4355,7 +4355,6 @@ sppp_update_ip6_addr(void *arg)
>       struct sppp *sp = arg;
>       struct ifnet *ifp = &sp->pp_if;
>       struct in6_aliasreq *ifra = &sp->ipv6cp.req_ifid;
> -     struct in6_addr mask = in6mask128;
>       struct in6_ifaddr *ia6;
>       int error;
>  
> @@ -4386,7 +4385,8 @@ sppp_update_ip6_addr(void *arg)
>        */
>  
>       /* Destination address can only be set for /128. */
> -     if (!in6_are_prefix_equal(&ia6->ia_prefixmask.sin6_addr, &mask, 128)) {
> +     if (memcmp(&ia6->ia_prefixmask.sin6_addr, &in6mask128,
> +         sizeof(in6mask128)) != 0) {
>               ifra->ifra_dstaddr.sin6_len = 0;
>               ifra->ifra_dstaddr.sin6_family = AF_UNSPEC;
>       }
> diff --git netinet6/in6.c netinet6/in6.c
> index b83e6df6c66..f9596be629b 100644
> --- netinet6/in6.c
> +++ netinet6/in6.c
> @@ -1519,32 +1519,6 @@ in6_matchlen(struct in6_addr *src, struct in6_addr 
> *dst)
>       return match;
>  }
>  
> -int
> -in6_are_prefix_equal(struct in6_addr *p1, struct in6_addr *p2, int len)
> -{
> -     int bytelen, bitlen;
> -
> -     /* sanity check */
> -     if (0 > len || len > 128) {
> -             log(LOG_ERR, "in6_are_prefix_equal: invalid prefix 
> length(%d)\n",
> -                 len);
> -             return (0);
> -     }
> -
> -     bytelen = len / 8;
> -     bitlen = len % 8;
> -
> -     if (bcmp(&p1->s6_addr, &p2->s6_addr, bytelen))
> -             return (0);
> -     /* len == 128 is ok because bitlen == 0 then */
> -     if (bitlen != 0 &&
> -         p1->s6_addr[bytelen] >> (8 - bitlen) !=
> -         p2->s6_addr[bytelen] >> (8 - bitlen))
> -             return (0);
> -
> -     return (1);
> -}
> -
>  void
>  in6_prefixlen2mask(struct in6_addr *maskp, int len)
>  {
> diff --git netinet6/in6_var.h netinet6/in6_var.h
> index a023d12a1bf..e5a72e6f903 100644
> --- netinet6/in6_var.h
> +++ netinet6/in6_var.h
> @@ -395,7 +395,6 @@ struct in6_ifaddr *in6ifa_ifpforlinklocal(struct ifnet *, 
> int);
>  struct in6_ifaddr *in6ifa_ifpwithaddr(struct ifnet *, struct in6_addr *);
>  int  in6_addr2scopeid(unsigned int, struct in6_addr *);
>  int  in6_matchlen(struct in6_addr *, struct in6_addr *);
> -int  in6_are_prefix_equal(struct in6_addr *, struct in6_addr *, int);
>  void in6_prefixlen2mask(struct in6_addr *, int);
>  void in6_purgeprefix(struct ifnet *);
>  #endif /* _KERNEL */
> 
> -- 
> I'm not entirely sure you are real.

Reply via email to