summaryrefslogtreecommitdiffstats
path: root/ospf6d
diff options
context:
space:
mode:
authorRuss White <russ@riw.us>2019-09-30 13:46:19 +0200
committerGitHub <noreply@github.com>2019-09-30 13:46:19 +0200
commit9898a2fb3441e7382dba4190233f466b8271deae (patch)
tree9629a5ce665db95addf0d0bc0f46864ef71b5a49 /ospf6d
parentMerge pull request #5066 from ak503/libfrr_crash (diff)
parentlib: delete interface if you can in upper level protocol (diff)
downloadfrr-9898a2fb3441e7382dba4190233f466b8271deae.tar.xz
frr-9898a2fb3441e7382dba4190233f466b8271deae.zip
Merge pull request #5009 from donaldsharp/interface_deletion
lib, zebra: Allow for interface deletion when kernel event happens
Diffstat (limited to 'ospf6d')
-rw-r--r--ospf6d/ospf6_interface.c54
-rw-r--r--ospf6d/ospf6_zebra.c55
2 files changed, 54 insertions, 55 deletions
diff --git a/ospf6d/ospf6_interface.c b/ospf6d/ospf6_interface.c
index 4d7c75a33..a56ba0a69 100644
--- a/ospf6d/ospf6_interface.c
+++ b/ospf6d/ospf6_interface.c
@@ -42,6 +42,7 @@
#include "ospf6_spf.h"
#include "ospf6d.h"
#include "ospf6_bfd.h"
+#include "ospf6_zebra.h"
DEFINE_MTYPE_STATIC(OSPF6D, CFG_PLIST_NAME, "configured prefix list names")
DEFINE_QOBJ_TYPE(ospf6_interface)
@@ -1946,11 +1947,64 @@ static struct cmd_node interface_node = {
INTERFACE_NODE, "%s(config-if)# ", 1 /* VTYSH */
};
+static int ospf6_ifp_create(struct interface *ifp)
+{
+ if (IS_OSPF6_DEBUG_ZEBRA(RECV))
+ zlog_debug("Zebra Interface add: %s index %d mtu %d", ifp->name,
+ ifp->ifindex, ifp->mtu6);
+ ospf6_interface_if_add(ifp);
+
+ return 0;
+}
+
+static int ospf6_ifp_up(struct interface *ifp)
+{
+ if (IS_OSPF6_DEBUG_ZEBRA(RECV))
+ zlog_debug(
+ "Zebra Interface state change: "
+ "%s index %d flags %llx metric %d mtu %d bandwidth %d",
+ ifp->name, ifp->ifindex, (unsigned long long)ifp->flags,
+ ifp->metric, ifp->mtu6, ifp->bandwidth);
+
+ ospf6_interface_state_update(ifp);
+
+ return 0;
+}
+
+static int ospf6_ifp_down(struct interface *ifp)
+{
+ if (IS_OSPF6_DEBUG_ZEBRA(RECV))
+ zlog_debug(
+ "Zebra Interface state change: "
+ "%s index %d flags %llx metric %d mtu %d bandwidth %d",
+ ifp->name, ifp->ifindex, (unsigned long long)ifp->flags,
+ ifp->metric, ifp->mtu6, ifp->bandwidth);
+
+ ospf6_interface_state_update(ifp);
+
+ return 0;
+}
+
+static int ospf6_ifp_destroy(struct interface *ifp)
+{
+ if (if_is_up(ifp))
+ zlog_warn("Zebra: got delete of %s, but interface is still up",
+ ifp->name);
+
+ if (IS_OSPF6_DEBUG_ZEBRA(RECV))
+ zlog_debug("Zebra Interface delete: %s index %d mtu %d",
+ ifp->name, ifp->ifindex, ifp->mtu6);
+
+ return 0;
+}
+
void ospf6_interface_init(void)
{
/* Install interface node. */
install_node(&interface_node, config_write_ospf6_interface);
if_cmd_init();
+ if_zapi_callbacks(ospf6_ifp_create, ospf6_ifp_up,
+ ospf6_ifp_down, ospf6_ifp_destroy);
install_element(VIEW_NODE, &show_ipv6_ospf6_interface_prefix_cmd);
install_element(VIEW_NODE, &show_ipv6_ospf6_interface_ifname_cmd);
diff --git a/ospf6d/ospf6_zebra.c b/ospf6d/ospf6_zebra.c
index 8454016b2..d8a6a39e1 100644
--- a/ospf6d/ospf6_zebra.c
+++ b/ospf6d/ospf6_zebra.c
@@ -97,57 +97,6 @@ void ospf6_zebra_no_redistribute(int type)
AFI_IP6, type, 0, VRF_DEFAULT);
}
-/* Inteface addition message from zebra. */
-static int ospf6_zebra_if_add(ZAPI_CALLBACK_ARGS)
-{
- struct interface *ifp;
-
- ifp = zebra_interface_add_read(zclient->ibuf, vrf_id);
- if (IS_OSPF6_DEBUG_ZEBRA(RECV))
- zlog_debug("Zebra Interface add: %s index %d mtu %d", ifp->name,
- ifp->ifindex, ifp->mtu6);
- ospf6_interface_if_add(ifp);
- return 0;
-}
-
-static int ospf6_zebra_if_del(ZAPI_CALLBACK_ARGS)
-{
- struct interface *ifp;
-
- if (!(ifp = zebra_interface_state_read(zclient->ibuf, vrf_id)))
- return 0;
-
- if (if_is_up(ifp))
- zlog_warn("Zebra: got delete of %s, but interface is still up",
- ifp->name);
-
- if (IS_OSPF6_DEBUG_ZEBRA(RECV))
- zlog_debug("Zebra Interface delete: %s index %d mtu %d",
- ifp->name, ifp->ifindex, ifp->mtu6);
-
- if_set_index(ifp, IFINDEX_INTERNAL);
- return 0;
-}
-
-static int ospf6_zebra_if_state_update(ZAPI_CALLBACK_ARGS)
-{
- struct interface *ifp;
-
- ifp = zebra_interface_state_read(zclient->ibuf, vrf_id);
- if (ifp == NULL)
- return 0;
-
- if (IS_OSPF6_DEBUG_ZEBRA(RECV))
- zlog_debug(
- "Zebra Interface state change: "
- "%s index %d flags %llx metric %d mtu %d bandwidth %d",
- ifp->name, ifp->ifindex, (unsigned long long)ifp->flags,
- ifp->metric, ifp->mtu6, ifp->bandwidth);
-
- ospf6_interface_state_update(ifp);
- return 0;
-}
-
static int ospf6_zebra_if_address_update_add(ZAPI_CALLBACK_ARGS)
{
struct connected *c;
@@ -583,10 +532,6 @@ void ospf6_zebra_init(struct thread_master *master)
zclient_init(zclient, ZEBRA_ROUTE_OSPF6, 0, &ospf6d_privs);
zclient->zebra_connected = ospf6_zebra_connected;
zclient->router_id_update = ospf6_router_id_update_zebra;
- zclient->interface_add = ospf6_zebra_if_add;
- zclient->interface_delete = ospf6_zebra_if_del;
- zclient->interface_up = ospf6_zebra_if_state_update;
- zclient->interface_down = ospf6_zebra_if_state_update;
zclient->interface_address_add = ospf6_zebra_if_address_update_add;
zclient->interface_address_delete =
ospf6_zebra_if_address_update_delete;