summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authormlaier <mlaier@FreeBSD.org>2004-02-26 04:27:55 +0000
committermlaier <mlaier@FreeBSD.org>2004-02-26 04:27:55 +0000
commitd937176b3481cd970c24fba3eddbe098a1fe564f (patch)
treeb65ebe6aae423d9c985d1fc587b2e375a7f3c7c4 /sys
parent428f1c9a0fbaac94f9cce57cd846b2b6f82e17d1 (diff)
downloadFreeBSD-src-d937176b3481cd970c24fba3eddbe098a1fe564f.zip
FreeBSD-src-d937176b3481cd970c24fba3eddbe098a1fe564f.tar.gz
Bring eventhandler callbacks for pf.
This enables pf to track dynamic address changes on interfaces (dailup) with the "on (<ifname>)"-syntax. This also brings hooks in anticipation of tracking cloned interfaces, which will be in future versions of pf. Approved by: bms(mentor)
Diffstat (limited to 'sys')
-rw-r--r--sys/net/if.c6
-rw-r--r--sys/net/if_var.h14
-rw-r--r--sys/netinet/in.c5
-rw-r--r--sys/netinet6/in6.c3
4 files changed, 28 insertions, 0 deletions
diff --git a/sys/net/if.c b/sys/net/if.c
index 8cea0c4..1d412f9 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -447,6 +447,8 @@ if_attach(struct ifnet *ifp)
if (domains)
if_attachdomain1(ifp);
+ EVENTHANDLER_INVOKE(ifnet_arrival_event, ifp);
+
/* Announce the interface. */
rt_ifannouncemsg(ifp, IFAN_ARRIVAL);
}
@@ -513,6 +515,7 @@ if_detach(struct ifnet *ifp)
int i;
struct domain *dp;
+ EVENTHANDLER_INVOKE(ifnet_departure_event, ifp);
/*
* Remove routes and flush queues.
*/
@@ -843,6 +846,7 @@ if_clone_attach(struct if_clone *ifc)
bitoff = unit - (bytoff << 3);
ifc->ifc_units[bytoff] |= (1 << bitoff);
}
+ EVENTHANDLER_INVOKE(if_clone_event, ifc);
}
/*
@@ -1378,6 +1382,7 @@ ifhwioctl(u_long cmd, struct ifnet *ifp, caddr_t data, struct thread *td)
if (ifunit(new_name) != NULL)
return (EEXIST);
+ EVENTHANDLER_INVOKE(ifnet_departure_event, ifp);
/* Announce the departure of the interface. */
rt_ifannouncemsg(ifp, IFAN_DEPARTURE);
@@ -1404,6 +1409,7 @@ ifhwioctl(u_long cmd, struct ifnet *ifp, caddr_t data, struct thread *td)
sdl->sdl_data[--namelen] = 0xff;
IFA_UNLOCK(ifa);
+ EVENTHANDLER_INVOKE(ifnet_arrival_event, ifp);
/* Announce the return of the interface. */
rt_ifannouncemsg(ifp, IFAN_ARRIVAL);
break;
diff --git a/sys/net/if_var.h b/sys/net/if_var.h
index a2f9178..5ddd72b 100644
--- a/sys/net/if_var.h
+++ b/sys/net/if_var.h
@@ -78,6 +78,7 @@ struct ether_header;
#ifdef _KERNEL
#include <sys/mbuf.h>
+#include <sys/eventhandler.h>
#endif /* _KERNEL */
#include <sys/lock.h> /* XXX */
#include <sys/mutex.h> /* XXX */
@@ -293,6 +294,19 @@ typedef void if_init_f_t(void *);
} while (0)
#ifdef _KERNEL
+/* interface address change event */
+typedef void (*ifaddr_event_handler_t)(void *, struct ifnet *);
+EVENTHANDLER_DECLARE(ifaddr_event, ifaddr_event_handler_t);
+/* new interface arrival event */
+typedef void (*ifnet_arrival_event_handler_t)(void *, struct ifnet *);
+EVENTHANDLER_DECLARE(ifnet_arrival_event, ifnet_arrival_event_handler_t);
+/* interface departure event */
+typedef void (*ifnet_departure_event_handler_t)(void *, struct ifnet *);
+EVENTHANDLER_DECLARE(ifnet_departure_event, ifnet_departure_event_handler_t);
+/* interface clone event */
+typedef void (*if_clone_event_handler_t)(void *, struct if_clone *);
+EVENTHANDLER_DECLARE(if_clone_event, if_clone_event_handler_t);
+
#define IF_AFDATA_LOCK_INIT(ifp) \
mtx_init(&(ifp)->if_afdata_mtx, "if_afdata", NULL, MTX_DEF)
#define IF_AFDATA_LOCK(ifp) mtx_lock(&(ifp)->if_afdata_mtx)
diff --git a/sys/netinet/in.c b/sys/netinet/in.c
index 187ed93..1873ae4 100644
--- a/sys/netinet/in.c
+++ b/sys/netinet/in.c
@@ -363,6 +363,8 @@ in_control(so, cmd, data, ifp, td)
(struct sockaddr_in *) &ifr->ifr_addr, 1);
if (error != 0 && iaIsNew)
break;
+ if (error == 0)
+ EVENTHANDLER_INVOKE(ifaddr_event, ifp);
return (0);
case SIOCSIFNETMASK:
@@ -405,6 +407,8 @@ in_control(so, cmd, data, ifp, td)
if ((ifp->if_flags & IFF_BROADCAST) &&
(ifra->ifra_broadaddr.sin_family == AF_INET))
ia->ia_broadaddr = ifra->ifra_broadaddr;
+ if (error == 0)
+ EVENTHANDLER_INVOKE(ifaddr_event, ifp);
return (error);
case SIOCDIFADDR:
@@ -427,6 +431,7 @@ in_control(so, cmd, data, ifp, td)
in_pcbpurgeif0(&ripcbinfo, ifp);
in_pcbpurgeif0(&udbinfo, ifp);
}
+ EVENTHANDLER_INVOKE(ifaddr_event, ifp);
error = 0;
break;
diff --git a/sys/netinet6/in6.c b/sys/netinet6/in6.c
index 801472a..4c0dd5b 100644
--- a/sys/netinet6/in6.c
+++ b/sys/netinet6/in6.c
@@ -667,6 +667,8 @@ in6_control(so, cmd, data, ifp, td)
*/
pfxlist_onlink_check();
}
+ if (error == 0 && ia)
+ EVENTHANDLER_INVOKE(ifaddr_event, ifp);
break;
}
@@ -714,6 +716,7 @@ in6_control(so, cmd, data, ifp, td)
purgeaddr:
in6_purgeaddr(&ia->ia_ifa);
+ EVENTHANDLER_INVOKE(ifaddr_event, ifp);
break;
}
OpenPOWER on IntegriCloud