Module Name: src Committed By: rjs Date: Tue Aug 13 19:55:40 UTC 2019
Modified Files: src/sys/netinet: sctp_crc32.c sctp_crc32.h sctputil.c Log Message: Remove unused checksum code. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/netinet/sctp_crc32.c cvs rdiff -u -r1.1 -r1.2 src/sys/netinet/sctp_crc32.h cvs rdiff -u -r1.14 -r1.15 src/sys/netinet/sctputil.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/netinet/sctp_crc32.c diff -u src/sys/netinet/sctp_crc32.c:1.2 src/sys/netinet/sctp_crc32.c:1.3 --- src/sys/netinet/sctp_crc32.c:1.2 Fri Aug 12 19:08:54 2016 +++ src/sys/netinet/sctp_crc32.c Tue Aug 13 19:55:40 2019 @@ -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 @@ __KERNEL_RCSID(0, "$NetBSD: sctp_crc32.c #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 @@ sctp_csum_finalize(u_int32_t crc32c) return (crc32c); } -#endif Index: src/sys/netinet/sctp_crc32.h diff -u src/sys/netinet/sctp_crc32.h:1.1 src/sys/netinet/sctp_crc32.h:1.2 --- src/sys/netinet/sctp_crc32.h:1.1 Tue Oct 13 21:28:35 2015 +++ src/sys/netinet/sctp_crc32.h Tue Aug 13 19:55:40 2019 @@ -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__ */ Index: src/sys/netinet/sctputil.c diff -u src/sys/netinet/sctputil.c:1.14 src/sys/netinet/sctputil.c:1.15 --- src/sys/netinet/sctputil.c:1.14 Thu Nov 8 06:34:40 2018 +++ src/sys/netinet/sctputil.c Tue Aug 13 19:55:40 2019 @@ -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 @@ sctp_timer_stop(int t_type, struct sctp_ 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 @@ sctp_calculate_len(struct mbuf *m) 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 @@ sctp_calculate_sum(struct mbuf *m, int32 * 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 @@ sctp_calculate_sum(struct mbuf *m, int32 } 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 @@ sctp_calculate_sum(struct mbuf *m, int32 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)