aboutgitcodebugslistschat
diff options
context:
space:
mode:
authorJon Maloy <jmaloy@redhat.com>2025-02-19 10:20:41 -0500
committerStefano Brivio <sbrivio@redhat.com>2025-02-20 12:43:00 +0100
commitea69ca6a20ac7408a913fd5de383a5383d679678 (patch)
tree3b5e58d10d156f9ac8c013ffa9c60f4eebfdda87
parent4dac2351fae5534c01e144273f849ce9ece0dca7 (diff)
downloadpasst-ea69ca6a20ac7408a913fd5de383a5383d679678.tar
passt-ea69ca6a20ac7408a913fd5de383a5383d679678.tar.gz
passt-ea69ca6a20ac7408a913fd5de383a5383d679678.tar.bz2
passt-ea69ca6a20ac7408a913fd5de383a5383d679678.tar.lz
passt-ea69ca6a20ac7408a913fd5de383a5383d679678.tar.xz
passt-ea69ca6a20ac7408a913fd5de383a5383d679678.tar.zst
passt-ea69ca6a20ac7408a913fd5de383a5383d679678.zip
tap: always set the no_frag flag in IPv4 headers
When studying the Linux source code and Wireshark dumps it seems like the no_frag flag in the IPv4 header is always set. Following discussions in the Internet on this subject indicates that modern routers never fragment packets, and that it isn't even supported in many cases. Adding to this that incoming messages forwarded on the tap interface never even pass through a router it seems safe to always set this flag. This makes the IPv4 headers of forwarded messages identical to those sent by the external sockets, something we must consider desirable. Signed-off-by: Jon Maloy <jmaloy@redhat.com> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
-rw-r--r--ip.h3
-rw-r--r--tap.c2
2 files changed, 3 insertions, 2 deletions
diff --git a/ip.h b/ip.h
index 1544dbf..858cc89 100644
--- a/ip.h
+++ b/ip.h
@@ -36,13 +36,14 @@
.tos = 0, \
.tot_len = 0, \
.id = 0, \
- .frag_off = 0, \
+ .frag_off = htons(IP_DF), \
.ttl = 0xff, \
.protocol = (proto), \
.saddr = 0, \
.daddr = 0, \
}
#define L2_BUF_IP4_PSUM(proto) ((uint32_t)htons_constant(0x4500) + \
+ (uint32_t)htons_constant(IP_DF) + \
(uint32_t)htons(0xff00 | (proto)))
diff --git a/tap.c b/tap.c
index d0673e5..44b0fc0 100644
--- a/tap.c
+++ b/tap.c
@@ -153,7 +153,7 @@ static void *tap_push_ip4h(struct iphdr *ip4h, struct in_addr src,
ip4h->tos = 0;
ip4h->tot_len = htons(l3len);
ip4h->id = 0;
- ip4h->frag_off = 0;
+ ip4h->frag_off = htons(IP_DF);
ip4h->ttl = 255;
ip4h->protocol = proto;
ip4h->saddr = src.s_addr;