1
0
mirror of https://github.com/osrg/gobgp.git synced 2024-05-11 05:55:10 +00:00

367 Commits

Author SHA1 Message Date
Arthur de Kerhor
3ae91215be graceful restart: send initial paths list to all neighbors
Before this PR, when graceful restart was configured for a neighbor
and when the restart flag was set by the restarting speaker, if
the neighbor was not advertising the GR capability, the initial
paths list was never sent by the restarting speaker to its neighbor

This is a problem when the server is configured with graceful
restart for all its peers without knowing if the peer supports it.
If some of the peers don't support it, they may never receive the
routes from the restarting speaker, leading to an inconsistent
routing state.
2024-04-30 16:05:51 +02:00
Tuetuopay
78516cf8af server: fix nil pointer exception in evpn mac mobility
With large EVPN fabrics, it can happen that some paths are nil in the
mac mobility codepath, causing crashes of the process.

    panic: runtime error: invalid memory address or nil pointer dereference
    [signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0xb8e03a]
    goroutine 25 [running]:
    github.com/osrg/gobgp/v3/internal/pkg/table.(*Path).root(...)
        /home/tuetuopay/dev/gobgp/internal/pkg/table/path.go:341
    github.com/osrg/gobgp/v3/internal/pkg/table.(*Path).OriginInfo(...)
        /home/tuetuopay/dev/gobgp/internal/pkg/table/path.go:348
    github.com/osrg/gobgp/v3/internal/pkg/table.(*Path).GetNlri(...)
        /home/tuetuopay/dev/gobgp/internal/pkg/table/path.go:460
    github.com/osrg/gobgp/v3/pkg/server.getMacMobilityExtendedCommunity(0x0, {0xc002833520, 0x6, 0xc00033ec00?}, {0xc001a52008, 0xa72, 0xc000000000?})
        /home/tuetuopay/dev/gobgp/pkg/server/server.go:2044 +0x1da
    github.com/osrg/gobgp/v3/pkg/server.(*BgpServer).fixupApiPath(0xc000372008, {0x0, 0x0}, {0xc0008fbe48, 0x1, 0x0?})
        /home/tuetuopay/dev/gobgp/pkg/server/server.go:2120 +0x4bc
    github.com/osrg/gobgp/v3/pkg/server.(*BgpServer).addPathList(0xc000372008, {0x0?, 0x0?}, {0xc0008fbe48, 0x1, 0x1})
        /home/tuetuopay/dev/gobgp/pkg/server/server.go:2162 +0x2c
    github.com/osrg/gobgp/v3/pkg/server.(*BgpServer).AddPath.func1()
        /home/tuetuopay/dev/gobgp/pkg/server/server.go:2191 +0xa5
    github.com/osrg/gobgp/v3/pkg/server.(*BgpServer).handleMGMTOp(0xc0b4e0?, 0xc001243140)
        /home/tuetuopay/dev/gobgp/pkg/server/server.go:280 +0x82
    github.com/osrg/gobgp/v3/pkg/server.(*BgpServer).Serve(0xc000372008)
        /home/tuetuopay/dev/gobgp/pkg/server/server.go:490 +0x53a
    created by main.main in goroutine 1
        /home/tuetuopay/dev/gobgp/cmd/gobgpd/main.go:202 +0x13ea
2024-04-29 19:34:56 +09:00
Maxime Peim
9fbc03765a send-max: respect configuration 2024-04-29 17:29:42 +09:00
Tuetuopay
bbde806641 evpn: fix quadratic mac-mobility handling for gRPC routes
The gRPC code paths uses different functions than the BGP code path.
Thus is did not receive the fix for the mac mobility handling.

Fixes: c393f43 ("evpn: fix quadratic evpn mac-mobility handling")
2024-04-29 17:25:29 +09:00
Arthur de Kerhor
7ec4af4818 fix data race when getting capabilities from neighbor config
Func capabilitiesFromConfig was always taken under the read lock.
However, when graceful restart is enabled for some families, this
function writes to the neighbor config which creates a data race.
2024-04-29 17:22:48 +09:00
Yutaro Hayakawa
d0bf8138ff Update the reference of draft-ietf-idr-bgp-gr-notification
draft-ietf-idr-bgp-gr-notification is promoted to RFC8538.

Signed-off-by: Yutaro Hayakawa <yutaro.hayakawa@isovalent.com>
2024-04-27 23:51:16 +09:00
Yutaro Hayakawa
0ccd87db55 Sending Cease/Hard Reset notification
Send Cease/Hard Reset notification for certain scenario when graceful
restart + notification support (RFC8538) are enabled. In this
implementation, we follow the suggestion of RFC8538 and map following
notification subcodes to Hard Reset subcode.

1. BGP_ERROR_SUB_MAXIMUM_NUMBER_OF_PREFIXES_REACHED

In this case, GoBGP is in the resource shortage and not working
properly. Thus, the peer should stop forwarding packet immediately.

2. BGP_ERROR_SUB_ADMINISTRATIVE_SHUTDOWN

This happens when the user uses DisablePeer API. This clearly indicates
user's intention of shutting down the session. Thus, we should send Hard
Reset.

3. BGP_ERROR_SUB_PEER_DECONFIGURED

This happens when the user uses DeletePeer API or StopBgp API or there's
an ASN mismatch found in the Open phase. The former two cases, the user
shows the intention to shutdown the session, so we should Hard Reset.
The latter case is not so obvious, but I think it's ok to do Hard Reset
because it is an unrecoverable error that cannot be solved without
user's involvement.

4. BGP_ERROR_SUB_HARD_RESET

This case currently doesn't exist, but obviously we should send Hard
Reset when someone explicitly specifies it.

The behavior for the remaining subcodes are unchanged. We may want to
expose a knob to adjust the behavior of BGP_ERROR_SUB_ADMINISTRATIVE_RESET
as suggested by RFC8538, but for this initial implementation, we kept it
as is.

Signed-off-by: Yutaro Hayakawa <yutaro.hayakawa@isovalent.com>
2024-04-27 23:51:11 +09:00
wenovus
7ef2f0bb82 Add CommunityCount BGP Policy Condition
This is intended to have the same behaviour as [these OpenConfig paths](https://openconfig.net/projects/models/schemadocs/yangdoc/openconfig-routing-policy.html#routing-policy-policy-definitions-policy-definition-statements-statement-conditions-bgp-conditions-community-count):
* /routing-policy/policy-definitions/policy-definition/statements/statement/conditions/bgp-conditions/community-count/config/operator
* /routing-policy/policy-definitions/policy-definition/statements/statement/conditions/bgp-conditions/community-count/config/value
2024-04-11 07:48:16 +09:00
Rinat Baygildin
5d5a6b9afe Do not check enabling when EOR received
Signed-off-by: Rinat Baygildin <bayrinat@yandex-team.ru>
2024-03-20 08:45:34 +00:00
Rinat Baygildin
ed87360952 Add EOR type to Table's filter on Watch method
Signed-off-by: Rinat Baygildin <bayrinat@yandex-team.ru>
2024-03-20 08:45:34 +00:00
wenovus
829bbcf0a2 Fix ListPath for ADJ_IN and EnableFiltered=true and add tests.
Currently, even though `ApplyPolicy` is called for determining the
accepted routes after apply policy, the new route with attribute
modifications is not returned. This is problematic for gRPC API users.

Tests are added for all four cases that were described in
https://github.com/osrg/gobgp/issues/2765. This PR makes the behaviour
correct for "Case/Attempt 2" described in the issue.
2024-03-15 16:11:55 -07:00
FUJITA Tomonori
9d05544d1e Revert "Add EOR type to Table's filter on Watch method"
This reverts commit aff055b44d.

This breaks WatchEvent API:
https://github.com/osrg/gobgp/issues/2777
2024-03-05 07:42:25 +00:00
FUJITA Tomonori
84a264e618 Revert "Do not check enabling when EOR received"
This reverts commit fbeaa1c668.

This breaks WatchEvent API:
https://github.com/osrg/gobgp/issues/2777
2024-03-05 07:41:28 +00:00
Rinat Baygildin
fbeaa1c668 Do not check enabling when EOR received
Signed-off-by: Rinat Baygildin <bayrinat@yandex-team.ru>
2024-03-02 08:35:54 +00:00
Rinat Baygildin
aff055b44d Add EOR type to Table's filter on Watch method
Signed-off-by: Rinat Baygildin <bayrinat@yandex-team.ru>
2024-03-02 08:35:54 +00:00
Britton Payne
3448996706 Use net.IP.Equal in peer.filterPathFromSourcePeer
- Compares IPs using net.IP.Equal instead of using a string comparison
  in order to avoid unnecessary allocations.

- Adds peer.routerID to access IP, called by peer.RouterID.
2024-03-02 07:45:40 +00:00
Dawn Minion
003745affe logs: Guard frequently called logs behind if check
Moves a number of heavily called debug lines behind if checks to avoid
needless allocations of Fields objects and stringification of fields.
For cases where the server is not set to "debug" log level, these fields
were allocated on the heap and then immediately discarded - as well a
number of these were stringifying state / NLRIs regardless of log level.

In servers with significant amounts of routes and BGP peers, this lead
to a large amount of wasted allocations - in our case looking at Go's
memory profiler, 25% of all allocations were from these lines alone.
2024-03-02 06:12:45 +00:00
Dawn Minion
87e5b819e4 server: Fix deadlock if StopBgp is called when conn queue is full
Fixes a deadlock condition that can happen if StopBgp is called when the
pending connection queue is full. During teardown, StopBgp calls a
mgmtOp on the server goroutine which attempts to stop the goroutine
accepting inbound connections, and waits for it to finish before
continuing.

This connection goroutine can block if the connection queue is full,
which is read by the same goroutine that processes all mgmtOps. This
means that if the queue is full and the goroutine is currently blocked,
then calling StopBgp will lead to a complete deadlock, as the connection
goroutine will never close as it is trying to send to the queue, but the
queue will not be read as the server goroutine is currently waiting for
the connection goroutine to exit.

To correct this, a context has been added that gets passed to the
connection goroutine. This is then checked in a new select statement on
the connection queue which gets cancelled by tcpListener.Close() ensuring
the goroutine exits correctly even if the queue is full.
2024-02-27 12:24:45 -08:00
Christian Persson
ce7e5d3296 server: only log warning if grpcServer.Serve() returned an error.
Additionally change the `Key` to be the listener address, which is hopefully
more useful than a difficult-to-decipher dump of the listener struct.

The previous behavior would result in log lines like the following, even if
nothing went wrong:
```
time="2024-01-31T17:30:25Z" level=warning msg="accept failed" Error="<nil>" Key="&{0x140002e4000 {<nil> 0 0}}" Topic=grpc
```
With this change, the message is only logged if there was an error, and it will look like this:
```
time="2024-01-31T17:40:25Z" level=warning msg="accept failed" Error="lolol just testing" Key="127.0.0.1:59289" Topic=grpc
```
2024-01-31 17:42:41 +00:00
Yutaro Hayakawa
815683fa5e Only wait for GR End of RIB for the received address family
Currently, graceful restart waits for the EoR message for all address
families "enabled" for the peer, but it should only wait for "received"
address families (the address families the peer is capable of handling).

Fixes: #2524

Signed-off-by: Yutaro Hayakawa <yutaro.hayakawa@isovalent.com>
2024-01-29 11:15:08 +09:00
Yuya Kusakabe
270ee41d9a mup: add Source Address to Type 1 ST Route
This patch adds Source Address to Type 1 ST Route as defined in draft-mpmz-bess-mup-safi-03.
See https://datatracker.ietf.org/doc/html/draft-mpmz-bess-mup-safi-03#section-3.1.3
2023-12-15 15:24:24 +09:00
Lauri Huotari
7ddcd293dd Add initial support for evpn subtype 4 2023-12-09 11:37:17 +09:00
Arthur de Kerhor
08529d6cc4 Make sure the TCP connection is closed when a peer is deleted
It could be that a peer gets deleted and added back during the
transition from active state to open confirm. In that case, the TCP
connection from the old version of the peer could still be up. This
is a problem if the server is a listener only as the remote peer
would consider the old TCP connection as being valid and it won't
be able to connect until the TCP connection is eventually cleaned
by the Golang GC.
2023-12-04 13:32:37 +01:00
Jeremiah Millay
0d57904082 add test case for AddDefinedSet with replace 2023-11-10 13:59:11 -05:00
Jeremiah Millay
16412bfc03 Add replace option to AddDefinedSet rpc 2023-11-10 13:35:24 -05:00
Joshua DeWald
02fa6129af Implementation of Dynamic Neighbor MD5 (Issue #2589)
Adds usage of the "prefix-based" TCP MD5 for dynamic
neighbors. Non-dynamic neighbors will continue to use
non-prefix based, which makes it more compatible with
running on older kernels, as only 4.14+ includes the
necessary support.

This change also includes tests of dynamic peers in general.
2023-11-07 11:28:12 -08:00
FUJITA Tomonori
d210224493 packet: fix software version capability parser
Fixes #2732

Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com>
2023-11-02 10:39:02 +09:00
wenovus
868ac6d7ff Add MaxSoftware 2023-10-31 22:42:13 +09:00
wenovus
340030dc28 Fix imports 2023-10-31 22:42:13 +09:00
wenovus
0e7420d8a1 Export some zebra symbols. 2023-10-31 22:42:13 +09:00
wenovus
7a77f281c5 Export zebra package to /pkg/zebra 2023-10-31 22:42:13 +09:00
FUJITA Tomonori
e26631ceb4 packet: fix FQDN capability parser
Fixes #2708
2023-10-31 21:46:34 +09:00
Jeremiah Millay
286c887775 fix: call validatePathAttributeFlags after parsing and setting path attribute length 2023-10-30 10:58:13 -04:00
Dawn Minion
1b975be057 Fix data race in newWatchEventPeer
This method was attempting to read from peer.fsm before acquiring a read
lock, leading to a data race as this struct is written by a different
goroutine in parallel. Commit moves the call to RLock before the first
read from the struct.
2023-10-24 22:26:02 +09:00
SkalaNetworks
4364a26a7f feat(config): autoreload on config changes 2023-10-17 17:27:43 +00:00
wenovus
419c50dfac Check Address and LocalAddress instead of RouterId 2023-10-15 21:33:50 +09:00
wenovus
16a9c95393 Allow testing multiple GoBGP instances on localhost.
Currently GoBGP does not accept UPDATE messages with nexthops pointing
to a loopback address. This disallows multiple GoBGP instances from
running at the same time on 127.0.0.0/8.

This PR proposes removing this constraint when the RouterID of the
current GoBGP instance itself resides within the testing subnet of
127.0.0.0/8.
2023-10-15 21:32:04 +09:00
Vladislav Grishenko
146b2b8f59 server: improve ListPath's memory consumption with batched send
With a lot of paths (hundreds of thousands) gobgp may oom or
stuck in swapping.
Allow to specify max batch size via grpc and keep unlimited batch
size by default since 21093fbc87
without preallocation on the first run, so it still should not
affect perfomance/allocations with small ammount of paths.

Signed-off-by: Vladislav Grishenko <themiron@yandex-team.ru>
2023-10-02 14:42:52 +09:00
wenovus
aa0cf39f37 Export Generated BGP Configuration Code
Move internal/pkg/config -> pkg/config/oc

Background: #2593
2023-09-30 09:53:37 +09:00
Arjun Singh
60bcfc20f2 [Fuzzing] fuzzing support for oss-fuzz
Signed-off-by: Arjun Singh <ajsinghyadav00@gmail.com>
2023-09-19 20:39:25 +05:30
Rodrigo Peña
b6be999f90 Fix crash on ListPathRequest with malformed prefix
When ListPathRequest is done by a gRPC client including a malformed prefix,
 the server would crash an invalid memory address reference.

This commit fixes the crash by checking whether the parseCIDR method returned
an error.
2023-09-07 10:50:37 -03:00
Kirill Pletnev
35bfc9605c CLI VPNv4/VPNv6 filtering
gobgp CLI can filter VPNv4/VPNv6 prefixes with or without rd.
2023-09-06 11:14:47 +03:00
Kirill Pletnev
002690b848 ListPath can filter VPNv4/v6 routes
ListPath gRPC endpoint can filter VPNv4/VPNv6 prefixes. All lookup options are supported.
2023-09-06 11:11:35 +03:00
Rinat Baygildin
b8e17e06cd Use filter for watch pre/post-update watch events
Filtering by peer address worked only for initial state.
Using watch event's filter allows to use it for each event and could be extended by other conditions, e.g. peer group.

peer_address and peer_group were added to API (backward compatible).

Signed-off-by: Rinat Baygildin <bayrinat@yandex-team.ru>
2023-09-06 15:35:55 +09:00
Rinat Baygildin
eb58efd79c Fix test TestAddBogusPath
Stop the server in the test.

Signed-off-by: Rinat Baygildin <bayrinat@yandex-team.ru>
2023-09-06 15:35:55 +09:00
Rastislav Szabo
d3a46b8e1f Fix SRv6 prefix SID unmarshalling
During SRv6 prefix SID unmarshalling, wrong Path Attribute
length was applied (4B instead of 3B). This was causing
a 1 byte difference in PA length after marshalling & unmarshalling.

Signed-off-by: Rastislav Szabo <rastislav.szabo@isovalent.com>
2023-08-03 11:27:58 +09:00
Maxime Peim
e7534de3d2 use TCP MSS configuration 2023-07-25 12:46:48 +09:00
Rastislav Szabo
f617588415 Enhance AsPath attribute String() format
Signed-off-by: Rastislav Szabo <rastislav.szabo@isovalent.com>
2023-07-16 20:43:43 +09:00
FUJITA Tomonori
d4d97da220 pkg/packet/mrt: restore compatibility
restore the API breakage due to c801e18495.

However, this is a hack. Should be removed with the major version updated.

Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com>
2023-07-01 13:35:40 +09:00
Harry Freeborough
c801e18495 Add MRT-specific MP_REACH_NLRI encoding
This form, as defined in RFC 6396 4.3.4, is found in many public MRT
dumps.
2023-07-01 13:05:51 +09:00