Use -1 to identify the post-initial MTU discovery state.

This is a minor cosmetic nit to emphasise the distinction between the
initial MTU discovery phase, and the post-initial phase (i.e. maxmtu
checking).

Furthermore, this is an improvement with regard to the DRY (Don't
Repeat Yourself) principle, as the maximum mtuprobes value is only
written once.
This commit is contained in:
Etienne Dechamps 2015-01-01 16:04:08 +00:00
parent df6f678957
commit 5bdc1f2b82

View file

@ -66,7 +66,7 @@ int udp_discovery_timeout = 30;
#define MAX_SEQNO 1073741824 #define MAX_SEQNO 1073741824
static void try_fix_mtu(node_t *n) { static void try_fix_mtu(node_t *n) {
if(n->mtuprobes > 30) if(n->mtuprobes < 0)
return; return;
if(n->mtuprobes == 30 || n->minmtu >= n->maxmtu) { if(n->mtuprobes == 30 || n->minmtu >= n->maxmtu) {
@ -76,7 +76,7 @@ static void try_fix_mtu(node_t *n) {
n->maxmtu = n->minmtu; n->maxmtu = n->minmtu;
n->mtu = n->minmtu; n->mtu = n->minmtu;
logger(DEBUG_TRAFFIC, LOG_INFO, "Fixing MTU of %s (%s) to %d after %d probes", n->name, n->hostname, n->mtu, n->mtuprobes); logger(DEBUG_TRAFFIC, LOG_INFO, "Fixing MTU of %s (%s) to %d after %d probes", n->name, n->hostname, n->mtu, n->mtuprobes);
n->mtuprobes = 31; n->mtuprobes = -1;
} }
} }
@ -904,14 +904,14 @@ static void try_mtu(node_t *n) {
} }
/* mtuprobes == 0..29: initial discovery, send bursts with 1 second interval, mtuprobes++ /* mtuprobes == 0..29: initial discovery, send bursts with 1 second interval, mtuprobes++
mtuprobes == 30: fix MTU, and go to 31 mtuprobes == 30: fix MTU, and go to -1
mtuprobes == 31: send one >maxmtu probe every pingtimeout */ mtuprobes == -1: send one >maxmtu probe every pingtimeout */
struct timeval now; struct timeval now;
gettimeofday(&now, NULL); gettimeofday(&now, NULL);
struct timeval elapsed; struct timeval elapsed;
timersub(&now, &n->probe_sent_time, &elapsed); timersub(&now, &n->probe_sent_time, &elapsed);
if(n->mtuprobes < 31) { if(n->mtuprobes >= 0) {
if(n->mtuprobes != 0 && elapsed.tv_sec < 1) if(n->mtuprobes != 0 && elapsed.tv_sec < 1)
return; return;
} else { } else {
@ -922,7 +922,7 @@ static void try_mtu(node_t *n) {
try_fix_mtu(n); try_fix_mtu(n);
int timeout; int timeout;
if(n->mtuprobes == 31) { if(n->mtuprobes < 0) {
/* After the initial discovery, we only send one >maxmtu probe /* After the initial discovery, we only send one >maxmtu probe
to detect PMTU increases. */ to detect PMTU increases. */
if(n->maxmtu + 8 < MTU) if(n->maxmtu + 8 < MTU)