This commit is contained in:
purplerain 2023-05-16 22:16:59 +00:00
parent ab90ba3a7c
commit 9e5eddc6af
Signed by: purplerain
GPG key ID: F42C07F07E2E35B7
57 changed files with 838 additions and 537 deletions

View file

@ -1,4 +1,4 @@
/* $OpenBSD: in_proto.c,v 1.99 2022/08/15 09:11:38 mvs Exp $ */
/* $OpenBSD: in_proto.c,v 1.100 2023/05/16 19:36:00 mvs Exp $ */
/* $NetBSD: in_proto.c,v 1.14 1996/02/18 18:58:32 christos Exp $ */
/*
@ -177,6 +177,7 @@ u_char ip_protox[IPPROTO_MAX];
const struct protosw inetsw[] = {
{
.pr_domain = &inetdomain,
.pr_flags = PR_MPSYSCTL,
.pr_init = ip_init,
.pr_slowtimo = ip_slowtimo,
.pr_sysctl = ip_sysctl

View file

@ -1,4 +1,4 @@
/* $OpenBSD: ip_carp.c,v 1.356 2023/03/08 04:43:09 guenther Exp $ */
/* $OpenBSD: ip_carp.c,v 1.357 2023/05/16 14:32:54 jan Exp $ */
/*
* Copyright (c) 2002 Michael Shalayeff. All rights reserved.
@ -1693,7 +1693,7 @@ carp_set_ifp(struct carp_softc *sc, struct ifnet *ifp0)
sc->sc_carpdevidx = ifp0->if_index;
sc->sc_if.if_capabilities = ifp0->if_capabilities &
IFCAP_CSUM_MASK;
(IFCAP_CSUM_MASK | IFCAP_TSOv4 | IFCAP_TSOv6);
SRPL_FOREACH_LOCKED(vr, cif, sc_list) {
struct carp_vhost_entry *vrhead, *schead;

View file

@ -1,4 +1,4 @@
/* $OpenBSD: ip_input.c,v 1.383 2023/04/05 21:51:47 bluhm Exp $ */
/* $OpenBSD: ip_input.c,v 1.384 2023/05/16 19:36:00 mvs Exp $ */
/* $NetBSD: ip_input.c,v 1.30 1996/03/16 23:53:58 christos Exp $ */
/*
@ -1704,8 +1704,11 @@ ip_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp,
return (ip_sysctl_ipstat(oldp, oldlenp, newp));
#ifdef MROUTING
case IPCTL_MRTSTATS:
return (sysctl_rdstruct(oldp, oldlenp, newp,
&mrtstat, sizeof(mrtstat)));
KERNEL_LOCK();
error = sysctl_rdstruct(oldp, oldlenp, newp,
&mrtstat, sizeof(mrtstat));
KERNEL_UNLOCK();
return (error);
case IPCTL_MRTMFC:
if (newp)
return (EPERM);

View file

@ -1,4 +1,4 @@
/* $OpenBSD: ip_output.c,v 1.386 2023/05/13 13:35:17 bluhm Exp $ */
/* $OpenBSD: ip_output.c,v 1.387 2023/05/15 16:34:56 bluhm Exp $ */
/* $NetBSD: ip_output.c,v 1.28 1996/02/13 23:43:07 christos Exp $ */
/*
@ -460,15 +460,10 @@ sendit:
goto done;
}
if (ISSET(m->m_pkthdr.csum_flags, M_TCP_TSO) &&
m->m_pkthdr.ph_mss <= mtu) {
if ((error = tcp_chopper(m, &ml, ifp, m->m_pkthdr.ph_mss)) ||
(error = if_output_ml(ifp, &ml, sintosa(dst), ro->ro_rt)))
goto done;
tcpstat_inc(tcps_outswtso);
error = tcp_if_output_tso(ifp, &m, sintosa(dst), ro->ro_rt,
IFCAP_TSOv4, mtu);
if (error || m == NULL)
goto done;
}
CLR(m->m_pkthdr.csum_flags, M_TCP_TSO);
/*
* Too large for interface; fragment if possible.
@ -1887,10 +1882,15 @@ in_proto_cksum_out(struct mbuf *m, struct ifnet *ifp)
u_int16_t csum = 0, offset;
offset = ip->ip_hl << 2;
if (m->m_pkthdr.csum_flags & (M_TCP_CSUM_OUT|M_UDP_CSUM_OUT))
if (ISSET(m->m_pkthdr.csum_flags, M_TCP_TSO)) {
csum = in_cksum_phdr(ip->ip_src.s_addr,
ip->ip_dst.s_addr, htonl(ip->ip_p));
} else if (ISSET(m->m_pkthdr.csum_flags,
M_TCP_CSUM_OUT|M_UDP_CSUM_OUT)) {
csum = in_cksum_phdr(ip->ip_src.s_addr,
ip->ip_dst.s_addr, htonl(ntohs(ip->ip_len) -
offset + ip->ip_p));
}
if (ip->ip_p == IPPROTO_TCP)
offset += offsetof(struct tcphdr, th_sum);
else if (ip->ip_p == IPPROTO_UDP)

View file

@ -1,4 +1,4 @@
/* $OpenBSD: tcp_output.c,v 1.137 2023/05/13 13:35:18 bluhm Exp $ */
/* $OpenBSD: tcp_output.c,v 1.138 2023/05/15 16:34:56 bluhm Exp $ */
/* $NetBSD: tcp_output.c,v 1.16 1997/06/03 16:17:09 kml Exp $ */
/*
@ -80,6 +80,7 @@
#include <sys/kernel.h>
#include <net/if.h>
#include <net/if_var.h>
#include <net/route.h>
#if NPF > 0
#include <net/pfvar.h>
@ -753,7 +754,7 @@ send:
/* Enable TSO and specify the size of the resulting segments. */
if (tso) {
m->m_pkthdr.csum_flags |= M_TCP_TSO;
SET(m->m_pkthdr.csum_flags, M_TCP_TSO);
m->m_pkthdr.ph_mss = tp->t_maxseg;
}
@ -1349,3 +1350,45 @@ tcp_chopper(struct mbuf *m0, struct mbuf_list *ml, struct ifnet *ifp,
ml_purge(ml);
return error;
}
int
tcp_if_output_tso(struct ifnet *ifp, struct mbuf **mp, struct sockaddr *dst,
struct rtentry *rt, uint32_t ifcap, u_int mtu)
{
struct mbuf_list ml;
int error;
/* caller must fail later or fragment */
if (!ISSET((*mp)->m_pkthdr.csum_flags, M_TCP_TSO))
return 0;
if ((*mp)->m_pkthdr.ph_mss > mtu) {
CLR((*mp)->m_pkthdr.csum_flags, M_TCP_TSO);
return 0;
}
/* network interface hardware will do TSO */
if (in_ifcap_cksum(*mp, ifp, ifcap)) {
if (ISSET(ifcap, IFCAP_TSOv4)) {
in_hdr_cksum_out(*mp, ifp);
in_proto_cksum_out(*mp, ifp);
}
#ifdef INET6
if (ISSET(ifcap, IFCAP_TSOv6))
in6_proto_cksum_out(*mp, ifp);
#endif
error = ifp->if_output(ifp, *mp, dst, rt);
if (!error)
tcpstat_inc(tcps_outhwtso);
goto done;
}
/* as fallback do TSO in software */
if ((error = tcp_chopper(*mp, &ml, ifp, (*mp)->m_pkthdr.ph_mss)) ||
(error = if_output_ml(ifp, &ml, dst, rt)))
goto done;
tcpstat_inc(tcps_outswtso);
done:
*mp = NULL;
return error;
}

View file

@ -1,4 +1,4 @@
/* $OpenBSD: tcp_var.h,v 1.164 2023/05/10 12:07:16 bluhm Exp $ */
/* $OpenBSD: tcp_var.h,v 1.165 2023/05/15 16:34:56 bluhm Exp $ */
/* $NetBSD: tcp_var.h,v 1.17 1996/02/13 23:44:24 christos Exp $ */
/*
@ -719,6 +719,8 @@ struct tcpcb *
void tcp_notify(struct inpcb *, int);
int tcp_output(struct tcpcb *);
int tcp_chopper(struct mbuf *, struct mbuf_list *, struct ifnet *, u_int);
int tcp_if_output_tso(struct ifnet *, struct mbuf **, struct sockaddr *,
struct rtentry *, uint32_t, u_int);
void tcp_pulloutofband(struct socket *, u_int, struct mbuf *, int);
int tcp_reass(struct tcpcb *, struct tcphdr *, struct mbuf *, int *);
void tcp_rscale(struct tcpcb *, u_long);