summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordexuan <dexuan@FreeBSD.org>2017-02-23 06:57:18 +0000
committerdexuan <dexuan@FreeBSD.org>2017-02-23 06:57:18 +0000
commit801edb7982092c7fdc32ca79e679bc44e314d71f (patch)
treedaa74c25f21ff742b5c747f9c347872789bfa6ab
parent2efa1535a98f7c89985bee7c9a39d33e1e15355c (diff)
downloadFreeBSD-src-801edb7982092c7fdc32ca79e679bc44e314d71f.zip
FreeBSD-src-801edb7982092c7fdc32ca79e679bc44e314d71f.tar.gz
MFC: r312687, r312916
Approved by: sephe (mentor) r312687 ifnet: introduce event handlers for ifup/ifdown events Hyper-V's NIC SR-IOV implementation needs a Hyper-V synthetic NIC and a VF NIC to work together, mainly to support seamless live migration. When the VF device becomes UP (or DOWN), the synthetic NIC driver needs to switch the data path from the synthetic NIC to the VF (or the opposite). So the synthetic NIC driver needs to know when a VF device is becoming UP or DOWN and hence the patch is made. Reviewed by: sephe Approved by: sephe (mentor) Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8963 r312916 ifnet: move the new ifnet_event EVENTHANDLER_DECLARE to net/if_var.h Thank glebius for pointing this out: "The network stuff shall not be added to sys/eventhandler.h" Reviewed by: David_A_Bright_DELL.com, sephe, glebius Approved by: sephe (mentor) Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D9345
-rw-r--r--sys/net/if.c2
-rw-r--r--sys/net/if_var.h5
2 files changed, 7 insertions, 0 deletions
diff --git a/sys/net/if.c b/sys/net/if.c
index 67f086b..625b6d0 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -2183,6 +2183,7 @@ void
if_down(struct ifnet *ifp)
{
+ EVENTHANDLER_INVOKE(ifnet_event, ifp, IFNET_EVENT_DOWN);
if_unroute(ifp, IFF_UP, AF_UNSPEC);
}
@@ -2195,6 +2196,7 @@ if_up(struct ifnet *ifp)
{
if_route(ifp, IFF_UP, AF_UNSPEC);
+ EVENTHANDLER_INVOKE(ifnet_event, ifp, IFNET_EVENT_UP);
}
/*
diff --git a/sys/net/if_var.h b/sys/net/if_var.h
index 01ca26c..1456793 100644
--- a/sys/net/if_var.h
+++ b/sys/net/if_var.h
@@ -424,6 +424,11 @@ EVENTHANDLER_DECLARE(ifnet_departure_event, ifnet_departure_event_handler_t);
/* Interface link state change event */
typedef void (*ifnet_link_event_handler_t)(void *, struct ifnet *, int);
EVENTHANDLER_DECLARE(ifnet_link_event, ifnet_link_event_handler_t);
+/* Interface up/down event */
+#define IFNET_EVENT_UP 0
+#define IFNET_EVENT_DOWN 1
+typedef void (*ifnet_event_fn)(void *, struct ifnet *ifp, int event);
+EVENTHANDLER_DECLARE(ifnet_event, ifnet_event_fn);
/*
* interface groups
OpenPOWER on IntegriCloud