Commit graph

30 commits

Author SHA1 Message Date
Donald Sharp 348c2dc3f8 bgpd: Only update peer connection information when needed
Currently bgp is repeatedly grabbing peer connection information.
This is a bit overkill.  There are two situations:

a) Opening a connection to the peer
   In this case, we know the remote port/address a priori and can get
   the local information by just asking the OS.
b) Peer opening a connection to us.
   In this case, we know the local port/address a priori and can get
   the remote information by just asking the OS.

Modify the code to just grab this data at the appropriate time.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2025-01-10 10:07:11 -05:00
Donald Sharp 0e416ff157 bgpd: bgp_getsockanme is connection oriented
Let's make it so.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2025-01-10 10:06:16 -05:00
Donald Sharp 1baeb81632 bgpd: bgp_getsockname should use connection
Let's use the connection associated with the peer
instead.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-11-26 11:59:33 -05:00
Donald Sharp 2771431938 bgpd: Modify bgp_udpatesockname to pass in a connection
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-11-26 11:59:19 -05:00
Donald Sharp 2a94de8af2 bgpd: bgp_connect should return an enum connect_result
This function when it is run by bgp_start is expected
to return a `enum connect_result`.  But instead
the function returns a variety of values that are
not really being checked for.  Consolidate to a correct
choice.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-11-20 16:11:22 -05:00
Philippe Guibert 37702ca080 bgpd: fix 'nexthop_set failed' error message often displayed
The 'nexthop_set failed, resetting connection - intf' log message
is often seen when peering with BGP peers. This message has been
displayed by introducing a recent fix that extracts the IP/port
information of outgoing connections when peering is not yet
established.

Fix this by separating the update of the socket information from
the call to bgp_zebra_nexthop_set().

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2024-09-12 16:14:27 +02:00
Donatas Abraitis 81ece63e3e bgpd: Set TCP min MSS per listener
Set only if at least one peer is in passive mode.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-09-18 22:34:45 +03:00
Donald Sharp c50a82c39b bgpd: Convert bgp_network.c to use peer_connection
Modify bgp_network.c to use a peer_connection as
it's prime parameters.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-09-10 08:31:25 -04:00
Donald Sharp 70c3c27ebc bgpd: bgp_connect is struct peer_connection oriented
Make it so.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-09-10 08:31:25 -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
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
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 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
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
Donald Sharp 2a0e69ae3c bgpd: Add 'show bgp listeners' command for diagnostics
Add a command to display listen sockets and the vrf that they
are associated with.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-03-10 09:59:56 -04:00
Quentin Young 9e7d9a61ac bgpd: add support for MD5 auth on listen ranges
Co-authored-by: Donald Sharp <sharpd@cumulusnetworks.com>
Co-authored-by: Quentin Young <qlyoung@cumulusnetworks.com>
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-04-16 15:26:20 +00:00
Philippe Guibert e5619c289a bgpd: server socket is created for all enabled VRF
Upon creation of BGP instances, server socket may or may not be created.
In the case of VRF instances, if the VRF backend relies on NETNS, then
a new server socket will be created for each BGP VRF instance. If the
VRF backend relies on VRF LITE, then only one server socket will be
enough. Moreover, At startup, with BGP VRF configuration, a server
socket may not be created if VRF is not the default one or VRF is not
recognized yet.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-02-27 11:11:24 +01:00
Philippe Guibert 61cf4b3715 bgpd: bgp support for netns
The change contained in this commit does the following:
- discovery of vrf id from zebra daemon, and adaptation of bgp contexts
  with BGP.
  The list of network addresses contain a reference to the bgp context
  supporting the vrf.
  The bgp context contains a vrf pointer that gives information about
  the netns path in case the vrf is a netns path.

Only some contexts are impacted, namely socket creation, and retrieval
of local IP settings. ( this requires vrf identifier).

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-02-27 11:11:24 +01:00
whitespace / reindent d62a17aede *: reindent
indent.py `git ls-files | pcregrep '\.[ch]$' | pcregrep -v '^(ldpd|babeld|nhrpd)/'`

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-17 14:04:07 +02:00
David Lamparter 896014f4bc *: make consistent & update GPLv2 file headers
The FSF's address changed, and we had a mixture of comment styles for
the GPL file header.  (The style with * at the beginning won out with
580 to 141 in existing files.)

Note: I've intentionally left intact other "variations" of the copyright
header, e.g. whether it says "Zebra", "Quagga", "FRR", or nothing.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-05-15 16:37:41 +02:00
vivek 89ca90fad9 BGP: Fix MD5 authentication for unnumbered neighbors
Ticket: CM-6369
Reviewed By: CCR-3318
Testing Done: Manual testing of various password scenarios.

This is a port of patch bgpd-unnumbered-nbr-fix-password.patch from
2.5-br.

In the case of BGP unnumbered, the peer IP address is derived and not
explicitly configured. If there is a password configured for the peer,
it can be set on the listen socket only after the IP address has been
derived and needs to be cleared when the IP address goes away.
2015-08-29 16:10:12 -07:00
Donald Sharp e5cc509c34 bgpd-ebgp-multihop-fix.patch
BGP: Fix EBGP multihop transitions correctly

Since BGP connection setup has migrated to using NHT to decide when to bring a
session up, we have to handle ebgp multihop transitions correctly to ensure NHT
registrations are correctly handled.

Signed-off-by: Dinesh G Dutt <ddutt@cumulusnetworks.com>
2015-05-19 18:45:53 -07:00
Donald Sharp 1ff9a34058 bgpd: bgpd-fsm-fix.patch
BGP: Fix FSM to handle active/passive connections better

The existing code didn't work well when dual connections resulted between
peers during session bringup. This patch fixes that.

Signed-off-by: Dinesh G Dutt <ddutt@cumulusnetworks.com>
2015-05-19 17:40:37 -07:00
Vipin Kumar 3374bef041 bgpd: increase TCP socket buffer size
BGP does not respond fairly in high scale.  As the number of BGP peers
and prefixes increase, triggers like interface flaps which lead to BGP
peer flaps, cause blockage in bgp_write.

BGP does handle the cases of TCP socket buffer full by queuing a write
event back, there is no functional issue there as such. Still,
increasing the peer socket buffer size should help reduce event queueing
in BGP.

Signed-off-by: Vipin Kumar <vipin@cumulusnetworks.com>
Reviewed-by: Pradosh Mohapatra <pmohapat@cumulusnetworks.com>
Reviewed-by: Dinesh Dutt <ddutt@cumulusnetworks.com>
[DL: patch split, this is item 3.]
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2014-05-15 20:34:53 +02:00
Stephen Hemminger d023aec49f bgpd: start listener on first instance
Start BGP listener only after first instance is started.  This helps the
security if BGP is not used but daemon is started.  It also addresses some
issues like MD5 not working on listener unless IPV6 configured (because
listener was not in list); as well as compiler warnings.

* bgp_network.c: (bgp_listener) listen socket creation consolidated here
  (bgp_socket) Use bgp_listener
* bgpd.c: (bgp_get) call bgp_socket on creation of first struct bgp.
  (bgp_init) remove bgp_socket call.
* memtypes.c: Add MTYPE_BGP_LISTENER
2009-07-28 10:04:38 +01:00
Paul Jakma 0df7c91f04 [bgpd] TCP-MD5: password vty configuration and initial Linux support
2008-07-21 Paul Jakma <paul.jakma@sun.com>

	* bgp_packet.c: (bgp_open_receive) fix warning in a zlog call
	* bgp_vty.c: (bgp_vty_return) add return code
	* bgpd.c: (bgp_master_init) setup the socket list.
	* bgp_network.c: Remove the dual IPv4/6 socket thing for now, which
	  was implemented by Michael, until such time as its clear its
	  required for Linux (see sockopt comments). IPv6 support, including
	  IPv4 sessions on AF_INET6 sockets, therefore is broken, and the
	  '-l 0.0.0.0' arguments would need to be given to bgpd to make
	  things work here.

2008-07-21 Michael H. Warfield <mhw@wittsend.com>
           YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
	   Tomohiko Kusuda <kusuda@inetcore.com>
           Leigh Brown <leigh@solinno.co.uk>

	* bgp_network.c: (bgp_md5_set_one) shim between libzebra tcp-md5
	  sockopt and bgpd.
	  (bgp_md5_set_socket) Helper for bgp_connect
	  (bgp_md5_set) setup TCP-MD5SIG for the given peer.
	  (bgp_connect) call out to bgp_md5_set_socket for the outgoing
	  connect socket.
	  (bgp_socket) save references to the listen sockets, needed if
	  TCP-MD5SIG is applied later or changed.
	* bgp_vty.c: (*neighbor_password_cmd) New 'neighbor ... password'
	  commands.
	* bgpd.c: (peer_{new,delete) manage TCP-MD5 password
	  (peer_group2peer_config_copy) inherit TCP-MD5 password
	  (peer_password_{un,}set) orchestrate the whole add/remove of TCP-MD5
	  passwords: applying checks, stopping peers, and trying to return
	  errors to UI, etc.
	  (bgp_config_write_peer) save password.
	  Fix missing newline in writeout of neighbor ... port.

2008-07-21 Paul Jakma <paul.jakma@sun.com>

	* sockunion.c: ifdef out various places that converted
	  v4mapped sockets to pure v4. Doesn't seem necessary at all,
	  presumably a workaround for now historical inet_ntop bugs (?)

2008-07-21 Michael H. Warfield <mhw@wittsend.com>
           YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>

	* sockopt.{c,h}: (sockopt_tcp_signature) Add TCP-MD5SIG support.
2008-07-21 21:02:49 +00:00
Paul Jakma 3a02d1f7fb 2007-10-30 Nick Hilliard <nick@inex.ie>
* bgp_main.c: Add 'listenon' argument, to pass address to bind
	  to.
	* bgp_network.c: (bgp_socket) Extend to take bind address.
	* bgpd.c: (bgp_init) Pass stored address.
	* bgpd.h: (struct bgp_master) storage for bind address

2007-11-01 Paul Jakma <paul.jakma@sun.com>

	* tools/multiple-bgpd.sh: New, quick script to launch a bunch of
	  bgpds.
2007-11-01 14:29:11 +00:00
paul 94f2b3923e 2005-06-28 Paul Jakma <paul.jakma@sun.com>
* (global) The great bgpd extern and static'ification.
	* bgp_routemap.c: remove unused ROUTE_MATCH_ASPATH_OLD code
	  (route_set_metric_compile) fix u_int32_t to ULONG_MAX comparison
	  warnings.
	* bgp_route.h: (bgp_process, bgp_withdraw, bgp_update) export these
	  used by various files which had their own private declarations,
	  in the case of mplsvpn - incorrect.
2005-06-28 12:44:16 +00:00
paul 00d252cb5f 2005-05-23 Paul Jakma <paul@dishone.st>
* bgp_fsm.h: Add extern qualifier to exported functions
	* bgp_nexthop.c: add static to nexthop specific globals
	* *.h: Add guard defines
2005-05-23 14:19:54 +00:00
paul 718e374419 Initial revision 2002-12-13 20:15:29 +00:00