From nobody Wed Dec 25 09:51:05 2024 X-Original-To: dev-commits-ports-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4YJ6TP4X7Jz5hrdM; Wed, 25 Dec 2024 09:51:05 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4YJ6TP2xt0z4Y2j; Wed, 25 Dec 2024 09:51:05 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1735120265; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=8ASziRWZLRkDfEPlwzeUS7Z7K92WWdAEQvsBcKsOh2Y=; b=lVK1oS3eI3wg0MCX0TC4PRPad7Oq/nAvOSgehsoTl8XXFW9UGqQAewc0RZ26ry4ibT6jpO nuchNvPOf0o7mIh1JMMV5dq6MBPHbDgDtpYoRtzNXLP3dcSHixc9Ufo6VO8/giOQuDah7L kfWMkWNV+tfuPCOFcCnbuajK3NGgzvh42P7dt5fw6X0yPY8Lv1+lopCw9anSgEZod/S7w7 fqVJQhenoIVi7bV9d4wTQ++bU5wtOuZ0lrjAIbr1G27YhLJitfYBugrkIFG0tTxboyrpbQ Z2j6bDA7BKg3aZVIQjWhpCFc1j+ElyHMDl8LiUtOPH+gz5GKB40HJsl+621mWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1735120265; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=8ASziRWZLRkDfEPlwzeUS7Z7K92WWdAEQvsBcKsOh2Y=; b=bhTuIK1FO473F1c2Vp9OnFj4sRr+SS1HXn1OnQTK4rkk2do7EWoHaKXjrFwvgkNGu+8TBW EMg0UtOnCxXGRO+wq9CygKAKsbneiF4+AJyHYYzX6Q6jNlFnLYk6UMDf2hlp+3JrMfWPvl aPKO1b/KivxweBdq3O4urc98o1SPZfdHwjVpiC7vgG1GxNU/NR160DTIr8am4gzjJ7xLwL LdUlO485dk10vTWwAitZfWHjZOlsK3qyR2Mh7otq4T61mqve+33XnIx/Hw9YdB8EvXDG7K iDuYnxa0hFCqQXGasUKq5GOgZ8vHaE5XYhvyrSPjNPO1JGLCLbIaboeP+7BsMg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1735120265; a=rsa-sha256; cv=none; b=c7snNVGkhbR52K/oQ4/LSJfpXYkVtL5ejh9JPZ1oAP1MGUT2eIPNhqtr+ygWqxMg+CWTzt R772uedwrf8k6955UAg3dbN3RP1+/rIEe5UanEXEd7JH55EmUsiYi7J1wzhLbXkyvocGng q7xnXV5CkPgDIKtBzd6iRgEEIPZfW9Hm4OHAbiq62FS448FFV68zxapGzIFqPK26jAorwT A3TXbu7GL5xpA2R5lxI03uzEIbONfTumf8zTjgkl61LZxU/9b5DF0t7FHsaq8LYtARqIal CGuiPmUfwOdxrUz1eWZ48l1QafI6FnUOdYTAPUU+9e27zl/VvD0+2lU9gWC/gQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4YJ6TP2Q8Yz1JpL; Wed, 25 Dec 2024 09:51:05 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 4BP9p5GC035602; Wed, 25 Dec 2024 09:51:05 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4BP9p5pa035599; Wed, 25 Dec 2024 09:51:05 GMT (envelope-from git) Date: Wed, 25 Dec 2024 09:51:05 GMT Message-Id: <202412250951.4BP9p5pa035599@gitrepo.freebsd.org> To: ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org From: Vladimir Druzenko Subject: git: 352837935554 - main - emulators/virtualbox-ose-kmod-legacy: Fix build error since 1500027 (struct ifnet is now hidden) List-Id: Commit messages for all branches of the ports repository List-Archive: https://lists.freebsd.org/archives/dev-commits-ports-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-ports-all@freebsd.org Sender: owner-dev-commits-ports-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: vvd X-Git-Repository: ports X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 3528379355540d3fa2c7c1aee40963742016303a Auto-Submitted: auto-generated The branch main has been updated by vvd: URL: https://cgit.FreeBSD.org/ports/commit/?id=3528379355540d3fa2c7c1aee40963742016303a commit 3528379355540d3fa2c7c1aee40963742016303a Author: Vladimir Druzenko AuthorDate: 2024-12-25 09:48:45 +0000 Commit: Vladimir Druzenko CommitDate: 2024-12-25 09:48:45 +0000 emulators/virtualbox-ose-kmod-legacy: Fix build error since 1500027 (struct ifnet is now hidden) Based on patch from wulf. PR: 282780 Tested by: groenveld@acm.org --- ...Drivers-VBoxNetAdp-freebsd-VBoxNetAdp-freebsd.c | 137 ++++++++++++- ...Drivers_VBoxNetFlt_freebsd_VBoxNetFlt-freebsd.c | 215 ++++++++++++++++++--- 2 files changed, 326 insertions(+), 26 deletions(-) diff --git a/emulators/virtualbox-ose-legacy/files/patch-src-VBox-HostDrivers-VBoxNetAdp-freebsd-VBoxNetAdp-freebsd.c b/emulators/virtualbox-ose-legacy/files/patch-src-VBox-HostDrivers-VBoxNetAdp-freebsd-VBoxNetAdp-freebsd.c index 75a18c10f559..c38db5bc24c5 100644 --- a/emulators/virtualbox-ose-legacy/files/patch-src-VBox-HostDrivers-VBoxNetAdp-freebsd-VBoxNetAdp-freebsd.c +++ b/emulators/virtualbox-ose-legacy/files/patch-src-VBox-HostDrivers-VBoxNetAdp-freebsd-VBoxNetAdp-freebsd.c @@ -1,14 +1,147 @@ ---- src/VBox/HostDrivers/VBoxNetAdp/freebsd/VBoxNetAdp-freebsd.c.orig 2020-05-13 19:43:54 UTC +--- src/VBox/HostDrivers/VBoxNetAdp/freebsd/VBoxNetAdp-freebsd.c.orig 2020-07-09 16:57:01 UTC +++ src/VBox/HostDrivers/VBoxNetAdp/freebsd/VBoxNetAdp-freebsd.c -@@ -235,7 +235,11 @@ static void VBoxNetAdpFreeBSDNetstart(struct ifnet *if +@@ -216,7 +216,11 @@ static void VBoxNetAdpFreeBSDNetinit(void *priv) + PVBOXNETADP pThis = priv; + struct ifnet *ifp = pThis->u.s.ifp; + ++#if __FreeBSD_version >= 1500000 ++ if_setdrvflagbits(ifp, IFF_DRV_RUNNING, 0); ++#else + ifp->if_drv_flags |= IFF_DRV_RUNNING; ++#endif + } + + /** +@@ -226,21 +230,46 @@ static void VBoxNetAdpFreeBSDNetstart(struct ifnet *if + */ + static void VBoxNetAdpFreeBSDNetstart(struct ifnet *ifp) + { ++#if __FreeBSD_version >= 1500000 ++ PVBOXNETADP pThis = if_getsoftc(ifp); ++#else + PVBOXNETADP pThis = ifp->if_softc; ++#endif + struct mbuf *m; + ++#if __FreeBSD_version >= 1500000 ++ if ((if_getdrvflags(ifp) & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) != IFF_DRV_RUNNING) ++#else + if ((ifp->if_drv_flags & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) != IFF_DRV_RUNNING) ++#endif + return; + ++#if __FreeBSD_version >= 1500000 ++ if_setdrvflagbits(ifp, IFF_DRV_OACTIVE, 0); ++ while (!if_sendq_empty(ifp)) ++#else ifp->if_drv_flags |= IFF_DRV_OACTIVE; while (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) ++#endif { +#if __FreeBSD_version >= 1100036 + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); +#else ifp->if_opackets++; +#endif ++#if __FreeBSD_version >= 1500000 ++ m = if_dequeue(ifp); ++#else IFQ_DRV_DEQUEUE(&ifp->if_snd, m); ++#endif BPF_MTAP(ifp, m); m_freem(m); + } ++#if __FreeBSD_version >= 1500000 ++ if_setdrvflagbits(ifp, 0, IFF_DRV_OACTIVE); ++#else + ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; ++#endif + } + + /** +@@ -253,6 +282,18 @@ static int VBoxNetAdpFreeBSDNetioctl(struct ifnet *ifp + switch (cmd) + { + case SIOCSIFFLAGS: ++#if __FreeBSD_version >= 1500000 ++ if (if_getflags(ifp) & IFF_UP) ++ { ++ if (!(if_getdrvflags(ifp) & IFF_DRV_RUNNING)) ++ if_init(ifp, if_getsoftc(ifp)); ++ } ++ else ++ { ++ if (if_getdrvflags(ifp) & IFF_DRV_RUNNING) ++ if_setdrvflagbits(ifp, 0, IFF_DRV_RUNNING); ++ } ++#else + if (ifp->if_flags & IFF_UP) + { + if (!(ifp->if_drv_flags & IFF_DRV_RUNNING)) +@@ -263,6 +304,7 @@ static int VBoxNetAdpFreeBSDNetioctl(struct ifnet *ifp + if (ifp->if_drv_flags & IFF_DRV_RUNNING) + ifp->if_drv_flags &= ~IFF_DRV_RUNNING; + } ++#endif + break; + case SIOCGIFMEDIA: + { +@@ -297,7 +339,11 @@ int vboxNetAdpOsCreate(PVBOXNETADP pThis, PCRTMAC pMac + + int vboxNetAdpOsCreate(PVBOXNETADP pThis, PCRTMAC pMac) + { ++#if __FreeBSD_version >= 1500000 ++ if_t ifp; ++#else + struct ifnet *ifp; ++#endif + + VBOXCURVNET_SET_FROM_UCRED(); + ifp = if_alloc(IFT_ETHER); +@@ -305,6 +351,16 @@ int vboxNetAdpOsCreate(PVBOXNETADP pThis, PCRTMAC pMac + return VERR_NO_MEMORY; + + if_initname(ifp, VBOXNETADP_NAME, pThis->iUnit); ++#if __FreeBSD_version >= 1500000 ++ if_setsoftc(ifp, pThis); ++ if_setmtu(ifp, ETHERMTU); ++ if_setflagbits(ifp, IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST, 0); ++ if_setioctlfn(ifp, VBoxNetAdpFreeBSDNetioctl); ++ if_setstartfn(ifp, VBoxNetAdpFreeBSDNetstart); ++ if_setinitfn(ifp, VBoxNetAdpFreeBSDNetinit); ++ if_setsendqlen(ifp, IFQ_MAXLEN); ++ if_setsendqready(ifp); ++#else + ifp->if_softc = pThis; + ifp->if_mtu = ETHERMTU; + ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; +@@ -314,10 +370,17 @@ int vboxNetAdpOsCreate(PVBOXNETADP pThis, PCRTMAC pMac + IFQ_SET_MAXLEN(&ifp->if_snd, IFQ_MAXLEN); + ifp->if_snd.ifq_drv_maxlen = IFQ_MAXLEN; + IFQ_SET_READY(&ifp->if_snd); ++#endif + ether_ifattach(ifp, (void *)pMac); ++#if __FreeBSD_version >= 1500000 ++ (void)if_setbaudrate(ifp, 0); ++ ++ strncpy(pThis->szName, if_name(ifp), VBOXNETADP_MAX_NAME_LEN); ++#else + ifp->if_baudrate = 0; + + strncpy(pThis->szName, ifp->if_xname, VBOXNETADP_MAX_NAME_LEN); ++#endif + pThis->u.s.ifp = ifp; + VBOXCURVNET_RESTORE(); + return 0; +@@ -328,7 +391,11 @@ void vboxNetAdpOsDestroy(PVBOXNETADP pThis) + struct ifnet *ifp; + + ifp = pThis->u.s.ifp; ++#if __FreeBSD_version >= 1500000 ++ VBOXCURVNET_SET(if_getvnet(ifp)); ++#else + VBOXCURVNET_SET(ifp->if_vnet); ++#endif + ether_ifdetach(ifp); + if_free(ifp); + VBOXCURVNET_RESTORE(); diff --git a/emulators/virtualbox-ose-legacy/files/patch-src_VBox_HostDrivers_VBoxNetFlt_freebsd_VBoxNetFlt-freebsd.c b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_HostDrivers_VBoxNetFlt_freebsd_VBoxNetFlt-freebsd.c index d9d1bfaef91b..5accbdf87224 100644 --- a/emulators/virtualbox-ose-legacy/files/patch-src_VBox_HostDrivers_VBoxNetFlt_freebsd_VBoxNetFlt-freebsd.c +++ b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_HostDrivers_VBoxNetFlt_freebsd_VBoxNetFlt-freebsd.c @@ -33,7 +33,28 @@ break; case MOD_UNLOAD: -@@ -361,7 +362,14 @@ static int ng_vboxnetflt_rcvdata(hook_p hook, item_p i +@@ -334,12 +335,20 @@ static int ng_vboxnetflt_rcvdata(hook_p hook, item_p i + { + const node_p node = NG_HOOK_NODE(hook); + PVBOXNETFLTINS pThis = NG_NODE_PRIVATE(node); ++#if __FreeBSD_version >= 1500000 ++ if_t ifp = pThis->u.s.ifp; ++#else + struct ifnet *ifp = pThis->u.s.ifp; ++#endif + struct mbuf *m; + struct m_tag *mtag; + bool fActive; + ++#if __FreeBSD_version >= 1500000 ++ VBOXCURVNET_SET(if_getvnet(ifp)); ++#else + VBOXCURVNET_SET(ifp->if_vnet); ++#endif + fActive = vboxNetFltTryRetainBusyActive(pThis); + + NGI_GET_M(item, m); +@@ -361,7 +370,14 @@ static int ng_vboxnetflt_rcvdata(hook_p hook, item_p i { if (mtag != NULL || !fActive) { @@ -48,7 +69,7 @@ if (fActive) vboxNetFltRelease(pThis, true /*fBusy*/); VBOXCURVNET_RESTORE(); -@@ -370,7 +378,11 @@ static int ng_vboxnetflt_rcvdata(hook_p hook, item_p i +@@ -370,7 +386,11 @@ static int ng_vboxnetflt_rcvdata(hook_p hook, item_p i mtx_lock_spin(&pThis->u.s.inq.ifq_mtx); _IF_ENQUEUE(&pThis->u.s.inq, m); mtx_unlock_spin(&pThis->u.s.inq.ifq_mtx); @@ -60,7 +81,7 @@ } /* * Handle mbufs on the outgoing hook, frames going to the interface -@@ -388,7 +400,11 @@ static int ng_vboxnetflt_rcvdata(hook_p hook, item_p i +@@ -388,7 +408,11 @@ static int ng_vboxnetflt_rcvdata(hook_p hook, item_p i mtx_lock_spin(&pThis->u.s.outq.ifq_mtx); _IF_ENQUEUE(&pThis->u.s.outq, m); mtx_unlock_spin(&pThis->u.s.outq.ifq_mtx); @@ -72,16 +93,30 @@ } else { -@@ -428,6 +444,8 @@ static void vboxNetFltFreeBSDinput(void *arg, int pend +@@ -425,12 +449,22 @@ static void vboxNetFltFreeBSDinput(void *arg, int pend + { + PVBOXNETFLTINS pThis = (PVBOXNETFLTINS)arg; + struct mbuf *m, *m0; ++#if __FreeBSD_version >= 1500000 ++ if_t ifp = pThis->u.s.ifp; ++#else struct ifnet *ifp = pThis->u.s.ifp; ++#endif unsigned int cSegs = 0; bool fDropIt = false, fActive; + bool is_vl_tagged = false; + uint16_t vl_tag; PINTNETSG pSG; ++#if __FreeBSD_version >= 1500000 ++ VBOXCURVNET_SET(if_getvnet(ifp)); ++#else VBOXCURVNET_SET(ifp->if_vnet); -@@ -440,6 +458,19 @@ static void vboxNetFltFreeBSDinput(void *arg, int pend ++#endif + vboxNetFltRetain(pThis, true /* fBusy */); + for (;;) + { +@@ -440,6 +474,19 @@ static void vboxNetFltFreeBSDinput(void *arg, int pend if (m == NULL) break; @@ -101,7 +136,7 @@ for (m0 = m; m0 != NULL; m0 = m0->m_next) if (m0->m_len > 0) cSegs++; -@@ -454,10 +485,40 @@ static void vboxNetFltFreeBSDinput(void *arg, int pend +@@ -454,10 +501,39 @@ static void vboxNetFltFreeBSDinput(void *arg, int pend vboxNetFltFreeBSDMBufToSG(pThis, m, pSG, cSegs, 0); fDropIt = pThis->pSwitchPort->pfnRecv(pThis->pSwitchPort, NULL /* pvIf */, pSG, INTNETTRUNKDIR_WIRE); RTMemTmpFree(pSG); @@ -128,8 +163,8 @@ + if (fDropIt) m_freem(m); - else -+ { +- else ++ else { +#if __FreeBSD_version >= 1300049 + struct epoch_tracker et; + NET_EPOCH_ENTER(et); @@ -142,7 +177,28 @@ } vboxNetFltRelease(pThis, true /* fBusy */); VBOXCURVNET_RESTORE(); -@@ -513,6 +574,7 @@ int vboxNetFltPortOsXmit(PVBOXNETFLTINS pThis, void *p +@@ -470,12 +546,20 @@ static void vboxNetFltFreeBSDoutput(void *arg, int pen + { + PVBOXNETFLTINS pThis = (PVBOXNETFLTINS)arg; + struct mbuf *m, *m0; ++#if __FreeBSD_version >= 1500000 ++ if_t ifp = pThis->u.s.ifp; ++#else + struct ifnet *ifp = pThis->u.s.ifp; ++#endif + unsigned int cSegs = 0; + bool fDropIt = false, fActive; + PINTNETSG pSG; + ++#if __FreeBSD_version >= 1500000 ++ VBOXCURVNET_SET(if_getvnet(ifp)); ++#else + VBOXCURVNET_SET(ifp->if_vnet); ++#endif + vboxNetFltRetain(pThis, true /* fBusy */); + for (;;) + { +@@ -513,26 +597,41 @@ int vboxNetFltPortOsXmit(PVBOXNETFLTINS pThis, void *p */ int vboxNetFltPortOsXmit(PVBOXNETFLTINS pThis, void *pvIfData, PINTNETSG pSG, uint32_t fDst) { @@ -150,7 +206,24 @@ NOREF(pvIfData); void (*input_f)(struct ifnet *, struct mbuf *); -@@ -529,10 +591,16 @@ int vboxNetFltPortOsXmit(PVBOXNETFLTINS pThis, void *p ++#if __FreeBSD_version >= 1500000 ++ if_t ifp; ++#else + struct ifnet *ifp; ++#endif + struct mbuf *m; + struct m_tag *mtag; + bool fActive; + int error; + + ifp = ASMAtomicUoReadPtrT(&pThis->u.s.ifp, struct ifnet *); ++#if __FreeBSD_version >= 1500000 ++ VBOXCURVNET_SET(if_getvnet(ifp)); ++#else + VBOXCURVNET_SET(ifp->if_vnet); ++#endif + + if (fDst & INTNETTRUNKDIR_WIRE) { m = vboxNetFltFreeBSDSGMBufFromSG(pThis, pSG); if (m == NULL) @@ -167,7 +240,7 @@ m->m_flags |= M_PKTHDR; ether_output_frame(ifp, m); -@@ -542,10 +610,16 @@ int vboxNetFltPortOsXmit(PVBOXNETFLTINS pThis, void *p +@@ -542,10 +641,16 @@ int vboxNetFltPortOsXmit(PVBOXNETFLTINS pThis, void *p { m = vboxNetFltFreeBSDSGMBufFromSG(pThis, pSG); if (m == NULL) @@ -184,7 +257,7 @@ /* * Delivering packets to the host will be captured by the * input hook. Tag the packet with a mbuf tag so that we -@@ -556,6 +630,7 @@ int vboxNetFltPortOsXmit(PVBOXNETFLTINS pThis, void *p +@@ -556,6 +661,7 @@ int vboxNetFltPortOsXmit(PVBOXNETFLTINS pThis, void *p if (mtag == NULL) { m_freem(m); @@ -192,7 +265,7 @@ return VERR_NO_MEMORY; } -@@ -563,9 +638,17 @@ int vboxNetFltPortOsXmit(PVBOXNETFLTINS pThis, void *p +@@ -563,9 +669,21 @@ int vboxNetFltPortOsXmit(PVBOXNETFLTINS pThis, void *p m_tag_prepend(m, mtag); m->m_flags |= M_PKTHDR; m->m_pkthdr.rcvif = ifp; @@ -200,7 +273,11 @@ + struct epoch_tracker et; + NET_EPOCH_ENTER(et); +#endif ++#if __FreeBSD_version >= 1500000 ++ if_input(ifp, m); ++#else ifp->if_input(ifp, m); ++#endif +#if __FreeBSD_version >= 1300049 + NET_EPOCH_EXIT(et); +#endif @@ -210,15 +287,20 @@ return VINF_SUCCESS; } -@@ -578,6 +661,7 @@ int vboxNetFltOsInitInstance(PVBOXNETFLTINS pThis, voi +@@ -578,15 +696,23 @@ int vboxNetFltOsInitInstance(PVBOXNETFLTINS pThis, voi int vboxNetFltOsInitInstance(PVBOXNETFLTINS pThis, void *pvContext) { + IPRT_FREEBSD_SAVE_EFL_AC(); char nam[NG_NODESIZ]; ++#if __FreeBSD_version >= 1500000 ++ if_t ifp; ++#else struct ifnet *ifp; ++#endif node_p node; -@@ -586,7 +670,10 @@ int vboxNetFltOsInitInstance(PVBOXNETFLTINS pThis, voi + + VBOXCURVNET_SET_FROM_UCRED(); NOREF(pvContext); ifp = ifunit(pThis->szName); if (ifp == NULL) @@ -229,7 +311,19 @@ /* Create a new netgraph node for this instance */ if (ng_make_node_common(&ng_vboxnetflt_typestruct, &node) != 0) -@@ -630,12 +717,14 @@ int vboxNetFltOsInitInstance(PVBOXNETFLTINS pThis, voi +@@ -596,7 +722,11 @@ int vboxNetFltOsInitInstance(PVBOXNETFLTINS pThis, voi + + ASMAtomicUoWritePtr(&pThis->u.s.ifp, ifp); + pThis->u.s.node = node; ++#if __FreeBSD_version >= 1500000 ++ bcopy(if_getlladdr(ifp), &pThis->u.s.MacAddr, ETHER_ADDR_LEN); ++#else + bcopy(IF_LLADDR(ifp), &pThis->u.s.MacAddr, ETHER_ADDR_LEN); ++#endif + ASMAtomicUoWriteBool(&pThis->fDisconnectedFromHost, false); + + /* Initialize deferred input queue */ +@@ -630,16 +760,26 @@ int vboxNetFltOsInitInstance(PVBOXNETFLTINS pThis, voi vboxNetFltRelease(pThis, true /*fBusy*/); } VBOXCURVNET_RESTORE(); @@ -241,10 +335,22 @@ bool vboxNetFltOsMaybeRediscovered(PVBOXNETFLTINS pThis) { + IPRT_FREEBSD_SAVE_EFL_AC(); ++#if __FreeBSD_version >= 1500000 ++ if_t ifp, ifp0; ++#else struct ifnet *ifp, *ifp0; ++#endif ifp = ASMAtomicUoReadPtrT(&pThis->u.s.ifp, struct ifnet *); -@@ -652,6 +741,7 @@ bool vboxNetFltOsMaybeRediscovered(PVBOXNETFLTINS pThi ++#if __FreeBSD_version >= 1500000 ++ VBOXCURVNET_SET(if_getvnet(ifp)); ++#else + VBOXCURVNET_SET(ifp->if_vnet); ++#endif + /* + * Attempt to check if the interface is still there and re-initialize if + * something has changed. +@@ -652,6 +792,7 @@ bool vboxNetFltOsMaybeRediscovered(PVBOXNETFLTINS pThi pThis->u.s.node = NULL; } VBOXCURVNET_RESTORE(); @@ -252,7 +358,7 @@ if (ifp0 != NULL) { -@@ -664,6 +754,7 @@ void vboxNetFltOsDeleteInstance(PVBOXNETFLTINS pThis) +@@ -664,6 +805,7 @@ void vboxNetFltOsDeleteInstance(PVBOXNETFLTINS pThis) void vboxNetFltOsDeleteInstance(PVBOXNETFLTINS pThis) { @@ -260,7 +366,7 @@ taskqueue_drain(taskqueue_fast, &pThis->u.s.tskin); taskqueue_drain(taskqueue_fast, &pThis->u.s.tskout); -@@ -676,6 +767,7 @@ void vboxNetFltOsDeleteInstance(PVBOXNETFLTINS pThis) +@@ -676,6 +818,7 @@ void vboxNetFltOsDeleteInstance(PVBOXNETFLTINS pThis) ng_rmnode_self(pThis->u.s.node); VBOXCURVNET_RESTORE(); pThis->u.s.node = NULL; @@ -268,15 +374,51 @@ } int vboxNetFltOsPreInitInstance(PVBOXNETFLTINS pThis) -@@ -689,6 +781,7 @@ void vboxNetFltPortOsSetActive(PVBOXNETFLTINS pThis, b +@@ -689,7 +832,12 @@ void vboxNetFltPortOsSetActive(PVBOXNETFLTINS pThis, b void vboxNetFltPortOsSetActive(PVBOXNETFLTINS pThis, bool fActive) { + IPRT_FREEBSD_SAVE_EFL_AC(); ++#if __FreeBSD_version >= 1500000 ++ if_t ifp; ++#else struct ifnet *ifp; ++#endif struct ifreq ifreq; int error; -@@ -722,7 +815,10 @@ void vboxNetFltPortOsSetActive(PVBOXNETFLTINS pThis, b + node_p node; +@@ -701,18 +849,30 @@ void vboxNetFltPortOsSetActive(PVBOXNETFLTINS pThis, b + Log(("%s: fActive:%d\n", __func__, fActive)); + + ifp = ASMAtomicUoReadPtrT(&pThis->u.s.ifp, struct ifnet *); ++#if __FreeBSD_version >= 1500000 ++ VBOXCURVNET_SET(if_getvnet(ifp)); ++#else + VBOXCURVNET_SET(ifp->if_vnet); ++#endif + node = ASMAtomicUoReadPtrT(&pThis->u.s.node, node_p); + + memset(&ifreq, 0, sizeof(struct ifreq)); + /* Activate interface */ + if (fActive) + { ++#if __FreeBSD_version >= 1500000 ++ pThis->u.s.flags = if_getflags(ifp); ++#else + pThis->u.s.flags = ifp->if_flags; ++#endif + ifpromisc(ifp, 1); + + /* ng_ether nodes are named after the interface name */ ++#if __FreeBSD_version >= 1500000 ++ snprintf(path, sizeof(path), "%s:", if_name(ifp)); ++#else + snprintf(path, sizeof(path), "%s:", ifp->if_xname); ++#endif + + /* + * Send a netgraph connect message to the ng_ether node +@@ -722,9 +882,16 @@ void vboxNetFltPortOsSetActive(PVBOXNETFLTINS pThis, b NG_MKMESSAGE(msg, NGM_GENERIC_COOKIE, NGM_CONNECT, sizeof(struct ngm_connect), M_NOWAIT); if (msg == NULL) @@ -285,9 +427,15 @@ return; + } con = (struct ngm_connect *)msg->data; ++#if __FreeBSD_version >= 1500000 ++ snprintf(con->path, NG_PATHSIZ, "vboxnetflt_%s:", if_name(ifp)); ++#else snprintf(con->path, NG_PATHSIZ, "vboxnetflt_%s:", ifp->if_xname); ++#endif strlcpy(con->ourhook, "lower", NG_HOOKSIZ); -@@ -736,7 +832,10 @@ void vboxNetFltPortOsSetActive(PVBOXNETFLTINS pThis, b + strlcpy(con->peerhook, "input", NG_HOOKSIZ); + NG_SEND_MSG_PATH(error, node, msg, path, 0); +@@ -736,10 +903,17 @@ void vboxNetFltPortOsSetActive(PVBOXNETFLTINS pThis, b NG_MKMESSAGE(msg, NGM_GENERIC_COOKIE, NGM_CONNECT, sizeof(struct ngm_connect), M_NOWAIT); if (msg == NULL) @@ -297,8 +445,27 @@ + } con = (struct ngm_connect *)msg->data; snprintf(con->path, NG_PATHSIZ, "vboxnetflt_%s:", ++#if __FreeBSD_version >= 1500000 ++ if_name(ifp)); ++#else ifp->if_xname); -@@ -759,7 +858,10 @@ void vboxNetFltPortOsSetActive(PVBOXNETFLTINS pThis, b ++#endif + strlcpy(con->ourhook, "upper", sizeof(con->ourhook)); + strlcpy(con->peerhook, "output", sizeof(con->peerhook)); + NG_SEND_MSG_PATH(error, node, msg, path, 0); +@@ -751,7 +925,11 @@ void vboxNetFltPortOsSetActive(PVBOXNETFLTINS pThis, b + ifpromisc(ifp, 0); + + /* Disconnect msgs are addressed to ourself */ ++#if __FreeBSD_version >= 1500000 ++ snprintf(path, sizeof(path), "vboxnetflt_%s:", if_name(ifp)); ++#else + snprintf(path, sizeof(path), "vboxnetflt_%s:", ifp->if_xname); ++#endif + + /* + * Send a netgraph message to disconnect our 'input' hook +@@ -759,7 +937,10 @@ void vboxNetFltPortOsSetActive(PVBOXNETFLTINS pThis, b NG_MKMESSAGE(msg, NGM_GENERIC_COOKIE, NGM_RMHOOK, sizeof(struct ngm_rmhook), M_NOWAIT); if (msg == NULL) @@ -309,7 +476,7 @@ rm = (struct ngm_rmhook *)msg->data; strlcpy(rm->ourhook, "input", NG_HOOKSIZ); NG_SEND_MSG_PATH(error, node, msg, path, 0); -@@ -770,12 +872,16 @@ void vboxNetFltPortOsSetActive(PVBOXNETFLTINS pThis, b +@@ -770,12 +951,16 @@ void vboxNetFltPortOsSetActive(PVBOXNETFLTINS pThis, b NG_MKMESSAGE(msg, NGM_GENERIC_COOKIE, NGM_RMHOOK, sizeof(struct ngm_rmhook), M_NOWAIT); if (msg == NULL)