Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OSPFD yang #6055

Closed
wants to merge 42 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
0693b0d
yang: add vrf model
chiragshah6 Dec 6, 2019
e095f16
*: add frr-vrf yang module in makefile
chiragshah6 Dec 9, 2019
7d75ef8
Merge pull request #5501 from chiragshah6/yang_nb1
riw777 Dec 17, 2019
cf93250
yang: add vrf model
chiragshah6 Dec 6, 2019
245daf0
*: add frr-vrf yang module in makefile
chiragshah6 Dec 9, 2019
2d2d0ee
Merge branch 'nb_conversions' of https://github.com/FRRouting/frr int…
Feb 4, 2020
87ee53f
yang: add vrf ref to interface model
chiragshah6 Feb 3, 2020
5dd164b
Merge pull request #5751 from chiragshah6/yang_nb1
rwestphal Feb 5, 2020
95f1804
staticd: yang defination
vishaldhingra Dec 3, 2019
f5319ff
lib: yang defination for basic frr-routing
vishaldhingra Dec 11, 2019
a530bfe
lib: FRR next-hop yang data model.
Dec 20, 2019
db727fe
Merge pull request #5578 from Spantik/working_nb
qlyoung Feb 12, 2020
2a9ca11
Merge pull request #5460 from vishaldhingra/static_nb
qlyoung Feb 14, 2020
aa9935c
Merge pull request #5530 from vishaldhingra/common_nb
qlyoung Feb 14, 2020
6514ce8
yang: add vrf model
chiragshah6 Dec 6, 2019
5b15a51
*: add frr-vrf yang module in makefile
Feb 20, 2020
ee8ac97
yang: add vrf ref to interface model
chiragshah6 Feb 3, 2020
97928ec
lib: FRR next-hop yang data model.
Dec 20, 2019
8f8cac6
staticd: yang defination
vishaldhingra Dec 3, 2019
2aa6fcc
lib: yang defination for basic frr-routing
vishaldhingra Dec 11, 2019
3e31357
Merge branch 'nb_conversions' of https://github.com/FRRouting/frr int…
Feb 20, 2020
c590694
yang: add vrf model
chiragshah6 Dec 6, 2019
2884b53
*: add frr-vrf yang module in makefile
Feb 20, 2020
745d694
yang: add vrf ref to interface model
chiragshah6 Feb 3, 2020
1dc094d
lib: FRR next-hop yang data model.
Dec 20, 2019
3cd3efe
staticd: yang defination
vishaldhingra Dec 3, 2019
30144e1
lib: yang defination for basic frr-routing
vishaldhingra Dec 11, 2019
84b5d31
Merge branch 'nb_conversions' of https://github.com/FRRouting/frr int…
Mar 10, 2020
9503d08
yang: add vrf model
chiragshah6 Dec 6, 2019
f899a08
*: add frr-vrf yang module in makefile
Feb 20, 2020
5246d64
yang: add vrf ref to interface model
chiragshah6 Feb 3, 2020
1feaebb
lib: FRR next-hop yang data model.
Dec 20, 2019
a715c1b
staticd: yang defination
vishaldhingra Dec 3, 2019
dbd8ec5
lib: yang defination for basic frr-routing
vishaldhingra Dec 11, 2019
36dfb2f
Merge branch 'nb_conversions' of https://github.com/FRRouting/frr int…
Mar 20, 2020
2ee0eff
lib: vrf northbound callbacks
chiragshah6 Mar 11, 2020
fc8bee3
*: include vrf northbound module in init
chiragshah6 Mar 11, 2020
4d780b1
lib: convert vrf cmd to northbound config callback
chiragshah6 Mar 21, 2020
93624af
yang: revert leafref to get interface cmd working
chiragshah6 Mar 21, 2020
2209fc5
lib: static yang array size gcc 4 workaround
chiragshah6 Mar 24, 2020
2ee1136
Merge pull request #5989 from chiragshah6/yang_nb3
rwestphal Mar 25, 2020
391aa5b
ospfd: Configuration Yang for OSPF.
Mar 20, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions babeld/babel_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,10 @@ struct option longopts[] =
{ 0 }
};

static const struct frr_yang_module_info *const babeld_yang_modules[] =
{
&frr_interface_info,
};
static const struct frr_yang_module_info *const babeld_yang_modules[] = {
&frr_interface_info,
&frr_vrf_info,
};

FRR_DAEMON_INFO(babeld, BABELD,
.vty_port = BABEL_VTY_PORT,
Expand Down
1 change: 1 addition & 0 deletions bfdd/bfdd.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ static struct quagga_signal_t bfd_signals[] = {
static const struct frr_yang_module_info *const bfdd_yang_modules[] = {
&frr_interface_info,
&frr_bfdd_info,
&frr_vrf_info,
};

FRR_DAEMON_INFO(bfdd, BFD, .vty_port = 2617,
Expand Down
1 change: 1 addition & 0 deletions bgpd/bgp_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,7 @@ static void bgp_vrf_terminate(void)
static const struct frr_yang_module_info *const bgpd_yang_modules[] = {
&frr_interface_info,
&frr_route_map_info,
&frr_vrf_info,
};

FRR_DAEMON_INFO(bgpd, BGP, .vty_port = BGP_VTY_PORT,
Expand Down
1 change: 1 addition & 0 deletions eigrpd/eigrp_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ static const struct frr_yang_module_info *const eigrpd_yang_modules[] = {
&frr_eigrpd_info,
&frr_interface_info,
&frr_route_map_info,
&frr_vrf_info,
};

FRR_DAEMON_INFO(eigrpd, EIGRP, .vty_port = EIGRP_VTY_PORT,
Expand Down
1 change: 1 addition & 0 deletions isisd/isis_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ static const struct frr_yang_module_info *const isisd_yang_modules[] = {
&frr_isisd_info,
#endif /* ifndef FABRICD */
&frr_route_map_info,
&frr_vrf_info,
};

#ifdef FABRICD
Expand Down
1 change: 1 addition & 0 deletions ldpd/ldpd.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ static struct quagga_signal_t ldp_signals[] =
};

static const struct frr_yang_module_info *const ldpd_yang_modules[] = {
&frr_vrf_info,
};

FRR_DAEMON_INFO(ldpd, LDP,
Expand Down
4 changes: 4 additions & 0 deletions lib/northbound.h
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,11 @@ struct frr_yang_module_info {

/* Priority - lower priorities are processed first. */
uint32_t priority;
#if defined(__GNUC__) && ((__GNUC__ - 0) < 5) && !defined(__clang__)
} nodes[1000];
#else
} nodes[];
#endif
};

/* Northbound error codes. */
Expand Down
2 changes: 2 additions & 0 deletions lib/subdir.am
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ nodist_lib_libfrr_la_SOURCES = \
yang/frr-interface.yang.c \
yang/frr-route-map.yang.c \
yang/frr-route-types.yang.c \
yang/frr-vrf.yang.c \
yang/frr-routing.yang.c \
yang/ietf/ietf-routing-types.yang.c \
yang/frr-module-translator.yang.c \
# end
Expand Down
180 changes: 170 additions & 10 deletions lib/vrf.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
#include "privs.h"
#include "nexthop_group.h"
#include "lib_errors.h"
#include "northbound.h"
#include "northbound_cli.h"

/* default VRF ID value used when VRF backend is not NETNS */
#define VRF_DEFAULT_INTERNAL 0
Expand Down Expand Up @@ -603,6 +605,8 @@ int vrf_handler_create(struct vty *vty, const char *vrfname,
struct vrf **vrf)
{
struct vrf *vrfp;
char xpath_list[XPATH_MAXLEN];
int ret;

if (strlen(vrfname) > VRF_NAMSIZ) {
if (vty)
Expand All @@ -617,13 +621,24 @@ int vrf_handler_create(struct vty *vty, const char *vrfname,
return CMD_WARNING_CONFIG_FAILED;
}

vrfp = vrf_get(VRF_UNKNOWN, vrfname);

if (vty)
VTY_PUSH_CONTEXT(VRF_NODE, vrfp);
if (vty) {
snprintf(xpath_list, sizeof(xpath_list),
"/frr-vrf:lib/vrf[name='%s']", vrfname);

nb_cli_enqueue_change(vty, xpath_list, NB_OP_CREATE, NULL);
ret = nb_cli_apply_changes(vty, xpath_list);
if (ret == CMD_SUCCESS) {
VTY_PUSH_XPATH(VRF_NODE, xpath_list);
vrfp = vrf_lookup_by_name(vrfname);
if (vrfp)
VTY_PUSH_CONTEXT(VRF_NODE, vrfp);
}
} else {
vrfp = vrf_get(VRF_UNKNOWN, vrfname);

if (vrf)
*vrf = vrfp;
if (vrf)
*vrf = vrfp;
}
return CMD_SUCCESS;
}

Expand Down Expand Up @@ -726,6 +741,7 @@ DEFUN (no_vrf,
"VRF's name\n")
{
const char *vrfname = argv[2]->arg;
char xpath_list[XPATH_MAXLEN];

struct vrf *vrfp;

Expand All @@ -741,11 +757,11 @@ DEFUN (no_vrf,
return CMD_WARNING_CONFIG_FAILED;
}

/* Clear configured flag and invoke delete. */
UNSET_FLAG(vrfp->status, VRF_CONFIGURED);
vrf_delete(vrfp);
snprintf(xpath_list, sizeof(xpath_list), "/frr-vrf:lib/vrf[name='%s']",
vrfname);

return CMD_SUCCESS;
nb_cli_enqueue_change(vty, xpath_list, NB_OP_DESTROY, NULL);
return nb_cli_apply_changes(vty, xpath_list);
}


Expand Down Expand Up @@ -1010,3 +1026,147 @@ vrf_id_t vrf_generate_id(void)

return ++vrf_id_local;
}

/* ------- Northbound callbacks ------- */

/*
* XPath: /frr-vrf:lib/vrf
*/
static int lib_vrf_create(enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource)
{
const char *vrfname;
struct vrf *vrfp;

vrfname = yang_dnode_get_string(dnode, "./name");

if (event != NB_EV_APPLY)
return NB_OK;

vrfp = vrf_get(VRF_UNKNOWN, vrfname);

nb_running_set_entry(dnode, vrfp);

return NB_OK;
}

static int lib_vrf_destroy(enum nb_event event, const struct lyd_node *dnode)
{
struct vrf *vrfp;

switch (event) {
case NB_EV_VALIDATE:
vrfp = nb_running_get_entry(dnode, NULL, true);
if (CHECK_FLAG(vrfp->status, VRF_ACTIVE)) {
zlog_debug("%s Only inactive VRFs can be deleted",
__func__);
return NB_ERR_VALIDATION;
}
break;
case NB_EV_PREPARE:
case NB_EV_ABORT:
break;
case NB_EV_APPLY:
vrfp = nb_running_unset_entry(dnode);

/* Clear configured flag and invoke delete. */
UNSET_FLAG(vrfp->status, VRF_CONFIGURED);
vrf_delete(vrfp);
break;
}

return NB_OK;
}

static const void *lib_vrf_get_next(const void *parent_list_entry,
const void *list_entry)
{
struct vrf *vrfp = (struct vrf *)list_entry;

if (list_entry == NULL) {
vrfp = RB_MIN(vrf_name_head, &vrfs_by_name);
} else {
vrfp = RB_NEXT(vrf_name_head, vrfp);
}

return vrfp;
}

static int lib_vrf_get_keys(const void *list_entry, struct yang_list_keys *keys)
{
struct vrf *vrfp = (struct vrf *)list_entry;

keys->num = 1;
strlcpy(keys->key[0], vrfp->name, sizeof(keys->key[0]));

return NB_OK;
}

static const void *lib_vrf_lookup_entry(const void *parent_list_entry,
const struct yang_list_keys *keys)
{
const char *vrfname = keys->key[0];

struct vrf *vrf = vrf_lookup_by_name(vrfname);

return vrf;
}

/*
* XPath: /frr-vrf:lib/vrf/id
*/
static struct yang_data *lib_vrf_state_id_get_elem(const char *xpath,
const void *list_entry)
{
struct vrf *vrfp = (struct vrf *)list_entry;

return yang_data_new_uint32(xpath, vrfp->vrf_id);
}

/*
* XPath: /frr-vrf:lib/vrf/active
*/
static struct yang_data *lib_vrf_state_active_get_elem(const char *xpath,
const void *list_entry)
{
struct vrf *vrfp = (struct vrf *)list_entry;

if (vrfp->status == VRF_ACTIVE)
return yang_data_new_bool(
xpath, vrfp->status == VRF_ACTIVE ? true : false);

return NULL;
}

/* clang-format off */
const struct frr_yang_module_info frr_vrf_info = {
.name = "frr-vrf",
.nodes = {
{
.xpath = "/frr-vrf:lib/vrf",
.cbs = {
.create = lib_vrf_create,
.destroy = lib_vrf_destroy,
.get_next = lib_vrf_get_next,
.get_keys = lib_vrf_get_keys,
.lookup_entry = lib_vrf_lookup_entry,
}
},
{
.xpath = "/frr-vrf:lib/vrf/state/id",
.cbs = {
.get_elem = lib_vrf_state_id_get_elem,
}
},
{
.xpath = "/frr-vrf:lib/vrf/state/active",
.cbs = {
.get_elem = lib_vrf_state_active_get_elem,
}
},
{
.xpath = NULL,
},
}
};

2 changes: 2 additions & 0 deletions lib/vrf.h
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,8 @@ extern int vrf_enable(struct vrf *vrf);
extern void vrf_delete(struct vrf *vrf);
extern vrf_id_t vrf_generate_id(void);

extern const struct frr_yang_module_info frr_vrf_info;

#ifdef __cplusplus
}
#endif
Expand Down
1 change: 1 addition & 0 deletions lib/yang.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ static const char *yang_module_imp_clb(const char *mod_name,

static const char *const frr_native_modules[] = {
"frr-interface",
"frr-vrf",
"frr-ripd",
"frr-ripngd",
"frr-isisd",
Expand Down
1 change: 1 addition & 0 deletions ospf6d/ospf6_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ struct quagga_signal_t ospf6_signals[] = {
static const struct frr_yang_module_info *const ospf6d_yang_modules[] = {
&frr_interface_info,
&frr_route_map_info,
&frr_vrf_info,
};

FRR_DAEMON_INFO(ospf6d, OSPF6, .vty_port = OSPF6_VTY_PORT,
Expand Down
1 change: 1 addition & 0 deletions ospfd/ospf_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ struct quagga_signal_t ospf_signals[] = {
static const struct frr_yang_module_info *const ospfd_yang_modules[] = {
&frr_interface_info,
&frr_route_map_info,
&frr_vrf_info,
};

FRR_DAEMON_INFO(ospfd, OSPF, .vty_port = OSPF_VTY_PORT,
Expand Down
1 change: 1 addition & 0 deletions pimd/pim_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ struct zebra_privs_t pimd_privs = {
static const struct frr_yang_module_info *const pimd_yang_modules[] = {
&frr_interface_info,
&frr_route_map_info,
&frr_vrf_info,
};

FRR_DAEMON_INFO(pimd, PIM, .vty_port = PIMD_VTY_PORT,
Expand Down
1 change: 1 addition & 0 deletions ripd/rip_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ static const struct frr_yang_module_info *const ripd_yang_modules[] = {
&frr_interface_info,
&frr_ripd_info,
&frr_route_map_info,
&frr_vrf_info,
};

FRR_DAEMON_INFO(ripd, RIP, .vty_port = RIP_VTY_PORT,
Expand Down
1 change: 1 addition & 0 deletions ripngd/ripng_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ static const struct frr_yang_module_info *const ripngd_yang_modules[] = {
&frr_interface_info,
&frr_ripngd_info,
&frr_route_map_info,
&frr_vrf_info,
};

FRR_DAEMON_INFO(ripngd, RIPNG, .vty_port = RIPNG_VTY_PORT,
Expand Down
1 change: 1 addition & 0 deletions sharpd/sharp_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ struct quagga_signal_t sharp_signals[] = {
static const struct frr_yang_module_info *const sharpd_yang_modules[] = {
&frr_interface_info,
&frr_route_map_info,
&frr_vrf_info,
};

FRR_DAEMON_INFO(sharpd, SHARP, .vty_port = SHARP_VTY_PORT,
Expand Down
1 change: 1 addition & 0 deletions staticd/static_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ struct quagga_signal_t static_signals[] = {
};

static const struct frr_yang_module_info *const staticd_yang_modules[] = {
&frr_vrf_info,
};

#define STATIC_VTY_PORT 2616
Expand Down
Loading