summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2022-06-17 09:12:07 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2022-06-17 09:12:07 +0000
commitaf70baed0e23b069a6f8855780cf2eec822188cb (patch)
treecbbd1649b3694851135deb51fc735d0259f72529
parentb8f1ccc43128f1b0173c6f742c6f8180e4320cb9 (diff)
Adapt the KAME hack in sa2addr() to be the same as in route/show.c
Also fix the function by moving the memcpy() after the embedded scope has been removed. OK tb@
-rw-r--r--usr.sbin/bgpd/util.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/usr.sbin/bgpd/util.c b/usr.sbin/bgpd/util.c
index 68ae4dcd657..414f70ed766 100644
--- a/usr.sbin/bgpd/util.c
+++ b/usr.sbin/bgpd/util.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: util.c,v 1.64 2022/06/16 15:33:05 claudio Exp $ */
+/* $OpenBSD: util.c,v 1.65 2022/06/17 09:12:06 claudio Exp $ */
/*
* Copyright (c) 2006 Claudio Jeker <claudio@openbsd.org>
@@ -897,24 +897,24 @@ sa2addr(struct sockaddr *sa, struct bgpd_addr *addr, uint16_t *port)
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);