Skip to content

Commit

Permalink
libyang: Updates libyang2 from review
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Hopps <chopps@labn.net>
  • Loading branch information
choppsv1 committed Apr 15, 2021
1 parent 1587f45 commit 01316ad
Show file tree
Hide file tree
Showing 37 changed files with 346 additions and 356 deletions.
16 changes: 8 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ services:
- docker
jobs:
include:
- script:
- docker/centos-7/build.sh
- docker images
name: centos7
- script:
- docker/centos-8/build.sh
- docker images
name: centos8
# - script:
# - docker/centos-7/build.sh
# - docker images
# name: centos7
# - script:
# - docker/centos-8/build.sh
# - docker images
# name: centos8
- script:
- sudo apt install -y linux-modules-extra-$(uname -r)
- docker build -t frr-ubuntu18:latest -f docker/ubuntu18-ci/Dockerfile .
Expand Down
4 changes: 2 additions & 2 deletions bfdd/bfd.c
Original file line number Diff line number Diff line change
Expand Up @@ -2195,8 +2195,8 @@ void bfd_session_update_vrf_name(struct bfd_session *bs, struct vrf *vrf)
snprintf(xpath + slen, sizeof(xpath) - slen, "[vrf='%s']/vrf",
bs->key.vrfname);

bfd_dnode = yang_dnode_get(running_config->dnode, xpath,
bs->key.vrfname);
bfd_dnode = yang_dnode_getf(running_config->dnode, xpath,
bs->key.vrfname);
if (bfd_dnode) {
yang_dnode_get_path(lyd_parent(bfd_dnode), oldpath,
sizeof(oldpath));
Expand Down
3 changes: 0 additions & 3 deletions bgpd/bgp_nb.c
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,6 @@ const struct frr_yang_module_info frr_bgp_info = {
.xpath = "/frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-bgp:bgp/neighbors/neighbor/local-as/no-prepend",
.cbs = {
.modify = bgp_neighbors_neighbor_local_as_no_prepend_modify,
.destroy = bgp_neighbors_neighbor_local_as_no_prepend_destroy,
}
},
{
Expand Down Expand Up @@ -921,7 +920,6 @@ const struct frr_yang_module_info frr_bgp_info = {
.xpath = "/frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-bgp:bgp/neighbors/unnumbered-neighbor/local-as/no-prepend",
.cbs = {
.modify = bgp_neighbors_unnumbered_neighbor_local_as_no_prepend_modify,
.destroy = bgp_neighbors_unnumbered_neighbor_local_as_no_prepend_destroy,
}
},
{
Expand Down Expand Up @@ -1213,7 +1211,6 @@ const struct frr_yang_module_info frr_bgp_info = {
.xpath = "/frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-bgp:bgp/peer-groups/peer-group/local-as/no-prepend",
.cbs = {
.modify = bgp_peer_groups_peer_group_local_as_no_prepend_modify,
.destroy = bgp_peer_groups_peer_group_local_as_no_prepend_destroy,
}
},
{
Expand Down
6 changes: 0 additions & 6 deletions bgpd/bgp_nb.h
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,6 @@ int bgp_neighbors_neighbor_local_as_local_as_destroy(
struct nb_cb_destroy_args *args);
int bgp_neighbors_neighbor_local_as_no_prepend_modify(
struct nb_cb_modify_args *args);
int bgp_neighbors_neighbor_local_as_no_prepend_destroy(
struct nb_cb_destroy_args *args);
int bgp_neighbors_neighbor_local_as_no_replace_as_modify(
struct nb_cb_modify_args *args);
int bgp_neighbors_neighbor_bfd_options_enable_modify(
Expand Down Expand Up @@ -367,8 +365,6 @@ int bgp_neighbors_unnumbered_neighbor_local_as_local_as_destroy(
struct nb_cb_destroy_args *args);
int bgp_neighbors_unnumbered_neighbor_local_as_no_prepend_modify(
struct nb_cb_modify_args *args);
int bgp_neighbors_unnumbered_neighbor_local_as_no_prepend_destroy(
struct nb_cb_destroy_args *args);
int bgp_neighbors_unnumbered_neighbor_local_as_no_replace_as_modify(
struct nb_cb_modify_args *args);
int bgp_neighbors_unnumbered_neighbor_bfd_options_enable_modify(
Expand Down Expand Up @@ -501,8 +497,6 @@ int bgp_peer_groups_peer_group_local_as_local_as_destroy(
struct nb_cb_destroy_args *args);
int bgp_peer_groups_peer_group_local_as_no_prepend_modify(
struct nb_cb_modify_args *args);
int bgp_peer_groups_peer_group_local_as_no_prepend_destroy(
struct nb_cb_destroy_args *args);
int bgp_peer_groups_peer_group_local_as_no_replace_as_modify(
struct nb_cb_modify_args *args);
int bgp_peer_groups_peer_group_bfd_options_enable_modify(
Expand Down
45 changes: 0 additions & 45 deletions bgpd/bgp_nb_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -3560,21 +3560,6 @@ int bgp_neighbors_neighbor_local_as_no_prepend_modify(
return NB_OK;
}

int bgp_neighbors_neighbor_local_as_no_prepend_destroy(
struct nb_cb_destroy_args *args)
{
switch (args->event) {
case NB_EV_VALIDATE:
case NB_EV_PREPARE:
case NB_EV_ABORT:
case NB_EV_APPLY:
/* TODO: implement me. */
break;
}

return NB_OK;
}

/*
* XPath:
* /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-bgp:bgp/neighbors/neighbor/local-as/no-replace-as
Expand Down Expand Up @@ -5576,21 +5561,6 @@ int bgp_neighbors_unnumbered_neighbor_local_as_no_prepend_modify(
return NB_OK;
}

int bgp_neighbors_unnumbered_neighbor_local_as_no_prepend_destroy(
struct nb_cb_destroy_args *args)
{
switch (args->event) {
case NB_EV_VALIDATE:
case NB_EV_PREPARE:
case NB_EV_ABORT:
case NB_EV_APPLY:
/* TODO: implement me. */
break;
}

return NB_OK;
}

/*
* XPath:
* /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-bgp:bgp/neighbors/unnumbered-neighbor/local-as/no-replace-as
Expand Down Expand Up @@ -7493,21 +7463,6 @@ int bgp_peer_groups_peer_group_local_as_no_prepend_modify(
return NB_OK;
}

int bgp_peer_groups_peer_group_local_as_no_prepend_destroy(
struct nb_cb_destroy_args *args)
{
switch (args->event) {
case NB_EV_VALIDATE:
case NB_EV_PREPARE:
case NB_EV_ABORT:
case NB_EV_APPLY:
/* TODO: implement me. */
break;
}

return NB_OK;
}

/*
* XPath:
* /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-bgp:bgp/peer-groups/peer-group/local-as/no-replace-as
Expand Down
51 changes: 27 additions & 24 deletions bgpd/bgp_vty.c
Original file line number Diff line number Diff line change
Expand Up @@ -1394,6 +1394,9 @@ DEFUN_YANG_NOSH(router_bgp,
if (ret == CMD_SUCCESS) {
VTY_PUSH_XPATH(BGP_NODE, base_xpath);

/* Need to commit this if batched so lookup succeeds */
nb_cli_pending_commit_check(vty);

/*
* For backward compatibility with old commands we still
* need to use the qobj infrastructure.
Expand Down Expand Up @@ -4320,12 +4323,12 @@ DEFUN_YANG(neighbor_remote_as,
snprintf(prgrp_xpath, sizeof(prgrp_xpath),
FRR_BGP_PEER_GROUP_XPATH, argv[idx_peer]->arg, "");

if (yang_dnode_exists(vty->candidate_config->dnode, "%s%s",
VTY_CURR_XPATH, unnbr_xpath + 1)) {
if (yang_dnode_existsf(vty->candidate_config->dnode, "%s%s",
VTY_CURR_XPATH, unnbr_xpath + 1)) {
strlcpy(base_xpath, unnbr_xpath, sizeof(base_xpath));
} else if (yang_dnode_exists(vty->candidate_config->dnode,
"%s%s", VTY_CURR_XPATH,
prgrp_xpath + 1)) {
} else if (yang_dnode_existsf(vty->candidate_config->dnode,
"%s%s", VTY_CURR_XPATH,
prgrp_xpath + 1)) {
snprintf(base_xpath, sizeof(base_xpath),
FRR_BGP_PEER_GROUP_XPATH, argv[idx_peer]->arg,
"");
Expand Down Expand Up @@ -4596,8 +4599,8 @@ DEFUN_YANG(no_neighbor,
if (str2sockunion(argv[idx_peer]->arg, &su) == 0) {
snprintf(num_xpath, sizeof(num_xpath),
FRR_BGP_NEIGHBOR_NUM_XPATH, argv[idx_peer]->arg, "");
if (yang_dnode_exists(vty->candidate_config->dnode, "%s%s",
VTY_CURR_XPATH, num_xpath + 1)) {
if (yang_dnode_existsf(vty->candidate_config->dnode, "%s%s",
VTY_CURR_XPATH, num_xpath + 1)) {
strlcpy(base_xpath, num_xpath, sizeof(base_xpath));
}
} else {
Expand All @@ -4607,12 +4610,12 @@ DEFUN_YANG(no_neighbor,
snprintf(prgrp_xpath, sizeof(prgrp_xpath),
FRR_BGP_PEER_GROUP_XPATH, argv[idx_peer]->arg, "");

if (yang_dnode_exists(vty->candidate_config->dnode, "%s%s",
VTY_CURR_XPATH, unnbr_xpath + 1)) {
if (yang_dnode_existsf(vty->candidate_config->dnode, "%s%s",
VTY_CURR_XPATH, unnbr_xpath + 1)) {
strlcpy(base_xpath, unnbr_xpath, sizeof(base_xpath));
} else if (yang_dnode_exists(vty->candidate_config->dnode,
"%s%s", VTY_CURR_XPATH,
prgrp_xpath + 1)) {
} else if (yang_dnode_existsf(vty->candidate_config->dnode,
"%s%s", VTY_CURR_XPATH,
prgrp_xpath + 1)) {
strlcpy(base_xpath, prgrp_xpath, sizeof(base_xpath));
} else {
vty_out(vty,
Expand Down Expand Up @@ -4688,11 +4691,11 @@ DEFUN_YANG(no_neighbor_interface_peer_group_remote_as,
snprintf(prgrp_xpath, sizeof(prgrp_xpath), FRR_BGP_PEER_GROUP_XPATH,
argv[idx_peer]->arg, "");

if (yang_dnode_exists(vty->candidate_config->dnode, "%s%s",
VTY_CURR_XPATH, unnbr_xpath + 1)) {
if (yang_dnode_existsf(vty->candidate_config->dnode, "%s%s",
VTY_CURR_XPATH, unnbr_xpath + 1)) {
strlcpy(base_xpath, unnbr_xpath, sizeof(base_xpath));
} else if (yang_dnode_exists(vty->candidate_config->dnode, "%s%s",
VTY_CURR_XPATH, prgrp_xpath + 1)) {
} else if (yang_dnode_existsf(vty->candidate_config->dnode, "%s%s",
VTY_CURR_XPATH, prgrp_xpath + 1)) {
strlcpy(base_xpath, prgrp_xpath, sizeof(base_xpath));
} else {
vty_out(vty, "%% Create the peer-group or interface first\n");
Expand Down Expand Up @@ -6984,8 +6987,8 @@ static int peer_and_group_lookup_nb(struct vty *vty, const char *peer_str,
if (str2sockunion(peer_str, &su) == 0) {
snprintf(num_xpath, sizeof(num_xpath),
"/neighbors/neighbor[remote-address='%s']", peer_str);
if (yang_dnode_exists(vty->candidate_config->dnode, "%s%s",
VTY_CURR_XPATH, num_xpath)) {
if (yang_dnode_existsf(vty->candidate_config->dnode, "%s%s",
VTY_CURR_XPATH, num_xpath)) {
snprintf(base_xpath, xpath_len,
FRR_BGP_NEIGHBOR_NUM_XPATH, peer_str,
xpath ? xpath : "");
Expand All @@ -7004,14 +7007,14 @@ static int peer_and_group_lookup_nb(struct vty *vty, const char *peer_str,
"/peer-groups/peer-group[peer-group-name='%s']",
peer_str);

if (yang_dnode_exists(vty->candidate_config->dnode, "%s%s",
VTY_CURR_XPATH, unnbr_xpath)) {
if (yang_dnode_existsf(vty->candidate_config->dnode, "%s%s",
VTY_CURR_XPATH, unnbr_xpath)) {
snprintf(base_xpath, xpath_len,
FRR_BGP_NEIGHBOR_UNNUM_XPATH, peer_str,
xpath ? xpath : "");
} else if (yang_dnode_exists(vty->candidate_config->dnode,
"%s%s", VTY_CURR_XPATH,
prgrp_xpath)) {
} else if (yang_dnode_existsf(vty->candidate_config->dnode,
"%s%s", VTY_CURR_XPATH,
prgrp_xpath)) {
snprintf(base_xpath, xpath_len,
FRR_BGP_PEER_GROUP_XPATH, peer_str,
xpath ? xpath : "");
Expand Down Expand Up @@ -8033,7 +8036,7 @@ DEFPY_YANG(
bgp_afi_safi_get_container_str(afi, safi));

if (!no) {
if (!yang_dnode_exists(
if (!yang_dnode_existsf(
vty->candidate_config->dnode,
"/frr-route-map:lib/route-map[name='%s']",
rmap_str)) {
Expand Down
4 changes: 2 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -1864,8 +1864,8 @@ AC_SUBST([SNMP_CFLAGS])
dnl ---------------
dnl libyang
dnl ---------------
PKG_CHECK_MODULES([LIBYANG], [libyang >= 1.0.184], , [
AC_MSG_ERROR([libyang (>= 1.0.184) was not found on your system.])
PKG_CHECK_MODULES([LIBYANG], [libyang >= 2.0.0], , [
AC_MSG_ERROR([libyang (>= 2.0.0) was not found on your system.])
])
ac_cflags_save="$CFLAGS"
CFLAGS="$CFLAGS $LIBYANG_CFLAGS"
Expand Down
2 changes: 1 addition & 1 deletion doc/developer/building-libyang.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ RPM packages are at our `RPM repository <https://rpm.frrouting.org>`_.
git clone https://github.com/CESNET/libyang.git -b libyang2
cd libyang
git checkout f9266b10a
git checkout 11a1abe3
mkdir build; cd build
cmake -D CMAKE_INSTALL_PREFIX:PATH=/usr \
-D CMAKE_BUILD_TYPE:String="Release" ..
Expand Down
14 changes: 7 additions & 7 deletions docker/ubuntu18-ci/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,19 @@ RUN groupadd -r -g 92 frr && \
echo 'frr ALL = NOPASSWD: ALL' | tee /etc/sudoers.d/frr && \
mkdir -p /home/frr && chown frr.frr /home/frr

#for libyang 1
RUN apt-get install -y cmake libpcre3-dev
#for libyang 2
RUN apt-get install -y cmake libpcre2-dev

USER frr:frr

# build and install libyang1
RUN cd && pwd && ls -al && \
git clone https://github.com/CESNET/libyang.git && \
git clone https://github.com/CESNET/libyang.git -b libyang2 && \
cd libyang && \
git checkout v1.0.225 && \
git checkout 11a1abe3 && \
mkdir build; cd build && \
cmake -DENABLE_LYD_PRIV=ON -DCMAKE_INSTALL_PREFIX:PATH=/usr \
-D CMAKE_BUILD_TYPE:String="Release" .. && \
cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr \
-DCMAKE_BUILD_TYPE:String="Release" .. && \
make -j $(nproc) && \
sudo make install

Expand All @@ -47,7 +47,7 @@ COPY --chown=frr:frr . /home/frr/frr/
RUN cd && ls -al && ls -al frr

RUN cd ~/frr && \
./bootstrap.sh && \
./bootstrap.sh && \
./configure \
--prefix=/usr \
--localstatedir=/var/run/frr \
Expand Down
14 changes: 7 additions & 7 deletions docker/ubuntu20-ci/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,19 @@ RUN groupadd -r -g 92 frr && \
echo 'frr ALL = NOPASSWD: ALL' | tee /etc/sudoers.d/frr && \
mkdir -p /home/frr && chown frr.frr /home/frr

#for libyang 1
RUN apt-get install -y cmake libpcre3-dev
#for libyang 2
RUN apt-get install -y cmake libpcre2-dev

USER frr:frr

# build and install libyang1
RUN cd && pwd && ls -al && \
git clone https://github.com/CESNET/libyang.git && \
git clone https://github.com/CESNET/libyang.git -b libyang2 && \
cd libyang && \
git checkout v1.0.225 && \
git checkout 11a1abe3 && \
mkdir build; cd build && \
cmake -DENABLE_LYD_PRIV=ON -DCMAKE_INSTALL_PREFIX:PATH=/usr \
-D CMAKE_BUILD_TYPE:String="Release" .. && \
cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr \
-DCMAKE_BUILD_TYPE:String="Release" .. && \
make -j $(nproc) && \
sudo make install

Expand All @@ -50,7 +50,7 @@ COPY --chown=frr:frr . /home/frr/frr/
RUN cd && ls -al && ls -al frr

RUN cd ~/frr && \
./bootstrap.sh && \
./bootstrap.sh && \
./configure \
--prefix=/usr \
--localstatedir=/var/run/frr \
Expand Down
2 changes: 1 addition & 1 deletion eigrpd/eigrp_cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,7 @@ static int eigrp_write_interface(struct vty *vty)

RB_FOREACH(vrf, vrf_name_head, &vrfs_by_name) {
FOR_ALL_INTERFACES(vrf, ifp) {
dnode = yang_dnode_get(
dnode = yang_dnode_getf(
running_config->dnode,
"/frr-interface:lib/interface[name='%s'][vrf='%s']",
ifp->name, vrf->name);
Expand Down
2 changes: 1 addition & 1 deletion isisd/isis_circuit.c
Original file line number Diff line number Diff line change
Expand Up @@ -1330,7 +1330,7 @@ static int isis_interface_config_write(struct vty *vty)

FOR_ALL_INTERFACES (vrf, ifp) {
struct lyd_node *dnode;
dnode = yang_dnode_get(
dnode = yang_dnode_getf(
running_config->dnode,
"/frr-interface:lib/interface[name='%s'][vrf='%s']",
ifp->name, vrf->name);
Expand Down
Loading

0 comments on commit 01316ad

Please sign in to comment.