Use libevent to send MTU probes.
This commit is contained in:
parent
ee7844905f
commit
3321591d93
3 changed files with 11 additions and 14 deletions
|
@ -36,7 +36,6 @@
|
|||
#include "connection.h"
|
||||
#include "device.h"
|
||||
#include "ethernet.h"
|
||||
#include "tevent.h"
|
||||
#include "graph.h"
|
||||
#include "list.h"
|
||||
#include "logger.h"
|
||||
|
@ -61,15 +60,14 @@ static void send_udppacket(node_t *, vpn_packet_t *);
|
|||
|
||||
#define MAX_SEQNO 1073741824
|
||||
|
||||
void send_mtu_probe(node_t *n)
|
||||
{
|
||||
static void send_mtu_probe_handler(int fd, short events, void *data) {
|
||||
node_t *n = data;
|
||||
vpn_packet_t packet;
|
||||
int len, i;
|
||||
|
||||
cp();
|
||||
|
||||
n->mtuprobes++;
|
||||
n->mtuevent = NULL;
|
||||
|
||||
if(n->mtuprobes >= 10 && !n->minmtu) {
|
||||
ifdebug(TRAFFIC) logger(LOG_INFO, _("No response to MTU probes from %s (%s)"), n->name, n->hostname);
|
||||
|
@ -96,11 +94,13 @@ void send_mtu_probe(node_t *n)
|
|||
send_udppacket(n, &packet);
|
||||
}
|
||||
|
||||
n->mtuevent = new_tevent();
|
||||
n->mtuevent->handler = (event_handler_t)send_mtu_probe;
|
||||
n->mtuevent->data = n;
|
||||
n->mtuevent->time = now + 1;
|
||||
tevent_add(n->mtuevent);
|
||||
event_add(&n->mtuevent, &(struct timeval){1, 0});
|
||||
}
|
||||
|
||||
void send_mtu_probe(node_t *n) {
|
||||
if(!n->mtuevent.ev_callback)
|
||||
timeout_set(&n->mtuevent, send_mtu_probe_handler, n);
|
||||
send_mtu_probe_handler(0, 0, n);
|
||||
}
|
||||
|
||||
void mtu_probe_h(node_t *n, vpn_packet_t *packet) {
|
||||
|
|
|
@ -106,10 +106,7 @@ void free_node(node_t *n)
|
|||
|
||||
EVP_CIPHER_CTX_cleanup(&n->packet_ctx);
|
||||
|
||||
if(n->mtuevent) {
|
||||
tevent_del(n->mtuevent);
|
||||
free_tevent(n->mtuevent);
|
||||
}
|
||||
event_del(&n->mtuevent);
|
||||
|
||||
if(n->hostname)
|
||||
free(n->hostname);
|
||||
|
|
|
@ -80,7 +80,7 @@ typedef struct node_t {
|
|||
length_t minmtu; /* Probed minimum MTU */
|
||||
length_t maxmtu; /* Probed maximum MTU */
|
||||
int mtuprobes; /* Number of probes */
|
||||
tevent_t *mtuevent; /* Probe event */
|
||||
struct event mtuevent; /* Probe event */
|
||||
} node_t;
|
||||
|
||||
extern struct node_t *myself;
|
||||
|
|
Loading…
Reference in a new issue