aboutgitcodebugslistschat
path: root/tap.c
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2023-08-22 15:29:57 +1000
committerStefano Brivio <sbrivio@redhat.com>2023-08-22 12:15:33 +0200
commit955dd3251c9e9b0a1469015748e4600f68e8de0a (patch)
treecf8a69238316c2e8a526f77b8faad6873c7c7cfe /tap.c
parent5bf200ae8a1ab298cb393bf1956599d1178567cb (diff)
downloadpasst-955dd3251c9e9b0a1469015748e4600f68e8de0a.tar
passt-955dd3251c9e9b0a1469015748e4600f68e8de0a.tar.gz
passt-955dd3251c9e9b0a1469015748e4600f68e8de0a.tar.bz2
passt-955dd3251c9e9b0a1469015748e4600f68e8de0a.tar.lz
passt-955dd3251c9e9b0a1469015748e4600f68e8de0a.tar.xz
passt-955dd3251c9e9b0a1469015748e4600f68e8de0a.tar.zst
passt-955dd3251c9e9b0a1469015748e4600f68e8de0a.zip
tcp, udp: Don't pre-fill IPv4 destination address in headers
Because packets sent on the tap interface will always be going to the guest/namespace, we more-or-less know what address they'll be going to. So we pre-fill this destination address in our header buffers for IPv4. We can't do the same for IPv6 because we could need either the global or link-local address for the guest. In future we're going to want more flexibility for the destination address, so this pre-filling will get in the way. Change the flow so we always fill in the IPv4 destination address for each packet, rather than prefilling it from proto_update_l2_buf(). In fact for TCP we already redundantly filled the destination for each packet anyway. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'tap.c')
-rw-r--r--tap.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/tap.c b/tap.c
index 4ed63f1..ee79be0 100644
--- a/tap.c
+++ b/tap.c
@@ -625,10 +625,8 @@ resume:
l4_len = l3_len - hlen;
- if (iph->saddr && c->ip4.addr_seen.s_addr != iph->saddr) {
+ if (iph->saddr && c->ip4.addr_seen.s_addr != iph->saddr)
c->ip4.addr_seen.s_addr = iph->saddr;
- proto_update_l2_buf(NULL, NULL, &c->ip4.addr_seen);
- }
l4h = packet_get(in, i, sizeof(*eh) + hlen, l4_len, NULL);
if (!l4h)
@@ -969,7 +967,7 @@ redo:
if (memcmp(c->mac_guest, eh->h_source, ETH_ALEN)) {
memcpy(c->mac_guest, eh->h_source, ETH_ALEN);
- proto_update_l2_buf(c->mac_guest, NULL, NULL);
+ proto_update_l2_buf(c->mac_guest, NULL);
}
switch (ntohs(eh->h_proto)) {
@@ -1030,7 +1028,7 @@ restart:
if (memcmp(c->mac_guest, eh->h_source, ETH_ALEN)) {
memcpy(c->mac_guest, eh->h_source, ETH_ALEN);
- proto_update_l2_buf(c->mac_guest, NULL, NULL);
+ proto_update_l2_buf(c->mac_guest, NULL);
}
switch (ntohs(eh->h_proto)) {