aboutgitcodebugslistschat
diff options
context:
space:
mode:
authorStefano Brivio <sbrivio@redhat.com>2024-05-22 18:18:11 +0200
committerStefano Brivio <sbrivio@redhat.com>2024-05-23 16:42:06 +0200
commitd02bb6ca0550b7e878da02d7bac67f7f8106ee91 (patch)
tree6b24111666d1ababb0c768c84d1965b5038d2250
parent45b8632dcc0edcc60e17a2d068b433eaf82fdf82 (diff)
downloadpasst-d02bb6ca0550b7e878da02d7bac67f7f8106ee91.tar
passt-d02bb6ca0550b7e878da02d7bac67f7f8106ee91.tar.gz
passt-d02bb6ca0550b7e878da02d7bac67f7f8106ee91.tar.bz2
passt-d02bb6ca0550b7e878da02d7bac67f7f8106ee91.tar.lz
passt-d02bb6ca0550b7e878da02d7bac67f7f8106ee91.tar.xz
passt-d02bb6ca0550b7e878da02d7bac67f7f8106ee91.tar.zst
passt-d02bb6ca0550b7e878da02d7bac67f7f8106ee91.zip
tap: Move all-ones initialisation of mac_guest to tap_sock_init()
It has nothing to do with tap_sock_unix_init(). It used to be there as that function could be called multiple times per passt instance, but it's not the case anymore. This also takes care of the fact that, with --fd, we wouldn't set the initial MAC address, so we would need to wait for the guest to send us an ARP packet before we could exchange data. Fixes: 6b4e68383c66 ("passt, tap: Add --fd option") Signed-off-by: Stefano Brivio <sbrivio@redhat.com> Reviewed-by: David Gibson <david@gibson.dropbear.id.au> Acked-by: Richard W.M. Jones <rjones@redhat.com>
-rw-r--r--tap.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/tap.c b/tap.c
index 91fd2e2..177fe26 100644
--- a/tap.c
+++ b/tap.c
@@ -1111,12 +1111,6 @@ static void tap_sock_unix_init(struct ctx *c)
if (fd < 0)
die("UNIX socket: %s", strerror(errno));
- /* In passt mode, we don't know the guest's MAC until it sends
- * us packets. Use the broadcast address so our first packets
- * will reach it.
- */
- memset(&c->mac_guest, 0xff, sizeof(c->mac_guest));
-
for (i = 1; i < UNIX_SOCK_MAX; i++) {
char *path = addr.sun_path;
int ex, ret;
@@ -1312,6 +1306,12 @@ void tap_sock_init(struct ctx *c)
if (c->mode == MODE_PASST) {
if (c->fd_tap_listen == -1)
tap_sock_unix_init(c);
+
+ /* In passt mode, we don't know the guest's MAC address until it
+ * sends us packets. Use the broadcast address so that our
+ * first packets will reach it.
+ */
+ memset(&c->mac_guest, 0xff, sizeof(c->mac_guest));
} else {
tap_sock_tun_init(c);
}