mirror of
https://passt.top/passt
synced 2024-11-09 22:29:56 +00:00
flow: Introduce flow_foreach_sidei() macro
We have a handful of places where we use a loop to step through each side of a flow or flows, and we're probably going to have mroe in future. Introduce a macro to implement this loop for convenience. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
This commit is contained in:
parent
71d7985188
commit
5235c47c79
@ -41,6 +41,12 @@ union flow {
|
|||||||
extern unsigned flow_first_free;
|
extern unsigned flow_first_free;
|
||||||
extern union flow flowtab[];
|
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
|
/** flow_idx() - Index of flow from common structure
|
||||||
* @f: Common flow fields pointer
|
* @f: Common flow fields pointer
|
||||||
|
@ -263,7 +263,7 @@ bool tcp_splice_flow_defer(struct tcp_splice_conn *conn)
|
|||||||
if (!(conn->flags & CLOSING))
|
if (!(conn->flags & CLOSING))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
for (sidei = 0; sidei < SIDES; sidei++) {
|
flow_foreach_sidei(sidei) {
|
||||||
/* Flushing might need to block: don't recycle them. */
|
/* Flushing might need to block: don't recycle them. */
|
||||||
if (conn->pipe[sidei][0] >= 0) {
|
if (conn->pipe[sidei][0] >= 0) {
|
||||||
close(conn->pipe[sidei][0]);
|
close(conn->pipe[sidei][0]);
|
||||||
@ -299,7 +299,7 @@ static int tcp_splice_connect_finish(const struct ctx *c,
|
|||||||
unsigned sidei;
|
unsigned sidei;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
for (sidei = 0; sidei < SIDES; sidei++) {
|
flow_foreach_sidei(sidei) {
|
||||||
for (; i < TCP_SPLICE_PIPE_POOL_SIZE; i++) {
|
for (; i < TCP_SPLICE_PIPE_POOL_SIZE; i++) {
|
||||||
if (splice_pipe_pool[i][0] >= 0) {
|
if (splice_pipe_pool[i][0] >= 0) {
|
||||||
SWAP(conn->pipe[sidei][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));
|
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 set = sidei == 0 ? RCVLOWAT_SET_0 : RCVLOWAT_SET_1;
|
||||||
uint8_t act = sidei == 0 ? RCVLOWAT_ACT_0 : RCVLOWAT_ACT_1;
|
uint8_t act = sidei == 0 ? RCVLOWAT_ACT_0 : RCVLOWAT_ACT_1;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user