Simplify logic in ip{,6}_output().

Now, we have M_CSUM_TSOv[46] bit in ifp->if_csum_flags_tx when
TSO[46] is enabled for the interface. So we can simply check
whether TSO[46] is required in a packet but missing in the
interface by (sw_csum & M_CSUM_TSOv[46]).

Note that this is a very rare case where TSO[46] is suddenly
turned off during a packet passing b/w TCP and IP.

part of PR kern/53562
OK msaitoh
This commit is contained in:
rin 2018-12-12 01:53:52 +00:00
parent f7201ab71a
commit 7f120f6563
2 changed files with 18 additions and 15 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: ip_output.c,v 1.307 2018/07/11 05:25:45 maxv Exp $ */
/* $NetBSD: ip_output.c,v 1.308 2018/12/12 01:53:52 rin Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@ -91,7 +91,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ip_output.c,v 1.307 2018/07/11 05:25:45 maxv Exp $");
__KERNEL_RCSID(0, "$NetBSD: ip_output.c,v 1.308 2018/12/12 01:53:52 rin Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@ -715,13 +715,14 @@ sendit:
}
sa = (m->m_flags & M_MCAST) ? sintocsa(rdst) : sintocsa(dst);
if (__predict_true(
(m->m_pkthdr.csum_flags & M_CSUM_TSOv4) == 0 ||
(ifp->if_capenable & IFCAP_TSOv4) != 0)) {
error = ip_if_output(ifp, m, sa, rt);
} else {
if (__predict_false(sw_csum & M_CSUM_TSOv4)) {
/*
* TSO4 is required by a packet, but disabled for
* the interface.
*/
error = ip_tso_output(ifp, m, sa, rt);
}
} else
error = ip_if_output(ifp, m, sa, rt);
goto done;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: ip6_output.c,v 1.213 2018/11/29 10:02:52 ozaki-r Exp $ */
/* $NetBSD: ip6_output.c,v 1.214 2018/12/12 01:53:52 rin Exp $ */
/* $KAME: ip6_output.c,v 1.172 2001/03/25 09:55:56 itojun Exp $ */
/*
@ -62,7 +62,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ip6_output.c,v 1.213 2018/11/29 10:02:52 ozaki-r Exp $");
__KERNEL_RCSID(0, "$NetBSD: ip6_output.c,v 1.214 2018/12/12 01:53:52 rin Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@ -843,12 +843,14 @@ ip6_output(
}
KASSERT(dst != NULL);
if (__predict_true(!tso ||
(ifp->if_capenable & IFCAP_TSOv6) != 0)) {
error = ip6_if_output(ifp, origifp, m, dst, rt);
} else {
if (__predict_false(sw_csum & M_CSUM_TSOv6)) {
/*
* TSO6 is required by a packet, but disabled for
* the interface.
*/
error = ip6_tso_output(ifp, origifp, m, dst, rt);
}
} else
error = ip6_if_output(ifp, origifp, m, dst, rt);
goto done;
}