summaryrefslogtreecommitdiff
path: root/ospf6d/ospf6_interface.c
diff options
context:
space:
mode:
authorIgor Ryzhov <iryzhov@nfware.com>2021-05-25 21:58:55 +0300
committerIgor Ryzhov <iryzhov@nfware.com>2021-05-27 13:20:04 +0300
commit7a9a640e1ece3e7d9fcd9e5eb9d526d4113397f2 (patch)
treea0cb951b75203a430ae99f3a0233c3c67b32b2c6 /ospf6d/ospf6_interface.c
parent13df8fc58ebc7e8f428f7caa82772e8bc655308b (diff)
ospf6d: fix possible crashes
OSPF6 instance may not exist when processing interface state change. Do not execute processing steps that require an instance if an area is not configured for an interface. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
Diffstat (limited to 'ospf6d/ospf6_interface.c')
-rw-r--r--ospf6d/ospf6_interface.c31
1 files changed, 19 insertions, 12 deletions
diff --git a/ospf6d/ospf6_interface.c b/ospf6d/ospf6_interface.c
index c2f9c3362e..9a738aa5b5 100644
--- a/ospf6d/ospf6_interface.c
+++ b/ospf6d/ospf6_interface.c
@@ -499,6 +499,9 @@ static int ospf6_interface_state_change(uint8_t next_state,
if (prev_state == next_state)
return -1;
+ if (!oi->area)
+ return -1;
+
/* log */
if (IS_OSPF6_DEBUG_INTERFACE) {
zlog_debug("Interface state change %s: %s -> %s",
@@ -507,7 +510,8 @@ static int ospf6_interface_state_change(uint8_t next_state,
ospf6_interface_state_str[next_state]);
}
oi->state_change++;
- ospf6 = ospf6_lookup_by_vrf_id(oi->interface->vrf_id);
+
+ ospf6 = oi->area->ospf6;
if ((prev_state == OSPF6_INTERFACE_DR
|| prev_state == OSPF6_INTERFACE_BDR)
@@ -772,10 +776,8 @@ int interface_up(struct thread *thread)
return 0;
}
#endif /* __FreeBSD__ */
- if (oi->area->ospf6)
- ospf6 = oi->area->ospf6;
- else
- ospf6 = ospf6_lookup_by_vrf_id(oi->interface->vrf_id);
+
+ ospf6 = oi->area->ospf6;
/* Join AllSPFRouters */
if (ospf6_sso(oi->interface->ifindex, &allspfrouters6, IPV6_JOIN_GROUP,
@@ -890,13 +892,6 @@ int interface_down(struct thread *thread)
/* Stop trying to set socket options. */
THREAD_OFF(oi->thread_sso);
- ospf6 = ospf6_lookup_by_vrf_id(oi->interface->vrf_id);
- /* Leave AllSPFRouters */
- if (oi->state > OSPF6_INTERFACE_DOWN)
- ospf6_sso(oi->interface->ifindex, &allspfrouters6,
- IPV6_LEAVE_GROUP, ospf6->fd);
-
- ospf6_interface_state_change(OSPF6_INTERFACE_DOWN, oi);
for (ALL_LIST_ELEMENTS(oi->neighbor_list, node, nnode, on))
ospf6_neighbor_delete(on);
@@ -907,6 +902,18 @@ int interface_down(struct thread *thread)
* DR election, as it is no longer valid. */
oi->drouter = oi->prev_drouter = htonl(0);
oi->bdrouter = oi->prev_bdrouter = htonl(0);
+
+ if (oi->area == NULL)
+ return 0;
+
+ ospf6 = oi->area->ospf6;
+ /* Leave AllSPFRouters */
+ if (oi->state > OSPF6_INTERFACE_DOWN)
+ ospf6_sso(oi->interface->ifindex, &allspfrouters6,
+ IPV6_LEAVE_GROUP, ospf6->fd);
+
+ ospf6_interface_state_change(OSPF6_INTERFACE_DOWN, oi);
+
return 0;
}