kern/180430: [ofed] [patch] Bad UDP checksum calc for fragmented packets

John Baldwin jhb at freebsd.org
Thu Jul 11 17:41:33 UTC 2013


On Wednesday, July 10, 2013 6:59:42 am linimon at freebsd.org wrote:
> Old Synopsis: Bad UDP checksum calc for fragmented packets
> New Synopsis: [ofed] [patch] Bad UDP checksum calc for fragmented packets
> 
> Responsible-Changed-From-To: freebsd-bugs->freebsd-net
> Responsible-Changed-By: linimon
> Responsible-Changed-When: Wed Jul 10 10:59:03 UTC 2013
> Responsible-Changed-Why: 
> Over to maintainer(s).
> 
> http://www.freebsd.org/cgi/query-pr.cgi?pr=180430

Is the problem that the hardware checksum overwrites arbitrary data in the 
packet (at the location where the UDP header would be)?

Also, I've looked at other drivers, and they all look at the CSUM_*
flags to determine the right settings.  IP fragments will not have
CSUM_UDP or CSUM_TCP set, so I think the more correct fix is this:

Index: en_tx.c
===================================================================
--- en_tx.c	(revision 253202)
+++ en_tx.c	(working copy)
@@ -780,8 +780,12 @@ retry:
 	tx_desc->ctrl.srcrb_flags = cpu_to_be32(MLX4_WQE_CTRL_CQ_UPDATE |
 						MLX4_WQE_CTRL_SOLICITED);
 	if (mb->m_pkthdr.csum_flags & (CSUM_IP|CSUM_TCP|CSUM_UDP)) {
-		tx_desc->ctrl.srcrb_flags |= cpu_to_be32(MLX4_WQE_CTRL_IP_CSUM |
-							 MLX4_WQE_CTRL_TCP_UDP_CSUM);
+		if (mb->m_pkthdr.csum_flags & CSUM_IP)
+			tx_desc->ctrl.srcrb_flags |=
+			    cpu_to_be32(MLX4_WQE_CTRL_IP_CSUM);
+		if (mb->m_pkthdr.csum_flags & (CSUM_TCP|CSUM_UDP)) {
+			tx_desc->ctrl.srcrb_flags |=
+			    cpu_to_be32(MLX4_WQE_CTRL_TCP_UDP_CSUM);
 		priv->port_stats.tx_chksum_offload++;
 	}
 

-- 
John Baldwin


More information about the freebsd-net mailing list