Date: Tue, 24 Jan 2017 09:19:47 +0000 (UTC) From: Dexuan Cui <dexuan@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r312687 - in head/sys: net sys Message-ID: <201701240919.v0O9JlM7021007@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: dexuan Date: Tue Jan 24 09:19:46 2017 New Revision: 312687 URL: https://svnweb.freebsd.org/changeset/base/312687 Log: 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) MFC after: 2 weeks Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8963 Modified: head/sys/net/if.c head/sys/sys/eventhandler.h Modified: head/sys/net/if.c ============================================================================== --- head/sys/net/if.c Tue Jan 24 09:15:36 2017 (r312686) +++ head/sys/net/if.c Tue Jan 24 09:19:46 2017 (r312687) @@ -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 @@ void 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_up(struct ifnet *ifp) { if_route(ifp, IFF_UP, AF_UNSPEC); + EVENTHANDLER_INVOKE(ifnet_event, ifp, IFNET_EVENT_UP); } /* Modified: head/sys/sys/eventhandler.h ============================================================================== --- head/sys/sys/eventhandler.h Tue Jan 24 09:15:36 2017 (r312686) +++ head/sys/sys/eventhandler.h Tue Jan 24 09:19:46 2017 (r312687) @@ -284,4 +284,11 @@ typedef void (*swapoff_fn)(void *, struc 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_ */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201701240919.v0O9JlM7021007>