Commit Graph

32852 Commits

Author SHA1 Message Date
Donald Sharp
8d56ba855b zebra: Remove vrf_id from passed around object
The nexthop that is stored already knows it's nexthop and
in all cases the vrf id is derived from the nexthop->vrf_id
let's just cut to the chase and not do this.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-08-11 11:06:04 -04:00
Donald Sharp
112bb33db5 zebra: import table match against interface name could fail
If an import table route-map is trying to match against
a particular interface, The code is matching against
the actual vrf the route entry is in -vs- the vrf
the nexthop entry is in.  Let's modify the code
to actually allow the import table entry to match
against the nexthops vrf.

Not working:

ip import-table 91
ip import-table 93 route-map FOO
no service integrated-vtysh-config
!
debug zebra events
!
interface green
 ip address 192.168.4.3/24
exit
!
route-map FOO permit 10
 match interface green
exit

eva# show ip route
Codes: K - kernel route, C - connected, S - static, R - RIP,
       O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
       T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP,
       F - PBR, f - OpenFabric,
       > - selected route, * - FIB route, q - queued, r - rejected, b - backup
       t - trapped, o - offload failure

K>* 0.0.0.0/0 [0/100] via 192.168.119.1, enp13s0, 1d10h07m
T[91]>* 1.2.3.5/32 [15/0] via 192.168.119.1, enp13s0, 00:00:05
K>* 169.254.0.0/16 [0/1000] is directly connected, virbr0 linkdown, 1d16h34m
C>* 192.168.44.0/24 is directly connected, virbr1, 01:30:51
C>* 192.168.45.0/24 is directly connected, virbr2, 01:30:51
C>* 192.168.119.0/24 is directly connected, enp13s0, 1d16h34m
C>* 192.168.122.0/24 is directly connected, virbr0 linkdown, 01:30:51
eva# show ip route table 91
Codes: K - kernel route, C - connected, S - static, R - RIP,
       O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
       T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP,
       F - PBR, f - OpenFabric,
       > - selected route, * - FIB route, q - queued, r - rejected, b - backup
       t - trapped, o - offload failure

VRF default table 91:
K>* 1.2.3.5/32 [0/0] via 192.168.119.1, enp13s0, 00:00:15
eva# show ip route table 93
Codes: K - kernel route, C - connected, S - static, R - RIP,
       O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
       T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP,
       F - PBR, f - OpenFabric,
       > - selected route, * - FIB route, q - queued, r - rejected, b - backup
       t - trapped, o - offload failure

VRF default table 93:
K * 1.2.3.4/32 [0/0] via 192.168.4.5, green (vrf green), 00:03:05

Working:

eva# show ip route
Codes: K - kernel route, C - connected, S - static, R - RIP,
       O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
       T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP,
       F - PBR, f - OpenFabric,
       > - selected route, * - FIB route, q - queued, r - rejected, b - backup
       t - trapped, o - offload failure

K>* 0.0.0.0/0 [0/100] via 192.168.119.1, enp13s0, 00:03:09
T[93]>* 1.2.3.4/32 [15/0] via 192.168.4.5, green (vrf green), 00:02:21
T[91]>* 1.2.3.5/32 [15/0] via 192.168.119.1, enp13s0, 00:02:26
K>* 169.254.0.0/16 [0/1000] is directly connected, virbr0, 00:03:09
C>* 192.168.44.0/24 is directly connected, virbr1, 00:03:09
C>* 192.168.45.0/24 is directly connected, virbr2, 00:03:09
C>* 192.168.119.0/24 is directly connected, enp13s0, 00:03:09
C>* 192.168.122.0/24 is directly connected, virbr0, 00:03:09
eva# show ip route table 91
Codes: K - kernel route, C - connected, S - static, R - RIP,
       O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
       T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP,
       F - PBR, f - OpenFabric,
       > - selected route, * - FIB route, q - queued, r - rejected, b - backup
       t - trapped, o - offload failure

VRF default table 91:
K * 1.2.3.5/32 [0/0] via 192.168.119.1, enp13s0, 00:03:12
eva# show ip route table 93
Codes: K - kernel route, C - connected, S - static, R - RIP,
       O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
       T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP,
       F - PBR, f - OpenFabric,
       > - selected route, * - FIB route, q - queued, r - rejected, b - backup
       t - trapped, o - offload failure

VRF default table 93:
K * 1.2.3.4/32 [0/0] via 192.168.4.5, green (vrf green), 00:03:14

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-08-11 10:33:16 -04:00
Donald Sharp
28a8065ec4 zebra: Rename struct nh_rmap_obj to struct zebra_rmap_obj
This structure is really the generic route map object for
handling routemaps in zebra.  Let's name it appropriately.
Future commits will consolidate the data to using the
struct route_entry as part of this data instead of copying
bits and bobs of it.  This will allow future work to
set/control the route_entry more directly.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-08-11 10:33:16 -04:00
Donald Sharp
1e8ac95bfb bgpd: evpn code was not properly unlocking rd_dest
Found some code where bgp was not unlocking the dest
and rd_dest when walking the tree attempting to
find something to install.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-08-11 10:11:10 -04:00
Donatas Abraitis
f1fda7bf84 bgpd: Assign explicit-null for default-originate according to the AFI
RFC 3032 defines:

A value of 2 represents the "IPv6 Explicit NULL Label".
This label value is only legal at the bottom of the label
stack.  It indicates that the label stack must be popped,
and the forwarding of the packet must then be based on the
IPv6 header.

Before this patch we set 128, but it was even more wrong, because it was sent
in host-byte order, not the network-byte.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-08-11 10:52:40 +03:00
Donatas Abraitis
e7dce035ab tests: Check if labeled IPv6 unicast default route works too
Also, check if remote label is explicit null according to the AFI.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-08-11 10:52:39 +03:00
Philippe Guibert
17c3f31642 topotests: add static mpls routing test
There is no test that checks for the mpls interface
configuration.
The new test checks that mpls configuration per
interface works when value is enabled or disabled.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2023-08-10 18:13:21 +02:00
Philippe Guibert
63be83eac5 doc: update mpls per interface command
Update mpls per interface command information.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2023-08-10 18:13:21 +02:00
Philippe Guibert
7832bbcc30 zebra, yang: add an mpls leaf to interface
The yang NB API does not handle the mpls configuration
on its leaf.
Add an mpls leaf to stick to the mpls configuration.
- true or false to mean if config
- not defined, means no config.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2023-08-10 18:13:21 +02:00
Philippe Guibert
8291e3a313 zebra: fix 'no mpls' command by using 'mpls disable' instead
The 'no mpls' command wrongly assumes the user wants to disable
the mpls handling on the interface whereas this is just a config
knob that should mean 'I don't care with mpls'.

Fix this by adding a 'disable' option to the mpls command.

Fixes: 39ffa8e8e8 ("zebra: Add a `mpls enable` interface node command")

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2023-08-10 18:13:21 +02:00
Donatas Abraitis
8ceb262401
Merge pull request #14171 from mjstapp/fix_bgp_lblpool_indent
bgpd: fix whitespace/indent in bgp_labelpool module
2023-08-10 16:20:28 +03:00
Donatas Abraitis
4751e9abb4
Merge pull request #14170 from mjstapp/fix_bitfield_mtype
libs: use XREALLOC in bitfield lib module
2023-08-10 14:17:28 +03:00
Donald Sharp
b886422443
Merge pull request #14169 from qlyoung/amalgamate-checkping
tests: amalgamate check_ping
2023-08-09 19:47:56 -04:00
Mark Stapp
2c11fbe4d3 bgpd: fix whitespace/indent in bgp_labelpool module
Fix some weird indentation in the bgp labelpool module.

Signed-off-by: Mark Stapp <mjs@labn.net>
2023-08-09 17:01:16 -04:00
Mark Stapp
82cde1f85b libs: use XREALLOC in bitfield lib module
Use FRR mem api instead of raw realloc() in bitfield module.

Signed-off-by: Mark Stapp <mjs@labn.net>
2023-08-09 16:19:40 -04:00
Quentin Young
e0c1b43814 tests: amalgamate check_ping
✂️📋

Signed-off-by: Quentin Young <qlyoung@qlyoung.net>
2023-08-09 15:46:29 -04:00
G. Paul Ziemba
ba240bcfa3 pbrd: add packet mangling actions (src/dst ip-addr/port, dscp, ecn)
Signed-off-by: G. Paul Ziemba <paulz@labn.net>
2023-08-09 12:11:43 -07:00
G. Paul Ziemba
887367a01c pbrd: use flags to indicate active fields
Before now, PBRD used non-zero values to imply that a rule's
    match or action field was active. This approach was getting
    cumbersome for fields where 0 is a valid active value and
    various field-specific magic values had to be used.

    This commit changes PBRD to use a flag bit per field to
    indicate that the field is active.

Signed-off-by: G. Paul Ziemba <paulz@labn.net>
2023-08-09 12:11:35 -07:00
Donatas Abraitis
df04c23c8f
Merge pull request #14073 from fdumontet6WIND/as_path_replace_reg
bgpd: add set as-path replace acl-list command
2023-08-09 15:28:58 +03:00
Donatas Abraitis
456b63d8c8
Merge pull request #14099 from lkClare/formated_sync_0727
bgpd: bgp_path_info_extra memory optimization
2023-08-09 14:46:48 +03:00
Francois Dumontet
7ac7cd804b doc: set as-path replace as-path-access-list
Signed-off-by: Francois Dumontet <francois.dumontet@6wind.com>
2023-08-09 11:13:38 +02:00
G. Paul Ziemba
c47fd378f3 pbrd: add explicit 'family' field for rules
In the netlink-mediated kernel dataplane, each rule is stored
    in either an IPv4-specific database or an IPv6-specific database.
    PBRD opportunistically gleans each rule's address family value
    from its source or destination IP address match value (if either
    exists), or from its nexthop or nexthop-group (if it exists).

    The 'family' value is particularly needed for netlink during
    incremental rule deletion when none of the above fields remain set.

    Before now, this address family has been encoded by occult means
    in the (possibly otherwise unset) source/destination IP match
    fields in ZAPI and zebra.

    This commit documents the reasons for maintaining the 'family'
    field in the PBRD rule structure, adds a 'family' field in the
    common lib/pbr.h rule structure, and carries it explicitly in ZAPI.

Signed-off-by: G. Paul Ziemba <paulz@labn.net>
2023-08-08 10:18:22 -07:00
G. Paul Ziemba
5572f45d51 pbrd: PBR_FILTER_DSFIELD -> {PBR_FILTER_DSCP,PBR_FILTER_ECN}
DSCP and ECN matching are configured independently. Maintain
    these values in independent fields in pbrd, zapi, and zebra.

Signed-off-by: G. Paul Ziemba <paulz@labn.net>
2023-08-08 10:18:22 -07:00
G. Paul Ziemba
09262f1b72 pbrd: add nexthop drop type
Signed-off-by: G. Paul Ziemba <paulz@labn.net>
2023-08-08 10:18:15 -07:00
Mark Stapp
cffa2472af
Merge pull request #14161 from opensourcerouting/fix/comment
bgpd: Fix RFC number in a comment
2023-08-08 12:36:58 -04:00
Russ White
a84dee73d1
Merge pull request #14154 from opensourcerouting/feature/bgpd_handle_role_capability_using_dynamic_capability
bgpd: Handle role capability using dynamic capability
2023-08-08 10:47:04 -04:00
Donatas Abraitis
2352bbf1bf
Merge pull request #14158 from donaldsharp/listnode_stuff
ospfd: Ensure listnode returns are usable
2023-08-08 16:31:57 +03:00
Donatas Abraitis
ffa7233fa1 bgpd: Fix RFC number in a comment
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-08-08 16:31:12 +03:00
Valerian_He
98efa5bc6b bgpd: bgp_path_info_extra memory optimization
Even if some of the attributes in bgp_path_info_extra are
not used, their memory is still allocated every time. It
cause a waste of memory.
This commit code deletes all unnecessary attributes and
changes the optional attributes to pointer storage. Memory
will only be allocated when they are actually used. After
optimization, extra info related memory is reduced by about
half(~400B -> ~200B).

Signed-off-by: Valerian_He <1826906282@qq.com>
2023-08-08 10:48:07 +00:00
Donatas Abraitis
85fe386079
Merge pull request #14157 from donaldsharp/blargle_smargle
bgpd: bgp_vrf is already deref'ed in all paths
2023-08-08 13:03:34 +03:00
Donald Sharp
296645fc78 ospfd: Ensure listnode returns are usable
Coverity is complaining that listnode can return a NULL
value and thus FRR could derefence the returned value.
Since this is not crashing we know that this is not happening
in the wild.  Let's make this an assert or check that it is
legal to use the value.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-08-07 15:57:29 -04:00
Donald Sharp
a67b223377
Merge pull request #14153 from idryzhov/vtysh-empty-interface
vtysh: fix checking empty interface node
2023-08-07 15:48:00 -04:00
G. Paul Ziemba
0e1bf005dc lib: pbr.h: remove unused PBR_FILTER_PROTO
Signed-off-by: G. Paul Ziemba <paulz@labn.net>
2023-08-07 12:29:41 -07:00
G. Paul Ziemba
c5d60c4a67 pbrd: pbr_vty.c organize/style
No functional changes: just arrange CLI handlers into logical
    order and standardize DEFPY formatting.

Signed-off-by: G. Paul Ziemba <paulz@labn.net>
2023-08-07 12:29:41 -07:00
Donald Sharp
e343833baa
Merge pull request #14155 from LabNConsulting/ziemba-zebra-pbr-ctx-common
zebra: zebra_dplane.[ch]: use pbr common struct in ctx
2023-08-07 15:15:25 -04:00
Donald Sharp
ad5329c7b0 bgpd: bgp_vrf is already deref'ed in all paths
The usage of bgp_vrf does not need to be tested
at this point since it's already been derefed in all
paths to this point.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-08-07 15:11:05 -04:00
G. Paul Ziemba
1c900cea90 zebra: zebra_dplane.[ch]: use pbr common struct in ctx
Signed-off-by: G. Paul Ziemba <paulz@labn.net>
2023-08-07 06:24:53 -07:00
Francois Dumontet
459e1cd903 tests: add one test to bgp_set_aspath_replace.py
add support of  set as-path replace as-path-access-list

Signed-off-by: Francois Dumontet <francois.dumontet@6wind.com>
2023-08-07 12:30:34 +02:00
Francois Dumontet
958340e935 bgpd: add set as-path exclude acl-list command
A route-map applied on incoming BGP updates is not able
to replace an unwanted as segments by another one.
unwanted as segment are 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 replace as-path-access-list RULE 6000

```
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
      6000 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)
```

Signed-off-by: Francois Dumontet <francois.dumontet@6wind.com>
2023-08-07 12:30:34 +02:00
Donald Sharp
529203905b
Merge pull request #14151 from opensourcerouting/fix/improve_addpath_selected_test
tests: Improve bgp_addpath_best_selected topotest
2023-08-06 17:01:16 -04:00
Donatas Abraitis
4735badb87
Merge pull request #14152 from idryzhov/vtysh-filter
vtysh: remove unused cmd_filter_type
2023-08-06 20:14:13 +03:00
Donatas Abraitis
ceea81be77
Merge pull request #14139 from donaldsharp/v6_v4_nexthops
V6 v4 nexthops
2023-08-06 20:11:19 +03:00
Donatas Abraitis
6d91d1c768
Merge pull request #14149 from donaldsharp/cleanup_bad_commands
Cleanup bad commands
2023-08-06 20:10:23 +03:00
Donatas Abraitis
50c5908c9f bgpd: Check if peer is established and dynamic capability-aware
Add this logic inside bgp_capability_send() instead of repeating the whole
logic before calling bgp_capability_send().

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-08-05 23:02:59 +03:00
Donatas Abraitis
2b5236dbb3 tests: Check if role capability is exchanged via dynamic capability
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-08-05 22:57:06 +03:00
Donatas Abraitis
454d37aec2 bgpd: Handle role capability using dynamic capability
When setting local-role for the neighbor, force sending ROLE capability via
dynamic capability if it's enabled.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-08-05 22:44:45 +03:00
Igor Ryzhov
cedba2406f vtysh: fix checking empty interface node
vtysh is not supposed to show empty interface node in running config,
however the corresponding check is broken and empty nodes are shown.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2023-08-05 00:46:45 +03:00
Igor Ryzhov
8c098c31db vtysh: remove unused cmd_filter_type
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2023-08-05 00:45:10 +03:00
Donatas Abraitis
0ba5225b92 tests: Drop duplicate neighbor definition
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-08-04 23:22:38 +03:00
Donald Sharp
d65249aa65
Merge pull request #14148 from opensourcerouting/fix/tests_bgp_addpath_failing_sometimes
tests: Use a correct syntax for defining keepalive/hold timers
2023-08-04 15:44:10 -04:00