Source-Changes-HG archive

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

[src/trunk]: src/sys/netinet We do not do checksums on loopback interfaces, n...



details:   https://anonhg.NetBSD.org/src/rev/651ac862aab7
branches:  trunk
changeset: 763983:651ac862aab7
user:      martin <martin%NetBSD.org@localhost>
date:      Sat Apr 09 20:34:36 2011 +0000

description:
We do not do checksums on loopback interfaces, not even if fragmenting.
Fixes PR kern/43664.

diffstat:

 sys/netinet/ip_output.c |  23 ++++++++++++++---------
 1 files changed, 14 insertions(+), 9 deletions(-)

diffs (44 lines):

diff -r c3ec5f3f01a0 -r 651ac862aab7 sys/netinet/ip_output.c
--- a/sys/netinet/ip_output.c   Sat Apr 09 19:56:20 2011 +0000
+++ b/sys/netinet/ip_output.c   Sat Apr 09 20:34:36 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ip_output.c,v 1.205 2009/07/17 22:02:54 minskim Exp $  */
+/*     $NetBSD: ip_output.c,v 1.206 2011/04/09 20:34:36 martin Exp $   */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -91,7 +91,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ip_output.c,v 1.205 2009/07/17 22:02:54 minskim Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_output.c,v 1.206 2011/04/09 20:34:36 martin Exp $");
 
 #include "opt_pfil_hooks.h"
 #include "opt_inet.h"
@@ -1026,13 +1026,18 @@
        ip->ip_len = htons((u_int16_t)m->m_pkthdr.len);
        ip->ip_off |= htons(IP_MF);
        ip->ip_sum = 0;
-       if (sw_csum & M_CSUM_IPv4) {
-               ip->ip_sum = in_cksum(m, hlen);
-               m->m_pkthdr.csum_flags &= ~M_CSUM_IPv4;
-       } else {
-               KASSERT(m->m_pkthdr.csum_flags & M_CSUM_IPv4);
-               KASSERT(M_CSUM_DATA_IPv4_IPHL(m->m_pkthdr.csum_data) >=
-                       sizeof(struct ip));
+       /*
+        * We do not do checksums on loopback interfaces
+        */
+       if (__predict_true(ifp == NULL || !(ifp->if_flags & IFF_LOOPBACK)))  {
+               if (sw_csum & M_CSUM_IPv4) {
+                       ip->ip_sum = in_cksum(m, hlen);
+                       m->m_pkthdr.csum_flags &= ~M_CSUM_IPv4;
+               } else {
+                       KASSERT(m->m_pkthdr.csum_flags & M_CSUM_IPv4);
+                       KASSERT(M_CSUM_DATA_IPv4_IPHL(m->m_pkthdr.csum_data) >=
+                               sizeof(struct ip));
+               }
        }
 sendorfree:
        /*



Home | Main Index | Thread Index | Old Index