diff options
author | Donatas Abraitis <donatas@opensourcerouting.org> | 2022-04-25 09:34:36 +0200 |
---|---|---|
committer | Donatas Abraitis <donatas@opensourcerouting.org> | 2022-04-25 13:05:22 +0200 |
commit | 77e3d82167b97a1ff4abe59d6e4f12086a61d9f9 (patch) | |
tree | 5c68e86eaa6fd6b9734e40928b6bee1390377299 /bgpd/bgp_aspath.c | |
parent | Merge pull request #11064 from opensourcerouting/fix/allow_only_euid_0_runnin... (diff) | |
download | frr-77e3d82167b97a1ff4abe59d6e4f12086a61d9f9.tar.xz frr-77e3d82167b97a1ff4abe59d6e4f12086a61d9f9.zip |
bgpd: Add `set as-path replace <any|ASN>` cmd for route-maps
```
route-map tstas permit 10
set as-path replace 1
exit
```
Before:
```
donatas-laptop(config-router-af)# do show ip bgp 10.10.10.10/32
BGP routing table entry for 10.10.10.10/32, version 13
Paths: (1 available, best #1, table default)
Advertised to non peer-group peers:
192.168.10.65
65000 1 2 3 123
192.168.10.65 from 192.168.10.65 (10.10.10.11)
Origin IGP, metric 0, valid, external, best (First path received)
Last update: Mon Apr 25 10:39:50 2022
```
After:
```
donatas-laptop(config-router-af)# do show ip bgp 10.10.10.10/32
BGP routing table entry for 10.10.10.10/32, version 15
Paths: (1 available, best #1, table default)
Advertised to non peer-group peers:
192.168.10.65
65000 65010 2 3 123
192.168.10.65 from 192.168.10.65 (10.10.10.11)
Origin IGP, metric 0, valid, external, best (First path received)
Last update: Mon Apr 25 10:40:16 2022
```
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
Diffstat (limited to 'bgpd/bgp_aspath.c')
-rw-r--r-- | bgpd/bgp_aspath.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/bgpd/bgp_aspath.c b/bgpd/bgp_aspath.c index fd644ebf0..880e15fad 100644 --- a/bgpd/bgp_aspath.c +++ b/bgpd/bgp_aspath.c @@ -1258,6 +1258,28 @@ struct aspath *aspath_replace_specific_asn(struct aspath *aspath, return new; } +/* Replace all ASNs with our own ASN */ +struct aspath *aspath_replace_all_asn(struct aspath *aspath, as_t our_asn) +{ + struct aspath *new; + struct assegment *seg; + + new = aspath_dup(aspath); + seg = new->segments; + + while (seg) { + int i; + + for (i = 0; i < seg->length; i++) + seg->as[i] = our_asn; + + seg = seg->next; + } + + aspath_str_update(new, false); + return new; +} + /* Replace all private ASNs with our own ASN */ struct aspath *aspath_replace_private_asns(struct aspath *aspath, as_t asn, as_t peer_asn) |