Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 6 Jan 2017 09:23:12 +0000
From:      "decui_microsoft.com (Dexuan Cui)" <phabric-noreply@FreeBSD.org>
To:        freebsd-net@freebsd.org
Subject:   [Differential] D8963: ifnet: introduce event handlers for ifup/ifdown events
Message-ID:  <40d32d89a0160cf02a1fa819d29ced09@localhost.localdomain>
In-Reply-To: <differential-rev-PHID-DREV-3ybd3zjkngxrs2mfdmts-req@FreeBSD.org>
References:  <differential-rev-PHID-DREV-3ybd3zjkngxrs2mfdmts-req@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help

[-- Attachment #1 --]
decui_microsoft.com updated the summary for this revision.
decui_microsoft.com updated this revision to Diff 23652.
decui_microsoft.com added a comment.


  Since sephe's patch (https://reviews.freebsd.org/D8905) is accepted, let me update this patch accordingly.

CHANGES SINCE LAST UPDATE
  https://reviews.freebsd.org/D8963?vs=23382&id=23652

REVISION DETAIL
  https://reviews.freebsd.org/D8963

AFFECTED FILES
  sys/net/if.c
  sys/sys/eventhandler.h

EMAIL PREFERENCES
  https://reviews.freebsd.org/settings/panel/emailpreferences/

To: decui_microsoft.com, hselasky, sepherosa_gmail.com, cem, np, kmacy, kib, honzhan_microsoft.com, howard0su_gmail.com, jhb, ae, delphij, royger, glebius, gnn, rwatson
Cc: freebsd-net-list

[-- Attachment #2 --]
diff --git a/sys/sys/eventhandler.h b/sys/sys/eventhandler.h
--- a/sys/sys/eventhandler.h
+++ b/sys/sys/eventhandler.h
@@ -284,4 +284,11 @@
 EVENTHANDLER_DECLARE(swapon, swapon_fn);
 EVENTHANDLER_DECLARE(swapoff, swapoff_fn);
 
+/* ifup/ifdown events */
+#define IFNET_EVENT_UP		0
+#define IFNET_EVENT_DOWN	1
+struct ifnet;
+typedef void (*ifnet_event_fn)(void *, struct ifnet *ifp, int event);
+EVENTHANDLER_DECLARE(ifnet_event, ifnet_event_fn);
+
 #endif /* _SYS_EVENTHANDLER_H_ */
diff --git a/sys/net/if.c b/sys/net/if.c
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -59,6 +59,7 @@
 #include <sys/domain.h>
 #include <sys/jail.h>
 #include <sys/priv.h>
+#include <sys/eventhandler.h>
 
 #include <machine/stdarg.h>
 #include <vm/uma.h>
@@ -2218,6 +2219,7 @@
 if_down(struct ifnet *ifp)
 {
 
+	EVENTHANDLER_INVOKE(ifnet_event, ifp, IFNET_EVENT_DOWN);
 	if_unroute(ifp, IFF_UP, AF_UNSPEC);
 }
 
@@ -2230,6 +2232,7 @@
 {
 
 	if_route(ifp, IFF_UP, AF_UNSPEC);
+	EVENTHANDLER_INVOKE(ifnet_event, ifp, IFNET_EVENT_UP);
 }
 
 /*


Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?40d32d89a0160cf02a1fa819d29ced09>