VirtualBox

Ignore:
Timestamp:
Sep 25, 2015 7:57:12 PM (10 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
102876
Message:

VBoxNetFlt/darwin, VBoxNetAdp/darwin: Don't leak host-guest traffic to
the wire when the interface is in promiscuous mode. Call bpf_tap_in
and bpf_tap_out in the filter. Adjust VBoxNetAdp accordingly.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostDrivers/VBoxNetFlt/darwin/VBoxNetFlt-darwin.cpp

    r57817 r57904  
    5959#include <net/if.h>
    6060#include <net/if_var.h>
     61RT_C_DECLS_BEGIN
     62#include <net/bpf.h>
     63RT_C_DECLS_END
    6164#include <netinet/in.h>
    6265#include <netinet/in_var.h>
     
    924927        {
    925928            /*
    926              * Check if this interface is in promiscuous mode. We should not drop
    927              * any packets before they get to the driver as it passes them to tap
    928              * callbacks in order for BPF to work properly.
     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.
    929933             */
    930             if (vboxNetFltDarwinIsPromiscuous(pThis))
     934            if (   fSrc == INTNETTRUNKDIR_WIRE
     935                && vboxNetFltDarwinIsPromiscuous(pThis))
     936            {
    931937                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            }
    932948        }
    933949    }
     
    10881104            Assert(pThis->pSwitchPort);
    10891105            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             */
    10901113            pThis->pSwitchPort->pfnReportPromiscuousMode(pThis->pSwitchPort, vboxNetFltDarwinIsPromiscuous(pThis));
     1114#endif
    10911115            pThis->pSwitchPort->pfnReportGsoCapabilities(pThis->pSwitchPort, 0,  INTNETTRUNKDIR_WIRE | INTNETTRUNKDIR_HOST);
    10921116            pThis->pSwitchPort->pfnReportNoPreemptDsts(pThis->pSwitchPort, 0 /* none */);
     
    11271151        /*
    11281152         * Create a mbuf for the gather list and push it onto the wire.
    1129          *
    1130          * Note! If the interface is in the promiscuous mode we need to send the
    1131          *       packet down the stack so it reaches the driver and Berkeley
    1132          *       Packet Filter (see @bugref{5817}).
    11331153         */
    1134         if ((fDst & INTNETTRUNKDIR_WIRE) || vboxNetFltDarwinIsPromiscuous(pThis))
     1154        if (fDst & INTNETTRUNKDIR_WIRE)
    11351155        {
    11361156            mbuf_t pMBuf = vboxNetFltDarwinMBufFromSG(pThis, pSG);
     
    11531173            if (pMBuf)
    11541174            {
    1155                 /* This is what IONetworkInterface::inputPacket does. */
     1175                void *pvEthHdr = mbuf_data(pMBuf);
    11561176                unsigned const cbEthHdr = 14;
    1157                 mbuf_pkthdr_setheader(pMBuf, mbuf_data(pMBuf));
    1158                 mbuf_pkthdr_setlen(pMBuf, mbuf_pkthdr_len(pMBuf) - cbEthHdr);
    1159                 mbuf_setdata(pMBuf, (uint8_t *)mbuf_data(pMBuf) + cbEthHdr, mbuf_len(pMBuf) - cbEthHdr);
    1160                 mbuf_pkthdr_setrcvif(pMBuf, pIfNet); /* will crash without this. */
    1161 
     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);
    11621183                errno_t err = ifnet_input(pIfNet, pMBuf, NULL);
    11631184                if (err)
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette