diff options
| author | Igor Ryzhov <iryzhov@nfware.com> | 2024-01-27 01:50:04 +0200 | 
|---|---|---|
| committer | Igor Ryzhov <iryzhov@nfware.com> | 2024-01-28 23:28:40 +0200 | 
| commit | f776dda1ec5b2ac6f9a0bc71501acf958abd2e5f (patch) | |
| tree | 0a98a2cc3910b1266a6e7823f7626321deda1d21 /zebra/zebra_nb_config.c | |
| parent | 244e6ebd162465f386687d8afcc29c1cf51de192 (diff) | |
zebra: convert ip protocol commands to NB
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
Diffstat (limited to 'zebra/zebra_nb_config.c')
| -rw-r--r-- | zebra/zebra_nb_config.c | 101 | 
1 files changed, 101 insertions, 0 deletions
diff --git a/zebra/zebra_nb_config.c b/zebra/zebra_nb_config.c index c828d08733..ca1d1c626a 100644 --- a/zebra/zebra_nb_config.c +++ b/zebra/zebra_nb_config.c @@ -26,6 +26,7 @@  #include "zebra/zebra_evpn_mh.h"  #include "zebra/zebra_ptm.h"  #include "zebra/router-id.h" +#include "zebra/zebra_routemap.h"  /*   * XPath: /frr-zebra:zebra/mcast-rpf-lookup @@ -3304,6 +3305,106 @@ int lib_vrf_zebra_ipv6_router_id_destroy(struct nb_cb_destroy_args *args)  }  /* + * XPath: /frr-vrf:lib/vrf/frr-zebra:zebra/filter-protocol + */ +int lib_vrf_zebra_filter_protocol_create(struct nb_cb_create_args *args) +{ +	struct vrf *vrf; +	const char *afi_safi = yang_dnode_get_string(args->dnode, "afi-safi"); +	const char *proto = yang_dnode_get_string(args->dnode, "protocol"); +	const char *rmap = yang_dnode_get_string(args->dnode, "route-map"); +	afi_t afi; +	safi_t safi; +	int rtype; + +	yang_afi_safi_identity2value(afi_safi, &afi, &safi); + +	if (strcasecmp(proto, "any") == 0) +		rtype = ZEBRA_ROUTE_MAX; +	else +		rtype = proto_name2num(proto); + +	if (args->event == NB_EV_VALIDATE) +		if (rtype < 0) { +			snprintfrr(args->errmsg, args->errmsg_len, +				   "invalid protocol name \"%s\"", proto); +			return NB_ERR_VALIDATION; +		} + +	if (args->event != NB_EV_APPLY) +		return NB_OK; + +	vrf = nb_running_get_entry(args->dnode, NULL, true); + +	ip_protocol_rm_add(vrf->info, rmap, rtype, afi, safi); + +	return NB_OK; +} + +int lib_vrf_zebra_filter_protocol_destroy(struct nb_cb_destroy_args *args) +{ +	struct vrf *vrf; +	const char *afi_safi = yang_dnode_get_string(args->dnode, "afi-safi"); +	const char *proto = yang_dnode_get_string(args->dnode, "protocol"); +	const char *rmap = yang_dnode_get_string(args->dnode, "route-map"); +	afi_t afi; +	safi_t safi; +	int rtype; + +	yang_afi_safi_identity2value(afi_safi, &afi, &safi); + +	if (strcasecmp(proto, "any") == 0) +		rtype = ZEBRA_ROUTE_MAX; +	else +		rtype = proto_name2num(proto); + +	/* deleting an existing entry, it can't be invalid */ +	assert(rtype >= 0); + +	if (args->event != NB_EV_APPLY) +		return NB_OK; + +	vrf = nb_running_get_entry(args->dnode, NULL, true); + +	ip_protocol_rm_del(vrf->info, rmap, rtype, afi, safi); + +	return NB_OK; +} + +/* + * XPath: /frr-vrf:lib/vrf/frr-zebra:zebra/filter-protocol/route-map + */ +int lib_vrf_zebra_filter_protocol_route_map_modify(struct nb_cb_modify_args *args) +{ +	struct vrf *vrf; +	const char *afi_safi = yang_dnode_get_string(args->dnode, "../afi-safi"); +	const char *proto = yang_dnode_get_string(args->dnode, "../protocol"); +	const char *rmap = yang_dnode_get_string(args->dnode, NULL); +	afi_t afi; +	safi_t safi; +	int rtype; + +	yang_afi_safi_identity2value(afi_safi, &afi, &safi); + +	if (strcasecmp(proto, "any") == 0) +		rtype = ZEBRA_ROUTE_MAX; +	else +		rtype = proto_name2num(proto); + +	/* editing an existing entry, it can't be invalid */ +	assert(rtype >= 0); + +	if (args->event != NB_EV_APPLY) +		return NB_OK; + +	vrf = nb_running_get_entry(args->dnode, NULL, true); + +	ip_protocol_rm_add(vrf->info, rmap, rtype, afi, safi); + +	return NB_OK; +} + +/*   * XPath: /frr-vrf:lib/vrf/frr-zebra:zebra/l3vni-id   */  int lib_vrf_zebra_l3vni_id_modify(struct nb_cb_modify_args *args)  | 
