mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-06-14 12:52:37 +00:00
ospfd: North-bound implementation for ospfd rmaps
This commit introduces the implementation for the north-bound callbacks for the ospfd-specific route-map match and set clauses. Signed-off-by: NaveenThanikachalam <nthanikachal@vmware.com> Signed-off-by: Sarita Patra <saritap@vmware.com>
This commit is contained in:
parent
078110ca60
commit
a623b52619
@ -56,6 +56,7 @@
|
||||
#include "ospfd/ospf_bfd.h"
|
||||
#include "ospfd/ospf_errors.h"
|
||||
#include "ospfd/ospf_ldp_sync.h"
|
||||
#include "ospfd/ospf_routemap_nb.h"
|
||||
|
||||
/* ospfd privileges */
|
||||
zebra_capabilities_t _caps_p[] = {ZCAP_NET_RAW, ZCAP_BIND, ZCAP_NET_ADMIN,
|
||||
@ -134,6 +135,7 @@ static const struct frr_yang_module_info *const ospfd_yang_modules[] = {
|
||||
&frr_interface_info,
|
||||
&frr_route_map_info,
|
||||
&frr_vrf_info,
|
||||
&frr_ospf_route_map_info,
|
||||
};
|
||||
|
||||
FRR_DAEMON_INFO(ospfd, OSPF, .vty_port = OSPF_VTY_PORT,
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include "plist.h"
|
||||
#include "vrf.h"
|
||||
#include "frrstr.h"
|
||||
#include "northbound_cli.h"
|
||||
|
||||
#include "ospfd/ospfd.h"
|
||||
#include "ospfd/ospf_asbr.h"
|
||||
@ -534,7 +535,7 @@ static const struct route_map_rule_cmd route_set_tag_cmd = {
|
||||
route_map_rule_tag_free,
|
||||
};
|
||||
|
||||
DEFUN (set_metric_type,
|
||||
DEFUN_YANG (set_metric_type,
|
||||
set_metric_type_cmd,
|
||||
"set metric-type <type-1|type-2>",
|
||||
SET_STR
|
||||
@ -543,11 +544,19 @@ DEFUN (set_metric_type,
|
||||
"OSPF[6] external type 2 metric\n")
|
||||
{
|
||||
char *ext = argv[2]->text;
|
||||
return generic_set_add(vty, VTY_GET_CONTEXT(route_map_index),
|
||||
"metric-type", ext);
|
||||
|
||||
const char *xpath =
|
||||
"./set-action[action='frr-ospf-route-map:metric-type']";
|
||||
char xpath_value[XPATH_MAXLEN];
|
||||
|
||||
nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
|
||||
snprintf(xpath_value, sizeof(xpath_value),
|
||||
"%s/rmap-set-action/frr-ospf-route-map:metric-type", xpath);
|
||||
nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY, ext);
|
||||
return nb_cli_apply_changes(vty, NULL);
|
||||
}
|
||||
|
||||
DEFUN (no_set_metric_type,
|
||||
DEFUN_YANG (no_set_metric_type,
|
||||
no_set_metric_type_cmd,
|
||||
"no set metric-type [<type-1|type-2>]",
|
||||
NO_STR
|
||||
@ -556,9 +565,11 @@ DEFUN (no_set_metric_type,
|
||||
"OSPF[6] external type 1 metric\n"
|
||||
"OSPF[6] external type 2 metric\n")
|
||||
{
|
||||
char *ext = (argc == 4) ? argv[3]->text : NULL;
|
||||
return generic_set_delete(vty, VTY_GET_CONTEXT(route_map_index),
|
||||
"metric-type", ext);
|
||||
const char *xpath =
|
||||
"./set-action[action='frr-ospf-route-map:metric-type']";
|
||||
|
||||
nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
|
||||
return nb_cli_apply_changes(vty, NULL);
|
||||
}
|
||||
|
||||
/* Route-map init */
|
||||
|
39
ospfd/ospf_routemap_nb.c
Normal file
39
ospfd/ospf_routemap_nb.c
Normal file
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Vmware
|
||||
* Sarita Patra
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; see the file COPYING; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "lib/northbound.h"
|
||||
#include "lib/routemap.h"
|
||||
#include "ospf_routemap_nb.h"
|
||||
|
||||
/* clang-format off */
|
||||
const struct frr_yang_module_info frr_ospf_route_map_info = {
|
||||
.name = "frr-ospf-route-map",
|
||||
.nodes = {
|
||||
{
|
||||
.xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-ospf-route-map:metric-type",
|
||||
.cbs = {
|
||||
.modify = lib_route_map_entry_set_action_rmap_set_action_metric_type_modify,
|
||||
.destroy = lib_route_map_entry_set_action_rmap_set_action_metric_type_destroy,
|
||||
}
|
||||
},
|
||||
{
|
||||
.xpath = NULL,
|
||||
},
|
||||
}
|
||||
};
|
37
ospfd/ospf_routemap_nb.h
Normal file
37
ospfd/ospf_routemap_nb.h
Normal file
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Vmware
|
||||
* Sarita Patra
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; see the file COPYING; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef _FRR_OSPF_ROUTEMAP_NB_H_
|
||||
#define _FRR_OSPF_ROUTEMAP_NB_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern const struct frr_yang_module_info frr_ospf_route_map_info;
|
||||
|
||||
/* prototypes */
|
||||
int lib_route_map_entry_set_action_rmap_set_action_metric_type_modify(struct nb_cb_modify_args *args);
|
||||
int lib_route_map_entry_set_action_rmap_set_action_metric_type_destroy(struct nb_cb_destroy_args *args);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
63
ospfd/ospf_routemap_nb_config.c
Normal file
63
ospfd/ospf_routemap_nb_config.c
Normal file
@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Vmware
|
||||
* Sarita Patra
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; see the file COPYING; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "lib/command.h"
|
||||
#include "lib/log.h"
|
||||
#include "lib/northbound.h"
|
||||
#include "lib/routemap.h"
|
||||
#include "ospf_routemap_nb.h"
|
||||
|
||||
/*
|
||||
* XPath:
|
||||
* /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-ospf-route-map:metric-type
|
||||
*/
|
||||
int lib_route_map_entry_set_action_rmap_set_action_metric_type_modify(
|
||||
struct nb_cb_modify_args *args)
|
||||
{
|
||||
struct routemap_hook_context *rhc;
|
||||
const char *type;
|
||||
int rv;
|
||||
|
||||
if (args->event != NB_EV_APPLY)
|
||||
return NB_OK;
|
||||
|
||||
/* Add configuration. */
|
||||
rhc = nb_running_get_entry(args->dnode, NULL, true);
|
||||
type = yang_dnode_get_string(args->dnode, NULL);
|
||||
|
||||
/* Set destroy information. */
|
||||
rhc->rhc_shook = generic_set_delete;
|
||||
rhc->rhc_rule = "metric-type";
|
||||
rhc->rhc_event = RMAP_EVENT_SET_DELETED;
|
||||
|
||||
rv = generic_set_add(rhc->rhc_rmi, "metric-type", type,
|
||||
args->errmsg, args->errmsg_len);
|
||||
if (rv != CMD_SUCCESS) {
|
||||
rhc->rhc_mhook = NULL;
|
||||
return NB_ERR_INCONSISTENCY;
|
||||
}
|
||||
|
||||
return NB_OK;
|
||||
}
|
||||
|
||||
int lib_route_map_entry_set_action_rmap_set_action_metric_type_destroy(
|
||||
struct nb_cb_destroy_args *args)
|
||||
{
|
||||
return lib_route_map_entry_set_destroy(args);
|
||||
}
|
@ -732,4 +732,5 @@ extern int p_spaces_compare_func(const struct p_space *a,
|
||||
const struct p_space *b);
|
||||
extern int q_spaces_compare_func(const struct q_space *a,
|
||||
const struct q_space *b);
|
||||
|
||||
#endif /* _ZEBRA_OSPFD_H */
|
||||
|
@ -51,6 +51,8 @@ ospfd_libfrrospf_a_SOURCES = \
|
||||
ospfd/ospf_ri.c \
|
||||
ospfd/ospf_route.c \
|
||||
ospfd/ospf_routemap.c \
|
||||
ospfd/ospf_routemap_nb.c \
|
||||
ospfd/ospf_routemap_nb_config.c \
|
||||
ospfd/ospf_spf.c \
|
||||
ospfd/ospf_ti_lfa.c \
|
||||
ospfd/ospf_sr.c \
|
||||
@ -100,6 +102,7 @@ noinst_HEADERS += \
|
||||
ospfd/ospf_packet.h \
|
||||
ospfd/ospf_ri.h \
|
||||
ospfd/ospf_route.h \
|
||||
ospfd/ospf_routemap_nb.h \
|
||||
ospfd/ospf_spf.h \
|
||||
ospfd/ospf_ti_lfa.h \
|
||||
ospfd/ospf_sr.h \
|
||||
@ -120,3 +123,7 @@ ospfd_ospfd_snmp_la_LIBADD = lib/libfrrsnmp.la
|
||||
EXTRA_DIST += \
|
||||
ospfd/ChangeLog.opaque.txt \
|
||||
# end
|
||||
|
||||
nodist_ospfd_ospfd_SOURCES = \
|
||||
yang/frr-ospf-route-map.yang.c \
|
||||
# end
|
||||
|
Loading…
Reference in New Issue
Block a user