summaryrefslogtreecommitdiff
path: root/sys/netinet6/nd6_nbr.c
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2008-10-01 21:17:07 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2008-10-01 21:17:07 +0000
commit681fc59ab964ddcd2f94289c067b44b927a31576 (patch)
tree19e25328f647cafad8e8353672b667313c9826c3 /sys/netinet6/nd6_nbr.c
parent0339078b2931d1fd37be17f300448c8b32ec06e7 (diff)
If a neighbor solictation isn't from the unspecified address, make sure
that the source address matches one of the interfaces address prefixes. From NetBSD, tested by todd@ and naddy@
Diffstat (limited to 'sys/netinet6/nd6_nbr.c')
-rw-r--r--sys/netinet6/nd6_nbr.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/sys/netinet6/nd6_nbr.c b/sys/netinet6/nd6_nbr.c
index d89e818f254..5b604f3825e 100644
--- a/sys/netinet6/nd6_nbr.c
+++ b/sys/netinet6/nd6_nbr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: nd6_nbr.c,v 1.52 2008/09/17 05:43:15 chl Exp $ */
+/* $OpenBSD: nd6_nbr.c,v 1.53 2008/10/01 21:17:06 claudio Exp $ */
/* $KAME: nd6_nbr.c,v 1.61 2001/02/10 16:06:14 jinmei Exp $ */
/*
@@ -132,8 +132,18 @@ nd6_ns_input(struct mbuf *m, int off, int icmp6len)
"(wrong ip6 dst)\n"));
goto bad;
}
+ } else {
+ /*
+ * Make sure the source address is from a neighbor's address.
+ */
+ if (in6ifa_ifplocaladdr(ifp, &saddr6) == NULL) {
+ nd6log((LOG_INFO, "nd6_ns_input: "
+ "NS packet from non-neighbor\n"));
+ goto bad;
+ }
}
+
if (IN6_IS_ADDR_MULTICAST(&taddr6)) {
nd6log((LOG_INFO, "nd6_ns_input: bad NS target (multicast)\n"));
goto bad;
@@ -540,9 +550,7 @@ nd6_na_input(struct mbuf *m, int off, int icmp6len)
struct ifnet *ifp = m->m_pkthdr.rcvif;
struct ip6_hdr *ip6 = mtod(m, struct ip6_hdr *);
struct nd_neighbor_advert *nd_na;
-#if 0
struct in6_addr saddr6 = ip6->ip6_src;
-#endif
struct in6_addr daddr6 = ip6->ip6_dst;
struct in6_addr taddr6;
int flags;
@@ -629,6 +637,14 @@ nd6_na_input(struct mbuf *m, int off, int icmp6len)
ip6_sprintf(&taddr6));
goto freeit;
}
+ /*
+ * Make sure the source address is from a neighbor's address.
+ */
+ if (in6ifa_ifplocaladdr(ifp, &saddr6) == NULL) {
+ nd6log((LOG_INFO, "nd6_na_input: "
+ "ND packet from non-neighbor\n"));
+ goto bad;
+ }
if (lladdr && ((ifp->if_addrlen + 2 + 7) & ~7) != lladdrlen) {
nd6log((LOG_INFO, "nd6_na_input: lladdrlen mismatch for %s "