summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Sperling <stsp@cvs.openbsd.org>2009-01-04 18:20:23 +0000
committerStefan Sperling <stsp@cvs.openbsd.org>2009-01-04 18:20:23 +0000
commitddcdcbb53684313862452fb8868fb84d9bda7b12 (patch)
treecf037e86e19d845a39591baf7db529b54b9083a1
parenta61ba976b5794aed2e736e8223632bf41004b18a (diff)
if_newaddr() was hard-coding all interface prefixes to /64.
Make it smarter so that ospf6d knows the actual prefix length configured on an interface. ok claudio@
-rw-r--r--usr.sbin/ospf6d/kroute.c32
1 files changed, 23 insertions, 9 deletions
diff --git a/usr.sbin/ospf6d/kroute.c b/usr.sbin/ospf6d/kroute.c
index b32b012bc5e..e5a78cc69b6 100644
--- a/usr.sbin/ospf6d/kroute.c
+++ b/usr.sbin/ospf6d/kroute.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kroute.c,v 1.8 2008/05/09 12:55:48 claudio Exp $ */
+/* $OpenBSD: kroute.c,v 1.9 2009/01/04 18:20:22 stsp Exp $ */
/*
* Copyright (c) 2004 Esben Norby <norby@openbsd.org>
@@ -854,18 +854,32 @@ if_newaddr(u_short ifindex, struct sockaddr_in6 *ifa, struct sockaddr_in6 *mask,
ia->addr = ifa->sin6_addr;
if (mask)
- ia->prefixlen = 64; // XXX mask2prefixlen(&mask->sin6_addr);
+ ia->prefixlen = mask2prefixlen(mask);
else
ia->prefixlen = 0;
-#if 0 /* XXX fix me */
- if (brd)
- ka->dstbrd = brd->sin6_addr;
+ if (brd && brd->sin6_family == AF_INET6)
+ ia->dstbrd = brd->sin6_addr;
else
- bzero(&ka->dstbrd, sizeof(ka->dstbrd));
-#endif
+ bzero(&ia->dstbrd, sizeof(ia->dstbrd));
- log_debug("if_newaddr: ifindex %u, addr %s", ifindex,
- log_in6addr(&ia->addr));
+ switch (iface->type) {
+ case IF_TYPE_BROADCAST:
+ case IF_TYPE_NBMA:
+ log_debug("if_newaddr: ifindex %u, addr %s/%d",
+ ifindex, log_in6addr(&ia->addr), ia->prefixlen);
+ break;
+ case IF_TYPE_VIRTUALLINK: /* FIXME */
+ break;
+ case IF_TYPE_POINTOPOINT:
+ case IF_TYPE_POINTOMULTIPOINT:
+ log_debug("if_newaddr: ifindex %u, addr %s/%d, "
+ "dest %s", ifindex, log_in6addr(&ia->addr),
+ ia->prefixlen, log_in6addr(&ia->dstbrd));
+ break;
+ default:
+ fatalx("if_newaddr: unknown interface type");
+ }
+
TAILQ_INSERT_TAIL(&iface->ifa_list, ia, entry);
}