Skip to content

Commit 6dac152

Browse files
Ilya Lesokhindavem330
authored andcommitted
tcp: Add clean acked data hook
Called when a TCP segment is acknowledged. Could be used by application protocols who hold additional metadata associated with the stream data. This is required by TLS device offload to release metadata associated with acknowledged TLS records. Signed-off-by: Ilya Lesokhin <[email protected]> Signed-off-by: Boris Pismenny <[email protected]> Signed-off-by: Aviad Yehezkel <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 1a1f4a2 commit 6dac152

File tree

3 files changed

+35
-0
lines changed

3 files changed

+35
-0
lines changed

include/net/inet_connection_sock.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ struct inet_connection_sock_af_ops {
7777
* @icsk_af_ops Operations which are AF_INET{4,6} specific
7878
* @icsk_ulp_ops Pluggable ULP control hook
7979
* @icsk_ulp_data ULP private data
80+
* @icsk_clean_acked Clean acked data hook
8081
* @icsk_listen_portaddr_node hash to the portaddr listener hashtable
8182
* @icsk_ca_state: Congestion control state
8283
* @icsk_retransmits: Number of unrecovered [RTO] timeouts
@@ -102,6 +103,7 @@ struct inet_connection_sock {
102103
const struct inet_connection_sock_af_ops *icsk_af_ops;
103104
const struct tcp_ulp_ops *icsk_ulp_ops;
104105
void *icsk_ulp_data;
106+
void (*icsk_clean_acked)(struct sock *sk, u32 acked_seq);
105107
struct hlist_node icsk_listen_portaddr_node;
106108
unsigned int (*icsk_sync_mss)(struct sock *sk, u32 pmtu);
107109
__u8 icsk_ca_state:6,

include/net/tcp.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2105,4 +2105,12 @@ static inline bool tcp_bpf_ca_needs_ecn(struct sock *sk)
21052105
#if IS_ENABLED(CONFIG_SMC)
21062106
extern struct static_key_false tcp_have_smc;
21072107
#endif
2108+
2109+
#if IS_ENABLED(CONFIG_TLS_DEVICE)
2110+
void clean_acked_data_enable(struct inet_connection_sock *icsk,
2111+
void (*cad)(struct sock *sk, u32 ack_seq));
2112+
void clean_acked_data_disable(struct inet_connection_sock *icsk);
2113+
2114+
#endif
2115+
21082116
#endif /* _TCP_H */

net/ipv4/tcp_input.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,25 @@ int sysctl_tcp_max_orphans __read_mostly = NR_FILE;
111111
#define REXMIT_LOST 1 /* retransmit packets marked lost */
112112
#define REXMIT_NEW 2 /* FRTO-style transmit of unsent/new packets */
113113

114+
#if IS_ENABLED(CONFIG_TLS_DEVICE)
115+
static DEFINE_STATIC_KEY_FALSE(clean_acked_data_enabled);
116+
117+
void clean_acked_data_enable(struct inet_connection_sock *icsk,
118+
void (*cad)(struct sock *sk, u32 ack_seq))
119+
{
120+
icsk->icsk_clean_acked = cad;
121+
static_branch_inc(&clean_acked_data_enabled);
122+
}
123+
EXPORT_SYMBOL_GPL(clean_acked_data_enable);
124+
125+
void clean_acked_data_disable(struct inet_connection_sock *icsk)
126+
{
127+
static_branch_dec(&clean_acked_data_enabled);
128+
icsk->icsk_clean_acked = NULL;
129+
}
130+
EXPORT_SYMBOL_GPL(clean_acked_data_disable);
131+
#endif
132+
114133
static void tcp_gro_dev_warn(struct sock *sk, const struct sk_buff *skb,
115134
unsigned int len)
116135
{
@@ -3560,6 +3579,12 @@ static int tcp_ack(struct sock *sk, const struct sk_buff *skb, int flag)
35603579
if (after(ack, prior_snd_una)) {
35613580
flag |= FLAG_SND_UNA_ADVANCED;
35623581
icsk->icsk_retransmits = 0;
3582+
3583+
#if IS_ENABLED(CONFIG_TLS_DEVICE)
3584+
if (static_branch_unlikely(&clean_acked_data_enabled))
3585+
if (icsk->icsk_clean_acked)
3586+
icsk->icsk_clean_acked(sk, ack);
3587+
#endif
35633588
}
35643589

35653590
prior_fack = tcp_is_sack(tp) ? tcp_highest_sack_seq(tp) : tp->snd_una;

0 commit comments

Comments
 (0)