Skip to content

Commit

Permalink
Merge pull request #14911 from LabNConsulting/chopps/speed-xpath-up
Browse files Browse the repository at this point in the history
lib: all: remove './' from xpath 22% speedup
  • Loading branch information
idryzhov authored Dec 1, 2023
2 parents 05567ba + 2c01083 commit aa6934b
Show file tree
Hide file tree
Showing 33 changed files with 534 additions and 534 deletions.
12 changes: 6 additions & 6 deletions bfdd/bfdd_cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -219,24 +219,24 @@ static void _bfd_cli_show_peer(struct vty *vty, const struct lyd_node *dnode,
bool show_defaults __attribute__((__unused__)),
bool mhop)
{
const char *vrf = yang_dnode_get_string(dnode, "./vrf");
const char *vrf = yang_dnode_get_string(dnode, "vrf");

vty_out(vty, " peer %s",
yang_dnode_get_string(dnode, "./dest-addr"));
yang_dnode_get_string(dnode, "dest-addr"));

if (mhop)
vty_out(vty, " multihop");

if (yang_dnode_exists(dnode, "./source-addr"))
if (yang_dnode_exists(dnode, "source-addr"))
vty_out(vty, " local-address %s",
yang_dnode_get_string(dnode, "./source-addr"));
yang_dnode_get_string(dnode, "source-addr"));

if (strcmp(vrf, VRF_DEFAULT_NAME))
vty_out(vty, " vrf %s", vrf);

if (!mhop) {
const char *ifname =
yang_dnode_get_string(dnode, "./interface");
yang_dnode_get_string(dnode, "interface");
if (strcmp(ifname, "*"))
vty_out(vty, " interface %s", ifname);
}
Expand Down Expand Up @@ -567,7 +567,7 @@ DEFPY_YANG(no_bfd_profile, no_bfd_profile_cmd,
void bfd_cli_show_profile(struct vty *vty, const struct lyd_node *dnode,
bool show_defaults)
{
vty_out(vty, " profile %s\n", yang_dnode_get_string(dnode, "./name"));
vty_out(vty, " profile %s\n", yang_dnode_get_string(dnode, "name"));
}

ALIAS_YANG(bfd_peer_mult, bfd_profile_mult_cmd,
Expand Down
22 changes: 11 additions & 11 deletions bfdd/bfdd_nb_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@ static void bfd_session_get_key(bool mhop, const struct lyd_node *dnode,
struct sockaddr_any psa, lsa;

/* Required destination parameter. */
strtosa(yang_dnode_get_string(dnode, "./dest-addr"), &psa);
strtosa(yang_dnode_get_string(dnode, "dest-addr"), &psa);

/* Get optional source address. */
memset(&lsa, 0, sizeof(lsa));
if (yang_dnode_exists(dnode, "./source-addr"))
strtosa(yang_dnode_get_string(dnode, "./source-addr"), &lsa);
if (yang_dnode_exists(dnode, "source-addr"))
strtosa(yang_dnode_get_string(dnode, "source-addr"), &lsa);

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

if (!mhop) {
ifname = yang_dnode_get_string(dnode, "./interface");
ifname = yang_dnode_get_string(dnode, "interface");
if (strcmp(ifname, "*") == 0)
ifname = NULL;
}
Expand All @@ -53,7 +53,7 @@ static int session_iter_cb(const struct lyd_node *dnode, void *arg)
struct session_iter *iter = arg;
const char *ifname;

ifname = yang_dnode_get_string(dnode, "./interface");
ifname = yang_dnode_get_string(dnode, "interface");

if (strmatch(ifname, "*"))
iter->wildcard = true;
Expand All @@ -76,7 +76,7 @@ static int bfd_session_create(struct nb_cb_create_args *args, bool mhop)

switch (args->event) {
case NB_EV_VALIDATE:
yang_dnode_get_prefix(&p, args->dnode, "./dest-addr");
yang_dnode_get_prefix(&p, args->dnode, "dest-addr");

if (mhop) {
/*
Expand All @@ -97,7 +97,7 @@ static int bfd_session_create(struct nb_cb_create_args *args, bool mhop)
* require interface name, otherwise we can't figure
* which interface to use to send the packets.
*/
ifname = yang_dnode_get_string(args->dnode, "./interface");
ifname = yang_dnode_get_string(args->dnode, "interface");

if (p.family == AF_INET6 && IN6_IS_ADDR_LINKLOCAL(&p.u.prefix6)
&& strcmp(ifname, "*") == 0) {
Expand All @@ -112,8 +112,8 @@ static int bfd_session_create(struct nb_cb_create_args *args, bool mhop)

sess_dnode = yang_dnode_get_parent(args->dnode, "sessions");

dest = yang_dnode_get_string(args->dnode, "./dest-addr");
vrfname = yang_dnode_get_string(args->dnode, "./vrf");
dest = yang_dnode_get_string(args->dnode, "dest-addr");
vrfname = yang_dnode_get_string(args->dnode, "vrf");

yang_dnode_iterate(session_iter_cb, &iter, sess_dnode,
"./single-hop[dest-addr='%s'][vrf='%s']",
Expand Down Expand Up @@ -275,7 +275,7 @@ int bfdd_bfd_profile_create(struct nb_cb_create_args *args)
if (args->event != NB_EV_APPLY)
return NB_OK;

name = yang_dnode_get_string(args->dnode, "./name");
name = yang_dnode_get_string(args->dnode, "name");
bp = bfd_profile_new(name);
nb_running_set_entry(args->dnode, bp);

Expand Down
18 changes: 9 additions & 9 deletions bgpd/bgp_routemap_nb_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -1135,14 +1135,14 @@ lib_route_map_entry_match_condition_rmap_match_condition_comm_list_finish(

/* Add configuration. */
rhc = nb_running_get_entry(args->dnode, NULL, true);
value = yang_dnode_get_string(args->dnode, "./comm-list-name");
value = yang_dnode_get_string(args->dnode, "comm-list-name");

if (yang_dnode_exists(args->dnode, "./comm-list-name-exact-match"))
if (yang_dnode_exists(args->dnode, "comm-list-name-exact-match"))
exact_match = yang_dnode_get_bool(
args->dnode, "./comm-list-name-exact-match");

if (yang_dnode_exists(args->dnode, "./comm-list-name-any"))
any = yang_dnode_get_bool(args->dnode, "./comm-list-name-any");
if (yang_dnode_exists(args->dnode, "comm-list-name-any"))
any = yang_dnode_get_bool(args->dnode, "comm-list-name-any");

if (exact_match) {
argstr = XMALLOC(MTYPE_ROUTE_MAP_COMPILED,
Expand Down Expand Up @@ -2745,8 +2745,8 @@ void lib_route_map_entry_set_action_rmap_set_action_aggregator_finish(

/* Add configuration. */
rhc = nb_running_get_entry(args->dnode, NULL, true);
asn = yang_dnode_get_string(args->dnode, "./aggregator-asn");
addr = yang_dnode_get_string(args->dnode, "./aggregator-address");
asn = yang_dnode_get_string(args->dnode, "aggregator-asn");
addr = yang_dnode_get_string(args->dnode, "aggregator-address");

argstr = XMALLOC(MTYPE_ROUTE_MAP_COMPILED,
strlen(asn) + strlen(addr) + 2);
Expand Down Expand Up @@ -2929,7 +2929,7 @@ lib_route_map_entry_set_action_rmap_set_action_extcommunity_lb_finish(

/* Add configuration. */
rhc = nb_running_get_entry(args->dnode, NULL, true);
lb_type = yang_dnode_get_enum(args->dnode, "./lb-type");
lb_type = yang_dnode_get_enum(args->dnode, "lb-type");

/* Set destroy information. */
rhc->rhc_shook = generic_set_delete;
Expand All @@ -2938,7 +2938,7 @@ lib_route_map_entry_set_action_rmap_set_action_extcommunity_lb_finish(

switch (lb_type) {
case EXPLICIT_BANDWIDTH:
bandwidth = yang_dnode_get_uint16(args->dnode, "./bandwidth");
bandwidth = yang_dnode_get_uint16(args->dnode, "bandwidth");
snprintf(str, sizeof(str), "%d", bandwidth);
break;
case CUMULATIVE_BANDWIDTH:
Expand All @@ -2948,7 +2948,7 @@ lib_route_map_entry_set_action_rmap_set_action_extcommunity_lb_finish(
snprintf(str, sizeof(str), "%s", "num-multipaths");
}

if (yang_dnode_get_bool(args->dnode, "./two-octet-as-specific"))
if (yang_dnode_get_bool(args->dnode, "two-octet-as-specific"))
strlcat(str, " non-transitive", sizeof(str));

ret = generic_set_add(rhc->rhc_rmi, "extcommunity bandwidth", str,
Expand Down
56 changes: 28 additions & 28 deletions eigrpd/eigrp_cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ DEFPY_YANG(
void eigrp_cli_show_header(struct vty *vty, const struct lyd_node *dnode,
bool show_defaults)
{
const char *asn = yang_dnode_get_string(dnode, "./asn");
const char *vrf = yang_dnode_get_string(dnode, "./vrf");
const char *asn = yang_dnode_get_string(dnode, "asn");
const char *vrf = yang_dnode_get_string(dnode, "vrf");

vty_out(vty, "router eigrp %s", asn);
if (strcmp(vrf, VRF_DEFAULT_NAME))
Expand Down Expand Up @@ -323,18 +323,18 @@ void eigrp_cli_show_metrics(struct vty *vty, const struct lyd_node *dnode,
{
const char *k1, *k2, *k3, *k4, *k5, *k6;

k1 = yang_dnode_exists(dnode, "./K1") ?
yang_dnode_get_string(dnode, "./K1") : "0";
k2 = yang_dnode_exists(dnode, "./K2") ?
yang_dnode_get_string(dnode, "./K2") : "0";
k3 = yang_dnode_exists(dnode, "./K3") ?
yang_dnode_get_string(dnode, "./K3") : "0";
k4 = yang_dnode_exists(dnode, "./K4") ?
yang_dnode_get_string(dnode, "./K4") : "0";
k5 = yang_dnode_exists(dnode, "./K5") ?
yang_dnode_get_string(dnode, "./K5") : "0";
k6 = yang_dnode_exists(dnode, "./K6") ?
yang_dnode_get_string(dnode, "./K6") : "0";
k1 = yang_dnode_exists(dnode, "K1") ?
yang_dnode_get_string(dnode, "K1") : "0";
k2 = yang_dnode_exists(dnode, "K2") ?
yang_dnode_get_string(dnode, "K2") : "0";
k3 = yang_dnode_exists(dnode, "K3") ?
yang_dnode_get_string(dnode, "K3") : "0";
k4 = yang_dnode_exists(dnode, "K4") ?
yang_dnode_get_string(dnode, "K4") : "0";
k5 = yang_dnode_exists(dnode, "K5") ?
yang_dnode_get_string(dnode, "K5") : "0";
k6 = yang_dnode_exists(dnode, "K6") ?
yang_dnode_get_string(dnode, "K6") : "0";

vty_out(vty, " metric weights %s %s %s %s %s",
k1, k2, k3, k4, k5);
Expand Down Expand Up @@ -456,19 +456,19 @@ DEFPY_YANG(
void eigrp_cli_show_redistribute(struct vty *vty, const struct lyd_node *dnode,
bool show_defaults)
{
const char *proto = yang_dnode_get_string(dnode, "./protocol");
const char *proto = yang_dnode_get_string(dnode, "protocol");
const char *bw, *delay, *load, *mtu, *rlbt;

bw = yang_dnode_exists(dnode, "./metrics/bandwidth") ?
yang_dnode_get_string(dnode, "./metrics/bandwidth") : NULL;
delay = yang_dnode_exists(dnode, "./metrics/delay") ?
yang_dnode_get_string(dnode, "./metrics/delay") : NULL;
rlbt = yang_dnode_exists(dnode, "./metrics/reliability") ?
yang_dnode_get_string(dnode, "./metrics/reliability") : NULL;
load = yang_dnode_exists(dnode, "./metrics/load") ?
yang_dnode_get_string(dnode, "./metrics/load") : NULL;
mtu = yang_dnode_exists(dnode, "./metrics/mtu") ?
yang_dnode_get_string(dnode, "./metrics/mtu") : NULL;
bw = yang_dnode_exists(dnode, "metrics/bandwidth") ?
yang_dnode_get_string(dnode, "metrics/bandwidth") : NULL;
delay = yang_dnode_exists(dnode, "metrics/delay") ?
yang_dnode_get_string(dnode, "metrics/delay") : NULL;
rlbt = yang_dnode_exists(dnode, "metrics/reliability") ?
yang_dnode_get_string(dnode, "metrics/reliability") : NULL;
load = yang_dnode_exists(dnode, "metrics/load") ?
yang_dnode_get_string(dnode, "metrics/load") : NULL;
mtu = yang_dnode_exists(dnode, "metrics/mtu") ?
yang_dnode_get_string(dnode, "metrics/mtu") : NULL;

vty_out(vty, " redistribute %s", proto);
if (bw || rlbt || delay || load || mtu)
Expand Down Expand Up @@ -693,7 +693,7 @@ void eigrp_cli_show_summarize_address(struct vty *vty,
{
const struct lyd_node *instance =
yang_dnode_get_parent(dnode, "instance");
uint16_t asn = yang_dnode_get_uint16(instance, "./asn");
uint16_t asn = yang_dnode_get_uint16(instance, "asn");
const char *summarize_address = yang_dnode_get_string(dnode, NULL);

vty_out(vty, " ip summary-address eigrp %d %s\n", asn,
Expand Down Expand Up @@ -759,7 +759,7 @@ void eigrp_cli_show_authentication(struct vty *vty,
{
const struct lyd_node *instance =
yang_dnode_get_parent(dnode, "instance");
uint16_t asn = yang_dnode_get_uint16(instance, "./asn");
uint16_t asn = yang_dnode_get_uint16(instance, "asn");
const char *crypt = yang_dnode_get_string(dnode, NULL);

vty_out(vty, " ip authentication mode eigrp %d %s\n", asn, crypt);
Expand Down Expand Up @@ -819,7 +819,7 @@ void eigrp_cli_show_keychain(struct vty *vty, const struct lyd_node *dnode,
{
const struct lyd_node *instance =
yang_dnode_get_parent(dnode, "instance");
uint16_t asn = yang_dnode_get_uint16(instance, "./asn");
uint16_t asn = yang_dnode_get_uint16(instance, "asn");
const char *keychain = yang_dnode_get_string(dnode, NULL);

vty_out(vty, " ip authentication key-chain eigrp %d %s\n", asn,
Expand Down
34 changes: 17 additions & 17 deletions eigrpd/eigrp_northbound.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,18 @@ static void redistribute_get_metrics(const struct lyd_node *dnode,
{
memset(em, 0, sizeof(*em));

if (yang_dnode_exists(dnode, "./bandwidth"))
em->bandwidth = yang_dnode_get_uint32(dnode, "./bandwidth");
if (yang_dnode_exists(dnode, "./delay"))
em->delay = yang_dnode_get_uint32(dnode, "./delay");
if (yang_dnode_exists(dnode, "bandwidth"))
em->bandwidth = yang_dnode_get_uint32(dnode, "bandwidth");
if (yang_dnode_exists(dnode, "delay"))
em->delay = yang_dnode_get_uint32(dnode, "delay");
#if 0 /* TODO: How does MTU work? */
if (yang_dnode_exists(dnode, "./mtu"))
em->mtu[0] = yang_dnode_get_uint32(dnode, "./mtu");
if (yang_dnode_exists(dnode, "mtu"))
em->mtu[0] = yang_dnode_get_uint32(dnode, "mtu");
#endif
if (yang_dnode_exists(dnode, "./load"))
em->load = yang_dnode_get_uint32(dnode, "./load");
if (yang_dnode_exists(dnode, "./reliability"))
em->reliability = yang_dnode_get_uint32(dnode, "./reliability");
if (yang_dnode_exists(dnode, "load"))
em->load = yang_dnode_get_uint32(dnode, "load");
if (yang_dnode_exists(dnode, "reliability"))
em->reliability = yang_dnode_get_uint32(dnode, "reliability");
}

static struct eigrp_interface *eigrp_interface_lookup(const struct eigrp *eigrp,
Expand Down Expand Up @@ -73,15 +73,15 @@ static int eigrpd_instance_create(struct nb_cb_create_args *args)
/* NOTHING */
break;
case NB_EV_PREPARE:
vrf = yang_dnode_get_string(args->dnode, "./vrf");
vrf = yang_dnode_get_string(args->dnode, "vrf");

pVrf = vrf_lookup_by_name(vrf);
if (pVrf)
vrfid = pVrf->vrf_id;
else
vrfid = VRF_DEFAULT;

eigrp = eigrp_get(yang_dnode_get_uint16(args->dnode, "./asn"),
eigrp = eigrp_get(yang_dnode_get_uint16(args->dnode, "asn"),
vrfid);
args->resource->ptr = eigrp;
break;
Expand Down Expand Up @@ -715,7 +715,7 @@ static int eigrpd_instance_redistribute_create(struct nb_cb_create_args *args)

switch (args->event) {
case NB_EV_VALIDATE:
proto = yang_dnode_get_enum(args->dnode, "./protocol");
proto = yang_dnode_get_enum(args->dnode, "protocol");
vrfname = yang_dnode_get_string(args->dnode, "../vrf");

pVrf = vrf_lookup_by_name(vrfname);
Expand All @@ -733,7 +733,7 @@ static int eigrpd_instance_redistribute_create(struct nb_cb_create_args *args)
break;
case NB_EV_APPLY:
eigrp = nb_running_get_entry(args->dnode, NULL, true);
proto = yang_dnode_get_enum(args->dnode, "./protocol");
proto = yang_dnode_get_enum(args->dnode, "protocol");
redistribute_get_metrics(args->dnode, &metrics);
eigrp_redistribute_set(eigrp, proto, metrics);
break;
Expand All @@ -755,7 +755,7 @@ static int eigrpd_instance_redistribute_destroy(struct nb_cb_destroy_args *args)
break;
case NB_EV_APPLY:
eigrp = nb_running_get_entry(args->dnode, NULL, true);
proto = yang_dnode_get_enum(args->dnode, "./protocol");
proto = yang_dnode_get_enum(args->dnode, "protocol");
eigrp_redistribute_unset(eigrp, proto);
break;
}
Expand Down Expand Up @@ -1120,7 +1120,7 @@ static int lib_interface_eigrp_instance_create(struct nb_cb_create_args *args)
break;
}

eigrp = eigrp_get(yang_dnode_get_uint16(args->dnode, "./asn"),
eigrp = eigrp_get(yang_dnode_get_uint16(args->dnode, "asn"),
ifp->vrf->vrf_id);
eif = eigrp_interface_lookup(eigrp, ifp->name);
if (eif == NULL)
Expand All @@ -1132,7 +1132,7 @@ static int lib_interface_eigrp_instance_create(struct nb_cb_create_args *args)
break;
case NB_EV_APPLY:
ifp = nb_running_get_entry(args->dnode, NULL, true);
eigrp = eigrp_get(yang_dnode_get_uint16(args->dnode, "./asn"),
eigrp = eigrp_get(yang_dnode_get_uint16(args->dnode, "asn"),
ifp->vrf->vrf_id);
eif = eigrp_interface_lookup(eigrp, ifp->name);
if (eif == NULL)
Expand Down
Loading

0 comments on commit aa6934b

Please sign in to comment.