summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorAlexander Bluhm <bluhm@cvs.openbsd.org>2012-10-22 07:28:50 +0000
committerAlexander Bluhm <bluhm@cvs.openbsd.org>2012-10-22 07:28:50 +0000
commite28e0d9c2f03963978e58beeb6ddbedc05628972 (patch)
treed63d0ce40321bda8eb7d080b5ef9a0fc9c9e3570 /usr.sbin
parent46eeb0aada8237ac4896dfa8e3b8898baa8c787a (diff)
Unfortunately "ospf6ctl show fib" printed embedded scopes as the
destination addresses still contain them. To fix that, call recoverscope() in log_in6addr(). Also log_in6addr_scope() should not fiddle with the scope itself, put that into a generic function addscope(). OK claudio@
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/ospf6d/log.c14
-rw-r--r--usr.sbin/ospf6d/ospf6d.h3
-rw-r--r--usr.sbin/ospf6d/util.c15
3 files changed, 24 insertions, 8 deletions
diff --git a/usr.sbin/ospf6d/log.c b/usr.sbin/ospf6d/log.c
index db0ee9da7ac..34d1efca6ca 100644
--- a/usr.sbin/ospf6d/log.c
+++ b/usr.sbin/ospf6d/log.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: log.c,v 1.9 2012/09/20 07:22:48 bluhm Exp $ */
+/* $OpenBSD: log.c,v 1.10 2012/10/22 07:28:49 bluhm Exp $ */
/*
* Copyright (c) 2006 Claudio Jeker <claudio@openbsd.org>
@@ -186,6 +186,12 @@ log_in6addr(const struct in6_addr *addr)
sa_in6.sin6_family = AF_INET6;
memcpy(&sa_in6.sin6_addr, addr, sizeof(sa_in6.sin6_addr));
+ /*
+ * Destination addresses contain embedded scopes.
+ * They must be recovered for ospf6ctl show fib.
+ */
+ recoverscope(&sa_in6);
+
return (log_sockaddr(&sa_in6));
}
@@ -199,11 +205,7 @@ log_in6addr_scope(const struct in6_addr *addr, unsigned int ifindex)
sa_in6.sin6_family = AF_INET6;
memcpy(&sa_in6.sin6_addr, addr, sizeof(sa_in6.sin6_addr));
- /* XXX thanks, IPv6 & KAME, for this ugliness... */
- if (IN6_IS_ADDR_LINKLOCAL(&sa_in6.sin6_addr) ||
- IN6_IS_ADDR_MC_LINKLOCAL(&sa_in6.sin6_addr)) {
- sa_in6.sin6_scope_id = ifindex;
- }
+ addscope(&sa_in6, ifindex);
return (log_sockaddr(&sa_in6));
}
diff --git a/usr.sbin/ospf6d/ospf6d.h b/usr.sbin/ospf6d/ospf6d.h
index 30cbfc7e5aa..275c54e586a 100644
--- a/usr.sbin/ospf6d/ospf6d.h
+++ b/usr.sbin/ospf6d/ospf6d.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ospf6d.h,v 1.24 2012/09/19 19:20:34 bluhm Exp $ */
+/* $OpenBSD: ospf6d.h,v 1.25 2012/10/22 07:28:49 bluhm Exp $ */
/*
* Copyright (c) 2004, 2007 Esben Norby <norby@openbsd.org>
@@ -537,6 +537,7 @@ void kr_reload(void);
void embedscope(struct sockaddr_in6 *);
void recoverscope(struct sockaddr_in6 *);
+void addscope(struct sockaddr_in6 *, u_int32_t);
void clearscope(struct in6_addr *);
u_int8_t mask2prefixlen(struct sockaddr_in6 *);
struct in6_addr *prefixlen2mask(u_int8_t);
diff --git a/usr.sbin/ospf6d/util.c b/usr.sbin/ospf6d/util.c
index cfc0a5f980e..ba2878dc3a4 100644
--- a/usr.sbin/ospf6d/util.c
+++ b/usr.sbin/ospf6d/util.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: util.c,v 1.1 2012/10/21 21:30:44 bluhm Exp $ */
+/* $OpenBSD: util.c,v 1.2 2012/10/22 07:28:49 bluhm Exp $ */
/*
* Copyright (c) 2012 Alexander Bluhm <bluhm@openbsd.org>
@@ -65,6 +65,19 @@ recoverscope(struct sockaddr_in6 *sin6)
}
void
+addscope(struct sockaddr_in6 *sin6, u_int32_t id)
+{
+ if (sin6->sin6_scope_id != 0) {
+ log_warnx("addscope: address %s already has scope id %u",
+ log_sockaddr(sin6), sin6->sin6_scope_id);
+ }
+
+ if (IN6_IS_SCOPE_EMBED(&sin6->sin6_addr)) {
+ sin6->sin6_scope_id = id;
+ }
+}
+
+void
clearscope(struct in6_addr *in6)
{
if (IN6_IS_SCOPE_EMBED(in6)) {