Skip to content

Commit 7970ddc

Browse files
edumazetdavem330
authored andcommitted
tcp: uninline tcp_oow_rate_limited()
tcp_oow_rate_limited() is hardly used in fast path, there is no point inlining it. Signed-of-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 1bfc443 commit 7970ddc

File tree

2 files changed

+32
-30
lines changed

2 files changed

+32
-30
lines changed

include/net/tcp.h

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1216,36 +1216,8 @@ static inline bool tcp_paws_reject(const struct tcp_options_received *rx_opt,
12161216
return true;
12171217
}
12181218

1219-
/* Return true if we're currently rate-limiting out-of-window ACKs and
1220-
* thus shouldn't send a dupack right now. We rate-limit dupacks in
1221-
* response to out-of-window SYNs or ACKs to mitigate ACK loops or DoS
1222-
* attacks that send repeated SYNs or ACKs for the same connection. To
1223-
* do this, we do not send a duplicate SYNACK or ACK if the remote
1224-
* endpoint is sending out-of-window SYNs or pure ACKs at a high rate.
1225-
*/
1226-
static inline bool tcp_oow_rate_limited(struct net *net,
1227-
const struct sk_buff *skb,
1228-
int mib_idx, u32 *last_oow_ack_time)
1229-
{
1230-
/* Data packets without SYNs are not likely part of an ACK loop. */
1231-
if ((TCP_SKB_CB(skb)->seq != TCP_SKB_CB(skb)->end_seq) &&
1232-
!tcp_hdr(skb)->syn)
1233-
goto not_rate_limited;
1234-
1235-
if (*last_oow_ack_time) {
1236-
s32 elapsed = (s32)(tcp_time_stamp - *last_oow_ack_time);
1237-
1238-
if (0 <= elapsed && elapsed < sysctl_tcp_invalid_ratelimit) {
1239-
NET_INC_STATS_BH(net, mib_idx);
1240-
return true; /* rate-limited: don't send yet! */
1241-
}
1242-
}
1243-
1244-
*last_oow_ack_time = tcp_time_stamp;
1245-
1246-
not_rate_limited:
1247-
return false; /* not rate-limited: go ahead, send dupack now! */
1248-
}
1219+
bool tcp_oow_rate_limited(struct net *net, const struct sk_buff *skb,
1220+
int mib_idx, u32 *last_oow_ack_time);
12491221

12501222
static inline void tcp_mib_init(struct net *net)
12511223
{

net/ipv4/tcp_input.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3321,6 +3321,36 @@ static int tcp_ack_update_window(struct sock *sk, const struct sk_buff *skb, u32
33213321
return flag;
33223322
}
33233323

3324+
/* Return true if we're currently rate-limiting out-of-window ACKs and
3325+
* thus shouldn't send a dupack right now. We rate-limit dupacks in
3326+
* response to out-of-window SYNs or ACKs to mitigate ACK loops or DoS
3327+
* attacks that send repeated SYNs or ACKs for the same connection. To
3328+
* do this, we do not send a duplicate SYNACK or ACK if the remote
3329+
* endpoint is sending out-of-window SYNs or pure ACKs at a high rate.
3330+
*/
3331+
bool tcp_oow_rate_limited(struct net *net, const struct sk_buff *skb,
3332+
int mib_idx, u32 *last_oow_ack_time)
3333+
{
3334+
/* Data packets without SYNs are not likely part of an ACK loop. */
3335+
if ((TCP_SKB_CB(skb)->seq != TCP_SKB_CB(skb)->end_seq) &&
3336+
!tcp_hdr(skb)->syn)
3337+
goto not_rate_limited;
3338+
3339+
if (*last_oow_ack_time) {
3340+
s32 elapsed = (s32)(tcp_time_stamp - *last_oow_ack_time);
3341+
3342+
if (0 <= elapsed && elapsed < sysctl_tcp_invalid_ratelimit) {
3343+
NET_INC_STATS_BH(net, mib_idx);
3344+
return true; /* rate-limited: don't send yet! */
3345+
}
3346+
}
3347+
3348+
*last_oow_ack_time = tcp_time_stamp;
3349+
3350+
not_rate_limited:
3351+
return false; /* not rate-limited: go ahead, send dupack now! */
3352+
}
3353+
33243354
/* RFC 5961 7 [ACK Throttling] */
33253355
static void tcp_send_challenge_ack(struct sock *sk, const struct sk_buff *skb)
33263356
{

0 commit comments

Comments
 (0)