mirror of
https://github.com/servalproject/serval-dna.git
synced 2025-04-16 15:09:00 +00:00
Fix next-hop logic for case of no interfaces up
This commit is contained in:
parent
55f22c8cd5
commit
ddc17434c4
@ -654,7 +654,7 @@ void overlay_interface_discover(struct sched_ent *alarm){
|
||||
int detect_real_interfaces = 0;
|
||||
|
||||
/* Mark all UP interfaces as DETECTING, so we can tell which interfaces are new, and which are dead */
|
||||
for(i = 0; i < overlay_interface_count; i++)
|
||||
for (i = 0; i < overlay_interface_count; i++)
|
||||
if (overlay_interfaces[i].state==INTERFACE_STATE_UP)
|
||||
overlay_interfaces[i].state=INTERFACE_STATE_DETECTING;
|
||||
|
||||
@ -665,7 +665,7 @@ void overlay_interface_discover(struct sched_ent *alarm){
|
||||
continue;
|
||||
}
|
||||
|
||||
for(i = 0; i < overlay_interface_count; i++)
|
||||
for (i = 0; i < overlay_interface_count; i++)
|
||||
if (!strcasecmp(overlay_interfaces[i].name,r->namespec)){
|
||||
if (overlay_interfaces[i].state==INTERFACE_STATE_DETECTING)
|
||||
overlay_interfaces[i].state=INTERFACE_STATE_UP;
|
||||
|
@ -398,28 +398,29 @@ int overlay_get_nexthop(unsigned char *d,unsigned char *nexthop,int *interface)
|
||||
|
||||
long long now = gettime_ms();
|
||||
overlay_neighbour *direct_neighbour=NULL;
|
||||
|
||||
if (n->neighbour_id){
|
||||
|
||||
if (n->neighbour_id) {
|
||||
direct_neighbour = &overlay_neighbours[n->neighbour_id];
|
||||
overlay_route_recalc_neighbour_metrics(direct_neighbour, now);
|
||||
/* Is a direct neighbour.
|
||||
So in the absence of any better indirect route, we pick the interface that
|
||||
we can hear this neighbour on the most reliably, and then send the frame
|
||||
we can hear this neighbour on the most reliably, and then send the frame
|
||||
via that interface and directly addressed to the recipient. */
|
||||
|
||||
*interface=0;
|
||||
for(i=1;i<OVERLAY_MAX_INTERFACES;i++) {
|
||||
if (overlay_interfaces[i].state==INTERFACE_STATE_UP &&
|
||||
direct_neighbour->scores[i]>direct_neighbour->scores[*interface]) *interface=i;
|
||||
int ifn = -1;
|
||||
for (i = 0; i < overlay_interface_count; ++i) {
|
||||
if ( overlay_interfaces[i].state == INTERFACE_STATE_UP
|
||||
&& (ifn == -1 || direct_neighbour->scores[i] > direct_neighbour->scores[ifn]))
|
||||
ifn = i;
|
||||
}
|
||||
if (direct_neighbour->scores[*interface]>0) {
|
||||
bcopy(d,nexthop,SID_SIZE);
|
||||
if (0) DEBUGF("nexthop is %s",alloca_tohex_sid(nexthop));
|
||||
if (ifn != -1 && direct_neighbour->scores[ifn] > 0) {
|
||||
*interface = ifn;
|
||||
bcopy(d, nexthop, SID_SIZE);
|
||||
if (debug&DEBUG_OVERLAYROUTING)
|
||||
DEBUGF("nexthop is %s", alloca_tohex_sid(nexthop));
|
||||
return 0;
|
||||
}
|
||||
// otherwise fall through
|
||||
}
|
||||
|
||||
|
||||
/* Is not a direct neighbour.
|
||||
XXX - Very simplistic for now. */
|
||||
int o;
|
||||
|
Loading…
x
Reference in New Issue
Block a user