I'd like to change rtdeletemsg() to stop accepting a NULL ifp pointer. Here's a diff converting the last occurrence.
This will then allow me to move a hack checking for interface index out of rtrequest_delete(). Ok? Index: net/route.c =================================================================== RCS file: /cvs/src/sys/net/route.c,v retrieving revision 1.291 diff -u -p -r1.291 route.c --- net/route.c 9 Dec 2015 09:23:08 -0000 1.291 +++ net/route.c 9 Dec 2015 09:34:09 -0000 @@ -623,6 +623,8 @@ rtdeletemsg(struct rtentry *rt, struct i unsigned int ifidx; struct sockaddr_in6 sa_mask; + KASSERT(rt->rt_ifidx == ifp->if_index); + /* * Request the new route so that the entry is not actually * deleted. That will allow the information being reported to @@ -1088,8 +1090,14 @@ rtrequest(int req, struct rt_addrinfo *i rt->rt_priority, rt); if (error != 0 && (crt = rtalloc(ndst, 0, tableid)) != NULL) { /* overwrite cloned route */ - if ((crt->rt_flags & RTF_CLONED) != 0) { - rtdeletemsg(crt, NULL, tableid); + if (ISSET(crt->rt_flags, RTF_CLONED)) { + struct ifnet *cifp; + + cifp = if_get(crt->rt_ifidx); + KASSERT(cifp != NULL); + rtdeletemsg(crt, cifp, tableid); + if_put(cifp); + error = rtable_insert(tableid, ndst, info->rti_info[RTAX_NETMASK], info->rti_info[RTAX_GATEWAY],