From 5020dd8837f56b45edd717dde5f5ff870fc14dcf Mon Sep 17 00:00:00 2001 From: Henning Brauer Date: Sat, 19 Oct 2013 10:38:56 +0000 Subject: make in_proto_cksum_out not rely on the pseudo header checksum to be already there, just compute it - it's dirt cheap. since that happens very late in ip_output, the rest of the stack doesn't have to care about checksums at all any more, if something needs to be checksummed, just set the flag on the pkthdr mbuf to indicate so. stop pre-computing the pseudo header checksum and incrementally updating it in the tcp and udp stacks. ok lteo florian --- sys/netinet/udp_usrreq.c | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) (limited to 'sys/netinet/udp_usrreq.c') diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c index e2e3e9f61f3..0604b9f0c8a 100644 --- a/sys/netinet/udp_usrreq.c +++ b/sys/netinet/udp_usrreq.c @@ -1,4 +1,4 @@ -/* $OpenBSD: udp_usrreq.c,v 1.168 2013/10/17 16:27:44 bluhm Exp $ */ +/* $OpenBSD: udp_usrreq.c,v 1.169 2013/10/19 10:38:55 henning Exp $ */ /* $NetBSD: udp_usrreq.c,v 1.28 1996/03/16 23:54:03 christos Exp $ */ /* @@ -1077,21 +1077,11 @@ udp_output(struct mbuf *m, ...) ui->ui_sport = inp->inp_lport; ui->ui_dport = inp->inp_fport; ui->ui_ulen = ui->ui_len; - - /* - * Compute the pseudo-header checksum; defer further checksumming - * until ip_output() or hardware (if it exists). - */ - if (udpcksum) { - m->m_pkthdr.csum_flags |= M_UDP_CSUM_OUT; - ui->ui_sum = in_cksum_phdr(ui->ui_src.s_addr, - ui->ui_dst.s_addr, htons((u_int16_t)len + - sizeof (struct udphdr) + IPPROTO_UDP)); - } else - ui->ui_sum = 0; ((struct ip *)ui)->ip_len = htons(sizeof (struct udpiphdr) + len); ((struct ip *)ui)->ip_ttl = inp->inp_ip.ip_ttl; ((struct ip *)ui)->ip_tos = inp->inp_ip.ip_tos; + if (udpcksum) + m->m_pkthdr.csum_flags |= M_UDP_CSUM_OUT; udpstat.udps_opackets++; -- cgit v1.2.3