From e790ea0ec68d7a62fce04731f2b8fe3773582420 Mon Sep 17 00:00:00 2001 From: bluhm Date: Tue, 4 Jul 2023 10:48:19 +0000 Subject: [PATCH] Remove redundant code when calculating checksum. OK jmatthew@ --- sys/netinet/ip_output.c | 4 ++-- sys/netinet/tcp_output.c | 5 +---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/sys/netinet/ip_output.c b/sys/netinet/ip_output.c index 86288bc8892..0e56ffb3f11 100644 --- a/sys/netinet/ip_output.c +++ b/sys/netinet/ip_output.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_output.c,v 1.388 2023/05/22 16:08:34 bluhm Exp $ */ +/* $OpenBSD: ip_output.c,v 1.389 2023/07/04 10:48:19 bluhm Exp $ */ /* $NetBSD: ip_output.c,v 1.28 1996/02/13 23:43:07 christos Exp $ */ /* @@ -1801,7 +1801,7 @@ in_hdr_cksum_out(struct mbuf *m, struct ifnet *ifp) struct ip *ip = mtod(m, struct ip *); ip->ip_sum = 0; - if (ifp && in_ifcap_cksum(m, ifp, IFCAP_CSUM_IPv4)) { + if (in_ifcap_cksum(m, ifp, IFCAP_CSUM_IPv4)) { SET(m->m_pkthdr.csum_flags, M_IPV4_CSUM_OUT); } else { ipstat_inc(ips_outswcsum); diff --git a/sys/netinet/tcp_output.c b/sys/netinet/tcp_output.c index c7111b143ec..fabd9d332ae 100644 --- a/sys/netinet/tcp_output.c +++ b/sys/netinet/tcp_output.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tcp_output.c,v 1.138 2023/05/15 16:34:56 bluhm Exp $ */ +/* $OpenBSD: tcp_output.c,v 1.139 2023/07/04 10:48:19 bluhm Exp $ */ /* $NetBSD: tcp_output.c,v 1.16 1997/06/03 16:17:09 kml Exp $ */ /* @@ -1295,7 +1295,6 @@ tcp_chopper(struct mbuf *m0, struct mbuf_list *ml, struct ifnet *ifp, /* copy and adjust IP header, calculate checksum */ SET(m->m_pkthdr.csum_flags, M_TCP_CSUM_OUT); - mhth->th_sum = 0; if (ip) { struct ip *mhip; @@ -1328,10 +1327,8 @@ tcp_chopper(struct mbuf *m0, struct mbuf_list *ml, struct ifnet *ifp, } /* adjust IP header, calculate checksum */ SET(m0->m_pkthdr.csum_flags, M_TCP_CSUM_OUT); - th->th_sum = 0; if (ip) { ip->ip_len = htons(m0->m_pkthdr.len); - ip->ip_sum = 0; in_hdr_cksum_out(m0, ifp); in_proto_cksum_out(m0, ifp); } -- 2.20.1