summaryrefslogtreecommitdiff
path: root/tools/lua.scr
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2017-11-07 09:14:32 -0500
committerDonald Sharp <sharpd@cumulusnetworks.com>2018-09-26 21:21:23 -0400
commit1d7c7ace3c08fd1986143f37063114594fb91069 (patch)
tree1b5b0c476375dfeb00f3b0be0167f9911a8734c7 /tools/lua.scr
parent634949aef8ffbd504fe6337a4668de4b9b8b3941 (diff)
bgpd: Add lua match command
Please note this is a Proof of Concept and not actually something that is ready to commit at this point. The file tools/lua.scr contains some documentation on how we expect it to work currently. Additionally not all bgp values have been hooked up into the ability to lua script yet. There is still significant work to be done here: 1) Add the ability to pass in more data and to adjust the return values as appropriate. To set it up: 1) copy tools/lua.scr into /etc/frr (or whereever the config directory is ) 2) Create a route-map match command: ! router bgp 55 neighbor 10.50.11.116 remote-as external ! address-family ipv4 unicast neighbor 10.50.11.116 route-map TEST in exit-address-family ! route-map TEST permit 10 match command mooey ! 3) In the lua.scr file make sure that you have a function named 'mooey' ( as the above example does ): function mooey () zlog_debug(string.format("Family: %d: %s %d ifindex: %d aspath: %s localpref: %d", prefix.family, prefix.route, nexthop.metric, nexthop.ifindex, nexthop.aspath, nexthop.localpref)) nexthop.metric = 33 nexthop.localpref = 13 return 3 end This example script modifies the metric and localpref currently. I've also provided a zlog_debug function in lua to allow some simple debugging. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Diffstat (limited to 'tools/lua.scr')
-rw-r--r--tools/lua.scr29
1 files changed, 29 insertions, 0 deletions
diff --git a/tools/lua.scr b/tools/lua.scr
new file mode 100644
index 0000000000..db6bf7d36b
--- /dev/null
+++ b/tools/lua.scr
@@ -0,0 +1,29 @@
+-- Route map functionality
+--
+-- There are no parameters passed in.
+-- Currently we set two global tables
+-- prefix
+-- .family = The v4 or v6 family we are working in
+-- .route = the A.B.C.D/X or Z:A:B::D/X string
+-- nexthop
+-- .metric = The metric we are going to use
+-- .ifindex = The outgoing interface
+-- .aspath = The aspath of the route
+-- .localpref = The localpref value
+--
+-- Valid Return Codes:
+-- 0 - Some sort of processing failure
+-- This turns into a implicit DENY
+-- 1 - No match was found, turns into a DENY
+-- 2 - Match found, turns into a PERMIT
+-- 3 - Match found and data structures changed, turns into a PERMIT
+-- and a reread of the prefix and nexthop tables
+function mooey ()
+ zlog_debug(string.format("Family: %d: %s %d ifindex: %d aspath: %s localpref: %d",
+ prefix.family, prefix.route,
+ nexthop.metric, nexthop.ifindex, nexthop.aspath, nexthop.localpref))
+
+ nexthop.metric = 33
+ nexthop.localpref = 13
+ return 3
+end