From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by passt.top (Postfix) with ESMTP id 2922F5A004E for ; Thu, 11 Jul 2024 10:23:56 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720686235; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Bz2+EYSWL/MM3qtlO4BIYpqHOFRYI69jL9D1/GdRtVw=; b=PYNKAhhgJPP85zoGjEUYfmqVEZuIatlT4cezkSmN3HttsaJG7ZUo4+zaMJndu29botP7AL TD0HisEmMr7xt0DOP/ps1Qaip+6PtOryJLs4P4ZfAU9klrn/ReEZWTZc6/jy12Gwtg5BC6 RdUXN8t5kHRqzwCo+l3XKbgcKYIfink= Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-496-lblug2AiOmyKR1bJY0TDpQ-1; Thu, 11 Jul 2024 04:23:53 -0400 X-MC-Unique: lblug2AiOmyKR1bJY0TDpQ-1 Received: by mail-qk1-f197.google.com with SMTP id af79cd13be357-7a143064795so55888485a.0 for ; Thu, 11 Jul 2024 01:23:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720686232; x=1721291032; h=content-transfer-encoding:mime-version:organization:references :in-reply-to:message-id:subject:cc:to:from:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=Bz2+EYSWL/MM3qtlO4BIYpqHOFRYI69jL9D1/GdRtVw=; b=VcfqXBeZPZxjLwmpES+2j1vxam8DhyRWAN4tsAkz9aJ6hOAQcadouOF0PKWkYX645P 0G5iqAE2K2KXtjiX8MYDGccMKcZkzVBCKbg9rX6EwvhHD1q17gZxQIrfMspBV3eeEThu 6eQzriWj6D4axw9KVzk9b1EXtAS5Pu8WmRIZfe5D3Ob1q3cuwf5G5Smi8cq+R8sJaEUK BUbYTfgPlem6jhO7CALezYlsid6IslT218OlSvKpK5H4CMBCyCKwBZVszwahLvP20oQx 03z8EGEleOK9dpvbjPXK59oap1VXSsNxzDXQd89UJaFS8EvoJim72tKbiTz+UgV3Wj8e WqgQ== X-Gm-Message-State: AOJu0Yzn93ZPx4mf8GrXQF/6/7bXYMUU6FdIpRXd0sdqdznWEBT1mZGo 72ptdf2Q+fa6loYZ0pLfMiUMObnAtJL+W6OCWhvgWRnczb5XV3QPOy20sK0aA8voStjXLm2uz3m cdnEk2RXAqVvgT2kwOmlaVY8lOw2giLqhlWsYLeH/9swVh8RIzQ== X-Received: by 2002:a05:620a:3bd7:b0:798:c7d2:a89d with SMTP id af79cd13be357-79f19ae175fmr886709085a.64.1720686232505; Thu, 11 Jul 2024 01:23:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGvG5Dn6LCgOxO7vU5BSPVoL0mbr4Tnw3i8c1MgTp6+hBlRbPBfkNVKY3f/Rim1ZVeMK5B/gQ== X-Received: by 2002:a05:620a:3bd7:b0:798:c7d2:a89d with SMTP id af79cd13be357-79f19ae175fmr886708085a.64.1720686232188; Thu, 11 Jul 2024 01:23:52 -0700 (PDT) Received: from maya.cloud.tilaa.com (maya.cloud.tilaa.com. [164.138.29.33]) by smtp.gmail.com with ESMTPSA id af79cd13be357-79f1909ab81sm269338685a.99.2024.07.11.01.23.51 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Jul 2024 01:23:51 -0700 (PDT) Date: Thu, 11 Jul 2024 10:23:17 +0200 From: Stefano Brivio To: David Gibson Subject: Re: [PATCH v7 21/27] udp: Handle "spliced" datagrams with per-flow sockets Message-ID: <20240711102307.0b97dc2f@elisabeth> In-Reply-To: References: <20240705020724.3447719-1-david@gibson.dropbear.id.au> <20240705020724.3447719-22-david@gibson.dropbear.id.au> <20240710003233.1d9937fd@elisabeth> <20240710191316.53b7ac5d@elisabeth> Organization: Red Hat X-Mailer: Claws Mail 4.2.0 (GTK 3.24.41; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: 7QL4HQRRZCCWAUPUXWTAG4PIZNR5MALC X-Message-ID-Hash: 7QL4HQRRZCCWAUPUXWTAG4PIZNR5MALC X-MailFrom: sbrivio@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: passt-dev@passt.top, jmaloy@redhat.com X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On Thu, 11 Jul 2024 11:30:52 +1000 David Gibson wrote: > On Wed, Jul 10, 2024 at 07:13:26PM +0200, Stefano Brivio wrote: > > On Wed, 10 Jul 2024 10:23:14 +1000 > > David Gibson wrote: > > > > > On Wed, Jul 10, 2024 at 12:32:33AM +0200, Stefano Brivio wrote: > > > > On Fri, 5 Jul 2024 12:07:18 +1000 > > > > David Gibson wrote: > [snip] > > > > > + uflow->s[INISIDE] = fcntl(s_ini, F_DUPFD_CLOEXEC, 0); > > > > > > > > There's one aspect of this I don't understand: if s_ini is closed while > > > > checking for bound ports (is it? I didn't really reach the end of this > > > > series), aren't duplicates also closed? > > > > > > > > That is, the documentation of dup2(2), which should be the same for > > > > this purpose, states that the duplicate inherits "file status flags", > > > > which I would assume also includes the fact that a socket is closed. I > > > > didn't test that though. > > > > > > I don't believe so. My understanding is that dup() (and the rest) > > > make a new fd referencing the same underlying file object, yes. But > > > AIUI, close() just closes one fd - the underlying object is only > > > closed only when all fds are gone. > > > > Ah, probably, yes. > > > > > > If duplicates are closed, I guess an alternative solution could be to > > > > introduce some kind of reference counting for sockets... somewhere. > > > > > > .. in other words, I believe the kernel does the reference counting. > > > > > > I should verify this though, I'll try to come up with something new > > > for doc/platform-requirements. > > > > I didn't really find the time to sketch this but I guess the easiest > > way to check this behaviour is to have a TCP connection between a > > socket pair, with one socket having two descriptors, then closing one > > descriptor and check if the peer socket sees a closed connection > > (recv() returning 0 or similar). > > So.. yes, this would check whether close() on a non-last fd for a > socket triggers socket closing actions, but that's much stricter than > what we actually need here. I would, for example, expect shutdown() > on a TCP socket to affect all dups - and I don't actually know if a > close() on one dup might trigger that. > > But we're dealing with UDP here, so there's no "on wire" effect of a > close. Right, that's why I was thinking of using a TCP socket. On the other hand it's a bit silly to test something slightly different to indirectly check the hypothesis. > So all we actually need to check is: > 1. Open a "listening" udp socket > 2. Dup it > 3. Close a dup > 4. Can the remaining dup still receive datagrams? ...sounds much better, yes. -- Stefano