aboutgitcodebugslistschat
path: root/tcp_splice.c
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2023-11-07 13:42:43 +1100
committerStefano Brivio <sbrivio@redhat.com>2023-11-07 09:54:00 +0100
commit409d3ca87f858152de88d61112c71d8464ff6149 (patch)
tree670b97c9f2ddc02b2617890eb3173b0c208c6929 /tcp_splice.c
parent5a79ba6272814dda72b387ea13b97d1f0e79dbcf (diff)
downloadpasst-409d3ca87f858152de88d61112c71d8464ff6149.tar
passt-409d3ca87f858152de88d61112c71d8464ff6149.tar.gz
passt-409d3ca87f858152de88d61112c71d8464ff6149.tar.bz2
passt-409d3ca87f858152de88d61112c71d8464ff6149.tar.lz
passt-409d3ca87f858152de88d61112c71d8464ff6149.tar.xz
passt-409d3ca87f858152de88d61112c71d8464ff6149.tar.zst
passt-409d3ca87f858152de88d61112c71d8464ff6149.zip
tcp_splice: Remove unnecessary forward declaration
In tcp_splice.c we forward declare tcp_splice_epoll_ctl() then define it later on. However, there are no circular dependencies which prevent us from simply having the full definition in place of the forward declaration. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'tcp_splice.c')
-rw-r--r--tcp_splice.c71
1 files changed, 34 insertions, 37 deletions
diff --git a/tcp_splice.c b/tcp_splice.c
index 570a8c6..44d1e4a 100644
--- a/tcp_splice.c
+++ b/tcp_splice.c
@@ -116,8 +116,41 @@ static void tcp_splice_conn_epoll_events(uint16_t events,
*b |= (events & B_OUT_WAIT) ? EPOLLOUT : 0;
}
+/**
+ * tcp_splice_epoll_ctl() - Add/modify/delete epoll state from connection events
+ * @c: Execution context
+ * @conn: Connection pointer
+ *
+ * Return: 0 on success, negative error code on failure (not on deletion)
+ */
static int tcp_splice_epoll_ctl(const struct ctx *c,
- struct tcp_splice_conn *conn);
+ struct tcp_splice_conn *conn)
+{
+ int m = conn->in_epoll ? EPOLL_CTL_MOD : EPOLL_CTL_ADD;
+ union epoll_ref ref_a = { .type = EPOLL_TYPE_TCP, .fd = conn->a,
+ .tcp.index = CONN_IDX(conn) };
+ union epoll_ref ref_b = { .type = EPOLL_TYPE_TCP, .fd = conn->b,
+ .tcp.index = CONN_IDX(conn) };
+ struct epoll_event ev_a = { .data.u64 = ref_a.u64 };
+ struct epoll_event ev_b = { .data.u64 = ref_b.u64 };
+ uint32_t events_a, events_b;
+
+ tcp_splice_conn_epoll_events(conn->events, &events_a, &events_b);
+ ev_a.events = events_a;
+ ev_b.events = events_b;
+
+ if (epoll_ctl(c->epollfd, m, conn->a, &ev_a) ||
+ epoll_ctl(c->epollfd, m, conn->b, &ev_b)) {
+ int ret = -errno;
+ err("TCP (spliced): index %li, ERROR on epoll_ctl(): %s",
+ CONN_IDX(conn), strerror(errno));
+ return ret;
+ }
+
+ conn->in_epoll = true;
+
+ return 0;
+}
/**
* conn_flag_do() - Set/unset given flag, log, update epoll on CLOSING flag
@@ -166,42 +199,6 @@ static void conn_flag_do(const struct ctx *c, struct tcp_splice_conn *conn,
} while (0)
/**
- * tcp_splice_epoll_ctl() - Add/modify/delete epoll state from connection events
- * @c: Execution context
- * @conn: Connection pointer
- *
- * Return: 0 on success, negative error code on failure (not on deletion)
- */
-static int tcp_splice_epoll_ctl(const struct ctx *c,
- struct tcp_splice_conn *conn)
-{
- int m = conn->in_epoll ? EPOLL_CTL_MOD : EPOLL_CTL_ADD;
- union epoll_ref ref_a = { .type = EPOLL_TYPE_TCP, .fd = conn->a,
- .tcp.index = CONN_IDX(conn) };
- union epoll_ref ref_b = { .type = EPOLL_TYPE_TCP, .fd = conn->b,
- .tcp.index = CONN_IDX(conn) };
- struct epoll_event ev_a = { .data.u64 = ref_a.u64 };
- struct epoll_event ev_b = { .data.u64 = ref_b.u64 };
- uint32_t events_a, events_b;
-
- tcp_splice_conn_epoll_events(conn->events, &events_a, &events_b);
- ev_a.events = events_a;
- ev_b.events = events_b;
-
- if (epoll_ctl(c->epollfd, m, conn->a, &ev_a) ||
- epoll_ctl(c->epollfd, m, conn->b, &ev_b)) {
- int ret = -errno;
- err("TCP (spliced): index %li, ERROR on epoll_ctl(): %s",
- CONN_IDX(conn), strerror(errno));
- return ret;
- }
-
- conn->in_epoll = true;
-
- return 0;
-}
-
-/**
* conn_event_do() - Set and log connection events, update epoll state
* @c: Execution context
* @conn: Connection pointer