-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bgpd: expose comms, ext-comms, large-comms to lua #13683
base: master
Are you sure you want to change the base?
Conversation
MED, local-pref, ifindex and AS-Path attrs were being decoded by lua scripts, but were not being applied to the route. This adds the logic missing for those path attributes. Signed-off-by: Trey Aspelund <[email protected]>
Expose "community", "extended-community", and "large-community" strings to lua for use in scripting. Example: ``` [21:00:14] root@GRTicker:~/frr scripting_comms✔ # cat /etc/frr/scripts/comm_log.lua function route_match(prefix, attributes, peer, RM_FAILURE, RM_NOMATCH, RM_MATCH, RM_MATCH_AND_CHANGE) route_string = prefix.network for attr, val in pairs(attributes) do if ((attr == "community" or attr == "extended-community" or attr == "large-community") and (val ~= 0 and val ~= nil)) then route_string = route_string .. " " .. attr .. "(" .. val .. ")" end end log.info("Evaluating route " .. route_string .. " from " .. peer.remote_id.string) attributes["community"] = "1111:2222" log.info("new comm: " .. attributes["community"]) attributes["extended-community"] = "rt 1:1" log.info("new ext-comm: " .. attributes["extended-community"]) attributes["large-community"] = "1111:2222:3333" log.info("new large-comm: " .. attributes["large-community"]) return { action = RM_MATCH_AND_CHANGE, attributes = attributes } end [21:00:19] root@GRTicker:~/frr scripting_comms✔ # grep -A3 Evaluating /var/log/frr/trey.log | tail -4 2023/06/04 21:00:20 BGP: [JZMNV-MDH8J] Evaluating route 209.239.224.0/20 large-community(19625:53610:1) community(2914:410 2914:1005 2914:2000 2914:3000 3356:3 3356:22 3356:86 3356:575 3356:666 3356:903 3356:2059 53610:3356) extended-community() from 208.64.92.14 2023/06/04 21:00:20 BGP: [JZMNV-MDH8J] new comm: 1111:2222 2023/06/04 21:00:20 BGP: [JZMNV-MDH8J] new ext-comm: rt 1:1 2023/06/04 21:00:20 BGP: [JZMNV-MDH8J] new large-comm: 1111:2222:3333 [21:00:21] root@GRTicker:~/frr scripting_comms✔ # vtysh -c 'show ip bgp 209.239.224.0/20' BGP routing table entry for 209.239.224.0/20, version 65808 Paths: (1 available, best FRRouting#1, table default) Not advertised to any peer 19625 53610 3356 2914 5033 2602:fc59:e:c02::1 from 2602:fc59:e:c02::1 (208.64.92.14) (fe80::5cce:6fff:fe43:eb70) (used) Origin IGP, valid, external, best (First path received) Community: 1111:2222 Extended Community: RT:1:1 Large Community: 1111:2222:3333 Last update: Sun Jun 4 21:00:21 2023 ``` Signed-off-by: Trey Aspelund <[email protected]>
Continuous Integration Result: SUCCESSFULCongratulations, this patch passed basic tests Tested-by: NetDEF / OpenSourceRouting.org CI System CI System Testrun URL: https://ci1.netdef.org/browse/FRR-PULLREQ2-11988/ This is a comment from an automated CI system. |
|
||
path->attr->med = newattr.med; | ||
if (CHECK_FLAG(path->attr->flag, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this check overall? Can't use path->attr->med at once?
ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC)); | ||
} | ||
|
||
path->attr->aspath = newattr.aspath; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, I think we need here aspath_unintern() and intern a new value? Same for other pointers: community, lcomm, extcomm (bgp_attr_intern()).
This PR is stale because it has been open 180 days with no activity. Comment or remove the |
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
@taspelund would you like to continue with this PR? |
Expose "community", "extended-community", and "large-community" strings
to lua for use in scripting.
Example:
Signed-off-by: Trey Aspelund [email protected]