Commit Graph

187 Commits

Author SHA1 Message Date
Donald Sharp
fd8044a4fc
Merge pull request #13084 from opensourcerouting/fix/bgp_vrf_md5_password
bgpd: Set md5 TCP socket option for outgoing connections on listener
2023-03-26 08:21:31 -04: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
e16d030c65 *: Convert THREAD_XXX macros to EVENT_XXX macros
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24 08:32:17 -04:00
Donald Sharp
907a2395f4 *: Convert thread_add_XXX functions to event_add_XXX
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24 08:32:17 -04:00
Donald Sharp
e6685141aa *: Rename struct thread to struct event
Effectively a massive search and replace of
`struct thread` to `struct event`.  Using the
term `thread` gives people the thought that
this event system is a pthread when it is not

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
Donatas Abraitis
2804008474 bgpd: Set TCP_MD5 for outgoing connections when password is set
If configuring `neighbor password` under VRF (not default), the session
will never be established.

Before setting TCP_MD5 for the connection fd, we need to enable this on the
accept direction as well (listener).

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-03-22 15:55:38 +02:00
Donald Sharp
50e049db76 bgpd: Use interface name instead of pointer value
Log message is borked in a manner that makes it unusable:
bgpd[52]: [VX6SM-8YE5W][EC 33554460] 2000:31:0:53::2: nexthop_set failed, resetting connection - intf 0x561eb9005a30

Let's print out the interface name instead.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-16 10:26:01 -04:00
Donald Sharp
7c5062fb27 bgpd: Give better debug message when configuration is being read in
Sometimes bgp connections can be rejected for a variety of reasons.  Give
a bit more context about what is going wrong so that the operator can
make better decisions about their network.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-02-22 11:41:18 -05:00
Russ White
ba755d35e5
Merge pull request #12248 from pguibert6WIND/bgpasdot
lib, bgp: add initial support for asdot format
2023-02-21 08:01:03 -05:00
Philippe Guibert
de76ed8a0e bgpd: store the neighbor as identifier as a string
This identifier is used to display the peer configuration in
the running-config, like it has been configured.
The following commands are using a specific string attribute:
- neighbor .. remote-as ASN
- neighbor .. local-as ASN

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2023-02-10 10:27:23 +01: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
534db980a2 bgpd: When creating peer convey if it is a CONFIG_NODE or not
When actually creating a peer in BGP, tell the creation if
it is a config node or not.  There were cases where the
CONFIG_NODE was being set *after* being placed into
the bgp->peerhash, thus causing collisions between the
doppelganger and the peer and eventually use after free's.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-12-05 09:11:22 -05:00
Donald Sharp
40f67286f7 bgpd: peer creation now takes care of the su
At some point in the past the peer creation was not
properly setting the su and the code had the release
and re-add when setting the su.  Since peer_create
got a bit of code to handle the su properly the
need to release then add it back in is negated
so remove the code.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-12-05 09:11:21 -05:00
vivek
031c24f2a9 bgpd: Add more debug info for incoming connection
Signed-off-by: Vivek Venkatraman <vivek@nvidia.com>
2022-11-20 22:45:12 -05:00
Philippe Guibert
d1adb44843 bgpd: support TCP keepalive for BGP connection
TCP keepalive is enabled once BGP connection is established.

New vty commands:

bgp tcp-keepalive <1-65535> <1-65535> <1-30>
no bgp tcp-keepalive

Signed-off-by: Xiaofeng Liu <xiaofeng.liu@6wind.com>
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2022-08-30 15:09:28 +02:00
Donald Sharp
fa5806c318 bgpd: Remove various macros that overlap THREAD_OFF
Let's just use THREAD_OFF consistently in the code base
instead of each daemon having a special macro that needs to
be looked at and remembered what it does.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-07-21 08:27:36 -04:00
Donatas Abraitis
47e1288431 *: Replace sockunion2str => %pSU
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-06-21 13:34:56 +03:00
Donatas Abraitis
aef69e4f39
Merge pull request #11353 from fdumontet6WIND/bmp_src_interface
bmp: add a interface source to bmp connect command
2022-06-16 21:30:28 +03:00
Francois Dumontet
09f267ec95 bmp: add a interface source to bmp connect command
With current release, forcin the source ip address when setting up a BMP
connection is not possible.

The need is to add an extra parameter for the following vty command:

router bgp 65500
bmp targets AAA
bmp connect 2.2.2.2 port 666 min-retry 100 max-retry 700
bmp connect 2:2::2:2 port 666 min-retry 100 max-retry 700 [source-interface lo1]

Signed-off-by: Francois Dumontet <francois.dumontet@6wind.com>
2022-06-16 12:51:11 +02:00
Donatas Abraitis
69ecbc6ae7 bgpd: Set TTL for iBGP/eBGP by checking only if Generic TTL security applied
We set peer->ttl according if it's iBGP or eBGP, but when setting the TTL,
we technically ignore it.

Relax a bit and set TTL only if no GTSM configured.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-06-10 16:32:39 +03:00
Pavel Shirshov
425bd64be8 bgpd: Allow bgp to control the DSCP session TOS value
Allow BGP to control the TOS DSCP value in the tcp header
via a new command at the bgp global level `bgp session-dscp <0-63>`

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
Signed-off-by: Pavel Shirhov <pavelsh@microsoft.com>
2022-05-13 14:14:35 -04:00
anlan_cs
8e3aae66ce *: remove the checking returned value for hash_get()
Firstly, *keep no change* for `hash_get()` with NULL
`alloc_func`.

Only focus on cases with non-NULL `alloc_func` of
`hash_get()`.

Since `hash_get()` with non-NULL `alloc_func` parameter
shall not fail, just ignore the returned value of it.
The returned value must not be NULL.
So in this case, remove the unnecessary checking NULL
or not for the returned value and add `void` in front
of it.

Importantly, also *keep no change* for the two cases with
non-NULL `alloc_func` -
1) Use `assert(<returned_data> == <searching_data>)` to
   ensure it is a created node, not a found node.
   Refer to `isis_vertex_queue_insert()` of isisd, there
   are many examples of this case in isid.
2) Use `<returned_data> != <searching_data>` to judge it
   is a found node, then free <searching_data>.
   Refer to `aspath_intern()` of bgpd, there are many
   examples of this case in bgpd.

Here, <returned_data> is the returned value from `hash_get()`,
and <searching_data> is the data, which is to be put into
hash table.

Signed-off-by: anlan_cs <vic.lan@pica8.com>
2022-05-03 00:41:48 +08:00
Donald Sharp
cc9f21da22 *: Change thread->func to return void instead of int
The int return value is never used.  Modify the code
base to just return a void instead.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-02-23 19:56:04 -05:00
Donatas Abraitis
4122b697bb bgpd: Relax peer to be on the same host
If the existing listener is the same as the peer, treat as self and reject.

```
exit1-debian-11# sh bgp listeners
Name             fd Address
---------------------------
default          24 192.168.10.123
exit1-debian-11# con
exit1-debian-11(config)# router bgp
exit1-debian-11(config-router)# neighbor 192.168.10.123 remote-as external
% Can not configure the local system as neighbor

exit1-debian-11# sh bgp listeners
Name             fd Address
---------------------------
default          24 0.0.0.0
default          25 ::
exit1-debian-11# con
exit1-debian-11(config)# router bgp
exit1-debian-11(config-router)# neighbor 192.168.10.123 remote-as external
% Can not configure the local system as neighbor
exit1-debian-11(config-router)#

exit1-debian-11# sh bgp listeners
Name             fd Address
---------------------------
default          24 192.168.0.1
exit1-debian-11# con
exit1-debian-11(config)# router bgp
exit1-debian-11(config-router)# neighbor 192.168.10.123 remote-as external
exit1-debian-11(config-router)#
```

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2022-01-17 18:44:57 +02:00
Donald Sharp
dcd5ba5505 bgpd: Allow v6 LL peers to work when connected to as well
Initial commit: 8761cd6ddb

introduced the idea of v6 LL using interface up/down events
instead of nexthop resolution to know when a peering should
happen or not.  This above commit left a hole where if the remote
peer connected to this bgp, the bgp code would still believe
the peering is down.   Modify the code to double check and
ensure that we have proper v6 LL resolution flags set.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-09-16 08:07:45 -04:00
Donatas Abraitis
d9377cb626
Merge pull request #9557 from idryzhov/bgp-view-cleanup
bgpd: cleanup special checks for views
2021-09-07 10:14:30 +03:00
Igor Ryzhov
2c1eba8e84 bgpd: cleanup special checks for views
bgp->vrf_id is always VRF_DEFAULT for views. All these special checks
are not necessary.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-09-03 17:36:40 +03:00
Donald Sharp
c5fe9095fe bgpd: Add PEER_DOWN_SOCKET_ERROR to the list of peer failure modes
BGP can experience a bunch of errors associated with sockets
being manipulated which would prevent the peer from coming up.
Let's add some additional debug information here so that
our operators can do a bit more for themselves.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-09-03 07:56:35 -04:00
Donald Sharp
888e727c9e bgpd: Add some debug events for when things go wrong
As it stands there are cases where FRR is silently handling
error events and not giving any log output to say what is
going wrong.  This should be fixed.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-09-02 09:19:48 -04:00
Igor Ryzhov
7224dcd86a bgpd: fix bgp_get_bound_name to handle views better
The vrf socket code needs a interface/vrf name to be passed
in, in order for it to properly bind to the correct vrf.
In the case where bgp is using a view based instance
the bgp_get_bound_name should handle views better and
not return anything to be bound to.

Fixes #9519.
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-09-02 09:18:19 -04:00
Donatas Abraitis
936fbaef47 *: Replace IPV4_MAX_PREFIXLEN to IPV4_MAX_BITLEN
Just drop IPV4_MAX_PREFIXLEN at all, no need keeping both.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-07-01 17:44:09 +03:00
Donatas Abraitis
f4d81e5507 *: Replace IPV6_MAX_PREFIXLEN to IPV6_MAX_BITLEN
Just drop IPV6_MAX_PREFIXLEN at all, no need keeping both.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-07-01 17:41:09 +03:00
Donald Sharp
feb1723846 bgpd: Convert to using peer_established(peer) function
We are inconsistently using peer_establiahed(peer) with
sometimes using `peer->status == Established`.  Just Convert
over to using the function for consistency.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-06-07 10:48:36 -04:00
Igor Ryzhov
676847384b bgpd: pass correct vrf_id to vrf_socket when creating bgp view socket
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-05-31 22:12:55 +03:00
Igor Ryzhov
0def0c9fa3 bgpd: raise privs for SO_BINDTODEVICE
The priv raise was incorrectly dropped in 97896a9.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-05-18 17:07:06 +03:00
Donatas Abraitis
48c2039199
Merge pull request #8564 from rameshabhinay/bgp_tcp_mss
bgpd: Support tcp-mss for bgp neighbors
2021-05-05 13:45:39 +03:00
Abhinay Ramesh
4ab467017e bgpd: Support tcp-mss for bgp neighbors
Problem Statement:
=================
In scale setup BGP sessions start flapping.

RCA:
====
In virtualized environment there are multiple places where
MTU need to be set. If there are some places were MTU is not set
properly then there is chances that BGP packets get fragmented,
in scale setup this will lead to BGP session flap.

Fix:
====
A new tcp option is provided as part of this implementation,
which can be configured per neighbor and helps to set the TCP
max segment size. User need to derive the path MTU between the BGP
neighbors and set that value as part of tcp-mss setting.

1. CLI Configuration:
	[no] neighbor <A.B.C.D|X:X::X:X|WORD> tcp-mss (1-65535)

2. Running config
    frr# show running-config
    router bgp 100
     neighbor 198.51.100.2 tcp-mss 150       => new entry
     neighbor 2001:DB8::2 tcp-mss 400        => new entry

3. Show command
    frr# show bgp neighbors 198.51.100.2
    BGP neighbor is 198.51.100.2, remote AS 100, local AS 100, internal link
    Hostname: frr
      Configured tcp-mss is 150, synced tcp-mss is 138     => new display

4. Show command json output

    frr# show bgp neighbors 2001:DB8::2 json
    {
      "2001:DB8::2":{
        "remoteAs":100,
        "bgpTimerKeepAliveIntervalMsecs":60000,
        "bgpTcpMssConfigured":400,                               => new entry
        "bgpTcpMssSynced":388,                                  => new entry

Risk:
=====
Low - This is a config driven feature and it sets the max segment
size for the TCP session between BGP peers.

Tests Executed:
===============
Have done manual testing with three router topology.
1. Executed basic config and un config scenarios
2. Verified if the config is updated in running config
   during config and no config operation
3. Verified the show command output in both CLI format and
   JSON format.
4. Verified if TCP SYN messages carry the max segment size
   in their initial packets.
5. Verified the behaviour during clear bgp session.
6. done packet capture to see if the new segment size
   takes effect.

Signed-off-by: Abhinay Ramesh <rabhinay@vmware.com>
2021-05-04 06:21:24 +00:00
Donald Sharp
c3c6dbf80a bgpd: listener thread pointer is already NULL
FRR in thread.c clears the passed in double pointer when
we pull it off the ready queue and pass it back to
the calling function via thread_fetch().

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-05-02 07:31:30 -04:00
Donald Sharp
996319e63d bgpd: Address LL peer not NHT when receiving connection attempt
The new LL code in:
8761cd6ddb

Introduced the idea of the bgp unnumbered peers using interface up/down
events to track the bgp peers nexthop.  This code was not properly
working when a connection was received from a peer in some circumstances.

Effectively the connection from a peer was immediately skipping state transitions
and FRR was never properly tracking the peers nexthop.  When we receive the
connection attempt, let's track the nexthop now.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-04-15 13:16:28 -04:00
Donatas Abraitis
6740a191ad Revert "bgpd: BGP session not established for ipv6 link local address with vrf config"
This reverts commit 0b6d35324e.
2021-04-09 10:14:32 +03:00
sudhanshukumar22
0b6d35324e bgpd: BGP session not established for ipv6 link local address with vrf config
Description:
BGP session not established for ipv6 link local address with vrf config

Problem Description/Summary :
BGP session not established for ipv6 link local address with vrf configyy
1.Configure ipv6 link-local address fe80::1234/64 on dut1 and fe80::4567/64 on dut2
2.Configure BGP neighbors for ipv6 link-local on both dut1 and dut2
3.Verify BGP session is UP over link-local ipv6 address
4.Observed that bgp session not established for ipv6 link local address

Expected Behavior :
BGP session should be established for ipv6 link local address with vrf config

Signed-off-by: sudhanshukumar22 <sudhanshu.kumar@broadcom.com>
2021-04-01 02:43:51 -07:00
Russ White
38981e4bba
Merge pull request #8120 from ton31337/feature/bgp_ipv6_default_activated
bgpd: Activate ipv6-unicast for peer automatically if globally defined
2021-03-23 09:36:43 -04: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
e84c59af5b bgpd: Activate ipv6-unicast for peer automatically if globally defined
When you use a single BGP session for both IPv4 and IPv6 it's a bit
annoying going into ipv6 address-family and explicitly activating it.

Let's get this automatically if enabled with `bgp default ipv6-unicast`.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-02-28 19:49:43 +02:00
David Schweizer
6c537a18cf
bgpd: RFC 4271 DelayOpenTimer
Changes implement the DelayOpenTimer functionality proposed in RFC 4271.

Signed-off-by: David Schweizer <dschweizer@opensourcerouting.org>
2020-10-20 16:49:58 +02:00
Donald Sharp
0154d8ce45 bgpd, lib, nhrpd, zebra: verify return of sockunion2hostprefix
The return from sockunion2hostprefix tells us if the conversion
succeeded or not.  There are places in the code where we
always assume that it just `works`, since it can fail
notice and try to do the right thing.

Please note that failure of this function for most cases
of sockunion2hostprefix is highly highly unlikely as that
the sockunion was already created and tested elsewhere
it's just that this function can fail.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-11-18 11:04:27 -05:00
Pat Ruddy
a4faae3aac bgpd: associate listener with the appropriate bgp instance
When setting authentication on a BGP peer in a VRF the listener is
looked up from a global list. However there is no check that the
listener is the one associated with the VRF being configured. This
can result in the wrong listener beiong configured with a password,
leaving the intended listener in an open authentication state.
To simplify this lookup stash a pointer to the bgp instance in
the listener on creating (in the same way as is done for NS-based
VRFS).

Signed-off-by: Pat Ruddy <pat@voltanet.io>
2020-09-01 09:42:26 +01:00
David Schweizer
cb9196e77a
bgpd: bgp instance administrative shutdown.
* Fixed integration in FSM and packet handling.
* Added CLI "show" output, incl. JSON.
* For review and testing only.

Signed-off-by: David Schweizer <dschweizer@opensourcerouting.org>
2020-08-14 10:23:34 +02:00
David Lamparter
3efd0893d0 *: un-split strings across lines
Remove mid-string line breaks, cf. workflow doc:

  .. [#tool_style_conflicts] For example, lines over 80 characters are allowed
     for text strings to make it possible to search the code for them: please
     see `Linux kernel style (breaking long lines and strings)
     <https://www.kernel.org/doc/html/v4.10/process/coding-style.html#breaking-long-lines-and-strings>`_
     and `Issue #1794 <https://github.com/FRRouting/frr/issues/1794>`_.

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

Signed-off-by: David Lamparter <equinox@diac24.net>
2020-07-14 10:37:25 +02:00