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

Maintain unicast Hello history.

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