Changeset View
Changeset View
Standalone View
Standalone View
sys/net/if_tuntap.c
| Show First 20 Lines • Show All 1,876 Lines • ▼ Show 20 Lines | tunread(struct cdev *dev, struct uio *uio, int flag) | ||||
| TUN_UNLOCK(tp); | TUN_UNLOCK(tp); | ||||
| len = min(tp->tun_vhdrlen, uio->uio_resid); | len = min(tp->tun_vhdrlen, uio->uio_resid); | ||||
| if (len > 0) { | if (len > 0) { | ||||
| struct virtio_net_hdr_mrg_rxbuf vhdr; | struct virtio_net_hdr_mrg_rxbuf vhdr; | ||||
| bzero(&vhdr, sizeof(vhdr)); | bzero(&vhdr, sizeof(vhdr)); | ||||
| if (m->m_pkthdr.csum_flags & TAP_ALL_OFFLOAD) { | if (m->m_pkthdr.csum_flags & TAP_ALL_OFFLOAD) { | ||||
| m = virtio_net_tx_offload(ifp, m, false, &vhdr.hdr); | /* | ||||
| * Translate the CSUM_* flags in the mbuf to the | |||||
| * corresponding flags in the VirtIO header. | |||||
| * | |||||
| * Always indicate that ECN has not been negotiated | |||||
| * and VirtIO modern mode is not used because bhyve | |||||
| * does not do this. | |||||
| */ | |||||
| virtio_net_tx_offload(ifp, &m, &vhdr.hdr, false, | |||||
| false); | |||||
| } | } | ||||
| TUNDEBUG(ifp, "txvhdr: f %u, gt %u, hl %u, " | TUNDEBUG(ifp, "txvhdr: f %u, gt %u, hl %u, " | ||||
| "gs %u, cs %u, co %u\n", vhdr.hdr.flags, | "gs %u, cs %u, co %u\n", vhdr.hdr.flags, | ||||
| vhdr.hdr.gso_type, vhdr.hdr.hdr_len, | vhdr.hdr.gso_type, vhdr.hdr.hdr_len, | ||||
| vhdr.hdr.gso_size, vhdr.hdr.csum_start, | vhdr.hdr.gso_size, vhdr.hdr.csum_start, | ||||
| vhdr.hdr.csum_offset); | vhdr.hdr.csum_offset); | ||||
| error = uiomove(&vhdr, len, uio); | error = uiomove(&vhdr, len, uio); | ||||
| Show All 28 Lines | tunwrite_l2(struct tuntap_softc *tp, struct mbuf *m, | ||||
| if ((ifp->if_flags & IFF_PROMISC) == 0 && | if ((ifp->if_flags & IFF_PROMISC) == 0 && | ||||
| !ETHER_IS_MULTICAST(eh->ether_dhost) && | !ETHER_IS_MULTICAST(eh->ether_dhost) && | ||||
| bcmp(eh->ether_dhost, IF_LLADDR(ifp), ETHER_ADDR_LEN) != 0) { | bcmp(eh->ether_dhost, IF_LLADDR(ifp), ETHER_ADDR_LEN) != 0) { | ||||
| m_freem(m); | m_freem(m); | ||||
| return (0); | return (0); | ||||
| } | } | ||||
| if (vhdr != NULL) { | if (vhdr != NULL) { | ||||
| if (virtio_net_rx_csum(m, &vhdr->hdr)) { | /* | ||||
| * Translate the VirtIO header flags to the corresponding | |||||
| * CSUM_* flags in the mbuf. | |||||
| */ | |||||
| if (((vhdr->hdr.flags & (VIRTIO_NET_HDR_F_NEEDS_CSUM | | |||||
| VIRTIO_NET_HDR_F_DATA_VALID)) != 0) && | |||||
| (virtio_net_rx_csum(m, &vhdr->hdr) != 0)) { | |||||
| m_freem(m); | m_freem(m); | ||||
| return (0); | return (0); | ||||
| } | } | ||||
| } else { | } else { | ||||
| switch (ntohs(eh->ether_type)) { | switch (ntohs(eh->ether_type)) { | ||||
| #ifdef INET | #ifdef INET | ||||
| case ETHERTYPE_IP: | case ETHERTYPE_IP: | ||||
| if (ifp->if_capenable & IFCAP_RXCSUM) { | if (ifp->if_capenable & IFCAP_RXCSUM) { | ||||
| ▲ Show 20 Lines • Show All 265 Lines • Show Last 20 Lines | |||||