mirror of
https://github.com/ntop/n2n.git
synced 2024-09-19 16:41:11 +02:00
limited federation broadcast to active supernodes only (#958)
This commit is contained in:
parent
a271dc7039
commit
cbad152994
|
@ -592,7 +592,8 @@ static int try_broadcast (n2n_sn_t * sss,
|
||||||
const n2n_mac_t srcMac,
|
const n2n_mac_t srcMac,
|
||||||
uint8_t from_supernode,
|
uint8_t from_supernode,
|
||||||
const uint8_t * pktbuf,
|
const uint8_t * pktbuf,
|
||||||
size_t pktsize) {
|
size_t pktsize,
|
||||||
|
time_t now) {
|
||||||
|
|
||||||
struct peer_info *scan, *tmp;
|
struct peer_info *scan, *tmp;
|
||||||
macstr_t mac_buf;
|
macstr_t mac_buf;
|
||||||
|
@ -609,6 +610,9 @@ static int try_broadcast (n2n_sn_t * sss,
|
||||||
HASH_ITER(hh, sss->federation->edges, scan, tmp) {
|
HASH_ITER(hh, sss->federation->edges, scan, tmp) {
|
||||||
int data_sent_len;
|
int data_sent_len;
|
||||||
|
|
||||||
|
// only forward to active supernodes
|
||||||
|
if(scan->last_seen + LAST_SEEN_SN_INACTIVE > now) {
|
||||||
|
|
||||||
data_sent_len = sendto_peer(sss, scan, pktbuf, pktsize);
|
data_sent_len = sendto_peer(sss, scan, pktbuf, pktsize);
|
||||||
|
|
||||||
if(data_sent_len != pktsize) {
|
if(data_sent_len != pktsize) {
|
||||||
|
@ -627,6 +631,7 @@ static int try_broadcast (n2n_sn_t * sss,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(comm) {
|
if(comm) {
|
||||||
HASH_ITER(hh, comm->edges, scan, tmp) {
|
HASH_ITER(hh, comm->edges, scan, tmp) {
|
||||||
|
@ -664,7 +669,8 @@ static int try_forward (n2n_sn_t * sss,
|
||||||
const n2n_mac_t dstMac,
|
const n2n_mac_t dstMac,
|
||||||
uint8_t from_supernode,
|
uint8_t from_supernode,
|
||||||
const uint8_t * pktbuf,
|
const uint8_t * pktbuf,
|
||||||
size_t pktsize) {
|
size_t pktsize,
|
||||||
|
time_t now) {
|
||||||
|
|
||||||
struct peer_info * scan;
|
struct peer_info * scan;
|
||||||
node_supernode_association_t *assoc;
|
node_supernode_association_t *assoc;
|
||||||
|
@ -704,7 +710,7 @@ static int try_forward (n2n_sn_t * sss,
|
||||||
} else {
|
} else {
|
||||||
// forwarding packet to all federated supernodes
|
// forwarding packet to all federated supernodes
|
||||||
traceEvent(TRACE_DEBUG, "unknown mac address, broadcasting packet to all federated supernodes");
|
traceEvent(TRACE_DEBUG, "unknown mac address, broadcasting packet to all federated supernodes");
|
||||||
try_broadcast(sss, NULL, cmn, sss->mac_addr, from_supernode, pktbuf, pktsize);
|
try_broadcast(sss, NULL, cmn, sss->mac_addr, from_supernode, pktbuf, pktsize, now);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
traceEvent(TRACE_DEBUG, "unknown mac address in packet from a supernode, dropping the packet");
|
traceEvent(TRACE_DEBUG, "unknown mac address in packet from a supernode, dropping the packet");
|
||||||
|
@ -1918,9 +1924,9 @@ static int process_udp (n2n_sn_t * sss,
|
||||||
|
|
||||||
/* Common section to forward the final product. */
|
/* Common section to forward the final product. */
|
||||||
if(unicast) {
|
if(unicast) {
|
||||||
try_forward(sss, comm, &cmn, pkt.dstMac, from_supernode, rec_buf, encx);
|
try_forward(sss, comm, &cmn, pkt.dstMac, from_supernode, rec_buf, encx, now);
|
||||||
} else {
|
} else {
|
||||||
try_broadcast(sss, comm, &cmn, pkt.srcMac, from_supernode, rec_buf, encx);
|
try_broadcast(sss, comm, &cmn, pkt.srcMac, from_supernode, rec_buf, encx, now);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1986,7 +1992,7 @@ static int process_udp (n2n_sn_t * sss,
|
||||||
comm->header_encryption_ctx_dynamic, comm->header_iv_ctx_dynamic,
|
comm->header_encryption_ctx_dynamic, comm->header_iv_ctx_dynamic,
|
||||||
time_stamp());
|
time_stamp());
|
||||||
}
|
}
|
||||||
try_forward(sss, comm, &cmn, reg.dstMac, from_supernode, rec_buf, encx); /* unicast only */
|
try_forward(sss, comm, &cmn, reg.dstMac, from_supernode, rec_buf, encx, now); /* unicast only */
|
||||||
} else {
|
} else {
|
||||||
traceEvent(TRACE_ERROR, "Rx REGISTER with multicast destination");
|
traceEvent(TRACE_ERROR, "Rx REGISTER with multicast destination");
|
||||||
}
|
}
|
||||||
|
@ -2225,7 +2231,7 @@ static int process_udp (n2n_sn_t * sss,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try_broadcast(sss, NULL, &cmn, reg.edgeMac, from_supernode, ackbuf, encx);
|
try_broadcast(sss, NULL, &cmn, reg.edgeMac, from_supernode, ackbuf, encx, now);
|
||||||
}
|
}
|
||||||
|
|
||||||
// dynamic key time handling if appropriate
|
// dynamic key time handling if appropriate
|
||||||
|
@ -2641,7 +2647,7 @@ static int process_udp (n2n_sn_t * sss,
|
||||||
time_stamp());
|
time_stamp());
|
||||||
}
|
}
|
||||||
|
|
||||||
try_broadcast(sss, NULL, &cmn, query.srcMac, from_supernode, encbuf, encx);
|
try_broadcast(sss, NULL, &cmn, query.srcMac, from_supernode, encbuf, encx, now);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user