Commit graph

131 commits

Author SHA1 Message Date
Donatas Abraitis ca24f56a5c bgpd: Add an ability to disable link-local capability per peer
Even if we have unnumbered peering, let's respect `no neighbor X capability link-local`
and disable it per-neighbor on demand.

Fixes: db853cc97e ("bgpd: Implement Link-Local Next Hop capability")

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2025-02-11 17:01:56 +02:00
Donatas Abraitis 0050f82b8d bgpd: Send LL only if LL Next Hop capability is negotiated
If we have LL Next Hop capability exchanged, we should send LL-only as 16-bytes
NH instead of a GUA (global unicast).

Fixes: db853cc97e ("bgpd: Implement Link-Local Next Hop capability")

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2025-02-11 10:19:20 +02:00
Enke Chen 96ba273e4e bgpd: remove unused BATTR_REFLECTED for rmap_change_flags
Remove unused BATTR_REFLECTED for rmap_change_flags.

Signed-off-by: Enke Chen <enchen@paloaltonetworks.com>
2025-01-14 08:46:54 -08:00
Enke Chen fc82d7750f bgpd: fix AIGP calculation in route advertisement
Currently the AIGP is always incremented when a route with the
attribute is advertised. That is incorrect when the nexthop is
unchanged, as is commonly the case in route reflection.

Adjust the AIGP for propagation only when the nexthop is set
to ourselves.

Signed-off-by: Enke Chen <enchen@paloaltonetworks.com>
2024-10-21 18:03:08 -07:00
Louis Scalbert a152692f5a bgpd: fix labels static-analyser
Fix static-analyser warnings with BGP labels:

> $ scan-build make -j12
> bgpd/bgp_updgrp_packet.c:819:10: warning: Access to field 'extra' results in a dereference of a null pointer (loaded from variable 'path') [core.NullDereference]
>                                                 ? &path->extra->labels->label[0]
>                                                    ^~~~~~~~~

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2024-08-26 10:29:12 +02:00
Jafar Al-Gharaibeh 741c030395 Revert "Merge pull request #15368 from louis-6wind/fix-6pe"
This reverts commit df98e88368, reversing
changes made to b652119235.
2024-08-22 10:38:09 -05:00
Jafar Al-Gharaibeh 0097489b4a Revert "Merge pull request #15614 from louis-6wind/fix-6pe-address"
This reverts commit b3600d82dc, reversing
changes made to 51119823d0.
2024-08-21 13:37:43 -05:00
Jafar Al-Gharaibeh 0d2d20825e Revert "Merge pull request #16439 from louis-6wind/fix-ipv4-mapped-ipv6"
This reverts commit cc0fdd3b1d, reversing
changes made to 4e208087fd.
2024-08-21 13:26:50 -05:00
Donald Sharp 89a3879973
Merge pull request #16549 from opensourcerouting/fix/some_memory_optimizations_for_struct_attr
bgpd: Move evpn_overlay to a pointer
2024-08-15 09:20:41 -04:00
Donatas Abraitis 4ace11d010 bgpd: Move evpn_overlay to a pointer
Before this convertion:

```
	/* --- cacheline 3 boundary (192 bytes) --- */
	struct bgp_attr_encap_subtlv * encap_subtlvs;    /*   192     8 */
	struct bgp_attr_encap_subtlv * vnc_subtlvs;      /*   200     8 */
	struct bgp_route_evpn      evpn_overlay;         /*   208    36 */
```

After this convertion:

```
	/* --- cacheline 3 boundary (192 bytes) --- */
	struct bgp_attr_encap_subtlv * encap_subtlvs;    /*   192     8 */
	struct bgp_attr_encap_subtlv * vnc_subtlvs;      /*   200     8 */
	struct bgp_route_evpn *    evpn_overlay;         /*   208     8 */
```

Saving 28 bytes when EVPN is not used.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-08-11 13:59:13 +03:00
Louis Scalbert 5d2289db26 bgpd: replace ipv4-mapped ipv6 at update forwarding
Replace IPv4-mapped IPv6 at update forwarding because the peer may not
be able to create a route with the IPv4-mapped IPv6.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2024-07-24 10:17:42 +02:00
Louis Scalbert 15fb7209ee bgpd: fix ipv4-mapped ipv6 for ipv6 over ipv4 peer
When IPv6 prefixes are sent over an IPv4 session, the UPDATE is sent
with a link-local nexthop as global nexthop instead of a IPv4-mapped
IPv6 address. If the peer interface has no IPv6 address, routes are
not installed.

Seen with bgp_nexthop_mp_ipv4_6 topotests on step2:

> root@r2:/# vtysh -c 'show bgp ipv6 fd00💯:/64 json' | jq .
> {
>   "prefix": "fd00💯:/64",
>   "paths": [
>     {
>       "nexthops": [
>         {
>           "ip": "fe80::449a:f8ff:fe67:1f93",
>           "hostname": "r1",
>           "afi": "ipv6",
>           "scope": "global",
>           "metric": 0,
>           "accessible": true
>         },
>         {
>           "ip": "fe80::449a:f8ff:fe67:1f93",
>           "hostname": "r1",
>           "afi": "ipv6",
>           "scope": "link-local",
>           "accessible": true,
>           "used": true
>         }
>       ],
>     }
>   ]
> }

Now:

> root@r2:/# vtysh -c 'show bgp ipv6 fd00💯:/64 json' | jq .
> {
>   "prefix": "fd00💯:/64",
>   "paths": [
>       "nexthops": [
>         {
>           "ip": "::ffff:172.16.0.1",
>           "hostname": "r1",
>           "afi": "ipv6",
>           "scope": "global",
>           "metric": 0,
>           "accessible": true
>         },
>         {
>           "ip": "fe80::3842:28ff:fe90:f815",
>           "hostname": "r1",
>           "afi": "ipv6",
>           "scope": "link-local",
>           "accessible": true,
>           "used": true
>         }
>       ],
>     }
>   ]
> }

Note that the link-local is still preferred over the global address.

Fixes: 25995695f5 ("bgpd: set ipv4-mapped ipv6 for ipv4 with ipv6 nexthop")
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2024-07-24 10:17:42 +02:00
Louis Scalbert ca32945b1f bgpd: move labels from extra to extra->labels
Move labels from extra to extra->labels. Labels are now stored in a hash
list.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2024-06-05 13:11:29 +02:00
Louis Scalbert a6de910448 bgpd: store number of labels with 8 bits
8 bits are sufficient to store the number of labels because the current
maximum is 2.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2024-06-05 13:11:29 +02:00
Louis Scalbert 64fe15fd28 bgpd: add bgp_path_info_num_labels()
Add bgp_path_info_num_labels() to get the number of labels stored in
a path_info structure.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2024-06-05 11:08:46 +02:00
Louis Scalbert fc5a738409 bgpd: set ipv4-mapped ipv6 for ipv4 with ipv6 nexthop
The code was expected that no IPv6 global address was present but the
previous commit was replacing nexthop.v6global by the link-local address
instead of un-setting it in case of removal of the IPv6 global.

Set also ipv4-mapped ipv6 address as nexthop when a link-local is found
and it is an ipv4 prefix over ipv6 nexthop.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2024-04-23 11:28:36 +02:00
Louis Scalbert d346d1ac41 Revert "bgpd: fix 6vpe nexthop"
This reverts commit 0325116a27.

It was causing an issue where a nexthop for IPv6 over an IPv4 session
was always rewritten to an IPv4-mapped IPv6 address even when a valid
IPv6 global address was existing.

Link: https://github.com/FRRouting/frr/issues/15610
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2024-04-23 11:26:49 +02:00
Louis Scalbert 0325116a27 bgpd: fix 6vpe nexthop
6vPE enables the announcement of IPv6 VPN prefixes through an IPv4 BGP
session. In this scenario, the next hop addresses for these prefixes are
represented in an IPv4-mapped IPv6 format, noted as ::ffff:[IPv4]. This
format indicates to the peer that it should route these IPv6 addresses
using information from the IPv4 nexthop. For example:

> Path Attribute - MP_REACH_NLRI
> [...]
>     Address family identifier (AFI): IPv6 (2)
>     Subsequent address family identifier (SAFI): Labeled VPN Unicast (128)
>     Next hop:  RD=0:0 IPv6=::ffff:192.0.2.5 RD=0:0 Link-local=fe80::501d:42ff:feef:b021
>     Number of Subnetwork points of attachment (SNPA): 0

This rule is set out in RFC4798:

> The IPv4 address of the egress 6PE router MUST be encoded as an
> IPv4-mapped IPv6 address in the BGP Next Hop field.

However, in some situations, bgpd sends a standard nexthop IPv6 address
instead of an IPv4-mapped IPv6 address because the outgoing interface for
the BGP session has a valid IPv6 address. This is problematic because
the peer router may not be able to route the nexthop IPv6 address (ie.
if the outgoing interface has not IPv6).

Fix the issue by always sending a IPv4-mapped IPv6 address as nexthop
when the BGP session is on IPv4 and address family IPv6.

Link: https://datatracker.ietf.org/doc/html/rfc4798#section-2
Fixes: 92d6f76 ("lib,zebra,bgpd: Fix for nexthop as IPv4 mapped IPv6 address")
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2024-02-26 10:17:08 +01: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
Philippe Guibert 98c615f05a bgpd: advertise mpls vpn routes with appropriate label
The advertised label value from mpls vpn routes is not modified
when the advertised next-hop is modified to next-hop-self.

Actually, the original label value received is redistributed as
is, whereas the new_label value bound in the nexthop label
bind entry should be used.

Only the VPN entries that contain MPLS information, and that
are redistributed between distinct peers, will have a label
value to advertise.
- no SRv6 attribute
- no local prefix
- no exported VPN prefixes from a VRF

If the advertisement to a given peer has the next-hop modified,
then the new label value will be picked up. The considered cases
are peers configured with 'next-hop-self' option, or ebgp peerings
without the 'next-hop-unchanged' option.

Note that the the NLRI format will follow the rfc3107 format, as
multiple label values for MPLS VPN NLRIs are not supported (the
rfc8277 is not supported).
Note also that the case where an outgoing route-map is applied to
the outgoing neighbor is not considered in this commit.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2023-06-16 10:54:58 +02:00
Donald Sharp 24a58196dd *: Convert event.h to frrevent.h
We should probably prevent any type of namespace collision
with something else.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24 08:32:17 -04:00
Donald Sharp cb37cb336a *: Rename thread.[ch] to event.[ch]
This is a first in a series of commits, whose goal is to rename
the thread system in FRR to an event system.  There is a continual
problem where people are confusing `struct thread` with a true
pthread.  In reality, our entire thread.c is an event system.

In this commit rename the thread.[ch] files to event.[ch].

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24 08:32:16 -04: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
Donatas Abraitis 2de5f5b5f8 bgpd: Announce labeled-unicast default-originate
Without this patch, this just crashes:

```
(gdb) bt
0  raise (sig=sig@entry=11) at ../sysdeps/unix/sysv/linux/raise.c:51
1  0x00007f66d977b10c in core_handler (signo=11, siginfo=0x7ffd87aa0430, context=<optimized out>) at lib/sigevent.c:261
2  <signal handler called>
3  stream_put_labeled_prefix (s=s@entry=0x55bd3ce53050, p=p@entry=0x7ffd87aa0a20, label=label@entry=0x0, addpath_capable=<optimized out>, addpath_tx_id=addpath_tx_id@entry=1)
    at lib/stream.c:1057
4  0x000055bd3bfba176 in bgp_packet_mpattr_prefix (s=s@entry=0x55bd3ce53050, afi=afi@entry=AFI_IP, safi=safi@entry=SAFI_LABELED_UNICAST, p=p@entry=0x7ffd87aa0a20, prd=prd@entry=0x0,
    label=label@entry=0x0, num_labels=0, addpath_capable=true, addpath_tx_id=1, attr=0x7ffd87aa2c20) at bgpd/bgp_attr.c:3964
5  0x000055bd3bfba2b5 in bgp_packet_attribute (bgp=0x55bd3cd8e470, bgp@entry=0x0, peer=peer@entry=0x55bd3cf21fc0, s=s@entry=0x55bd3ce53050, attr=attr@entry=0x7ffd87aa2c20,
    vecarr=vecarr@entry=0x7ffd87aa0a10, p=p@entry=0x7ffd87aa0a20, afi=AFI_IP, safi=SAFI_LABELED_UNICAST, from=0x7f66d9ba9010, prd=0x0, label=0x0, num_labels=0, addpath_capable=true,
    addpath_tx_id=1, bpi=0x0) at bgpd/bgp_attr.c:4139
6  0x000055bd3c04d455 in subgroup_default_update_packet (subgrp=subgrp@entry=0x55bd3cd885b0, attr=attr@entry=0x7ffd87aa2c20, from=from@entry=0x7f66d9ba9010) at bgpd/bgp_updgrp_packet.c:1129
7  0x000055bd3c04a9a5 in subgroup_default_originate (subgrp=0x55bd3cd885b0, withdraw=withdraw@entry=0) at bgpd/bgp_updgrp_adv.c:972
8  0x000055bd3c022668 in bgp_default_originate (peer=peer@entry=0x7f66d574a010, afi=afi@entry=AFI_IP, safi=safi@entry=SAFI_LABELED_UNICAST, withdraw=withdraw@entry=0)
    at bgpd/bgp_route.c:5037
9  0x000055bd3c0922e0 in peer_default_originate_set (peer=0x7f66d574a010, afi=afi@entry=AFI_IP, safi=safi@entry=SAFI_LABELED_UNICAST, rmap=rmap@entry=0x0, route_map=route_map@entry=0x0)
    at bgpd/bgpd.c:5428
10 0x000055bd3c076c07 in peer_default_originate_set_vty (set=1, rmap=0x0, safi=SAFI_LABELED_UNICAST, afi=AFI_IP, peer_str=<optimized out>, vty=0x55bd3ce4c900) at bgpd/bgp_vty.c:6941
11 neighbor_default_originate (self=<optimized out>, vty=0x55bd3ce4c900, argc=<optimized out>, argv=<optimized out>) at bgpd/bgp_vty.c:6958
12 0x00007f66d9721dc0 in cmd_execute_command_real (vline=vline@entry=0x55bd3cd874d0, vty=vty@entry=0x55bd3ce4c900, cmd=cmd@entry=0x0, up_level=up_level@entry=0, filter=FILTER_RELAXED)
    at lib/command.c:996
13 0x00007f66d9721f39 in cmd_execute_command (vline=vline@entry=0x55bd3cd874d0, vty=vty@entry=0x55bd3ce4c900, cmd=cmd@entry=0x0, vtysh=vtysh@entry=0) at lib/command.c:1055
14 0x00007f66d9722162 in cmd_execute (vty=vty@entry=0x55bd3ce4c900, cmd=cmd@entry=0x55bd3cd8a230 "neighbor 192.168.34.4 default-originate ", matched=matched@entry=0x0, vtysh=vtysh@entry=0)
    at lib/command.c:1223
15 0x00007f66d9792337 in vty_command (vty=vty@entry=0x55bd3ce4c900, buf=<optimized out>) at lib/vty.c:486
16 0x00007f66d9792570 in vty_execute (vty=0x55bd3ce4c900) at lib/vty.c:1249
```

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-12-07 23:18:07 +02:00
Donatas Abraitis 6eeb925545 bgpd: Allow overriding MPLS VPN next-hops via route-maps
Just do not reset next-hop for MPLS VPN routes.

Example of 172.16.255.1/32 (using extended next-hop capability):

```
pe2# sh bgp ipv4 vpn
BGP table version is 4, local router ID is 10.10.10.20, 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
Route Distinguisher: 192.168.1.2:2
 *>i10.0.0.0/24      2001:db8:1::1            0    100      0 65000 ?
    UN=2001:db8:1::1 EC{192.168.1.2:2} label=1111 type=bgp, subtype=0
 *>i172.16.255.1/32  2001:db8::1              0    100      0 65000 ?
    UN=2001:db8::1 EC{192.168.1.2:2} label=1111 type=bgp, subtype=0
 *>i192.168.1.0/24   2001:db8:1::1            0    100      0 65000 ?
    UN=2001:db8:1::1 EC{192.168.1.2:2} label=1111 type=bgp, subtype=0
 *>i192.168.2.0/24   2001:db8:1::1                 100      0 65000 ?
    UN=2001:db8:1::1 EC{192.168.1.2:2} label=1111 type=bgp, subtype=0
Route Distinguisher: 192.168.2.2:2
 *> 10.0.0.0/24      192.168.2.1@4<           0     50      0 65000 ?
    UN=192.168.2.1 EC{192.168.2.2:2} label=2222 type=bgp, subtype=5
 *> 172.16.255.1/32  192.168.2.1@4<                 50      0 65000 ?
    UN=192.168.2.1 EC{192.168.2.2:2} label=2222 type=bgp, subtype=5
 *> 192.168.1.0/24   192.168.2.1@4<                 50      0 65000 ?
    UN=192.168.2.1 EC{192.168.2.2:2} label=2222 type=bgp, subtype=5
 *> 192.168.2.0/24   192.168.2.1@4<           0     50      0 65000 ?
    UN=192.168.2.1 EC{192.168.2.2:2} label=2222 type=bgp, subtype=5

Displayed  8 routes and 8 total paths
```

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-11-18 16:17:15 +02:00
Russ White a5dac02901
Merge pull request #12114 from opensourcerouting/feature/bgp_aigp_attribute
bgpd: Implement AIGP
2022-10-31 11:24:43 -04:00
Ryoga Saito 5b786189bc bgpd: Fix the condition whether nexthop is changed
Given that the following topology, route server MUST not modify NEXT_HOP
attribute because route server isn't in the actual routing path. This
behavior is required to comply RFC7947

(Router A) <-(eBGP peer)-> (Route Server) <-(eBGP peer)-> (Router B)

RFC7947 says as follows:

> As the route server does not participate in the actual routing of
> traffic, the NEXT_HOP attribute MUST be passed unmodified to the route
> server clients, similar to the "third-party" next-hop
> feature described in Section 5.1.3. of [RFC4271].

However, current FRR is violating RFC7947 in some cases. If routers and
route server established BGP peer over IPv6 connection and routers
advertise ipv4-vpn routes through route server, route server will modify
NEXT_HOP attribute in these advertisements.

This is because the condition to check whether NEXT_HOP attribute should
be changed or not is wrong. We should use (afi, safi) as the key to
check, but (nhafi, safi) is actually used. This causes the RFC7947
violation.

Signed-off-by: Ryoga Saito <ryoga.saito@linecorp.com>
2022-10-27 10:38:05 +09: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
Iqra Siddiqui 46c4f05bb6 bgpd: Inconsistencies in SNT counters with default-originate
Description:
Change is intended for fixing the inconsistencies present
while adjusting the SNT counters with default originate.

- SNT counter gets incremented on every change of policy associated
  with default-originate, leading to inconsistencies.
- This fix has been added to ensure that the SNT counters gets
  incremented and decremented only once during the creation and
  deletion workflow of default-originate, and prevents
  incrementing the counter during update flow.

Co-authored-by: Abhinay Ramesh <rabhinay@vmware.com>
Signed-off-by: Iqra Siddiqui <imujeebsiddi@vmware.com>
2022-07-06 05:38:35 +00:00
Donatas Abraitis e8e36ff315 bgpd: Convert bpacket_attr_vec_type to enum
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-04-12 22:13:55 +03:00
Donatas Abraitis be92fc9f1a bgpd: Convert bgp_addpath_encode_[tr]x() to bool from int
Rename addpath_encode[d] to addpath_capable to be consistent.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2022-02-01 13:31:16 +02:00
Louis Scalbert d0bf49ecd5 bgpd: apply maximum-prefix-out without clearing the neighbor
Abstract:
- The command "neighbor PEER maximum-prefix-out NUMBER" cannot be applied
  without clearing the BGP neighbor.
- Apply the maximum-prefix-out value as soon as it is modified without
  clearing the neighbor.

subgroup_update_packet() and subgroup_withdraw_packet() respectively
manages the announcement and withdrawal BGP message to the peer.
subgrp->scount counter counts the number of sent prefixes.

Before the patch, the maximum out prefix limitation was applied in
subgroup_update_packet() in order that subgrp->scount never exceeds the
limit. Setting a limit inferior to the effective number of sent prefix
did not result in sending any withdrawal message to reduce the number of
sent prefixes. Without clearing the BGP neighbor, the limitation only
applied to the announcement of new prefixes when the limitation was
over.

With the patch, the limitation is checked in subgroup_announce_check().
The function is intended to say whether a prefix has to be announced in
regards to the prefix-list, route-map... Now when a maximum-prefix-out
value is changed/removed, the neighbor AFI/SAFI table is re-parsed in
the same way as for the application of route-map, prefix-lists...

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2022-01-20 18:19:37 +01:00
Donatas Abraitis fea96c555b bgpd: Increase sent prefix count per subgrp when originating default route
Before we didn't count default-originate to pfxSnt.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-07-14 23:55:20 +03:00
Ameya Dharkar 6c995628c1 bgpd: Generate and advertise gateway IP overlay index with EVPN RT-5
Gateway IP overlay index is generated for EVPN RT-5 when following CLI is
configured.

router bgp 100 vrf vrf-blue
 address-family l2vpn evpn
  advertise ipv4 unicast gateway-ip
  advertise ipv6 unicast gateway-ip

BGP nexthop of the VRF IP/IPv6 route is set as the gateway IP of the
corresponding EVPN RT-5

Signed-off-by: Ameya Dharkar <adharkar@vmware.com>
2021-06-07 17:58:22 -07:00
Donald Sharp c0d72166ee bgpd: Convert remaining string output to our internal types
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-03-09 19:50:42 -05:00
Donatas Abraitis ef56aee47c bgpd: Add BGP Extended message support
Implement https://www.rfc-editor.org/rfc/rfc8654.txt

```
> | jq '."192.168.10.25".neighborCapabilities.extendedMessage'
"advertisedAndReceived"
```

Another side is Bird:

```
BIRD 2.0.7 ready.
Name       Proto      Table      State  Since         Info
v4         BGP        ---        up     19:39:15.689  Established
  BGP state:          Established
    Neighbor address: 192.168.10.123
    Neighbor AS:      65534
    Local AS:         65025
    Neighbor ID:      192.168.100.1
    Local capabilities
      Multiprotocol
        AF announced: ipv4
      Route refresh
      Extended message
      Graceful restart
      4-octet AS numbers
      Enhanced refresh
      Long-lived graceful restart
    Neighbor capabilities
      Multiprotocol
        AF announced: ipv4
      Route refresh
      Extended message
      Graceful restart
      4-octet AS numbers
      ADD-PATH
        RX: ipv4
        TX:
      Enhanced refresh
    Session:          external AS4
    Source address:   192.168.10.25
    Hold timer:       140.139/180
    Keepalive timer:  9.484/60
  Channel ipv4
    State:          UP
    Table:          master4
    Preference:     100
    Input filter:   ACCEPT
    Output filter:  ACCEPT
    Routes:         9 imported, 3 exported, 8 preferred
    Route change stats:     received   rejected   filtered    ignored   accepted
      Import updates:              9          0          0          0          9
      Import withdraws:            2          0        ---          2          0
      Export updates:             11          8          0        ---          3
      Export withdraws:            0        ---        ---        ---          0
    BGP Next hop:   192.168.10.25
```

Tested at least as well with to make sure it works with backward compat.:
	ExaBGP 4.0.2-1c737d99.
	Arista vEOS 4.21.14M

Testing by injecint 10k routes with:
```
sharp install routes 172.16.0.1 nexthop 192.168.10.123 10000
```

Before extended message support:
```
2021/03/01 07:18:51 BGP: u1:s1 send UPDATE len 4096 (max message len: 4096) numpfx 809
2021/03/01 07:18:51 BGP: u1:s1 send UPDATE len 4096 (max message len: 4096) numpfx 809
2021/03/01 07:18:51 BGP: u1:s1 send UPDATE len 4096 (max message len: 4096) numpfx 809
2021/03/01 07:18:51 BGP: u1:s1 send UPDATE len 4096 (max message len: 4096) numpfx 809
2021/03/01 07:18:51 BGP: u1:s1 send UPDATE len 4096 (max message len: 4096) numpfx 809
2021/03/01 07:18:51 BGP: u1:s1 send UPDATE len 4096 (max message len: 4096) numpfx 809
2021/03/01 07:18:52 BGP: u1:s1 send UPDATE len 4096 (max message len: 4096) numpfx 809
2021/03/01 07:18:52 BGP: u1:s1 send UPDATE len 4096 (max message len: 4096) numpfx 809
2021/03/01 07:18:52 BGP: u1:s1 send UPDATE len 4096 (max message len: 4096) numpfx 809
2021/03/01 07:18:52 BGP: u1:s1 send UPDATE len 4096 (max message len: 4096) numpfx 809
2021/03/01 07:18:52 BGP: u1:s1 send UPDATE len 4096 (max message len: 4096) numpfx 809
2021/03/01 07:18:52 BGP: u1:s1 send UPDATE len 2186 (max message len: 4096) numpfx 427
2021/03/01 07:18:53 BGP: u1:s1 send UPDATE len 3421 (max message len: 4096) numpfx 674
```

After extended message support:
```
2021/03/01 07:20:11 BGP: u1:s1 send UPDATE len 50051 (max message len: 65535) numpfx 10000
```

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-03-04 21:32:36 +02:00
Donald Sharp 9669fbde13 bgpd: Centralize the dest unlocking for adj_out data structure
When FRR creates a adj_out data structure we lock the `struct
bgp_dest` node associated with it.  On freeing of this data
structure and removing the lock it was not associated with
the actual free of the adjacency structure.  Let's clean up
the lock/unlock to be centralized to the alloc/free of the adj_out.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-02-01 10:25:09 -05:00
Donald Sharp 62e0464d73 bgpd: Remove #if 0 code
Remove all dead #if 0 code from bgpd.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-01-28 13:57:49 -05:00
Donatas Abraitis 3a6290bdd1 *: Replace s_addr check agains 0 with INADDR_ANY
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-12-14 21:03:38 +02:00
Donatas Abraitis adf086ec58 bgpd: Print afi/safi as strings when handling update/withdraw in zlog_debug
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-12-11 11:44:38 +02:00
Donatas Abraitis 2dbe669bdf :* Convert prefix2str to %pFX
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-10-22 09:07:41 +03:00
Donatas Abraitis 23d0a75356 bgpd: Convert inet_ntoa to %pI4/inet_ntop
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-10-18 11:22:30 +03:00
Renato Westphal 4fe5bc8c62
Merge pull request #6943 from ton31337/fix/replace_sizeof_instead_of_constant_for_bgp_dump_attr
bgpd: Use sizeof() in bgp_dump_attr()
2020-08-19 07:36:13 -03:00
Donatas Abraitis 5022c8331d bgpd: Use sizeof() in bgp_dump_attr()
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-08-18 21:43:07 +03:00
Kaushik 92d6f76988 lib,zebra,bgpd: Fix for nexthop as IPv4 mapped IPv6 address
Added a macro to validate the v4 mapped v6 address.
Modified bgp receive & send updates for v4 mapped v6 address as
nexthop and installing it as recursive nexthop in RIB.
Minor change in fpm while sending the routes for nexthop as
v4 mapped v6 address.

Signed-off-by: Kaushik <kaushik@niralnetworks.com>
2020-08-03 23:24:04 -07:00
David Lamparter 6cde4b4552 *: remove PRI[udx](8|16|32)
These are completely pointless and break coccinelle string replacements.

Scripted commit, idempotent to running:
```
python3 tools/stringmangle.py --pri8-16-32 `git ls-files | egrep '\.[ch]$'`
```

Signed-off-by: David Lamparter <equinox@diac24.net>
2020-07-14 10:43:40 +02:00
Donald Sharp 9bcb3eef54 bgp: rename bgp_node to bgp_dest
This is the bulk part extracted from "bgpd: Convert from `struct
bgp_node` to `struct bgp_dest`".  It should not result in any functional
change.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2020-06-23 17:32:52 +02:00
Donatas Abraitis 3ddd699401 bgpd: Use constants for nexthop length instead of just numbers
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-06-13 20:36:59 +03:00
Donald Sharp b54892e0ea bgpd: Convert users of rn->p to use accessor function
Add new function `bgp_node_get_prefix()` and modify
the bgp code base to use it.

This is prep work for the struct bgp_dest rework.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-03-26 16:25:16 -04:00
Donatas Abraitis 3dc339cdc2 bgpd: Convert lots of int type functions to bool/void
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-03-21 14:59:18 +02:00