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 0A6915A026B for ; Fri, 25 Nov 2022 08:29:26 +0100 (CET) Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4NJRM42Ksrz4xP3; Fri, 25 Nov 2022 18:29:20 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=201602; t=1669361360; bh=gMNGUObd0+yQphfvlpPJgT/OSlT21oGN8VIMa+3aGmE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RjbLtB0fCFwWsA2mRXFULN4n0IWVgFFksV5SXy3qHBi5rsIzpc7KzZ09gCgZEbBDh RdFRFUFQqYz0N/70nSoNh7l0k1vbD/iZFTfBlNMwUzodQnkRfkFlvLYZFxV6wFr+sO BrkiHKm6siU7sWTtzNgpcQrLt71H1J9QaHPmjZcA= From: David Gibson To: Stefano Brivio , passt-dev@passt.top Subject: [PATCH v3 11/16] udp: Simplify udp_sock_handler_splice Date: Fri, 25 Nov 2022 18:29:11 +1100 Message-Id: <20221125072916.3060938-12-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221125072916.3060938-1-david@gibson.dropbear.id.au> References: <20221125072916.3060938-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: RQPZBQZ6T4IX26LGOME3C45OUNQLUHXY X-Message-ID-Hash: RQPZBQZ6T4IX26LGOME3C45OUNQLUHXY 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.3 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: Previous cleanups mean that we can now rework some complex ifs in udp_sock_handler_splice() into a simpler set. Signed-off-by: David Gibson --- udp.c | 47 +++++++++++++++-------------------------------- 1 file changed, 15 insertions(+), 32 deletions(-) diff --git a/udp.c b/udp.c index d835a89..25a37c6 100644 --- a/udp.c +++ b/udp.c @@ -532,50 +532,33 @@ static void udp_sock_handler_splice(const struct ctx *c, union epoll_ref ref, } - if (ref.r.p.udp.udp.orig && !ref.r.p.udp.udp.ns) { - src += c->udp.fwd_out.rdelta[src]; - - if (!(s = udp_splice_ns[v6][src].sock)) { - struct udp_splice_new_ns_arg arg = { - c, v6, src, -1, - }; - - NS_CALL(udp_splice_new_ns, &arg); - if ((s = arg.s) < 0) - return; - } - - udp_splice_init[v6][dst].ts = now->tv_sec; - udp_splice_ns[v6][src].ts = now->tv_sec; - } else if (!ref.r.p.udp.udp.orig && ref.r.p.udp.udp.ns) { + if (ref.r.p.udp.udp.ns) { src += c->udp.fwd_in.rdelta[src]; + s = udp_splice_init[v6][src].sock; + if (!s && ref.r.p.udp.udp.orig) + s = udp_splice_new(c, v6, src, false); - if (!(s = udp_splice_init[v6][src].sock)) + if (s < 0) return; udp_splice_ns[v6][dst].ts = now->tv_sec; udp_splice_init[v6][src].ts = now->tv_sec; - } else if (ref.r.p.udp.udp.orig && ref.r.p.udp.udp.ns) { - src += c->udp.fwd_in.rdelta[src]; - - if (!(s = udp_splice_init[v6][src].sock)) { - s = udp_splice_new(c, v6, src, false); - if (s < 0) - return; - } - - udp_splice_ns[v6][dst].ts = now->tv_sec; - udp_splice_init[v6][src].ts = now->tv_sec; - } else if (!ref.r.p.udp.udp.orig && !ref.r.p.udp.udp.ns) { + } else { src += c->udp.fwd_out.rdelta[src]; + s = udp_splice_ns[v6][src].sock; + if (!s && ref.r.p.udp.udp.orig) { + struct udp_splice_new_ns_arg arg = { + c, v6, src, -1, + }; - if (!(s = udp_splice_ns[v6][src].sock)) + NS_CALL(udp_splice_new_ns, &arg); + s = arg.s; + } + if (s < 0) return; udp_splice_init[v6][dst].ts = now->tv_sec; udp_splice_ns[v6][src].ts = now->tv_sec; - } else { - return; } for (i = 0; i < n; i++) { -- 2.38.1