From 6021965926654eb96c22391725ae0133ea77e784 Mon Sep 17 00:00:00 2001 From: Quentin Young Date: Sat, 11 May 2019 00:55:50 +0000 Subject: lib: clean up frrlua.[ch] * Use frrlua_* prefix to differentiate from Lua builtins * Allow frrlua_initialize to pass an empty script * Fixup naming of table accessors * Fixup naming of prefix -> table encoder * Fixup BGP routemap code to new function names * Fix includes for frrlua.h * Clean up doc comments Signed-off-by: Quentin Young --- bgpd/bgp_routemap.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'bgpd') diff --git a/bgpd/bgp_routemap.c b/bgpd/bgp_routemap.c index 637eaca39..d9457ea61 100644 --- a/bgpd/bgp_routemap.c +++ b/bgpd/bgp_routemap.c @@ -344,9 +344,9 @@ route_match_command(void *rule, const struct prefix *prefix, void *object) int status = RMAP_NOMATCH; u_int32_t locpref = 0; u_int32_t newlocpref = 0; - enum lua_rm_status lrm_status; + enum frrlua_rm_status lrm_status; struct bgp_path_info *path = (struct bgp_path_info *)object; - lua_State *L = lua_initialize("/etc/frr/lua.scr"); + lua_State *L = frrlua_initialize("/etc/frr/lua.scr"); if (L == NULL) return status; @@ -354,9 +354,7 @@ route_match_command(void *rule, const struct prefix *prefix, void *object) /* * Setup the prefix information to pass in */ - lua_setup_prefix_table(L, prefix); - - zlog_debug("Set up prefix table"); + frrlua_newtable_prefix(L, prefix); /* * Setup the bgp_path_info information */ @@ -376,7 +374,7 @@ route_match_command(void *rule, const struct prefix *prefix, void *object) /* * Run the rule */ - lrm_status = lua_run_rm_rule(L, rule); + lrm_status = frrlua_run_rm_rule(L, rule); switch (lrm_status) { case LUA_RM_FAILURE: zlog_debug("RM_FAILURE"); @@ -387,13 +385,13 @@ route_match_command(void *rule, const struct prefix *prefix, void *object) case LUA_RM_MATCH_AND_CHANGE: zlog_debug("MATCH AND CHANGE"); lua_getglobal(L, "nexthop"); - path->attr->med = get_integer(L, "metric"); + path->attr->med = frrlua_table_get_integer(L, "metric"); /* * This needs to be abstraced with the set function */ if (path->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF)) locpref = path->attr->local_pref; - newlocpref = get_integer(L, "localpref"); + newlocpref = frrlua_table_get_integer(L, "localpref"); if (newlocpref != locpref) { path->attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF); path->attr->local_pref = newlocpref; -- cgit v1.2.3