Skip to content

Commit

Permalink
Fix retractions with no router-id.
Browse files Browse the repository at this point in the history
Thanks to Fabian Blaese.
  • Loading branch information
jech committed Dec 20, 2020
1 parent f9698a5 commit d3734a1
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
5 changes: 3 additions & 2 deletions message.c
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,7 @@ parse_packet(const unsigned char *from, struct interface *ifp,
}
have_router_id = 1;
}
if(!have_router_id && message[2] != 0) {
if(metric < INFINITY && !have_router_id && message[2] != 0) {
fprintf(stderr, "Received prefix with no router id.\n");
goto fail;
}
Expand Down Expand Up @@ -773,7 +773,8 @@ parse_packet(const unsigned char *from, struct interface *ifp,
goto done;
}

update_route(router_id, prefix, plen, src_prefix, src_plen, seqno,
update_route(have_router_id ? router_id : NULL,
prefix, plen, src_prefix, src_plen, seqno,
metric, interval, neigh, nh,
channels, channels_len);
} else if(type == MESSAGE_REQUEST) {
Expand Down
24 changes: 22 additions & 2 deletions route.c
Original file line number Diff line number Diff line change
Expand Up @@ -877,8 +877,15 @@ update_route(const unsigned char *id,
int add_metric;
int hold_time = MAX((4 * interval) / 100 + interval / 50, 15);
int is_v4;
if(memcmp(id, myid, 8) == 0)

if(!id) {
if(refmetric < INFINITY) {
fprintf(stderr, "Update with no id and finite metric.");
return NULL;
}
} else if(memcmp(id, myid, 8) == 0) {
return NULL;
}

if(martian_prefix(prefix, plen) || martian_prefix(src_prefix, src_plen)) {
fprintf(stderr, "Rejecting martian route to %s from %s through %s.\n",
Expand All @@ -898,6 +905,19 @@ update_route(const unsigned char *id,

route = find_route(prefix, plen, src_prefix, src_plen, neigh, nexthop);

if(refmetric >= INFINITY && !route) {
/* Somebody's retracting a route that we've never seen. */
return NULL;
} else if(!id) {
/* Pretend the retraction came from the currently installed source. */
id = route->src->id;
}

if(!id) {
fprintf(stderr, "No id in update_route -- this shouldn't happen.\n");
return NULL;
}

if(route && memcmp(route->src->id, id, 8) == 0)
/* Avoid scanning the source table. */
src = route->src;
Expand All @@ -919,7 +939,7 @@ update_route(const unsigned char *id,
oldsrc = route->src;
oldmetric = route_metric(route);

/* If a successor switches sources, we must accept his update even
/* If a successor switches sources, we must accept their update even
if it makes a route unfeasible in order to break any routing loops
in a timely manner. If the source remains the same, we ignore
the update. */
Expand Down

0 comments on commit d3734a1

Please sign in to comment.