Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bgpd: Fix for session reset issue caused by malformed core attributes in update message #14129

Merged
merged 1 commit into from
Aug 2, 2023

Conversation

samanvithab
Copy link
Contributor

@samanvithab samanvithab commented Aug 2, 2023

Problem:
Few of the Update message error handling methods in RFC 4271 are updated with RFC 7606.
According to the RFC 7606, the error handling for the core attributes
has been relaxed to follow 'treat-as-withdraw' approach than session resets.
However, BGP session resets on encountering any malformed core attribute.

RCA:
On encountering any attribute error for core attributes in update message, the error handling is set to 'treat as withdraw' and further parsing of the remaining attributes is skipped. But the stream pointer is not being correctly adjusted to point to the next NLRI field skipping the rest of the attributes. This leads to incorrect parsing of the NLRI field, which causes BGP session to reset.

Fix:
The stream pointer offset is rightly adjusted to point to the NLRI field correctly when the malformed attribute is encountered and remaining attribute parsing is skipped.

Testing details with & without fix:

  1. Update message attribute flag error : handled with treat-as-withdraw approach

Without fix: session resets

2023/08/01 22:27:51 BGP: [M59KS-A3ZXZ] bgp_update_receive: rcvd End-of-RIB for IPv4 Unicast from 24.0.0.4 in vrf default
2023/08/01 22:27:55 BGP: [NYD0B-A3BTB][EC 33554433] ORIGIN attribute must be flagged as "Optional"
2023/08/01 22:27:55 BGP: [SM0KX-WXMGK] bgp_attr_malformed: attributes:
2023/08/01 22:27:55 BGP: [G2Z1P-1H5F3][EC 33554454] 24.0.0.4(frr) rcvd UPDATE with errors in attr(s)!! Withdrawing route.
2023/08/01 22:27:55 BGP: [PCFFM-WMARW] 24.0.0.4(frr) rcvd UPDATE wlen 0 attrlen 28 alen 28
2023/08/01 22:27:55 BGP: [QMZ79-K2DH7][EC 33554454] 24.0.0.4 [Error] Update packet error (wrong prefix length 80 for afi 1)
2023/08/01 22:27:55 BGP: [P9SYB-54XRZ][EC 33554454] 24.0.0.4 [Error] Error parsing NLRI
2023/08/01 22:27:55 BGP: [HZN6M-XRM1G] %NOTIFICATION: sent to neighbor 24.0.0.4 3/10 (UPDATE Message Error/Invalid Network Field) 0 bytes

With Fix: no session reset

2023/08/01 22:26:27 BGP: [NYD0B-A3BTB][EC 33554433] ORIGIN attribute must be flagged as "Optional"
2023/08/01 22:26:27 BGP: [SM0KX-WXMGK] bgp_attr_malformed: attributes:
2023/08/01 22:26:27 BGP: [G2Z1P-1H5F3][EC 33554454] 24.0.0.4(frr) rcvd UPDATE with errors in attr(s)!! Withdrawing route.
2023/08/01 22:26:27 BGP: [PCFFM-WMARW] 24.0.0.4(frr) rcvd UPDATE wlen 0 attrlen 28 alen 4
2023/08/01 22:26:27 BGP: [PAPP6-VDAWM] 24.0.0.4(frr) rcvd UPDATE about 9.9.9.0/24 IPv4 unicast -- withdrawn
2023/08/01 22:26:27 BGP: [PC71A-4RFD8] 24.0.0.4 Can't find the route 9.9.9.0/24 IPv4 unicast
2023/08/01 22:26:27 BGP: [P8XN0-33WQ6] 24.0.0.4 [FSM] Timer (keepalive timer expire)
2023/08/01 22:26:27 BGP: [HRDT0-0DPQ7] 24.0.0.4 sending KEEPALIVE
2023/08/01 22:26:27 BGP: [X61A3-E95TJ] 24.0.0.4 KEEPALIVE rcvd

====================================================================

  1. Update message attribute length error : treat-as-withdraw approach

Without fix: the session resets

2023/08/01 22:16:16 BGP: [RB8T5-WW10B][EC 33554434] Origin attribute length is not one 0
2023/08/01 22:16:16 BGP: [SM0KX-WXMGK] bgp_attr_malformed: attributes:
2023/08/01 22:16:16 BGP: [P7TRR-4J6XT][EC 33554487] 24.0.0.4: Attribute ORIGIN, parse error - treating as withdrawal
2023/08/01 22:16:16 BGP: [G2Z1P-1H5F3][EC 33554454] 24.0.0.4(frr) rcvd UPDATE with errors in attr(s)!! Withdrawing route.
2023/08/01 22:16:16 BGP: [PCFFM-WMARW] 24.0.0.4(frr) rcvd UPDATE wlen 0 attrlen 28 alen 29
2023/08/01 22:16:16 BGP: [PAPP6-VDAWM] 24.0.0.4(frr) rcvd UPDATE about 80.0.0.0/2 IPv4 unicast -- withdrawn
2023/08/01 22:16:16 BGP: [PC71A-4RFD8] 24.0.0.4 Can't find the route 80.0.0.0/2 IPv4 unicast
2023/08/01 22:16:16 BGP: [PAPP6-VDAWM] 24.0.0.4(frr) rcvd UPDATE about 0.0.0.0/2 IPv4 unicast -- withdrawn
2023/08/01 22:16:16 BGP: [PC71A-4RFD8] 24.0.0.4 Can't find the route 0.0.0.0/2 IPv4 unicast
2023/08/01 22:16:16 BGP: [PAPP6-VDAWM] 24.0.0.4(frr) rcvd UPDATE about 144.0.0.0/1 IPv4 unicast -- withdrawn
2023/08/01 22:16:16 BGP: [PC71A-4RFD8] 24.0.0.4 Can't find the route 144.0.0.0/1 IPv4 unicast
2023/08/01 22:16:16 BGP: [QMZ79-K2DH7][EC 33554454] 24.0.0.4 [Error] Update packet error (wrong prefix length 64 for afi 1)
2023/08/01 22:16:16 BGP: [P9SYB-54XRZ][EC 33554454] 24.0.0.4 [Error] Error parsing NLRI
2023/08/01 22:16:16 BGP: [HZN6M-XRM1G] %NOTIFICATION: sent to neighbor 24.0.0.4 3/10 (UPDATE Message Error/Invalid Network Field) 0 bytes

With Fix: no session reset

2023/08/01 22:20:50 BGP: [RB8T5-WW10B][EC 33554434] Origin attribute length is not one 0
2023/08/01 22:20:50 BGP: [SM0KX-WXMGK] bgp_attr_malformed: attributes:
2023/08/01 22:20:50 BGP: [P7TRR-4J6XT][EC 33554487] 24.0.0.4: Attribute ORIGIN, parse error - treating as withdrawal
2023/08/01 22:20:50 BGP: [G2Z1P-1H5F3][EC 33554454] 24.0.0.4(frr) rcvd UPDATE with errors in attr(s)!! Withdrawing route.
2023/08/01 22:20:50 BGP: [PCFFM-WMARW] 24.0.0.4(frr) rcvd UPDATE wlen 0 attrlen 28 alen 4
2023/08/01 22:20:50 BGP: [PAPP6-VDAWM] 24.0.0.4(frr) rcvd UPDATE about 9.9.9.0/24 IPv4 unicast -- withdrawn
2023/08/01 22:20:50 BGP: [PC71A-4RFD8] 24.0.0.4 Can't find the route 9.9.9.0/24 IPv4 unicast
2023/08/01 22:20:50 BGP: [P8XN0-33WQ6] 24.0.0.4 [FSM] Timer (keepalive timer expire)
2023/08/01 22:20:50 BGP: [HRDT0-0DPQ7] 24.0.0.4 sending KEEPALIVE
2023/08/01 22:20:50 BGP: [X61A3-E95TJ] 24.0.0.4 KEEPALIVE rcvd

@frrbot frrbot bot added the bgp label Aug 2, 2023
RCA:
On encountering any attribute error for core attributes in update message,
the error handling is set to 'treat as withdraw' and
further parsing of the remaining attributes is skipped.
But the stream pointer is not being correctly adjusted to
point to the next NLRI field skipping the rest of the attributes.
This leads to incorrect parsing of the NLRI field,
which causes BGP session to reset.

Fix:
The stream pointer offset is rightly adjusted to point to the NLRI field correctly
when the malformed attribute is encountered and remaining attribute parsing is skipped.

Signed-off-by: Samanvitha B Bhargav <[email protected]>
@NetDEF-CI
Copy link
Collaborator

NetDEF-CI commented Aug 2, 2023

Continuous Integration Result: FAILED

Continuous Integration Result: FAILED

See below for issues.
CI System Testrun URL: https://ci1.netdef.org/browse/FRR-PULLREQ2-13245/

This is a comment from an automated CI system.
For questions and feedback in regards to this CI system, please feel free to email
Martin Winter - mwinter (at) opensourcerouting.org.

Get source / Pull Request: Successful

Building Stage: Successful

Basic Tests: Failed

Topotests Ubuntu 18.04 arm8 part 1: Failed (click for details) Topotests Ubuntu 18.04 arm8 part 1: No useful log found
Successful on other platforms/tests
  • Topotests debian 10 amd64 part 6
  • Topotests Ubuntu 18.04 amd64 part 0
  • Topotests Ubuntu 18.04 arm8 part 6
  • Addresssanitizer topotests part 3
  • Topotests Ubuntu 18.04 amd64 part 7
  • Topotests Ubuntu 18.04 i386 part 5
  • Addresssanitizer topotests part 2
  • Topotests debian 10 amd64 part 5
  • CentOS 7 rpm pkg check
  • Topotests Ubuntu 18.04 amd64 part 4
  • Topotests debian 10 amd64 part 7
  • Topotests Ubuntu 18.04 amd64 part 3
  • Addresssanitizer topotests part 8
  • Topotests Ubuntu 18.04 i386 part 7
  • Topotests Ubuntu 18.04 i386 part 2
  • Topotests Ubuntu 18.04 arm8 part 8
  • Ubuntu 18.04 deb pkg check
  • Topotests Ubuntu 18.04 i386 part 0
  • Addresssanitizer topotests part 6
  • Topotests Ubuntu 18.04 amd64 part 1
  • Topotests Ubuntu 18.04 i386 part 8
  • Topotests Ubuntu 18.04 amd64 part 2
  • Topotests Ubuntu 18.04 i386 part 3
  • Topotests debian 10 amd64 part 8
  • Addresssanitizer topotests part 0
  • Topotests Ubuntu 18.04 amd64 part 6
  • Topotests debian 10 amd64 part 3
  • Topotests Ubuntu 18.04 arm8 part 4
  • Topotests Ubuntu 18.04 arm8 part 9
  • Addresssanitizer topotests part 4
  • Topotests Ubuntu 18.04 arm8 part 3
  • Debian 9 deb pkg check
  • Topotests debian 10 amd64 part 9
  • Addresssanitizer topotests part 1
  • Topotests Ubuntu 18.04 i386 part 4
  • Topotests debian 10 amd64 part 4
  • Topotests debian 10 amd64 part 2
  • Addresssanitizer topotests part 9
  • Topotests Ubuntu 18.04 amd64 part 9
  • Topotests Ubuntu 18.04 i386 part 9
  • Topotests Ubuntu 18.04 arm8 part 0
  • Topotests Ubuntu 18.04 amd64 part 8
  • Topotests Ubuntu 18.04 arm8 part 7
  • Topotests Ubuntu 18.04 arm8 part 2
  • Static analyzer (clang)
  • Topotests debian 10 amd64 part 0
  • Addresssanitizer topotests part 7
  • Ubuntu 20.04 deb pkg check
  • Topotests Ubuntu 18.04 i386 part 6
  • Topotests Ubuntu 18.04 amd64 part 5
  • Debian 10 deb pkg check
  • Topotests debian 10 amd64 part 1
  • Topotests Ubuntu 18.04 arm8 part 5
  • Addresssanitizer topotests part 5
  • Topotests Ubuntu 18.04 i386 part 1

@NetDEF-CI
Copy link
Collaborator

Continuous Integration Result: SUCCESSFUL

Congratulations, this patch passed basic tests

Tested-by: NetDEF / OpenSourceRouting.org CI System

CI System Testrun URL: https://ci1.netdef.org/browse/FRR-PULLREQ2-13246/

This is a comment from an automated CI system.
For questions and feedback in regards to this CI system, please feel free to email
Martin Winter - mwinter (at) opensourcerouting.org.

@samanvithab samanvithab marked this pull request as ready for review August 2, 2023 16:18
@donaldsharp
Copy link
Member

@Mergifyio backport stable/9.0 stable/8.5 stable/8.4

@mergify
Copy link

mergify bot commented Aug 2, 2023

@donaldsharp donaldsharp merged commit 7415f1e into FRRouting:master Aug 2, 2023
5 checks passed
ton31337 added a commit that referenced this pull request Aug 3, 2023
bgpd: Fix for session reset issue caused by malformed core attributes  in update message (backport #14129)
ton31337 added a commit that referenced this pull request Aug 3, 2023
bgpd: Fix for session reset issue caused by malformed core attributes  in update message (backport #14129)
donaldsharp added a commit that referenced this pull request Aug 4, 2023
bgpd: Fix for session reset issue caused by malformed core attributes  in update message (backport #14129)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants