Commit graph

59 commits

Author SHA1 Message Date
Donatas Abraitis 09e2a362a3 bgpd: Implement draft-li-idr-link-bandwidth-ext-01
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-04-22 17:50:08 +03:00
Igor Ryzhov c1b4976786 *: use af-specific autocompletion for prefix-lists when possible
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-02-04 22:26:48 +02:00
Christian Hopps 2c01083d35 lib: all: remove './' from xpath 22% speedup
fixes #8299

Signed-off-by: Christian Hopps <chopps@labn.net>
2023-11-29 14:37:23 -05:00
Philippe Guibert aa511000e0 bgpd: add 'match community-list any' function
There is no match mechanism to match one community from the
incoming community-list. Add the 'any' keyword to the 'match
route-map' command of communit-list and large-community-list.

> match community-list AAA any
> match large-community-list AAA any

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2023-10-02 15:24:18 +02:00
Farid Mihoub 902a8d1fd3 bgpd: add set extended-comm-list <> delete command
Signed-off-by: Farid Mihoub <farid.mihoub@6wind.com>
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2023-07-31 11:52:36 +02:00
Francois Dumontet b80ebc2d8c bgpd: add colored extended communities support
add support of color extended community, conforming to RFC 9012.
This extended community will be added to the existing one, RT,SOO
and Node Target. The configuration will be made through the
route-map service.

find above a configuration example:

router bgp 65001
 bgp router-id 192.168.1.1
 no bgp ebgp-requires-policy
 no bgp network import-check
 neighbor 192.168.1.2 remote-as external
 neighbor 192.168.1.3 remote-as external
 neighbor 192.168.1.4 remote-as external
 address-family ipv4 unicast
  network 10.10.10.10/24 route-map rmap
  exit-address-family
!
  route-map rmap permit 10
   set extcommunity color 55555 200
  exit

Signed-off-by: Francois Dumontet <francois.dumontet@6wind.com>
2023-06-26 14:27:27 +02:00
Donatas Abraitis 1c035c8c2c bgpd: Implement match source-protocol for route-maps
The main idea is to filter routes by matching source (originating) protocol
for outgoing direction. For instance, filter outgoing routes to an arbitrary
router that are static only. Or filter out only routes learned from RIP.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-05-11 11:39:23 +03:00
Russ White 4855ca5e56
Merge pull request #13310 from opensourcerouting/feature/bgpd_node_target_extended_community
bgpd: Add Node Target Extended Communities support
2023-04-25 11:06:23 -04:00
Jafar Al-Gharaibeh 055355e104 lib, ospfd, yang: add route map set for min/max metric
Signed-off-by: Jafar Al-Gharaibeh <jafar@atcorp.com>
2023-04-18 00:48:16 -05:00
Donatas Abraitis c9a2561444 bgpd: Implement Node Target Extended Communities
kttps://datatracker.ietf.org/doc/html/draft-ietf-idr-node-target-ext-comm

unet> sh r1 vtysh -c 'sh ip bgp nei 192.168.1.2 adver'
BGP table version is 1, local router ID is 192.168.1.1, vrf id 0
Default local pref 100, local AS 65001
Status codes:  s suppressed, d damped, h history, * valid, > best, = multipath,
               i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes:  i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

    Network          Next Hop            Metric LocPrf Weight Path
 *> 10.10.10.10/32   0.0.0.0                  0         32768 i

Total number of prefixes 1

unet> sh r1 vtysh -c 'sh ip bgp nei 192.168.1.3 adver'
BGP table version is 1, local router ID is 192.168.1.1, vrf id 0
Default local pref 100, local AS 65001
Status codes:  s suppressed, d damped, h history, * valid, > best, = multipath,
               i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes:  i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

    Network          Next Hop            Metric LocPrf Weight Path
 *> 10.10.10.10/32   0.0.0.0                  0         32768 i

Total number of prefixes 1

unet> sh r2 vtysh -c 'show ip bgp 10.10.10.10/32'
% Network not in table

unet> sh r3 vtysh -c 'show ip bgp 10.10.10.10/32'
BGP routing table entry for 10.10.10.10/32, version 1
Paths: (1 available, best #1, table default)
  Advertised to non peer-group peers:
  192.168.1.1
  65001
    192.168.1.1 from 192.168.1.1 (192.168.1.1)
      Origin IGP, metric 0, valid, external, best (First path received)
      Extended Community: NT:192.168.1.3 NT:192.168.1.4
      Last update: Tue Apr 11 23:19:33 2023

unet>

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-04-14 21:04:40 +03:00
David Lamparter acddc0ed3c *: auto-convert to SPDX License IDs
Done with a combination of regex'ing and banging my head against a wall.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-02-09 14:09:11 +01:00
Donald Sharp d7cde18c63
Merge pull request #12196 from opensourcerouting/xref-vtysh
*: rewrite `extract.pl` using `xref` infra
2022-11-03 08:54:09 -04:00
David Lamparter 89cb86aeb0 build, vtysh: extract vtysh commands from .xref
Rather than running selected source files through the preprocessor and a
bunch of perl regex'ing to get the list of all DEFUNs, use the data
collected in frr.xref.

This not only eliminates issues we've been having with preprocessor
failures due to nonexistent header files, but is also much faster.
Where extract.pl would take 5s, this now finishes in 0.2s.  And since
this is a non-parallelizable build step towards the end of the build
(dependent on a lot of other things being done already), the speedup is
actually noticeable.

Also files containing CLI no longer need to be listed in `vtysh_scan`
since the .xref data covers everything.  `#ifndef VTYSH_EXTRACT_PL`
checks are equally obsolete.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-10-26 17:12:34 +01:00
Donatas Abraitis 97a52c82a5 bgpd: Implement Accumulated IGP Metric Attribute for BGP
https://www.rfc-editor.org/rfc/rfc7311.html

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-10-26 11:26:57 +03:00
Russ White 7fa5e07b1c
Merge pull request #11899 from opensourcerouting/feature/route_validation_extended_community
bgpd: Implement Origin Validation State via extended communities
2022-09-13 11:30:54 -04:00
Philippe Guibert 1bb550b63c bgpd: add resolution for l3vpn traffic over gre interfaces
When a route imported from l3vpn is analysed, the nexthop from default
VRF is looked up against a valid MPLS path. Generally, this is done on
backbones with a MPLS signalisation transport layer like LDP. Generally,
the BGP connection is multiple hops away. That scenario is already
working.

There is case where it is possible to run L3VPN over GRE interfaces, and
where there is no LSP path over that GRE interface: GRE is just here to
tunnel MPLS traffic. On that case, the nexthop given in the path does not
have MPLS path, but should be authorized to convey MPLS traffic provided
that the user permits it via a configuration command.

That commit introduces a new command that can be activated in route-map:
 > set l3vpn next-hop encapsulation gre

That command authorizes the nexthop tracking engine to accept paths that
o have a GRE interface as output, independently of the presence of an LSP
path or not.

A configuration example is given below. When bgp incoming vpnv4 updates
are received, the nexthop of NLRI is 192.168.0.2. Based on nexthop
tracking service from zebra, BGP knows that the output interface to reach
192.168.0.2 is r1-gre0. Because that interface is not MPLS based, but is
a GRE tunnel, then the update will be using that nexthop to be installed.

    interface r1-gre0
     ip address 192.168.0.1/24
    exit
    router bgp 65500
     bgp router-id 1.1.1.1
     neighbor 192.168.0.2 remote-as 65500
     !
     address-family ipv4 unicast
      no neighbor 192.168.0.2 activate
     exit-address-family
     !
     address-family ipv4 vpn
      neighbor 192.168.0.2 activate
      neighbor 192.168.0.2 route-map rmap in
     exit-address-family
    exit
    !
    router bgp 65500 vrf vrf1
     bgp router-id 1.1.1.1
     no bgp network import-check
     !
     address-family ipv4 unicast
      network 10.201.0.0/24
      redistribute connected
      label vpn export 101
      rd vpn export 444:1
      rt vpn both 52:100
      export vpn
      import vpn
     exit-address-family
    exit
    !
    route-map rmap permit 1
     set l3vpn next-hop encapsulation gre
    exit

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2022-09-05 22:26:25 +02:00
Donatas Abraitis 324e8b1f79 bgpd: Handle Origin Validation State extended community via route-map match
Add an ability to match via route-maps. An additional route-map command

`match rpki-extcommunity <invalid|notfound|valid>` added.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-09-04 21:54:47 +03:00
Donatas Abraitis 77e3d82167 bgpd: Add set as-path replace <any|ASN> cmd for route-maps
```
route-map tstas permit 10
 set as-path replace 1
exit
```

Before:

```
donatas-laptop(config-router-af)# do show ip bgp 10.10.10.10/32
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)
      Last update: Mon Apr 25 10:39:50 2022
```

After:

```
donatas-laptop(config-router-af)# 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
  65000 65010 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)
      Last update: Mon Apr 25 10:40:16 2022
```

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-04-25 14:05:22 +03:00
Donatas Abraitis c90fab3c26 lib: Remove deprecated routemap_optimization_cmd
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-04-11 10:12:18 +03:00
Donatas Abraitis 49ecb8b807 bgpd: Show match script SCRIPT in running config
Before:
```
route-map lua permit 10
exit
```

After:
```
route-map lua permit 10
 match script rm
exit
```

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-03-31 09:39:52 +03:00
Igor Ryzhov fb2e99ef9c lib: routemap config output cleanup
Just a small cleanup to unify the code and remove duplication.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-12-03 21:00:01 +03:00
Donatas Abraitis 82f191a213 bgpd: Add an ability to match ipv6 next-hop by prefix-list
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-11-24 16:28:31 +02:00
Donatas Abraitis 8f241168b7 lib: Use autocomplete for route-map <name> <action> <seq>
```
exit1-debian-11(config)# route-map ?
  RMAP_NAME  Route map tag
     belekas testas
```

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-11-23 16:10:10 +02:00
Donatas Abraitis bc63ba980f bgpd: Add an ability to match ipv6 next-hop by access-list
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-11-23 13:47:26 +02:00
Igor Ryzhov 03030106ce bgpd, lib: fix inconsistency of match ip/ipv6 next-hop commands
For IPv4 matching, we have "match ip next-hop address A.B.C.D".
For IPv6 matching, we have "match ipv6 next-hop X:X::X:X".

To have consistency, let's add "address" keyword to IPv6 commands.
Old commands are preserved as hidden for backward compatibility.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-11-19 21:11:52 +03:00
Donatas Abraitis c60dec369a lib: Add autocomplete for access-lists
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-10-31 20:26:06 +02:00
Donatas Abraitis 943224a13a lib: Add autocomplete for prefix-list under route-maps
```
exit1-debian-9(config-route-map)# match ip route-source prefix-list ?
  <cr>
  PREFIXLIST_NAME  IP prefix-list name
     p1 p2
```

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-10-28 14:01:13 +03:00
Donald Sharp 6f354338f9
Merge pull request #9824 from idryzhov/nb-cli-const-lyd-node
lib: northbound cli show/cmd functions must not modify data nodes
2021-10-25 07:55:39 -04:00
Igor Ryzhov 2560505196 lib: northbound cli show/cmd functions must not modify data nodes
To ensure this, add a const modifier to functions' arguments. Would be
great do this initially and avoid this large code change, but better
late than never.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-10-13 20:12:35 +03:00
Igor Ryzhov 7e86999140 *: cleanup number-named access-lists in CLI
There's no more difference between number-named and word-named access-lists.
This commit removes separate arguments for number-named ACLs from CLI.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-10-08 19:25:41 +03:00
Russ White ce4f3813f0
Merge pull request #9439 from ton31337/feature/set_ext_community_to_none
bgpd: Route-map `set extcommunity none`
2021-09-01 12:55:45 -04:00
Christian Hopps d448e2c5f9
Merge pull request #9331 from idryzhov/explicit-exit
*: explicitly print "exit" at the end of every node config
2021-08-26 11:57:33 -04:00
Igor Ryzhov 14b066917b lib: remove the dependency on bgpd code
The library code should not depend on a specific daemon's code.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-08-24 17:42:37 +03:00
Igor Ryzhov 07679ad98a *: explicitly print "exit" at the end of every node config
There is a possibility that the same line can be matched as a command in
some node and its parent node. In this case, when reading the config,
this line is always executed as a command of the child node.

For example, with the following config:
```
router ospf
 network 193.168.0.0/16 area 0
!
mpls ldp
 discovery hello interval 111
!
```
Line `mpls ldp` is processed as command `mpls ldp-sync` inside the
`router ospf` node. This leads to a complete loss of `mpls ldp` node
configuration.

To eliminate this issue and all possible similar issues, let's print an
explicit "exit" at the end of every node config.

This commit also changes indentation for a couple of existing exit
commands so that all existing commands are on the same level as their
corresponding node-entering commands.

Fixes #9206.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-08-23 22:08:20 +03:00
Donatas Abraitis bb4dcdd13e bgpd: Add an ability to set extcommunity to none in route-maps
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-08-18 14:14:52 +03:00
Donatas Abraitis 71bdae66b2 bgpd: Keep extcommunity bandwidth commands persistent in route-maps
~/frr# vtysh -c 'conf' -c 'route-map testas permit 10' -c 'set extcommunity bandwidth 321'
~/frr# vtysh -c 'show route-map testas' | grep 321
    extcommunity bandwidth 321 non-transitive
~/frr# vtysh -c 'sh run' | grep 321
~/frr#

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-08-03 14:38:53 +03:00
Donatas Abraitis 2690f18cc8 bgpd: Add route-map match alias command
Will be handy to filter BGP prefixes by using BGP community alias
instead of numerical community values.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-07-21 09:26:14 +03:00
Ameya Dharkar d0a4ee6010 bgpd: Add "set evpn gateway-ip" clause for route-map
- Add following set clause for route-maps
  "set evpn gateway-ip <ipv4|ipv6 >A.B.C.D|X:X::X:X"
- When this route-map is applied as outboubd policy in BGP, it will set the
  gateway-ip in BGP attribute For EVPN type-5 routes.

Example configuration:

route-map RMAP-EVPN_GWIP permit 5
 set evpn gateway-ip ipv4 50.0.2.12
 set evpn gateway-ip ipv6 50:0:2::12

router bgp 101
 bgp router-id 10.100.0.1
 neighbor 10.0.1.2 remote-as 102
 !
 address-family l2vpn evpn
  neighbor 10.0.1.2 activate
  neighbor 10.0.1.2 route-map RMAP-EVPN_GWIP out
  advertise-all-vni
 exit-address-family

Signed-off-by: Ameya Dharkar <adharkar@vmware.com>
2021-06-07 17:58:22 -07:00
Igor Ryzhov 38133c4a11 lib, doc: add "route-map NAME optimization" command
Currently we have a "route-map optimization" command which is entered
from inside the route-map entry but actually applies to the whole
route-map. In addition, this command is not shown in the running-config
and not stored to the startup-config during "write".

Let's add a new command on the config node level to control this setting
and show it in the running-config to make possible to save it during
"write".

The old command is saved for the backward compatibility but hidden and
marked as deprecated.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-04-09 20:58:36 +03:00
Igor Ryzhov 3ebeec9446 lib: convert route-map optimization to NB
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-04-06 19:00:21 +03:00
Sarita Patra d5d737a2df lib: Modifications to route-map NB
This commit introduces the changes to the library route-map
north-bound callback implementation in order to align it to
the modified yang definitions.

Signed-off-by: NaveenThanikachalam <nthanikachal@vmware.com>
Signed-off-by: Sarita Patra <saritap@vmware.com>
2021-03-30 22:58:42 +03:00
Igor Ryzhov de8936be5e lib: sort route-map commands by sequence number in running-config
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-03-23 16:24:40 +03:00
David Schweizer 12488d7c8d
lib: fix negating set metric route-map command
Changed negating set metric route-map command to be usable in
conjunction with the affirming command.

Signed-off-by: David Schweizer <dschweizer@opensourcerouting.org>
2020-09-10 09:14:58 +02:00
Renato Westphal add39cde9d lib: fix the "set metric" route-map command
The "set metric" command wasn't processing metric additions and
subtractions (using + and -) correctly. Fix those problems.

Also, remove the "+metric" and "-metric" options since they don't
work and don't make any sense (they could be interpreted as unitary
increments/decrements but that was never supported).

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2020-09-09 14:53:26 -03:00
Rafael Zalamena 2068453728 lib: fix missing doc string in route map
Add the missing route map doc string for call command.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-08-07 14:37:02 -03:00
Donatas Abraitis 2b42623bd3
Merge pull request #6847 from donaldsharp/time_to_rerun
Time to rerun
2020-08-05 17:34:46 +03:00
Donald Sharp 680b9b6258 lib: Allow no call WORD
The `no call` cli was not accepting the original CLI as
a quick cut-n-paste.  This fixes that.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-08-04 10:16:14 -04:00
Renato Westphal b855e95fd3 lib: introduce configuration back-off timer for YANG-modeled commands
When using the default CLI mode, the northbound layer needs to create
a separate transaction to process each YANG-modeled command since
they are supposed to be applied immediately (there's no candidate
configuration nor the "commit" command like in the transactional
CLI). The problem is that configuration transactions have an overhead
associated to them, in big part because of the use of some heavy
libyang functions like `lyd_validate()` and `lyd_diff()`. As of
now this overhead is substantial and doesn't scale well when large
numbers of transactions need to be performed in sequence.

As an example, loading 50k prefix-lists using a single transaction
takes about 2 seconds on a modern CPU. Loading the same 50k
prefix-lists using 50k transactions can take more than an hour
to complete (which is unacceptable by any standard). To fix this
problem, some heavy optimization work needs to be done on libyang and
on the FRR northbound itself too (e.g. perform partial configuration
diffs whenever possible).  This, however, should be a long term
effort since these optimizations shouldn't be trivial to implement
and we're far from having the performance numbers we need.

In the meanwhile, this commit introduces a simple but efficient
workaround to alleviate the issue. In short, a new back-off timer
was introduced in the CLI to monitor and detect when too many
YANG-modeled commands are being received at the same time. When
a certain threshold is reached (100 YANG-modeled commands within
one second), the northbound starts to group all subsequent commands
into a single large transaction, which allows them to be processed
much faster (e.g. seconds and not hours).  It's essentially a
protection mechanism that creates dynamically-sized transactions
when necessary to prevent performance issues from happening. This
mechanism is enabled both when parsing configuration files and when
reading commands from a terminal.

The downside of this optimization is that, if several YANG-modeled
commands are grouped into the same transaction and at least one of
them fails, the whole transaction is rejected. This is undesirable
since users don't expect transactional behavior when that's not
enabled explicitly. To minimize this issue, the CLI will log all
commands that were rejected whenever that happens, to make the
user aware of what happened and have enough information to fix
the problem. Commands that fail due to parsing errors or CLI-level
validations in general are rejected separately.

Again, this proposed workaround is intended to be temporary. The
goal is to provided a quick fix to issues like #6658 while we work
on better long-term solutions.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2020-08-03 15:17:03 -03:00
Renato Westphal ca77b518bd *: introduce DEFPY_YANG & friends
DEFPY_YANG will allow the CLI to identify which commands are
YANG-modeled or not before executing them. This is going to be
useful for the upcoming configuration back-off timer work that
needs to commit pending configuration changes before executing a
command that isn't YANG-modeled.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2020-08-03 15:17:03 -03:00
Rafael Zalamena 375d157f0e lib,yang: merge cisco/zebra access list styles
Merge the cisco style access list with zebra's logic so we can mix both
types of rules while keeping the commands.

With this the cisco style limitation of having 'destination-*' only for
specific number ranges no longer exist for users of YANG/northbound (the
CLI still has this limitation).

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-07-19 15:27:56 -03:00