tcp: LRO code to deal with all 12 TCP header flags

TCP per RFC793 has 4 reserved flag bits for future use. One
of those bits may be used for Accurate ECN.
This patch is to include these bits in the LRO code to ease
the extensibility if/when these bits are used.

Reviewed By: hselasky, rrs, #transport
Sponsored by:        NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D34127
This commit is contained in:
Richard Scheffenegger 2022-02-01 17:25:49 +01:00
parent 8a67a1a964
commit 93e28d6e89
3 changed files with 16 additions and 15 deletions

View File

@ -55,12 +55,12 @@ struct tcphdr {
tcp_seq th_seq; /* sequence number */
tcp_seq th_ack; /* acknowledgement number */
#if BYTE_ORDER == LITTLE_ENDIAN
u_char th_x2:4, /* (unused) */
u_char th_x2:4, /* upper 4 (reserved) flags */
th_off:4; /* data offset */
#endif
#if BYTE_ORDER == BIG_ENDIAN
u_char th_off:4, /* data offset */
th_x2:4; /* (unused) */
th_x2:4; /* upper 4 (reserved) flags */
#endif
u_char th_flags;
#define TH_FIN 0x01

View File

@ -921,7 +921,7 @@ tcp_set_entry_to_mbuf(struct lro_ctrl *lc, struct lro_entry *le,
le->next_seq = ntohl(th->th_seq) + tcp_data_len;
le->ack_seq = th->th_ack;
le->window = th->th_win;
le->flags = th->th_flags;
le->flags = (th->th_x2 << 8) | th->th_flags;
le->needs_merge = 0;
/* Setup new data pointers. */
@ -1033,7 +1033,7 @@ tcp_lro_condense(struct lro_ctrl *lc, struct lro_entry *le)
tcp_push_and_replace(lc, le, m);
goto again;
}
if ((th->th_flags & ~(TH_ACK | TH_PUSH)) != 0) {
if ((((th->th_x2 << 8) | th->th_flags) & ~(TH_ACK | TH_PUSH)) != 0) {
/*
* Make sure that previously seen segments/ACKs are delivered
* before this segment, e.g. FIN.
@ -1077,7 +1077,7 @@ tcp_lro_condense(struct lro_ctrl *lc, struct lro_entry *le)
tcp_push_and_replace(lc, le, m);
goto again;
}
if ((th->th_flags & ~(TH_ACK | TH_PUSH)) != 0) {
if ((((th->th_x2 << 8) | th->th_flags) & ~(TH_ACK | TH_PUSH)) != 0) {
tcp_push_and_replace(lc, le, m);
goto again;
}
@ -1265,7 +1265,7 @@ tcp_lro_ack_valid(struct mbuf *m, struct tcphdr *th, uint32_t **ppts, bool *othe
break;
}
/* For ACKCMP we only accept ACK, PUSH, ECE and CWR. */
if ((th->th_flags & ~(TH_ACK | TH_PUSH | TH_ECE | TH_CWR)) != 0)
if ((((th->th_x2 << 8) | th->th_flags) & ~(TH_ACK | TH_PUSH | TH_ECE | TH_CWR)) != 0)
ret = false;
/* If it has data on it we cannot compress it */
if (m->m_pkthdr.lro_tcp_d_len)
@ -1576,7 +1576,7 @@ build_ack_entry(struct tcp_ackent *ae, struct tcphdr *th, struct mbuf *m,
ae->flags = TSTMP_HDWR;
ae->seq = ntohl(th->th_seq);
ae->ack = ntohl(th->th_ack);
ae->flags |= th->th_flags;
ae->flags |= (th->th_x2 << 8) | th->th_flags;
if (ts_ptr != NULL) {
ae->ts_value = ntohl(ts_ptr[1]);
ae->ts_echo = ntohl(ts_ptr[2]);

View File

@ -42,20 +42,20 @@
/*
* Flags for ACK entry for compression
* the bottom 8 bits has the th_flags.
* the bottom 12 bits has the th_x2|th_flags.
* LRO itself adds only the TSTMP flags
* to indicate if either of the types
* of timestamps are filled and the
* HAS_TSTMP option to indicate if the
* TCP timestamp option is valid.
*
* The other 5 flag bits are for processing
* The other 1 flag bits are for processing
* by a stack.
*
*/
#define TSTMP_LRO 0x0100
#define TSTMP_HDWR 0x0200
#define HAS_TSTMP 0x0400
#define TSTMP_LRO 0x1000
#define TSTMP_HDWR 0x2000
#define HAS_TSTMP 0x4000
/*
* Default number of interrupts on the same cpu in a row
* that will cause us to declare a "affinity cpu".
@ -146,9 +146,10 @@ struct lro_entry {
uint16_t compressed;
uint16_t uncompressed;
uint16_t window;
uint8_t flags;
uint8_t timestamp : 1;
uint8_t needs_merge : 1;
uint16_t flags : 12, /* 12 TCP header bits */
timestamp : 1,
needs_merge : 1,
reserved : 2; /* unused */
struct bintime alloc_time; /* time when entry was allocated */
};