diff options
author | Martin Winter <mwinter@opensourcerouting.org> | 2021-05-14 01:12:06 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-14 01:12:06 +0200 |
commit | d8baf3db2d559fc13b3137ba9e3c6fa998f7e773 (patch) | |
tree | 7bb01bcf098421c5bdef61b932309ebfc9d8b9ad /bgpd | |
parent | Merge pull request #8658 from gromit1811/bugfix_8567 (diff) | |
parent | lib: adapt to version 2 of libyang (diff) | |
download | frr-d8baf3db2d559fc13b3137ba9e3c6fa998f7e773.tar.xz frr-d8baf3db2d559fc13b3137ba9e3c6fa998f7e773.zip |
Merge pull request #8144 from LabNConsulting/chopps/ly2
libyang2
Diffstat (limited to 'bgpd')
-rw-r--r-- | bgpd/bgp_nb.c | 3 | ||||
-rw-r--r-- | bgpd/bgp_nb.h | 6 | ||||
-rw-r--r-- | bgpd/bgp_nb_config.c | 62 | ||||
-rw-r--r-- | bgpd/bgp_vty.c | 48 | ||||
-rw-r--r-- | bgpd/subdir.am | 4 |
5 files changed, 32 insertions, 91 deletions
diff --git a/bgpd/bgp_nb.c b/bgpd/bgp_nb.c index 21810b634..71824cd6d 100644 --- a/bgpd/bgp_nb.c +++ b/bgpd/bgp_nb.c @@ -632,7 +632,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, } }, { @@ -923,7 +922,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, } }, { @@ -1215,7 +1213,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, } }, { diff --git a/bgpd/bgp_nb.h b/bgpd/bgp_nb.h index 57f379b6c..f8bb31aad 100644 --- a/bgpd/bgp_nb.h +++ b/bgpd/bgp_nb.h @@ -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( @@ -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( @@ -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( diff --git a/bgpd/bgp_nb_config.c b/bgpd/bgp_nb_config.c index 8ca7836a9..a430124b5 100644 --- a/bgpd/bgp_nb_config.c +++ b/bgpd/bgp_nb_config.c @@ -239,8 +239,8 @@ int bgp_global_local_as_modify(struct nb_cb_modify_args *args) * If the instance already exists - return the validation * error. */ - bgp = nb_running_get_entry_non_rec(args->dnode->parent->parent, - NULL, false); + bgp = nb_running_get_entry_non_rec( + lyd_parent(lyd_parent(args->dnode)), NULL, false); if (bgp) { snprintf(args->errmsg, args->errmsg_len, "Changing AS number is not allowed"); @@ -580,16 +580,11 @@ int bgp_global_route_reflector_route_reflector_cluster_id_modify( struct bgp *bgp; struct in_addr cluster_id; - const struct lyd_node_leaf_list *dleaf; bgp = nb_running_get_entry(args->dnode, NULL, true); - dleaf = (const struct lyd_node_leaf_list *)args->dnode; - if (dleaf->value_type == LY_TYPE_STRING) - yang_dnode_get_ipv4(&cluster_id, args->dnode, NULL); - else - (void)inet_aton(dleaf->value_str, &cluster_id); - + /* cluster-id is either dotted-quad or a uint32 */ + (void)inet_aton(lyd_get_value(args->dnode), &cluster_id); bgp_cluster_id_set(bgp, &cluster_id); if (bgp_clear_star_soft_out(bgp->name, args->errmsg, args->errmsg_len)) @@ -1495,8 +1490,8 @@ int bgp_global_instance_type_view_modify(struct nb_cb_modify_args *args) * If the instance already exists - return the validation * error. */ - bgp = nb_running_get_entry_non_rec(args->dnode->parent->parent, - NULL, false); + bgp = nb_running_get_entry_non_rec( + lyd_parent(lyd_parent(args->dnode)), NULL, false); if (bgp) { snprintf(args->errmsg, args->errmsg_len, "Changing instance type is not allowed"); @@ -3560,21 +3555,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 @@ -5576,21 +5556,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 @@ -7493,21 +7458,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 diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 5b5f166e4..9be614ad6 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -4372,12 +4372,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, ""); @@ -4648,8 +4648,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 { @@ -4659,12 +4659,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, @@ -4740,11 +4740,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"); @@ -7036,8 +7036,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 : ""); @@ -7056,14 +7056,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 : ""); @@ -8085,7 +8085,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)) { diff --git a/bgpd/subdir.am b/bgpd/subdir.am index b54c41cab..53225192f 100644 --- a/bgpd/subdir.am +++ b/bgpd/subdir.am @@ -214,8 +214,8 @@ bgpd_bgpd_SOURCES = bgpd/bgp_main.c bgpd_bgp_btoa_SOURCES = bgpd/bgp_btoa.c # RFPLDADD is set in bgpd/rfp-example/librfp/subdir.am -bgpd_bgpd_LDADD = bgpd/libbgp.a $(RFPLDADD) lib/libfrr.la $(LIBCAP) $(LIBM) $(UST_LIBS) -bgpd_bgp_btoa_LDADD = bgpd/libbgp.a $(RFPLDADD) lib/libfrr.la $(LIBCAP) $(LIBM) $(UST_LIBS) +bgpd_bgpd_LDADD = bgpd/libbgp.a $(RFPLDADD) lib/libfrr.la $(LIBYANG_LIBS) $(LIBCAP) $(LIBM) $(UST_LIBS) +bgpd_bgp_btoa_LDADD = bgpd/libbgp.a $(RFPLDADD) lib/libfrr.la $(LIBYANG_LIBS) $(LIBCAP) $(LIBM) $(UST_LIBS) bgpd_bgpd_snmp_la_SOURCES = bgpd/bgp_snmp.c bgpd/bgp_mplsvpn_snmp.c bgpd_bgpd_snmp_la_CFLAGS = $(AM_CFLAGS) $(SNMP_CFLAGS) -std=gnu11 |