From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gandalf.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id 5D6B75A0272 for ; Mon, 9 Oct 2023 10:30:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=201602; t=1696840216; bh=O43hlTUR6zYd+tJ5jW/U9GYtKrU1872prNTpzNsbWUA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FwVVBQ+YgW1pHRzwHFQdlNMw3XkSL2dkPXaDVs4jcTNuEB6c56SzRIkwqFyaqCD39 Rv7ZJL2by281wiwXszOQWqQ6me8/YtjR5rpoXESCIJp9Uxlp7fOXLUpmyH9bZGrHfn SpaMp0WmlBerX6uMdrb2JpQ8TRLKenir+HCx+EEQ= Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4S3sfc3mP7z4xWS; Mon, 9 Oct 2023 19:30:16 +1100 (AEDT) From: David Gibson To: Stefano Brivio , passt-dev@passt.top Subject: [PATCH 1/4] udp: Clean up ref initialisation in udp_sock_init() Date: Mon, 9 Oct 2023 19:30:10 +1100 Message-ID: <20231009083013.2837178-2-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231009083013.2837178-1-david@gibson.dropbear.id.au> References: <20231009083013.2837178-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: OA5NZSXXVLDIRXBCAKCR7OFJ23DUCS3H X-Message-ID-Hash: OA5NZSXXVLDIRXBCAKCR7OFJ23DUCS3H X-MailFrom: dgibson@gandalf.ozlabs.org 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: 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: udp_sock_init() has a number of paths that initialise uref differently. However some of the fields are initialised the same way in all of them. Move those fields into the original initialiser to save a few lines. Signed-off-by: David Gibson --- udp.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/udp.c b/udp.c index cadf393..db35859 100644 --- a/udp.c +++ b/udp.c @@ -969,7 +969,8 @@ int udp_tap_handler(struct ctx *c, int af, const void *saddr, const void *daddr, int udp_sock_init(const struct ctx *c, int ns, sa_family_t af, const void *addr, const char *ifname, in_port_t port) { - union udp_epoll_ref uref = { .u32 = 0 }; + union udp_epoll_ref uref = { .splice = (c->mode == MODE_PASTA), + .orig = true }; int s, r4 = FD_REF_MAX + 1, r6 = FD_REF_MAX + 1; if (ns) { @@ -980,8 +981,6 @@ int udp_sock_init(const struct ctx *c, int ns, sa_family_t af, if ((af == AF_INET || af == AF_UNSPEC) && c->ifi4) { uref.v6 = 0; - uref.splice = (c->mode == MODE_PASTA); - uref.orig = true; if (!ns) { r4 = s = sock_l4(c, AF_INET, IPPROTO_UDP, addr, @@ -1001,8 +1000,6 @@ int udp_sock_init(const struct ctx *c, int ns, sa_family_t af, if ((af == AF_INET6 || af == AF_UNSPEC) && c->ifi6) { uref.v6 = 1; - uref.splice = (c->mode == MODE_PASTA); - uref.orig = true; if (!ns) { r6 = s = sock_l4(c, AF_INET6, IPPROTO_UDP, addr, -- 2.41.0