aboutgitcodebugslistschat
path: root/udp.c
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2022-11-30 15:13:11 +1100
committerStefano Brivio <sbrivio@redhat.com>2022-12-06 07:41:48 +0100
commit5b0027f942b7a15061eeec9b86f6e51b86042445 (patch)
treeace5874f42dacd8dfd19feb0833d66aac3cb32be /udp.c
parent71d2595a8f045a7b7bc51e4a9472d5eb540fe079 (diff)
downloadpasst-5b0027f942b7a15061eeec9b86f6e51b86042445.tar
passt-5b0027f942b7a15061eeec9b86f6e51b86042445.tar.gz
passt-5b0027f942b7a15061eeec9b86f6e51b86042445.tar.bz2
passt-5b0027f942b7a15061eeec9b86f6e51b86042445.tar.lz
passt-5b0027f942b7a15061eeec9b86f6e51b86042445.tar.xz
passt-5b0027f942b7a15061eeec9b86f6e51b86042445.tar.zst
passt-5b0027f942b7a15061eeec9b86f6e51b86042445.zip
udp: Simplify udp_sock_handler_splice
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 <david@gibson.dropbear.id.au> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'udp.c')
-rw-r--r--udp.c47
1 files 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++) {