public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
* [PATCH] conf: Fix initialisation of IPv6 unicast and link-local addresses
@ 2022-07-13  6:18 Stefano Brivio
  0 siblings, 0 replies; only message in thread
From: Stefano Brivio @ 2022-07-13  6:18 UTC (permalink / raw)
  To: passt-dev

[-- Attachment #1: Type: text/plain, Size: 1602 bytes --]

In commit 675174d4ba25 ("conf, tap: Split netlink and pasta
functions, allow interface configuration"), I broke the initial
setting of the observed IPv6 addresses in two ways:

- the size copied from the configured addresses corresponds to an
  IPv4 address, not to an IPv6 address

- the observed link-local address is initialised to the configured
  unicast address, not the link-local one

If we haven't seen the guest using some type of addresses yet, we
should default to the configured values, hence these initial
settings: fix both.

This resulted in UDP flows to the guest from a unique local address
on the network not working before the guest shows passt a valid
address itself, as reported by Alona.

Reported-by: Alona Paz <alkaplan(a)redhat.com>
Link: https://bugs.passt.top/show_bug.cgi?id=16
Fixes: 675174d4ba25 ("conf, tap: Split netlink and pasta functions, allow interface configuration")
Signed-off-by: Stefano Brivio <sbrivio(a)redhat.com>
---
 conf.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/conf.c b/conf.c
index 13cb5a1..cff71ff 100644
--- a/conf.c
+++ b/conf.c
@@ -589,8 +589,8 @@ static void conf_ip(struct ctx *c)
 			IN6_IS_ADDR_UNSPECIFIED(&c->addr6) ? &c->addr6 : NULL,
 			&prefix_len, &c->addr6_ll);
 
-		memcpy(&c->addr6_seen, &c->addr6, sizeof(c->addr4_seen));
-		memcpy(&c->addr6_ll_seen, &c->addr6, sizeof(c->addr4_seen));
+		memcpy(&c->addr6_seen, &c->addr6, sizeof(c->addr6));
+		memcpy(&c->addr6_ll_seen, &c->addr6_ll, sizeof(c->addr6_ll));
 	}
 
 	if (!c->gw4 || !c->addr4 ||
-- 
@@ -589,8 +589,8 @@ static void conf_ip(struct ctx *c)
 			IN6_IS_ADDR_UNSPECIFIED(&c->addr6) ? &c->addr6 : NULL,
 			&prefix_len, &c->addr6_ll);
 
-		memcpy(&c->addr6_seen, &c->addr6, sizeof(c->addr4_seen));
-		memcpy(&c->addr6_ll_seen, &c->addr6, sizeof(c->addr4_seen));
+		memcpy(&c->addr6_seen, &c->addr6, sizeof(c->addr6));
+		memcpy(&c->addr6_ll_seen, &c->addr6_ll, sizeof(c->addr6_ll));
 	}
 
 	if (!c->gw4 || !c->addr4 ||
-- 
2.35.1


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2022-07-13  6:18 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-13  6:18 [PATCH] conf: Fix initialisation of IPv6 unicast and link-local addresses Stefano Brivio

Code repositories for project(s) associated with this public inbox

	https://passt.top/passt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).