Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F145350437
D54085.1777697965.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D54085.1777697965.diff
View Options
diff --git a/sys/net/if.c b/sys/net/if.c
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -932,10 +932,10 @@
if (domain_init_status >= 2)
if_attachdomain1(ifp);
+ EVENTHANDLER_INVOKE(ifnet_arrival_event, ifp);
if_link_ifnet(ifp);
- EVENTHANDLER_INVOKE(ifnet_arrival_event, ifp);
if (IS_DEFAULT_VNET(curvnet))
devctl_notify("IFNET", ifp->if_xname, "ATTACH", NULL);
}
diff --git a/sys/net/if_var.h b/sys/net/if_var.h
--- a/sys/net/if_var.h
+++ b/sys/net/if_var.h
@@ -358,12 +358,23 @@
EVENTHANDLER_DECLARE(ifaddr_event_ext, ifaddr_event_ext_handler_t);
#define IFADDR_EVENT_ADD 0
#define IFADDR_EVENT_DEL 1
-/* new interface arrival event */
-typedef void (*ifnet_arrival_event_handler_t)(void *, if_t);
-EVENTHANDLER_DECLARE(ifnet_arrival_event, ifnet_arrival_event_handler_t);
-/* interface departure event */
-typedef void (*ifnet_departure_event_handler_t)(void *, if_t);
-EVENTHANDLER_DECLARE(ifnet_departure_event, ifnet_departure_event_handler_t);
+
+/*
+ * Interface arrival & departure events.
+ * The ifnet_arrival_event is executed before the is yet globally visible.
+ * Protocols shall use this event to attach themselves. Protocols shall not
+ * expect other protocols to be fully attached.
+ * The ifnet_attached_event is executed after the interface is attached to all
+ * protocols, is globally visible and fully functional.
+ * The ifnet_departure_event is complementary to ifnet_arrival_event. The
+ * interface is no longer globally visible, protocols may detach.
+ * XXXGL: immediate memory reclamation may not be safe in ifnet_departure_event.
+ */
+typedef void (*ifnet_event_handler_t)(void *, if_t);
+EVENTHANDLER_DECLARE(ifnet_arrival_event, ifnet_event_handler_t);
+EVENTHANDLER_DECLARE(ifnet_attached_event, ifnet_event_handler_t);
+EVENTHANDLER_DECLARE(ifnet_departure_event, ifnet_event_handler_t);
+
/* Interface link state change event */
typedef void (*ifnet_link_event_handler_t)(void *, if_t, int);
EVENTHANDLER_DECLARE(ifnet_link_event, ifnet_link_event_handler_t);
diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c
--- a/sys/net/rtsock.c
+++ b/sys/net/rtsock.c
@@ -317,11 +317,11 @@
SYSINIT(rtsock_init, SI_SUB_PROTO_DOMAIN, SI_ORDER_THIRD, rtsock_init, NULL);
static void
-rts_handle_ifnet_arrival(void *arg __unused, struct ifnet *ifp)
+rts_ifnet_attached(void *arg __unused, struct ifnet *ifp)
{
rt_ifannouncemsg(ifp, IFAN_ARRIVAL);
}
-EVENTHANDLER_DEFINE(ifnet_arrival_event, rts_handle_ifnet_arrival, NULL, 0);
+EVENTHANDLER_DEFINE(ifnet_attached_event, rts_ifnet_attached, NULL, 0);
static void
rts_handle_ifnet_departure(void *arg __unused, struct ifnet *ifp)
diff --git a/sys/netlink/route/iface.c b/sys/netlink/route/iface.c
--- a/sys/netlink/route/iface.c
+++ b/sys/netlink/route/iface.c
@@ -1508,7 +1508,7 @@
rtnl_ifaces_init(void)
{
ifattach_event = EVENTHANDLER_REGISTER(
- ifnet_arrival_event, rtnl_handle_ifattach, NULL,
+ ifnet_attached_event, rtnl_handle_ifattach, NULL,
EVENTHANDLER_PRI_ANY);
ifdetach_event = EVENTHANDLER_REGISTER(
ifnet_departure_event, rtnl_handle_ifdetach, NULL,
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, May 2, 4:59 AM (7 h, 24 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
28536593
Default Alt Text
D54085.1777697965.diff (3 KB)
Attached To
Mode
D54085: net: split ifnet_arrival_event into two events
Attached
Detach File
Event Timeline
Log In to Comment