summaryrefslogtreecommitdiff
path: root/bgpd/bgp_aspath.c
diff options
context:
space:
mode:
authorFrancois Dumontet <francois.dumontet@6wind.com>2022-11-08 16:25:15 +0100
committerFrancois Dumontet <francois.dumontet@6wind.com>2022-11-25 15:28:32 +0100
commitb0a8f709a56d83d347bb544f77ba78de8fd587b6 (patch)
treede0056b5971a16697f280f4759141d381326c267 /bgpd/bgp_aspath.c
parent53317d66d1c435462335f76344faf8b34216a70a (diff)
bgp: fix case where confederation id same as member-as
currently the following configuration dut: ! interface ntfp2 ip router isis 1 ! router bgp 200 no bgp ebgp-requires-policy bgp confederation identifier 300 bgp confederation peers 300 neighbor 192.168.1.1 remote-as 100 neighbor 192.168.2.2 remote-as 300 ! address-family ipv4 unicast neighbor 192.168.2.2 default-originate exit-address-family ! router isis 1 is-type level-2-only net 49.0001.0002.0002.0002.00 redistribute ipv4 connected level-2 ! end router: ! interface ntfp2 ip router isis 1 isis circuit-type level-2-only ! router bgp 300 no bgp ebgp-requires-policy bgp confederation identifier 300 bgp confederation peers 200 neighbor 192.168.2.1 remote-as 200 neighbor 192.168.3.2 remote-as 400 ! address-family ipv4 unicast network 3.3.3.0/24 exit-address-family ! router isis 1 is-type level-2-only net 49.0001.0003.0003.0003.00 redistribute ipv4 connected level-2 ! end on dut result of show bgp ipv4 unicast command is: show bgp ipv4 unicast BGP table version is 1, local router ID is 192.168.2.1, vrf id 0 Default local pref 100, local AS 200 Status codes: s suppressed, d damped, h history, * valid, > best, = multipath, i internal, r RIB-failure, S Stale, R Removed Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self Origin codes: i - IGP, e - EGP, ? - incomplete RPKI validation codes: V valid, I invalid, N Not found Network Next Hop Metric LocPrf Weight Path *> 1.1.1.0/24 192.168.1.1 0 0 100 i instead of sho bgp ipv4 unicast BGP table version is 3, local router ID is 192.168.2.1, vrf id 0 Default local pref 100, local AS 200 Status codes: s suppressed, d damped, h history, * valid, > best, = multipath, i internal, r RIB-failure, S Stale, R Removed Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self Origin codes: i - IGP, e - EGP, ? - incomplete RPKI validation codes: V valid, I invalid, N Not found Network Next Hop Metric LocPrf Weight Path *> 1.1.1.0/24 192.168.1.1 0 0 100 i *> 3.3.3.0/24 192.168.2.2 0 100 0 (300) i *> 4.4.4.0/24 192.168.3.2 0 100 0 (300) 400 i Displayed 3 routes and 3 total paths According to RFC 5065:the usage of one of the member AS number as the confederation identifier is not forbidden. fixes are the following in bgp_route.c: in bgp_update remove the test for presence of confederation id in as_path since, this case is allowed; in bgp_vty.c bgp_confederation_peers, remove the test on peer as value in bgpd.c bgp_confederation_peers_add remove the test on peer as value invert the order of setting peer->sort value and peer->local_as, since peer->sort is depending from current peer->local_as value bgp_confederation_peers_remove invert the order of setting peer->sort value and peer->local_as, since peer->sort is depending from current peer->local_as value Signed-off-by: Francois Dumontet <francois.dumontet@6wind.com>
Diffstat (limited to 'bgpd/bgp_aspath.c')
-rw-r--r--bgpd/bgp_aspath.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/bgpd/bgp_aspath.c b/bgpd/bgp_aspath.c
index 06f6073781..85f09ccf0b 100644
--- a/bgpd/bgp_aspath.c
+++ b/bgpd/bgp_aspath.c
@@ -1187,6 +1187,33 @@ int aspath_loop_check(struct aspath *aspath, as_t asno)
return count;
}
+/* AS path loop check. If aspath contains asno
+ * that is a confed id then return >= 1.
+ */
+int aspath_loop_check_confed(struct aspath *aspath, as_t asno)
+{
+ struct assegment *seg;
+ int count = 0;
+
+ if (aspath == NULL || aspath->segments == NULL)
+ return 0;
+
+ seg = aspath->segments;
+
+ while (seg) {
+ unsigned int i;
+
+ for (i = 0; i < seg->length; i++)
+ if (seg->type != AS_CONFED_SEQUENCE &&
+ seg->type != AS_CONFED_SET && seg->as[i] == asno)
+ count++;
+
+ seg = seg->next;
+ }
+ return count;
+}
+
+
/* When all of AS path is private AS return 1. */
bool aspath_private_as_check(struct aspath *aspath)
{