mirror of
https://github.com/ntop/n2n.git
synced 2024-09-20 00:51:10 +02:00
Revert "fix supernode coredump when accessing management socket"
This reverts commit 66d73b0713
.
This commit is contained in:
parent
66d73b0713
commit
ee46e3e86b
|
@ -99,8 +99,6 @@
|
||||||
#include <immintrin.h>
|
#include <immintrin.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define SAFE_SNPRINTF(BUF, SIZE, FORMAT, ...) (ssize_t)(SIZE) > 0 ? snprintf(BUF, SIZE, FORMAT, ##__VA_ARGS__) : 0
|
|
||||||
|
|
||||||
#define ETH_ADDR_LEN 6
|
#define ETH_ADDR_LEN 6
|
||||||
|
|
||||||
struct ether_hdr
|
struct ether_hdr
|
||||||
|
|
|
@ -302,10 +302,10 @@ static int process_mgmt(n2n_sn_t *sss,
|
||||||
|
|
||||||
traceEvent(TRACE_DEBUG, "process_mgmt");
|
traceEvent(TRACE_DEBUG, "process_mgmt");
|
||||||
|
|
||||||
ressize += SAFE_SNPRINTF(resbuf + ressize, N2N_SN_PKTBUF_SIZE - ressize,
|
ressize += snprintf(resbuf + ressize, N2N_SN_PKTBUF_SIZE - ressize,
|
||||||
"----------------\n");
|
"----------------\n");
|
||||||
|
|
||||||
ressize += SAFE_SNPRINTF(resbuf + ressize, N2N_SN_PKTBUF_SIZE - ressize,
|
ressize += snprintf(resbuf + ressize, N2N_SN_PKTBUF_SIZE - ressize,
|
||||||
"uptime %lu\n", (now - sss->start_time));
|
"uptime %lu\n", (now - sss->start_time));
|
||||||
|
|
||||||
HASH_ITER(hh, sss->communities, community, tmp)
|
HASH_ITER(hh, sss->communities, community, tmp)
|
||||||
|
@ -313,54 +313,54 @@ static int process_mgmt(n2n_sn_t *sss,
|
||||||
num_edges += HASH_COUNT(community->edges);
|
num_edges += HASH_COUNT(community->edges);
|
||||||
}
|
}
|
||||||
|
|
||||||
ressize += SAFE_SNPRINTF(resbuf + ressize, N2N_SN_PKTBUF_SIZE - ressize,
|
ressize += snprintf(resbuf + ressize, N2N_SN_PKTBUF_SIZE - ressize,
|
||||||
"edges %u\n",
|
"edges %u\n",
|
||||||
num_edges);
|
num_edges);
|
||||||
|
|
||||||
ressize += SAFE_SNPRINTF(resbuf + ressize, N2N_SN_PKTBUF_SIZE - ressize,
|
ressize += snprintf(resbuf + ressize, N2N_SN_PKTBUF_SIZE - ressize,
|
||||||
"errors %u\n",
|
"errors %u\n",
|
||||||
(unsigned int)sss->stats.errors);
|
(unsigned int)sss->stats.errors);
|
||||||
|
|
||||||
ressize += SAFE_SNPRINTF(resbuf + ressize, N2N_SN_PKTBUF_SIZE - ressize,
|
ressize += snprintf(resbuf + ressize, N2N_SN_PKTBUF_SIZE - ressize,
|
||||||
"reg_sup %u\n",
|
"reg_sup %u\n",
|
||||||
(unsigned int)sss->stats.reg_super);
|
(unsigned int)sss->stats.reg_super);
|
||||||
|
|
||||||
ressize += SAFE_SNPRINTF(resbuf + ressize, N2N_SN_PKTBUF_SIZE - ressize,
|
ressize += snprintf(resbuf + ressize, N2N_SN_PKTBUF_SIZE - ressize,
|
||||||
"reg_nak %u\n",
|
"reg_nak %u\n",
|
||||||
(unsigned int)sss->stats.reg_super_nak);
|
(unsigned int)sss->stats.reg_super_nak);
|
||||||
|
|
||||||
ressize += SAFE_SNPRINTF(resbuf + ressize, N2N_SN_PKTBUF_SIZE - ressize,
|
ressize += snprintf(resbuf + ressize, N2N_SN_PKTBUF_SIZE - ressize,
|
||||||
"fwd %u\n",
|
"fwd %u\n",
|
||||||
(unsigned int)sss->stats.fwd);
|
(unsigned int)sss->stats.fwd);
|
||||||
|
|
||||||
ressize += SAFE_SNPRINTF(resbuf + ressize, N2N_SN_PKTBUF_SIZE - ressize,
|
ressize += snprintf(resbuf + ressize, N2N_SN_PKTBUF_SIZE - ressize,
|
||||||
"broadcast %u\n",
|
"broadcast %u\n",
|
||||||
(unsigned int)sss->stats.broadcast);
|
(unsigned int)sss->stats.broadcast);
|
||||||
|
|
||||||
ressize += SAFE_SNPRINTF(resbuf + ressize, N2N_SN_PKTBUF_SIZE - ressize,
|
ressize += snprintf(resbuf + ressize, N2N_SN_PKTBUF_SIZE - ressize,
|
||||||
"last fwd %lu sec ago\n",
|
"last fwd %lu sec ago\n",
|
||||||
(long unsigned int)(now - sss->stats.last_fwd));
|
(long unsigned int)(now - sss->stats.last_fwd));
|
||||||
|
|
||||||
ressize += SAFE_SNPRINTF(resbuf + ressize, N2N_SN_PKTBUF_SIZE - ressize,
|
ressize += snprintf(resbuf + ressize, N2N_SN_PKTBUF_SIZE - ressize,
|
||||||
"last reg %lu sec ago\n",
|
"last reg %lu sec ago\n",
|
||||||
(long unsigned int)(now - sss->stats.last_reg_super));
|
(long unsigned int)(now - sss->stats.last_reg_super));
|
||||||
|
|
||||||
ressize += SAFE_SNPRINTF(resbuf+ressize, N2N_SN_PKTBUF_SIZE-ressize,
|
ressize += snprintf(resbuf+ressize, N2N_SN_PKTBUF_SIZE-ressize,
|
||||||
"cur_cmnts");
|
"cur_cmnts");
|
||||||
HASH_ITER(hh, sss->communities, community, tmp) {
|
HASH_ITER(hh, sss->communities, community, tmp) {
|
||||||
ressize += SAFE_SNPRINTF(resbuf+ressize, N2N_SN_PKTBUF_SIZE-ressize,
|
ressize += snprintf(resbuf+ressize, N2N_SN_PKTBUF_SIZE-ressize,
|
||||||
" [%s]",
|
" [%s]",
|
||||||
community->community);
|
community->community);
|
||||||
HASH_ITER(hh, community->edges, peer, tmpPeer) {
|
HASH_ITER(hh, community->edges, peer, tmpPeer) {
|
||||||
ressize += SAFE_SNPRINTF(resbuf+ressize, N2N_SN_PKTBUF_SIZE-ressize,
|
ressize += snprintf(resbuf+ressize, N2N_SN_PKTBUF_SIZE-ressize,
|
||||||
" {%s}",
|
" {%s}",
|
||||||
macaddr_str(mac_buf, peer->mac_addr));
|
macaddr_str(mac_buf, peer->mac_addr));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ressize += SAFE_SNPRINTF(resbuf+ressize, N2N_SN_PKTBUF_SIZE-ressize,
|
ressize += snprintf(resbuf+ressize, N2N_SN_PKTBUF_SIZE-ressize,
|
||||||
"\n");
|
"\n");
|
||||||
|
|
||||||
r = sendto(sss->mgmt_sock, resbuf, MIN(ressize, N2N_SN_PKTBUF_SIZE), 0 /*flags*/,
|
r = sendto(sss->mgmt_sock, resbuf, ressize, 0 /*flags*/,
|
||||||
(struct sockaddr *)sender_sock, sizeof(struct sockaddr_in));
|
(struct sockaddr *)sender_sock, sizeof(struct sockaddr_in));
|
||||||
|
|
||||||
if (r <= 0)
|
if (r <= 0)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user