Commit 643c839c authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Maintain unicast Hello history.

parent 917ea3ee
...@@ -1113,11 +1113,12 @@ dump_tables(FILE *out) ...@@ -1113,11 +1113,12 @@ dump_tables(FILE *out)
fprintf(out, "My id %s seqno %d\n", format_eui64(myid), myseqno); fprintf(out, "My id %s seqno %d\n", format_eui64(myid), myseqno);
FOR_ALL_NEIGHBOURS(neigh) { FOR_ALL_NEIGHBOURS(neigh) {
fprintf(out, "Neighbour %s dev %s reach %04x rxcost %d txcost %d " fprintf(out, "Neighbour %s dev %s reach %04x ureach %04x "
"rtt %s rttcost %d chan %d%s.\n", "rxcost %d txcost %d rtt %s rttcost %d chan %d%s.\n",
format_address(neigh->address), format_address(neigh->address),
neigh->ifp->name, neigh->ifp->name,
neigh->hello.reach, neigh->hello.reach,
neigh->uhello.reach,
neighbour_rxcost(neigh), neighbour_rxcost(neigh),
neigh->txcost, neigh->txcost,
format_thousands(neigh->rtt), format_thousands(neigh->rtt),
......
...@@ -153,7 +153,8 @@ local_notify_neighbour_1(struct local_socket *s, ...@@ -153,7 +153,8 @@ local_notify_neighbour_1(struct local_socket *s,
rc = snprintf(buf, 512, rc = snprintf(buf, 512,
"%s neighbour %lx address %s " "%s neighbour %lx address %s "
"if %s reach %04x rxcost %d txcost %d%s cost %d\n", "if %s reach %04x ureach %04x "
"rxcost %d txcost %d%s cost %d\n",
local_kind(kind), local_kind(kind),
/* Neighbours never move around in memory , so we can use the /* Neighbours never move around in memory , so we can use the
address as a unique identifier. */ address as a unique identifier. */
...@@ -161,6 +162,7 @@ local_notify_neighbour_1(struct local_socket *s, ...@@ -161,6 +162,7 @@ local_notify_neighbour_1(struct local_socket *s,
format_address(neigh->address), format_address(neigh->address),
neigh->ifp->name, neigh->ifp->name,
neigh->hello.reach, neigh->hello.reach,
neigh->uhello.reach,
neighbour_rxcost(neigh), neighbour_rxcost(neigh),
neighbour_txcost(neigh), neighbour_txcost(neigh),
rttbuf, rttbuf,
......
...@@ -425,9 +425,10 @@ parse_packet(const unsigned char *from, struct interface *ifp, ...@@ -425,9 +425,10 @@ parse_packet(const unsigned char *from, struct interface *ifp,
/* Nothing right now */ /* Nothing right now */
} else if(type == MESSAGE_HELLO) { } else if(type == MESSAGE_HELLO) {
unsigned short seqno, interval; unsigned short seqno, interval;
int changed, have_timestamp, rc; int unicast, changed, have_timestamp, rc;
unsigned int timestamp; unsigned int timestamp;
if(len < 6) goto fail; if(len < 6) goto fail;
unicast = !!(message[2] & 0x80);
DO_NTOHS(seqno, message + 4); DO_NTOHS(seqno, message + 4);
DO_NTOHS(interval, message + 6); DO_NTOHS(interval, message + 6);
debugf("Received hello %d (%d) from %s on %s.\n", debugf("Received hello %d (%d) from %s on %s.\n",
...@@ -438,10 +439,10 @@ parse_packet(const unsigned char *from, struct interface *ifp, ...@@ -438,10 +439,10 @@ parse_packet(const unsigned char *from, struct interface *ifp,
&timestamp, &have_timestamp); &timestamp, &have_timestamp);
if(rc < 0) if(rc < 0)
goto done; goto done;
if(message[2] & 0x80) changed =
/* Unicast, ignored for now. */ update_neighbour(neigh,
goto done; unicast ? &neigh->uhello : &neigh->hello,
changed = update_neighbour(neigh, &neigh->hello, seqno, interval); unicast, seqno, interval);
update_neighbour_metric(neigh, changed); update_neighbour_metric(neigh, changed);
if(interval > 0) if(interval > 0)
/* Multiply by 3/2 to allow hellos to expire. */ /* Multiply by 3/2 to allow hellos to expire. */
......
...@@ -90,11 +90,11 @@ find_neighbour(const unsigned char *address, struct interface *ifp) ...@@ -90,11 +90,11 @@ find_neighbour(const unsigned char *address, struct interface *ifp)
return NULL; return NULL;
} }
neigh->hello.seqno = -1; neigh->hello.seqno = neigh->uhello.seqno = -1;
memcpy(neigh->address, address, 16); memcpy(neigh->address, address, 16);
neigh->txcost = INFINITY; neigh->txcost = INFINITY;
neigh->ihu_time = now; neigh->ihu_time = now;
neigh->hello.time = zero; neigh->hello.time = neigh->uhello.time = zero;
neigh->hello_rtt_receive_time = zero; neigh->hello_rtt_receive_time = zero;
neigh->rtt_time = zero; neigh->rtt_time = zero;
neigh->ifp = ifp; neigh->ifp = ifp;
...@@ -109,7 +109,7 @@ find_neighbour(const unsigned char *address, struct interface *ifp) ...@@ -109,7 +109,7 @@ find_neighbour(const unsigned char *address, struct interface *ifp)
This does not call local_notify_neighbour, see update_neighbour_metric. */ This does not call local_notify_neighbour, see update_neighbour_metric. */
int int
update_neighbour(struct neighbour *neigh, struct hello_history *hist, update_neighbour(struct neighbour *neigh, struct hello_history *hist,
int hello, int hello_interval) int unicast, int hello, int hello_interval)
{ {
int missed_hellos; int missed_hellos;
int rc = 0; int rc = 0;
...@@ -163,6 +163,9 @@ update_neighbour(struct neighbour *neigh, struct hello_history *hist, ...@@ -163,6 +163,9 @@ update_neighbour(struct neighbour *neigh, struct hello_history *hist,
rc = 1; rc = 1;
} }
if(unicast)
return rc;
/* Make sure to give neighbours some feedback early after association */ /* Make sure to give neighbours some feedback early after association */
if((hist->reach & 0xBF00) == 0x8000) { if((hist->reach & 0xBF00) == 0x8000) {
/* A new neighbour */ /* A new neighbour */
...@@ -218,14 +221,16 @@ unsigned ...@@ -218,14 +221,16 @@ unsigned
check_neighbours() check_neighbours()
{ {
struct neighbour *neigh; struct neighbour *neigh;
int changed, rc;
unsigned msecs = 50000; unsigned msecs = 50000;
debugf("Checking neighbours.\n"); debugf("Checking neighbours.\n");
neigh = neighs; neigh = neighs;
while(neigh) { while(neigh) {
changed = update_neighbour(neigh, &neigh->hello, -1, 0); int changed, rc;
changed = update_neighbour(neigh, &neigh->hello, 0, -1, 0);
rc = update_neighbour(neigh, &neigh->uhello, 1, -1, 0);
changed = changed || rc;
if(neigh->hello.reach == 0 || if(neigh->hello.reach == 0 ||
neigh->hello.time.tv_sec > now.tv_sec || /* clock stepped */ neigh->hello.time.tv_sec > now.tv_sec || /* clock stepped */
......
...@@ -32,6 +32,7 @@ struct neighbour { ...@@ -32,6 +32,7 @@ struct neighbour {
/* This is -1 when unknown, so don't make it unsigned */ /* This is -1 when unknown, so don't make it unsigned */
unsigned char address[16]; unsigned char address[16];
struct hello_history hello; struct hello_history hello;
struct hello_history uhello; /* for Unicast hellos */
unsigned short txcost; unsigned short txcost;
struct timeval ihu_time; struct timeval ihu_time;
unsigned short ihu_interval; /* in centiseconds */ unsigned short ihu_interval; /* in centiseconds */
...@@ -55,7 +56,7 @@ void flush_neighbour(struct neighbour *neigh); ...@@ -55,7 +56,7 @@ void flush_neighbour(struct neighbour *neigh);
struct neighbour *find_neighbour(const unsigned char *address, struct neighbour *find_neighbour(const unsigned char *address,
struct interface *ifp); struct interface *ifp);
int update_neighbour(struct neighbour *neigh, struct hello_history *hist, int update_neighbour(struct neighbour *neigh, struct hello_history *hist,
int hello, int hello_interval); int unicast, int hello, int hello_interval);
unsigned check_neighbours(void); unsigned check_neighbours(void);
unsigned neighbour_txcost(struct neighbour *neigh); unsigned neighbour_txcost(struct neighbour *neigh);
unsigned neighbour_rxcost(struct neighbour *neigh); unsigned neighbour_rxcost(struct neighbour *neigh);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment