aboutgitcodebugslistschat
diff options
context:
space:
mode:
-rw-r--r--flow_table.h6
-rw-r--r--tcp_splice.c6
2 files changed, 9 insertions, 3 deletions
diff --git a/flow_table.h b/flow_table.h
index 8a5f8f2..4f5d041 100644
--- a/flow_table.h
+++ b/flow_table.h
@@ -41,6 +41,12 @@ union flow {
extern unsigned flow_first_free;
extern union flow flowtab[];
+/**
+ * flow_foreach_sidei() - 'for' type macro to step through each side of flow
+ * @sidei_: Takes value INISIDE, then TGTSIDE
+ */
+#define flow_foreach_sidei(sidei_) \
+ for ((sidei_) = INISIDE; (sidei_) < SIDES; (sidei_)++)
/** flow_idx() - Index of flow from common structure
* @f: Common flow fields pointer
diff --git a/tcp_splice.c b/tcp_splice.c
index 8bc68a1..5a9325b 100644
--- a/tcp_splice.c
+++ b/tcp_splice.c
@@ -263,7 +263,7 @@ bool tcp_splice_flow_defer(struct tcp_splice_conn *conn)
if (!(conn->flags & CLOSING))
return false;
- for (sidei = 0; sidei < SIDES; sidei++) {
+ flow_foreach_sidei(sidei) {
/* Flushing might need to block: don't recycle them. */
if (conn->pipe[sidei][0] >= 0) {
close(conn->pipe[sidei][0]);
@@ -299,7 +299,7 @@ static int tcp_splice_connect_finish(const struct ctx *c,
unsigned sidei;
int i = 0;
- for (sidei = 0; sidei < SIDES; sidei++) {
+ flow_foreach_sidei(sidei) {
for (; i < TCP_SPLICE_PIPE_POOL_SIZE; i++) {
if (splice_pipe_pool[i][0] >= 0) {
SWAP(conn->pipe[sidei][0],
@@ -820,7 +820,7 @@ void tcp_splice_timer(const struct ctx *c, struct tcp_splice_conn *conn)
ASSERT(!(conn->flags & CLOSING));
- for (sidei = 0; sidei < SIDES; sidei++) {
+ flow_foreach_sidei(sidei) {
uint8_t set = sidei == 0 ? RCVLOWAT_SET_0 : RCVLOWAT_SET_1;
uint8_t act = sidei == 0 ? RCVLOWAT_ACT_0 : RCVLOWAT_ACT_1;