Skip to content

Commit e34100c

Browse files
edumazetkuba-moo
authored andcommitted
tcp: add a drop_reason pointer to tcp_check_req()
We want to add new drop reasons for packets dropped in 3WHS in the following patches. tcp_rcv_state_process() has to set reason to TCP_FASTOPEN, because tcp_check_req() will conditionally overwrite the drop_reason. Signed-off-by: Eric Dumazet <[email protected]> Reviewed-by: Jason Xing <[email protected]> Reviewed-by: Kuniyuki Iwashima <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 3424291 commit e34100c

File tree

5 files changed

+9
-7
lines changed

5 files changed

+9
-7
lines changed

include/net/tcp.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ enum tcp_tw_status tcp_timewait_state_process(struct inet_timewait_sock *tw,
392392
u32 *tw_isn);
393393
struct sock *tcp_check_req(struct sock *sk, struct sk_buff *skb,
394394
struct request_sock *req, bool fastopen,
395-
bool *lost_race);
395+
bool *lost_race, enum skb_drop_reason *drop_reason);
396396
enum skb_drop_reason tcp_child_process(struct sock *parent, struct sock *child,
397397
struct sk_buff *skb);
398398
void tcp_enter_loss(struct sock *sk);

net/ipv4/tcp_input.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6812,10 +6812,9 @@ tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb)
68126812
WARN_ON_ONCE(sk->sk_state != TCP_SYN_RECV &&
68136813
sk->sk_state != TCP_FIN_WAIT1);
68146814

6815-
if (!tcp_check_req(sk, skb, req, true, &req_stolen)) {
6816-
SKB_DR_SET(reason, TCP_FASTOPEN);
6815+
SKB_DR_SET(reason, TCP_FASTOPEN);
6816+
if (!tcp_check_req(sk, skb, req, true, &req_stolen, &reason))
68176817
goto discard;
6818-
}
68196818
}
68206819

68216820
if (!th->ack && !th->rst && !th->syn) {

net/ipv4/tcp_ipv4.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2265,7 +2265,8 @@ int tcp_v4_rcv(struct sk_buff *skb)
22652265
th = (const struct tcphdr *)skb->data;
22662266
iph = ip_hdr(skb);
22672267
tcp_v4_fill_cb(skb, iph, th);
2268-
nsk = tcp_check_req(sk, skb, req, false, &req_stolen);
2268+
nsk = tcp_check_req(sk, skb, req, false, &req_stolen,
2269+
&drop_reason);
22692270
} else {
22702271
drop_reason = SKB_DROP_REASON_SOCKET_FILTER;
22712272
}

net/ipv4/tcp_minisocks.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,8 @@ EXPORT_SYMBOL(tcp_create_openreq_child);
657657

658658
struct sock *tcp_check_req(struct sock *sk, struct sk_buff *skb,
659659
struct request_sock *req,
660-
bool fastopen, bool *req_stolen)
660+
bool fastopen, bool *req_stolen,
661+
enum skb_drop_reason *drop_reason)
661662
{
662663
struct tcp_options_received tmp_opt;
663664
struct sock *child;

net/ipv6/tcp_ipv6.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1828,7 +1828,8 @@ INDIRECT_CALLABLE_SCOPE int tcp_v6_rcv(struct sk_buff *skb)
18281828
th = (const struct tcphdr *)skb->data;
18291829
hdr = ipv6_hdr(skb);
18301830
tcp_v6_fill_cb(skb, hdr, th);
1831-
nsk = tcp_check_req(sk, skb, req, false, &req_stolen);
1831+
nsk = tcp_check_req(sk, skb, req, false, &req_stolen,
1832+
&drop_reason);
18321833
} else {
18331834
drop_reason = SKB_DROP_REASON_SOCKET_FILTER;
18341835
}

0 commit comments

Comments
 (0)