bgpd: Fix integer truncation of SRLG count when parsing SRLG TLV`count` is declared as `uint8_t` but receives `length / 4` where
`length` is a `uint16_t`. For `length >= 1024`, the division result
exceeds 255, which cannot be stored in `count` since `uint8_t` holds
at most 255, and the value silently truncates. The result is then
stored in `attr->srlg_count`, also `uint8_t`, which would re-truncate
it.
Widen `count` in `parse_srlg()` and `srlg_count` in ...
lib: fix zclient crash when many peers reconnect after FRR restartReplace select() with poll() in zclient_read_sync_response() to avoid
FD_SETSIZE (1024) limit. When the zebra socket fd exceeds 1024, FD_SET()
triggers __fdelt_warn and aborts. poll() has no such limit.
Handle POLLNVAL, POLLHUP, and POLLERR explicitly to avoid busy-spin on
socket errors, matching the pattern from lib/event.c.
Backtrace before fix:
```
Mar 09 22:16:42 core frrinit.sh[898790]:...
tests: Add BGP-LS topotest suiteAdd pytest topology test for BGP Link-State covering producer and
consumer modes with ISIS IGP backend.
Tests BGP-LS capability negotiation, NLRI advertisement/reception
(Node, Link, Prefix), and dynamic topology change propagation
including route additions/removals and link state changes.
Verifies BGP-LS updates flow correctly from IGP through BGP-LS
producer to BGP-LS consumer.
Signed-off-...
bgpd: Set nexthop for BGP-LS based on peer address familyBGP-LS routes advertised to peers require a nexthop with the same
address family as the peer session (IPv4 peer needs IPv4 nexthop,
IPv6 peer needs IPv6 nexthop).
The MP_REACH_NLRI and MP_UNREACH_NLRI encoding code in bgp_attr does
not have direct knowledge of the peer's address family, making it
unable to select the appropriate nexthop address family for BGP-LS
advertisements.
Add peer flags...
bgpd: Parse BGP-LS NLRI received from peersAdd inbound BGP-LS message processing to receive Link-State topology
information from BGP peers.
When BGP receives a BGP UPDATE message from a peer, it calls
bgp_nlri_parse() to parse the NLRI. The bgp_nlri_parse() function
checks the SAFI (Subsequent Address Family Identifier) contained in
the UPDATE message and dispatches to the appropriate SAFI-specific
handler. Currently supported SAFIs in...
bgpd: Unregister from lsdb on terminationCall bgp_ls_unregister() in bgp_ls_terminate() to cleanly unregister
from the zebra link-state database when BGP instance terminates.
This ensures proper cleanup and stops receiving IGP topology updates
when the BGP-LS functionality is no longer needed.
Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
bgpd: Receive BGP-LS attributeAdd bgp_attr_ls() function to parse and intern BGP-LS attributes (Type 29)
from received BGP update messages. The function validates peer configuration,
parses Type 29 TLVs, and interns the resulting attribute for use in route
processing.
Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
bgpd: Encode BGP-LS NLRI and attribute when building UPDATE packetAdd BGP-LS encoding support to UPDATE message generation for
transmitting Link-State topology information to peers.
Implement bgp_packet_ls_attribute() to encode BGP-LS Attribute (Type 29)
by dispatching to type-specific encoders (node/link/prefix attributes).
Extend packet building functions to accept ls_nlri parameter:
- bgp_packet_attribute() - encode BGP-LS attribute when present
- bgp_pa...
bgpd: Add BGP-LS AFI/SAFI to negotiation functionsAdd BGP-LS capability checks to peer activity and address family
negotiation functions.
Update peer status and capability negotiation functions to include
BGP-LS AFI/SAFI:
- peer_active() - Check if peer has BGP-LS configured
- peer_active_nego() - Check if BGP-LS was negotiated with peer
- peer_group_af_configured() - Check if peer group has BGP-LS enabled
- bgp_open_option_parse() - Validat...
bgpd: Add BGP-LS capability display supportAdd display support for BGP-LS multi-protocol capability in BGP OPEN
message output.
Update bgp_capability_vty_out() to properly display BGP-LS capabilities:
- Display "AFI BGP-LS" for AFI_BGP_LS (16388)
- Display "SAFI BGP-LS" for SAFI_BGP_LS (71)
- Add JSON output support for BGP-LS capabilities
This allows users to verify BGP-LS capability negotiation between peers
using "show bgp neighbo...
bgpd: Register for linkstate db updates when peer is activatedRegister for Link State database updates when the first BGP-LS peer is
activated, and unregister when the last peer is deactivated.
Modify peer_activate() and peer_deactivate() to manage Link State
database registration based on active BGP-LS peers:
- When first peer is activated for link-state address family, call
bgp_ls_register() to subscribe to IGP topology updates from zebra
- When las...
bgpd: Add show commands for BGP-LS NLRIsAdd commands to display BGP Link-State NLRIs from the BGP RIB.
New commands:
- show bgp link-state link-state [json]
Display all BGP-LS routes with node/link/prefix NLRIs
- show bgp link-state link-state NLRI [json]
Display specific BGP-LS route by NLRI identifier
NLRI format: [Type][ID][Protocol][Instance][AS][Area][Descriptors...]
Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
bgpd: Add BGP-LS configuration write supportExtend bgp_config_write() to serialize BGP Link-State address family
configuration.
This enables BGP-LS configuration to be:
- Displayed via show running-config
- Saved to startup-config (write memory)
- Written to configuration files
Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
lib: Add CLI node for BGP Link-State address family configurationAdd BGP_LS_NODE to enum node_type in command.h to enable BGP Link-State
address family configuration mode.
This allows creating a dedicated configuration context for BGP-LS:
router bgp 65000
address-family link-state
<BGP-LS specific commands>
exit-address-family
Follows the same pattern as other BGP address families (BGP_EVPN_NODE,
BGP_SRV6_NODE).
Signed-off-by: Carmine Sca...
bgpd: Handle zebra opaque messagesAdd callback handler to process ZAPI Opaque messages from zebra containing
Link State updates from IGP producers.
Register bgp_zebra_opaque_msg_handler() as the callback for
ZEBRA_OPAQUE_MESSAGE type in the zebra client handler table. The handler:
- Decodes ZAPI Opaque message header using zclient_opaque_decode()
- Routes Link State messages (LINK_STATE_SYNC, LINK_STATE_UPDATE) to
bgp_ls_pr...
bgpd: Add functions to parse updates received from linkstate dbAdd callback functions to parse and process Link State updates received
from IGP producers via ZAPI Opaque messages.
When IGPs (IS-IS, OSPF) detect topology changes, they send Link State
Update messages through zebra to registered consumers. These functions
handle the received messages:
- bgp_ls_parse_update() - Parse ZAPI Opaque Link State messages
- bgp_ls_process_node() - Process Node upda...
bgpd: Add BGP-LS update and withdraw functionsImplement BGP-LS route installation and withdrawal to enable processing
of BGP-LS NLRIs received in BGP UPDATE messages.
In BGP-LS, UPDATE messages contain BGP-LS NLRIs (not traditional prefixes).
When a BGP UPDATE with BGP-LS NLRI is received, a bgp_dest is allocated
to represent that NLRI location in the RIB and stored in the BGP RIB tree.
The ls_nlri field in bgp_dest stores the BGP-LS NLRI...
bgpd: Add BGP-LS Attribute support to attr structureExtend the core BGP attribute structure to support BGP-LS Attributes
(RFC 9552 Section 5.3) by adding ls_attr field and updating all related
attribute processing functions.
Changes:
- Add ls_attr field to struct attr to store BGP-LS Attribute TLVs
- Update attrhash_key_make() to include ls_attr in attribute hash key
- Update attrhash_cmp() to compare ls_attr when present
- Extend bgp_attr_inte...
bgpd: Add helper functions to register linkstate db notificationsAdd helper functions to register and unregister BGP-LS for Link State
database notifications from IGP producers.
In FRR's Link State architecture, consumers must register with zebra to
receive ZAPI Opaque Link State Update messages from producers (IS-IS, OSPF).
These functions wrap the Link State API registration mechanism:
- bgp_ls_register() - Register to receive LS updates from IGPs
- bgp_...
bgpd: Add TED instance to BGP-LS data structureAdd Traffic Engineering Database (TED) instance to BGP-LS structure to
store link-state topology.
In FRR's Link State architecture, IGP protocols (IS-IS, OSPF) act as
producers that build link-state databases from protocol exchanges and
send updates via ZAPI Opaque messages. BGP-LS acts as a consumer that
synchronizes with IGPs and listens for updates, maintaining a TED with
the topology infor...
bgpd: Add BGP-LS NLRI encode functionsAdd functions to serialize BGP-LS NLRIs to wire format per RFC 9552.
The encode functions convert in-memory NLRI structures to the TLV-based
wire format used in MP_REACH_NLRI and MP_UNREACH_NLRI path attributes.
- bgp_ls_encode_node_descriptor() - Encode Node Descriptors
- bgp_ls_encode_link_descriptor() - Encode Link Descriptors
- bgp_ls_encode_prefix_descriptor() - Encode Prefix Descriptors...
bgpd: Add error code for BGP-LS packet errorsAdd EC_BGP_LS_PACKET error code for BGP-LS NLRI and attribute packet
parsing/encoding errors.
This error code is used by BGP-LS decode functions to log warnings when
malformed packets are received from peers, such as invalid TLV lengths,
missing mandatory fields, or unknown NLRI types.
Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
bgpd: Add hash table to store BGP-LS NLRIsAdd hash table infrastructure to store BGP-LS NLRIs originated by the
local node and received from peers.
- Add nlri_hash to bgp_ls structure for NLRI storage
- Add hash functions to compute hash keys and compare NLRIs
- Add bgp_ls_nlri_intern() to insert NLRI and increment reference count
- Add bgp_ls_nlri_unintern() to remove NLRI and decrement reference count
- Add bgp_ls_entry_lookup() to ...
bgpd: Add BGP-LS NLRI deep copy functionAdd function to create deep copy of BGP-LS NLRI structures.
Used in subsequent commits for NLRI storage and management.
Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
bgpd: Add BGP-LS NLRI size calculation helperAdd function to calculate wire format size of BGP-LS NLRI structures.
Used in subsequent commits for NLRI encoding.
Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
bgpd: Add BGP-LS NLRI validation functionsAdd validation functions to verify BGP-LS NLRI is valid per RFC 9552.
Used in subsequent commits to validate NLRIs received from peers.
Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
bgpd: Add BGP-LS NLRI comparison functionsAdd functions to determine if two BGP-LS NLRIs are equal.
These functions will be used in subsequent commits for NLRI hash table
lookups and duplicate handling.
Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
bgpd: Add BGP-LS instance structure and initializationIntroduce core BGP-LS module infrastructure.
- Add `struct bgp_ls` to hold BGP-LS state
- Add `bgp_ls_init()` to initialize BGP-LS module during BGP instance
creation
- Add `bgp_ls_terminate()` to cleanup BGP-LS module during BGP instance
destruction
Subsequent commits will extend this structure with NLRI and TED support.
Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
bgpd: Add debugging support for BGP-LSAdd debugging support for BGP Link-State operations to aid development
and troubleshooting.
- Add `debug bgp link-state` command
- Add `no debug bgp link-state` command
- Extend `no debug bgp` to also disable link-state debugging
- Show link-state debugging status in `show debugging bgp`
Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
*: Add BGP-LS AFI/SAFI constantsAdd BGP Link-State (BGP-LS) Address Family infrastructure to prepare
for full protocol implementation in subsequent commits (RFC 9552).
Introduce AFI_BGP_LS (16388) and SAFI_BGP_LS (71) and update all
AFI/SAFI-aware code paths to recognize the new address family.
Protocol-specific logic is marked with TODO placeholders to be
implemented in subsequent commits.
Signed-off-by: Carmine Scarpitta...