Merge pull request #9798 from abuibrahim/master

fix broken northbound confd
This commit is contained in:
Quentin Young 2021-11-30 00:17:28 -05:00 committed by GitHub
commit 23b2f11a47
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 102 additions and 46 deletions

View File

@ -1915,6 +1915,7 @@ if test "$enable_confd" != "" -a "$enable_confd" != "no"; then
if test "$CONFD" = "/bin/false"; then if test "$CONFD" = "/bin/false"; then
AC_MSG_ERROR([confd was not found on your system.])] AC_MSG_ERROR([confd was not found on your system.])]
fi fi
AC_CHECK_PROG([CONFDC], [confdc], [confdc], [/bin/false], "${enable_confd}/bin")
CONFD_CFLAGS="-I${enable_confd}/include -L${enable_confd}/lib" CONFD_CFLAGS="-I${enable_confd}/include -L${enable_confd}/lib"
AC_SUBST([CONFD_CFLAGS]) AC_SUBST([CONFD_CFLAGS])
CONFD_LIBS="-lconfd" CONFD_LIBS="-lconfd"

View File

@ -491,6 +491,47 @@ static void *thread_cdb_trigger_subscriptions(void *data)
return NULL; return NULL;
} }
static int frr_confd_subscribe(const struct lysc_node *snode, void *arg)
{
struct yang_module *module = arg;
struct nb_node *nb_node;
int *spoint;
int ret;
switch (snode->nodetype) {
case LYS_CONTAINER:
case LYS_LEAF:
case LYS_LEAFLIST:
case LYS_LIST:
break;
default:
return YANG_ITER_CONTINUE;
}
if (CHECK_FLAG(snode->flags, LYS_CONFIG_R))
return YANG_ITER_CONTINUE;
nb_node = snode->priv;
if (!nb_node)
return YANG_ITER_CONTINUE;
DEBUGD(&nb_dbg_client_confd, "%s: subscribing to '%s'", __func__,
nb_node->xpath);
spoint = XMALLOC(MTYPE_CONFD, sizeof(*spoint));
ret = cdb_subscribe2(cdb_sub_sock, CDB_SUB_RUNNING_TWOPHASE,
CDB_SUB_WANT_ABORT_ON_ABORT, 3, spoint,
module->confd_hash, nb_node->xpath);
if (ret != CONFD_OK) {
flog_err_confd("cdb_subscribe2");
XFREE(MTYPE_CONFD, spoint);
return YANG_ITER_CONTINUE;
}
listnode_add(confd_spoints, spoint);
return YANG_ITER_CONTINUE;
}
static int frr_confd_init_cdb(void) static int frr_confd_init_cdb(void)
{ {
struct yang_module *module; struct yang_module *module;
@ -514,8 +555,6 @@ static int frr_confd_init_cdb(void)
/* Subscribe to all loaded YANG data modules. */ /* Subscribe to all loaded YANG data modules. */
confd_spoints = list_new(); confd_spoints = list_new();
RB_FOREACH (module, yang_modules, &yang_modules) { RB_FOREACH (module, yang_modules, &yang_modules) {
struct lysc_node *snode;
module->confd_hash = confd_str2hash(module->info->ns); module->confd_hash = confd_str2hash(module->info->ns);
if (module->confd_hash == 0) { if (module->confd_hash == 0) {
flog_err( flog_err(
@ -530,42 +569,8 @@ static int frr_confd_init_cdb(void)
* entire YANG module. So we have to find the top level * entire YANG module. So we have to find the top level
* nodes ourselves and subscribe to their paths. * nodes ourselves and subscribe to their paths.
*/ */
LY_LIST_FOR (module->info->data, snode) { yang_snodes_iterate(module->info, frr_confd_subscribe, 0,
struct nb_node *nb_node; module);
int *spoint;
int ret;
switch (snode->nodetype) {
case LYS_CONTAINER:
case LYS_LEAF:
case LYS_LEAFLIST:
case LYS_LIST:
break;
default:
continue;
}
if (CHECK_FLAG(snode->flags, LYS_CONFIG_R))
continue;
nb_node = snode->priv;
if (!nb_node)
continue;
DEBUGD(&nb_dbg_client_confd, "%s: subscribing to '%s'",
__func__, nb_node->xpath);
spoint = XMALLOC(MTYPE_CONFD, sizeof(*spoint));
ret = cdb_subscribe2(
cdb_sub_sock, CDB_SUB_RUNNING_TWOPHASE,
CDB_SUB_WANT_ABORT_ON_ABORT, 3, spoint,
module->confd_hash, nb_node->xpath);
if (ret != CONFD_OK) {
flog_err_confd("cdb_subscribe2");
XFREE(MTYPE_CONFD, spoint);
}
listnode_add(confd_spoints, spoint);
}
} }
if (cdb_subscribe_done(cdb_sub_sock) != CONFD_OK) { if (cdb_subscribe_done(cdb_sub_sock) != CONFD_OK) {
@ -705,7 +710,7 @@ static int frr_confd_data_get_next(struct confd_trans_ctx *tctx,
confd_data_reply_next_key(tctx, v, keys.num, confd_data_reply_next_key(tctx, v, keys.num,
(long)nb_next); (long)nb_next);
} else { } else {
char pointer_str[16]; char pointer_str[32];
/* /*
* ConfD 6.6 user guide, chapter 6.11 (Operational data * ConfD 6.6 user guide, chapter 6.11 (Operational data
@ -843,7 +848,7 @@ static int frr_confd_data_get_next_object(struct confd_trans_ctx *tctx,
const void *nb_next; const void *nb_next;
#define CONFD_OBJECTS_PER_TIME 100 #define CONFD_OBJECTS_PER_TIME 100
struct confd_next_object objects[CONFD_OBJECTS_PER_TIME + 1]; struct confd_next_object objects[CONFD_OBJECTS_PER_TIME + 1];
char pseudo_keys[CONFD_OBJECTS_PER_TIME][16]; char pseudo_keys[CONFD_OBJECTS_PER_TIME][32];
int nobjects = 0; int nobjects = 0;
frr_confd_get_xpath(kp, xpath, sizeof(xpath)); frr_confd_get_xpath(kp, xpath, sizeof(xpath));
@ -868,7 +873,7 @@ static int frr_confd_data_get_next_object(struct confd_trans_ctx *tctx,
memset(objects, 0, sizeof(objects)); memset(objects, 0, sizeof(objects));
for (int j = 0; j < CONFD_OBJECTS_PER_TIME; j++) { for (int j = 0; j < CONFD_OBJECTS_PER_TIME; j++) {
struct confd_next_object *object; struct confd_next_object *object;
struct lysc_node *child; const struct lysc_node *child;
struct yang_data *data; struct yang_data *data;
size_t nvalues = 0; size_t nvalues = 0;
@ -1189,6 +1194,8 @@ static int frr_confd_dp_ctl_read(struct thread *thread)
thread_add_read(master, frr_confd_dp_ctl_read, dctx, fd, &t_dp_ctl); thread_add_read(master, frr_confd_dp_ctl_read, dctx, fd, &t_dp_ctl);
frr_confd_dp_read(dctx, fd); frr_confd_dp_read(dctx, fd);
return 0;
} }
static int frr_confd_dp_worker_read(struct thread *thread) static int frr_confd_dp_worker_read(struct thread *thread)
@ -1199,6 +1206,8 @@ static int frr_confd_dp_worker_read(struct thread *thread)
thread_add_read(master, frr_confd_dp_worker_read, dctx, fd, &t_dp_worker); thread_add_read(master, frr_confd_dp_worker_read, dctx, fd, &t_dp_worker);
frr_confd_dp_read(dctx, fd); frr_confd_dp_read(dctx, fd);
return 0;
} }
static int frr_confd_subscribe_state(const struct lysc_node *snode, void *arg) static int frr_confd_subscribe_state(const struct lysc_node *snode, void *arg)

View File

@ -11,8 +11,10 @@ module confd.frr-ripd {
tailf:annotate-module "frr-ripd" { tailf:annotate-module "frr-ripd" {
tailf:annotate-statement "container[name='ripd']" { tailf:annotate-statement "container[name='ripd']" {
tailf:annotate-statement "container[name='state']" { tailf:annotate-statement "list[name='instance']" {
tailf:callpoint "state"; tailf:annotate-statement "container[name='state']" {
tailf:callpoint "state";
}
} }
} }
tailf:annotate-statement "rpc[name='clear-rip-route']" { tailf:annotate-statement "rpc[name='clear-rip-route']" {

View File

@ -11,8 +11,10 @@ module confd.frr-ripngd {
tailf:annotate-module "frr-ripngd" { tailf:annotate-module "frr-ripngd" {
tailf:annotate-statement "container[name='ripngd']" { tailf:annotate-statement "container[name='ripngd']" {
tailf:annotate-statement "container[name='state']" { tailf:annotate-statement "list[name='instance']" {
tailf:callpoint "state"; tailf:annotate-statement "container[name='state']" {
tailf:callpoint "state";
}
} }
} }
tailf:annotate-statement "rpc[name='clear-ripng-route']" { tailf:annotate-statement "rpc[name='clear-ripng-route']" {

View File

@ -13,6 +13,8 @@ submodule frr-bgp-bmp {
prefix frr-bt; prefix frr-bt;
} }
include "frr-bgp-common-multiprotocol";
organization organization
"FRRouting"; "FRRouting";
contact contact

View File

@ -25,6 +25,8 @@ submodule frr-bgp-common-structure {
prefix frr-bt; prefix frr-bt;
} }
include "frr-bgp-common";
organization organization
"FRRouting"; "FRRouting";
contact contact

View File

@ -5,6 +5,10 @@ submodule frr-bgp-neighbor {
prefix "bgp"; prefix "bgp";
} }
include "frr-bgp-common-multiprotocol";
include "frr-bgp-common-structure";
organization organization
"FRRouting"; "FRRouting";
contact contact

View File

@ -13,6 +13,10 @@ submodule frr-bgp-peer-group {
prefix frr-bt; prefix frr-bt;
} }
include "frr-bgp-common-structure";
include "frr-bgp-neighbor";
organization organization
"FRRouting"; "FRRouting";
contact contact

View File

@ -1,7 +1,7 @@
module frr-routing { module frr-routing {
yang-version "1.1"; yang-version "1.1";
namespace "http://frrouting.org/yang/routing"; namespace "http://frrouting.org/yang/routing";
prefix "rt"; prefix "frr-routing";
import ietf-yang-types { import ietf-yang-types {
prefix "yang"; prefix "yang";

View File

@ -88,6 +88,10 @@ dist_yangmodels_DATA += yang/frr-bgp-types.yang
dist_yangmodels_DATA += yang/frr-bgp.yang dist_yangmodels_DATA += yang/frr-bgp.yang
endif endif
if OSPFD
dist_yangmodels_DATA += yang/frr-ospfd.yang
endif
if PATHD if PATHD
dist_yangmodels_DATA += yang/frr-pathd.yang dist_yangmodels_DATA += yang/frr-pathd.yang
endif endif
@ -97,3 +101,29 @@ CLEANFILES += \
yang/ietf/*.c \ yang/ietf/*.c \
yang/confd/*.c \ yang/confd/*.c \
# #
if CONFD
SUBMODULES = $(shell cd $(top_srcdir); grep -l belongs-to $(dist_yangmodels_DATA))
EXCLUDED_MODULES = $(SUBMODULES) yang/frr-module-translator.yang
YANG_MODULES = $(filter-out $(EXCLUDED_MODULES),$(dist_yangmodels_DATA))
fxsdir = $(sysconfdir)/confd
fxs_DATA = $(YANG_MODULES:.yang=.fxs)
SUFFIXES += .fxs
CLEANFILES += $(fxs_DATA)
AM_V_CONFDC = $(AM_V_CONFDC_@AM_V@)
AM_V_CONFDC_ = $(AM_V_CONFDC_@AM_DEFAULT_V@)
AM_V_CONFDC_0 = @echo " CONFDC " $@;
CONFDC_FLAGS = --yangpath $(srcdir)/yang --yangpath $(srcdir)/yang/ietf
yang/%.fxs: yang/%.yang yang/confd/confd.%.yang
$(AM_V_CONFDC)$(CONFDC) $(CONFDC_FLAGS) -c -o $@ -a $(srcdir)/yang/confd/confd.$*.yang -- $<
yang/%.fxs: yang/%.yang
$(AM_V_CONFDC)$(CONFDC) $(CONFDC_FLAGS) -c -o $@ -- $<
endif