Skip to content

Commit e520af4

Browse files
edumazetdavem330
authored andcommitted
tcp: add TCPWinProbe and TCPKeepAlive SNMP counters
Diagnosing problems related to Window Probes has been hard because we lack a counter. TCPWinProbe counts the number of ACK packets a sender has to send at regular intervals to make sure a reverse ACK packet opening back a window had not been lost. TCPKeepAlive counts the number of ACK packets sent to keep TCP flows alive (SO_KEEPALIVE) Signed-off-by: Eric Dumazet <[email protected]> Signed-off-by: Yuchung Cheng <[email protected]> Acked-by: Neal Cardwell <[email protected]> Acked-by: Nandita Dukkipati <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 21c8fe9 commit e520af4

File tree

5 files changed

+13
-8
lines changed

5 files changed

+13
-8
lines changed

include/net/tcp.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ int tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int, gfp_t);
527527

528528
void tcp_send_probe0(struct sock *);
529529
void tcp_send_partial(struct sock *);
530-
int tcp_write_wakeup(struct sock *);
530+
int tcp_write_wakeup(struct sock *, int mib);
531531
void tcp_send_fin(struct sock *sk);
532532
void tcp_send_active_reset(struct sock *sk, gfp_t priority);
533533
int tcp_send_synack(struct sock *);

include/uapi/linux/snmp.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,8 @@ enum
276276
LINUX_MIB_TCPACKSKIPPEDFINWAIT2, /* TCPACKSkippedFinWait2 */
277277
LINUX_MIB_TCPACKSKIPPEDTIMEWAIT, /* TCPACKSkippedTimeWait */
278278
LINUX_MIB_TCPACKSKIPPEDCHALLENGE, /* TCPACKSkippedChallenge */
279+
LINUX_MIB_TCPWINPROBE, /* TCPWinProbe */
280+
LINUX_MIB_TCPKEEPALIVE, /* TCPKeepAlive */
279281
__LINUX_MIB_MAX
280282
};
281283

net/ipv4/proc.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,8 @@ static const struct snmp_mib snmp4_net_list[] = {
298298
SNMP_MIB_ITEM("TCPACKSkippedFinWait2", LINUX_MIB_TCPACKSKIPPEDFINWAIT2),
299299
SNMP_MIB_ITEM("TCPACKSkippedTimeWait", LINUX_MIB_TCPACKSKIPPEDTIMEWAIT),
300300
SNMP_MIB_ITEM("TCPACKSkippedChallenge", LINUX_MIB_TCPACKSKIPPEDCHALLENGE),
301+
SNMP_MIB_ITEM("TCPWinProbe", LINUX_MIB_TCPWINPROBE),
302+
SNMP_MIB_ITEM("TCPKeepAlive", LINUX_MIB_TCPKEEPALIVE),
301303
SNMP_MIB_SENTINEL
302304
};
303305

net/ipv4/tcp_output.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3382,7 +3382,7 @@ EXPORT_SYMBOL_GPL(tcp_send_ack);
33823382
* one is with SEG.SEQ=SND.UNA to deliver urgent pointer, another is
33833383
* out-of-date with SND.UNA-1 to probe window.
33843384
*/
3385-
static int tcp_xmit_probe_skb(struct sock *sk, int urgent)
3385+
static int tcp_xmit_probe_skb(struct sock *sk, int urgent, int mib)
33863386
{
33873387
struct tcp_sock *tp = tcp_sk(sk);
33883388
struct sk_buff *skb;
@@ -3400,19 +3400,20 @@ static int tcp_xmit_probe_skb(struct sock *sk, int urgent)
34003400
*/
34013401
tcp_init_nondata_skb(skb, tp->snd_una - !urgent, TCPHDR_ACK);
34023402
skb_mstamp_get(&skb->skb_mstamp);
3403+
NET_INC_STATS_BH(sock_net(sk), mib);
34033404
return tcp_transmit_skb(sk, skb, 0, GFP_ATOMIC);
34043405
}
34053406

34063407
void tcp_send_window_probe(struct sock *sk)
34073408
{
34083409
if (sk->sk_state == TCP_ESTABLISHED) {
34093410
tcp_sk(sk)->snd_wl1 = tcp_sk(sk)->rcv_nxt - 1;
3410-
tcp_xmit_probe_skb(sk, 0);
3411+
tcp_xmit_probe_skb(sk, 0, LINUX_MIB_TCPWINPROBE);
34113412
}
34123413
}
34133414

34143415
/* Initiate keepalive or window probe from timer. */
3415-
int tcp_write_wakeup(struct sock *sk)
3416+
int tcp_write_wakeup(struct sock *sk, int mib)
34163417
{
34173418
struct tcp_sock *tp = tcp_sk(sk);
34183419
struct sk_buff *skb;
@@ -3449,8 +3450,8 @@ int tcp_write_wakeup(struct sock *sk)
34493450
return err;
34503451
} else {
34513452
if (between(tp->snd_up, tp->snd_una + 1, tp->snd_una + 0xFFFF))
3452-
tcp_xmit_probe_skb(sk, 1);
3453-
return tcp_xmit_probe_skb(sk, 0);
3453+
tcp_xmit_probe_skb(sk, 1, mib);
3454+
return tcp_xmit_probe_skb(sk, 0, mib);
34543455
}
34553456
}
34563457

@@ -3464,7 +3465,7 @@ void tcp_send_probe0(struct sock *sk)
34643465
unsigned long probe_max;
34653466
int err;
34663467

3467-
err = tcp_write_wakeup(sk);
3468+
err = tcp_write_wakeup(sk, LINUX_MIB_TCPWINPROBE);
34683469

34693470
if (tp->packets_out || !tcp_send_head(sk)) {
34703471
/* Cancel probe timer, if it is not required. */

net/ipv4/tcp_timer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,7 @@ static void tcp_keepalive_timer (unsigned long data)
616616
tcp_write_err(sk);
617617
goto out;
618618
}
619-
if (tcp_write_wakeup(sk) <= 0) {
619+
if (tcp_write_wakeup(sk, LINUX_MIB_TCPKEEPALIVE) <= 0) {
620620
icsk->icsk_probes_out++;
621621
elapsed = keepalive_intvl_when(tp);
622622
} else {

0 commit comments

Comments
 (0)