Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 29 Apr 2013 21:17:30 -0400
From:      Juan Mojica <jmojica@gmail.com>
To:        FreeBSD Net <freebsd-net@freebsd.org>
Subject:   in_lltable_rtcheck
Message-ID:  <CAPKuH-yfJf0EMyz1iEQ%2BkMz%2BenxRrfhDcpOcMJQfLjJYx10jRQ@mail.gmail.com>

next in thread | raw e-mail | index | archive | help
Why is the code comparing the entire sockaddr structure instead of just the
relevant fields?  We have a flood of the log message below when
transitioning an IP address from one port to another.  And this triggers
other behavior as well.

Through GDB, we can see that the addresses are in the same subnet.  The
problem is that the sin_port port fields in the l3addr and in sa do not
match.

Is there a reason sin_port should be compared here?

I can come up with a patch, that's not an issue, but I wanted to confirm
with others first.


	if (!(rt->rt_flags & RTF_HOST) && rt->rt_ifp != ifp) {
		const char *sa, *mask, *addr, *lim;
		int len;

		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;

		for ( ; addr < lim; sa++, mask++, addr++) {
			if ((*sa ^ *addr) & *mask) {
#ifdef DIAGNOSTIC
				log(LOG_INFO, "IPv4 address: \"%s\" is not on the network\n",
				    inet_ntoa(((const struct sockaddr_in *)l3addr)->sin_addr));
#endif
				RTFREE_LOCKED(rt);
				return (EINVAL);
			}
		}
	}


Regards

-- 
Juan Mojica
Email: jmojica@gmail.com



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAPKuH-yfJf0EMyz1iEQ%2BkMz%2BenxRrfhDcpOcMJQfLjJYx10jRQ>