public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
From: Stefano Brivio <sbrivio@redhat.com>
To: passt-dev@passt.top
Subject: [PATCH v2] conf: Don't fail if the template interface doesn't have a MAC address
Date: Fri, 12 Apr 2024 00:24:41 +0200	[thread overview]
Message-ID: <20240411222441.551092-1-sbrivio@redhat.com> (raw)

...simply resort to using locally-administered address (LAA) as
host-side source, instead.

Pick 02:00:00:00:00:00, to make it clear that we don't actually care
about that address, and also to matchthe 00 (Administratively Assigned
Identifier) quadrant of SLAP (RFC 8948).

Otherwise, pasta refuses to start if the template is a tun or
Wireguard interface.

Link: https://bugs.passt.top/show_bug.cgi?id=49
Link: https://github.com/containers/podman/issues/22320
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
---
v2: Include change in util.h

 conf.c | 12 ++++++++----
 util.h |  1 +
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/conf.c b/conf.c
index 90d3436..3f30725 100644
--- a/conf.c
+++ b/conf.c
@@ -629,10 +629,12 @@ static unsigned int conf_ip4(unsigned int ifi,
 			    if_indextoname(ifi, ifname), strerror(-rc));
 			return 0;
 		}
+
+		if (MAC_IS_ZERO(mac))
+			memcpy(mac, MAC_LAA, ETH_ALEN);
 	}
 
-	if (IN4_IS_ADDR_UNSPECIFIED(&ip4->addr) ||
-	    MAC_IS_ZERO(mac))
+	if (IN4_IS_ADDR_UNSPECIFIED(&ip4->addr))
 		return 0;
 
 	return ifi;
@@ -688,11 +690,13 @@ static unsigned int conf_ip6(unsigned int ifi,
 			    if_indextoname(ifi, ifname), strerror(-rc));
 			return 0;
 		}
+
+		if (MAC_IS_ZERO(mac))
+			memcpy(mac, MAC_LAA, ETH_ALEN);
 	}
 
 	if (IN6_IS_ADDR_UNSPECIFIED(&ip6->addr) ||
-	    IN6_IS_ADDR_UNSPECIFIED(&ip6->addr_ll) ||
-	    MAC_IS_ZERO(mac))
+	    IN6_IS_ADDR_UNSPECIFIED(&ip6->addr_ll))
 		return 0;
 
 	return ifi;
diff --git a/util.h b/util.h
index 8c37729..ef01001 100644
--- a/util.h
+++ b/util.h
@@ -91,6 +91,7 @@
 #define PORT_IS_EPHEMERAL(port) ((port) >= PORT_EPHEMERAL_MIN)
 
 #define MAC_ZERO		((uint8_t [ETH_ALEN]){ 0 })
+#define MAC_LAA			((uint8_t [ETH_ALEN]){ BIT(1), 0, 0, 0, 0, 0 })
 #define MAC_IS_ZERO(addr)	(!memcmp((addr), MAC_ZERO, ETH_ALEN))
 
 #ifndef __bswap_constant_16
-- 
@@ -91,6 +91,7 @@
 #define PORT_IS_EPHEMERAL(port) ((port) >= PORT_EPHEMERAL_MIN)
 
 #define MAC_ZERO		((uint8_t [ETH_ALEN]){ 0 })
+#define MAC_LAA			((uint8_t [ETH_ALEN]){ BIT(1), 0, 0, 0, 0, 0 })
 #define MAC_IS_ZERO(addr)	(!memcmp((addr), MAC_ZERO, ETH_ALEN))
 
 #ifndef __bswap_constant_16
-- 
2.43.0


                 reply	other threads:[~2024-04-11 22:24 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240411222441.551092-1-sbrivio@redhat.com \
    --to=sbrivio@redhat.com \
    --cc=passt-dev@passt.top \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).