From owner-freebsd-net@FreeBSD.ORG Fri Feb 28 21:15:00 2014 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 54E69B1B for ; Fri, 28 Feb 2014 21:15:00 +0000 (UTC) Received: from mail-vc0-x230.google.com (mail-vc0-x230.google.com [IPv6:2607:f8b0:400c:c03::230]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 0F6CA18D9 for ; Fri, 28 Feb 2014 21:14:59 +0000 (UTC) Received: by mail-vc0-f176.google.com with SMTP id la4so1289983vcb.7 for ; Fri, 28 Feb 2014 13:14:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:from:date:message-id:subject:to:content-type; bh=ldKBtS7aaWQCRQ+W2ncHdPFg1acaiXri6KigIuC99mU=; b=d6iMDcGFqVtYSMEUHaLRJ4UkGsA/2HMWwiq5ynQRpFe7XlMEZCALZWheZbT+xIOcWa BKcyXTyuvH1PSKGzks9KDs9WZ0j7+N8OqB7JPervqnZnmUU42XGACg2iNUMyseYl8913 6a8l2uOzOVf1VqaFKJYnM2FBHmTjqAlhP4pnW7INsJPCMBo9uc1uwU4rrr/5YinrH4p6 lij8A8kve0OwBS79MJy/s5jPRu4WkV+ouKYMiJHwNYRFEAI4S1rwDfwXS8dt0jfWjblP /qezhQPVCPPx4A2L0hxcFFZM+wI2maWyVPs9IqH/fCDzBa32rWwbYkCCW+8tVu5Sfe85 BkBQ== X-Received: by 10.52.75.101 with SMTP id b5mr6716425vdw.40.1393622099101; Fri, 28 Feb 2014 13:14:59 -0800 (PST) MIME-Version: 1.0 Sender: cochard@gmail.com Received: by 10.58.188.35 with HTTP; Fri, 28 Feb 2014 13:14:39 -0800 (PST) From: =?ISO-8859-1?Q?Olivier_Cochard=2DLabb=E9?= Date: Fri, 28 Feb 2014 22:14:39 +0100 X-Google-Sender-Auth: GrbG1oJX7lr_XpUdXnEcQ62rkAo Message-ID: Subject: netmap's pkt-gen patch for IP and UDP checksum To: "freebsd-net@freebsd.org" , Luigi Rizzo Content-Type: text/plain; charset=ISO-8859-1 X-Content-Filtered-By: Mailman/MimeDel 2.1.17 X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 Feb 2014 21:15:00 -0000 I've found the problem with netmap's pkt-gen when using IP srt/dst or UDP port range: The function update_addresses() update the IP src/dst and/or the UDP port but forgot to update the IP and UDP checksum after these changes: Then only packets that correspond to the first value of the range are correct, all other have bad checksum. Some code is missing after the last comment "// update checksum" at the end of this function. I've did a dirty copy/past code from the initialize_packet() function for fixing this behavior and the problem is gone. Here is an example with this command-line: pkt-gen -f tx -l 60 -d 2.1.3.1-2.1.3.10 -s 1.1.3.1-1.1.3.10 Before the patch, on the receiving host, we see lot's of packet with bad checksum: 19:31:28.029702 IP (tos 0x10, ttl 64, id 0, offset 0, flags [DF], proto UDP (17), length 46, bad cksum 31ac (->31a1)!) 1.1.3.9.0 > 2.1.3.4.0: [bad udp cksum 0x2a23 -> 0x2a18!] UDP, length 18 19:31:28.029704 IP (tos 0x10, ttl 64, id 0, offset 0, flags [DF], proto UDP (17), length 46, bad cksum 31ac (->31a3)!) 1.1.3.10.0 > 2.1.3.1.0: [bad udp cksum 0x2a23 -> 0x2a1a!] UDP, length 18 19:31:28.029705 IP (tos 0x10, ttl 64, id 0, offset 0, flags [DF], proto UDP (17), length 46, bad cksum 31ac (->31a6)!) 1.1.3.4.0 > 2.1.3.4.0: [bad udp cksum 0x2a23 -> 0x2a1d!] UDP, length 18 19:31:28.029706 IP (tos 0x10, ttl 64, id 0, offset 0, flags [DF], proto UDP (17), length 46, bad cksum 31ac (->31a4)!) 1.1.3.7.0 > 2.1.3.3.0: [bad udp cksum 0x2a23 -> 0x2a1b!] UDP, length 18 19:31:28.029706 IP (tos 0x10, ttl 64, id 0, offset 0, flags [DF], proto UDP (17), length 46, bad cksum 31ac (->31a1)!) 1.1.3.6.0 > 2.1.3.7.0: [bad udp cksum 0x2a23 -> 0x2a18!] UDP, length 18 19:31:28.029707 IP (tos 0x10, ttl 64, id 0, offset 0, flags [DF], proto UDP (17), length 46, bad cksum 31ac (->319f)!) 1.1.3.5.0 > 2.1.3.10.0: [bad udp cksum 0x2a23 -> 0x2a16!] UDP, length 18 After the patch on the receiving host, no more bad checksum: 19:33:43.824502 IP (tos 0x10, ttl 64, id 0, offset 0, flags [DF], proto UDP (17), length 46) 1.1.3.9.0 > 2.1.3.2.0: [udp sum ok] UDP, length 18 19:33:43.824502 IP (tos 0x10, ttl 64, id 0, offset 0, flags [DF], proto UDP (17), length 46) 1.1.3.9.0 > 2.1.3.1.0: [udp sum ok] UDP, length 18 19:33:43.824505 IP (tos 0x10, ttl 64, id 0, offset 0, flags [DF], proto UDP (17), length 46) 1.1.3.4.0 > 2.1.3.5.0: [udp sum ok] UDP, length 18 19:33:43.824506 IP (tos 0x10, ttl 64, id 0, offset 0, flags [DF], proto UDP (17), length 46) 1.1.3.6.0 > 2.1.3.3.0: [udp sum ok] UDP, length 18 19:33:43.824507 IP (tos 0x10, ttl 64, id 0, offset 0, flags [DF], proto UDP (17), length 46) 1.1.3.4.0 > 2.1.3.7.0: [udp sum ok] UDP, length 18 19:33:43.824508 IP (tos 0x10, ttl 64, id 0, offset 0, flags [DF], proto UDP (17), length 46) 1.1.3.5.0 > 2.1.3.2.0: [udp sum ok] UDP, length 18 19:33:43.824510 IP (tos 0x10, ttl 64, id 0, offset 0, flags [DF], proto UDP (17), length 46) 1.1.3.4.0 > 2.1.3.8.0: [udp sum ok] UDP, length 18 19:33:43.824511 IP (tos 0x10, ttl 64, id 0, offset 0, flags [DF], proto UDP (17), length 46) 1.1.3.10.0 > 2.1.3.3.0: [udp sum ok] UDP, length 18 19:33:43.824512 IP (tos 0x10, ttl 64, id 0, offset 0, flags [DF], proto UDP (17), length 46) 1.1.3.6.0 > 2.1.3.4.0: [udp sum ok] UDP, length 18 19:33:43.824512 IP (tos 0x10, ttl 64, id 0, offset 0, flags [DF], proto UDP (17), length 46) 1.1.3.9.0 > 2.1.3.4.0: [udp sum ok] UDP, length 18 The patch is here: http://www.freebsd.org/cgi/query-pr.cgi?pr=187149 Regards, Olivier