Skip to content

Commit 404db6f

Browse files
committed
flushing neighbours associated with flushed interface.
1 parent 0801126 commit 404db6f

4 files changed

Lines changed: 15 additions & 17 deletions

File tree

interface.c

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ int
101101
flush_interface(char *ifname)
102102
{
103103
struct interface *ifp, *prev;
104+
struct neighbour *neigh;
104105

105106
prev = NULL;
106107
ifp = interfaces;
@@ -114,6 +115,18 @@ flush_interface(char *ifname)
114115
if(ifp == NULL)
115116
return 0;
116117

118+
/* flush any neighbours associated with interface */
119+
neigh = neighs;
120+
while(neigh) {
121+
if(neigh->ifp == ifp) {
122+
struct neighbour *old = neigh;
123+
neigh = neigh->next;
124+
flush_neighbour(old);
125+
continue;
126+
}
127+
neigh = neigh->next;
128+
}
129+
117130
interface_updown(ifp, 0);
118131
if(prev)
119132
prev->next = ifp->next;
@@ -512,14 +525,6 @@ interface_updown(struct interface *ifp, int up)
512525
free(ifp->ll);
513526
ifp->ll = NULL;
514527
ifp->numll = 0;
515-
516-
/* unset ifp for any neighbors -prevents neighbor from referencing free'd ifp */
517-
struct neighbour *neigh;
518-
FOR_ALL_NEIGHBOURS(neigh) {
519-
if (ifp && neigh && neigh->ifp && (neigh->ifp == ifp)) {
520-
neigh->ifp = NULL;
521-
}
522-
}
523528
}
524529

525530
local_notify_interface(ifp, LOCAL_CHANGE);

local.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,6 @@ local_notify_neighbour_1(struct local_socket *s,
145145
char buf[512], rttbuf[64];
146146
int rc;
147147

148-
if (neigh->ifp == NULL) {
149-
return;
150-
}
151-
152148
rttbuf[0] = '\0';
153149
if(valid_rtt(neigh)) {
154150
rc = snprintf(rttbuf, 64, " rtt %s rttcost %u",
@@ -240,10 +236,6 @@ local_notify_route_1(struct local_socket *s, struct babel_route *route, int kind
240236
char buf[512];
241237
int rc;
242238

243-
if (route->neigh->ifp == NULL) {
244-
return;
245-
}
246-
247239
const char *dst_prefix = format_prefix(route->src->prefix,
248240
route->src->plen);
249241
const char *src_prefix = format_prefix(route->src->src_prefix,

neighbour.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ find_neighbour_nocreate(const unsigned char *address, struct interface *ifp)
5454
return NULL;
5555
}
5656

57-
static void
57+
void
5858
flush_neighbour(struct neighbour *neigh)
5959
{
6060
flush_neighbour_routes(neigh);

neighbour.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ struct neighbour *find_neighbour(const unsigned char *address,
6868
int update_neighbour(struct neighbour *neigh, struct hello_history *hist,
6969
int unicast, int hello, int hello_interval);
7070
unsigned check_neighbours(void);
71+
void flush_neighbour(struct neighbour *neigh);
7172
unsigned neighbour_txcost(struct neighbour *neigh);
7273
unsigned neighbour_rxcost(struct neighbour *neigh);
7374
unsigned neighbour_rttcost(struct neighbour *neigh);

0 commit comments

Comments
 (0)