Source-Changes-HG archive

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

[src/trunk]: src/sys/netinet Honour the M_CSUM_NO_PSEUDOHDR, if set on inboun...



details:   https://anonhg.NetBSD.org/src/rev/21c10d07c7db
branches:  trunk
changeset: 550781:21c10d07c7db
user:      jonathan <jonathan%NetBSD.org@localhost>
date:      Thu Aug 21 14:49:49 2003 +0000

description:
Honour the M_CSUM_NO_PSEUDOHDR, if set on inbound TCP and UDP packets.
Tested against  bcm5700 with patched if_bge.c.

diffstat:

 sys/netinet/tcp_input.c  |  16 ++++++++++++----
 sys/netinet/udp_usrreq.c |  13 +++++++++----
 2 files changed, 21 insertions(+), 8 deletions(-)

diffs (77 lines):

diff -r f13ac7508846 -r 21c10d07c7db sys/netinet/tcp_input.c
--- a/sys/netinet/tcp_input.c   Thu Aug 21 14:41:00 2003 +0000
+++ b/sys/netinet/tcp_input.c   Thu Aug 21 14:49:49 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tcp_input.c,v 1.175 2003/08/15 03:42:04 jonathan Exp $ */
+/*     $NetBSD: tcp_input.c,v 1.176 2003/08/21 14:49:49 jonathan Exp $ */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -148,7 +148,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tcp_input.c,v 1.175 2003/08/15 03:42:04 jonathan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tcp_input.c,v 1.176 2003/08/21 14:49:49 jonathan Exp $");
 
 #include "opt_inet.h"
 #include "opt_ipsec.h"
@@ -1100,11 +1100,19 @@
                        TCP_CSUM_COUNTER_INCR(&tcp_hwcsum_bad);
                        goto badcsum;
 
-               case M_CSUM_TCPv4|M_CSUM_DATA:
+               case M_CSUM_TCPv4|M_CSUM_DATA: {
+                       u_int32_t hw_csum = m->m_pkthdr.csum_data;
                        TCP_CSUM_COUNTER_INCR(&tcp_hwcsum_data);
-                       if ((m->m_pkthdr.csum_data ^ 0xffff) != 0)
+                       if (m->m_pkthdr.csum_flags & M_CSUM_NO_PSEUDOHDR) {
+                               hw_csum = in_cksum_phdr(ip->ip_src.s_addr,
+                                   ip->ip_dst.s_addr,
+                                   htonl(hw_csum + ntohs(ip->ip_len) +
+                                         IPPROTO_UDP));
+                       }
+                       if ((hw_csum ^ 0xffff) != 0)
                                goto badcsum;
                        break;
+               }
 
                case M_CSUM_TCPv4:
                        /* Checksum was okay. */
diff -r f13ac7508846 -r 21c10d07c7db sys/netinet/udp_usrreq.c
--- a/sys/netinet/udp_usrreq.c  Thu Aug 21 14:41:00 2003 +0000
+++ b/sys/netinet/udp_usrreq.c  Thu Aug 21 14:49:49 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: udp_usrreq.c,v 1.105 2003/08/15 03:42:05 jonathan Exp $        */
+/*     $NetBSD: udp_usrreq.c,v 1.106 2003/08/21 14:49:50 jonathan Exp $        */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -61,7 +61,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: udp_usrreq.c,v 1.105 2003/08/15 03:42:05 jonathan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: udp_usrreq.c,v 1.106 2003/08/21 14:49:50 jonathan Exp $");
 
 #include "opt_inet.h"
 #include "opt_ipsec.h"
@@ -278,11 +278,16 @@
                        UDP_CSUM_COUNTER_INCR(&udp_hwcsum_bad);
                        goto badcsum;
 
-               case M_CSUM_UDPv4|M_CSUM_DATA:
+               case M_CSUM_UDPv4|M_CSUM_DATA: {
+                       u_int32_t hw_csum = m->m_pkthdr.csum_data;
                        UDP_CSUM_COUNTER_INCR(&udp_hwcsum_data);
-                       if ((m->m_pkthdr.csum_data ^ 0xffff) != 0)
+                       if (m->m_pkthdr.csum_flags & M_CSUM_NO_PSEUDOHDR)
+                         hw_csum = in_cksum_phdr(ip->ip_src.s_addr, ip->ip_dst.s_addr,
+                               htonl(hw_csum + ntohs(ip->ip_len) + IPPROTO_UDP));
+                       if ((hw_csum ^ 0xffff) != 0)
                                goto badcsum;
                        break;
+               }
 
                case M_CSUM_UDPv4:
                        /* Checksum was okay. */



Home | Main Index | Thread Index | Old Index