ospfd: 'ip ospf network' interface should down iface before changing type
* ospf_vty.c: (ip_ospf_network) This function changes the interface type
and only then downs/ups the interface if already up. So the down happens
with the interface type already altered. However, the interface type
can have major ramifications for how underlying state is stored/indexed,
which may cause problems.
Further, bit of an encapsulation violation to twiddle state here.
(no_ip_ospf_network) ditto.
* ospf_interface.c: (ospf_if_reset_type) New function to reset the OSPF
interface type on an interface. Ensure the interface is downed before
the type is changed.
* ospf_interface.h: (ospf_if_reset_type) Export, for ospf_vty.c
diff --git a/ospfd/ospf_interface.c b/ospfd/ospf_interface.c
index 8755c08..a46ca6d 100644
--- a/ospfd/ospf_interface.c
+++ b/ospfd/ospf_interface.c
@@ -144,6 +144,29 @@
oi->v_ls_ack = 1;
}
+void
+ospf_if_reset_type (struct interface *ifp, u_char type)
+{
+ struct route_node *rn;
+
+ for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
+ {
+ struct ospf_interface *oi = rn->info;
+ u_char orig_ism_state;
+
+ if (!oi)
+ continue;
+
+ orig_ism_state = oi->state;
+ OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown);
+
+ oi->type = IF_DEF_PARAMS (ifp)->type;
+
+ if (orig_ism_state > ISM_Down)
+ OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp);
+ }
+}
+
/* lookup oi for specified prefix/ifp */
struct ospf_interface *
ospf_if_table_lookup (struct interface *ifp, struct prefix *prefix)