Source-Changes-HG archive

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

[src/trunk]: src/sys Rename



details:   https://anonhg.NetBSD.org/src/rev/11b77dd91d35
branches:  trunk
changeset: 320532:11b77dd91d35
user:      maxv <maxv%NetBSD.org@localhost>
date:      Wed Jul 11 05:25:45 2018 +0000

description:
Rename

        ip_undefer_csum  -> in_undefer_cksum
        in_delayed_cksum -> in_undefer_cksum_tcpudp

The two previous names were inconsistent and misleading.

Put the two functions into in_offload.c. Add comments to explain what
we're doing.

The same could be done for IPv6.

diffstat:

 sys/arch/powerpc/booke/dev/pq3etsec.c        |   6 ++--
 sys/dist/pf/net/pf.c                         |   6 ++--
 sys/dist/pf/net/pf_ioctl.c                   |   6 ++--
 sys/external/bsd/ipf/netinet/fil.c           |   9 ++++--
 sys/external/bsd/ipf/netinet/ip_fil_netbsd.c |   9 ++++--
 sys/net/if_loop.c                            |   6 ++--
 sys/net/npf/npf_mbuf.c                       |   7 +++--
 sys/netinet/in.h                             |   3 +-
 sys/netinet/in_offload.c                     |  36 +++++++++++++++++++++++++--
 sys/netinet/in_offload.h                     |   5 ++-
 sys/netinet/ip_mroute.c                      |   8 +++---
 sys/netinet/ip_output.c                      |  35 +++-----------------------
 sys/netipsec/ipsec.c                         |   7 +++--
 13 files changed, 78 insertions(+), 65 deletions(-)

diffs (truncated from 457 to 300 lines):

diff -r e47c78250a90 -r 11b77dd91d35 sys/arch/powerpc/booke/dev/pq3etsec.c
--- a/sys/arch/powerpc/booke/dev/pq3etsec.c     Wed Jul 11 03:36:32 2018 +0000
+++ b/sys/arch/powerpc/booke/dev/pq3etsec.c     Wed Jul 11 05:25:45 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pq3etsec.c,v 1.34 2018/06/26 06:47:59 msaitoh Exp $    */
+/*     $NetBSD: pq3etsec.c,v 1.35 2018/07/11 05:25:45 maxv Exp $       */
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -41,7 +41,7 @@
 
 #include <sys/cdefs.h>
 
-__KERNEL_RCSID(0, "$NetBSD: pq3etsec.c,v 1.34 2018/06/26 06:47:59 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pq3etsec.c,v 1.35 2018/07/11 05:25:45 maxv Exp $");
 
 #include <sys/param.h>
 #include <sys/cpu.h>
@@ -2087,7 +2087,7 @@
                if (mn == NULL) {
                        if (csum_flags & M_CSUM_IP4) {
 #ifdef INET
-                               ip_undefer_csum(m, ETHER_HDR_LEN,
+                               in_undefer_cksum(m, ETHER_HDR_LEN,
                                    csum_flags & M_CSUM_IP4);
 #else
                                panic("%s: impossible M_CSUM flags %#x",
diff -r e47c78250a90 -r 11b77dd91d35 sys/dist/pf/net/pf.c
--- a/sys/dist/pf/net/pf.c      Wed Jul 11 03:36:32 2018 +0000
+++ b/sys/dist/pf/net/pf.c      Wed Jul 11 05:25:45 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pf.c,v 1.81 2018/05/03 07:01:08 maxv Exp $     */
+/*     $NetBSD: pf.c,v 1.82 2018/07/11 05:25:46 maxv Exp $     */
 /*     $OpenBSD: pf.c,v 1.552.2.1 2007/11/27 16:37:57 henning Exp $ */
 
 /*
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pf.c,v 1.81 2018/05/03 07:01:08 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pf.c,v 1.82 2018/07/11 05:25:46 maxv Exp $");
 
 #include "pflog.h"
 
@@ -5353,7 +5353,7 @@
        /* Catch routing changes wrt. hardware checksumming for TCP or UDP. */
 #ifdef __NetBSD__
        if (m0->m_pkthdr.csum_flags & (M_CSUM_TCPv4|M_CSUM_UDPv4)) {
-               in_delayed_cksum(m0);
+               in_undefer_cksum_tcpudp(m0);
                m0->m_pkthdr.csum_flags &= ~(M_CSUM_TCPv4|M_CSUM_UDPv4);
        }
 #else
diff -r e47c78250a90 -r 11b77dd91d35 sys/dist/pf/net/pf_ioctl.c
--- a/sys/dist/pf/net/pf_ioctl.c        Wed Jul 11 03:36:32 2018 +0000
+++ b/sys/dist/pf/net/pf_ioctl.c        Wed Jul 11 05:25:45 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pf_ioctl.c,v 1.52 2017/10/15 04:30:05 pgoyette Exp $   */
+/*     $NetBSD: pf_ioctl.c,v 1.53 2018/07/11 05:25:46 maxv Exp $       */
 /*     $OpenBSD: pf_ioctl.c,v 1.182 2007/06/24 11:17:13 mcbride Exp $ */
 
 /*
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pf_ioctl.c,v 1.52 2017/10/15 04:30:05 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pf_ioctl.c,v 1.53 2018/07/11 05:25:46 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -3293,7 +3293,7 @@
         */
        if (dir == PFIL_OUT) {
                if ((*mp)->m_pkthdr.csum_flags & (M_CSUM_TCPv4|M_CSUM_UDPv4)) {
-                       in_delayed_cksum(*mp);
+                       in_undefer_cksum_tcpudp(*mp);
                        (*mp)->m_pkthdr.csum_flags &=
                            ~(M_CSUM_TCPv4|M_CSUM_UDPv4);
                }
diff -r e47c78250a90 -r 11b77dd91d35 sys/external/bsd/ipf/netinet/fil.c
--- a/sys/external/bsd/ipf/netinet/fil.c        Wed Jul 11 03:36:32 2018 +0000
+++ b/sys/external/bsd/ipf/netinet/fil.c        Wed Jul 11 05:25:45 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fil.c,v 1.23 2018/06/03 10:37:23 maxv Exp $    */
+/*     $NetBSD: fil.c,v 1.24 2018/07/11 05:25:46 maxv Exp $    */
 
 /*
  * Copyright (C) 2012 by Darren Reed.
@@ -133,12 +133,15 @@
 # include <sys/timeout.h>
 extern struct timeout ipf_slowtimer_ch;
 #endif
+#if defined(__NetBSD__)
+#include <netinet/in_offload.h>
+#endif
 /* END OF INCLUDES */
 
 #if !defined(lint)
 #if defined(__NetBSD__)
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fil.c,v 1.23 2018/06/03 10:37:23 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fil.c,v 1.24 2018/07/11 05:25:46 maxv Exp $");
 #else
 static const char sccsid[] = "@(#)fil.c        1.36 6/5/96 (C) 1993-2000 Darren Reed";
 static const char rcsid[] = "@(#)Id: fil.c,v 1.1.1.2 2012/07/22 13:45:07 darrenr Exp $";
@@ -2853,7 +2856,7 @@
         * disable delayed checksums.
         */
        if (m->m_pkthdr.csum_flags & CSUM_DELAY_DATA) {
-               in_delayed_cksum(m);
+               in_undefer_cksum_tcpudp(m);
                m->m_pkthdr.csum_flags &= ~CSUM_DELAY_DATA;
        }
 #  endif /* CSUM_DELAY_DATA */
diff -r e47c78250a90 -r 11b77dd91d35 sys/external/bsd/ipf/netinet/ip_fil_netbsd.c
--- a/sys/external/bsd/ipf/netinet/ip_fil_netbsd.c      Wed Jul 11 03:36:32 2018 +0000
+++ b/sys/external/bsd/ipf/netinet/ip_fil_netbsd.c      Wed Jul 11 05:25:45 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ip_fil_netbsd.c,v 1.28 2018/05/03 07:13:48 maxv Exp $  */
+/*     $NetBSD: ip_fil_netbsd.c,v 1.29 2018/07/11 05:25:46 maxv Exp $  */
 
 /*
  * Copyright (C) 2012 by Darren Reed.
@@ -8,7 +8,7 @@
 #if !defined(lint)
 #if defined(__NetBSD__)
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ip_fil_netbsd.c,v 1.28 2018/05/03 07:13:48 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_fil_netbsd.c,v 1.29 2018/07/11 05:25:46 maxv Exp $");
 #else
 static const char sccsid[] = "@(#)ip_fil.c     2.41 6/5/96 (C) 1993-2000 Darren Reed";
 static const char rcsid[] = "@(#)Id: ip_fil_netbsd.c,v 1.1.1.2 2012/07/22 13:45:17 darrenr Exp";
@@ -57,6 +57,9 @@
 #include <sys/module.h>
 #include <sys/mutex.h>
 #endif
+#if defined(__NetBSD__)
+#include <netinet/in_offload.h>
+#endif
 
 #include <net/if.h>
 #include <net/route.h>
@@ -219,7 +222,7 @@
         */
        if (dir == PFIL_OUT) {
                if ((*mp)->m_pkthdr.csum_flags & (M_CSUM_TCPv4|M_CSUM_UDPv4)) {
-                       in_delayed_cksum(*mp);
+                       in_undefer_cksum_tcpudp(*mp);
                        (*mp)->m_pkthdr.csum_flags &=
                            ~(M_CSUM_TCPv4|M_CSUM_UDPv4);
                }
diff -r e47c78250a90 -r 11b77dd91d35 sys/net/if_loop.c
--- a/sys/net/if_loop.c Wed Jul 11 03:36:32 2018 +0000
+++ b/sys/net/if_loop.c Wed Jul 11 05:25:45 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_loop.c,v 1.103 2018/06/28 06:02:24 ozaki-r Exp $    */
+/*     $NetBSD: if_loop.c,v 1.104 2018/07/11 05:25:45 maxv Exp $       */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -65,7 +65,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_loop.c,v 1.103 2018/06/28 06:02:24 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_loop.c,v 1.104 2018/07/11 05:25:45 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -320,7 +320,7 @@
                csum_flags = m->m_pkthdr.csum_flags;
                KASSERT((csum_flags & ~(M_CSUM_IPv4|M_CSUM_UDPv4)) == 0);
                if (csum_flags != 0 && IN_LOOPBACK_NEED_CHECKSUM(csum_flags)) {
-                       ip_undefer_csum(m, 0, csum_flags);
+                       in_undefer_cksum(m, 0, csum_flags);
                }
                m->m_pkthdr.csum_flags = 0;
                pktq = ip_pktq;
diff -r e47c78250a90 -r 11b77dd91d35 sys/net/npf/npf_mbuf.c
--- a/sys/net/npf/npf_mbuf.c    Wed Jul 11 03:36:32 2018 +0000
+++ b/sys/net/npf/npf_mbuf.c    Wed Jul 11 05:25:45 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: npf_mbuf.c,v 1.18 2016/12/26 23:05:06 christos Exp $   */
+/*     $NetBSD: npf_mbuf.c,v 1.19 2018/07/11 05:25:45 maxv Exp $       */
 
 /*-
  * Copyright (c) 2009-2012 The NetBSD Foundation, Inc.
@@ -38,10 +38,11 @@
 
 #ifdef _KERNEL
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: npf_mbuf.c,v 1.18 2016/12/26 23:05:06 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: npf_mbuf.c,v 1.19 2018/07/11 05:25:45 maxv Exp $");
 
 #include <sys/param.h>
 #include <sys/mbuf.h>
+#include <netinet/in_offload.h>
 #endif
 
 #include "npf_impl.h"
@@ -272,7 +273,7 @@
        KASSERT(m_flags_p(m, M_PKTHDR));
 
        if (m->m_pkthdr.csum_flags & (M_CSUM_TCPv4 | M_CSUM_UDPv4)) {
-               in_delayed_cksum(m);
+               in_undefer_cksum_tcpudp(m);
                m->m_pkthdr.csum_flags &= ~(M_CSUM_TCPv4 | M_CSUM_UDPv4);
                return true;
        }
diff -r e47c78250a90 -r 11b77dd91d35 sys/netinet/in.h
--- a/sys/netinet/in.h  Wed Jul 11 03:36:32 2018 +0000
+++ b/sys/netinet/in.h  Wed Jul 11 05:25:45 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: in.h,v 1.105 2018/04/19 21:21:44 christos Exp $        */
+/*     $NetBSD: in.h,v 1.106 2018/07/11 05:25:45 maxv Exp $    */
 
 /*
  * Copyright (c) 1982, 1986, 1990, 1993
@@ -569,7 +569,6 @@
 int    cpu_in_cksum(struct mbuf *, int, int, uint32_t);
 int    in_cksum(struct mbuf *, int);
 int    in4_cksum(struct mbuf *, u_int8_t, int, int);
-void   in_delayed_cksum(struct mbuf *);
 int    in_localaddr(struct in_addr);
 void   in_socktrim(struct sockaddr_in *);
 
diff -r e47c78250a90 -r 11b77dd91d35 sys/netinet/in_offload.c
--- a/sys/netinet/in_offload.c  Wed Jul 11 03:36:32 2018 +0000
+++ b/sys/netinet/in_offload.c  Wed Jul 11 05:25:45 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: in_offload.c,v 1.7 2016/04/26 09:30:01 ozaki-r Exp $   */
+/*     $NetBSD: in_offload.c,v 1.8 2018/07/11 05:25:45 maxv Exp $      */
 
 /*-
  * Copyright (c)2005, 2006 YAMAMOTO Takashi,
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: in_offload.c,v 1.7 2016/04/26 09:30:01 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in_offload.c,v 1.8 2018/07/11 05:25:45 maxv Exp $");
 
 #include <sys/param.h>
 #include <sys/mbuf.h>
@@ -197,8 +197,12 @@
        return error;
 }
 
+/*
+ * Compute now in software the IP and TCP/UDP checksums. Cancel the
+ * hardware offloading.
+ */
 void
-ip_undefer_csum(struct mbuf *m, size_t hdrlen, int csum_flags)
+in_undefer_cksum(struct mbuf *m, size_t hdrlen, int csum_flags)
 {
        const size_t iphdrlen = M_CSUM_DATA_IPv4_IPHL(m->m_pkthdr.csum_data);
        uint16_t csum;
@@ -252,3 +256,29 @@
 
        m->m_pkthdr.csum_flags ^= csum_flags;
 }
+
+/*
+ * Compute now in software the TCP/UDP checksum. Cancel the hardware
+ * offloading.
+ */
+void
+in_undefer_cksum_tcpudp(struct mbuf *m)
+{
+       struct ip *ip;
+       u_int16_t csum, offset;
+
+       ip = mtod(m, struct ip *);
+       offset = ip->ip_hl << 2;
+       csum = in4_cksum(m, 0, offset, ntohs(ip->ip_len) - offset);
+       if (csum == 0 && (m->m_pkthdr.csum_flags & M_CSUM_UDPv4) != 0)
+               csum = 0xffff;
+
+       offset += M_CSUM_DATA_IPv4_OFFSET(m->m_pkthdr.csum_data);
+
+       if ((offset + sizeof(u_int16_t)) > m->m_len) {
+               /* This happens when ip options were inserted */
+               m_copyback(m, offset, sizeof(csum), (void *)&csum);
+       } else {
+               *(u_int16_t *)(mtod(m, char *) + offset) = csum;
+       }
+}
diff -r e47c78250a90 -r 11b77dd91d35 sys/netinet/in_offload.h
--- a/sys/netinet/in_offload.h  Wed Jul 11 03:36:32 2018 +0000
+++ b/sys/netinet/in_offload.h  Wed Jul 11 05:25:45 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: in_offload.h,v 1.8 2011/04/25 22:20:59 yamt Exp $      */
+/*     $NetBSD: in_offload.h,v 1.9 2018/07/11 05:25:45 maxv Exp $      */
 
 /*-
  * Copyright (c)2005, 2006 YAMAMOTO Takashi,
@@ -36,7 +36,8 @@



Home | Main Index | Thread Index | Old Index