diff options
Diffstat (limited to 'ospfd/ospf_interface.c')
| -rw-r--r-- | ospfd/ospf_interface.c | 93 |
1 files changed, 87 insertions, 6 deletions
diff --git a/ospfd/ospf_interface.c b/ospfd/ospf_interface.c index 334ed33ee0..eb7a8348e8 100644 --- a/ospfd/ospf_interface.c +++ b/ospfd/ospf_interface.c @@ -49,6 +49,8 @@ #include "ospfd/ospf_network.h" #include "ospfd/ospf_dump.h" #include "ospfd/ospf_ldp_sync.h" +#include "ospfd/ospf_route.h" +#include "ospfd/ospf_te.h" DEFINE_QOBJ_TYPE(ospf_interface); DEFINE_HOOK(ospf_vl_add, (struct ospf_vl_data * vd), (vd)); @@ -186,7 +188,7 @@ struct ospf_interface *ospf_if_table_lookup(struct interface *ifp, struct ospf_interface *rninfo = NULL; p = *prefix; - p.prefixlen = IPV4_MAX_PREFIXLEN; + p.prefixlen = IPV4_MAX_BITLEN; /* route_node_get implicitely locks */ if ((rn = route_node_lookup(IF_OIFS(ifp), &p))) { @@ -203,7 +205,7 @@ static void ospf_add_to_if(struct interface *ifp, struct ospf_interface *oi) struct prefix p; p = *oi->address; - p.prefixlen = IPV4_MAX_PREFIXLEN; + p.prefixlen = IPV4_MAX_BITLEN; apply_mask(&p); rn = route_node_get(IF_OIFS(ifp), &p); @@ -221,7 +223,7 @@ static void ospf_delete_from_if(struct interface *ifp, struct prefix p; p = *oi->address; - p.prefixlen = IPV4_MAX_PREFIXLEN; + p.prefixlen = IPV4_MAX_BITLEN; rn = route_node_lookup(IF_OIFS(oi->ifp), &p); assert(rn); @@ -564,7 +566,7 @@ void ospf_free_if_params(struct interface *ifp, struct in_addr addr) struct route_node *rn; p.family = AF_INET; - p.prefixlen = IPV4_MAX_PREFIXLEN; + p.prefixlen = IPV4_MAX_BITLEN; p.prefix = addr; rn = route_node_lookup(IF_OIFS_PARAMS(ifp), (struct prefix *)&p); if (!rn || !rn->info) @@ -599,7 +601,7 @@ struct ospf_if_params *ospf_lookup_if_params(struct interface *ifp, struct route_node *rn; p.family = AF_INET; - p.prefixlen = IPV4_MAX_PREFIXLEN; + p.prefixlen = IPV4_MAX_BITLEN; p.prefix = addr; rn = route_node_lookup(IF_OIFS_PARAMS(ifp), (struct prefix *)&p); @@ -619,7 +621,7 @@ struct ospf_if_params *ospf_get_if_params(struct interface *ifp, struct route_node *rn; p.family = AF_INET; - p.prefixlen = IPV4_MAX_PREFIXLEN; + p.prefixlen = IPV4_MAX_BITLEN; p.prefix = addr; apply_mask_ipv4(&p); @@ -804,6 +806,10 @@ int ospf_if_up(struct ospf_interface *oi) int ospf_if_down(struct ospf_interface *oi) { struct ospf *ospf; + struct route_node *rn; + struct ospf_route *or; + struct listnode *nh; + struct ospf_path *op; if (oi == NULL) return 0; @@ -840,6 +846,22 @@ int ospf_if_down(struct ospf_interface *oi) /* Shutdown packet reception and sending */ ospf_if_stream_unset(oi); + for (rn = route_top(ospf->new_table); rn; rn = route_next(rn)) { + or = rn->info; + + if (!or) + continue; + + for (nh = listhead(or->paths); nh; + nh = listnextnode_unchecked(nh)) { + op = listgetdata(nh); + if (op->ifindex == oi->ifp->ifindex) { + or->changed = true; + break; + } + } + } + return 1; } @@ -1333,6 +1355,9 @@ static int ospf_ifp_create(struct interface *ifp) ospf_if_update(ospf, ifp); + if (HAS_LINK_PARAMS(ifp)) + ospf_mpls_te_update_if(ifp); + hook_call(ospf_if_update, ifp); return 0; @@ -1371,6 +1396,9 @@ static int ospf_ifp_up(struct interface *ifp) ospf_if_up(oi); } + if (HAS_LINK_PARAMS(ifp)) + ospf_mpls_te_update_if(ifp); + return 0; } @@ -1419,6 +1447,59 @@ static int ospf_ifp_destroy(struct interface *ifp) return 0; } +/* Resetting ospf hello timer */ +void ospf_reset_hello_timer(struct interface *ifp, struct in_addr addr, + bool is_addr) +{ + struct route_node *rn; + + if (is_addr) { + struct prefix p; + struct ospf_interface *oi = NULL; + + p.u.prefix4 = addr; + p.family = AF_INET; + p.prefixlen = IPV4_MAX_BITLEN; + + oi = ospf_if_table_lookup(ifp, &p); + + if (oi) { + /* Send hello before restart the hello timer + * to avoid session flaps in case of bigger + * hello interval configurations. + */ + ospf_hello_send(oi); + + /* Restart hello timer for this interface */ + OSPF_ISM_TIMER_OFF(oi->t_hello); + OSPF_HELLO_TIMER_ON(oi); + } + + return; + } + + for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next(rn)) { + struct ospf_interface *oi = rn->info; + + if (!oi) + continue; + + /* If hello interval configured on this oi, don't restart. */ + if (OSPF_IF_PARAM_CONFIGURED(oi->params, v_hello)) + continue; + + /* Send hello before restart the hello timer + * to avoid session flaps in case of bigger + * hello interval configurations. + */ + ospf_hello_send(oi); + + /* Restart the hello timer. */ + OSPF_ISM_TIMER_OFF(oi->t_hello); + OSPF_HELLO_TIMER_ON(oi); + } +} + void ospf_if_init(void) { if_zapi_callbacks(ospf_ifp_create, ospf_ifp_up, |
