On DragonFlyBSD, the UDP packet sent from sendto has no flowlabel (0x00000) even if net.inet6.ip6.auto_flowlabel
is left set (the default).
On DragonFlyBSD, tcpdump shows the empty flowlabel (the 3 octets following the first 0x60)
08:58:15.240037 IP6 (hlim 64, next-header UDP (17) payload length: 16) ::1.2082 > ::1.3456: [udp sum ok] udp/vt 8 69 / 21 [|vat]
0x0000: 6000 0000 0010 1140 0000 0000 0000 0000 `......@........
0x0010: 0000 0000 0000 0001 0000 0000 0000 0000 ................
0x0020: 0000 0000 0000 0001 0822 0d80 0010 c00c ........."......
0x0030: 5445 5354 4041 4243 TEST@ABC
while on another system (namely, WSL)
23:51:23.201149 IP6 (flowlabel 0x33ba2, hlim 64, next-header UDP (17) payload length: 16) ::1.40700 > ::1.3456: [bad udp cksum 0x0023 -> 0x2932!] udp/vt 8 69 / 21 [|vat]
0x0000: 6003 3ba2 0010 1140 0000 0000 0000 0000 `.;....@........
0x0010: 0000 0000 0000 0001 0000 0000 0000 0000 ................
0x0020: 0000 0000 0000 0001 9efc 0d80 0010 0023 ...............#
0x0030: 5445 5354 4041 4243 TEST@ABC
sendto.c:
#include <sys/socket.h>
#include <sys/types.h>
#include <err.h>
#include <errno.h>
#include <netdb.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
int
main(int ac, char **av)
{
struct addrinfo hint, *ai = NULL;
int s = -1;
if (ac < 1 + 3)
errx(1, "usage: %s host port msg", av[0]);
const char *msg = av[3];
size_t msglen = strlen(msg);
memset(&hint, 0, sizeof hint);
hint.ai_family = AF_UNSPEC;
hint.ai_socktype = SOCK_DGRAM;
hint.ai_flags = AI_PASSIVE;
hint.ai_protocol = 0;
hint.ai_canonname = NULL;
hint.ai_addr = NULL;
hint.ai_next = NULL;
if (getaddrinfo(av[1], av[2], &hint, &ai) != 0)
err(errno, "getaddrinfo");
if ((s = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol)) == -1)
err(errno, "socket");
ssize_t sent = sendto(s, msg, msglen, 0, ai->ai_addr, ai->ai_addrlen);
if (sent == -1)
err(errno, "sendto");
close(s);
freeaddrinfo(ai);
return 0;
}
To build:
make sendto CFLAGS='-W -Wall' && ./sendto ::1 3456 TEST@ABC
To observe (on Linux system, change lo0 to lo):
sudo tcpdump -Xnvs 1500 -i lo0 udp 3456