Hi, I have a suggestion to add support for ip-address changes to the kqueue (EVFILT_NETDEV) system. The infrastructure for EVFILT_NETDEV is already in place and this only introduce NOTE_NEWADDR and NOTE_DELADDR and minor modifications to the interface ioctl handler. The purpose is not to replicate the functionality of the routing socket, but to provide a low overhead mechanism for monitoring a given interface for address changes. No information about the event is sent through the kqueue system, instead it will be up to the caller to query the system (if wanted) to obtain information about the current state of the interface that is being monitored. I have attached a suggested patch, any thoughts? Fredrik Lindberg Index: sys/event.h =================================================================== RCS file: /home/ncvs/src/sys/sys/event.h,v retrieving revision 1.36 diff -u -r1.36 event.h --- sys/event.h 16 Mar 2006 11:19:36 -0000 1.36 +++ sys/event.h 25 Jul 2006 12:18:16 -0000 _at__at_ -115,6 +115,8 _at__at_ #define NOTE_LINKUP 0x0001 /* link is up */ #define NOTE_LINKDOWN 0x0002 /* link is down */ #define NOTE_LINKINV 0x0004 /* link state is invalid */ +#define NOTE_NEWADDR 0x0008 /* ip-address added */ +#define NOTE_DELADDR 0x0010 /* ip-address removed */ struct knote; SLIST_HEAD(klist, knote); Index: netinet/in.c =================================================================== RCS file: /home/ncvs/src/sys/netinet/in.c,v retrieving revision 1.93 diff -u -r1.93 in.c --- netinet/in.c 24 Jan 2006 16:19:31 -0000 1.93 +++ netinet/in.c 25 Jul 2006 12:18:16 -0000 _at__at_ -399,8 +399,10 _at__at_ (struct sockaddr_in *) &ifr->ifr_addr, 1); if (error != 0 && iaIsNew) break; - if (error == 0) + if (error == 0) { EVENTHANDLER_INVOKE(ifaddr_event, ifp); + KNOTE_UNLOCKED(&ifp->if_klist, NOTE_NEWADDR); + } return (0); case SIOCSIFNETMASK: _at__at_ -443,8 +445,10 _at__at_ if ((ifp->if_flags & IFF_BROADCAST) && (ifra->ifra_broadaddr.sin_family == AF_INET)) ia->ia_broadaddr = ifra->ifra_broadaddr; - if (error == 0) + if (error == 0) { EVENTHANDLER_INVOKE(ifaddr_event, ifp); + KNOTE_UNLOCKED(&ifp->if_klist, NOTE_NEWADDR); + } return (error); case SIOCDIFADDR: _at__at_ -460,6 +464,7 _at__at_ */ in_ifadown(&ia->ia_ifa, 1); EVENTHANDLER_INVOKE(ifaddr_event, ifp); + KNOTE_UNLOCKED(&ifp->if_klist, NOTE_DELADDR); error = 0; break;Received on Tue Jul 25 2006 - 10:54:22 UTC
This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:58 UTC