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 12:03:37 +0200 (CEST) Received: by 2002:a05:6a11:2489:b0:55f:c3c0:ed08 with SMTP id sg9csp1201477pxb; Thu, 23 May 2024 03:03:19 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVsPolxe6yfZJq8/mIVa3KqkHD0HHD3OKtNWvN+FkRRV5+aX4jwzSU/U+ulnqbHsGJZW7r3tE+4OgiMGGRxIr9kfx08MINk3Qg= X-Google-Smtp-Source: AGHT+IFB6NR11xRvK+iviE2vOW87EDO6k9Yb9ZKaliDMOxZU+ZS5/cntbVqoCIMF/GQ7EdPpVUhd X-Received: by 2002:a05:6214:3118:b0:6a0:6167:9eab with SMTP id 6a1803df08f44-6ab7f3536a5mr58967306d6.16.1716458599667; Thu, 23 May 2024 03:03:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1716458599; cv=none; d=google.com; s=arc-20160816; b=CkPnXHEqi7Cn5RGQbKuikmBs3uPZac2m/SbDTMid1On7UrA4LN2qZPXDKi6gDTMUK7 Ihh5JAp9AbuxE/m4GYx/nxAxDv3HRWNkPDRnEnrmUkTiHRt6zp0I9YNZLzyY+p6dYcuB /DRNGsGw+5IMpioZsMc8kOA6nPS6YzzoIJ1oyiVGKJDqDSI2EugL1OXodJ4CwCfuPYZ1 REp66Sy13Bs8ZGN3VFXH63RLG++Yu6oVZEULYhLmh47x1OFnZVC749jNi7O/h4tFue/Q DGlzrCQ3Bvx9y0TmOVJjGTsL0pSL7n6e9OlfrTOwoxGWfLTbMwmCraXUuwVpqUMFUMv/ n9mg== 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=GdMPJhCMm93oBr8bV6hbRVdF86makN8ha0+wmtEvggk=; fh=sa22/YzBg7gBlP1vWMAMO0ID50cEEzmrnuJNDeV9zT4=; b=w6yzs/JTWopt6BGFGhyGq2GrkM4lx61MWcndEY2lsRS+dxHP++KC8dnzCBDxIOyIhi oEl9+UueNS8mqdfY9lxI2eCg6QE/AvVdKktU8nLMAS0n1vj/F2vd8cGBJSY6qY7WQkk2 wyp5MPu3Ihv2wz3XrFO7IBRRwGZZ2XCudqSSgUnHfTVtt+SB2Hs+wMD8OGvtGg4IljD9 e/lNnFDjCIzXG9pTlzzjt31SVfO3AfhxQcUrr23nWkeU6igIfctfcjjWEXXmzn+/FHHw PLfqzCKD6/YcrWfJ8tpwG5pvUkFlu0+1xS8ErqSp3xhNTDP/ngY/i+G3D3Di7tu4g00J Wy7w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; gateway.spf=pass (google.com: domain gapps.redhat.com configured 170.10.128.131 as internal address) smtp.mailfrom=rjones@redhat.com smtp.remote-ip=170.10.128.131 policy.d=gapps.redhat.com Return-Path: Received: from us-smtp-inbound-delivery-1.mimecast.com (us-smtp-delivery-1.mimecast.com. [170.10.128.131]) by mx.google.com with ESMTPS id 6a1803df08f44-6ab70cd02bfsi14747506d6.100.2024.05.23.03.03.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 May 2024 03:03:19 -0700 (PDT) Received-SPF: pass (google.com: domain gapps.redhat.com configured 170.10.128.131 as internal address) Authentication-Results: mx.google.com; gateway.spf=pass (google.com: domain gapps.redhat.com configured 170.10.128.131 as internal address) smtp.mailfrom=rjones@redhat.com smtp.remote-ip=170.10.128.131 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-625-dxY9ts72MZav9dc1-5PTBA-1; Thu, 23 May 2024 06:03:17 -0400 X-MC-Unique: dxY9ts72MZav9dc1-5PTBA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (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 9539D800994 for ; Thu, 23 May 2024 10:03:17 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 91E1B10004FB; Thu, 23 May 2024 10:03:17 +0000 (UTC) Received: from localhost (unknown [10.42.28.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id 16415100046D; Thu, 23 May 2024 10:03:16 +0000 (UTC) Date: Thu, 23 May 2024 11:03:16 +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: <20240523100316.GM10577@redhat.com> References: <20240522205911.261325-1-sbrivio@redhat.com> <20240522205911.261325-3-sbrivio@redhat.com> <20240523095932.GS4345@redhat.com> MIME-Version: 1.0 In-Reply-To: <20240523095932.GS4345@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline List-Id: On Thu, May 23, 2024 at 10:59:32AM +0100, Richard W.M. Jones wrote: > 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 Reading the next patch, I see that fd_tap_listen *isn't* the --fd option ... However that doesn't change the analysis. > 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 nbdkit - Flexible, fast NBD server with plugins https://gitlab.com/nbdkit/nbdkit