diff --git a/sys/net/route.c b/sys/net/route.c --- a/sys/net/route.c +++ b/sys/net/route.c @@ -50,6 +50,7 @@ #include #include #include +#include #include #include #include @@ -67,6 +68,7 @@ #include #include +#include VNET_PCPUSTAT_DEFINE(struct rtstat, rtstat); @@ -693,6 +695,8 @@ int rt_addrmsg(int cmd, struct ifaddr *ifa, int fibnum) { + struct sockaddr *sa = ifa->ifa_addr; + struct ifnet *ifp = ifa->ifa_ifp; KASSERT(cmd == RTM_ADD || cmd == RTM_DELETE, ("unexpected cmd %d", cmd)); @@ -701,6 +705,28 @@ EVENTHANDLER_DIRECT_INVOKE(rt_addrmsg, ifa, cmd); +#ifdef INET + if (sa->sa_family == AF_INET) { + char addrstr[INET_ADDRSTRLEN]; + char strbuf[INET_ADDRSTRLEN + 12]; + inet_ntoa_r((((struct sockaddr_in*)sa)->sin_addr), + addrstr); + snprintf(strbuf, sizeof(strbuf), "address=%s", addrstr); + devctl_notify("IFNET", ifp->if_xname, + (cmd == RTM_ADD) ? "ADDR_ADD" : "ADDR_DEL", strbuf); + } +#endif +#ifdef INET6 + if (sa->sa_family == AF_INET6) { + char addrstr[INET6_ADDRSTRLEN]; + char strbuf[INET6_ADDRSTRLEN + 12]; + ip6_sprintf(addrstr, IFA_IN6(ifa)); + snprintf(strbuf, sizeof(strbuf), "address=%s", addrstr); + devctl_notify("IFNET", ifp->if_xname, + (cmd == RTM_ADD) ? "ADDR_ADD" : "ADDR_DEL", strbuf); + } +#endif + if (V_rt_add_addr_allfibs) fibnum = RT_ALL_FIBS; return (rtsock_addrmsg(cmd, ifa, fibnum));