Source-Changes-HG archive

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

[src/trunk]: src/sys/netinet Remove unused checksum code.



details:   https://anonhg.NetBSD.org/src/rev/8ca439846fa3
branches:  trunk
changeset: 964720:8ca439846fa3
user:      rjs <rjs%NetBSD.org@localhost>
date:      Tue Aug 13 19:55:40 2019 +0000

description:
Remove unused checksum code.

diffstat:

 sys/netinet/sctp_crc32.c |    7 +-
 sys/netinet/sctp_crc32.h |    4 +-
 sys/netinet/sctputil.c   |  122 +---------------------------------------------
 3 files changed, 7 insertions(+), 126 deletions(-)

diffs (241 lines):

diff -r 3f5168b51989 -r 8ca439846fa3 sys/netinet/sctp_crc32.c
--- a/sys/netinet/sctp_crc32.c  Tue Aug 13 17:57:49 2019 +0000
+++ b/sys/netinet/sctp_crc32.c  Tue Aug 13 19:55:40 2019 +0000
@@ -1,5 +1,5 @@
 /*     $KAME: sctp_crc32.c,v 1.12 2005/03/06 16:04:17 itojun Exp $     */
-/*     $NetBSD: sctp_crc32.c,v 1.2 2016/08/12 19:08:54 jdolecek Exp $ */
+/*     $NetBSD: sctp_crc32.c,v 1.3 2019/08/13 19:55:40 rjs Exp $ */
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Cisco Systems, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sctp_crc32.c,v 1.2 2016/08/12 19:08:54 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sctp_crc32.c,v 1.3 2019/08/13 19:55:40 rjs Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_sctp.h"
@@ -43,8 +43,6 @@
 #include <sys/param.h>
 #include <netinet/sctp_crc32.h>
 
-#ifndef SCTP_USE_ADLER32
-
 #define SCTP_CRC32C_POLY 0x1EDC6F41
 #define SCTP_CRC32C(c, d) (c = ((c) >> 8) ^ sctp_crc_c[((c) ^ (d)) & 0xFF])
 
@@ -181,4 +179,3 @@
        return (crc32c);
 }
 
-#endif
diff -r 3f5168b51989 -r 8ca439846fa3 sys/netinet/sctp_crc32.h
--- a/sys/netinet/sctp_crc32.h  Tue Aug 13 17:57:49 2019 +0000
+++ b/sys/netinet/sctp_crc32.h  Tue Aug 13 19:55:40 2019 +0000
@@ -1,5 +1,5 @@
 /*     $KAME: sctp_crc32.h,v 1.5 2004/08/17 04:06:16 itojun Exp $      */
-/*     $NetBSD: sctp_crc32.h,v 1.1 2015/10/13 21:28:35 rjs Exp $ */
+/*     $NetBSD: sctp_crc32.h,v 1.2 2019/08/13 19:55:40 rjs Exp $ */
 
 #ifndef __SCTP_CRC32C_H__
 #define __SCTP_CRC32C_H__
@@ -38,12 +38,10 @@
 
 #include <sys/types.h>
 
-#ifndef SCTP_USE_ADLER32
 #if defined(_KERNEL)
 u_int32_t update_crc32(u_int32_t, unsigned char *, unsigned int);
 
 u_int32_t sctp_csum_finalize(u_int32_t);
 
 #endif /* _KERNEL */
-#endif /* !SCTP_USE_ADLER32 */
 #endif /* __SCTP_CRC32C_H__ */
diff -r 3f5168b51989 -r 8ca439846fa3 sys/netinet/sctputil.c
--- a/sys/netinet/sctputil.c    Tue Aug 13 17:57:49 2019 +0000
+++ b/sys/netinet/sctputil.c    Tue Aug 13 19:55:40 2019 +0000
@@ -1,5 +1,5 @@
 /*     $KAME: sctputil.c,v 1.39 2005/06/16 20:54:06 jinmei Exp $       */
-/*     $NetBSD: sctputil.c,v 1.14 2018/11/08 06:34:40 msaitoh Exp $    */
+/*     $NetBSD: sctputil.c,v 1.15 2019/08/13 19:55:40 rjs Exp $        */
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Cisco Systems, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sctputil.c,v 1.14 2018/11/08 06:34:40 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sctputil.c,v 1.15 2019/08/13 19:55:40 rjs Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -1572,47 +1572,6 @@
        return (0);
 }
 
-#ifdef SCTP_USE_ADLER32
-static uint32_t
-update_adler32(uint32_t adler, uint8_t *buf, int32_t len)
-{
-       u_int32_t s1 = adler & 0xffff;
-       u_int32_t s2 = (adler >> 16) & 0xffff;
-       int n;
-
-       for (n = 0; n < len; n++, buf++) {
-               /* s1 = (s1 + buf[n]) % BASE */
-               /* first we add */
-               s1 = (s1 + *buf);
-               /*
-                * now if we need to, we do a mod by subtracting. It seems
-                * a bit faster since I really will only ever do one subtract
-                * at the MOST, since buf[n] is a max of 255.
-                */
-               if (s1 >= SCTP_ADLER32_BASE) {
-                       s1 -= SCTP_ADLER32_BASE;
-               }
-               /* s2 = (s2 + s1) % BASE */
-               /* first we add */
-               s2 = (s2 + s1);
-               /*
-                * again, it is more efficent (it seems) to subtract since
-                * the most s2 will ever be is (BASE-1 + BASE-1) in the worse
-                * case. This would then be (2 * BASE) - 2, which will still
-                * only do one subtract. On Intel this is much better to do
-                * this way and avoid the divide. Have not -pg'd on sparc.
-                */
-               if (s2 >= SCTP_ADLER32_BASE) {
-                       s2 -= SCTP_ADLER32_BASE;
-               }
-       }
-       /* Return the adler32 of the bytes buf[0..len-1] */
-       return ((s2 << 16) + s1);
-}
-
-#endif
-
-
 u_int32_t
 sctp_calculate_len(struct mbuf *m)
 {
@@ -1626,31 +1585,6 @@
        return (tlen);
 }
 
-#if defined(SCTP_WITH_NO_CSUM)
-
-uint32_t
-sctp_calculate_sum(struct mbuf *m, int32_t *pktlen, uint32_t offset)
-{
-       /*
-        * given a mbuf chain with a packetheader offset by 'offset'
-        * pointing at a sctphdr (with csum set to 0) go through
-        * the chain of m_next's and calculate the SCTP checksum.
-        * This is currently Adler32 but will change to CRC32x
-        * soon. Also has a side bonus calculate the total length
-        * of the mbuf chain.
-        * Note: if offset is greater than the total mbuf length,
-        * checksum=1, pktlen=0 is returned (ie. no real error code)
-        */
-       if (pktlen == NULL)
-               return (0);
-       *pktlen = sctp_calculate_len(m);
-       return (0);
-}
-
-#elif defined(SCTP_USE_INCHKSUM)
-
-#include <machine/in_cksum.h>
-
 uint32_t
 sctp_calculate_sum(struct mbuf *m, int32_t *pktlen, uint32_t offset)
 {
@@ -1658,49 +1592,14 @@
         * given a mbuf chain with a packetheader offset by 'offset'
         * pointing at a sctphdr (with csum set to 0) go through
         * the chain of m_next's and calculate the SCTP checksum.
-        * This is currently Adler32 but will change to CRC32x
-        * soon. Also has a side bonus calculate the total length
+        * This is CRC32c.
+        * Also has a side bonus calculate the total length
         * of the mbuf chain.
         * Note: if offset is greater than the total mbuf length,
         * checksum=1, pktlen=0 is returned (ie. no real error code)
         */
        int32_t tlen=0;
-       struct mbuf *at;
-       uint32_t the_sum, retsum;
-
-       at = m;
-       while (at) {
-               tlen += at->m_len;
-               at = at->m_next;
-       }
-       the_sum = (uint32_t)(in_cksum_skip(m, tlen, offset));
-       if (pktlen != NULL)
-               *pktlen = (tlen-offset);
-       retsum = htons(the_sum);
-       return (the_sum);
-}
-
-#else
-
-uint32_t
-sctp_calculate_sum(struct mbuf *m, int32_t *pktlen, uint32_t offset)
-{
-       /*
-        * given a mbuf chain with a packetheader offset by 'offset'
-        * pointing at a sctphdr (with csum set to 0) go through
-        * the chain of m_next's and calculate the SCTP checksum.
-        * This is currently Adler32 but will change to CRC32x
-        * soon. Also has a side bonus calculate the total length
-        * of the mbuf chain.
-        * Note: if offset is greater than the total mbuf length,
-        * checksum=1, pktlen=0 is returned (ie. no real error code)
-        */
-       int32_t tlen=0;
-#ifdef SCTP_USE_ADLER32
-       uint32_t base = 1L;
-#else
        uint32_t base = 0xffffffff;
-#endif /* SCTP_USE_ADLER32 */
        struct mbuf *at;
        at = m;
        /* find the correct mbuf and offset into mbuf */
@@ -1710,13 +1609,8 @@
        }
 
        while (at != NULL) {
-#ifdef SCTP_USE_ADLER32
-               base = update_adler32(base, at->m_data + offset,
-                   at->m_len - offset);
-#else
                base = update_crc32(base, at->m_data + offset,
                    at->m_len - offset);
-#endif /* SCTP_USE_ADLER32 */
                tlen += at->m_len - offset;
                /* we only offset once into the first mbuf */
                if (offset) {
@@ -1727,19 +1621,11 @@
        if (pktlen != NULL) {
                *pktlen = tlen;
        }
-#ifdef SCTP_USE_ADLER32
-       /* Adler32 */
-       base = htonl(base);
-#else
        /* CRC-32c */
        base = sctp_csum_finalize(base);
-#endif
        return (base);
 }
 
-
-#endif
-
 void
 sctp_mtu_size_reset(struct sctp_inpcb *inp,
                    struct sctp_association *asoc, u_long mtu)



Home | Main Index | Thread Index | Old Index