2023-02-08 13:17:09 +01:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2002-12-13 21:15:29 +01:00
|
|
|
/* BGP advertisement and adjacency
|
2017-05-13 10:25:29 +02:00
|
|
|
* Copyright (C) 1996, 97, 98, 99, 2000 Kunihiro Ishiguro
|
|
|
|
*/
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2005-05-23 16:19:54 +02:00
|
|
|
#ifndef _QUAGGA_BGP_ADVERTISE_H
|
|
|
|
#define _QUAGGA_BGP_ADVERTISE_H
|
|
|
|
|
2019-04-21 18:17:45 +02:00
|
|
|
#include "lib/typesafe.h"
|
2016-01-08 13:37:14 +01:00
|
|
|
|
2019-05-20 23:41:16 +02:00
|
|
|
PREDECL_DLIST(bgp_adv_fifo);
|
2015-05-20 03:03:47 +02:00
|
|
|
|
2019-04-21 18:17:45 +02:00
|
|
|
struct update_subgroup;
|
2023-10-06 18:48:38 +02:00
|
|
|
struct bgp_advertise;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2023-10-06 18:48:38 +02:00
|
|
|
PREDECL_DLIST(bgp_advertise_attr_fifo);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2023-10-06 18:48:38 +02:00
|
|
|
struct bgp_advertise_attr;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2023-10-06 18:48:38 +02:00
|
|
|
/* BGP advertise attribute. */
|
2002-12-13 21:15:29 +01:00
|
|
|
struct bgp_advertise {
|
|
|
|
/* FIFO for advertisement. */
|
2019-04-21 18:17:45 +02:00
|
|
|
struct bgp_adv_fifo_item fifo;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2023-10-06 18:48:38 +02:00
|
|
|
/* FIFO for this item in the bgp_advertise_attr fifo */
|
|
|
|
struct bgp_advertise_attr_fifo_item item;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
/* Prefix information. */
|
2020-03-27 00:11:58 +01:00
|
|
|
struct bgp_dest *dest;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
/* Reference pointer. */
|
|
|
|
struct bgp_adj_out *adj;
|
|
|
|
|
|
|
|
/* Advertisement attribute. */
|
|
|
|
struct bgp_advertise_attr *baa;
|
|
|
|
|
|
|
|
/* BGP info. */
|
2018-10-03 00:34:03 +02:00
|
|
|
struct bgp_path_info *pathi;
|
2002-12-13 21:15:29 +01:00
|
|
|
};
|
|
|
|
|
2023-10-06 18:48:38 +02:00
|
|
|
DECLARE_DLIST(bgp_advertise_attr_fifo, struct bgp_advertise, item);
|
2019-05-20 23:41:16 +02:00
|
|
|
DECLARE_DLIST(bgp_adv_fifo, struct bgp_advertise, fifo);
|
2019-04-21 18:17:45 +02:00
|
|
|
|
2023-10-06 18:48:38 +02:00
|
|
|
/* BGP advertise attribute. */
|
|
|
|
struct bgp_advertise_attr {
|
|
|
|
/* Head of advertisement pointer. */
|
|
|
|
struct bgp_advertise_attr_fifo_head fifo;
|
|
|
|
|
|
|
|
/* Reference counter. */
|
|
|
|
unsigned long refcnt;
|
|
|
|
|
|
|
|
/* Attribute pointer to be announced. */
|
|
|
|
struct attr *attr;
|
|
|
|
};
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* BGP adjacency out. */
|
|
|
|
struct bgp_adj_out {
|
2018-12-07 15:01:59 +01:00
|
|
|
/* RB Tree of adjacency entries */
|
|
|
|
RB_ENTRY(bgp_adj_out) adj_entry;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2015-05-20 03:03:47 +02:00
|
|
|
/* Advertised subgroup. */
|
|
|
|
struct update_subgroup *subgroup;
|
|
|
|
|
|
|
|
/* Threading that makes the adj part of subgroup's adj queue */
|
|
|
|
TAILQ_ENTRY(bgp_adj_out) subgrp_adj_train;
|
|
|
|
|
|
|
|
/* Prefix information. */
|
2020-03-27 00:11:58 +01:00
|
|
|
struct bgp_dest *dest;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2018-03-27 21:13:34 +02:00
|
|
|
uint32_t addpath_tx_id;
|
BGP: support for addpath TX
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
Reviewed-by: Donald Sharp <sharpd@cumulusnetworks.com>
Reviewed-by: Vivek Venkataraman <vivek@cumulusnetworks.com
Ticket: CM-8014
This implements addpath TX with the first feature to use it
being "neighbor x.x.x.x addpath-tx-all-paths".
One change to show output is 'show ip bgp x.x.x.x'. If no addpath-tx
features are configured for any peers then everything looks the same
as it is today in that "Advertised to" is at the top and refers to
which peers the bestpath was advertise to.
root@superm-redxp-05[quagga-stash5]# vtysh -c 'show ip bgp 1.1.1.1'
BGP routing table entry for 1.1.1.1/32
Paths: (6 available, best #6, table Default-IP-Routing-Table)
Advertised to non peer-group peers:
r1(10.0.0.1) r2(10.0.0.2) r3(10.0.0.3) r4(10.0.0.4) r5(10.0.0.5) r6(10.0.0.6) r8(10.0.0.8)
Local, (Received from a RR-client)
12.12.12.12 (metric 20) from r2(10.0.0.2) (10.0.0.2)
Origin IGP, metric 0, localpref 100, valid, internal
AddPath ID: RX 0, TX 8
Last update: Fri Oct 30 18:26:44 2015
[snip]
but once you enable an addpath feature we must display "Advertised to" on a path-by-path basis:
superm-redxp-05# show ip bgp 1.1.1.1/32
BGP routing table entry for 1.1.1.1/32
Paths: (6 available, best #6, table Default-IP-Routing-Table)
Local, (Received from a RR-client)
12.12.12.12 (metric 20) from r2(10.0.0.2) (10.0.0.2)
Origin IGP, metric 0, localpref 100, valid, internal
AddPath ID: RX 0, TX 8
Advertised to: r8(10.0.0.8)
Last update: Fri Oct 30 18:26:44 2015
Local, (Received from a RR-client)
34.34.34.34 (metric 20) from r3(10.0.0.3) (10.0.0.3)
Origin IGP, metric 0, localpref 100, valid, internal
AddPath ID: RX 0, TX 7
Advertised to: r8(10.0.0.8)
Last update: Fri Oct 30 18:26:39 2015
Local, (Received from a RR-client)
56.56.56.56 (metric 20) from r6(10.0.0.6) (10.0.0.6)
Origin IGP, metric 0, localpref 100, valid, internal
AddPath ID: RX 0, TX 6
Advertised to: r8(10.0.0.8)
Last update: Fri Oct 30 18:26:39 2015
Local, (Received from a RR-client)
56.56.56.56 (metric 20) from r5(10.0.0.5) (10.0.0.5)
Origin IGP, metric 0, localpref 100, valid, internal
AddPath ID: RX 0, TX 5
Advertised to: r8(10.0.0.8)
Last update: Fri Oct 30 18:26:39 2015
Local, (Received from a RR-client)
34.34.34.34 (metric 20) from r4(10.0.0.4) (10.0.0.4)
Origin IGP, metric 0, localpref 100, valid, internal
AddPath ID: RX 0, TX 4
Advertised to: r8(10.0.0.8)
Last update: Fri Oct 30 18:26:39 2015
Local, (Received from a RR-client)
12.12.12.12 (metric 20) from r1(10.0.0.1) (10.0.0.1)
Origin IGP, metric 0, localpref 100, valid, internal, best
AddPath ID: RX 0, TX 3
Advertised to: r1(10.0.0.1) r2(10.0.0.2) r3(10.0.0.3) r4(10.0.0.4) r5(10.0.0.5) r6(10.0.0.6) r8(10.0.0.8)
Last update: Fri Oct 30 18:26:34 2015
superm-redxp-05#
2015-11-05 18:29:43 +01:00
|
|
|
|
2024-02-09 16:18:22 +01:00
|
|
|
/* Attribute hash */
|
|
|
|
uint32_t attr_hash;
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Advertised attribute. */
|
|
|
|
struct attr *attr;
|
|
|
|
|
2023-02-23 15:38:11 +01:00
|
|
|
/* VPN label information */
|
|
|
|
struct bgp_labels *labels;
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Advertisement information. */
|
|
|
|
struct bgp_advertise *adv;
|
|
|
|
};
|
|
|
|
|
2018-12-07 15:01:59 +01:00
|
|
|
RB_HEAD(bgp_adj_out_rb, bgp_adj_out);
|
|
|
|
RB_PROTOTYPE(bgp_adj_out_rb, bgp_adj_out, adj_entry,
|
|
|
|
bgp_adj_out_compare);
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* BGP adjacency in. */
|
|
|
|
struct bgp_adj_in {
|
|
|
|
/* Linked list pointer. */
|
|
|
|
struct bgp_adj_in *next;
|
|
|
|
struct bgp_adj_in *prev;
|
|
|
|
|
|
|
|
/* Received peer. */
|
|
|
|
struct peer *peer;
|
|
|
|
|
|
|
|
/* Received attribute. */
|
|
|
|
struct attr *attr;
|
2015-05-20 03:04:01 +02:00
|
|
|
|
bgpd: fix labels in adj-rib-in
In a BGP L3VPN context using ADJ-RIB-IN (ie. enabled with
'soft-reconfiguration inbound'), after applying a deny route-map and
removing it, the remote MPLS label information is lost. As a result, BGP
is unable to re-install the related routes in the RIB.
For example,
> router bgp 65500
> [..]
> neighbor 192.0.2.2 remote-as 65501
> address-family ipv4 vpn
> neighbor 192.0.2.2 activate
> neighbor 192.0.2.2 soft-reconfiguration inbound
The 192.168.0.0/24 prefix has a remote label value of 102 in the BGP
RIB.
> # show bgp ipv4 vpn 192.168.0.0/24
> BGP routing table entry for 444:1:192.168.0.0/24, version 2
> [..]
> 192.168.0.0 from 192.0.2.2
> Origin incomplete, metric 0, valid, external, best (First path received)
> Extended Community: RT:52:100
> Remote label: 102
A route-map now filter all incoming BGP updates:
> route-map rmap deny 1
> router bgp 65500
> address-family ipv4 vpn
> neighbor 192.0.2.2 route-map rmap in
The prefix is now filtered:
> # show bgp ipv4 vpn 192.168.0.0/24
> #
The route-map is detached:
> router bgp 65500
> address-family ipv4 vpn
> no neighbor 192.168.0.1 route-map rmap in
The BGP RIB entry is present but the remote label is lost:
> # show bgp ipv4 vpn 192.168.0.0/24
> BGP routing table entry for 444:1:192.168.0.0/24, version 2
> [..]
> 192.168.0.0 from 192.0.2.2
> Origin incomplete, metric 0, valid, external, best (First path received)
> Extended Community: RT:52:100
The reason for the loose is that labels are stored within struct attr ->
struct extra -> struct bgp_labels but not in the struct bgp_adj_in.
Reference the bgp_labels pointer in struct bgp_adj_in and use its values
when doing a soft reconfiguration of the BGP table.
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2023-01-13 15:59:52 +01:00
|
|
|
/* VPN label information */
|
|
|
|
struct bgp_labels *labels;
|
|
|
|
|
2019-07-17 15:24:28 +02:00
|
|
|
/* timestamp (monotime) */
|
|
|
|
time_t uptime;
|
|
|
|
|
2015-05-20 03:04:01 +02:00
|
|
|
/* Addpath identifier */
|
2018-03-27 21:13:34 +02:00
|
|
|
uint32_t addpath_rx_id;
|
2002-12-13 21:15:29 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
/* BGP advertisement list. */
|
|
|
|
struct bgp_synchronize {
|
2019-04-21 18:17:45 +02:00
|
|
|
struct bgp_adv_fifo_head update;
|
|
|
|
struct bgp_adv_fifo_head withdraw;
|
2002-12-13 21:15:29 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
/* BGP adjacency linked list. */
|
2018-09-14 02:34:42 +02:00
|
|
|
#define BGP_PATH_INFO_ADD(N, A, TYPE) \
|
2002-12-13 21:15:29 +01:00
|
|
|
do { \
|
|
|
|
(A)->prev = NULL; \
|
|
|
|
(A)->next = (N)->TYPE; \
|
|
|
|
if ((N)->TYPE) \
|
|
|
|
(N)->TYPE->prev = (A); \
|
|
|
|
(N)->TYPE = (A); \
|
|
|
|
} while (0)
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2018-09-14 02:34:42 +02:00
|
|
|
#define BGP_PATH_INFO_DEL(N, A, TYPE) \
|
2002-12-13 21:15:29 +01:00
|
|
|
do { \
|
|
|
|
if ((A)->next) \
|
|
|
|
(A)->next->prev = (A)->prev; \
|
|
|
|
if ((A)->prev) \
|
|
|
|
(A)->prev->next = (A)->next; \
|
|
|
|
else \
|
|
|
|
(N)->TYPE = (A)->next; \
|
|
|
|
} while (0)
|
|
|
|
|
2018-09-14 02:34:42 +02:00
|
|
|
#define BGP_ADJ_IN_ADD(N, A) BGP_PATH_INFO_ADD(N, A, adj_in)
|
|
|
|
#define BGP_ADJ_IN_DEL(N, A) BGP_PATH_INFO_DEL(N, A, adj_in)
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
/* Prototypes. */
|
2022-05-12 14:53:01 +02:00
|
|
|
extern bool bgp_adj_out_lookup(struct peer *peer, struct bgp_dest *dest,
|
|
|
|
uint32_t addpath_tx_id);
|
|
|
|
extern void bgp_adj_in_set(struct bgp_dest *dest, struct peer *peer,
|
bgpd: fix labels in adj-rib-in
In a BGP L3VPN context using ADJ-RIB-IN (ie. enabled with
'soft-reconfiguration inbound'), after applying a deny route-map and
removing it, the remote MPLS label information is lost. As a result, BGP
is unable to re-install the related routes in the RIB.
For example,
> router bgp 65500
> [..]
> neighbor 192.0.2.2 remote-as 65501
> address-family ipv4 vpn
> neighbor 192.0.2.2 activate
> neighbor 192.0.2.2 soft-reconfiguration inbound
The 192.168.0.0/24 prefix has a remote label value of 102 in the BGP
RIB.
> # show bgp ipv4 vpn 192.168.0.0/24
> BGP routing table entry for 444:1:192.168.0.0/24, version 2
> [..]
> 192.168.0.0 from 192.0.2.2
> Origin incomplete, metric 0, valid, external, best (First path received)
> Extended Community: RT:52:100
> Remote label: 102
A route-map now filter all incoming BGP updates:
> route-map rmap deny 1
> router bgp 65500
> address-family ipv4 vpn
> neighbor 192.0.2.2 route-map rmap in
The prefix is now filtered:
> # show bgp ipv4 vpn 192.168.0.0/24
> #
The route-map is detached:
> router bgp 65500
> address-family ipv4 vpn
> no neighbor 192.168.0.1 route-map rmap in
The BGP RIB entry is present but the remote label is lost:
> # show bgp ipv4 vpn 192.168.0.0/24
> BGP routing table entry for 444:1:192.168.0.0/24, version 2
> [..]
> 192.168.0.0 from 192.0.2.2
> Origin incomplete, metric 0, valid, external, best (First path received)
> Extended Community: RT:52:100
The reason for the loose is that labels are stored within struct attr ->
struct extra -> struct bgp_labels but not in the struct bgp_adj_in.
Reference the bgp_labels pointer in struct bgp_adj_in and use its values
when doing a soft reconfiguration of the BGP table.
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2023-01-13 15:59:52 +01:00
|
|
|
struct attr *attr, uint32_t addpath_id,
|
|
|
|
struct bgp_labels *labels);
|
2023-09-10 15:27:51 +02:00
|
|
|
extern bool bgp_adj_in_unset(struct bgp_dest **dest, struct peer *peer,
|
2022-05-12 14:53:01 +02:00
|
|
|
uint32_t addpath_id);
|
2023-09-10 14:53:36 +02:00
|
|
|
extern void bgp_adj_in_remove(struct bgp_dest **dest, struct bgp_adj_in *bai);
|
2022-05-12 14:53:01 +02:00
|
|
|
|
2022-07-25 15:37:17 +02:00
|
|
|
extern unsigned int bgp_advertise_attr_hash_key(const void *p);
|
|
|
|
extern bool bgp_advertise_attr_hash_cmp(const void *p1, const void *p2);
|
2015-05-20 03:03:47 +02:00
|
|
|
extern void bgp_advertise_add(struct bgp_advertise_attr *baa,
|
|
|
|
struct bgp_advertise *adv);
|
|
|
|
extern struct bgp_advertise *bgp_advertise_new(void);
|
|
|
|
extern void bgp_advertise_free(struct bgp_advertise *adv);
|
2022-07-25 15:37:17 +02:00
|
|
|
extern struct bgp_advertise_attr *bgp_advertise_attr_intern(struct hash *hash,
|
|
|
|
struct attr *attr);
|
|
|
|
extern struct bgp_advertise_attr *bgp_advertise_attr_new(void);
|
2015-05-20 03:03:47 +02:00
|
|
|
extern void bgp_advertise_delete(struct bgp_advertise_attr *baa,
|
|
|
|
struct bgp_advertise *adv);
|
2022-07-25 15:37:17 +02:00
|
|
|
extern void bgp_advertise_attr_unintern(struct hash *hash,
|
|
|
|
struct bgp_advertise_attr *baa);
|
|
|
|
extern void bgp_advertise_attr_free(struct bgp_advertise_attr *baa);
|
2005-05-23 16:19:54 +02:00
|
|
|
|
|
|
|
#endif /* _QUAGGA_BGP_ADVERTISE_H */
|