add support for skipping IPv4 checksums
This commit is contained in:
parent
607744efc3
commit
b39bb188f5
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: if_xennet_xenbus.c,v 1.91 2020/03/18 19:23:13 jdolecek Exp $ */
|
||||
/* $NetBSD: if_xennet_xenbus.c,v 1.92 2020/03/19 10:53:43 jdolecek Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2006 Manuel Bouyer.
|
||||
@ -84,7 +84,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: if_xennet_xenbus.c,v 1.91 2020/03/18 19:23:13 jdolecek Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: if_xennet_xenbus.c,v 1.92 2020/03/19 10:53:43 jdolecek Exp $");
|
||||
|
||||
#include "opt_xen.h"
|
||||
#include "opt_nfs_boot.h"
|
||||
@ -387,7 +387,8 @@ xennet_xenbus_attach(device_t parent, device_t self, void *aux)
|
||||
ifp->if_timer = 0;
|
||||
ifp->if_snd.ifq_maxlen = uimax(ifqmaxlen, NET_TX_RING_SIZE * 2);
|
||||
ifp->if_capabilities =
|
||||
IFCAP_CSUM_UDPv4_Rx | IFCAP_CSUM_UDPv4_Tx
|
||||
IFCAP_CSUM_IPv4_Rx | IFCAP_CSUM_IPv4_Tx
|
||||
| IFCAP_CSUM_UDPv4_Rx | IFCAP_CSUM_UDPv4_Tx
|
||||
| IFCAP_CSUM_TCPv4_Rx | IFCAP_CSUM_TCPv4_Tx;
|
||||
IFQ_SET_READY(&ifp->if_snd);
|
||||
if_attach(ifp);
|
||||
@ -1229,7 +1230,7 @@ xennet_softstart(void *arg)
|
||||
}
|
||||
|
||||
if ((m->m_pkthdr.csum_flags &
|
||||
(M_CSUM_TCPv4 | M_CSUM_UDPv4)) != 0) {
|
||||
(M_CSUM_TCPv4 | M_CSUM_UDPv4 | M_CSUM_IPv4)) != 0) {
|
||||
txflags = NETTXF_csum_blank;
|
||||
} else {
|
||||
txflags = NETTXF_data_validated;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: xennet_checksum.c,v 1.7 2020/03/18 19:23:13 jdolecek Exp $ */
|
||||
/* $NetBSD: xennet_checksum.c,v 1.8 2020/03/19 10:53:43 jdolecek Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c)2006 YAMAMOTO Takashi,
|
||||
@ -27,7 +27,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: xennet_checksum.c,v 1.7 2020/03/18 19:23:13 jdolecek Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: xennet_checksum.c,v 1.8 2020/03/19 10:53:43 jdolecek Exp $");
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
@ -126,15 +126,20 @@ xennet_checksum_fill(struct ifnet *ifp, struct mbuf *m, bool data_validated)
|
||||
|
||||
switch (nxt) {
|
||||
case IPPROTO_UDP:
|
||||
m->m_pkthdr.csum_flags = M_CSUM_UDPv4;
|
||||
m->m_pkthdr.csum_flags = M_CSUM_UDPv4 | M_CSUM_IPv4;
|
||||
m->m_pkthdr.csum_data = offsetof(struct udphdr, uh_sum);
|
||||
m->m_pkthdr.csum_data |= iphlen << 16;
|
||||
break;
|
||||
case IPPROTO_TCP:
|
||||
m->m_pkthdr.csum_flags = M_CSUM_TCPv4;
|
||||
m->m_pkthdr.csum_flags = M_CSUM_TCPv4 | M_CSUM_IPv4;
|
||||
m->m_pkthdr.csum_data = offsetof(struct tcphdr, th_sum);
|
||||
m->m_pkthdr.csum_data |= iphlen << 16;
|
||||
break;
|
||||
case IPPROTO_ICMP:
|
||||
case IPPROTO_IGMP:
|
||||
m->m_pkthdr.csum_flags = M_CSUM_IPv4;
|
||||
m->m_pkthdr.csum_data = iphlen << 16;
|
||||
break;
|
||||
default:
|
||||
{
|
||||
static struct timeval lasttime;
|
||||
@ -153,6 +158,14 @@ xennet_checksum_fill(struct ifnet *ifp, struct mbuf *m, bool data_validated)
|
||||
*/
|
||||
sw_csum = m->m_pkthdr.csum_flags & ~ifp->if_csum_flags_rx;
|
||||
|
||||
/*
|
||||
* Always initialize the sum to 0! Some HW assisted
|
||||
* checksumming requires this. in_undefer_cksum()
|
||||
* also needs it to be zero.
|
||||
*/
|
||||
if (m->m_pkthdr.csum_flags & M_CSUM_IPv4)
|
||||
iph->ip_sum = 0;
|
||||
|
||||
if (sw_csum & (M_CSUM_IPv4|M_CSUM_UDPv4|M_CSUM_TCPv4)) {
|
||||
in_undefer_cksum(m, ehlen,
|
||||
sw_csum & (M_CSUM_IPv4|M_CSUM_UDPv4|M_CSUM_TCPv4));
|
||||
|
Loading…
Reference in New Issue
Block a user