From c73e59341dde78c84e110f03ed5ada85cb3aaba9 Mon Sep 17 00:00:00 2001 From: Logan oos Even <46396513+Logan007@users.noreply.github.com> Date: Mon, 8 Feb 2021 20:55:11 +0545 Subject: [PATCH] made gratuitous arp being sent at the right time (#635) --- src/edge.c | 3 +-- src/edge_utils.c | 16 ++++++++++------ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/edge.c b/src/edge.c index 5be7cc0..1c61e1c 100644 --- a/src/edge.c +++ b/src/edge.c @@ -950,7 +950,7 @@ int main (int argc, char* argv[]) { runlevel = 2; } - eee->last_sup = 1; /* to prevent gratuitous arp packet */ + eee->last_sup = 0; /* if it wasn't zero yet */ eee->curr_sn = eee->conf.supernodes; while(runlevel < 5) { @@ -1072,7 +1072,6 @@ int main (int argc, char* argv[]) { eee->last_sweep = now_time - SWEEP_TIME + 2 * BOOTSTRAP_TIMEOUT; eee->sn_wait = 1; eee->last_register_req = 0; - eee->last_sup = 0; /* to allow gratuitous arp packet after regular REGISTER_SUPER_ACK */ #ifndef WIN32 if(eee->tuntap_priv_conf.daemon) { diff --git a/src/edge_utils.c b/src/edge_utils.c index b26fd7b..cb2d6fb 100644 --- a/src/edge_utils.c +++ b/src/edge_utils.c @@ -2229,14 +2229,18 @@ void readFromIPSocket (n2n_edge_t * eee, int in_sock) { } } - if(!eee->last_sup) { - // indicates successful connection between the edge and a supernode - traceEvent(TRACE_NORMAL, "[OK] Edge Peer <<< ================ >>> Super Node"); - // send gratuitous ARP only upon first registration with supernode - send_grat_arps(eee); + // update last_sup only on 'real' REGISTER_SUPER_ACKs, not on bootstrap ones (null_mac) + // this allows reliable in/out PACKET drop if not really registered with a supernode yet + if(!is_null_mac(ra.edgeMac)) { + if(!eee->last_sup) { + // indicates successful connection between the edge and a supernode + traceEvent(TRACE_NORMAL, "[OK] Edge Peer <<< ================ >>> Super Node"); + // send gratuitous ARP only upon first registration with supernode + send_grat_arps(eee); + } + eee->last_sup = now; } - eee->last_sup = now; eee->sn_wait = 0; eee->sup_attempts = N2N_EDGE_SUP_ATTEMPTS; /* refresh because we got a response */