summaryrefslogtreecommitdiffstats
path: root/sys/netinet/in.c
diff options
context:
space:
mode:
authorclaudio <claudio@openbsd.org>2005-03-07 10:40:42 +0000
committerclaudio <claudio@openbsd.org>2005-03-07 10:40:42 +0000
commit949e9697e182e7320878fbd206ca45c95f6d340e (patch)
tree29aff44b74755ed622cd05b8d8b5c812e37b64af /sys/netinet/in.c
parentTrack interface state (up/down) and media status. Simplify the code a bit (diff)
downloadwireguard-openbsd-949e9697e182e7320878fbd206ca45c95f6d340e.tar.xz
wireguard-openbsd-949e9697e182e7320878fbd206ca45c95f6d340e.zip
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/netinet/in.c')
-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