Changeset 57904 in vbox
- Timestamp:
- Sep 25, 2015 7:57:12 PM (9 years ago)
- Location:
- trunk/src/VBox/HostDrivers
- Files:
-
- 2 edited
-
VBoxNetAdp/darwin/VBoxNetAdp-darwin.cpp (modified) (2 diffs)
-
VBoxNetFlt/darwin/VBoxNetFlt-darwin.cpp (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostDrivers/VBoxNetAdp/darwin/VBoxNetAdp-darwin.cpp
r57358 r57904 144 144 static errno_t vboxNetAdpDarwinOutput(ifnet_t pIface, mbuf_t pMBuf) 145 145 { 146 PVBOXNETADP pThis = VBOXNETADP_FROM_IFACE(pIface); 147 Assert(pThis); 148 if (pThis->u.s.nTapMode & BPF_MODE_OUTPUT) 149 { 150 Log2(("vboxnetadp: out len=%d\n%.*Rhxd\n", mbuf_len(pMBuf), 14, mbuf_data(pMBuf))); 151 bpf_tap_out(pIface, DLT_EN10MB, pMBuf, NULL, 0); 152 } 146 /* 147 * We are a dummy interface with all the real work done in 148 * VBoxNetFlt bridged networking filter. If anything makes it 149 * this far, just drop it, we have nowhere to send it to. 150 */ 153 151 mbuf_freem_list(pMBuf); 154 152 return 0; … … 205 203 protocol_family_t *pProtocolFamily) 206 204 { 207 PVBOXNETADP pThis = VBOXNETADP_FROM_IFACE(pIface); 208 Assert(pThis); 209 Log2(("vboxNetAdpDarwinDemux: mode=%d\n", pThis->u.s.nTapMode)); 210 if (pThis->u.s.nTapMode & BPF_MODE_INPUT) 211 { 212 Log2(("vboxnetadp: in len=%d\n%.*Rhxd\n", mbuf_len(pMBuf), 14, pFrameHeader)); 213 bpf_tap_in(pIface, DLT_EN10MB, pMBuf, pFrameHeader, ETHER_HDR_LEN); 214 } 205 /* 206 * Anything we get here comes from VBoxNetFlt bridged networking 207 * filter where it has already been accounted for and fed to bpf. 208 */ 215 209 return ether_demux(pIface, pMBuf, pFrameHeader, pProtocolFamily); 216 210 } -
trunk/src/VBox/HostDrivers/VBoxNetFlt/darwin/VBoxNetFlt-darwin.cpp
r57817 r57904 59 59 #include <net/if.h> 60 60 #include <net/if_var.h> 61 RT_C_DECLS_BEGIN 62 #include <net/bpf.h> 63 RT_C_DECLS_END 61 64 #include <netinet/in.h> 62 65 #include <netinet/in_var.h> … … 924 927 { 925 928 /* 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. 929 933 */ 930 if (vboxNetFltDarwinIsPromiscuous(pThis)) 934 if ( fSrc == INTNETTRUNKDIR_WIRE 935 && vboxNetFltDarwinIsPromiscuous(pThis)) 936 { 931 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 } 932 948 } 933 949 } … … 1088 1104 Assert(pThis->pSwitchPort); 1089 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 */ 1090 1113 pThis->pSwitchPort->pfnReportPromiscuousMode(pThis->pSwitchPort, vboxNetFltDarwinIsPromiscuous(pThis)); 1114 #endif 1091 1115 pThis->pSwitchPort->pfnReportGsoCapabilities(pThis->pSwitchPort, 0, INTNETTRUNKDIR_WIRE | INTNETTRUNKDIR_HOST); 1092 1116 pThis->pSwitchPort->pfnReportNoPreemptDsts(pThis->pSwitchPort, 0 /* none */); … … 1127 1151 /* 1128 1152 * 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 the1131 * packet down the stack so it reaches the driver and Berkeley1132 * Packet Filter (see @bugref{5817}).1133 1153 */ 1134 if ( (fDst & INTNETTRUNKDIR_WIRE) || vboxNetFltDarwinIsPromiscuous(pThis))1154 if (fDst & INTNETTRUNKDIR_WIRE) 1135 1155 { 1136 1156 mbuf_t pMBuf = vboxNetFltDarwinMBufFromSG(pThis, pSG); … … 1153 1173 if (pMBuf) 1154 1174 { 1155 /* This is what IONetworkInterface::inputPacket does. */1175 void *pvEthHdr = mbuf_data(pMBuf); 1156 1176 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); 1162 1183 errno_t err = ifnet_input(pIfNet, pMBuf, NULL); 1163 1184 if (err)
Note:
See TracChangeset
for help on using the changeset viewer.

