summaryrefslogtreecommitdiff
path: root/bgpd/bgp_filter.c
AgeCommit message (Collapse)Author
2024-05-16bgpd: fix "bgp as-pah access-list" with "set aspath exclude" set/unset issuesFrancois Dumontet
whith the following config router bgp 65001 no bgp ebgp-requires-policy neighbor 192.168.1.2 remote-as external neighbor 192.168.1.2 timers 3 10 ! address-family ipv4 unicast neighbor 192.168.1.2 route-map r2 in exit-address-family exit ! bgp as-path access-list FIRST seq 5 permit ^65 bgp as-path access-list SECOND seq 5 permit 2$ ! route-map r2 permit 6 match ip address prefix-list p2 set as-path exclude as-path-access-list SECOND exit ! route-map r2 permit 10 match ip address prefix-list p1 set as-path exclude 65003 exit ! route-map r2 permit 20 match ip address prefix-list p3 set as-path exclude all exit making some no bgp as-path access-list SECOND permit 2$ bgp as-path access-list SECOND permit 3$ clear bgp * no bgp as-path access-list SECOND permit 3$ bgp as-path access-list SECOND permit 2$ clear bgp * will induce some crashes thus we rework the links between aslists and aspath_exclude Signed-off-by: Francois Dumontet <francois.dumontet@6wind.com>
2024-02-26bgpd: fix no bgp as-path access-list issueFrancois Dumontet
router bgp 65001 no bgp ebgp-requires-policy neighbor 192.168.1.2 remote-as external neighbor 192.168.1.2 timers 3 10 address-family ipv4 unicast neighbor 192.168.1.2 route-map r2 in exit-address-family ! ip prefix-list p1 seq 5 permit 172.16.255.31/32 ! route-map r2 permit 10 match ip address prefix-list p1 set as-path exclude 65003 route-map r2 permit 20 set as-path exclude all ! we make the following commands bgp as-path access-list FIRST permit ^65 bgp as-path access-list SECOND permit 2 route-map r2 permit 6 set as-path exclude as-path-access-list SECOND and then no bgp as-path access-list SECOND permit 2 clear bgp * we have the following crash in bgp Stack trace of thread 536083: #0 0x00007f87f8aacfe1 raise (libpthread.so.0 + 0x12fe1) #1 0x00007f87f8cf6870 core_handler (libfrr.so.0 + 0xf6870) #2 0x00007f87f8aad140 __restore_rt (libpthread.so.0 + 0x13140) #3 0x00007f87f89a5122 __GI___regexec (libc.so.6 + 0xdf122) #4 0x000055d7f198b4a7 aspath_filter_exclude_acl (bgpd + 0x2054a7) #5 0x000055d7f1902187 route_set_aspath_exclude (bgpd + 0x17c187) #6 0x00007f87f8ce54b0 route_map_apply_ext (libfrr.so.0 + 0xe54b0) #7 0x000055d7f18da925 bgp_input_modifier (bgpd + 0x154925) #8 0x000055d7f18e0647 bgp_update (bgpd + 0x15a647) #9 0x000055d7f18e4772 bgp_nlri_parse_ip (bgpd + 0x15e772) #10 0x000055d7f18c38ae bgp_nlri_parse (bgpd + 0x13d8ae) #11 0x000055d7f18c6b7a bgp_update_receive (bgpd + 0x140b7a) #12 0x000055d7f18c8ff3 bgp_process_packet (bgpd + 0x142ff3) #13 0x00007f87f8d0dce0 thread_call (libfrr.so.0 + 0x10dce0) #14 0x00007f87f8cacb28 frr_run (libfrr.so.0 + 0xacb28) #15 0x000055d7f18435da main (bgpd + 0xbd5da) #16 0x00007f87f88e9d0a __libc_start_main (libc.so.6 + 0x23d0a) #17 0x000055d7f18415fa _start (bgpd + 0xbb5fa) analysis crash is due to the fact that there were always a pointer from as-path exclude to deleted as-path access list. fix we add a backpointer mechanism to manage the dependency beetween as-path access-list and aspath exclude. Signed-off-by: Francois Dumontet <francois.dumontet@6wind.com>
2023-07-19bgpd: add set as-path exclude acl-list commandFrancois Dumontet
A route-map applied on incoming BGP updates is not able to exclude the unwanted as segments, based on an AS path access-list. The below configuration illustrates the case: router bgp 65001 address-family ipv4 unicast neighbor 192.168.1.2 route-map rule_2 in exit-address-family bgp as-path access-list RULE permit ^65 route-map rule_2 permit 10 set as-path exclude as-path-access-list RULE ``` BGP routing table entry for 10.10.10.10/32, version 13 Paths: (1 available, best #1, table default) Advertised to non peer-group peers: 192.168.10.65 65000 1 2 3 123 192.168.10.65 from 192.168.10.65 (10.10.10.11) Origin IGP, metric 0, valid, external, best (First path received) ``` After: ``` do show ip bgp 10.10.10.10/32 BGP routing table entry for 10.10.10.10/32, version 15 Paths: (1 available, best #1, table default) Advertised to non peer-group peers: 192.168.10.65 2 3 123 192.168.10.65 from 192.168.10.65 (10.10.10.11) Origin IGP, metric 0, valid, external, best (First path received) ``` Signed-off-by: Francois Dumontet <francois.dumontet@6wind.com>
2023-02-09*: auto-convert to SPDX License IDsDavid Lamparter
Done with a combination of regex'ing and banging my head against a wall. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-07-22bgpd: Free memory for as-path filter if regexp is wrongDonatas Abraitis
Before: ``` $ vtysh -c 'sh memory bgpd | include Temporary'; echo ; for x in $(seq 1 1000); do vtysh -c 'conf' -c 'bgp as-path access-list belekas permit wrong' >/dev/null; done; vtysh -c 'sh memory bgpd | include Temporary' Temporary memory : 19 variable 504 22 656 Temporary memory : 1019 variable 24504 1023 24656 ``` After: ``` $ vtysh -c 'sh memory bgpd | include Temporary'; echo ; for x in $(seq 1 1000); do vtysh -c 'conf' -c 'bgp as-path access-list belekas permit wrong' >/dev/null; done; vtysh -c 'sh memory bgpd | include Temporary' Temporary memory : 19 variable 504 22 656 Temporary memory : 19 variable 504 24 680 ``` Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-07-22bgpd: Call a hook when as-path filter is replacedDonatas Abraitis
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2021-11-27*: Remove redundand braces for single statement blocksDonatas Abraitis
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-11-25bgpd: Convert vty_out to vty_json for JSONDonatas Abraitis
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-10-19bgpd: Add autocomplete for as-path filtersDonatas Abraitis
``` exit1-debian-9# show bgp as-path-access-list <cr> AS_PATH_FILTER_NAME AS path access list name acl1 acl2 json JavaScript Object Notation exit1-debian-9(config)# route-map testas permit 10 exit1-debian-9(config-route-map)# match as-path ? AS_PATH_FILTER_NAME AS path access-list name acl1 acl2 ``` Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-08-02bgpd: add "json" option to "show bgp as-path-access-list"Renato Westphal
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2021-04-14*: cleanup number-named access-lists and prefix-listsIgor Ryzhov
A long time ago there was a difference between number-named and string-named access/prefix-lists. Currently we always treat the name as a string and there is no need for a separate list for number-named lists. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-03-17bgpd: add seqno in bgp as-path access-list policyChirag Shah
Add optional parameter seqno to bgp as-patch policy to inline with other bgp policies commands at same level. Testing Done: config t bgp as-path access-list foo1 permit _40_ bgp as-path access-list foo1 seq 5 permit _41_ bgp as-path access-list foo1 seq 8 permit _42_ bgp as-path access-list foo2 permit _43_ no bgp as-path access-list foo1 permit _41_ bgp as-path access-list foo1 permit 41$ show run: bgp as-path access-list foo1 seq 8 permit _42_ bgp as-path access-list foo1 seq 10 permit 41$ bgp as-path access-list foo2 seq 5 permit _43_ Signed-off-by: Chirag Shah <chirag@nvidia.com>
2020-10-14bgpd: print error when as-path filter doesn't existIgor Ryzhov
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2020-05-11bgpd: really remove the `no ip as-path...` commandDonald Sharp
We had already removed the `ip as-path..` command to have `bgp as-path` but for some reason a `no ip as-path..` command ALIAS was still around. Kill with extreme prejudice. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-04-16*: move CLI node names to cmd_node->nameDavid Lamparter
And again for the name. Why on earth would we centralize this, just so people can forget to update it? Signed-off-by: David Lamparter <equinox@diac24.net>
2020-04-16*: remove second parameter on install_node()David Lamparter
There is really no reason to not put this in the cmd_node. And while we're add it, rename from pointless ".func" to ".config_write". [v2: fix forgotten ldpd config_write] Signed-off-by: David Lamparter <equinox@diac24.net>
2020-04-16*: remove cmd_node->vtyshDavid Lamparter
The only nodes that have this as 0 don't have a "->func" anyway, so the entire thing is really just pointless. Signed-off-by: David Lamparter <equinox@diac24.net>
2020-04-16*: clean up cmd_node initializersDavid Lamparter
... and use named assignments everywhere (so I can change the struct.) Signed-off-by: David Lamparter <equinox@diac24.net>
2020-03-21bgpd: Convert lots of int type functions to bool/voidDonatas Abraitis
Some were converted to bool, where true/false status is needed. Converted to void only those, where the return status was only false or true. Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-02-04*: remove null check before XFREEQuentin Young
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-02-03*: don't null after XFREE; XFREE does this itselfQuentin Young
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-10-08bgpd: Remove depracated `ip` prefix for as-path/extcommunity/large/communitiesDonatas Abraitis
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2019-08-06*: fix ctype (isalpha & co.) castsDavid Lamparter
The correct cast for these is (unsigned char), because "char" could be signed and thus have some negative value. isalpha & co. expect an int arg that is positive, i.e. 0-255. So we need to cast to (unsigned char) when calling any of these. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2019-04-24Merge pull request #4184 from ton31337/fix/documentation_for_as-path_regexpQuentin Young
doc: Specify allowed chars in bgp regular expressions
2019-04-23doc: Specify allowed chars in bgp regular expressionsDonatas Abraitis
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2019-04-23bgpd: Validate as-path in `show bgp regexp`Donatas Abraitis
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2019-04-18bgpd: Allow backslash in as-path filter listsDonatas Abraitis
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2019-02-25*: remove null check before XFREEQuentin Young
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-10-04bgpd: remove ip prefix from as-path, <large,ext>community-listSarita Patra
The existing commands "ip as-path", "ip community list", "ip extcommunity list" & "ip largecommunity list" is used to configure both for ipv4 and ipv6. So the prefix "ip" is removed from these commands. All the configuration, show related configuration, show running config & boot up with write memory is also verified with the provided fix. Signed-off-by: Sarita Patra <saritap@vmware.com>
2018-08-31bgpd: Validate as-path access-list before continuing regarding invalid charsDonatas Abraitis
Signed-off-by: Donatas Abraitis donatas.abraitis@gmail.com
2017-10-08bgpd: fix clang warningVincent JARDIN
Same fix than c31a793, alwas get the string so clang does not complain that it can be NULL. Signed-off-by: Vincent Jardin <vincent.jardin@6wind.com>
2017-07-17*: reindentreindent-master-afterwhitespace / reindent
indent.py `git ls-files | pcregrep '\.[ch]$' | pcregrep -v '^(ldpd|babeld|nhrpd)/'` Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-14Merge remote-tracking branch 'frr/master' into newline-reduxDavid Lamparter
Lots of conflicts from CMD_WARNING_CONFIG_FAILED... Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-14*: remove VTYNL, part 1 of 6David Lamparter
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-13vtysh: return non-zero for configuration failuresDaniel Walton
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com> This allows frr-reload.py (or anything else that scripts via vtysh) to know if the vtysh command worked or hit an error.
2017-07-13*: ditch vty_outln(), part 1 of 2David Lamparter
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-06-29*: vty_outln (vty, "") --> vty_out (vty, VTYNL)Quentin Young
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-06-29*: use vty_outlnQuentin Young
Saves 400 lines Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-05-15*: make consistent & update GPLv2 file headersDavid Lamparter
The FSF's address changed, and we had a mixture of comment styles for the GPL file header. (The style with * at the beginning won out with 580 to 141 in existing files.) Note: I've intentionally left intact other "variations" of the copyright header, e.g. whether it says "Zebra", "Quagga", "FRR", or nothing. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-11-18bgpd: Fix `no ip as-path access-list...`Quentin Young
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-11-17bgpd: Fix `ip as-path access-list ...` breakageQuentin Young
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-10-17Merge branch 'cmaster-next' into vtysh-grammarQuentin Young
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com> Conflicts: bgpd/bgp_route.c bgpd/bgp_routemap.c bgpd/bgp_vty.c isisd/isis_redist.c isisd/isis_routemap.c isisd/isis_vty.c isisd/isisd.c lib/command.c lib/distribute.c lib/if.c lib/keychain.c lib/routemap.c lib/routemap.h ospf6d/ospf6_asbr.c ospf6d/ospf6_interface.c ospf6d/ospf6_neighbor.c ospf6d/ospf6_top.c ospf6d/ospf6_zebra.c ospf6d/ospf6d.c ospfd/ospf_routemap.c ospfd/ospf_vty.c ripd/rip_routemap.c ripngd/ripng_routemap.c vtysh/extract.pl.in vtysh/vtysh.c zebra/interface.c zebra/irdp_interface.c zebra/rt_netlink.c zebra/rtadv.c zebra/test_main.c zebra/zebra_routemap.c zebra/zebra_vty.c
2016-10-07*: Consolidate all double VIEW_NODE and ENABLE_NODE'sDonald Sharp
If a command is put into the VIEW_NODE, it is going into the ENABLE_NODE as well. This is especially true for show commands. As such if a command is in both consolidate it down to VIEW_NODE. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-09-30all: scrubbed some argc CHECK MEsDaniel Walton
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
2016-09-29all: added CHECK ME for DEFUNs that look at argcDaniel Walton
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
2016-09-27bgpd, etc: changed .LINE to LINE...Daniel Walton
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
2016-09-23bgpd: add 'int idx_foo' argv index variablesDaniel Walton
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
2016-09-23convert <1-255> to (1-255), ()s to <>s, etcDaniel Walton
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
2016-09-22bgpd: argv update for all but bgp_vty.cDaniel Walton
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
2016-08-16lib, bgpd, tests: Refactor FILTER_X in zebra.hDonald Sharp
lib/zebra.h has FILTER_X #define's. These do not belong there. Put them in lib/filter.h where they belong. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com> (cherry picked from commit 0490729cc033a3483fc6b0ed45085ee249cac779)