diff options
author | Quentin Young <qlyoung@cumulusnetworks.com> | 2019-08-11 21:23:35 +0200 |
---|---|---|
committer | Quentin Young <qlyoung@nvidia.com> | 2020-12-02 00:37:14 +0100 |
commit | 0fe6a43d9040524f6715adaaf8f9d7d7aa28a53e (patch) | |
tree | d880c84634828e863efcacea7c3c498eb24e3467 /bgpd | |
parent | lib: remove frrlua_initialize (diff) | |
download | frr-0fe6a43d9040524f6715adaaf8f9d7d7aa28a53e.tar.xz frr-0fe6a43d9040524f6715adaaf8f9d7d7aa28a53e.zip |
lib: move bgp routemap stuff out of frrlua.[ch]
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
Diffstat (limited to 'bgpd')
-rw-r--r-- | bgpd/bgp_routemap.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/bgpd/bgp_routemap.c b/bgpd/bgp_routemap.c index 5274c4fae..247391ade 100644 --- a/bgpd/bgp_routemap.c +++ b/bgpd/bgp_routemap.c @@ -338,6 +338,45 @@ static const struct route_map_rule_cmd route_match_peer_cmd = { }; #if defined(HAVE_LUA) + +enum frrlua_rm_status { + /* + * Script function run failure. This will translate into a + * deny + */ + LUA_RM_FAILURE = 0, + /* + * No Match was found for the route map function + */ + LUA_RM_NOMATCH, + /* + * Match was found but no changes were made to the + * incoming data. + */ + LUA_RM_MATCH, + /* + * Match was found and data was modified, so + * figure out what changed + */ + LUA_RM_MATCH_AND_CHANGE, +}; + +static enum frrlua_rm_status frrlua_run_rm_rule(lua_State *L, const char *rule) +{ + int status; + + lua_getglobal(L, rule); + status = lua_pcall(L, 0, 1, 0); + if (status) { + zlog_debug("Executing Failure with function: %s: %d", + rule, status); + return LUA_RM_FAILURE; + } + + status = lua_tonumber(L, -1); + return status; +} + static enum route_map_cmd_result_t route_match_command(void *rule, const struct prefix *prefix, void *object) { |