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.]
This commit is contained in:
parent
66b1745e3e
commit
bfb26eecfb
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=151555
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user