Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys Simplify logic in ip{,6}_output().



details:   https://anonhg.NetBSD.org/src/rev/9d1956807b9e
branches:  trunk
changeset: 446590:9d1956807b9e
user:      rin <rin%NetBSD.org@localhost>
date:      Wed Dec 12 01:53:52 2018 +0000

description:
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

diffstat:

 sys/netinet/ip_output.c   |  17 +++++++++--------
 sys/netinet6/ip6_output.c |  16 +++++++++-------
 2 files changed, 18 insertions(+), 15 deletions(-)

diffs (77 lines):

diff -r c02f72410a3f -r 9d1956807b9e sys/netinet/ip_output.c
--- a/sys/netinet/ip_output.c   Wed Dec 12 01:51:32 2018 +0000
+++ b/sys/netinet/ip_output.c   Wed Dec 12 01:53:52 2018 +0000
@@ -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 @@
                }
 
                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)) {
+               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);
-               } else {
-                       error = ip_tso_output(ifp, m, sa, rt);
-               }
                goto done;
        }
 
diff -r c02f72410a3f -r 9d1956807b9e sys/netinet6/ip6_output.c
--- a/sys/netinet6/ip6_output.c Wed Dec 12 01:51:32 2018 +0000
+++ b/sys/netinet6/ip6_output.c Wed Dec 12 01:53:52 2018 +0000
@@ -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 @@
                }
 
                KASSERT(dst != NULL);
-               if (__predict_true(!tso ||
-                   (ifp->if_capenable & IFCAP_TSOv6) != 0)) {
+               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);
-               } else {
-                       error = ip6_tso_output(ifp, origifp, m, dst, rt);
-               }
                goto done;
        }
 



Home | Main Index | Thread Index | Old Index