You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Lua scripting environment loads the user script into an empty namespace, preventing necessary Lua functions like pairs() and ipairs form working. This makes it impossible to iterate over Lua tables, which is pretty important capability.
Version
Hello, this is FRRouting (version 10.2-dev_git20240920)
How to reproduce
Try the following:
functionon_rib_process_dplane_results(ctx)
ifctx.rinfo.zd_ngthenfork, vinpairs(ctx.rinfo.zd_ng) dolog.info("entry=" ..k.." ifindex=" ..v.ifindex)
endendreturn {}
end
Expected behavior
I should get a log entry for each entry in the nexthop group.
Actual behavior
The script will throw an exception:
Lua hook call 'on_rib_process_dplane_results' : runtime error: /etc/frr/scripts/logger.lua:3: attempt to call a nil value (global 'pairs')
Additional context
This kind of error is typical in Lua modules that use the deprecated module() function to create modules. This function creates a new namespace (or table, b/c it's Lua everything is a table) for the module definitions, and the global namespace is no longer accessible. Welcome to Lua. :)
Description
The Lua scripting environment loads the user script into an empty namespace, preventing necessary Lua functions like
pairs()
andipairs
form working. This makes it impossible to iterate over Lua tables, which is pretty important capability.Version
How to reproduce
Try the following:
Expected behavior
I should get a log entry for each entry in the nexthop group.
Actual behavior
The script will throw an exception:
Additional context
This kind of error is typical in Lua modules that use the deprecated
module()
function to create modules. This function creates a new namespace (or table, b/c it's Lua everything is a table) for the module definitions, and the global namespace is no longer accessible. Welcome to Lua. :)See here for more detail:
http://lua-users.org/wiki/ModulesTutorial
See also #16847.
Checklist
The text was updated successfully, but these errors were encountered: