diff options
| author | Donatas Abraitis <donatas.abraitis@gmail.com> | 2021-02-25 19:46:49 +0200 |
|---|---|---|
| committer | Donatas Abraitis <donatas.abraitis@gmail.com> | 2021-03-04 21:32:36 +0200 |
| commit | ef56aee47c7da33db54bb8554ca71ac4247842d3 (patch) | |
| tree | 0ce8bfd360f8aa996bd883233ef1268f445b1ce3 /bgpd/bgp_open.c | |
| parent | b764e4682a462e2e93196b42edc2f797713bb52e (diff) | |
bgpd: Add BGP Extended message support
Implement https://www.rfc-editor.org/rfc/rfc8654.txt
```
> | jq '."192.168.10.25".neighborCapabilities.extendedMessage'
"advertisedAndReceived"
```
Another side is Bird:
```
BIRD 2.0.7 ready.
Name Proto Table State Since Info
v4 BGP --- up 19:39:15.689 Established
BGP state: Established
Neighbor address: 192.168.10.123
Neighbor AS: 65534
Local AS: 65025
Neighbor ID: 192.168.100.1
Local capabilities
Multiprotocol
AF announced: ipv4
Route refresh
Extended message
Graceful restart
4-octet AS numbers
Enhanced refresh
Long-lived graceful restart
Neighbor capabilities
Multiprotocol
AF announced: ipv4
Route refresh
Extended message
Graceful restart
4-octet AS numbers
ADD-PATH
RX: ipv4
TX:
Enhanced refresh
Session: external AS4
Source address: 192.168.10.25
Hold timer: 140.139/180
Keepalive timer: 9.484/60
Channel ipv4
State: UP
Table: master4
Preference: 100
Input filter: ACCEPT
Output filter: ACCEPT
Routes: 9 imported, 3 exported, 8 preferred
Route change stats: received rejected filtered ignored accepted
Import updates: 9 0 0 0 9
Import withdraws: 2 0 --- 2 0
Export updates: 11 8 0 --- 3
Export withdraws: 0 --- --- --- 0
BGP Next hop: 192.168.10.25
```
Tested at least as well with to make sure it works with backward compat.:
ExaBGP 4.0.2-1c737d99.
Arista vEOS 4.21.14M
Testing by injecint 10k routes with:
```
sharp install routes 172.16.0.1 nexthop 192.168.10.123 10000
```
Before extended message support:
```
2021/03/01 07:18:51 BGP: u1:s1 send UPDATE len 4096 (max message len: 4096) numpfx 809
2021/03/01 07:18:51 BGP: u1:s1 send UPDATE len 4096 (max message len: 4096) numpfx 809
2021/03/01 07:18:51 BGP: u1:s1 send UPDATE len 4096 (max message len: 4096) numpfx 809
2021/03/01 07:18:51 BGP: u1:s1 send UPDATE len 4096 (max message len: 4096) numpfx 809
2021/03/01 07:18:51 BGP: u1:s1 send UPDATE len 4096 (max message len: 4096) numpfx 809
2021/03/01 07:18:51 BGP: u1:s1 send UPDATE len 4096 (max message len: 4096) numpfx 809
2021/03/01 07:18:52 BGP: u1:s1 send UPDATE len 4096 (max message len: 4096) numpfx 809
2021/03/01 07:18:52 BGP: u1:s1 send UPDATE len 4096 (max message len: 4096) numpfx 809
2021/03/01 07:18:52 BGP: u1:s1 send UPDATE len 4096 (max message len: 4096) numpfx 809
2021/03/01 07:18:52 BGP: u1:s1 send UPDATE len 4096 (max message len: 4096) numpfx 809
2021/03/01 07:18:52 BGP: u1:s1 send UPDATE len 4096 (max message len: 4096) numpfx 809
2021/03/01 07:18:52 BGP: u1:s1 send UPDATE len 2186 (max message len: 4096) numpfx 427
2021/03/01 07:18:53 BGP: u1:s1 send UPDATE len 3421 (max message len: 4096) numpfx 674
```
After extended message support:
```
2021/03/01 07:20:11 BGP: u1:s1 send UPDATE len 50051 (max message len: 65535) numpfx 10000
```
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
Diffstat (limited to 'bgpd/bgp_open.c')
| -rw-r--r-- | bgpd/bgp_open.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/bgpd/bgp_open.c b/bgpd/bgp_open.c index 533518cf93..7642640218 100644 --- a/bgpd/bgp_open.c +++ b/bgpd/bgp_open.c @@ -538,6 +538,22 @@ static as_t bgp_capability_as4(struct peer *peer, struct capability_header *hdr) return as4; } +static int bgp_capability_ext_message(struct peer *peer, + struct capability_header *hdr) +{ + if (hdr->length != CAPABILITY_CODE_EXT_MESSAGE_LEN) { + flog_err( + EC_BGP_PKT_OPEN, + "%s: BGP Extended Message capability has incorrect data length %d", + peer->host, hdr->length); + return -1; + } + + SET_FLAG(peer->cap, PEER_CAP_EXTENDED_MESSAGE_RCV); + + return 0; +} + static int bgp_capability_addpath(struct peer *peer, struct capability_header *hdr) { @@ -761,6 +777,7 @@ static const struct message capcode_str[] = { {CAPABILITY_CODE_ORF_OLD, "ORF (Old)"}, {CAPABILITY_CODE_FQDN, "FQDN"}, {CAPABILITY_CODE_ENHANCED_RR, "Enhanced Route Refresh"}, + {CAPABILITY_CODE_EXT_MESSAGE, "BGP Extended Message"}, {0}}; /* Minimum sizes for length field of each cap (so not inc. the header) */ @@ -778,6 +795,7 @@ static const size_t cap_minsizes[] = { [CAPABILITY_CODE_ORF_OLD] = CAPABILITY_CODE_ORF_LEN, [CAPABILITY_CODE_FQDN] = CAPABILITY_CODE_MIN_FQDN_LEN, [CAPABILITY_CODE_ENHANCED_RR] = CAPABILITY_CODE_ENHANCED_LEN, + [CAPABILITY_CODE_EXT_MESSAGE] = CAPABILITY_CODE_EXT_MESSAGE_LEN, }; /* value the capability must be a multiple of. @@ -799,6 +817,7 @@ static const size_t cap_modsizes[] = { [CAPABILITY_CODE_ORF_OLD] = 1, [CAPABILITY_CODE_FQDN] = 1, [CAPABILITY_CODE_ENHANCED_RR] = 1, + [CAPABILITY_CODE_EXT_MESSAGE] = 1, }; /** @@ -867,6 +886,7 @@ static int bgp_capability_parse(struct peer *peer, size_t length, case CAPABILITY_CODE_ENHE: case CAPABILITY_CODE_FQDN: case CAPABILITY_CODE_ENHANCED_RR: + case CAPABILITY_CODE_EXT_MESSAGE: /* Check length. */ if (caphdr.length < cap_minsizes[caphdr.code]) { zlog_info( @@ -955,6 +975,9 @@ static int bgp_capability_parse(struct peer *peer, size_t length, case CAPABILITY_CODE_ENHE: ret = bgp_capability_enhe(peer, &caphdr); break; + case CAPABILITY_CODE_EXT_MESSAGE: + ret = bgp_capability_ext_message(peer, &caphdr); + break; case CAPABILITY_CODE_FQDN: ret = bgp_capability_hostname(peer, &caphdr); break; @@ -1191,6 +1214,12 @@ int bgp_open_option_parse(struct peer *peer, uint8_t length, int *mp_capability) } } + /* Extended Message Support */ + peer->max_packet_size = + CHECK_FLAG(peer->cap, PEER_CAP_EXTENDED_MESSAGE_RCV) + ? BGP_MAX_EXTENDED_MESSAGE_PACKET_SIZE + : BGP_MAX_PACKET_SIZE; + /* Check there are no common AFI/SAFIs and send Unsupported Capability error. */ if (*mp_capability @@ -1476,6 +1505,13 @@ void bgp_open_capability(struct stream *s, struct peer *peer) local_as = peer->local_as; stream_putl(s, local_as); + /* Extended Message Support */ + SET_FLAG(peer->cap, PEER_CAP_EXTENDED_MESSAGE_ADV); + stream_putc(s, BGP_OPEN_OPT_CAP); + stream_putc(s, CAPABILITY_CODE_EXT_MESSAGE_LEN + 2); + stream_putc(s, CAPABILITY_CODE_EXT_MESSAGE); + stream_putc(s, CAPABILITY_CODE_EXT_MESSAGE_LEN); + /* AddPath */ FOREACH_AFI_SAFI (afi, safi) { if (peer->afc[afi][safi]) { |
