1 | /* $Id: VBoxNetFlt-darwin.cpp 57904 2015-09-25 19:57:12Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBoxNetFlt - Network Filter Driver (Host), Darwin Specific Code.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2015 Oracle Corporation
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | */
|
---|
17 |
|
---|
18 |
|
---|
19 | /*********************************************************************************************************************************
|
---|
20 | * Header Files *
|
---|
21 | *********************************************************************************************************************************/
|
---|
22 | #define LOG_GROUP LOG_GROUP_NET_FLT_DRV
|
---|
23 | #include "../../../Runtime/r0drv/darwin/the-darwin-kernel.h"
|
---|
24 |
|
---|
25 | #include <VBox/log.h>
|
---|
26 | #include <VBox/err.h>
|
---|
27 | #include <VBox/intnetinline.h>
|
---|
28 | #include <VBox/version.h>
|
---|
29 | #include <iprt/initterm.h>
|
---|
30 | #include <iprt/assert.h>
|
---|
31 | #include <iprt/spinlock.h>
|
---|
32 | #include <iprt/semaphore.h>
|
---|
33 | #include <iprt/process.h>
|
---|
34 | #include <iprt/alloc.h>
|
---|
35 | #include <iprt/alloca.h>
|
---|
36 | #include <iprt/time.h>
|
---|
37 | #include <iprt/net.h>
|
---|
38 | #include <iprt/thread.h>
|
---|
39 |
|
---|
40 | #include "../../darwin/VBoxNetSend.h"
|
---|
41 |
|
---|
42 | #include <mach/kmod.h>
|
---|
43 | #include <sys/conf.h>
|
---|
44 | #include <sys/errno.h>
|
---|
45 | #include <sys/ioccom.h>
|
---|
46 | #include <sys/filio.h>
|
---|
47 | #include <sys/malloc.h>
|
---|
48 | #include <sys/proc.h>
|
---|
49 | #include <sys/socket.h>
|
---|
50 | #include <sys/sockio.h>
|
---|
51 | #include <sys/kern_event.h>
|
---|
52 | #include <net/kpi_interface.h>
|
---|
53 | RT_C_DECLS_BEGIN /* Buggy 10.4 headers, fixed in 10.5. */
|
---|
54 | #include <sys/kpi_mbuf.h>
|
---|
55 | #include <net/kpi_interfacefilter.h>
|
---|
56 | RT_C_DECLS_END
|
---|
57 |
|
---|
58 | #include <sys/kpi_socket.h>
|
---|
59 | #include <net/if.h>
|
---|
60 | #include <net/if_var.h>
|
---|
61 | RT_C_DECLS_BEGIN
|
---|
62 | #include <net/bpf.h>
|
---|
63 | RT_C_DECLS_END
|
---|
64 | #include <netinet/in.h>
|
---|
65 | #include <netinet/in_var.h>
|
---|
66 | #include <netinet6/in6_var.h>
|
---|
67 |
|
---|
68 | #define VBOXNETFLT_OS_SPECFIC 1
|
---|
69 | #include "../VBoxNetFltInternal.h"
|
---|
70 |
|
---|
71 |
|
---|
72 | /*********************************************************************************************************************************
|
---|
73 | * Defined Constants And Macros *
|
---|
74 | *********************************************************************************************************************************/
|
---|
75 | /** The maximum number of SG segments.
|
---|
76 | * Used to prevent stack overflow and similar bad stuff. */
|
---|
77 | #define VBOXNETFLT_DARWIN_MAX_SEGS 32
|
---|
78 |
|
---|
79 | #if 0
|
---|
80 | /** For testing extremely segmented frames. */
|
---|
81 | #define VBOXNETFLT_DARWIN_TEST_SEG_SIZE 14
|
---|
82 | #endif
|
---|
83 |
|
---|
84 | /* XXX: hidden undef #ifdef __APPLE__ */
|
---|
85 | #define VBOX_IN_LOOPBACK(addr) (((addr) & IN_CLASSA_NET) == 0x7f000000)
|
---|
86 | #define VBOX_IN_LINKLOCAL(addr) (((addr) & IN_CLASSB_NET) == 0xa9fe0000)
|
---|
87 |
|
---|
88 |
|
---|
89 |
|
---|
90 | /*********************************************************************************************************************************
|
---|
91 | * Internal Functions *
|
---|
92 | *********************************************************************************************************************************/
|
---|
93 | RT_C_DECLS_BEGIN
|
---|
94 | static kern_return_t VBoxNetFltDarwinStart(struct kmod_info *pKModInfo, void *pvData);
|
---|
95 | static kern_return_t VBoxNetFltDarwinStop(struct kmod_info *pKModInfo, void *pvData);
|
---|
96 |
|
---|
97 | static void vboxNetFltDarwinSysSockUpcall(socket_t pSysSock, void *pvData, int fWait);
|
---|
98 | RT_C_DECLS_END
|
---|
99 |
|
---|
100 |
|
---|
101 | /*********************************************************************************************************************************
|
---|
102 | * Structures and Typedefs *
|
---|
103 | *********************************************************************************************************************************/
|
---|
104 | /**
|
---|
105 | * The mbuf tag data.
|
---|
106 | *
|
---|
107 | * We have to associate the ethernet header with each packet we're sending
|
---|
108 | * because things like icmp will inherit the tag it self so the tag along
|
---|
109 | * isn't sufficient to identify our mbufs. For the icmp scenario the ethernet
|
---|
110 | * header naturally changes before the packet is send pack, so let check it.
|
---|
111 | */
|
---|
112 | typedef struct VBOXNETFLTTAG
|
---|
113 | {
|
---|
114 | /** The ethernet header of the outgoing frame. */
|
---|
115 | RTNETETHERHDR EthHdr;
|
---|
116 | } VBOXNETFLTTAG;
|
---|
117 | /** Pointer to a VBoxNetFlt mbuf tag. */
|
---|
118 | typedef VBOXNETFLTTAG *PVBOXNETFLTTAG;
|
---|
119 | /** Pointer to a const VBoxNetFlt mbuf tag. */
|
---|
120 | typedef VBOXNETFLTTAG const *PCVBOXNETFLTTAG;
|
---|
121 |
|
---|
122 |
|
---|
123 | /*********************************************************************************************************************************
|
---|
124 | * Global Variables *
|
---|
125 | *********************************************************************************************************************************/
|
---|
126 | /**
|
---|
127 | * Declare the module stuff.
|
---|
128 | */
|
---|
129 | RT_C_DECLS_BEGIN
|
---|
130 | extern kern_return_t _start(struct kmod_info *pKModInfo, void *pvData);
|
---|
131 | extern kern_return_t _stop(struct kmod_info *pKModInfo, void *pvData);
|
---|
132 |
|
---|
133 | KMOD_EXPLICIT_DECL(VBoxNetFlt, VBOX_VERSION_STRING, _start, _stop)
|
---|
134 | DECLHIDDEN(kmod_start_func_t *) _realmain = VBoxNetFltDarwinStart;
|
---|
135 | DECLHIDDEN(kmod_stop_func_t *) _antimain = VBoxNetFltDarwinStop;
|
---|
136 | DECLHIDDEN(int) _kext_apple_cc = __APPLE_CC__;
|
---|
137 | RT_C_DECLS_END
|
---|
138 |
|
---|
139 |
|
---|
140 | /**
|
---|
141 | * The (common) global data.
|
---|
142 | */
|
---|
143 | static VBOXNETFLTGLOBALS g_VBoxNetFltGlobals;
|
---|
144 |
|
---|
145 | /** The unique tag id for this module.
|
---|
146 | * This is basically a unique string hash that lives on until reboot.
|
---|
147 | * It is used for tagging mbufs. */
|
---|
148 | static mbuf_tag_id_t g_idTag;
|
---|
149 |
|
---|
150 | /** The offset of the struct ifnet::if_pcount variable.
|
---|
151 | * @remarks Initial value is valid for Lion and earlier. We adjust it on attach
|
---|
152 | * for later releases. */
|
---|
153 | static unsigned g_offIfNetPCount = sizeof(void *) * (1 /*if_softc*/ + 1 /*if_name*/ + 2 /*if_link*/ + 2 /*if_addrhead*/ + 1 /*if_check_multi*/)
|
---|
154 | + sizeof(u_long) /*if_refcnt*/;
|
---|
155 | /** Macro for accessing ifnet::if_pcount. */
|
---|
156 | #define VBOX_GET_PCOUNT(pIfNet) ( *(int *)((uintptr_t)pIfNet + g_offIfNetPCount) )
|
---|
157 | /** The size of area of ifnet structure we try to locate if_pcount in. */
|
---|
158 | #define VBOXNETFLT_DARWIN_IFNET_SIZE 256
|
---|
159 | /** Indicates whether g_offIfNetPCount has been adjusted already (no point in
|
---|
160 | * doing it more than once). */
|
---|
161 | static bool g_fNetPCountFound = false;
|
---|
162 |
|
---|
163 |
|
---|
164 | /**
|
---|
165 | * Change the promiscuous setting and try spot the changed in @a pIfNet.
|
---|
166 | *
|
---|
167 | * @returns Offset of potential p_count field.
|
---|
168 | * @param pIfNet The interface we're attaching to.
|
---|
169 | * @param iPromisc Whether to enable (1) or disable (0) promiscuous mode.
|
---|
170 | *
|
---|
171 | * @note This implementation relies on if_pcount to be aligned on sizeof(int).
|
---|
172 | */
|
---|
173 | static unsigned vboxNetFltDarwinSetAndDiff(ifnet_t pIfNet, int iPromisc)
|
---|
174 | {
|
---|
175 | int aiSavedState[VBOXNETFLT_DARWIN_IFNET_SIZE / sizeof(int)];
|
---|
176 | memcpy(aiSavedState, pIfNet, sizeof(aiSavedState));
|
---|
177 |
|
---|
178 | ifnet_set_promiscuous(pIfNet, iPromisc);
|
---|
179 |
|
---|
180 | int const iDiff = iPromisc ? 1 : -1;
|
---|
181 |
|
---|
182 | /*
|
---|
183 | * We assume that ifnet structure will never have less members in front of if_pcount
|
---|
184 | * than it used to have in Lion. If this turns out to be false assumption we will
|
---|
185 | * have to start from zero offset.
|
---|
186 | */
|
---|
187 | for (unsigned i = g_offIfNetPCount / sizeof(int); i < RT_ELEMENTS(aiSavedState); i++)
|
---|
188 | if (((int*)pIfNet)[i] - aiSavedState[i] == iDiff)
|
---|
189 | return i * sizeof(int);
|
---|
190 |
|
---|
191 | return 0;
|
---|
192 | }
|
---|
193 |
|
---|
194 |
|
---|
195 | /**
|
---|
196 | * Detect and adjust the offset of ifnet::if_pcount.
|
---|
197 | *
|
---|
198 | * @param pIfNet The interface we're attaching to.
|
---|
199 | */
|
---|
200 | static void vboxNetFltDarwinDetectPCountOffset(ifnet_t pIfNet)
|
---|
201 | {
|
---|
202 | if (g_fNetPCountFound)
|
---|
203 | return;
|
---|
204 |
|
---|
205 | /*
|
---|
206 | * It would be nice to use locking at this point, but it is not available via KPI.
|
---|
207 | * This is why we try several times. At each attempt we modify if_pcount four times
|
---|
208 | * to rule out false detections.
|
---|
209 | */
|
---|
210 | unsigned offTry1, offTry2, offTry3, offTry4;
|
---|
211 | for (int iAttempt = 0; iAttempt < 3; iAttempt++)
|
---|
212 | {
|
---|
213 | offTry1 = vboxNetFltDarwinSetAndDiff(pIfNet, 1);
|
---|
214 | offTry2 = vboxNetFltDarwinSetAndDiff(pIfNet, 1);
|
---|
215 | offTry3 = vboxNetFltDarwinSetAndDiff(pIfNet, 0);
|
---|
216 | offTry4 = vboxNetFltDarwinSetAndDiff(pIfNet, 0);
|
---|
217 | if (offTry1 == offTry2 && offTry2 == offTry3 && offTry3 == offTry4)
|
---|
218 | {
|
---|
219 | if (g_offIfNetPCount != offTry1)
|
---|
220 | {
|
---|
221 | Log(("VBoxNetFltDarwinDetectPCountOffset: Adjusted if_pcount offset to %x from %x.\n", offTry1, g_offIfNetPCount));
|
---|
222 | g_offIfNetPCount = offTry1;
|
---|
223 | g_fNetPCountFound = true;
|
---|
224 | }
|
---|
225 | break;
|
---|
226 | }
|
---|
227 | }
|
---|
228 |
|
---|
229 | if (g_offIfNetPCount != offTry1)
|
---|
230 | LogRel(("VBoxNetFlt: Failed to detect promiscuous count, all traffic may reach wire (%x != %x).\n", g_offIfNetPCount, offTry1));
|
---|
231 | }
|
---|
232 |
|
---|
233 |
|
---|
234 | /**
|
---|
235 | * Start the kernel module.
|
---|
236 | */
|
---|
237 | static kern_return_t VBoxNetFltDarwinStart(struct kmod_info *pKModInfo, void *pvData)
|
---|
238 | {
|
---|
239 | int rc;
|
---|
240 |
|
---|
241 | /*
|
---|
242 | * Initialize IPRT and find our module tag id.
|
---|
243 | * (IPRT is shared with VBoxDrv, it creates the loggers.)
|
---|
244 | */
|
---|
245 | rc = RTR0Init(0);
|
---|
246 | if (RT_SUCCESS(rc))
|
---|
247 | {
|
---|
248 | Log(("VBoxNetFltDarwinStart\n"));
|
---|
249 | errno_t err = mbuf_tag_id_find("org.VirtualBox.kext.VBoxFltDrv", &g_idTag);
|
---|
250 | if (!err)
|
---|
251 | {
|
---|
252 | /*
|
---|
253 | * Initialize the globals and connect to the support driver.
|
---|
254 | *
|
---|
255 | * This will call back vboxNetFltOsOpenSupDrv (and maybe vboxNetFltOsCloseSupDrv)
|
---|
256 | * for establishing the connect to the support driver.
|
---|
257 | */
|
---|
258 | memset(&g_VBoxNetFltGlobals, 0, sizeof(g_VBoxNetFltGlobals));
|
---|
259 | rc = vboxNetFltInitGlobalsAndIdc(&g_VBoxNetFltGlobals);
|
---|
260 | if (RT_SUCCESS(rc))
|
---|
261 | {
|
---|
262 | LogRel(("VBoxFltDrv: version " VBOX_VERSION_STRING " r%d\n", VBOX_SVN_REV));
|
---|
263 | return KMOD_RETURN_SUCCESS;
|
---|
264 | }
|
---|
265 |
|
---|
266 | LogRel(("VBoxFltDrv: failed to initialize device extension (rc=%d)\n", rc));
|
---|
267 | }
|
---|
268 | else
|
---|
269 | LogRel(("VBoxFltDrv: mbuf_tag_id_find failed, err=%d\n", err));
|
---|
270 | RTR0Term();
|
---|
271 | }
|
---|
272 | else
|
---|
273 | printf("VBoxFltDrv: failed to initialize IPRT (rc=%d)\n", rc);
|
---|
274 |
|
---|
275 | memset(&g_VBoxNetFltGlobals, 0, sizeof(g_VBoxNetFltGlobals));
|
---|
276 | return KMOD_RETURN_FAILURE;
|
---|
277 | }
|
---|
278 |
|
---|
279 |
|
---|
280 | /**
|
---|
281 | * Stop the kernel module.
|
---|
282 | */
|
---|
283 | static kern_return_t VBoxNetFltDarwinStop(struct kmod_info *pKModInfo, void *pvData)
|
---|
284 | {
|
---|
285 | Log(("VBoxNetFltDarwinStop\n"));
|
---|
286 |
|
---|
287 | /*
|
---|
288 | * Refuse to unload if anyone is currently using the filter driver.
|
---|
289 | * This is important as I/O kit / xnu will to be able to do usage
|
---|
290 | * tracking for us!
|
---|
291 | */
|
---|
292 | int rc = vboxNetFltTryDeleteIdcAndGlobals(&g_VBoxNetFltGlobals);
|
---|
293 | if (RT_FAILURE(rc))
|
---|
294 | {
|
---|
295 | Log(("VBoxNetFltDarwinStop - failed, busy.\n"));
|
---|
296 | return KMOD_RETURN_FAILURE;
|
---|
297 | }
|
---|
298 |
|
---|
299 | /*
|
---|
300 | * Undo the work done during start (in reverse order).
|
---|
301 | */
|
---|
302 | memset(&g_VBoxNetFltGlobals, 0, sizeof(g_VBoxNetFltGlobals));
|
---|
303 |
|
---|
304 | RTR0Term();
|
---|
305 |
|
---|
306 | return KMOD_RETURN_SUCCESS;
|
---|
307 | }
|
---|
308 |
|
---|
309 |
|
---|
310 | /**
|
---|
311 | * Reads and retains the host interface handle.
|
---|
312 | *
|
---|
313 | * @returns The handle, NULL if detached.
|
---|
314 | * @param pThis
|
---|
315 | */
|
---|
316 | DECLINLINE(ifnet_t) vboxNetFltDarwinRetainIfNet(PVBOXNETFLTINS pThis)
|
---|
317 | {
|
---|
318 | ifnet_t pIfNet = NULL;
|
---|
319 |
|
---|
320 | /*
|
---|
321 | * Be careful here to avoid problems racing the detached callback.
|
---|
322 | */
|
---|
323 | RTSpinlockAcquire(pThis->hSpinlock);
|
---|
324 | if (!ASMAtomicUoReadBool(&pThis->fDisconnectedFromHost))
|
---|
325 | {
|
---|
326 | pIfNet = ASMAtomicUoReadPtrT(&pThis->u.s.pIfNet, ifnet_t);
|
---|
327 | if (pIfNet)
|
---|
328 | ifnet_reference(pIfNet);
|
---|
329 | }
|
---|
330 | RTSpinlockRelease(pThis->hSpinlock);
|
---|
331 |
|
---|
332 | return pIfNet;
|
---|
333 | }
|
---|
334 |
|
---|
335 |
|
---|
336 | /**
|
---|
337 | * Release the host interface handle previously retained
|
---|
338 | * by vboxNetFltDarwinRetainIfNet.
|
---|
339 | *
|
---|
340 | * @param pThis The instance.
|
---|
341 | * @param pIfNet The vboxNetFltDarwinRetainIfNet return value, NULL is fine.
|
---|
342 | */
|
---|
343 | DECLINLINE(void) vboxNetFltDarwinReleaseIfNet(PVBOXNETFLTINS pThis, ifnet_t pIfNet)
|
---|
344 | {
|
---|
345 | NOREF(pThis);
|
---|
346 | if (pIfNet)
|
---|
347 | ifnet_release(pIfNet);
|
---|
348 | }
|
---|
349 |
|
---|
350 |
|
---|
351 | /**
|
---|
352 | * Checks whether this is an mbuf created by vboxNetFltDarwinMBufFromSG,
|
---|
353 | * i.e. a buffer which we're pushing and should be ignored by the filter callbacks.
|
---|
354 | *
|
---|
355 | * @returns true / false accordingly.
|
---|
356 | * @param pThis The instance.
|
---|
357 | * @param pMBuf The mbuf.
|
---|
358 | * @param pvFrame The frame pointer, optional.
|
---|
359 | */
|
---|
360 | DECLINLINE(bool) vboxNetFltDarwinMBufIsOur(PVBOXNETFLTINS pThis, mbuf_t pMBuf, void *pvFrame)
|
---|
361 | {
|
---|
362 | NOREF(pThis);
|
---|
363 |
|
---|
364 | /*
|
---|
365 | * Lookup the tag set by vboxNetFltDarwinMBufFromSG.
|
---|
366 | */
|
---|
367 | PCVBOXNETFLTTAG pTagData;
|
---|
368 | size_t cbTagData;
|
---|
369 | errno_t err = mbuf_tag_find(pMBuf, g_idTag, 0 /* type */, &cbTagData, (void **)&pTagData);
|
---|
370 | if (err)
|
---|
371 | return false;
|
---|
372 | AssertReturn(cbTagData == sizeof(*pTagData), false);
|
---|
373 |
|
---|
374 | /*
|
---|
375 | * Dig out the ethernet header from the mbuf.
|
---|
376 | */
|
---|
377 | PCRTNETETHERHDR pEthHdr = (PCRTNETETHERHDR)pvFrame;
|
---|
378 | if (!pEthHdr)
|
---|
379 | pEthHdr = (PCRTNETETHERHDR)mbuf_pkthdr_header(pMBuf);
|
---|
380 | if (!pEthHdr)
|
---|
381 | pEthHdr = (PCRTNETETHERHDR)mbuf_data(pMBuf);
|
---|
382 | /* ASSUMING that there is enough data to work on! */
|
---|
383 | if ( pEthHdr->DstMac.au8[0] != pTagData->EthHdr.DstMac.au8[0]
|
---|
384 | || pEthHdr->DstMac.au8[1] != pTagData->EthHdr.DstMac.au8[1]
|
---|
385 | || pEthHdr->DstMac.au8[2] != pTagData->EthHdr.DstMac.au8[2]
|
---|
386 | || pEthHdr->DstMac.au8[3] != pTagData->EthHdr.DstMac.au8[3]
|
---|
387 | || pEthHdr->DstMac.au8[4] != pTagData->EthHdr.DstMac.au8[4]
|
---|
388 | || pEthHdr->DstMac.au8[5] != pTagData->EthHdr.DstMac.au8[5]
|
---|
389 | || pEthHdr->SrcMac.au8[0] != pTagData->EthHdr.SrcMac.au8[0]
|
---|
390 | || pEthHdr->SrcMac.au8[1] != pTagData->EthHdr.SrcMac.au8[1]
|
---|
391 | || pEthHdr->SrcMac.au8[2] != pTagData->EthHdr.SrcMac.au8[2]
|
---|
392 | || pEthHdr->SrcMac.au8[3] != pTagData->EthHdr.SrcMac.au8[3]
|
---|
393 | || pEthHdr->SrcMac.au8[4] != pTagData->EthHdr.SrcMac.au8[4]
|
---|
394 | || pEthHdr->SrcMac.au8[5] != pTagData->EthHdr.SrcMac.au8[5]
|
---|
395 | || pEthHdr->EtherType != pTagData->EthHdr.EtherType)
|
---|
396 | {
|
---|
397 | Log3(("tagged, but the ethernet header has changed\n"));
|
---|
398 | return false;
|
---|
399 | }
|
---|
400 |
|
---|
401 | return true;
|
---|
402 | }
|
---|
403 |
|
---|
404 |
|
---|
405 | /**
|
---|
406 | * Internal worker that create a darwin mbuf for a (scatter/)gather list.
|
---|
407 | *
|
---|
408 | * @returns Pointer to the mbuf.
|
---|
409 | * @param pThis The instance.
|
---|
410 | * @param pSG The (scatter/)gather list.
|
---|
411 | */
|
---|
412 | static mbuf_t vboxNetFltDarwinMBufFromSG(PVBOXNETFLTINS pThis, PINTNETSG pSG)
|
---|
413 | {
|
---|
414 | /// @todo future? mbuf_how_t How = preemption enabled ? MBUF_DONTWAIT : MBUF_WAITOK;
|
---|
415 | mbuf_how_t How = MBUF_WAITOK;
|
---|
416 |
|
---|
417 | /*
|
---|
418 | * We need some way of getting back to our instance data when
|
---|
419 | * the mbuf is freed, so use pvUserData for this.
|
---|
420 | * -- this is not relevant anylonger! --
|
---|
421 | */
|
---|
422 | Assert(!pSG->pvUserData || pSG->pvUserData == pThis);
|
---|
423 | Assert(!pSG->pvUserData2);
|
---|
424 | pSG->pvUserData = pThis;
|
---|
425 |
|
---|
426 | /*
|
---|
427 | * Allocate a packet and copy over the data.
|
---|
428 | *
|
---|
429 | * Using mbuf_attachcluster() here would've been nice but there are two
|
---|
430 | * issues with it: (1) it's 10.5.x only, and (2) the documentation indicates
|
---|
431 | * that it's not supposed to be used for really external buffers. The 2nd
|
---|
432 | * point might be argued against considering that the only m_clattach user
|
---|
433 | * is mallocs memory for the ext mbuf and not doing what's stated in the docs.
|
---|
434 | * However, it's hard to tell if these m_clattach buffers actually makes it
|
---|
435 | * to the NICs or not, and even if they did, the NIC would need the physical
|
---|
436 | * addresses for the pages they contain and might end up copying the data
|
---|
437 | * to a new mbuf anyway.
|
---|
438 | *
|
---|
439 | * So, in the end it's better to just do it the simple way that will work
|
---|
440 | * 100%, even if it involves some extra work (alloc + copy) we really wished
|
---|
441 | * to avoid.
|
---|
442 | *
|
---|
443 | * Note. We can't make use of the physical addresses on darwin because the
|
---|
444 | * way the mbuf / cluster stuff works (see mbuf_data_to_physical and
|
---|
445 | * mcl_to_paddr).
|
---|
446 | */
|
---|
447 | mbuf_t pPkt = NULL;
|
---|
448 | errno_t err = mbuf_allocpacket(How, pSG->cbTotal, NULL, &pPkt);
|
---|
449 | if (!err)
|
---|
450 | {
|
---|
451 | /* Skip zero sized memory buffers (paranoia). */
|
---|
452 | mbuf_t pCur = pPkt;
|
---|
453 | while (pCur && !mbuf_maxlen(pCur))
|
---|
454 | pCur = mbuf_next(pCur);
|
---|
455 | Assert(pCur);
|
---|
456 |
|
---|
457 | /* Set the required packet header attributes. */
|
---|
458 | mbuf_pkthdr_setlen(pPkt, pSG->cbTotal);
|
---|
459 | mbuf_pkthdr_setheader(pPkt, mbuf_data(pCur));
|
---|
460 |
|
---|
461 | /* Special case the single buffer copy. */
|
---|
462 | if ( mbuf_next(pCur)
|
---|
463 | && mbuf_maxlen(pCur) >= pSG->cbTotal)
|
---|
464 | {
|
---|
465 | mbuf_setlen(pCur, pSG->cbTotal);
|
---|
466 | IntNetSgRead(pSG, mbuf_data(pCur));
|
---|
467 | }
|
---|
468 | else
|
---|
469 | {
|
---|
470 | /* Multi buffer copying. */
|
---|
471 | size_t cbLeft = pSG->cbTotal;
|
---|
472 | size_t offSrc = 0;
|
---|
473 | while (cbLeft > 0 && pCur)
|
---|
474 | {
|
---|
475 | size_t cb = mbuf_maxlen(pCur);
|
---|
476 | if (cb > cbLeft)
|
---|
477 | cb = cbLeft;
|
---|
478 | mbuf_setlen(pCur, cb);
|
---|
479 | IntNetSgReadEx(pSG, offSrc, cb, mbuf_data(pCur));
|
---|
480 |
|
---|
481 | /* advance */
|
---|
482 | offSrc += cb;
|
---|
483 | cbLeft -= cb;
|
---|
484 | pCur = mbuf_next(pCur);
|
---|
485 | }
|
---|
486 | Assert(cbLeft == 0);
|
---|
487 | }
|
---|
488 | if (!err)
|
---|
489 | {
|
---|
490 | /*
|
---|
491 | * Tag the packet and return successfully.
|
---|
492 | */
|
---|
493 | PVBOXNETFLTTAG pTagData;
|
---|
494 | err = mbuf_tag_allocate(pPkt, g_idTag, 0 /* type */, sizeof(VBOXNETFLTTAG) /* tag len */, How, (void **)&pTagData);
|
---|
495 | if (!err)
|
---|
496 | {
|
---|
497 | Assert(pSG->aSegs[0].cb >= sizeof(pTagData->EthHdr));
|
---|
498 | memcpy(&pTagData->EthHdr, pSG->aSegs[0].pv, sizeof(pTagData->EthHdr));
|
---|
499 | return pPkt;
|
---|
500 | }
|
---|
501 |
|
---|
502 | /* bailout: */
|
---|
503 | AssertMsg(err == ENOMEM || err == EWOULDBLOCK, ("err=%d\n", err));
|
---|
504 | }
|
---|
505 |
|
---|
506 | mbuf_freem(pPkt);
|
---|
507 | }
|
---|
508 | else
|
---|
509 | AssertMsg(err == ENOMEM || err == EWOULDBLOCK, ("err=%d\n", err));
|
---|
510 | pSG->pvUserData = NULL;
|
---|
511 |
|
---|
512 | return NULL;
|
---|
513 | }
|
---|
514 |
|
---|
515 |
|
---|
516 | /**
|
---|
517 | * Calculates the number of segments required to represent the mbuf.
|
---|
518 | *
|
---|
519 | * @returns Number of segments.
|
---|
520 | * @param pThis The instance.
|
---|
521 | * @param pMBuf The mbuf.
|
---|
522 | * @param pvFrame The frame pointer, optional.
|
---|
523 | */
|
---|
524 | DECLINLINE(unsigned) vboxNetFltDarwinMBufCalcSGSegs(PVBOXNETFLTINS pThis, mbuf_t pMBuf, void *pvFrame)
|
---|
525 | {
|
---|
526 | NOREF(pThis);
|
---|
527 |
|
---|
528 | /*
|
---|
529 | * Count the buffers in the chain.
|
---|
530 | */
|
---|
531 | unsigned cSegs = 0;
|
---|
532 | for (mbuf_t pCur = pMBuf; pCur; pCur = mbuf_next(pCur))
|
---|
533 | if (mbuf_len(pCur))
|
---|
534 | cSegs++;
|
---|
535 | else if ( !cSegs
|
---|
536 | && pvFrame
|
---|
537 | && (uintptr_t)pvFrame - (uintptr_t)mbuf_datastart(pMBuf) < mbuf_maxlen(pMBuf))
|
---|
538 | cSegs++;
|
---|
539 |
|
---|
540 | #ifdef PADD_RUNT_FRAMES_FROM_HOST
|
---|
541 | /*
|
---|
542 | * Add one buffer if the total is less than the ethernet minimum 60 bytes.
|
---|
543 | * This may allocate a segment too much if the ethernet header is separated,
|
---|
544 | * but that shouldn't harm us much.
|
---|
545 | */
|
---|
546 | if (mbuf_pkthdr_len(pMBuf) < 60)
|
---|
547 | cSegs++;
|
---|
548 | #endif
|
---|
549 |
|
---|
550 | #ifdef VBOXNETFLT_DARWIN_TEST_SEG_SIZE
|
---|
551 | /* maximize the number of segments. */
|
---|
552 | cSegs = RT_MAX(VBOXNETFLT_DARWIN_MAX_SEGS - 1, cSegs);
|
---|
553 | #endif
|
---|
554 |
|
---|
555 | return cSegs ? cSegs : 1;
|
---|
556 | }
|
---|
557 |
|
---|
558 |
|
---|
559 | /**
|
---|
560 | * Initializes a SG list from an mbuf.
|
---|
561 | *
|
---|
562 | * @returns Number of segments.
|
---|
563 | * @param pThis The instance.
|
---|
564 | * @param pMBuf The mbuf.
|
---|
565 | * @param pSG The SG.
|
---|
566 | * @param pvFrame The frame pointer, optional.
|
---|
567 | * @param cSegs The number of segments allocated for the SG.
|
---|
568 | * This should match the number in the mbuf exactly!
|
---|
569 | * @param fSrc The source of the frame.
|
---|
570 | */
|
---|
571 | DECLINLINE(void) vboxNetFltDarwinMBufToSG(PVBOXNETFLTINS pThis, mbuf_t pMBuf, void *pvFrame, PINTNETSG pSG, unsigned cSegs, uint32_t fSrc)
|
---|
572 | {
|
---|
573 | NOREF(pThis);
|
---|
574 |
|
---|
575 | /*
|
---|
576 | * Walk the chain and convert the buffers to segments. Works INTNETSG::cbTotal.
|
---|
577 | */
|
---|
578 | unsigned iSeg = 0;
|
---|
579 | IntNetSgInitTempSegs(pSG, 0 /*cbTotal*/, cSegs, 0 /*cSegsUsed*/);
|
---|
580 | for (mbuf_t pCur = pMBuf; pCur; pCur = mbuf_next(pCur))
|
---|
581 | {
|
---|
582 | size_t cbSeg = mbuf_len(pCur);
|
---|
583 | if (cbSeg)
|
---|
584 | {
|
---|
585 | void *pvSeg = mbuf_data(pCur);
|
---|
586 |
|
---|
587 | /* deal with pvFrame */
|
---|
588 | if (!iSeg && pvFrame && pvFrame != pvSeg)
|
---|
589 | {
|
---|
590 | void *pvStart = mbuf_datastart(pMBuf);
|
---|
591 | uintptr_t offSeg = (uintptr_t)pvSeg - (uintptr_t)pvStart;
|
---|
592 | uintptr_t offSegEnd = offSeg + cbSeg;
|
---|
593 | Assert(pvStart && pvSeg && offSeg < mbuf_maxlen(pMBuf) && offSegEnd <= mbuf_maxlen(pMBuf)); NOREF(offSegEnd);
|
---|
594 | uintptr_t offFrame = (uintptr_t)pvFrame - (uintptr_t)pvStart;
|
---|
595 | if (RT_LIKELY(offFrame < offSeg))
|
---|
596 | {
|
---|
597 | pvSeg = pvFrame;
|
---|
598 | cbSeg += offSeg - offFrame;
|
---|
599 | }
|
---|
600 | else
|
---|
601 | AssertMsgFailed(("pvFrame=%p pvStart=%p pvSeg=%p offSeg=%p cbSeg=%#zx offSegEnd=%p offFrame=%p maxlen=%#zx\n",
|
---|
602 | pvFrame, pvStart, pvSeg, offSeg, cbSeg, offSegEnd, offFrame, mbuf_maxlen(pMBuf)));
|
---|
603 | pvFrame = NULL;
|
---|
604 | }
|
---|
605 |
|
---|
606 | AssertBreak(iSeg < cSegs);
|
---|
607 | pSG->cbTotal += cbSeg;
|
---|
608 | pSG->aSegs[iSeg].cb = cbSeg;
|
---|
609 | pSG->aSegs[iSeg].pv = pvSeg;
|
---|
610 | pSG->aSegs[iSeg].Phys = NIL_RTHCPHYS;
|
---|
611 | iSeg++;
|
---|
612 | }
|
---|
613 | /* The pvFrame might be in a now empty buffer. */
|
---|
614 | else if ( !iSeg
|
---|
615 | && pvFrame
|
---|
616 | && (uintptr_t)pvFrame - (uintptr_t)mbuf_datastart(pMBuf) < mbuf_maxlen(pMBuf))
|
---|
617 | {
|
---|
618 | cbSeg = (uintptr_t)mbuf_datastart(pMBuf) + mbuf_maxlen(pMBuf) - (uintptr_t)pvFrame;
|
---|
619 | pSG->cbTotal += cbSeg;
|
---|
620 | pSG->aSegs[iSeg].cb = cbSeg;
|
---|
621 | pSG->aSegs[iSeg].pv = pvFrame;
|
---|
622 | pSG->aSegs[iSeg].Phys = NIL_RTHCPHYS;
|
---|
623 | iSeg++;
|
---|
624 | pvFrame = NULL;
|
---|
625 | }
|
---|
626 | }
|
---|
627 |
|
---|
628 | Assert(iSeg && iSeg <= cSegs);
|
---|
629 | pSG->cSegsUsed = iSeg;
|
---|
630 |
|
---|
631 | #ifdef PADD_RUNT_FRAMES_FROM_HOST
|
---|
632 | /*
|
---|
633 | * Add a trailer if the frame is too small.
|
---|
634 | *
|
---|
635 | * Since we're getting to the packet before it is framed, it has not
|
---|
636 | * yet been padded. The current solution is to add a segment pointing
|
---|
637 | * to a buffer containing all zeros and pray that works for all frames...
|
---|
638 | */
|
---|
639 | if (pSG->cbTotal < 60 && (fSrc == INTNETTRUNKDIR_HOST))
|
---|
640 | {
|
---|
641 | AssertReturnVoid(iSeg < cSegs);
|
---|
642 |
|
---|
643 | static uint8_t const s_abZero[128] = {0};
|
---|
644 | pSG->aSegs[iSeg].Phys = NIL_RTHCPHYS;
|
---|
645 | pSG->aSegs[iSeg].pv = (void *)&s_abZero[0];
|
---|
646 | pSG->aSegs[iSeg].cb = 60 - pSG->cbTotal;
|
---|
647 | pSG->cbTotal = 60;
|
---|
648 | pSG->cSegsUsed++;
|
---|
649 | }
|
---|
650 | #endif
|
---|
651 |
|
---|
652 | #ifdef VBOXNETFLT_DARWIN_TEST_SEG_SIZE
|
---|
653 | /*
|
---|
654 | * Redistribute the segments.
|
---|
655 | */
|
---|
656 | if (pSG->cSegsUsed < pSG->cSegsAlloc)
|
---|
657 | {
|
---|
658 | /* copy the segments to the end. */
|
---|
659 | int iSrc = pSG->cSegsUsed;
|
---|
660 | int iDst = pSG->cSegsAlloc;
|
---|
661 | while (iSrc > 0)
|
---|
662 | {
|
---|
663 | iDst--;
|
---|
664 | iSrc--;
|
---|
665 | pSG->aSegs[iDst] = pSG->aSegs[iSrc];
|
---|
666 | }
|
---|
667 |
|
---|
668 | /* create small segments from the start. */
|
---|
669 | pSG->cSegsUsed = pSG->cSegsAlloc;
|
---|
670 | iSrc = iDst;
|
---|
671 | iDst = 0;
|
---|
672 | while ( iDst < iSrc
|
---|
673 | && iDst < pSG->cSegsAlloc)
|
---|
674 | {
|
---|
675 | pSG->aSegs[iDst].Phys = NIL_RTHCPHYS;
|
---|
676 | pSG->aSegs[iDst].pv = pSG->aSegs[iSrc].pv;
|
---|
677 | pSG->aSegs[iDst].cb = RT_MIN(pSG->aSegs[iSrc].cb, VBOXNETFLT_DARWIN_TEST_SEG_SIZE);
|
---|
678 | if (pSG->aSegs[iDst].cb != pSG->aSegs[iSrc].cb)
|
---|
679 | {
|
---|
680 | pSG->aSegs[iSrc].cb -= pSG->aSegs[iDst].cb;
|
---|
681 | pSG->aSegs[iSrc].pv = (uint8_t *)pSG->aSegs[iSrc].pv + pSG->aSegs[iDst].cb;
|
---|
682 | }
|
---|
683 | else if (++iSrc >= pSG->cSegsAlloc)
|
---|
684 | {
|
---|
685 | pSG->cSegsUsed = iDst + 1;
|
---|
686 | break;
|
---|
687 | }
|
---|
688 | iDst++;
|
---|
689 | }
|
---|
690 | }
|
---|
691 | #endif
|
---|
692 |
|
---|
693 | AssertMsg(!pvFrame, ("pvFrame=%p pMBuf=%p iSeg=%d\n", pvFrame, pMBuf, iSeg));
|
---|
694 | }
|
---|
695 |
|
---|
696 |
|
---|
697 | /**
|
---|
698 | * Helper for determining whether the host wants the interface to be
|
---|
699 | * promiscuous.
|
---|
700 | */
|
---|
701 | static bool vboxNetFltDarwinIsPromiscuous(PVBOXNETFLTINS pThis)
|
---|
702 | {
|
---|
703 | bool fRc = false;
|
---|
704 | ifnet_t pIfNet = vboxNetFltDarwinRetainIfNet(pThis);
|
---|
705 | if (pIfNet)
|
---|
706 | {
|
---|
707 | /* gather the data */
|
---|
708 | uint16_t fIf = ifnet_flags(pIfNet);
|
---|
709 | unsigned cPromisc = VBOX_GET_PCOUNT(pIfNet);
|
---|
710 | bool fSetPromiscuous = ASMAtomicUoReadBool(&pThis->u.s.fSetPromiscuous);
|
---|
711 | vboxNetFltDarwinReleaseIfNet(pThis, pIfNet);
|
---|
712 |
|
---|
713 | /* calc the return. */
|
---|
714 | fRc = (fIf & IFF_PROMISC)
|
---|
715 | && cPromisc > fSetPromiscuous;
|
---|
716 | }
|
---|
717 | return fRc;
|
---|
718 | }
|
---|
719 |
|
---|
720 |
|
---|
721 |
|
---|
722 | /**
|
---|
723 | *
|
---|
724 | * @see iff_detached_func in the darwin kpi.
|
---|
725 | */
|
---|
726 | static void vboxNetFltDarwinIffDetached(void *pvThis, ifnet_t pIfNet)
|
---|
727 | {
|
---|
728 | PVBOXNETFLTINS pThis = (PVBOXNETFLTINS)pvThis;
|
---|
729 | uint64_t NanoTS = RTTimeSystemNanoTS();
|
---|
730 | LogFlow(("vboxNetFltDarwinIffDetached: pThis=%p NanoTS=%RU64 (%d)\n",
|
---|
731 | pThis, NanoTS, VALID_PTR(pIfNet) ? VBOX_GET_PCOUNT(pIfNet) : -1));
|
---|
732 |
|
---|
733 | Assert(!pThis->fDisconnectedFromHost);
|
---|
734 | Assert(!pThis->fRediscoveryPending);
|
---|
735 |
|
---|
736 | /*
|
---|
737 | * If we've put it into promiscuous mode, undo that now. If we don't
|
---|
738 | * the if_pcount will go all wrong when it's replugged.
|
---|
739 | */
|
---|
740 | if (ASMAtomicXchgBool(&pThis->u.s.fSetPromiscuous, false))
|
---|
741 | ifnet_set_promiscuous(pIfNet, 0);
|
---|
742 |
|
---|
743 | /*
|
---|
744 | * We carefully take the spinlock and increase the interface reference
|
---|
745 | * behind it in order to avoid problematic races with the detached callback.
|
---|
746 | */
|
---|
747 | RTSpinlockAcquire(pThis->hSpinlock);
|
---|
748 |
|
---|
749 | pIfNet = ASMAtomicUoReadPtrT(&pThis->u.s.pIfNet, ifnet_t);
|
---|
750 | int cPromisc = VALID_PTR(pIfNet) ? VBOX_GET_PCOUNT(pIfNet) : - 1;
|
---|
751 |
|
---|
752 | ASMAtomicUoWriteNullPtr(&pThis->u.s.pIfNet);
|
---|
753 | ASMAtomicUoWriteNullPtr(&pThis->u.s.pIfFilter);
|
---|
754 | ASMAtomicWriteBool(&pThis->u.s.fNeedSetPromiscuous, false);
|
---|
755 | pThis->u.s.fSetPromiscuous = false;
|
---|
756 | ASMAtomicUoWriteU64(&pThis->NanoTSLastRediscovery, NanoTS);
|
---|
757 | ASMAtomicUoWriteBool(&pThis->fRediscoveryPending, false);
|
---|
758 | ASMAtomicWriteBool(&pThis->fDisconnectedFromHost, true);
|
---|
759 |
|
---|
760 | RTSpinlockRelease(pThis->hSpinlock);
|
---|
761 |
|
---|
762 | if (pIfNet)
|
---|
763 | ifnet_release(pIfNet);
|
---|
764 | LogRel(("VBoxNetFlt: was detached from '%s' (%d)\n", pThis->szName, cPromisc));
|
---|
765 | }
|
---|
766 |
|
---|
767 |
|
---|
768 | /**
|
---|
769 | *
|
---|
770 | * @see iff_ioctl_func in the darwin kpi.
|
---|
771 | */
|
---|
772 | static errno_t vboxNetFltDarwinIffIoCtl(void *pvThis, ifnet_t pIfNet, protocol_family_t eProtocol, u_long uCmd, void *pvArg)
|
---|
773 | {
|
---|
774 | PVBOXNETFLTINS pThis = (PVBOXNETFLTINS)pvThis;
|
---|
775 | LogFlow(("vboxNetFltDarwinIffIoCtl: pThis=%p uCmd=%lx\n", pThis, uCmd));
|
---|
776 |
|
---|
777 | /*
|
---|
778 | * Update fOtherPromiscuous.
|
---|
779 | */
|
---|
780 | /** @todo we'll have to find the offset of if_pcount to get this right! */
|
---|
781 | //if (uCmd == SIOCSIFFLAGS)
|
---|
782 | //{
|
---|
783 | //
|
---|
784 | //}
|
---|
785 |
|
---|
786 | /*
|
---|
787 | * We didn't handle it, continue processing.
|
---|
788 | */
|
---|
789 | NOREF(pThis);
|
---|
790 | NOREF(eProtocol);
|
---|
791 | NOREF(uCmd);
|
---|
792 | NOREF(pvArg);
|
---|
793 | return EOPNOTSUPP;
|
---|
794 | }
|
---|
795 |
|
---|
796 |
|
---|
797 | /**
|
---|
798 | *
|
---|
799 | * @see iff_event_func in the darwin kpi.
|
---|
800 | */
|
---|
801 | static void vboxNetFltDarwinIffEvent(void *pvThis, ifnet_t pIfNet, protocol_family_t eProtocol, const struct kev_msg *pEvMsg)
|
---|
802 | {
|
---|
803 | PVBOXNETFLTINS pThis = (PVBOXNETFLTINS)pvThis;
|
---|
804 | LogFlow(("vboxNetFltDarwinIffEvent: pThis=%p\n", pThis));
|
---|
805 |
|
---|
806 | NOREF(pThis);
|
---|
807 | NOREF(pIfNet);
|
---|
808 | NOREF(eProtocol);
|
---|
809 | NOREF(pEvMsg);
|
---|
810 |
|
---|
811 | /*
|
---|
812 | * Watch out for the interface going online / offline.
|
---|
813 | */
|
---|
814 | if ( VALID_PTR(pThis)
|
---|
815 | && VALID_PTR(pEvMsg)
|
---|
816 | && pEvMsg->vendor_code == KEV_VENDOR_APPLE
|
---|
817 | && pEvMsg->kev_class == KEV_NETWORK_CLASS
|
---|
818 | && pEvMsg->kev_subclass == KEV_DL_SUBCLASS)
|
---|
819 | {
|
---|
820 | if (pThis->u.s.pIfNet == pIfNet)
|
---|
821 | {
|
---|
822 | if (pEvMsg->event_code == KEV_DL_LINK_ON)
|
---|
823 | {
|
---|
824 | if (ASMAtomicUoReadBool(&pThis->u.s.fNeedSetPromiscuous))
|
---|
825 | {
|
---|
826 | /* failed to bring it online. */
|
---|
827 | errno_t err = ifnet_set_promiscuous(pIfNet, 1);
|
---|
828 | if (!err)
|
---|
829 | {
|
---|
830 | ASMAtomicWriteBool(&pThis->u.s.fSetPromiscuous, true);
|
---|
831 | ASMAtomicWriteBool(&pThis->u.s.fNeedSetPromiscuous, false);
|
---|
832 | Log(("vboxNetFltDarwinIffEvent: enabled promiscuous mode on %s (%d)\n", pThis->szName, VBOX_GET_PCOUNT(pIfNet)));
|
---|
833 | }
|
---|
834 | else
|
---|
835 | Log(("vboxNetFltDarwinIffEvent: ifnet_set_promiscuous failed on %s, err=%d (%d)\n", pThis->szName, err, VBOX_GET_PCOUNT(pIfNet)));
|
---|
836 | }
|
---|
837 | else if ( ASMAtomicUoReadBool(&pThis->u.s.fSetPromiscuous)
|
---|
838 | && !(ifnet_flags(pIfNet) & IFF_PROMISC))
|
---|
839 | {
|
---|
840 | /* Try fix the inconsistency. */
|
---|
841 | errno_t err = ifnet_set_flags(pIfNet, IFF_PROMISC, IFF_PROMISC);
|
---|
842 | if (!err)
|
---|
843 | err = ifnet_ioctl(pIfNet, 0, SIOCSIFFLAGS, NULL);
|
---|
844 | if (!err && (ifnet_flags(pIfNet) & IFF_PROMISC))
|
---|
845 | Log(("vboxNetFltDarwinIffEvent: fixed IFF_PROMISC on %s (%d)\n", pThis->szName, VBOX_GET_PCOUNT(pIfNet)));
|
---|
846 | else
|
---|
847 | Log(("vboxNetFltDarwinIffEvent: failed to fix IFF_PROMISC on %s, err=%d flags=%#x (%d)\n",
|
---|
848 | pThis->szName, err, ifnet_flags(pIfNet), VBOX_GET_PCOUNT(pIfNet)));
|
---|
849 | }
|
---|
850 | else
|
---|
851 | Log(("vboxNetFltDarwinIffEvent: online, '%s'. flags=%#x (%d)\n", pThis->szName, ifnet_flags(pIfNet), VBOX_GET_PCOUNT(pIfNet)));
|
---|
852 | }
|
---|
853 | else if (pEvMsg->event_code == KEV_DL_LINK_OFF)
|
---|
854 | Log(("vboxNetFltDarwinIffEvent: %s goes down (%d)\n", pThis->szName, VBOX_GET_PCOUNT(pIfNet)));
|
---|
855 | /** @todo KEV_DL_LINK_ADDRESS_CHANGED -> pfnReportMacAddress */
|
---|
856 | /** @todo KEV_DL_SIFFLAGS -> pfnReportPromiscuousMode */
|
---|
857 | }
|
---|
858 | else
|
---|
859 | Log(("vboxNetFltDarwinIffEvent: pThis->u.s.pIfNet=%p pIfNet=%p (%d)\n", pThis->u.s.pIfNet, pIfNet, VALID_PTR(pIfNet) ? VBOX_GET_PCOUNT(pIfNet) : -1));
|
---|
860 | }
|
---|
861 | else if (VALID_PTR(pEvMsg))
|
---|
862 | Log(("vboxNetFltDarwinIffEvent: vendor_code=%#x kev_class=%#x kev_subclass=%#x event_code=%#x\n",
|
---|
863 | pEvMsg->vendor_code, pEvMsg->kev_class, pEvMsg->kev_subclass, pEvMsg->event_code));
|
---|
864 | }
|
---|
865 |
|
---|
866 |
|
---|
867 | /**
|
---|
868 | * Internal worker for vboxNetFltDarwinIffInput and vboxNetFltDarwinIffOutput,
|
---|
869 | *
|
---|
870 | * @returns 0 or EJUSTRETURN.
|
---|
871 | * @param pThis The instance.
|
---|
872 | * @param pMBuf The mbuf.
|
---|
873 | * @param pvFrame The start of the frame, optional.
|
---|
874 | * @param fSrc Where the packet (allegedly) comes from, one INTNETTRUNKDIR_* value.
|
---|
875 | * @param eProtocol The protocol.
|
---|
876 | */
|
---|
877 | static errno_t vboxNetFltDarwinIffInputOutputWorker(PVBOXNETFLTINS pThis, mbuf_t pMBuf, void *pvFrame,
|
---|
878 | uint32_t fSrc, protocol_family_t eProtocol)
|
---|
879 | {
|
---|
880 | /*
|
---|
881 | * Drop it immediately?
|
---|
882 | */
|
---|
883 | Log2(("vboxNetFltDarwinIffInputOutputWorker: pThis=%p pMBuf=%p pvFrame=%p fSrc=%#x cbPkt=%x\n",
|
---|
884 | pThis, pMBuf, pvFrame, fSrc, pMBuf ? mbuf_pkthdr_len(pMBuf) : -1));
|
---|
885 | if (!pMBuf)
|
---|
886 | return 0;
|
---|
887 | #if 0 /* debugging lost icmp packets */
|
---|
888 | if (mbuf_pkthdr_len(pMBuf) > 0x300)
|
---|
889 | {
|
---|
890 | uint8_t *pb = (uint8_t *)(pvFrame ? pvFrame : mbuf_data(pMBuf));
|
---|
891 | Log3(("D=%.6Rhxs S=%.6Rhxs T=%04x IFF\n", pb, pb + 6, RT_BE2H_U16(*(uint16_t *)(pb + 12))));
|
---|
892 | }
|
---|
893 | #endif
|
---|
894 | if (vboxNetFltDarwinMBufIsOur(pThis, pMBuf, pvFrame))
|
---|
895 | return 0;
|
---|
896 |
|
---|
897 | /*
|
---|
898 | * Active? Retain the instance and increment the busy counter.
|
---|
899 | */
|
---|
900 | if (!vboxNetFltTryRetainBusyActive(pThis))
|
---|
901 | return 0;
|
---|
902 |
|
---|
903 | /*
|
---|
904 | * Finalize out-bound packets since the stack puts off finalizing
|
---|
905 | * TCP/IP checksums as long as possible.
|
---|
906 | * ASSUMES this only applies to outbound IP packets.
|
---|
907 | */
|
---|
908 | if ( (fSrc == INTNETTRUNKDIR_HOST)
|
---|
909 | && eProtocol == PF_INET)
|
---|
910 | {
|
---|
911 | Assert(!pvFrame);
|
---|
912 | mbuf_outbound_finalize(pMBuf, eProtocol, sizeof(RTNETETHERHDR));
|
---|
913 | }
|
---|
914 |
|
---|
915 | /*
|
---|
916 | * Create a (scatter/)gather list for the mbuf and feed it to the internal network.
|
---|
917 | */
|
---|
918 | bool fDropIt = false;
|
---|
919 | unsigned cSegs = vboxNetFltDarwinMBufCalcSGSegs(pThis, pMBuf, pvFrame);
|
---|
920 | if (cSegs < VBOXNETFLT_DARWIN_MAX_SEGS)
|
---|
921 | {
|
---|
922 | PINTNETSG pSG = (PINTNETSG)alloca(RT_OFFSETOF(INTNETSG, aSegs[cSegs]));
|
---|
923 | vboxNetFltDarwinMBufToSG(pThis, pMBuf, pvFrame, pSG, cSegs, fSrc);
|
---|
924 |
|
---|
925 | fDropIt = pThis->pSwitchPort->pfnRecv(pThis->pSwitchPort, NULL /* pvIf */, pSG, fSrc);
|
---|
926 | if (fDropIt)
|
---|
927 | {
|
---|
928 | /*
|
---|
929 | * If the interface is in promiscuous mode we should let
|
---|
930 | * all inbound packets (this one was for a bridged guest)
|
---|
931 | * reach the driver as it passes them to tap callbacks in
|
---|
932 | * order for BPF to work properly.
|
---|
933 | */
|
---|
934 | if ( fSrc == INTNETTRUNKDIR_WIRE
|
---|
935 | && vboxNetFltDarwinIsPromiscuous(pThis))
|
---|
936 | {
|
---|
937 | fDropIt = false;
|
---|
938 | }
|
---|
939 |
|
---|
940 | /*
|
---|
941 | * A packet from the host to a guest. As we won't pass it
|
---|
942 | * to the drvier/wire we need to feed it to bpf ourselves.
|
---|
943 | */
|
---|
944 | if (fSrc == INTNETTRUNKDIR_HOST)
|
---|
945 | {
|
---|
946 | bpf_tap_out(pThis->u.s.pIfNet, DLT_EN10MB, pMBuf, NULL, 0);
|
---|
947 | }
|
---|
948 | }
|
---|
949 | }
|
---|
950 |
|
---|
951 | vboxNetFltRelease(pThis, true /* fBusy */);
|
---|
952 |
|
---|
953 | if (fDropIt)
|
---|
954 | {
|
---|
955 | mbuf_freem(pMBuf);
|
---|
956 | return EJUSTRETURN;
|
---|
957 | }
|
---|
958 | return 0;
|
---|
959 | }
|
---|
960 |
|
---|
961 |
|
---|
962 | /**
|
---|
963 | * From the host.
|
---|
964 | *
|
---|
965 | * @see iff_output_func in the darwin kpi.
|
---|
966 | */
|
---|
967 | static errno_t vboxNetFltDarwinIffOutput(void *pvThis, ifnet_t pIfNet, protocol_family_t eProtocol, mbuf_t *ppMBuf)
|
---|
968 | {
|
---|
969 | /** @todo there was some note about the ethernet header here or something like that... */
|
---|
970 |
|
---|
971 | NOREF(eProtocol);
|
---|
972 | NOREF(pIfNet);
|
---|
973 | return vboxNetFltDarwinIffInputOutputWorker((PVBOXNETFLTINS)pvThis, *ppMBuf, NULL, INTNETTRUNKDIR_HOST, eProtocol);
|
---|
974 | }
|
---|
975 |
|
---|
976 |
|
---|
977 | /**
|
---|
978 | * From the wire.
|
---|
979 | *
|
---|
980 | * @see iff_input_func in the darwin kpi.
|
---|
981 | */
|
---|
982 | static errno_t vboxNetFltDarwinIffInput(void *pvThis, ifnet_t pIfNet, protocol_family_t eProtocol, mbuf_t *ppMBuf, char **ppchFrame)
|
---|
983 | {
|
---|
984 | NOREF(eProtocol);
|
---|
985 | NOREF(pIfNet);
|
---|
986 | return vboxNetFltDarwinIffInputOutputWorker((PVBOXNETFLTINS)pvThis, *ppMBuf, *ppchFrame, INTNETTRUNKDIR_WIRE, eProtocol);
|
---|
987 | }
|
---|
988 |
|
---|
989 |
|
---|
990 | /** A worker thread for vboxNetFltSendDummy(). */
|
---|
991 | static DECLCALLBACK(int) vboxNetFltSendDummyWorker(RTTHREAD hThreadSelf, void *pvUser)
|
---|
992 | {
|
---|
993 | Assert(pvUser);
|
---|
994 | ifnet_t pIfNet = (ifnet_t)pvUser;
|
---|
995 | return VBoxNetSendDummy(pIfNet);
|
---|
996 | }
|
---|
997 |
|
---|
998 |
|
---|
999 | /**
|
---|
1000 | * Prevent GUI icon freeze issue when VirtualBoxVM process terminates.
|
---|
1001 | *
|
---|
1002 | * This function is a workaround for stuck-in-dock issue. The idea here is to
|
---|
1003 | * send a dummy packet to an interface from the context of a kernel thread.
|
---|
1004 | * Therefore, an XNU's receive thread (which is created as a result if we are
|
---|
1005 | * the first who is communicating with the interface) will be associated with
|
---|
1006 | * the kernel thread instead of VirtualBoxVM process.
|
---|
1007 | *
|
---|
1008 | * @param pIfNet Interface to be used to send data.
|
---|
1009 | */
|
---|
1010 | static void vboxNetFltSendDummy(ifnet_t pIfNet)
|
---|
1011 | {
|
---|
1012 | RTTHREAD hThread;
|
---|
1013 | int rc = RTThreadCreate(&hThread, vboxNetFltSendDummyWorker, (void *)pIfNet, 0,
|
---|
1014 | RTTHREADTYPE_DEFAULT, RTTHREADFLAGS_WAITABLE, "DummyThread");
|
---|
1015 | if (RT_SUCCESS(rc))
|
---|
1016 | {
|
---|
1017 | RTThreadWait(hThread, RT_INDEFINITE_WAIT, NULL);
|
---|
1018 | LogFlow(("vboxNetFltSendDummy: a dummy packet has been successfully sent in order to prevent stuck-in-dock issue\n"));
|
---|
1019 | }
|
---|
1020 | else
|
---|
1021 | LogFlow(("vboxNetFltSendDummy: unable to send dummy packet in order to prevent stuck-in-dock issue\n"));
|
---|
1022 | }
|
---|
1023 |
|
---|
1024 |
|
---|
1025 | /**
|
---|
1026 | * Internal worker for vboxNetFltOsInitInstance and vboxNetFltOsMaybeRediscovered.
|
---|
1027 | *
|
---|
1028 | * @returns VBox status code.
|
---|
1029 | * @param pThis The instance.
|
---|
1030 | * @param fRediscovery If set we're doing a rediscovery attempt, so, don't
|
---|
1031 | * flood the release log.
|
---|
1032 | */
|
---|
1033 | static int vboxNetFltDarwinAttachToInterface(PVBOXNETFLTINS pThis, bool fRediscovery)
|
---|
1034 | {
|
---|
1035 | LogFlow(("vboxNetFltDarwinAttachToInterface: pThis=%p (%s)\n", pThis, pThis->szName));
|
---|
1036 | IPRT_DARWIN_SAVE_EFL_AC();
|
---|
1037 |
|
---|
1038 | /*
|
---|
1039 | * Locate the interface first.
|
---|
1040 | *
|
---|
1041 | * The pIfNet member is updated before iflt_attach is called and used
|
---|
1042 | * to deal with the hypothetical case where someone rips out the
|
---|
1043 | * interface immediately after our iflt_attach call.
|
---|
1044 | */
|
---|
1045 | ifnet_t pIfNet = NULL;
|
---|
1046 | errno_t err = ifnet_find_by_name(pThis->szName, &pIfNet);
|
---|
1047 | if (err)
|
---|
1048 | {
|
---|
1049 | Assert(err == ENXIO);
|
---|
1050 | if (!fRediscovery)
|
---|
1051 | LogRel(("VBoxFltDrv: failed to find ifnet '%s' (err=%d)\n", pThis->szName, err));
|
---|
1052 | else
|
---|
1053 | Log(("VBoxFltDrv: failed to find ifnet '%s' (err=%d)\n", pThis->szName, err));
|
---|
1054 | IPRT_DARWIN_RESTORE_EFL_AC();
|
---|
1055 | return VERR_INTNET_FLT_IF_NOT_FOUND;
|
---|
1056 | }
|
---|
1057 |
|
---|
1058 | RTSpinlockAcquire(pThis->hSpinlock);
|
---|
1059 | ASMAtomicUoWritePtr(&pThis->u.s.pIfNet, pIfNet);
|
---|
1060 | RTSpinlockRelease(pThis->hSpinlock);
|
---|
1061 |
|
---|
1062 | /* Adjust g_offIfNetPCount as it varies for different versions of xnu. */
|
---|
1063 | vboxNetFltDarwinDetectPCountOffset(pIfNet);
|
---|
1064 |
|
---|
1065 | /* Prevent stuck-in-dock issue by associating interface receive thread with kernel thread. */
|
---|
1066 | vboxNetFltSendDummy(pIfNet);
|
---|
1067 |
|
---|
1068 | /*
|
---|
1069 | * Get the mac address while we still have a valid ifnet reference.
|
---|
1070 | */
|
---|
1071 | err = ifnet_lladdr_copy_bytes(pIfNet, &pThis->u.s.MacAddr, sizeof(pThis->u.s.MacAddr));
|
---|
1072 | if (!err)
|
---|
1073 | {
|
---|
1074 | /*
|
---|
1075 | * Try attach the filter.
|
---|
1076 | */
|
---|
1077 | struct iff_filter RegRec;
|
---|
1078 | RegRec.iff_cookie = pThis;
|
---|
1079 | RegRec.iff_name = "VBoxNetFlt";
|
---|
1080 | RegRec.iff_protocol = 0;
|
---|
1081 | RegRec.iff_input = vboxNetFltDarwinIffInput;
|
---|
1082 | RegRec.iff_output = vboxNetFltDarwinIffOutput;
|
---|
1083 | RegRec.iff_event = vboxNetFltDarwinIffEvent;
|
---|
1084 | RegRec.iff_ioctl = vboxNetFltDarwinIffIoCtl;
|
---|
1085 | RegRec.iff_detached = vboxNetFltDarwinIffDetached;
|
---|
1086 | interface_filter_t pIfFilter = NULL;
|
---|
1087 | err = iflt_attach(pIfNet, &RegRec, &pIfFilter);
|
---|
1088 | Assert(err || pIfFilter);
|
---|
1089 |
|
---|
1090 | RTSpinlockAcquire(pThis->hSpinlock);
|
---|
1091 | pIfNet = ASMAtomicUoReadPtrT(&pThis->u.s.pIfNet, ifnet_t);
|
---|
1092 | if (pIfNet && !err)
|
---|
1093 | {
|
---|
1094 | ASMAtomicUoWriteBool(&pThis->fDisconnectedFromHost, false);
|
---|
1095 | ASMAtomicUoWritePtr(&pThis->u.s.pIfFilter, pIfFilter);
|
---|
1096 | pIfNet = NULL; /* don't dereference it */
|
---|
1097 | }
|
---|
1098 | RTSpinlockRelease(pThis->hSpinlock);
|
---|
1099 |
|
---|
1100 | /* Report capabilities. */
|
---|
1101 | if ( !pIfNet
|
---|
1102 | && vboxNetFltTryRetainBusyNotDisconnected(pThis))
|
---|
1103 | {
|
---|
1104 | Assert(pThis->pSwitchPort);
|
---|
1105 | pThis->pSwitchPort->pfnReportMacAddress(pThis->pSwitchPort, &pThis->u.s.MacAddr);
|
---|
1106 | #if 0
|
---|
1107 | /*
|
---|
1108 | * XXX: Don't tell SrvIntNetR0 if the interface is
|
---|
1109 | * promiscuous, because there's no code yet to update that
|
---|
1110 | * information and we don't want it stuck, spamming all
|
---|
1111 | * traffic to the host.
|
---|
1112 | */
|
---|
1113 | pThis->pSwitchPort->pfnReportPromiscuousMode(pThis->pSwitchPort, vboxNetFltDarwinIsPromiscuous(pThis));
|
---|
1114 | #endif
|
---|
1115 | pThis->pSwitchPort->pfnReportGsoCapabilities(pThis->pSwitchPort, 0, INTNETTRUNKDIR_WIRE | INTNETTRUNKDIR_HOST);
|
---|
1116 | pThis->pSwitchPort->pfnReportNoPreemptDsts(pThis->pSwitchPort, 0 /* none */);
|
---|
1117 | vboxNetFltRelease(pThis, true /*fBusy*/);
|
---|
1118 | }
|
---|
1119 | }
|
---|
1120 |
|
---|
1121 | /* Release the interface on failure. */
|
---|
1122 | if (pIfNet)
|
---|
1123 | ifnet_release(pIfNet);
|
---|
1124 |
|
---|
1125 | int rc = RTErrConvertFromErrno(err);
|
---|
1126 | if (RT_SUCCESS(rc))
|
---|
1127 | LogRel(("VBoxFltDrv: attached to '%s' / %RTmac\n", pThis->szName, &pThis->u.s.MacAddr));
|
---|
1128 | else
|
---|
1129 | LogRel(("VBoxFltDrv: failed to attach to ifnet '%s' (err=%d)\n", pThis->szName, err));
|
---|
1130 | IPRT_DARWIN_RESTORE_EFL_AC();
|
---|
1131 | return rc;
|
---|
1132 | }
|
---|
1133 |
|
---|
1134 |
|
---|
1135 | bool vboxNetFltOsMaybeRediscovered(PVBOXNETFLTINS pThis)
|
---|
1136 | {
|
---|
1137 | vboxNetFltDarwinAttachToInterface(pThis, true /* fRediscovery */);
|
---|
1138 | return !ASMAtomicUoReadBool(&pThis->fDisconnectedFromHost);
|
---|
1139 | }
|
---|
1140 |
|
---|
1141 |
|
---|
1142 | int vboxNetFltPortOsXmit(PVBOXNETFLTINS pThis, void *pvIfData, PINTNETSG pSG, uint32_t fDst)
|
---|
1143 | {
|
---|
1144 | IPRT_DARWIN_SAVE_EFL_AC();
|
---|
1145 | NOREF(pvIfData);
|
---|
1146 |
|
---|
1147 | int rc = VINF_SUCCESS;
|
---|
1148 | ifnet_t pIfNet = vboxNetFltDarwinRetainIfNet(pThis);
|
---|
1149 | if (pIfNet)
|
---|
1150 | {
|
---|
1151 | /*
|
---|
1152 | * Create a mbuf for the gather list and push it onto the wire.
|
---|
1153 | */
|
---|
1154 | if (fDst & INTNETTRUNKDIR_WIRE)
|
---|
1155 | {
|
---|
1156 | mbuf_t pMBuf = vboxNetFltDarwinMBufFromSG(pThis, pSG);
|
---|
1157 | if (pMBuf)
|
---|
1158 | {
|
---|
1159 | errno_t err = ifnet_output_raw(pIfNet, PF_LINK, pMBuf);
|
---|
1160 | if (err)
|
---|
1161 | rc = RTErrConvertFromErrno(err);
|
---|
1162 | }
|
---|
1163 | else
|
---|
1164 | rc = VERR_NO_MEMORY;
|
---|
1165 | }
|
---|
1166 |
|
---|
1167 | /*
|
---|
1168 | * Create a mbuf for the gather list and push it onto the host stack.
|
---|
1169 | */
|
---|
1170 | if (fDst & INTNETTRUNKDIR_HOST)
|
---|
1171 | {
|
---|
1172 | mbuf_t pMBuf = vboxNetFltDarwinMBufFromSG(pThis, pSG);
|
---|
1173 | if (pMBuf)
|
---|
1174 | {
|
---|
1175 | void *pvEthHdr = mbuf_data(pMBuf);
|
---|
1176 | unsigned const cbEthHdr = 14;
|
---|
1177 |
|
---|
1178 | mbuf_pkthdr_setrcvif(pMBuf, pIfNet);
|
---|
1179 | mbuf_pkthdr_setheader(pMBuf, pvEthHdr); /* link-layer header */
|
---|
1180 | mbuf_adj(pMBuf, cbEthHdr); /* move to payload */
|
---|
1181 |
|
---|
1182 | bpf_tap_in(pIfNet, DLT_EN10MB, pMBuf, pvEthHdr, cbEthHdr);
|
---|
1183 | errno_t err = ifnet_input(pIfNet, pMBuf, NULL);
|
---|
1184 | if (err)
|
---|
1185 | rc = RTErrConvertFromErrno(err);
|
---|
1186 | }
|
---|
1187 | else
|
---|
1188 | rc = VERR_NO_MEMORY;
|
---|
1189 | }
|
---|
1190 |
|
---|
1191 | vboxNetFltDarwinReleaseIfNet(pThis, pIfNet);
|
---|
1192 | }
|
---|
1193 |
|
---|
1194 | IPRT_DARWIN_RESTORE_EFL_AC();
|
---|
1195 | return rc;
|
---|
1196 | }
|
---|
1197 |
|
---|
1198 |
|
---|
1199 | void vboxNetFltPortOsSetActive(PVBOXNETFLTINS pThis, bool fActive)
|
---|
1200 | {
|
---|
1201 | IPRT_DARWIN_SAVE_EFL_AC();
|
---|
1202 | ifnet_t pIfNet = vboxNetFltDarwinRetainIfNet(pThis);
|
---|
1203 | if (pIfNet)
|
---|
1204 | {
|
---|
1205 | if (pThis->fDisablePromiscuous)
|
---|
1206 | {
|
---|
1207 | /*
|
---|
1208 | * Promiscuous mode should not be used (wireless), we just need to
|
---|
1209 | * make sure the interface is up.
|
---|
1210 | */
|
---|
1211 | if (fActive)
|
---|
1212 | {
|
---|
1213 | u_int16_t fIf = ifnet_flags(pIfNet);
|
---|
1214 | if ((fIf & (IFF_UP | IFF_RUNNING)) != (IFF_UP | IFF_RUNNING))
|
---|
1215 | {
|
---|
1216 | ifnet_set_flags(pIfNet, IFF_UP, IFF_UP);
|
---|
1217 | ifnet_ioctl(pIfNet, 0, SIOCSIFFLAGS, NULL);
|
---|
1218 | }
|
---|
1219 | }
|
---|
1220 | }
|
---|
1221 | else
|
---|
1222 | {
|
---|
1223 | /*
|
---|
1224 | * This api is a bit weird, the best reference is the code.
|
---|
1225 | *
|
---|
1226 | * Also, we have a bit or race conditions wrt the maintenance of
|
---|
1227 | * host the interface promiscuity for vboxNetFltPortOsIsPromiscuous.
|
---|
1228 | */
|
---|
1229 | unsigned const cPromiscBefore = VBOX_GET_PCOUNT(pIfNet);
|
---|
1230 | u_int16_t fIf;
|
---|
1231 | if (fActive)
|
---|
1232 | {
|
---|
1233 | Assert(!pThis->u.s.fSetPromiscuous);
|
---|
1234 | errno_t err = ENETDOWN;
|
---|
1235 | ASMAtomicWriteBool(&pThis->u.s.fNeedSetPromiscuous, true);
|
---|
1236 |
|
---|
1237 | /*
|
---|
1238 | * Try bring the interface up and running if it's down.
|
---|
1239 | */
|
---|
1240 | fIf = ifnet_flags(pIfNet);
|
---|
1241 | if ((fIf & (IFF_UP | IFF_RUNNING)) != (IFF_UP | IFF_RUNNING))
|
---|
1242 | {
|
---|
1243 | err = ifnet_set_flags(pIfNet, IFF_UP, IFF_UP);
|
---|
1244 | errno_t err2 = ifnet_ioctl(pIfNet, 0, SIOCSIFFLAGS, NULL);
|
---|
1245 | if (!err)
|
---|
1246 | err = err2;
|
---|
1247 | fIf = ifnet_flags(pIfNet);
|
---|
1248 | }
|
---|
1249 |
|
---|
1250 | /*
|
---|
1251 | * Is it already up? If it isn't, leave it to the link event or
|
---|
1252 | * we'll upset if_pcount (as stated above, ifnet_set_promiscuous is weird).
|
---|
1253 | */
|
---|
1254 | if ((fIf & (IFF_UP | IFF_RUNNING)) == (IFF_UP | IFF_RUNNING))
|
---|
1255 | {
|
---|
1256 | err = ifnet_set_promiscuous(pIfNet, 1);
|
---|
1257 | pThis->u.s.fSetPromiscuous = err == 0;
|
---|
1258 | if (!err)
|
---|
1259 | {
|
---|
1260 | ASMAtomicWriteBool(&pThis->u.s.fNeedSetPromiscuous, false);
|
---|
1261 |
|
---|
1262 | /* check if it actually worked, this stuff is not always behaving well. */
|
---|
1263 | if (!(ifnet_flags(pIfNet) & IFF_PROMISC))
|
---|
1264 | {
|
---|
1265 | err = ifnet_set_flags(pIfNet, IFF_PROMISC, IFF_PROMISC);
|
---|
1266 | if (!err)
|
---|
1267 | err = ifnet_ioctl(pIfNet, 0, SIOCSIFFLAGS, NULL);
|
---|
1268 | if (!err)
|
---|
1269 | Log(("vboxNetFlt: fixed IFF_PROMISC on %s (%d->%d)\n", pThis->szName, cPromiscBefore, VBOX_GET_PCOUNT(pIfNet)));
|
---|
1270 | else
|
---|
1271 | Log(("VBoxNetFlt: failed to fix IFF_PROMISC on %s, err=%d (%d->%d)\n",
|
---|
1272 | pThis->szName, err, cPromiscBefore, VBOX_GET_PCOUNT(pIfNet)));
|
---|
1273 | }
|
---|
1274 | }
|
---|
1275 | else
|
---|
1276 | Log(("VBoxNetFlt: ifnet_set_promiscuous -> err=%d grr! (%d->%d)\n", err, cPromiscBefore, VBOX_GET_PCOUNT(pIfNet)));
|
---|
1277 | }
|
---|
1278 | else if (!err)
|
---|
1279 | Log(("VBoxNetFlt: Waiting for the link to come up... (%d->%d)\n", cPromiscBefore, VBOX_GET_PCOUNT(pIfNet)));
|
---|
1280 | if (err)
|
---|
1281 | LogRel(("VBoxNetFlt: Failed to put '%s' into promiscuous mode, err=%d (%d->%d)\n", pThis->szName, err, cPromiscBefore, VBOX_GET_PCOUNT(pIfNet)));
|
---|
1282 | }
|
---|
1283 | else
|
---|
1284 | {
|
---|
1285 | ASMAtomicWriteBool(&pThis->u.s.fNeedSetPromiscuous, false);
|
---|
1286 | if (pThis->u.s.fSetPromiscuous)
|
---|
1287 | {
|
---|
1288 | errno_t err = ifnet_set_promiscuous(pIfNet, 0);
|
---|
1289 | AssertMsg(!err, ("%d\n", err)); NOREF(err);
|
---|
1290 | }
|
---|
1291 | pThis->u.s.fSetPromiscuous = false;
|
---|
1292 |
|
---|
1293 | fIf = ifnet_flags(pIfNet);
|
---|
1294 | Log(("VBoxNetFlt: fIf=%#x; %d->%d\n", fIf, cPromiscBefore, VBOX_GET_PCOUNT(pIfNet)));
|
---|
1295 | }
|
---|
1296 | }
|
---|
1297 |
|
---|
1298 | vboxNetFltDarwinReleaseIfNet(pThis, pIfNet);
|
---|
1299 | }
|
---|
1300 | IPRT_DARWIN_RESTORE_EFL_AC();
|
---|
1301 | }
|
---|
1302 |
|
---|
1303 |
|
---|
1304 | int vboxNetFltOsDisconnectIt(PVBOXNETFLTINS pThis)
|
---|
1305 | {
|
---|
1306 | /* Nothing to do here. */
|
---|
1307 | return VINF_SUCCESS;
|
---|
1308 | }
|
---|
1309 |
|
---|
1310 |
|
---|
1311 | int vboxNetFltOsConnectIt(PVBOXNETFLTINS pThis)
|
---|
1312 | {
|
---|
1313 | /* Nothing to do here. */
|
---|
1314 | return VINF_SUCCESS;
|
---|
1315 | }
|
---|
1316 |
|
---|
1317 |
|
---|
1318 | void vboxNetFltOsDeleteInstance(PVBOXNETFLTINS pThis)
|
---|
1319 | {
|
---|
1320 | IPRT_DARWIN_SAVE_EFL_AC();
|
---|
1321 |
|
---|
1322 | /*
|
---|
1323 | * Carefully obtain the interface filter reference and detach it.
|
---|
1324 | */
|
---|
1325 | RTSpinlockAcquire(pThis->hSpinlock);
|
---|
1326 | interface_filter_t pIfFilter = ASMAtomicUoReadPtrT(&pThis->u.s.pIfFilter, interface_filter_t);
|
---|
1327 | if (pIfFilter)
|
---|
1328 | ASMAtomicUoWriteNullPtr(&pThis->u.s.pIfFilter);
|
---|
1329 | RTSpinlockRelease(pThis->hSpinlock);
|
---|
1330 |
|
---|
1331 | if (pIfFilter)
|
---|
1332 | iflt_detach(pIfFilter);
|
---|
1333 |
|
---|
1334 | if (pThis->u.s.pSysSock != NULL)
|
---|
1335 | {
|
---|
1336 | sock_close(pThis->u.s.pSysSock);
|
---|
1337 | pThis->u.s.pSysSock = NULL;
|
---|
1338 | }
|
---|
1339 |
|
---|
1340 | IPRT_DARWIN_RESTORE_EFL_AC();
|
---|
1341 | }
|
---|
1342 |
|
---|
1343 |
|
---|
1344 | int vboxNetFltOsInitInstance(PVBOXNETFLTINS pThis, void *pvContext)
|
---|
1345 | {
|
---|
1346 | NOREF(pvContext);
|
---|
1347 |
|
---|
1348 | int rc = vboxNetFltDarwinAttachToInterface(pThis, false /* fRediscovery */);
|
---|
1349 | if (RT_FAILURE(rc))
|
---|
1350 | return rc;
|
---|
1351 |
|
---|
1352 | if (pThis->pSwitchPort->pfnNotifyHostAddress == NULL)
|
---|
1353 | return rc;
|
---|
1354 |
|
---|
1355 | /*
|
---|
1356 | * XXX: uwe
|
---|
1357 | *
|
---|
1358 | * Learn host's IP addresses and set up notifications for changes.
|
---|
1359 | * To avoid racing, set up notifications first.
|
---|
1360 | *
|
---|
1361 | * XXX: This should probably be global, since the only thing
|
---|
1362 | * specific to ifnet here is its IPv6 link-local address.
|
---|
1363 | */
|
---|
1364 | IPRT_DARWIN_SAVE_EFL_AC();
|
---|
1365 | errno_t error;
|
---|
1366 |
|
---|
1367 | /** @todo reorg code to not have numerous returns with duplicate code... */
|
---|
1368 | error = sock_socket(PF_SYSTEM, SOCK_RAW, SYSPROTO_EVENT,
|
---|
1369 | vboxNetFltDarwinSysSockUpcall, pThis,
|
---|
1370 | &pThis->u.s.pSysSock);
|
---|
1371 | if (error != 0)
|
---|
1372 | {
|
---|
1373 | LogRel(("sock_socket(SYSPROTO_EVENT): error %d\n", error));
|
---|
1374 | IPRT_DARWIN_RESTORE_EFL_AC();
|
---|
1375 | return rc;
|
---|
1376 | }
|
---|
1377 |
|
---|
1378 | int nbio = 1;
|
---|
1379 | error = sock_ioctl(pThis->u.s.pSysSock, FIONBIO, &nbio);
|
---|
1380 | if (error != 0)
|
---|
1381 | {
|
---|
1382 | LogRel(("FIONBIO: error %d\n", error));
|
---|
1383 | sock_close(pThis->u.s.pSysSock);
|
---|
1384 | IPRT_DARWIN_RESTORE_EFL_AC();
|
---|
1385 | return rc;
|
---|
1386 | }
|
---|
1387 |
|
---|
1388 | if (!sock_isnonblocking(pThis->u.s.pSysSock))
|
---|
1389 | {
|
---|
1390 | LogRel(("FIONBIO ok, but socket is blocking?!\n"));
|
---|
1391 | sock_close(pThis->u.s.pSysSock);
|
---|
1392 | IPRT_DARWIN_RESTORE_EFL_AC();
|
---|
1393 | return rc;
|
---|
1394 | }
|
---|
1395 |
|
---|
1396 | struct kev_request req;
|
---|
1397 | req.vendor_code = KEV_VENDOR_APPLE;
|
---|
1398 | req.kev_class = KEV_NETWORK_CLASS;
|
---|
1399 | req.kev_subclass = KEV_ANY_SUBCLASS; /* need both INET and INET6, so have to request all */
|
---|
1400 |
|
---|
1401 | error = sock_ioctl(pThis->u.s.pSysSock, SIOCSKEVFILT, &req);
|
---|
1402 | if (error != 0)
|
---|
1403 | {
|
---|
1404 | LogRel(("SIOCSKEVFILT: error %d\n", error));
|
---|
1405 | sock_close(pThis->u.s.pSysSock);
|
---|
1406 | IPRT_DARWIN_RESTORE_EFL_AC();
|
---|
1407 | return rc;
|
---|
1408 | }
|
---|
1409 |
|
---|
1410 | ifnet_t pIfNet = pThis->u.s.pIfNet; /* already retained */
|
---|
1411 |
|
---|
1412 | ifaddr_t *pIfAddrList;
|
---|
1413 | error = ifnet_get_address_list(/* all interfaces*/ NULL, &pIfAddrList);
|
---|
1414 | if (error != 0)
|
---|
1415 | {
|
---|
1416 | LogRel(("ifnet_get_address_list: error %d\n", error));
|
---|
1417 | IPRT_DARWIN_RESTORE_EFL_AC();
|
---|
1418 | return rc;
|
---|
1419 | }
|
---|
1420 |
|
---|
1421 | for (ifaddr_t *pIfAddr = pIfAddrList; *pIfAddr != NULL; ++pIfAddr)
|
---|
1422 | {
|
---|
1423 | ifaddr_t ifa = *pIfAddr;
|
---|
1424 | sa_family_t family = ifaddr_address_family(ifa);
|
---|
1425 | struct sockaddr_storage ss;
|
---|
1426 |
|
---|
1427 | error = ifaddr_address(ifa, (struct sockaddr *)&ss, sizeof(ss));
|
---|
1428 | if (error != 0)
|
---|
1429 | {
|
---|
1430 | LogRel(("getting address family %d: error %d\n", family, error));
|
---|
1431 | continue;
|
---|
1432 | }
|
---|
1433 |
|
---|
1434 | if (family == AF_INET)
|
---|
1435 | {
|
---|
1436 | struct sockaddr_in *sin = (struct sockaddr_in *)&ss;
|
---|
1437 | u_int32_t u32Addr = ntohl(sin->sin_addr.s_addr);
|
---|
1438 |
|
---|
1439 | if (VBOX_IN_LOOPBACK(u32Addr))
|
---|
1440 | continue;
|
---|
1441 |
|
---|
1442 | if (ifaddr_ifnet(ifa) != pIfNet && VBOX_IN_LINKLOCAL(u32Addr))
|
---|
1443 | continue;
|
---|
1444 |
|
---|
1445 | Log(("> inet %RTnaipv4\n", sin->sin_addr.s_addr));
|
---|
1446 | pThis->pSwitchPort->pfnNotifyHostAddress(pThis->pSwitchPort,
|
---|
1447 | /* :fAdded */ true, kIntNetAddrType_IPv4, &sin->sin_addr);
|
---|
1448 | }
|
---|
1449 | else if (family == AF_INET6)
|
---|
1450 | {
|
---|
1451 | struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)&ss;
|
---|
1452 |
|
---|
1453 | if (IN6_IS_ADDR_LOOPBACK(&sin6->sin6_addr))
|
---|
1454 | continue;
|
---|
1455 |
|
---|
1456 | /* link-local from other interfaces are out of scope */
|
---|
1457 | if (ifaddr_ifnet(ifa) != pIfNet && IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr))
|
---|
1458 | continue;
|
---|
1459 |
|
---|
1460 | Log(("> inet6 %RTnaipv6\n", &sin6->sin6_addr));
|
---|
1461 | pThis->pSwitchPort->pfnNotifyHostAddress(pThis->pSwitchPort,
|
---|
1462 | /* :fAdded */ true, kIntNetAddrType_IPv6, &sin6->sin6_addr);
|
---|
1463 | }
|
---|
1464 | }
|
---|
1465 |
|
---|
1466 | ifnet_free_address_list(pIfAddrList);
|
---|
1467 |
|
---|
1468 | /*
|
---|
1469 | * Now that we've got current addresses, check for events that
|
---|
1470 | * might have happened while we were working.
|
---|
1471 | */
|
---|
1472 | vboxNetFltDarwinSysSockUpcall(pThis->u.s.pSysSock, pThis, MBUF_DONTWAIT);
|
---|
1473 |
|
---|
1474 | IPRT_DARWIN_RESTORE_EFL_AC();
|
---|
1475 | return rc;
|
---|
1476 | }
|
---|
1477 |
|
---|
1478 |
|
---|
1479 | static void vboxNetFltDarwinSysSockUpcall(socket_t pSysSock, void *pvData, int fWait)
|
---|
1480 | {
|
---|
1481 | PVBOXNETFLTINS pThis = (PVBOXNETFLTINS)pvData;
|
---|
1482 | errno_t error;
|
---|
1483 |
|
---|
1484 | NOREF(fWait);
|
---|
1485 |
|
---|
1486 | if (RT_UNLIKELY(pSysSock != pThis->u.s.pSysSock))
|
---|
1487 | {
|
---|
1488 | Log(("vboxNetFltDarwinSysSockUpcall: %p != %p?\n",
|
---|
1489 | pSysSock, pThis->u.s.pSysSock));
|
---|
1490 | return;
|
---|
1491 | }
|
---|
1492 |
|
---|
1493 | struct net_event_data my_link;
|
---|
1494 | ifnet_t pIfNet = pThis->u.s.pIfNet; /* XXX: retain? */
|
---|
1495 | ifnet_family_t if_family = ifnet_family(pIfNet);
|
---|
1496 | u_int32_t if_unit = ifnet_unit(pIfNet);
|
---|
1497 |
|
---|
1498 | for (;;)
|
---|
1499 | {
|
---|
1500 | mbuf_t m;
|
---|
1501 | size_t len = sizeof(struct kern_event_msg) - sizeof(u_int32_t) + sizeof(struct kev_in6_data);
|
---|
1502 |
|
---|
1503 | error = sock_receivembuf(pSysSock, NULL, &m, 0, &len);
|
---|
1504 | if (error != 0)
|
---|
1505 | {
|
---|
1506 | if (error == EWOULDBLOCK)
|
---|
1507 | {
|
---|
1508 | Log(("vboxNetFltDarwinSysSockUpcall: EWOULDBLOCK - we are done\n"));
|
---|
1509 | error = 0;
|
---|
1510 | }
|
---|
1511 | else
|
---|
1512 | Log(("sock_receivembuf: error %d\n", error));
|
---|
1513 | break;
|
---|
1514 | }
|
---|
1515 |
|
---|
1516 | if (len < sizeof(struct kern_event_msg) - sizeof(u_int32_t))
|
---|
1517 | {
|
---|
1518 | Log(("vboxNetFltDarwinSysSockUpcall: %u bytes is too short\n", (unsigned int)len));
|
---|
1519 | mbuf_freem(m);
|
---|
1520 | return;
|
---|
1521 | }
|
---|
1522 |
|
---|
1523 | struct kern_event_msg *msg = (struct kern_event_msg *)mbuf_data(m);
|
---|
1524 | if (msg->kev_subclass == KEV_INET_SUBCLASS)
|
---|
1525 | {
|
---|
1526 | if (len - (sizeof(struct kern_event_msg) - sizeof(u_int32_t)) < sizeof(struct kev_in_data))
|
---|
1527 | {
|
---|
1528 | Log(("vboxNetFltDarwinSysSockUpcall: %u bytes is too short for KEV_INET_SUBCLASS\n",
|
---|
1529 | (unsigned int)len));
|
---|
1530 | mbuf_freem(m);
|
---|
1531 | return;
|
---|
1532 | }
|
---|
1533 |
|
---|
1534 | struct kev_in_data *iev = (struct kev_in_data *)msg->event_data;
|
---|
1535 | struct net_event_data *link = &iev->link_data;
|
---|
1536 | PCRTNETADDRU pAddr = (PCRTNETADDRU)&iev->ia_addr;
|
---|
1537 | u_int32_t u32Addr = ntohl(pAddr->IPv4.u);
|
---|
1538 |
|
---|
1539 | if (VBOX_IN_LOOPBACK(u32Addr))
|
---|
1540 | {
|
---|
1541 | mbuf_freem(m);
|
---|
1542 | continue;
|
---|
1543 | }
|
---|
1544 |
|
---|
1545 | if ( (link->if_family != if_family || link->if_unit != if_unit)
|
---|
1546 | && VBOX_IN_LINKLOCAL(u32Addr))
|
---|
1547 | {
|
---|
1548 | mbuf_freem(m);
|
---|
1549 | continue;
|
---|
1550 | }
|
---|
1551 |
|
---|
1552 | switch (msg->event_code)
|
---|
1553 | {
|
---|
1554 | case KEV_INET_NEW_ADDR:
|
---|
1555 | Log(("KEV_INET_NEW_ADDR %.*s%d: %RTnaipv4\n", IFNAMSIZ, link->if_name, link->if_unit, pAddr->IPv4.u));
|
---|
1556 | pThis->pSwitchPort->pfnNotifyHostAddress(pThis->pSwitchPort, true /*fAdded*/, kIntNetAddrType_IPv4, pAddr);
|
---|
1557 | break;
|
---|
1558 |
|
---|
1559 | case KEV_INET_ADDR_DELETED:
|
---|
1560 | Log(("KEV_INET_ADDR_DELETED %.*s%d: %RTnaipv4\n", IFNAMSIZ, link->if_name, link->if_unit, pAddr->IPv4.u));
|
---|
1561 | pThis->pSwitchPort->pfnNotifyHostAddress(pThis->pSwitchPort, false /*fAdded*/, kIntNetAddrType_IPv4, pAddr);
|
---|
1562 | break;
|
---|
1563 |
|
---|
1564 | default:
|
---|
1565 | Log(("KEV INET event %u %.*s%d: addr %RTnaipv4\n",
|
---|
1566 | msg->event_code, IFNAMSIZ, link->if_name, link->if_unit, pAddr->IPv4.u));
|
---|
1567 | break;
|
---|
1568 | }
|
---|
1569 | }
|
---|
1570 | else if (msg->kev_subclass == KEV_INET6_SUBCLASS)
|
---|
1571 | {
|
---|
1572 | if (len - (sizeof(struct kern_event_msg) - sizeof(u_int32_t)) < sizeof(struct kev_in6_data))
|
---|
1573 | {
|
---|
1574 | Log(("vboxNetFltDarwinSysSockUpcall: %u bytes is too short for KEV_INET6_SUBCLASS\n",
|
---|
1575 | (unsigned int)len));
|
---|
1576 | mbuf_freem(m);
|
---|
1577 | return;
|
---|
1578 | }
|
---|
1579 |
|
---|
1580 | struct kev_in6_data *iev6 = (struct kev_in6_data *)msg->event_data;
|
---|
1581 | struct net_event_data *link = &iev6->link_data;
|
---|
1582 | PCRTNETADDRU pAddr = (PCRTNETADDRU)&iev6->ia_addr.sin6_addr;
|
---|
1583 |
|
---|
1584 | if (IN6_IS_ADDR_LOOPBACK(&iev6->ia_addr.sin6_addr))
|
---|
1585 | {
|
---|
1586 | mbuf_freem(m);
|
---|
1587 | continue;
|
---|
1588 | }
|
---|
1589 |
|
---|
1590 | if ( (link->if_family != if_family || link->if_unit != if_unit)
|
---|
1591 | && IN6_IS_ADDR_LINKLOCAL(&iev6->ia_addr.sin6_addr))
|
---|
1592 | {
|
---|
1593 | mbuf_freem(m);
|
---|
1594 | continue;
|
---|
1595 | }
|
---|
1596 |
|
---|
1597 | switch (msg->event_code)
|
---|
1598 | {
|
---|
1599 | case KEV_INET6_NEW_USER_ADDR:
|
---|
1600 | Log(("KEV_INET6_NEW_USER_ADDR %.*s%d: %RTnaipv6\n",
|
---|
1601 | IFNAMSIZ, link->if_name, link->if_unit, pAddr));
|
---|
1602 | goto kev_inet6_new;
|
---|
1603 |
|
---|
1604 | case KEV_INET6_NEW_LL_ADDR:
|
---|
1605 | Log(("KEV_INET6_NEW_LL_ADDR %.*s%d: %RTnaipv6\n",
|
---|
1606 | IFNAMSIZ, link->if_name, link->if_unit, pAddr));
|
---|
1607 | goto kev_inet6_new;
|
---|
1608 |
|
---|
1609 | case KEV_INET6_NEW_RTADV_ADDR:
|
---|
1610 | Log(("KEV_INET6_NEW_RTADV_ADDR %.*s%d: %RTnaipv6\n",
|
---|
1611 | IFNAMSIZ, link->if_name, link->if_unit, pAddr));
|
---|
1612 | goto kev_inet6_new;
|
---|
1613 |
|
---|
1614 | kev_inet6_new:
|
---|
1615 | pThis->pSwitchPort->pfnNotifyHostAddress(pThis->pSwitchPort,
|
---|
1616 | /* :fAdded */ true, kIntNetAddrType_IPv6, pAddr);
|
---|
1617 | break;
|
---|
1618 |
|
---|
1619 | case KEV_INET6_ADDR_DELETED:
|
---|
1620 | Log(("KEV_INET6_ADDR_DELETED %.*s%d: %RTnaipv6\n",
|
---|
1621 | IFNAMSIZ, link->if_name, link->if_unit, pAddr));
|
---|
1622 |
|
---|
1623 | pThis->pSwitchPort->pfnNotifyHostAddress(pThis->pSwitchPort,
|
---|
1624 | /* :fAdded */ false, kIntNetAddrType_IPv6, pAddr);
|
---|
1625 | break;
|
---|
1626 |
|
---|
1627 | default:
|
---|
1628 | Log(("KEV INET6 event %u %.*s%d: addr %RTnaipv6\n",
|
---|
1629 | msg->event_code, IFNAMSIZ, link->if_name, link->if_unit, pAddr));
|
---|
1630 | break;
|
---|
1631 | }
|
---|
1632 | }
|
---|
1633 | else
|
---|
1634 | Log(("vboxNetFltDarwinSysSockUpcall: subclass %u ignored\n", (unsigned)msg->kev_subclass));
|
---|
1635 |
|
---|
1636 | mbuf_freem(m);
|
---|
1637 | }
|
---|
1638 | }
|
---|
1639 |
|
---|
1640 |
|
---|
1641 | int vboxNetFltOsPreInitInstance(PVBOXNETFLTINS pThis)
|
---|
1642 | {
|
---|
1643 | /*
|
---|
1644 | * Init the darwin specific members.
|
---|
1645 | */
|
---|
1646 | pThis->u.s.pIfNet = NULL;
|
---|
1647 | pThis->u.s.pIfFilter = NULL;
|
---|
1648 | pThis->u.s.fSetPromiscuous = false;
|
---|
1649 | pThis->u.s.fNeedSetPromiscuous = false;
|
---|
1650 | //pThis->u.s.MacAddr = {0};
|
---|
1651 | pThis->u.s.pSysSock = NULL;
|
---|
1652 |
|
---|
1653 | return VINF_SUCCESS;
|
---|
1654 | }
|
---|
1655 |
|
---|
1656 |
|
---|
1657 | void vboxNetFltPortOsNotifyMacAddress(PVBOXNETFLTINS pThis, void *pvIfData, PCRTMAC pMac)
|
---|
1658 | {
|
---|
1659 | NOREF(pThis); NOREF(pvIfData); NOREF(pMac);
|
---|
1660 | }
|
---|
1661 |
|
---|
1662 |
|
---|
1663 | int vboxNetFltPortOsConnectInterface(PVBOXNETFLTINS pThis, void *pvIf, void **ppvIfData)
|
---|
1664 | {
|
---|
1665 | /* Nothing to do */
|
---|
1666 | NOREF(pThis); NOREF(pvIf); NOREF(ppvIfData);
|
---|
1667 | return VINF_SUCCESS;
|
---|
1668 | }
|
---|
1669 |
|
---|
1670 |
|
---|
1671 | int vboxNetFltPortOsDisconnectInterface(PVBOXNETFLTINS pThis, void *pvIfData)
|
---|
1672 | {
|
---|
1673 | /* Nothing to do */
|
---|
1674 | NOREF(pThis); NOREF(pvIfData);
|
---|
1675 | return VINF_SUCCESS;
|
---|
1676 | }
|
---|
1677 |
|
---|