mirror of
https://passt.top/passt
synced 2025-07-07 20:48:43 +02:00
tcp_splice: Use parameterised macros for per-side event/flag bits
Both the events and flags fields in tcp_splice_conn have several bits which are per-side, e.g. OUT_WAIT_0 for side 0 and OUT_WAIT_1 for side 1. This necessitates some rather awkward ternary expressions when we need to get the relevant bit for a particular side. Simplify this by using a parameterised macro for the bit values. This needs a ternary expression inside the macros, but makes the places we use it substantially clearer. That simplification in turn allows us to use a loop across each side to implement several things which are currently open coded to do equivalent things for each side in turn. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
This commit is contained in:
parent
5235c47c79
commit
66a02c9f7c
2 changed files with 35 additions and 42 deletions
15
tcp_conn.h
15
tcp_conn.h
|
@ -129,19 +129,14 @@ struct tcp_splice_conn {
|
|||
#define SPLICE_CLOSED 0
|
||||
#define SPLICE_CONNECT BIT(0)
|
||||
#define SPLICE_ESTABLISHED BIT(1)
|
||||
#define OUT_WAIT_0 BIT(2)
|
||||
#define OUT_WAIT_1 BIT(3)
|
||||
#define FIN_RCVD_0 BIT(4)
|
||||
#define FIN_RCVD_1 BIT(5)
|
||||
#define FIN_SENT_0 BIT(6)
|
||||
#define FIN_SENT_1 BIT(7)
|
||||
#define OUT_WAIT(sidei_) ((sidei_) ? BIT(3) : BIT(2))
|
||||
#define FIN_RCVD(sidei_) ((sidei_) ? BIT(5) : BIT(4))
|
||||
#define FIN_SENT(sidei_) ((sidei_) ? BIT(7) : BIT(6))
|
||||
|
||||
uint8_t flags;
|
||||
#define SPLICE_V6 BIT(0)
|
||||
#define RCVLOWAT_SET_0 BIT(1)
|
||||
#define RCVLOWAT_SET_1 BIT(2)
|
||||
#define RCVLOWAT_ACT_0 BIT(3)
|
||||
#define RCVLOWAT_ACT_1 BIT(4)
|
||||
#define RCVLOWAT_SET(sidei_) ((sidei_) ? BIT(2) : BIT(1))
|
||||
#define RCVLOWAT_ACT(sidei_) ((sidei_) ? BIT(4) : BIT(3))
|
||||
#define CLOSING BIT(5)
|
||||
|
||||
uint32_t read[SIDES];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue