From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from imap.gmail.com [173.194.76.109] by localhost with POP3 (fetchmail-6.3.26) for (single-drop); Thu, 23 May 2024 11:59:52 +0200 (CEST) Received: by 2002:a05:6a11:2489:b0:55f:c3c0:ed08 with SMTP id sg9csp1199022pxb; Thu, 23 May 2024 02:59:36 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX0EZQMORB267HJrdyJyI+83fNLSobyQoRMeeAyMjkRxNYW4qODaUcz0AMGz9lYnkZNC24/z1tgy+SYWnuBYTMljCCpZyGK/Mg= X-Google-Smtp-Source: AGHT+IEh0+MlxuiOt2s56B6Wrzyqrk1M0CVEIcQ91Es3pGvD0drPVgTsE3XSmzgiFUG6G1FsS4yF X-Received: by 2002:a05:620a:28d0:b0:792:f046:b51d with SMTP id af79cd13be357-794994561c9mr515499385a.46.1716458376298; Thu, 23 May 2024 02:59:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1716458376; cv=none; d=google.com; s=arc-20160816; b=Y6NNrON1eOEalPmlzy5vXeBgSe60a2P1rQikldc6pTFdf5TzkEtCu0eFZ2Kzg/1c00 ITXJYiXRfOtsMcDIR4LNUfkyN00MiMeg4GxHhudZxH0vAI6yc+NEobloFsInsqG1JgsK P1YbfO4fiZkIuG00oQw+STas6Em234d4wv4EAwaJCboefFQ2bR9FuxQI4wdwr8F0S3Ld md1w5zgg2EfeuRlZSI0DE73NIRSIVZzCOup2DuIvDd5SURGOfZe0bygRi6UYOeJ5PAci lTzPblTTwDDFp+innviKbhNUBhbi0BOa/ndA7+zkZ2uRK8qUyLNSE+AWZnblnc+aTguN LDcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-disposition:user-agent:in-reply-to:mime-version:references :message-id:subject:cc:to:from:date:delivered-to; bh=ZxsCogmT+aPsLpmp61G68OI6QvgoInngcTzLv7i57zg=; fh=sa22/YzBg7gBlP1vWMAMO0ID50cEEzmrnuJNDeV9zT4=; b=KxVI/k5OWQjeN6yH+eZT+R3KqL8nF6IB6D1lk3pVe9GXhgTmtSASMlElfarbsFGwOK gV1IhkBQ0useQtyUtFmKbMUecDvUQAJunZdvXcWXlayV8dvGQxOPqPLavb/Ad91jB4id DpymqrJdKehhAcCTggmFxs7uTE97nam3rhYvpR279i/O92jjYBL+I+bdtXaFEqq7jX76 tUtG+KvCO9Uyn2rN9v3jMFNLoDxsDwssSUHExxLKJA8UmiOghhuVxSXV9eu3bGyH3sHt 6drDZgKGfXjBYQ4/Gh5gdUusbfBngRG6xJCw93GzYyFP8HOGMrlTa8sMksfkJ74io2SC 33LA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; gateway.spf=pass (google.com: domain gapps.redhat.com configured 205.139.110.120 as internal address) smtp.mailfrom=rjones@redhat.com smtp.remote-ip=205.139.110.120 policy.d=gapps.redhat.com Return-Path: Received: from us-smtp-inbound-delivery-1.mimecast.com (us-smtp-delivery-1.mimecast.com. [205.139.110.120]) by mx.google.com with ESMTPS id af79cd13be357-792bf361e68si3145650785a.610.2024.05.23.02.59.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 May 2024 02:59:36 -0700 (PDT) Received-SPF: pass (google.com: domain gapps.redhat.com configured 205.139.110.120 as internal address) Authentication-Results: mx.google.com; gateway.spf=pass (google.com: domain gapps.redhat.com configured 205.139.110.120 as internal address) smtp.mailfrom=rjones@redhat.com smtp.remote-ip=205.139.110.120 policy.d=gapps.redhat.com Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-648-BaiWZizeNxumZfv7ojwUhQ-1; Thu, 23 May 2024 05:59:34 -0400 X-MC-Unique: BaiWZizeNxumZfv7ojwUhQ-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2D633101A52C for ; Thu, 23 May 2024 09:59:34 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 2A55A400057; Thu, 23 May 2024 09:59:34 +0000 (UTC) Received: from localhost (unknown [10.42.28.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5F0BD492BC6; Thu, 23 May 2024 09:59:33 +0000 (UTC) Date: Thu, 23 May 2024 10:59:32 +0100 From: "Richard W.M. Jones" To: Stefano Brivio Cc: passt-dev@passt.top, David Gibson , Minxi Hou Subject: Re: [PATCH 2/8] tap: Move all-ones initialisation of mac_guest to tap_sock_init() Message-ID: <20240523095932.GS4345@redhat.com> References: <20240522205911.261325-1-sbrivio@redhat.com> <20240522205911.261325-3-sbrivio@redhat.com> MIME-Version: 1.0 In-Reply-To: <20240522205911.261325-3-sbrivio@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline List-Id: On Wed, May 22, 2024 at 10:59:05PM +0200, Stefano Brivio wrote: > 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 > --- > tap.c | 12 ++++++------ > 1 file 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); > } Reading tap.c, the effect of this is that memset will also be called when c->fd_tap_listen is set (the --fd option). As c cannot be NULL and c->mac_guest exists, this seems safe. Acked-by: Richard W.M. Jones Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com libguestfs lets you edit virtual machines. Supports shell scripting, bindings from many languages. http://libguestfs.org