Subject: Confusion about protocol_control functions
To: None <tech-net@NetBSD.ORG>
From: Bill Studenmund <wrstuden@loki.stanford.edu>
List: tech-net
Date: 11/16/1996 17:38:15
I'm part of the group trying to port Netatalk to NetBSD, and I've
gotten hideously confused about addresses on networks (the structures
in the kernel).

Basically we had 1.3.3 working in the kernel, but I'm trying to
get 1.4b2 to work (as it in general supports BSD4.4 much better).

Well, the at_control routine (the thing to respond to SIOCAIFADDR and
the like) looks like a lot of the others. It has some local variable
to walk through addresses (I've compared it w/ in_control in netinet/
in.c). aa for at_control, and ia for in_control. One of the first
things that happens is:

if (ifp)
	for (ia = in_ifaddr.tqh_first; ia; ia = ia->ia_list.tqe_next)
		if (ia->ia_ifp == ifp)
			break;

(This example of in_control but at_control is similar)

then we have a switch statement:

switch (cmd) {

case SIOCAIFADDR:
case SIOCDIFADDR:
	if (ifra->ifra_addr.sin_family == AF_INET)
		for (; ia != 0; ia -> ia_list.tqe_next)
		    if (ia->ia_ifp == ifp && ...

and then there are a lot more similar cases in the at_control example (we
have a case statement with a for(; aa; aa = aa->aa_next) near the top).

Am I just missing something, or can I crash the computer by trying to add
or delete an alias from an interface w/o an address? We would exit the
for loop above when ia == 0, and then start dereferencing it. N.B. This all
happens before we do a permissions check. I won't have to be root.

??

Thanks for your patience!

Take care,

Bill