[net.unix-wizards] 4.2 ip source route bug?

hagens@uwvax.UUCP (Rob Hagens) (01/23/85)

I have been having trouble getting 4.2 to forward source routed ip
datagrams. It seems that once into 4.2 ip, they never get back out.

Looking at the ip code, in ip_input.c, in function ip_dooptions,
at case label IPOPT_LSRR:

The next hop in the source route is placed into struct ipaddr.
Then a check is made to see if this address corresponds to any interface:

	ifp = if_ifwithaddr((struct sockaddr *)&ipaddr;

If, when this function returns, ifp == 0, then the source route is
aborted (ip_options returns without changing the destination address, and
ip_input assumes the datagram is for the current host).

Looking at the function if_ifwithaddr(), it appears that it checks 14 bytes
of internet address. I am confused here. One would think that the only
portion of the address to check is the net, not the entire address, let
alone 14 bytes! (see the #define equal in the if_ifwithaddr()).

Does anyone know whats going on here. I'd like a second opinion before I
change this stuff.

Rob Hagens
-- 
Rob Hagens @ wisconsin
...!{allegra,heurikon,ihnp4,seismo,sfwin,ucbvax,uwm-evax}!uwvax!hagens
hagens@wisc-rsch.arpa

Bob Walsh <walsh@bbn-labs-b> (01/24/85)

The distributed 4.2 source routing is not properly done.  A source
routed packet looks like:

	IP header
			dst	128.11.1.1
	---------------------------------------
	IP options
				8.7.0.2
				9.9.9.9  <-
				192.23.2.1

The if_ifwithaddr() check should see if the IP header destination field
is on the current host.  It improperly checks to see if the next hop is
the current host.  It should:

		Is the current host 128.11.1.1 => if_ifwithaddr(128.11.1.1)

No, and strict source routing => ICMP error message
No, and loose source routing  => forward packet

Yes.  IP dst gets 9.9.9.9.  Store outgoing interface where 9.9.9.9 was.
Bump option pointer up by sizeof(struct in_addr).  If we're not on the
network of the new destination and it's a strictly source routed packet,
then generate an ICMP error message.  Otherwise, forward it.


bob walsh

chris@umcp-cs.UUCP (Chris Torek) (01/27/85)

> I have been having trouble getting 4.2 to forward source routed ip
> datagrams. It seems that once into 4.2 ip, they never get back out.
> [...]
> [in ip_input.c, for SSRR:]
>
>	ifp = if_ifwithaddr((struct sockaddr *)&ipaddr);
>
> If, when this function returns, ifp == 0, then the source route is
> aborted (ip_options returns without changing the destination address, and
> ip_input assumes the datagram is for the current host).

It's wrong; it should be if_ifwithnet((struct sockaddr *)&ipaddr).  (There
*is* an if_ifwithnet in the standard 4.2 code, there *has* to be...?)

> Looking at the function if_ifwithaddr(), it appears that it checks 14 bytes
> of internet address.

That if_ifwithaddr deals in 14 byte things is a whole different bug, and
doesn't affect AF_INET.
-- 
(This line accidently left nonblank.)

In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7690)
UUCP:	{seismo,allegra,brl-bmd}!umcp-cs!chris
CSNet:	chris@umcp-cs		ARPA:	chris@maryland