]> git.puffer.fish Git - matthieu/frr.git/commitdiff
lib: remove frrlua_initialize
authorQuentin Young <qlyoung@cumulusnetworks.com>
Sun, 11 Aug 2019 18:35:16 +0000 (18:35 +0000)
committerQuentin Young <qlyoung@nvidia.com>
Tue, 1 Dec 2020 23:37:14 +0000 (18:37 -0500)
This was toy code used for testing purposes. Code calling Lua should be
very explicit about what is loaded into the Lua state. Also, the
allocator used is exactly the same allocator used by default w/
luaL_newstate().

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
bgpd/bgp_routemap.c
lib/frrlua.c
lib/frrlua.h

index d9457ea616a9ecca03bff377a4c067d2bacc5842..5274c4fae0870d0727a5e864c8ca835729a75f05 100644 (file)
@@ -346,7 +346,8 @@ route_match_command(void *rule, const struct prefix *prefix, void *object)
        u_int32_t newlocpref = 0;
        enum frrlua_rm_status lrm_status;
        struct bgp_path_info *path = (struct bgp_path_info *)object;
-       lua_State *L = frrlua_initialize("/etc/frr/lua.scr");
+       lua_State *L = luaL_newstate();;
+       luaL_openlibs(L);
 
        if (L == NULL)
                return status;
index 4c38e08a07e9f292f0dd049677f74bc70228acf7..7dc87869012f224a8857b6753579a67f4097dbc2 100644 (file)
@@ -194,38 +194,4 @@ enum frrlua_rm_status frrlua_run_rm_rule(lua_State *L, const char *rule)
        return status;
 }
 
-/* Initialization */
-
-static void *frrlua_alloc(void *ud, void *ptr, size_t osize, size_t nsize)
-{
-       (void)ud;
-       (void)osize; /* not used */
-
-       if (nsize == 0) {
-               free(ptr);
-               return NULL;
-       } else
-               return realloc(ptr, nsize);
-}
-
-lua_State *frrlua_initialize(const char *file)
-{
-       int status;
-       lua_State *L = lua_newstate(frrlua_alloc, NULL);
-
-       luaL_openlibs(L);
-       if (file) {
-               status = luaL_loadfile(L, file);
-               if (status) {
-                       zlog_debug("Failure to open %s %d", file, status);
-                       lua_close(L);
-                       return NULL;
-               }
-               lua_pcall(L, 0, LUA_MULTRET, 0);
-       }
-
-       return L;
-}
-
-
 #endif
index d6ee2347a955563ecc272f2ada8fc247a65c523b..56c43b7755248896dc28c698fcfff3edc62d380b 100644 (file)
@@ -56,15 +56,6 @@ enum frrlua_rm_status {
        LUA_RM_MATCH_AND_CHANGE,
 };
 
-/*
- * Creates a new Lua state, loads all libraries, and if a script is provided,
- * runs it.
- *
- * Returns:
- *    The new Lua state.
- */
-lua_State *frrlua_initialize(const char *file);
-
 /*
  * Pushes a new table containing relevant fields from a prefix structure.
  *