diff options
author | glebius <glebius@FreeBSD.org> | 2005-10-22 14:50:27 +0000 |
---|---|---|
committer | glebius <glebius@FreeBSD.org> | 2005-10-22 14:50:27 +0000 |
commit | 9ae88c3a40b88c17f04b1b11b1c589eed6e8a037 (patch) | |
tree | 4abbf1d094e43391d05c74b869fe6ec061fc8a40 /sys/netinet/in.c | |
parent | 78dec04340e40aec057547ffe8b6549c5b5617f0 (diff) | |
download | FreeBSD-src-9ae88c3a40b88c17f04b1b11b1c589eed6e8a037.zip FreeBSD-src-9ae88c3a40b88c17f04b1b11b1c589eed6e8a037.tar.gz |
In in_addprefix() compare not only route addresses, but their masks,
too. This fixes problem when connected prefixes overlap.
Obtained from: OpenBSD (rev. 1.40 by claudio);
[ I came to this fix myself, and then found out that
OpenBSD had already fixed it the same way.]
Diffstat (limited to 'sys/netinet/in.c')
-rw-r--r-- | sys/netinet/in.c | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/sys/netinet/in.c b/sys/netinet/in.c index 84052a3..4d902ea 100644 --- a/sys/netinet/in.c +++ b/sys/netinet/in.c @@ -794,7 +794,7 @@ in_addprefix(target, flags) int flags; { struct in_ifaddr *ia; - struct in_addr prefix, mask, p; + struct in_addr prefix, mask, p, m; int error; if ((flags & RTF_HOST) != 0) @@ -806,15 +806,20 @@ in_addprefix(target, flags) } TAILQ_FOREACH(ia, &in_ifaddrhead, ia_link) { - if (rtinitflags(ia)) - p = ia->ia_dstaddr.sin_addr; - else { + if (rtinitflags(ia)) { p = ia->ia_addr.sin_addr; - p.s_addr &= ia->ia_sockmask.sin_addr.s_addr; - } - if (prefix.s_addr != p.s_addr) - continue; + if (prefix.s_addr != p.s_addr) + continue; + } else { + p = ia->ia_addr.sin_addr; + m = ia->ia_sockmask.sin_addr; + p.s_addr &= m.s_addr; + + if (prefix.s_addr != p.s_addr || + mask.s_addr != m.s_addr) + continue; + } /* * If we got a matching prefix route inserted by other |