diff options
Diffstat (limited to 'ospf6d/ospf6_interface.c')
| -rw-r--r-- | ospf6d/ospf6_interface.c | 61 |
1 files changed, 44 insertions, 17 deletions
diff --git a/ospf6d/ospf6_interface.c b/ospf6d/ospf6_interface.c index c2f9c3362e..b71d884fdc 100644 --- a/ospf6d/ospf6_interface.c +++ b/ospf6d/ospf6_interface.c @@ -109,7 +109,7 @@ static uint8_t ospf6_default_iftype(struct interface *ifp) { if (if_is_pointopoint(ifp)) return OSPF_IFTYPE_POINTOPOINT; - else if (if_is_loopback(ifp)) + else if (if_is_loopback_or_vrf(ifp)) return OSPF_IFTYPE_LOOPBACK; else return OSPF_IFTYPE_BROADCAST; @@ -390,7 +390,7 @@ void ospf6_interface_state_update(struct interface *ifp) if (if_is_operative(ifp) && (ospf6_interface_get_linklocal_address(oi->interface) - || if_is_loopback(oi->interface))) + || if_is_loopback_or_vrf(oi->interface))) thread_execute(master, interface_up, oi, 0); else thread_execute(master, interface_down, oi, 0); @@ -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) @@ -730,7 +734,7 @@ int interface_up(struct thread *thread) /* check interface has a link-local address */ if (!(ospf6_interface_get_linklocal_address(oi->interface) - || if_is_loopback(oi->interface))) { + || if_is_loopback_or_vrf(oi->interface))) { if (IS_OSPF6_DEBUG_INTERFACE) zlog_debug( "Interface %s has no link local address, can't execute [InterfaceUp]", @@ -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, @@ -798,7 +800,7 @@ int interface_up(struct thread *thread) /* Schedule Hello */ if (!CHECK_FLAG(oi->flag, OSPF6_INTERFACE_PASSIVE) - && !if_is_loopback(oi->interface)) { + && !if_is_loopback_or_vrf(oi->interface)) { oi->thread_send_hello = NULL; thread_add_event(master, ospf6_hello_send, oi, 0, &oi->thread_send_hello); @@ -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; } @@ -1190,6 +1197,26 @@ static int ospf6_interface_show(struct vty *vty, struct interface *ifp, return 0; } +/* Find the global address to be used as a forwarding address in NSSA LSA.*/ +struct in6_addr *ospf6_interface_get_global_address(struct interface *ifp) +{ + struct listnode *n; + struct connected *c; + struct in6_addr *l = (struct in6_addr *)NULL; + + /* for each connected address */ + for (ALL_LIST_ELEMENTS_RO(ifp->connected, n, c)) { + /* if family not AF_INET6, ignore */ + if (c->address->family != AF_INET6) + continue; + + if (!IN6_IS_ADDR_LINKLOCAL(&c->address->u.prefix6)) + l = &c->address->u.prefix6; + } + return l; +} + + static int show_ospf6_interface_common(struct vty *vty, vrf_id_t vrf_id, int argc, struct cmd_token **argv, int idx_ifname, int intf_idx, @@ -2099,7 +2126,7 @@ DEFUN (no_ipv6_ospf6_passive, THREAD_OFF(oi->thread_sso); /* don't send hellos over loopback interface */ - if (!if_is_loopback(oi->interface)) + if (!if_is_loopback_or_vrf(oi->interface)) thread_add_event(master, ospf6_hello_send, oi, 0, &oi->thread_send_hello); |
