diff options
| -rw-r--r-- | bgpd/bgpd.c | 4 | ||||
| -rw-r--r-- | doc/developer/scripting.rst | 6 | ||||
| -rw-r--r-- | doc/user/bgp.rst | 4 | ||||
| -rw-r--r-- | doc/user/pathd.rst | 3 | ||||
| -rw-r--r-- | lib/command.h | 1 | ||||
| -rw-r--r-- | lib/frrlua.c | 41 | ||||
| -rw-r--r-- | lib/frrlua.h | 26 | ||||
| -rw-r--r-- | lib/frrscript.c | 2 | ||||
| -rw-r--r-- | lib/frrscript.h | 21 | ||||
| -rw-r--r-- | lib/northbound.c | 4 | ||||
| -rw-r--r-- | mgmtd/mgmt_main.c | 9 | ||||
| -rw-r--r-- | mgmtd/mgmt_vty.c | 19 | ||||
| -rw-r--r-- | pathd/path_pcep_cli.c | 19 | ||||
| -rw-r--r-- | staticd/static_nb.c | 15 | ||||
| -rw-r--r-- | staticd/static_vrf.c | 16 | ||||
| -rw-r--r-- | staticd/static_vty.c | 91 | ||||
| -rw-r--r-- | staticd/static_vty.h | 16 | ||||
| -rw-r--r-- | tests/lib/test_frrlua.c | 12 | ||||
| -rw-r--r-- | tests/lib/test_frrscript.c | 4 | ||||
| -rw-r--r-- | zebra/zebra_router.c | 6 | ||||
| -rw-r--r-- | zebra/zebra_tc.c | 23 | ||||
| -rw-r--r-- | zebra/zebra_tc.h | 3 |
22 files changed, 217 insertions, 128 deletions
diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index 3c1f223228..4fa021ab93 100644 --- a/bgpd/bgpd.c +++ b/bgpd/bgpd.c @@ -4062,10 +4062,14 @@ void bgp_free(struct bgp *bgp) bgp_srv6_cleanup(bgp); bgp_confederation_id_unset(bgp); + for (int i = 0; i < bgp->confed_peers_cnt; i++) + XFREE(MTYPE_BGP_NAME, bgp->confed_peers[i].as_pretty); + XFREE(MTYPE_BGP_NAME, bgp->as_pretty); XFREE(MTYPE_BGP_NAME, bgp->name); XFREE(MTYPE_BGP_NAME, bgp->name_pretty); XFREE(MTYPE_BGP_NAME, bgp->snmp_stats); + XFREE(MTYPE_BGP_CONFED_LIST, bgp->confed_peers); XFREE(MTYPE_BGP, bgp); } diff --git a/doc/developer/scripting.rst b/doc/developer/scripting.rst index 202f0036f8..7a43314490 100644 --- a/doc/developer/scripting.rst +++ b/doc/developer/scripting.rst @@ -488,12 +488,6 @@ match *exactly*. In the above example, we defined encoders/decoders for a value of ``struct prefix *``, but not ``struct prefix`` or ``const struct prefix *``. -``const`` values are a special case. We want to use them in our Lua scripts -but not modify them, so creating a decoder for them would be meaningless. -But we still need a decoder for the type of value so that the compiler will be -satisfied. -For that, use ``lua_decode_noop``: - .. code-block:: diff #define DECODE_ARGS_WITH_STATE(L, value) \ diff --git a/doc/user/bgp.rst b/doc/user/bgp.rst index 2171c9e99a..465d759e13 100644 --- a/doc/user/bgp.rst +++ b/doc/user/bgp.rst @@ -3060,11 +3060,11 @@ address-family: access-list acl2 permit 192.0.3.0/24 route-map rmap permit 10 match address acl1 - set extcommunity ty 65001:10 + set extcommunity rt 65001:10 ! route-map rmap permit 20 match address acl1 - set extcommunity ty 65001:20 + set extcommunity rt 65001:20 ! router bgp 65001 vrf vrf1 ! diff --git a/doc/user/pathd.rst b/doc/user/pathd.rst index ec107fbe47..fb238100a1 100644 --- a/doc/user/pathd.rst +++ b/doc/user/pathd.rst @@ -475,6 +475,9 @@ Configuration Commands Specify the maximum SID depth in a PCC definition. +.. clicmd:: no msd [(1-32)] + + Default the maximum SID depth to 4. .. clicmd:: peer WORD [precedence (1-255)] diff --git a/lib/command.h b/lib/command.h index 8b2dee17ea..30982c4fe9 100644 --- a/lib/command.h +++ b/lib/command.h @@ -176,6 +176,7 @@ enum node_type { BMP_NODE, /* BMP config under router bgp */ ISIS_SRV6_NODE, /* ISIS SRv6 node */ ISIS_SRV6_NODE_MSD_NODE, /* ISIS SRv6 Node MSDs node */ + MGMTD_NODE, /* MGMTD node. */ NODE_TYPE_MAX, /* maximum */ }; /* clang-format on */ diff --git a/lib/frrlua.c b/lib/frrlua.c index e626efe20b..2cab1a5460 100644 --- a/lib/frrlua.c +++ b/lib/frrlua.c @@ -259,12 +259,12 @@ void *lua_tosockunion(lua_State *L, int idx) return su; } -void lua_pushintegerp(lua_State *L, const long long *num) +void lua_pushintegerp(lua_State *L, const int *num) { lua_pushinteger(L, *num); } -void lua_decode_integerp(lua_State *L, int idx, long long *num) +void lua_decode_integerp(lua_State *L, int idx, int *num) { int isnum; *num = lua_tonumberx(L, idx, &isnum); @@ -274,7 +274,7 @@ void lua_decode_integerp(lua_State *L, int idx, long long *num) void *lua_tointegerp(lua_State *L, int idx) { - long long *num = XCALLOC(MTYPE_SCRIPT_RES, sizeof(long long)); + int *num = XCALLOC(MTYPE_SCRIPT_RES, sizeof(int)); lua_decode_integerp(L, idx, num); return num; @@ -332,32 +332,39 @@ void lua_pushnexthop_group(lua_State *L, const struct nexthop_group *ng) } } -void lua_decode_stringp(lua_State *L, int idx, char *str) +void lua_pushlonglongp(lua_State *L, const long long *num) { - strlcpy(str, lua_tostring(L, idx), strlen(str) + 1); + /* lua library function; this can take a long long */ + lua_pushinteger(L, *num); +} + +void lua_decode_longlongp(lua_State *L, int idx, long long *num) +{ + int isnum; + *num = lua_tonumberx(L, idx, &isnum); lua_pop(L, 1); + assert(isnum); } -void *lua_tostringp(lua_State *L, int idx) +void *lua_tolonglongp(lua_State *L, int idx) { - char *string = XSTRDUP(MTYPE_SCRIPT_RES, lua_tostring(L, idx)); + long long *num = XCALLOC(MTYPE_SCRIPT_RES, sizeof(long long)); - return string; + lua_decode_longlongp(L, idx, num); + return num; } -/* - * Decoder for const values, since we cannot modify them. - */ -void lua_decode_noop(lua_State *L, int idx, const void *ptr) +void lua_decode_stringp(lua_State *L, int idx, char *str) { + strlcpy(str, lua_tostring(L, idx), strlen(str) + 1); + lua_pop(L, 1); } - -/* - * Noop decoder for int. - */ -void lua_decode_integer_noop(lua_State *L, int idx, int i) +void *lua_tostringp(lua_State *L, int idx) { + char *string = XSTRDUP(MTYPE_SCRIPT_RES, lua_tostring(L, idx)); + + return string; } /* diff --git a/lib/frrlua.h b/lib/frrlua.h index d248312d62..dc0f4d9986 100644 --- a/lib/frrlua.h +++ b/lib/frrlua.h @@ -121,9 +121,9 @@ void lua_pushnexthop(lua_State *L, const struct nexthop *nexthop); /* * Converts an int to a Lua value and pushes it on the stack. */ -void lua_pushintegerp(lua_State *L, const long long *num); +void lua_pushintegerp(lua_State *L, const int *num); -void lua_decode_integerp(lua_State *L, int idx, long long *num); +void lua_decode_integerp(lua_State *L, int idx, int *num); /* * Converts the Lua value at idx to an int. @@ -133,6 +133,21 @@ void lua_decode_integerp(lua_State *L, int idx, long long *num); */ void *lua_tointegerp(lua_State *L, int idx); +/* + * Converts a long long to a Lua value and pushes it on the stack. + */ +void lua_pushlonglongp(lua_State *L, const long long *num); + +void lua_decode_longlongp(lua_State *L, int idx, long long *num); + +/* + * Converts the Lua value at idx to a long long. + * + * Returns: + * long long allocated with MTYPE_TMP. + */ +void *lua_tolonglongp(lua_State *L, int idx); + void lua_decode_stringp(lua_State *L, int idx, char *str); /* @@ -144,13 +159,6 @@ void lua_decode_stringp(lua_State *L, int idx, char *str); void *lua_tostringp(lua_State *L, int idx); /* - * No-op decoders - */ -void lua_decode_noop(lua_State *L, int idx, const void *ptr); - -void lua_decode_integer_noop(lua_State *L, int idx, int i); - -/* * Retrieve an integer from table on the top of the stack. * * key diff --git a/lib/frrscript.c b/lib/frrscript.c index 50410fb58b..acdd1df67b 100644 --- a/lib/frrscript.c +++ b/lib/frrscript.c @@ -25,6 +25,8 @@ DEFINE_MTYPE_STATIC(LIB, SCRIPT, "Scripting"); struct frrscript_names_head frrscript_names_hash; +void _lua_decode_noop(lua_State *L, ...) {} + /* * Wrapper for frrscript_names_add * Use this to register hook calls when a daemon starts up diff --git a/lib/frrscript.h b/lib/frrscript.h index df49b5718c..ce313a1b63 100644 --- a/lib/frrscript.h +++ b/lib/frrscript.h @@ -181,6 +181,11 @@ void frrscript_fini(void); } while (0) /* + * Noop function. Used below where we need a noop decoder for any type. + */ +void _lua_decode_noop(lua_State *, ...); + +/* * Maps the type of value to its encoder/decoder. * Add new mappings here. * @@ -192,7 +197,9 @@ void frrscript_fini(void); #define ENCODE_ARGS_WITH_STATE(L, value) \ _Generic((value), \ int : lua_pushinteger, \ -long long * : lua_pushintegerp, \ +int * : lua_pushintegerp, \ +long long : lua_pushinteger, \ +long long * : lua_pushlonglongp, \ struct prefix * : lua_pushprefix, \ struct interface * : lua_pushinterface, \ struct in_addr * : lua_pushinaddr, \ @@ -211,8 +218,8 @@ struct zebra_dplane_ctx * : lua_pushzebra_dplane_ctx \ #define DECODE_ARGS_WITH_STATE(L, value) \ _Generic((value), \ -int : lua_decode_integer_noop, \ -long long * : lua_decode_integerp, \ +int * : lua_decode_integerp, \ +long long * : lua_decode_longlongp, \ struct prefix * : lua_decode_prefix, \ struct interface * : lua_decode_interface, \ struct in_addr * : lua_decode_inaddr, \ @@ -220,13 +227,7 @@ struct in6_addr * : lua_decode_in6addr, \ union sockunion * : lua_decode_sockunion, \ char * : lua_decode_stringp, \ struct attr * : lua_decode_attr, \ -struct peer * : lua_decode_noop, \ -const struct prefix * : lua_decode_noop, \ -const struct ipaddr * : lua_decode_noop, \ -const struct ethaddr * : lua_decode_noop, \ -const struct nexthop_group * : lua_decode_noop, \ -const struct nexthop * : lua_decode_noop, \ -struct zebra_dplane_ctx * : lua_decode_noop \ +default : _lua_decode_noop \ )((L), -1, (value)) /* diff --git a/lib/northbound.c b/lib/northbound.c index 88aa2a5f20..32988dfc15 100644 --- a/lib/northbound.c +++ b/lib/northbound.c @@ -2575,10 +2575,6 @@ const char *nb_client_name(enum nb_client client) static void nb_load_callbacks(const struct frr_yang_module_info *module) { - - if (module->ignore_cbs) - return; - for (size_t i = 0; module->nodes[i].xpath; i++) { struct nb_node *nb_node; uint32_t priority; diff --git a/mgmtd/mgmt_main.c b/mgmtd/mgmt_main.c index 39362fa74a..b58b93c71d 100644 --- a/mgmtd/mgmt_main.c +++ b/mgmtd/mgmt_main.c @@ -185,6 +185,10 @@ static void mgmt_vrf_terminate(void) vrf_terminate(); } +#ifdef HAVE_STATICD +extern const struct frr_yang_module_info frr_staticd_info; +#endif + /* * List of YANG modules to be loaded in the process context of * MGMTd. @@ -201,11 +205,10 @@ static const struct frr_yang_module_info *const mgmt_yang_modules[] = { /* * YANG module info supported by backend clients get added here. * NOTE: Always set .ignore_cbs true for to avoid validating - * backend northbound callbacks during loading. + * backend configuration northbound callbacks during loading. */ #ifdef HAVE_STATICD - &(struct frr_yang_module_info){.name = "frr-staticd", - .ignore_cbs = true}, + &frr_staticd_info, #endif }; diff --git a/mgmtd/mgmt_vty.c b/mgmtd/mgmt_vty.c index a637898f8c..0f6df9f129 100644 --- a/mgmtd/mgmt_vty.c +++ b/mgmtd/mgmt_vty.c @@ -462,6 +462,24 @@ static void mgmt_config_read_in(struct event *event) } } +static int mgmtd_config_write(struct vty *vty) +{ + struct lyd_node *root; + + LY_LIST_FOR (running_config->dnode, root) { + nb_cli_show_dnode_cmds(vty, root, false); + } + + return 1; +} + +static struct cmd_node mgmtd_node = { + .name = "mgmtd", + .node = MGMTD_NODE, + .prompt = "", + .config_write = mgmtd_config_write, +}; + void mgmt_vty_init(void) { /* @@ -479,6 +497,7 @@ void mgmt_vty_init(void) &mgmt_daemon_info->read_in); install_node(&debug_node); + install_node(&mgmtd_node); install_element(VIEW_NODE, &show_mgmt_be_adapter_cmd); install_element(VIEW_NODE, &show_mgmt_be_xpath_reg_cmd); diff --git a/pathd/path_pcep_cli.c b/pathd/path_pcep_cli.c index ab61abc02d..f0c145c5d6 100644 --- a/pathd/path_pcep_cli.c +++ b/pathd/path_pcep_cli.c @@ -1026,7 +1026,7 @@ static int path_pcep_cli_pcc_pcc_msd(struct vty *vty, const char *msd_str, { if (reset) pcc_msd_configured_g = false; - else { + else if (msd_str) { pcc_msd_configured_g = true; PCEP_VTYSH_INT_ARG_CHECK(msd_str, msd, pcc_msd_g, 0, 33); } @@ -1706,7 +1706,7 @@ int pcep_cli_pce_config_write(struct vty *vty) &pce_opts->addr.ipaddr_v4); } if (pce_opts->port != PCEP_DEFAULT_PORT) { - vty_out(vty, " %s %d", PCEP_VTYSH_ARG_PORT, + vty_out(vty, " %s %d", PCEP_VTYSH_ARG_PORT, pce_opts->port); } vty_out(vty, "%s\n", buf); @@ -2043,12 +2043,22 @@ DEFPY(pcep_cli_no_pcc, DEFPY(pcep_cli_pcc_pcc_msd, pcep_cli_pcc_pcc_msd_cmd, - "[no] msd (1-32)", + "msd (1-32)", NO_STR "PCC maximum SID depth \n" "PCC maximum SID depth value\n") { - return path_pcep_cli_pcc_pcc_msd(vty, msd_str, msd, no); + return path_pcep_cli_pcc_pcc_msd(vty, msd_str, msd, false); +} + +DEFPY(no_pcep_cli_pcc_pcc_msd, + no_pcep_cli_pcc_pcc_msd_cmd, + "no msd [(1-32)]", + NO_STR + "PCC maximum SID depth \n" + "PCC maximum SID depth value\n") +{ + return path_pcep_cli_pcc_pcc_msd(vty, msd_str, msd, true); } DEFPY(pcep_cli_pcc_pcc_peer, @@ -2153,6 +2163,7 @@ void pcep_cli_init(void) install_element(PCEP_NODE, &pcep_cli_no_pcc_cmd); install_element(PCEP_PCC_NODE, &pcep_cli_pcc_pcc_peer_cmd); install_element(PCEP_PCC_NODE, &pcep_cli_pcc_pcc_msd_cmd); + install_element(PCEP_PCC_NODE, &no_pcep_cli_pcc_pcc_msd_cmd); /* Top commands */ install_element(CONFIG_NODE, &pcep_cli_debug_cmd); diff --git a/staticd/static_nb.c b/staticd/static_nb.c index 1c69a58035..e6aa71a77b 100644 --- a/staticd/static_nb.c +++ b/staticd/static_nb.c @@ -16,18 +16,10 @@ const struct frr_yang_module_info frr_staticd_info = { .name = "frr-staticd", .nodes = { { - .xpath = "/frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd", - .cbs = { - .cli_show = static_cli_show, - .cli_show_end = static_cli_show_end, - } - }, - { .xpath = "/frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list", .cbs = { .create = routing_control_plane_protocols_control_plane_protocol_staticd_route_list_create, .destroy = routing_control_plane_protocols_control_plane_protocol_staticd_route_list_destroy, - .cli_cmp = static_route_list_cli_cmp, } }, { @@ -35,7 +27,6 @@ const struct frr_yang_module_info frr_staticd_info = { .cbs = { .create = routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_create, .destroy = routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_destroy, - .cli_cmp = static_path_list_cli_cmp, } }, { @@ -51,8 +42,6 @@ const struct frr_yang_module_info frr_staticd_info = { .create = routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_create, .destroy = routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_destroy, .pre_validate = routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_pre_validate, - .cli_show = static_nexthop_cli_show, - .cli_cmp = static_nexthop_cli_cmp, } }, { @@ -150,7 +139,6 @@ const struct frr_yang_module_info frr_staticd_info = { .cbs = { .create = routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_create, .destroy = routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_destroy, - .cli_cmp = static_src_list_cli_cmp, } }, { @@ -158,7 +146,6 @@ const struct frr_yang_module_info frr_staticd_info = { .cbs = { .create = routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_create, .destroy = routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_destroy, - .cli_cmp = static_path_list_cli_cmp, } }, { @@ -174,8 +161,6 @@ const struct frr_yang_module_info frr_staticd_info = { .create = routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_create, .destroy = routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_destroy, .pre_validate = routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_pre_validate, - .cli_show = static_src_nexthop_cli_show, - .cli_cmp = static_nexthop_cli_cmp, } }, { diff --git a/staticd/static_vrf.c b/staticd/static_vrf.c index a67dce200f..7a0ff01d04 100644 --- a/staticd/static_vrf.c +++ b/staticd/static_vrf.c @@ -124,26 +124,12 @@ struct static_vrf *static_vrf_lookup_by_name(const char *name) return NULL; } -static int static_vrf_config_write(struct vty *vty) -{ - struct lyd_node *dnode; - int written = 0; - - dnode = yang_dnode_get(running_config->dnode, "/frr-routing:routing"); - if (dnode) { - nb_cli_show_dnode_cmds(vty, dnode, false); - written = 1; - } - - return written; -} - void static_vrf_init(void) { vrf_init(static_vrf_new, static_vrf_enable, static_vrf_disable, static_vrf_delete); - vrf_cmd_init(static_vrf_config_write); + vrf_cmd_init(NULL); } void static_vrf_terminate(void) diff --git a/staticd/static_vty.c b/staticd/static_vty.c index c2c260cfba..d9d4554c73 100644 --- a/staticd/static_vty.c +++ b/staticd/static_vty.c @@ -1234,8 +1234,10 @@ DEFPY_YANG(ipv6_route_vrf, ipv6_route_vrf_cmd, return static_route_nb_run(vty, &args); } -void static_cli_show(struct vty *vty, const struct lyd_node *dnode, - bool show_defaults) +#ifdef INCLUDE_MGMTD_CMDDEFS_ONLY + +static void static_cli_show(struct vty *vty, const struct lyd_node *dnode, + bool show_defaults) { const char *vrf; @@ -1244,7 +1246,7 @@ void static_cli_show(struct vty *vty, const struct lyd_node *dnode, vty_out(vty, "vrf %s\n", vrf); } -void static_cli_show_end(struct vty *vty, const struct lyd_node *dnode) +static void static_cli_show_end(struct vty *vty, const struct lyd_node *dnode) { const char *vrf; @@ -1444,8 +1446,9 @@ static void nexthop_cli_show(struct vty *vty, const struct lyd_node *route, vty_out(vty, "\n"); } -void static_nexthop_cli_show(struct vty *vty, const struct lyd_node *dnode, - bool show_defaults) +static void static_nexthop_cli_show(struct vty *vty, + const struct lyd_node *dnode, + bool show_defaults) { const struct lyd_node *path = yang_dnode_get_parent(dnode, "path-list"); const struct lyd_node *route = @@ -1454,8 +1457,9 @@ void static_nexthop_cli_show(struct vty *vty, const struct lyd_node *dnode, nexthop_cli_show(vty, route, NULL, path, dnode, show_defaults); } -void static_src_nexthop_cli_show(struct vty *vty, const struct lyd_node *dnode, - bool show_defaults) +static void static_src_nexthop_cli_show(struct vty *vty, + const struct lyd_node *dnode, + bool show_defaults) { const struct lyd_node *path = yang_dnode_get_parent(dnode, "path-list"); const struct lyd_node *src = yang_dnode_get_parent(path, "src-list"); @@ -1464,8 +1468,8 @@ void static_src_nexthop_cli_show(struct vty *vty, const struct lyd_node *dnode, nexthop_cli_show(vty, route, src, path, dnode, show_defaults); } -int static_nexthop_cli_cmp(const struct lyd_node *dnode1, - const struct lyd_node *dnode2) +static int static_nexthop_cli_cmp(const struct lyd_node *dnode1, + const struct lyd_node *dnode2) { enum static_nh_type nh_type1, nh_type2; struct prefix prefix1, prefix2; @@ -1519,8 +1523,8 @@ int static_nexthop_cli_cmp(const struct lyd_node *dnode1, return if_cmp_name_func(vrf1, vrf2); } -int static_route_list_cli_cmp(const struct lyd_node *dnode1, - const struct lyd_node *dnode2) +static int static_route_list_cli_cmp(const struct lyd_node *dnode1, + const struct lyd_node *dnode2) { const char *afi_safi1, *afi_safi2; afi_t afi1, afi2; @@ -1545,8 +1549,8 @@ int static_route_list_cli_cmp(const struct lyd_node *dnode1, return prefix_cmp(&prefix1, &prefix2); } -int static_src_list_cli_cmp(const struct lyd_node *dnode1, - const struct lyd_node *dnode2) +static int static_src_list_cli_cmp(const struct lyd_node *dnode1, + const struct lyd_node *dnode2) { struct prefix prefix1, prefix2; @@ -1556,8 +1560,8 @@ int static_src_list_cli_cmp(const struct lyd_node *dnode1, return prefix_cmp(&prefix1, &prefix2); } -int static_path_list_cli_cmp(const struct lyd_node *dnode1, - const struct lyd_node *dnode2) +static int static_path_list_cli_cmp(const struct lyd_node *dnode1, + const struct lyd_node *dnode2) { uint32_t table_id1, table_id2; uint8_t distance1, distance2; @@ -1574,7 +1578,62 @@ int static_path_list_cli_cmp(const struct lyd_node *dnode1, return (int)distance1 - (int)distance2; } -#ifndef INCLUDE_MGMTD_CMDDEFS_ONLY +const struct frr_yang_module_info frr_staticd_info = { + .name = "frr-staticd", + .ignore_cbs = true, + .nodes = { + { + .xpath = "/frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd", + .cbs = { + .cli_show = static_cli_show, + .cli_show_end = static_cli_show_end, + } + }, + { + .xpath = "/frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list", + .cbs = { + .cli_cmp = static_route_list_cli_cmp, + } + }, + { + .xpath = "/frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list", + .cbs = { + .cli_cmp = static_path_list_cli_cmp, + } + }, + { + .xpath = "/frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/frr-nexthops/nexthop", + .cbs = { + .cli_show = static_nexthop_cli_show, + .cli_cmp = static_nexthop_cli_cmp, + } + }, + { + .xpath = "/frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list", + .cbs = { + .cli_cmp = static_src_list_cli_cmp, + } + }, + { + .xpath = "/frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list/path-list", + .cbs = { + .cli_cmp = static_path_list_cli_cmp, + } + }, + { + .xpath = "/frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list/path-list/frr-nexthops/nexthop", + .cbs = { + .cli_show = static_src_nexthop_cli_show, + .cli_cmp = static_nexthop_cli_cmp, + } + }, + { + .xpath = NULL, + }, + } +}; + +#else /* ifdef INCLUDE_MGMTD_CMDDEFS_ONLY */ DEFPY_YANG(debug_staticd, debug_staticd_cmd, "[no] debug static [{events$events|route$route|bfd$bfd}]", diff --git a/staticd/static_vty.h b/staticd/static_vty.h index 77e52b5bdf..4b4cc1c3bf 100644 --- a/staticd/static_vty.h +++ b/staticd/static_vty.h @@ -11,22 +11,6 @@ extern "C" { #endif -void static_cli_show(struct vty *vty, const struct lyd_node *dnode, - bool show_defaults); -void static_cli_show_end(struct vty *vty, const struct lyd_node *dnode); -void static_nexthop_cli_show(struct vty *vty, const struct lyd_node *dnode, - bool show_defaults); -void static_src_nexthop_cli_show(struct vty *vty, const struct lyd_node *dnode, - bool show_defaults); -int static_nexthop_cli_cmp(const struct lyd_node *dnode1, - const struct lyd_node *dnode2); -int static_route_list_cli_cmp(const struct lyd_node *dnode1, - const struct lyd_node *dnode2); -int static_src_list_cli_cmp(const struct lyd_node *dnode1, - const struct lyd_node *dnode2); -int static_path_list_cli_cmp(const struct lyd_node *dnode1, - const struct lyd_node *dnode2); - void static_vty_init(void); #ifdef __cplusplus diff --git a/tests/lib/test_frrlua.c b/tests/lib/test_frrlua.c index 701e171c84..2760a273bd 100644 --- a/tests/lib/test_frrlua.c +++ b/tests/lib/test_frrlua.c @@ -13,14 +13,22 @@ static void test_encode_decode(void) { lua_State *L = luaL_newstate(); - long long a = 123; - long long b = a; + int a = 123; + int b = a; lua_pushintegerp(L, &a); lua_decode_integerp(L, -1, &a); assert(a == b); assert(lua_gettop(L) == 0); + long long ll_a = 123L; + long long ll_b = a; + + lua_pushlonglongp(L, &ll_a); + lua_decode_longlongp(L, -1, &ll_a); + assert(ll_a == ll_b); + assert(lua_gettop(L) == 0); + time_t time_a = 100; time_t time_b; diff --git a/tests/lib/test_frrscript.c b/tests/lib/test_frrscript.c index 7d4746cf3e..9698aeaa6c 100644 --- a/tests/lib/test_frrscript.c +++ b/tests/lib/test_frrscript.c @@ -32,7 +32,7 @@ int main(int argc, char **argv) assert(result == 0); result = frrscript_call(fs, "bar", ("a", &a), ("b", &b)); assert(result == 0); - long long *cptr = frrscript_get_result(fs, "bar", "c", lua_tointegerp); + long long *cptr = frrscript_get_result(fs, "bar", "c", lua_tolonglongp); /* a should not occur in the returned table in script */ assert(a == 100); @@ -47,7 +47,7 @@ int main(int argc, char **argv) result = frrscript_call(fs, "fact", ("n", &n)); assert(result == 0); long long *ansptr = - frrscript_get_result(fs, "fact", "ans", lua_tointegerp); + frrscript_get_result(fs, "fact", "ans", lua_tolonglongp); assert(*ansptr == 120); /* check consecutive call + get_result without re-loading */ diff --git a/zebra/zebra_router.c b/zebra/zebra_router.c index 676475355e..6271d029fb 100644 --- a/zebra/zebra_router.c +++ b/zebra/zebra_router.c @@ -241,9 +241,9 @@ void zebra_router_terminate(void) zebra_pbr_ipset_entry_free); hash_clean_and_free(&zrouter.ipset_hash, zebra_pbr_ipset_free); hash_clean_and_free(&zrouter.iptable_hash, zebra_pbr_iptable_free); - hash_clean_and_free(&zrouter.filter_hash, NULL); - hash_clean_and_free(&zrouter.qdisc_hash, NULL); - hash_clean_and_free(&zrouter.class_hash, NULL); + hash_clean_and_free(&zrouter.filter_hash, (void (*)(void *)) zebra_tc_filter_free); + hash_clean_and_free(&zrouter.qdisc_hash, (void (*)(void *)) zebra_tc_qdisc_free); + hash_clean_and_free(&zrouter.class_hash, (void (*)(void *)) zebra_tc_class_free); #ifdef HAVE_SCRIPTING zebra_script_destroy(); diff --git a/zebra/zebra_tc.c b/zebra/zebra_tc.c index 3d7e03b63e..1b5a57ae53 100644 --- a/zebra/zebra_tc.c +++ b/zebra/zebra_tc.c @@ -132,13 +132,18 @@ static void *tc_qdisc_alloc_intern(void *arg) return new; } +void zebra_tc_qdisc_free(struct zebra_tc_qdisc *qdisc) +{ + XFREE(MTYPE_TC_QDISC, qdisc); +} + static struct zebra_tc_qdisc *tc_qdisc_free(struct zebra_tc_qdisc *hash_data, bool free_data) { hash_release(zrouter.qdisc_hash, hash_data); if (free_data) { - XFREE(MTYPE_TC_QDISC, hash_data); + zebra_tc_qdisc_free(hash_data); return NULL; } @@ -178,7 +183,7 @@ void zebra_tc_qdisc_install(struct zebra_tc_qdisc *qdisc) new = hash_get(zrouter.qdisc_hash, qdisc, tc_qdisc_alloc_intern); (void)dplane_tc_qdisc_install(new); - XFREE(MTYPE_TC_QDISC, old); + zebra_tc_qdisc_free(old); } } else { new = hash_get(zrouter.qdisc_hash, qdisc, @@ -243,13 +248,18 @@ static void *tc_class_alloc_intern(void *arg) return new; } +void zebra_tc_class_free(struct zebra_tc_class *class) +{ + XFREE(MTYPE_TC_CLASS, class); +} + static struct zebra_tc_class *tc_class_free(struct zebra_tc_class *hash_data, bool free_data) { hash_release(zrouter.class_hash, hash_data); if (free_data) { - XFREE(MTYPE_TC_CLASS, hash_data); + zebra_tc_class_free(hash_data); return NULL; } @@ -353,13 +363,18 @@ bool zebra_tc_filter_hash_equal(const void *arg1, const void *arg2) return true; } +void zebra_tc_filter_free(struct zebra_tc_filter *filter) +{ + XFREE(MTYPE_TC_FILTER, filter); +} + static struct zebra_tc_filter *tc_filter_free(struct zebra_tc_filter *hash_data, bool free_data) { hash_release(zrouter.filter_hash, hash_data); if (free_data) { - XFREE(MTYPE_TC_FILTER, hash_data); + zebra_tc_filter_free(hash_data); return NULL; } diff --git a/zebra/zebra_tc.h b/zebra/zebra_tc.h index 335430c93d..814b453ec5 100644 --- a/zebra/zebra_tc.h +++ b/zebra/zebra_tc.h @@ -42,16 +42,19 @@ uint32_t zebra_tc_qdisc_hash_key(const void *arg); bool zebra_tc_qdisc_hash_equal(const void *arg1, const void *arg2); void zebra_tc_qdisc_install(struct zebra_tc_qdisc *qdisc); void zebra_tc_qdisc_uninstall(struct zebra_tc_qdisc *qdisc); +void zebra_tc_qdisc_free(struct zebra_tc_qdisc *qdisc); uint32_t zebra_tc_class_hash_key(const void *arg); bool zebra_tc_class_hash_equal(const void *arg1, const void *arg2); void zebra_tc_class_add(struct zebra_tc_class *class); void zebra_tc_class_delete(struct zebra_tc_class *class); +void zebra_tc_class_free(struct zebra_tc_class *class); const char *tc_filter_kind2str(uint32_t type); enum tc_qdisc_kind tc_filter_str2kind(const char *type); void zebra_tc_filter_add(struct zebra_tc_filter *filter); void zebra_tc_filter_delete(struct zebra_tc_filter *filter); +void zebra_tc_filter_free(struct zebra_tc_filter *filter); void zebra_tc_filters_free(void *arg); uint32_t zebra_tc_filter_hash_key(const void *arg); |
