in_pcbconnect_setup() question
Gleb Smirnoff
glebius at freebsd.org
Thu Feb 17 00:46:33 PST 2005
Dear networkers,
I've noticed a small oddity in in_pcbconnect_setup(). According to SuS, in
case of connection-less socket layer, e.g. SOCK_DGRAM, the connect() syscall
should only choose local address and that's all. To server this purposes a
route lookup is done in in_pcbconnect_setup(). However, if route is pointing
to a loopback interface, it is not accepted.
(Not clear to me) comment is also present:
/*
* If we found a route, use the address
* corresponding to the outgoing interface
* unless it is the loopback (in case a route
* to our address on another net goes to loopback).
*/
if (sro.ro_rt && !(sro.ro_rt->rt_ifp->if_flags & IFF_LOOPBACK))
ia = ifatoia(sro.ro_rt->rt_ifa);
if (sro.ro_rt)
RTFREE(sro.ro_rt);
For example, this breaks connect() of a UDP socket to a blackhole-routed IP
address, which shouldn't return an error. I'd like to change this block to the
following:
/*
* If we found a route, use the address
* corresponding to the outgoing interface.
*/
if (sro.ro_rt) {
ia = ifatoia(sro.ro_rt->rt_ifa);
RTFREE(sro.ro_rt);
}
Is there any hidden obstacles? Can someone explain me this comment?
--
Totus tuus, Glebius.
GLEBIUS-RIPN GLEB-RIPE
More information about the freebsd-net
mailing list