1
0
mirror of https://git.FreeBSD.org/src.git synced 2025-01-27 16:39:08 +00:00

Exclude host routes when checking for prefix coverage on multiple

interfaces. A host route has a NULL mask so check for that condition.
I have also been told by developers who customize the packet output
path with direct manipulation of the route entry (or the outgoing
interface to be specific). This patch checks for the route mask
explicitly to make sure custom code will not panic.

PR:		kern/161805
MFC after:	3 days
This commit is contained in:
Qing Li 2011-10-25 04:06:29 +00:00
parent 633d2bc579
commit b3664a14cc
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=226713

View File

@ -1429,12 +1429,21 @@ in_lltable_rtcheck(struct ifnet *ifp, u_int flags, const struct sockaddr *l3addr
* on one interface and the corresponding outgoing packet leaves
* another interface.
*/
if (rt->rt_ifp != ifp) {
if (!(rt->rt_flags & RTF_HOST) && rt->rt_ifp != ifp) {
const char *sa, *mask, *addr, *lim;
int len;
sa = (const char *)rt_key(rt);
mask = (const char *)rt_mask(rt);
/*
* Just being extra cautious to avoid some custom
* code getting into trouble.
*/
if (mask == NULL) {
RTFREE_LOCKED(rt);
return (EINVAL);
}
sa = (const char *)rt_key(rt);
addr = (const char *)l3addr;
len = ((const struct sockaddr_in *)l3addr)->sin_len;
lim = addr + len;