netmap's pkt-gen patch for IP and UDP checksum

Olivier Cochard-Labbé olivier at cochard.me
Fri Feb 28 21:15:00 UTC 2014


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


More information about the freebsd-net mailing list