From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: passt.top; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=QbmlGtW9; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by passt.top (Postfix) with ESMTPS id 9D9BC5A0265 for ; Wed, 06 May 2026 11:11:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778058669; 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:autocrypt:autocrypt; bh=MIvjH0zf7fHCkLGxeNpOz5/bx8JfQQ/a3MWmY/+8Hhg=; b=QbmlGtW9GobQ2rcgMguyFXkretQSczxCo4jeTGY930cDctEU6bkQ1bq/O3cEnVucbtKPWi 3Pr76Fl1iRCKhhiyt1liN+ct9YJDbhQX+1CEbwEmikpt7gYHTOzGDcpUl/VNvIuXnQ3M90 jHj9OgxpqnZ/uE3K1qEwsAwouINwXng= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-500-szy_1-oMMw6kS8Ggj819Ew-1; Wed, 06 May 2026 05:11:08 -0400 X-MC-Unique: szy_1-oMMw6kS8Ggj819Ew-1 X-Mimecast-MFC-AGG-ID: szy_1-oMMw6kS8Ggj819Ew_1778058667 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-43d7d0947aeso2993143f8f.3 for ; Wed, 06 May 2026 02:11:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778058667; x=1778663467; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=MIvjH0zf7fHCkLGxeNpOz5/bx8JfQQ/a3MWmY/+8Hhg=; b=rWs45EZoqcpjcbH0wXCENW8WZt/54pmMFYm86WoQ/DQJTqQENjQzfTALbv/qb+0qNi u6bVOp37JYgX13Oxs2qMye6Id5EhpSHXidCn79OWUrzExfH0+c9PL3ju0T27dzIpMrT0 Qh9If5rv88ZblTbrSWbSiF9OpvpBzg4CbYe+XTIsYAGvKpnacRlR7IMcM1BMMvzcaJ3A o9+OZZUzV43Uioeh/iH2D1SBOT713R3vCv4Z85YK8VEJbU6kabK6u2HoPastB95QJSe0 DX7+teiHPQHXb/fWobfaV73EgZFoKTEaHvdoBqaCUU1eKyTc810miBPQxHDBCL7WuasO 5GfA== X-Gm-Message-State: AOJu0YyptwIATTTqBfOXSRmMuD43Lgjhxx8fe/4hLb/wqr2Dj5SqBLW4 BlujBbE46BYPSEJ984JHpt6RTIjUjhGJf90kW2l2nuQWxGL5lEjW1lo1zsLgyzR76nkcul+P4o7 iThEo6fA6ZylW1bxdR86fY47U/6/nXX97ZpMOw5kv4w35oGhrVxzcug== X-Gm-Gg: AeBDietfrkg74Y9xLIyq1cQV1ltBBLX4FQt0ENf8D39c8+829X+O43VZBVVbByGMDR+ BXYw3hh9V2UszcVLr/Hf0oIY9JR2ghMg7Ma/ydqp7V/XyDGUROnQ+IeLXecANWKlvZZeTPDxChS +7i3vEJIWDORIu6TMNFOeenYmOkM6HdaRfVFRh41KK6oE/7SliLUYUqSJxDjdYK9hSbezwy7Bm9 5q2QEQeR3eVaDw+BR7Dj4FbFxaBbND6z4PNDUvPBnPKUzxcHibVkynZ0k2POYObTM3NcJbsBKIu LV+piijzMJnlNmWwf5uzEs0SQCUBtk90M1NEkWDWffdUcrKjQvlhnmyHgudflmPtWbycc24B2OW zRwtl+sOWMNVvWR2VSn1oXfHNtJcCMb5udsvVR9E/Rt5quyesx1CaJaW5ixheu0xIcA== X-Received: by 2002:a05:6000:2902:b0:43d:3004:5fef with SMTP id ffacd0b85a97d-4515a6c331amr4475507f8f.7.1778058667124; Wed, 06 May 2026 02:11:07 -0700 (PDT) X-Received: by 2002:a05:6000:2902:b0:43d:3004:5fef with SMTP id ffacd0b85a97d-4515a6c331amr4475458f8f.7.1778058666650; Wed, 06 May 2026 02:11:06 -0700 (PDT) Received: from [192.168.100.100] (82-64-211-94.subs.proxad.net. [82.64.211.94]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-45052a48c04sm11379590f8f.15.2026.05.06.02.11.05 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 06 May 2026 02:11:06 -0700 (PDT) Message-ID: <581577fc-a65a-4800-9acf-de7ff682e944@redhat.com> Date: Wed, 6 May 2026 11:11:05 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v8 17/19] conf, fwd: Allow switching to new rules received from pesto To: David Gibson , Stefano Brivio References: <20260505234719.1437340-1-sbrivio@redhat.com> <20260505234719.1437340-18-sbrivio@redhat.com> <20260506103930.1b7023a6@elisabeth> <20260506104955.51cdc602@elisabeth> From: Laurent Vivier Autocrypt: addr=lvivier@redhat.com; keydata= xsFNBFYFJhkBEAC2me7w2+RizYOKZM+vZCx69GTewOwqzHrrHSG07MUAxJ6AY29/+HYf6EY2 WoeuLWDmXE7A3oJoIsRecD6BXHTb0OYS20lS608anr3B0xn5g0BX7es9Mw+hV/pL+63EOCVm SUVTEQwbGQN62guOKnJJJfphbbv82glIC/Ei4Ky8BwZkUuXd7d5NFJKC9/GDrbWdj75cDNQx UZ9XXbXEKY9MHX83Uy7JFoiFDMOVHn55HnncflUncO0zDzY7CxFeQFwYRbsCXOUL9yBtqLer Ky8/yjBskIlNrp0uQSt9LMoMsdSjYLYhvk1StsNPg74+s4u0Q6z45+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yVcDTa+tz++q2S/Bp P4W98bXCBIuQgs2m+OflERv5c3Ojldp04/S4NEjXEYRWdiCxN7ca5iPml5gLtuvhJMSy36gl U6IW9kn30IWuSoBpTkgV7rLUEhh9Ms82VWW/h2TxL8enfx40PrfbDtWwqRID3WY8jLrjKfTd R3LW8BnUDNkG+c4FzvvGUs8AvuqxxyHbXAfDx9o/jXfPHVRmJVhSmd+hC3mcQ+4iX5bBPBPM oDqSoLt5w9GoQQ6gDVP2ZjTWqwSRMLzNr37rJjZ1pt0DCMMTbiYIUcrhX8eveCJtY7NGWNyx FCRkhxRuGcpwPmRVDwOl39MB3iTsRighiMnijkbLXiKoJ5CDVvX5yicNqYJPKh5MFXN1bvsB kmYiStMRbrD0HoY1kx5/VozBtc70OU0EB8Wrv9hZD+Ofp0T3KOr1RUHvCZoLURfFhSQ= In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: ySZzPphd-djc2VgW8DLLkBlRoFjUrY_x3Hud35eU5nM_1778058667 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Message-ID-Hash: INAQUAMD6HUKECLXMRIEVORSCFQS32G2 X-Message-ID-Hash: INAQUAMD6HUKECLXMRIEVORSCFQS32G2 X-MailFrom: lvivier@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, Jon Maloy 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 5/6/26 10:52, David Gibson wrote: > On Wed, May 06, 2026 at 10:49:55AM +0200, Stefano Brivio wrote: >> On Wed, 6 May 2026 10:39:30 +0200 >> Stefano Brivio wrote: >> >>> On Wed, 6 May 2026 10:12:21 +0200 >>> Laurent Vivier wrote: >>> >>>> On 5/6/26 01:47, Stefano Brivio wrote: >>>>> From: David Gibson >>>>> >>>>> We can now receive updates to the forwarding rules from the pesto client >>>>> and store them in a "pending" copy of the forwarding tables. Implement >>>>> switching to using the new rules. >>>>> >>>>> The logic is in a new fwd_listen_switch(). For now this closes all >>>>> listening sockets related to the old tables, swaps the active and pending >>>>> tables, then listens based on the new tables. In future we look to improve >>>>> this so that we don't temporarily stop listening on ports that both the >>>>> old and new tables specify. >>>>> >>>>> Signed-off-by: David Gibson >>>>> [sbrivio: In fwd_listen_switch(), use the destination size as argument >>>>> to memcpy(), instead of sizeof(tmp), as suggested by Laurent] >>>>> Signed-off-by: Stefano Brivio >>>>> --- >>>>> conf.c | 5 ++--- >>>>> fwd.c | 34 ++++++++++++++++++++++++++++++++++ >>>>> fwd.h | 1 + >>>>> 3 files changed, 37 insertions(+), 3 deletions(-) >>>>> >>>>> diff --git a/conf.c b/conf.c >>>>> index 76344da..3f48793 100644 >>>>> --- a/conf.c >>>>> +++ b/conf.c >>>>> @@ -2160,15 +2160,14 @@ void conf_handler(struct ctx *c, uint32_t events) >>>>> fwd_rules_dump(info, fwd->rules, fwd->count, >>>>> " ", ""); >>>>> } >>>>> + >>>>> + fwd_listen_switch(c); >>>>> } >>>>> >>>>> if (events & EPOLLHUP) { >>>>> debug("Configuration client hangup"); >>>>> - goto close; >>>>> } >>>>> >>>>> - return; >>>>> - >>>>> close: >>>>> conf_close(c); >>>>> >>>>> diff --git a/fwd.c b/fwd.c >>>>> index d93d2e5..0697435 100644 >>>>> --- a/fwd.c >>>>> +++ b/fwd.c >>>>> @@ -534,6 +534,40 @@ int fwd_listen_init(const struct ctx *c) >>>>> return 0; >>>>> } >>>>> >>>>> +/** >>>>> + * fwd_listen_switch() - Switch from current to pending rules table >>>>> + * @c: Execution context >>>>> + */ >>>>> +void fwd_listen_switch(struct ctx *c) >>>>> +{ >>>>> + struct fwd_table *tmp[PIF_NUM_TYPES]; >>>>> + unsigned i; >>>>> + >>>>> + /* Stop listening on the old tables */ >>>>> + for (i = 0; i < PIF_NUM_TYPES; i++) { >>>>> + struct fwd_table *fwd = c->fwd[i]; >>>>> + >>>>> + if (!fwd) >>>>> + continue; >>>>> + >>>>> + debug("Flushing %u old %s rules", fwd->count, pif_name(i)); >>>>> + fwd_listen_close(fwd); >>>>> + fwd->count = fwd->sock_count = 0; >>>>> + } >>>>> + >>>>> + /* Swap active and pending tables */ >>>>> + static_assert(sizeof(tmp) == sizeof(c->fwd) && >>>>> + sizeof(tmp) == sizeof(c->fwd_pending), >>>>> + "Temporary has wrong size"); >>>> >>>> At this point: >>>> >>>> c->fwd[PIF_HOST] = &fwd_in; >>>> c->fwd[PIF_SPLICE] = &fwd_out; >>>> >>>> c->fwd_pending[PIF_HOST] = &fwd_in_pending; >>>> c->fwd_pending[PIF_SPLICE] = &fwd_out_pending; >>>> >>>>> + memcpy(&tmp, (void *)c->fwd, sizeof(tmp)); >>>>> + memcpy((void *)c->fwd, (void *)c->fwd_pending, sizeof(c->fwd)); >>>>> + memcpy((void *)c->fwd_pending, &tmp, sizeof(c->fwd_pending)); >>>> >>>> At this point: >>>> >>>> c->fwd[PIF_HOST] = &fwd_in_pending; >>>> c->fwd[PIF_SPLICE] = &fwd_out_pending; >>>> >>>> c->fwd_pending[PIF_HOST] = &fwd_in; >>>> c->fwd_pending[PIF_SPLICE] = &fwd_out; >>> >>> Yeah, makes sense, I can change that in v9. >>> >>>> Perhaps it should be noted somewhere to avoid confusion in the future? >>> >>> What do you think should be noted exactly, and where? Can you show a >>> practical example of the change you're proposing? >> >> ...I'm leaving like it is in v9 to make sure I'm not misinterpreting >> you, and also because the current (v8) version is obviously correct and >> I also tested it fairly heavily by now. >> >> I'd suggest optimising this (and commenting as needed) in a separate >> patch later. > > As noted in another branch of this thread, I think all it really needs > is renaming the globals that c->fwd and c->fwd_pending point to. They > should just be fwd_in_[12] (or an array of 2 tables), instead of > implying a semantic difference between the plain and "pending" copies. > I agree with that. Thanks, Laurent