@@ -1693,6 +1693,7 @@ int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb)
goto discard;
if (nsk != sk) {
if (tcp_child_process(sk, nsk, skb)) {
+ reason = TCP_SKB_CB(skb)->drop_reason;
rsk = nsk;
goto reset;
}
@@ -1702,6 +1703,7 @@ int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb)
sock_rps_save_rxhash(sk, skb);
if (tcp_rcv_state_process(sk, skb)) {
+ reason = TCP_SKB_CB(skb)->drop_reason;
rsk = sk;
goto reset;
}
@@ -1945,6 +1947,7 @@ int tcp_v4_rcv(struct sk_buff *skb)
int ret;
drop_reason = SKB_DROP_REASON_NOT_SPECIFIED;
+ TCP_SKB_DR(skb, NOT_SPECIFIED);
if (skb->pkt_type != PACKET_HOST)
goto discard_it;
@@ -2050,6 +2053,7 @@ int tcp_v4_rcv(struct sk_buff *skb)
reqsk_put(req);
tcp_v4_restore_cb(skb);
} else if (tcp_child_process(sk, nsk, skb)) {
+ drop_reason = TCP_SKB_CB(skb)->drop_reason;
tcp_v4_send_reset(nsk, skb);
goto discard_and_relse;
} else {
@@ -2136,6 +2140,11 @@ int tcp_v4_rcv(struct sk_buff *skb)
kfree_skb_reason(skb, drop_reason);
return 0;
+free_it:
+ drop_reason = TCP_SKB_CB(skb)->drop_reason;
+ try_kfree_skb(skb, drop_reason);
+ return 0;
+
discard_and_relse:
sk_drops_add(sk, skb);
if (refcounted)
@@ -2171,6 +2180,8 @@ int tcp_v4_rcv(struct sk_buff *skb)
refcounted = false;
goto process;
}
+ /* TCP_FLAGS or NO_SOCKET? */
+ TCP_SKB_DR(skb, TCP_FLAGS);
}
/* to ACK */
fallthrough;
@@ -2180,10 +2191,10 @@ int tcp_v4_rcv(struct sk_buff *skb)
case TCP_TW_RST:
tcp_v4_send_reset(sk, skb);
inet_twsk_deschedule_put(inet_twsk(sk));
- goto discard_it;
+ goto free_it;
case TCP_TW_SUCCESS:;
}
- goto discard_it;
+ goto free_it;
}
static struct timewait_sock_ops tcp_timewait_sock_ops = {
@@ -1515,8 +1515,10 @@ int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
goto discard;
if (nsk != sk) {
- if (tcp_child_process(sk, nsk, skb))
+ if (tcp_child_process(sk, nsk, skb)) {
+ reason = TCP_SKB_CB(skb)->drop_reason;
goto reset;
+ }
if (opt_skb)
__kfree_skb(opt_skb);
return 0;
@@ -1524,8 +1526,10 @@ int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
} else
sock_rps_save_rxhash(sk, skb);
- if (tcp_rcv_state_process(sk, skb))
+ if (tcp_rcv_state_process(sk, skb)) {
+ reason = TCP_SKB_CB(skb)->drop_reason;
goto reset;
+ }
if (opt_skb)
goto ipv6_pktoptions;
return 0;
@@ -1615,6 +1619,7 @@ INDIRECT_CALLABLE_SCOPE int tcp_v6_rcv(struct sk_buff *skb)
struct net *net = dev_net(skb->dev);
drop_reason = SKB_DROP_REASON_NOT_SPECIFIED;
+ TCP_SKB_DR(skb, NOT_SPECIFIED);
if (skb->pkt_type != PACKET_HOST)
goto discard_it;
@@ -1711,6 +1716,7 @@ INDIRECT_CALLABLE_SCOPE int tcp_v6_rcv(struct sk_buff *skb)
reqsk_put(req);
tcp_v6_restore_cb(skb);
} else if (tcp_child_process(sk, nsk, skb)) {
+ drop_reason = TCP_SKB_CB(skb)->drop_reason;
tcp_v6_send_reset(nsk, skb);
goto discard_and_relse;
} else {
@@ -1792,6 +1798,11 @@ INDIRECT_CALLABLE_SCOPE int tcp_v6_rcv(struct sk_buff *skb)
kfree_skb_reason(skb, drop_reason);
return 0;
+free_it:
+ drop_reason = TCP_SKB_CB(skb)->drop_reason;
+ try_kfree_skb(skb, drop_reason);
+ return 0;
+
discard_and_relse:
sk_drops_add(sk, skb);
if (refcounted)
@@ -1832,6 +1843,7 @@ INDIRECT_CALLABLE_SCOPE int tcp_v6_rcv(struct sk_buff *skb)
refcounted = false;
goto process;
}
+ TCP_SKB_DR(skb, TCP_FLAGS);
}
/* to ACK */
fallthrough;
@@ -1841,11 +1853,11 @@ INDIRECT_CALLABLE_SCOPE int tcp_v6_rcv(struct sk_buff *skb)
case TCP_TW_RST:
tcp_v6_send_reset(sk, skb);
inet_twsk_deschedule_put(inet_twsk(sk));
- goto discard_it;
+ goto free_it;
case TCP_TW_SUCCESS:
;
}
- goto discard_it;
+ goto free_it;
}
void tcp_v6_early_demux(struct sk_buff *skb)