1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
From 4b7b53c8d081a0c12a16e91dbe40cc73eba41a26 Mon Sep 17 00:00:00 2001
From: Mark Vitale <mvitale@sinenomine.net>
Date: Fri, 7 May 2021 18:20:11 -0400
Subject: [PATCH 1/4] rx: Define symbolic names for Rx magic numbers
Since the original IBM code import, the magic number '6' has been used
to specify the number of consecutive lost keepalives (ping acks) that
indicate a dead connection. By implication, this also defines the
minimum number of seconds (at the minimum keeplive periodicity of 1
second) before a connection may be considered dead.
Define and use symbolic names for both uses of '6', and document their
relationship. Both have the same assigned value '6', but
RX_PINGS_LOST_BEFORE_DEAD is use as an ordinal count, while
RX_MINDEADTIME is expressed in units of seconds.
The magic number '12' is used in a couple of places for the default
value of rx_connDeadTime. Give this constant a name
(RX_DEFAULT_DEAD_TIME) and use it.
No functional change is incurred by this commit.
Reviewed-on: https://gerrit.openafs.org/14621
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: Benjamin Kaduk <kaduk@mit.edu>
(cherry picked from commit b4a4a2ae9c9546482dd94c7a89793b1bfa1714cd)
Change-Id: I87c2de0c1a14a9414a86e6fc0744139a120fbab9
---
src/rx/rx.c | 12 ++++++------
src/rx/rx.h | 12 ++++++++++++
src/rx/rx_globals.h | 2 +-
3 files changed, 19 insertions(+), 7 deletions(-)
diff --git a/src/rx/rx.c b/src/rx/rx.c
index d6c52c369..b3cc50c9b 100644
--- a/src/rx/rx.c
+++ b/src/rx/rx.c
@@ -550,7 +550,7 @@ rx_InitHost(u_int host, u_int port)
#endif /* RX_ENABLE_LOCKS && KERNEL */
rxi_nCalls = 0;
- rx_connDeadTime = 12;
+ rx_connDeadTime = RX_DEFAULT_DEAD_TIME;
rx_tranquil = 0; /* reset flag */
rxi_ResetStatistics();
htable = osi_Alloc(rx_hashTableSize * sizeof(struct rx_connection *));
@@ -1118,12 +1118,12 @@ rxi_CheckConnTimeouts(struct rx_connection *conn)
/* a connection's timeouts must have the relationship
* deadTime <= idleDeadTime <= hardDeadTime. Otherwise, for example, a
* total loss of network to a peer may cause an idle timeout instead of a
- * dead timeout, simply because the idle timeout gets hit first. Also set
- * a minimum deadTime of 6, just to ensure it doesn't get set too low. */
+ * dead timeout, simply because the idle timeout gets hit first. Also
+ * enforce a minimum deadTime, just to ensure it doesn't get set too low. */
/* this logic is slightly complicated by the fact that
* idleDeadTime/hardDeadTime may not be set at all, but it's not too bad.
*/
- conn->secondsUntilDead = MAX(conn->secondsUntilDead, 6);
+ conn->secondsUntilDead = MAX(conn->secondsUntilDead, RX_MINDEADTIME);
if (conn->idleDeadTime) {
conn->idleDeadTime = MAX(conn->idleDeadTime, conn->secondsUntilDead);
}
@@ -1143,7 +1143,7 @@ rx_SetConnDeadTime(struct rx_connection *conn, int seconds)
* keepalives to be dropped without timing out the connection. */
conn->secondsUntilDead = seconds;
rxi_CheckConnTimeouts(conn);
- conn->secondsUntilPing = conn->secondsUntilDead / 6;
+ conn->secondsUntilPing = conn->secondsUntilDead / RX_PINGS_LOST_BEFORE_DEAD;
}
void
@@ -6723,7 +6723,7 @@ rxi_ScheduleGrowMTUEvent(struct rx_call *call, int secs)
when = now;
if (!secs) {
if (call->conn->secondsUntilPing)
- secs = (6*call->conn->secondsUntilPing)-1;
+ secs = (RX_PINGS_LOST_BEFORE_DEAD * call->conn->secondsUntilPing)-1;
if (call->conn->secondsUntilDead)
secs = MIN(secs, (call->conn->secondsUntilDead-1));
diff --git a/src/rx/rx.h b/src/rx/rx.h
index ee1331e85..f9a387db6 100644
--- a/src/rx/rx.h
+++ b/src/rx/rx.h
@@ -163,7 +163,19 @@ extern u_short rx_PortOf(struct rx_peer *peer);
/* Configurable parameters */
#define RX_IDLE_DEAD_TIME 60 /* default idle dead time */
+#define RX_DEFAULT_DEAD_TIME 12 /* Default timeout for an unresponsive connection */
#define RX_MAX_SERVICES 20 /* Maximum number of services that may be installed */
+/*
+ * The number of consecutive keepalives (ping acks) that must be lost/missing
+ * before declaring an rx_call dead timeout (RX_CALL_DEAD). This number was
+ * chosen to be relatively small while allowing for "several" pings to be lost
+ * without triggering a timeout. (We are running on UDP after all). Since the
+ * miniumum non-zero secondsUntilPing is 1 second, this also determines the
+ * minimum rx dead time.
+ */
+#define RX_PINGS_LOST_BEFORE_DEAD 6
+#define RX_MINDEADTIME (RX_PINGS_LOST_BEFORE_DEAD * 1)
+
#if defined(KERNEL) && defined(AFS_AIX51_ENV) && defined(__64__)
# define RX_DEFAULT_STACK_SIZE 24000
#else
diff --git a/src/rx/rx_globals.h b/src/rx/rx_globals.h
index caf0d3bc9..558dc553b 100644
--- a/src/rx/rx_globals.h
+++ b/src/rx/rx_globals.h
@@ -65,7 +65,7 @@ EXT int rx_extraPackets GLOBALSINIT(256);
EXT int rx_stackSize GLOBALSINIT(RX_DEFAULT_STACK_SIZE);
/* Time until an unresponsive connection is declared dead */
-EXT int rx_connDeadTime GLOBALSINIT(12);
+EXT int rx_connDeadTime GLOBALSINIT(RX_DEFAULT_DEAD_TIME);
/* Set rx default connection dead time; set on both services and connections at creation time */
#ifdef AFS_NT40_ENV
--
2.46.1
|