tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Make sure to insert ifa/ia after initialization



On 2016-06-28 02:03, Ryota Ozaki wrote:
Hi,

Basically we should insert an item to a collection
(say a list) after completed item's initialization to
avoid accessing an item that is initialized halfway.

ifaddr and in{,6}_ifaddr aren't processed like so.
The patch below fixes the issue.

  http://www.netbsd.org/~ozaki-r/insert_ifa_after_init.diff

To this end, I need to tweak {arp,nd6}_rtrequest that
depend on that an ifaddr (in{,6}_ifaddr) is inserted
during its initialization; they explore interface's
address list to determine that rt_getkey(rt) of a given
rtentry is in the list (i.e., whether the route's
interface should be a loopback), which doesn't work
after the change. To make it work I use RTF_LOCAL flag
instead.

Any comments or suggestions?

+		if (rt->rt_flags & RTF_LOCAL) {
+			rt->rt_expire = 0;
+			if (useloopback) {
+				rt->rt_ifp = lo0ifp;
+				rt->rt_rmx.rmx_mtu = 0;
+			}
 		}
-		rt->rt_flags |= RTF_LOCAL;
-		/*

This has reverted r1.181 which had this comment:
If, for whatever reason, a local interface route is removed and then
re-added, mark it as a local route.

You've tested manually removing and re-adding the local route and noticing the flag is preserved?

Roy


Home | Main Index | Thread Index | Old Index