Enable UDP checksum offload.
authorAndrew Gallatin <gallatin@google.com>
Fri, 6 Jun 2014 18:37:07 +0000 (11:37 -0700)
committerAndrew Gallatin <gallatin@google.com>
Mon, 9 Jun 2014 14:37:11 +0000 (07:37 -0700)
Enable UDP csum offload for IPv4.  This is good for a few
hundred Mb/s performance improvement for netperf -tUDP_STREAM
tests using a 10GbE NIC.

Signed-off-by: Andrew Gallatin <gallatin@google.com>
kern/src/net/udp.c

index 787868f..dead80a 100644 (file)
@@ -384,14 +384,15 @@ void udpiput(struct Proto *udp, struct Ipifc *ifc, struct block *bp)
                        lport = nhgets(uh4->udpdport);
                        rport = nhgets(uh4->udpsport);
 
-                       if (nhgets(uh4->udpcksum)) {
-                               if (ptclcsum(bp, UDP4_PHDR_OFF, len + UDP4_PHDR_SZ)) {
-                                       upriv->ustats.udpInErrors++;
-                                       netlog(f, Logudp, "udp: checksum error %I\n", raddr);
-                                       printd("udp: checksum error %I\n", raddr);
-                                       freeblist(bp);
-                                       return;
-                               }
+                       if (!(bp->flag & Budpck) &&
+                           (uh4->udpcksum[0] || uh4->udpcksum[1]) &&
+                           ptclcsum(bp, UDP4_PHDR_OFF, len + UDP4_PHDR_SZ)) {
+                               upriv->ustats.udpInErrors++;
+                               netlog(f, Logudp, "udp: checksum error %I\n",
+                                      raddr);
+                               printd("udp: checksum error %I\n", raddr);
+                               freeblist(bp);
+                               return;
                        }
                        uh4->Unused = ottl;
                        hnputs(uh4->udpplen, olen);