From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gandalf.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id E21735A0271 for ; Tue, 7 Nov 2023 02:40:34 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=201602; t=1699321229; bh=O43hlTUR6zYd+tJ5jW/U9GYtKrU1872prNTpzNsbWUA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KSsdi2IErVCuWVr/fYY6mGBgnNrDzFmK2j+3mq70Ymo57Tnuma6Jx+MgKYPEmC4fP GQ/Nslf8XRNnvbDYaugsSnBs0aW/oPsfzTEQ0SsXbJkdEXxNoV9wxTSkB14i+qkIhV pux17+PjvUgxaC/zyGG639jqCnx6K9w22Hk90vIg= Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4SPWBP2YhWz4xGQ; Tue, 7 Nov 2023 12:40:29 +1100 (AEDT) From: David Gibson To: passt-dev@passt.top, Stefano Brivio Subject: [PATCH v2 1/4] udp: Clean up ref initialisation in udp_sock_init() Date: Tue, 7 Nov 2023 12:40:13 +1100 Message-ID: <20231107014016.1927410-2-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231107014016.1927410-1-david@gibson.dropbear.id.au> References: <20231107014016.1927410-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: UUU4LKDG37V3BZYUAZOHLSM3QUNOYDYH X-Message-ID-Hash: UUU4LKDG37V3BZYUAZOHLSM3QUNOYDYH 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