diff options
| author | Renato Westphal <renato@opensourcerouting.org> | 2021-09-06 19:52:32 -0300 | 
|---|---|---|
| committer | Renato Westphal <renato@opensourcerouting.org> | 2021-09-21 17:47:13 -0300 | 
| commit | 6735622c24a3510032e40aaf4b9f419e9efbea3d (patch) | |
| tree | 21c37b02d6b5833e47a7601c9879f323021b0ec4 /ospf6d/ospf6_zebra.c | |
| parent | 210429c74722d85f392cbee344ffd30bea83a004 (diff) | |
ospf6d: implement Type-7 default routes for NSSA areas
Add the "default-information-originate" option to the "area X nssa"
command. That option allows the origination of Type-7 default routes
on NSSA ABRs and ASBRs.
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
Diffstat (limited to 'ospf6d/ospf6_zebra.c')
| -rw-r--r-- | ospf6d/ospf6_zebra.c | 57 | 
1 files changed, 57 insertions, 0 deletions
diff --git a/ospf6d/ospf6_zebra.c b/ospf6d/ospf6_zebra.c index c2e91d09bb..9f491f1e8f 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);  | 
