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=OdADVXs1; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by passt.top (Postfix) with ESMTPS id C5F9E5A0269 for ; Wed, 06 May 2026 01:47:46 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778024865; 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=9d3Ys2fWPSdWazg1+tZc+nxRcwzBLtl8pmkMJ8cojYM=; b=OdADVXs1H+DN1sPyxBzP7K/q0w6RPLxKNWPemOu1sU7aa4GSyH8ggbXdLv18op4xnrN70x FsboGakNkUDVfr9RxhFYql1jn9ySu77+Fd96jDsHNkHi29lnaEddXQpGjP61/382TcXR/t QHCVzaM3o+WD/6wsKHop1EL+3tylIew= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-503-Vas7xJpUOU-B4X5vaxVRsg-1; Tue, 05 May 2026 19:47:44 -0400 X-MC-Unique: Vas7xJpUOU-B4X5vaxVRsg-1 X-Mimecast-MFC-AGG-ID: Vas7xJpUOU-B4X5vaxVRsg_1778024863 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-449b2a183d3so204796f8f.0 for ; Tue, 05 May 2026 16:47:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778024863; x=1778629663; h=date:content-transfer-encoding:mime-version:organization:references :in-reply-to:message-id:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=9d3Ys2fWPSdWazg1+tZc+nxRcwzBLtl8pmkMJ8cojYM=; b=sRFA0ECreEs3lTlVH6+LVHLqSMb/v9WutgrnkO9bbtR4yWGXERyxMSQjAnLLXcITeW rqHb1dBDs7vPrONiER9TsZf2awWrUKACI8Hw20VrYi3rbpuTCP8CSOwK0DrYj64mlJrQ MueGsOrz8x1BA5coHo2hY9kMwKfXe5040Ao7PGi3CuRiBWWOIsbUA5N5jiwg2a/hT7we frE0p22s0oRyrx/tKXMfBge8wvsda76g+PWeb7AeQEP+SWkpR7wRknlLlybFjNKv+GdO 5uuCR4kTKCPQgqYXg6ZOqWG2HthAfAyPCncrflCmIqjsPFDVzY0ZsULh2HPsGi45d52p 2eUA== X-Gm-Message-State: AOJu0YxG8U8BM1C+of7bQzYM0BGVp2pwHrqMaT0T2BFribDlKAic9GnJ EdU1emlMA6hdC4r2KxZF4uvDCnbjLA3S2qxGbL8XoUFqdO/vdsd7MN3A75FW+b+Y2TXvYV0EPEs qxsHIuJglI7Ap712hhkxRuknNJ3aBoYzzULGUxWcj2ArxMhePwLaOcg== X-Gm-Gg: AeBDieuFQNq9gImWZ81w45Wne31KSb4XHw4Tx6kfKC7etOeB7NFItQmvfPSJwj12dgg 6DW5wRg85toNO28Fg+6i7H7C45lg67oOI0pe2dFhmdjPGWYopLVdj23ofy9enAkHrR+DQs2T8uq WkdWg8BBvH36g6RSvSeK7qbIsRnBsEij7DpRDDaFmf4VBl5Fcf+L7Z3870X7vXxzs5JxA5orC9E zOIP3AN8TxN7qilkn8bs0HZb8S2m/BDWELwhUkOLIR/LN6C+eJwjgD6ScGyPK5+g4B/z/8zFE1N G9YfA26Jb7v8wjjMgiBhry1u6uBKZ8pp3+l/xZYUbBhgsvl7xEq+shPiEMbZcSPl2ECqr75evWx wmYMnxBgh75F8PXvA1N5A4eLjUC4SzMmS9e6SYvw0AE+w7NgF0Q9hb82gVWeK X-Received: by 2002:a05:6000:1842:b0:44c:53dc:8cb2 with SMTP id ffacd0b85a97d-4516594c3f1mr1484349f8f.14.1778024863388; Tue, 05 May 2026 16:47:43 -0700 (PDT) X-Received: by 2002:a05:6000:1842:b0:44c:53dc:8cb2 with SMTP id ffacd0b85a97d-4516594c3f1mr1484331f8f.14.1778024862921; Tue, 05 May 2026 16:47:42 -0700 (PDT) Received: from maya.myfinge.rs (ifcgrfdd.trafficplex.cloud. [176.103.220.4]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-45054b02f76sm7747980f8f.23.2026.05.05.16.47.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 May 2026 16:47:42 -0700 (PDT) From: Stefano Brivio To: Laurent Vivier Subject: Re: [PATCH v7 17/18] conf, fwd: Allow switching to new rules received from pesto Message-ID: <20260506014740.05933ec8@elisabeth> In-Reply-To: References: <20260504231142.1118652-1-sbrivio@redhat.com> <20260504231142.1118652-18-sbrivio@redhat.com> Organization: Red Hat X-Mailer: Claws Mail 4.2.0 (GTK 3.24.49; x86_64-pc-linux-gnu) MIME-Version: 1.0 Date: Wed, 06 May 2026 01:47:41 +0200 (CEST) X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 65pchYpIsLqVcI0GA1cdDV7fj_DfTR4pJKNSk4xrJiw_1778024863 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: CRC5L6VJPJJV5335OD4CIYGRSZGMXZPX X-Message-ID-Hash: CRC5L6VJPJJV5335OD4CIYGRSZGMXZPX 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, Jon Maloy , David Gibson 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 Tue, 5 May 2026 11:08:27 +0200 Laurent Vivier wrote: > On 5/5/26 01:11, 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 > > 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 f035fd3..75b8291 100644 > > --- a/conf.c > > +++ b/conf.c > > @@ -2159,15 +2159,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..35b9e2b 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; > > Perhaps we can reset fwd->count and fwd->sock_count in fwd_listen_close() as after > fwd_listen_close() these values are wrong? > > > + } > > + > > + /* Swap active and pending tables */ > > + static_assert(sizeof(tmp) == sizeof(c->fwd) && > > + sizeof(tmp) == sizeof(c->fwd_pending), > > + "Temporary has wrong size"); > > + memcpy(&tmp, (void *)c->fwd, sizeof(tmp)); > > + memcpy((void *)c->fwd, (void *)c->fwd_pending, sizeof(tmp)); > > + memcpy((void *)c->fwd_pending, &tmp, sizeof(tmp)); > > I know we have the static_assert(), but with memcpy() we usually use the sizeof() of the > destination to avoid write overflow. Changed in v8. -- Stefano