summaryrefslogtreecommitdiff
path: root/ospf6d/ospf6_zebra.c
diff options
context:
space:
mode:
authorRuss White <russ@riw.us>2021-09-24 13:42:49 -0400
committerGitHub <noreply@github.com>2021-09-24 13:42:49 -0400
commitb8beb67ef5a1c6e276a11ee346ea4a84c1c0b76f (patch)
treed471f2d6c8d8b7c50e09207a37e695e6138629c8 /ospf6d/ospf6_zebra.c
parentd2e41077549d65e08b14948597cacb3d34eeda52 (diff)
parent6735622c24a3510032e40aaf4b9f419e9efbea3d (diff)
Merge pull request #9585 from opensourcerouting/ospf6d-nssa-dflt-originate
ospf6d: add a knob to generate Type-7 default routes
Diffstat (limited to 'ospf6d/ospf6_zebra.c')
-rw-r--r--ospf6d/ospf6_zebra.c57
1 files changed, 57 insertions, 0 deletions
diff --git a/ospf6d/ospf6_zebra.c b/ospf6d/ospf6_zebra.c
index a6929b32c4..1a0c5a9971 100644
--- a/ospf6d/ospf6_zebra.c
+++ b/ospf6d/ospf6_zebra.c
@@ -37,6 +37,7 @@
#include "ospf6_lsa.h"
#include "ospf6_lsdb.h"
#include "ospf6_asbr.h"
+#include "ospf6_nssa.h"
#include "ospf6_zebra.h"
#include "ospf6d.h"
#include "ospf6_area.h"
@@ -129,6 +130,61 @@ void ospf6_zebra_no_redistribute(int type, vrf_id_t vrf_id)
AFI_IP6, type, 0, vrf_id);
}
+void ospf6_zebra_import_default_route(struct ospf6 *ospf6, bool unreg)
+{
+ struct prefix prefix = {};
+ int command;
+
+ if (zclient->sock < 0) {
+ if (IS_OSPF6_DEBUG_ZEBRA(SEND))
+ zlog_debug(" Not connected to Zebra");
+ return;
+ }
+
+ prefix.family = AF_INET6;
+ prefix.prefixlen = 0;
+
+ if (unreg)
+ command = ZEBRA_IMPORT_ROUTE_UNREGISTER;
+ else
+ command = ZEBRA_IMPORT_ROUTE_REGISTER;
+
+ if (IS_OSPF6_DEBUG_ZEBRA(SEND))
+ zlog_debug("%s: sending cmd %s for %pFX (vrf %u)", __func__,
+ zserv_command_string(command), &prefix,
+ ospf6->vrf_id);
+
+ if (zclient_send_rnh(zclient, command, &prefix, true, ospf6->vrf_id)
+ == ZCLIENT_SEND_FAILURE)
+ flog_err(EC_LIB_ZAPI_SOCKET, "%s: zclient_send_rnh() failed",
+ __func__);
+}
+
+static int ospf6_zebra_import_check_update(ZAPI_CALLBACK_ARGS)
+{
+ struct ospf6 *ospf6;
+ struct zapi_route nhr;
+
+ ospf6 = ospf6_lookup_by_vrf_id(vrf_id);
+ if (ospf6 == NULL || !IS_OSPF6_ASBR(ospf6))
+ return 0;
+
+ if (!zapi_nexthop_update_decode(zclient->ibuf, &nhr)) {
+ zlog_err("%s[%u]: Failure to decode route", __func__,
+ ospf6->vrf_id);
+ return -1;
+ }
+
+ if (nhr.prefix.family != AF_INET6 || nhr.prefix.prefixlen != 0
+ || nhr.type == ZEBRA_ROUTE_OSPF6)
+ return 0;
+
+ ospf6->nssa_default_import_check.status = !!nhr.nexthop_num;
+ ospf6_abr_nssa_type_7_defaults(ospf6);
+
+ return 0;
+}
+
static int ospf6_zebra_if_address_update_add(ZAPI_CALLBACK_ARGS)
{
struct connected *c;
@@ -664,6 +720,7 @@ void ospf6_zebra_init(struct thread_master *master)
ospf6_zebra_if_address_update_delete;
zclient->redistribute_route_add = ospf6_zebra_read_route;
zclient->redistribute_route_del = ospf6_zebra_read_route;
+ zclient->import_check_update = ospf6_zebra_import_check_update;
/* Install command element for zebra node. */
install_element(VIEW_NODE, &show_ospf6_zebra_cmd);