summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2005-03-07 10:40:43 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2005-03-07 10:40:43 +0000
commitfd9399343260e05d83411f4cc5afd7a8fc405a8c (patch)
tree08fa51908c033bfc1a1a3ea4e2a95ecb23bbb2c8 /sys
parent56b4dcaaffe518f3956a530758aecfc2eb6452e0 (diff)
Correctly compare routes in in_addprefix. If a netmask is supplied it needs
to be compared too -- 10/8 and 10/24 are not equal. This fixes a problem with overlapping networks reported by Simon Slaytor. OK henning@
Diffstat (limited to 'sys')
-rw-r--r--sys/netinet/in.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/sys/netinet/in.c b/sys/netinet/in.c
index c01104200a8..45576d2dc1b 100644
--- a/sys/netinet/in.c
+++ b/sys/netinet/in.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: in.c,v 1.39 2005/01/15 09:09:27 pascoe Exp $ */
+/* $OpenBSD: in.c,v 1.40 2005/03/07 10:40:42 claudio Exp $ */
/* $NetBSD: in.c,v 1.26 1996/02/13 23:41:39 christos Exp $ */
/*
@@ -778,17 +778,19 @@ in_addprefix(target, flags)
prefix.s_addr &= mask.s_addr;
}
- for (ia = in_ifaddr.tqh_first; ia; ia = ia->ia_list.tqe_next) {
- if (rtinitflags(ia))
+ TAILQ_FOREACH(ia, &in_ifaddr, ia_list) {
+ if (rtinitflags(ia)) {
p = ia->ia_dstaddr.sin_addr;
- else {
+ if (prefix.s_addr != p.s_addr)
+ continue;
+ } else {
p = ia->ia_addr.sin_addr;
p.s_addr &= ia->ia_sockmask.sin_addr.s_addr;
+ if (prefix.s_addr != p.s_addr ||
+ mask.s_addr != ia->ia_sockmask.sin_addr.s_addr)
+ continue;
}
- if (prefix.s_addr != p.s_addr)
- continue;
-
/*
* if we got a matching prefix route inserted by other
* interface adderss, we don't need to bother