Exa-Networks / exabgp

The BGP swiss army knife of networking
Other
2.07k stars 443 forks source link

AttributeError: 'ASN' object has no attribute 'ID' #1080

Closed NoifP closed 2 years ago

NoifP commented 2 years ago

Bug Report

AttributeError: 'ASN' object has no attribute 'ID'

Describe the bug

ExaBGP (git master) crashes when using a config file that worked fine on ExaBGP 4.2.18 (that was installed via pip with python 3.8.10).

root@3-nxtm1-tnsrpoc03-linux01:/opt/exabgp-git# cat /etc/exabgp/exabgp-poc-transit-vyos.conf
neighbor 10.0.1.4 {
    router-id 10.0.1.2;
    local-address 10.0.1.2;
    local-as 65002;
    peer-as 65004;

    # 1 transit :)
    static {
       route 96.0.0.0/4 next-hop 10.0.1.2 community [174:666] split /24;
    }
}

Running exabgp with -d results in the following:

root@3-nxtm1-tnsrpoc03-linux01:/opt/exabgp-git# ./sbin/exabgp -d /etc/exabgp/exabgp-poc-transit-vyos.conf
05:25:53 1879   welcome       Thank you for using ExaBGP
05:25:53 1879   version         master-7eedc9232d7209813b7572ec25697c9784dbdb66
05:25:53 1879   location        /opt/exabgp-git
05:25:53 1879   python          3.8.10 (default, Mar 15 2022, 12:22:08)  [GCC 9.4.0]
05:25:53 1879   platform        Linux 3-nxtm1-tnsrpoc03-linux01 5.4.0-109-generic #123-Ubuntu SMP Fri Apr 8 09:10:54 UTC 2022 x86_64
05:25:53 1879   cli control   named pipes for the cli are:
05:25:53 1879   cli control   to send commands  /run/exabgp.in
05:25:53 1879   cli control   to read responses /run/exabgp.out
05:25:53 1879   configuration performing reload of exabgp master-7eedc9232d7209813b7572ec25697c9784dbdb66
05:25:53 1879   configuration   > neighbor         | '10.0.1.4'
05:25:53 1879   configuration   . router-id        | '10.0.1.2'
05:25:53 1879   configuration   . local-address    | '10.0.1.2'
05:25:53 1879   configuration   . local-as         | '65002'
05:25:53 1879   configuration   . peer-as          | '65004'
05:25:53 1879   configuration   > static           |
05:25:53 1879   configuration   . route            | '96.0.0.0/4' 'next-hop' '10.0.1.2' 'community' '[' '174:666' ']' 'split' '/24'
05:26:13 1879   configuration   < static           |
05:26:28 1879   configuration   < neighbor         |
05:26:28 1879   reactor         new peer: neighbor 10.0.1.4 local-ip 10.0.1.2 local-as 65002 peer-as 65004 router-id 10.0.1.2 family-allowed in-open
05:26:28 1879   reactor       loaded new configuration successfully
05:26:28 1879   process         forked process api-internal-cli-c10a6b60
05:26:28 1879   reactor         initialising connection to peer-1
05:26:28 1879   outgoing-1      attempting connection to 10.0.1.4:179
05:26:28 1879   outgoing-1      sending TCP payload ( 251) FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF 00FB 0104 FDEA 00B4 0A00 0102 DE02 0601 0400 0100 0102 0601 0400 0100 0202 0601 0400 0100 0402 0601 0400 0100 8002 0601 0400 0100 8402 0601 0400 0100 8502 0601 0400 0100 8602 0601 0400 0200 0102 0601 0400 0200 0202 0601 0400 0200 0402 0601 0400 0200 8002 0601 0400 0200 8502 0601 0400 0200 8602 0601 0400 1900 4102 0601 0400 1900 4602 0601 0440 0400 4702 0601 0440 0400 4802 0641 0400 00FD EA02 4840 4680 B400 0101 8000 0102 8000 0104 8000 0180 8000 0184 8000 0185 8000 0186 8000 0201 8000 0202 8000 0204 8000 0280 8000 0285
8000 0286 8000 1941 8000 1946 8040 0447 8040 0448 8002 0206 00
05:26:28 1879   outgoing-1      >> OPEN version=4 asn=65002 hold_time=180 router_id=10.0.1.2 capabilities=[Multiprotocol(ipv4 unicast,ipv4 multicast,ipv4 nlri-mpls,ipv4 mpls-vpn,ipv4 rtc,ipv4 flow,ipv4 flow-vpn,ipv6 unicast,ipv6 multicast,ipv6 nlri-mpls,ipv6 mpls-vpn,ipv6 flow,ipv6 flow-vpn,l2vpn vpls,l2vpn evpn,bgp-ls bgp-ls,bgp-ls bgp-ls-vpn), Extended Message(65535), Graceful Restart Flags 0x8 Time 180 ipv4/unicast=0x80 ipv4/multicast=0x80 ipv4/nlri-mpls=0x80 ipv4/mpls-vpn=0x80 ipv4/rtc=0x80 ipv4/flow=0x80 ipv4/flow-vpn=0x80 ipv6/unicast=0x80 ipv6/multicast=0x80 ipv6/nlri-mpls=0x80 ipv6/mpls-vpn=0x80 ipv6/flow=0x80 ipv6/flow-vpn=0x80 l2vpn/vpls=0x80 l2vpn/evpn=0x80 bgp-ls/bgp-ls=0x80 bgp-ls/bgp-ls-vpn=0x80, ASN4(65002)]
05:26:28 1879   outgoing-1      received TCP payload (  19) FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF 0061 01
05:26:28 1879   outgoing-1      received TCP payload (  78) 04FD EC00 B40A 0001 0444 0206 0104 0001 0001 0202 8000 0202 0200 0206 4104 0000 FDEC 0206 4504 0001 0101 021C 491A 1833 2D6E 7874 6D31 2D74 6E73 7270 6F63 3033 2D76 796F 7330 3100 0204 4002 0078
05:26:28 1879   outgoing-1      << message of type OPEN
05:26:28 1879   outgoing-1      << OPEN version=4 asn=65004 hold_time=180 router_id=10.0.1.4 capabilities=[Multiprotocol(ipv4 unicast), Route Refresh, Graceful Restart Flags 0x0 Time 120 , ASN4(65004), AddPath(receive ipv4 unicast), Unassigned 73, Route Refresh]
05:26:28 1879   ka-outgoing-1   receive-timer 60 second(s) left
05:26:28 1879   outgoing-1    --------------------------------------------------------------------
05:26:28 1879   outgoing-1    the connection can not carry the following family/families
05:26:28 1879   outgoing-1     - peer is not configured for ipv6/flow
05:26:28 1879   outgoing-1     - peer is not configured for ipv6/nlri-mpls
05:26:28 1879   outgoing-1     - peer is not configured for ipv4/multicast
05:26:28 1879   outgoing-1     - peer is not configured for ipv6/unicast
05:26:28 1879   outgoing-1     - peer is not configured for l2vpn/evpn
05:26:28 1879   outgoing-1     - peer is not configured for ipv4/flow
05:26:28 1879   outgoing-1     - peer is not configured for ipv4/nlri-mpls
05:26:28 1879   outgoing-1     - peer is not configured for ipv4/mpls-vpn
05:26:28 1879   outgoing-1     - peer is not configured for bgp-ls/bgp-ls-vpn
05:26:28 1879   outgoing-1     - peer is not configured for ipv6/mpls-vpn
05:26:28 1879   outgoing-1     - peer is not configured for ipv4/rtc
05:26:28 1879   outgoing-1     - peer is not configured for ipv6/multicast
05:26:28 1879   outgoing-1     - peer is not configured for ipv6/flow-vpn
05:26:28 1879   outgoing-1     - peer is not configured for l2vpn/vpls
05:26:28 1879   outgoing-1     - peer is not configured for bgp-ls/bgp-ls
05:26:28 1879   outgoing-1     - peer is not configured for ipv4/flow-vpn
05:26:28 1879   outgoing-1    therefore no routes of this kind can be announced on the connection
05:26:28 1879   outgoing-1    --------------------------------------------------------------------
05:26:28 1879   outgoing-1      sending TCP payload (  19) FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF 0013 04
05:26:28 1879   outgoing-1      >> KEEPALIVE (OPENCONFIRM)
05:26:28 1879   outgoing-1      received TCP payload (  19) FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF 0013 04
05:26:28 1879   outgoing-1      << message of type KEEPALIVE
05:26:28 1879   ka-outgoing-1   receive-timer 180 second(s) left
05:26:28 1879   reactor       connected to peer-1 with outgoing-1 10.0.1.2-10.0.1.4
05:26:43 1879   reactor
05:26:43 1879   reactor         ********************************************************************************
05:26:43 1879   reactor         EXABGP MISBEHAVED / HELP US FIX IT
05:26:43 1879   reactor         ********************************************************************************
05:26:43 1879   reactor
05:26:43 1879   reactor         Sorry, you encountered a problem with ExaBGP, as the problem only affects one
05:26:43 1879   reactor         peer, we are trying to keep the program running.
05:26:43 1879   reactor
05:26:43 1879   reactor         There are a few things you can do to help us (and yourself):
05:26:43 1879   reactor         - make sure you are running the latest version of the code available at
05:26:43 1879   reactor           https://github.com/Exa-Networks/exabgp/releases/latest
05:26:43 1879   reactor         - if so report the issue on https://github.com/Exa-Networks/exabgp/issues
05:26:43 1879   reactor           so it can be fixed (github can be searched for similar reports)
05:26:43 1879   reactor
05:26:43 1879   reactor         PLEASE, when reporting, do include as much information as you can:
05:26:43 1879   reactor         - do not obfuscate any data (feel free to send us a private  email with the
05:26:43 1879   reactor           extra information if your business policy is strict on information sharing)
05:26:43 1879   reactor           https://github.com/Exa-Networks/exabgp/wiki/FAQ
05:26:43 1879   reactor         - if you can reproduce the issue, run ExaBGP with the command line option -d
05:26:43 1879   reactor           it provides us with much needed information to fix problems quickly
05:26:43 1879   reactor         - include the information presented below
05:26:43 1879   reactor
05:26:43 1879   reactor         Should you not receive an acknowledgment of your issue on github (assignement,
05:26:43 1879   reactor         comment, or similar) within a few hours, feel free to email us to make sure
05:26:43 1879   reactor         it was not overlooked. (please keep in mind the authors are based in GMT/Europe)
05:26:43 1879   reactor
05:26:43 1879   reactor         ********************************************************************************
05:26:43 1879   reactor         -- Please provide ALL the information below on :
05:26:43 1879   reactor         -- https://github.com/Exa-Networks/exabgp/issues
05:26:43 1879   reactor         ********************************************************************************
05:26:43 1879   reactor
05:26:43 1879   reactor         ExaBGP version : master-7eedc9232d7209813b7572ec25697c9784dbdb66
05:26:43 1879   reactor         Python version : 3.8.10 (default, Mar 15 2022, 12:22:08)  [GCC 9.4.0]
05:26:43 1879   reactor         System Uname   : #123-Ubuntu SMP Fri Apr 8 09:10:54 UTC 2022
05:26:43 1879   reactor         System MaxInt  : 9223372036854775807
05:26:43 1879   reactor         Root           : /opt/exabgp-git
05:26:43 1879   reactor
05:26:43 1879   reactor         Environment:
05:26:43 1879   reactor         exabgp.log.enable=false
05:26:43 1879   reactor         exabgp.log.short=false
05:26:43 1879   reactor
05:26:43 1879   reactor
05:26:43 1879   reactor
05:26:43 1879   reactor         <class 'AttributeError'>
05:26:43 1879   reactor         'ASN' object has no attribute 'ID'
05:26:43 1879   reactor         Traceback (most recent call last):
05:26:43 1879   reactor           File "/opt/exabgp-git/src/exabgp/reactor/peer.py", line 565, in _run
05:26:43 1879   reactor             for action in self._main():
05:26:43 1879   reactor           File "/opt/exabgp-git/src/exabgp/reactor/peer.py", line 513, in _main
05:26:43 1879   reactor             next(new_routes)
05:26:43 1879   reactor           File "/opt/exabgp-git/src/exabgp/reactor/protocol.py", line 355, in new_update
05:26:43 1879   reactor             for message in update.messages(self.negotiated, include_withdraw):
05:26:43 1879   reactor           File "/opt/exabgp-git/src/exabgp/bgp/message/update/__init__.py", line 167, in messages
05:26:43 1879   reactor             attr = self.attributes.pack(negotiated, include_defaults)
05:26:43 1879   reactor           File "/opt/exabgp-git/src/exabgp/bgp/message/update/attribute/attributes.py", line 255, in pack
05:26:43 1879   reactor             message += default[code](local_asn, peer_asn).pack(negotiated)
05:26:43 1879   reactor           File "/opt/exabgp-git/src/exabgp/bgp/message/update/attribute/aspath.py", line 116, in pack
05:26:43 1879   reactor             return self.pack_segments(self.aspath, negotiated.asn4)
05:26:43 1879   reactor           File "/opt/exabgp-git/src/exabgp/bgp/message/update/attribute/aspath.py", line 107, in pack_segments
05:26:43 1879   reactor             segments += cls._segment(content.ID, content, asn4)
05:26:43 1879   reactor         AttributeError: 'ASN' object has no attribute 'ID'
05:26:43 1879   reactor
05:26:43 1879   reactor         ********************************************************************************
05:26:43 1879   reactor         -- Please provide _ALL_ the information above on :
05:26:43 1879   reactor         -- https://github.com/Exa-Networks/exabgp/issues
05:26:43 1879   reactor         ********************************************************************************
05:26:43 1879   reactor
05:26:43 1879   outgoing-1      peer reset, message [] error[]
05:26:43 1879   outgoing-1    outgoing-1 10.0.1.2-10.0.1.4, closing connection
05:26:43 1879   outgoing-1    connection to 10.0.1.4 closed
05:26:43 1879   reactor         initialising connection to peer-1
05:26:43 1879   outgoing-2      attempting connection to 10.0.1.4:179
05:26:43 1879   outgoing-2      sending TCP payload ( 251) FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF 00FB 0104 FDEA 00B4 0A00 0102 DE02 0601 0400 0100 0102 0601 0400 0100 0202 0601 0400 0100 0402 0601 0400 0100 8002 0601 0400 0100 8402 0601 0400 0100 8502 0601 0400 0100 8602 0601 0400 0200 0102 0601 0400 0200 0202 0601 0400 0200 0402 0601 0400 0200 8002 0601 0400 0200 8502 0601 0400 0200 8602 0601 0400 1900 4102 0601 0400 1900 4602 0601 0440 0400 4702 0601 0440 0400 4802 0641 0400 00FD EA02 4840 4680 B400 0101 8000 0102 8000 0104 8000 0180 8000 0184 8000 0185 8000 0186 8000 0201 8000 0202 8000 0204 8000 0280 8000 0285
8000 0286 8000 1941 8000 1946 8040 0447 8040 0448 8002 0206 00
05:26:43 1879   outgoing-2      >> OPEN version=4 asn=65002 hold_time=180 router_id=10.0.1.2 capabilities=[Multiprotocol(ipv4 unicast,ipv4 multicast,ipv4 nlri-mpls,ipv4 mpls-vpn,ipv4 rtc,ipv4 flow,ipv4 flow-vpn,ipv6 unicast,ipv6 multicast,ipv6 nlri-mpls,ipv6 mpls-vpn,ipv6 flow,ipv6 flow-vpn,l2vpn vpls,l2vpn evpn,bgp-ls bgp-ls,bgp-ls bgp-ls-vpn), Extended Message(65535), Graceful Restart Flags 0x8 Time 180 ipv4/unicast=0x80 ipv4/multicast=0x80 ipv4/nlri-mpls=0x80 ipv4/mpls-vpn=0x80 ipv4/rtc=0x80 ipv4/flow=0x80 ipv4/flow-vpn=0x80 ipv6/unicast=0x80 ipv6/multicast=0x80 ipv6/nlri-mpls=0x80 ipv6/mpls-vpn=0x80 ipv6/flow=0x80 ipv6/flow-vpn=0x80 l2vpn/vpls=0x80 l2vpn/evpn=0x80 bgp-ls/bgp-ls=0x80 bgp-ls/bgp-ls-vpn=0x80, ASN4(65002)]
05:26:43 1879   outgoing-2      received TCP payload (  19) FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF 0061 01
05:26:43 1879   outgoing-2      received TCP payload (  78) 04FD EC00 B40A 0001 0444 0206 0104 0001 0001 0202 8000 0202 0200 0206 4104 0000 FDEC 0206 4504 0001 0101 021C 491A 1833 2D6E 7874 6D31 2D74 6E73 7270 6F63 3033 2D76 796F 7330 3100 0204 4002 0078
05:26:43 1879   outgoing-2      << message of type OPEN
05:26:43 1879   outgoing-2      << OPEN version=4 asn=65004 hold_time=180 router_id=10.0.1.4 capabilities=[Multiprotocol(ipv4 unicast), Route Refresh, Graceful Restart Flags 0x0 Time 120 , ASN4(65004), AddPath(receive ipv4 unicast), Unassigned 73, Route Refresh]
05:26:43 1879   ka-outgoing-2   receive-timer 60 second(s) left
05:26:43 1879   outgoing-2    --------------------------------------------------------------------
05:26:43 1879   outgoing-2    the connection can not carry the following family/families
05:26:43 1879   outgoing-2     - peer is not configured for ipv6/flow
05:26:43 1879   outgoing-2     - peer is not configured for ipv6/nlri-mpls
05:26:43 1879   outgoing-2     - peer is not configured for ipv4/multicast
05:26:43 1879   outgoing-2     - peer is not configured for ipv6/unicast
05:26:43 1879   outgoing-2     - peer is not configured for l2vpn/evpn
05:26:43 1879   outgoing-2     - peer is not configured for ipv4/flow
05:26:43 1879   outgoing-2     - peer is not configured for ipv4/nlri-mpls
05:26:43 1879   outgoing-2     - peer is not configured for ipv4/mpls-vpn
05:26:43 1879   outgoing-2     - peer is not configured for bgp-ls/bgp-ls-vpn
05:26:43 1879   outgoing-2     - peer is not configured for ipv6/mpls-vpn
05:26:43 1879   outgoing-2     - peer is not configured for ipv4/rtc
05:26:43 1879   outgoing-2     - peer is not configured for ipv6/multicast
05:26:43 1879   outgoing-2     - peer is not configured for ipv6/flow-vpn
05:26:43 1879   outgoing-2     - peer is not configured for l2vpn/vpls
05:26:43 1879   outgoing-2     - peer is not configured for bgp-ls/bgp-ls
05:26:43 1879   outgoing-2     - peer is not configured for ipv4/flow-vpn
05:26:43 1879   outgoing-2    therefore no routes of this kind can be announced on the connection
05:26:43 1879   outgoing-2    --------------------------------------------------------------------
05:26:43 1879   outgoing-2      sending TCP payload (  19) FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF 0013 04
05:26:43 1879   outgoing-2      >> KEEPALIVE (OPENCONFIRM)
05:26:43 1879   outgoing-2      received TCP payload (  19) FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF 0013 04
05:26:43 1879   outgoing-2      << message of type KEEPALIVE
05:26:43 1879   ka-outgoing-2   receive-timer 180 second(s) left
05:26:43 1879   reactor       connected to peer-1 with outgoing-2 10.0.1.2-10.0.1.4
05:26:49 1879   reactor       ^C received
05:26:49 1879   reactor       performing shutdown
05:26:49 1879   outgoing-2      stop, message [shutting down]
05:26:49 1879   outgoing-2    outgoing-2 10.0.1.2-10.0.1.4, closing connection
05:26:49 1879   outgoing-2    connection to 10.0.1.4 closed
05:26:50 1879   process         terminating process api-internal-cli-c10a6b60
05:26:51 1879   outgoing-2    outgoing-2 10.0.1.2-10.0.1.4, closing connection
05:26:51 1879   outgoing-2    connection to 10.0.1.4 closed
05:26:51 1879   outgoing-1    outgoing-1 10.0.1.2-10.0.1.4, closing connection
05:26:51 1879   outgoing-1    connection to 10.0.1.4 closed

To Reproduce

Steps to reproduce the behaviour:

cd /opt
git clone https://github.com/Exa-Networks/exabgp exabgp-git
cd /opt/exabgp-git
/opt/exabgp-git# ./sbin/exabgp -d /etc/exabgp/exabgp-poc-transit-vyos.conf

Expected behaviour

ExaBGP should run without crashing and trying to start multiple BGP connection to the peer.

Environment

Additional context

peer is VyOS 1.3.0-rc6 configured as follows:

set interfaces ethernet eth1 address '10.0.1.4/24'
set policy as-path-list as65004 rule 10 action 'permit'
set policy as-path-list as65004 rule 10 regex '65004'
set protocols bgp 65004 neighbor 10.0.1.2 address-family ipv4-unicast filter-list export 'as65004'
set protocols bgp 65004 neighbor 10.0.1.2 address-family ipv4-unicast soft-reconfiguration inbound
set protocols bgp 65004 neighbor 10.0.1.2 description 'EXABGP'
set protocols bgp 65004 neighbor 10.0.1.2 remote-as '65002'
set protocols bgp 65004 parameters log-neighbor-changes
set protocols bgp 65004 parameters router-id '10.0.1.4'

log file on VyOS:

Apr 28 05:53:58 3-nxtm1-tnsrpoc03-vyos01 bgpd[970]: [EC 33554503] 10.0.1.2 unrecognized capability code: 6 - ignored
Apr 28 05:53:58 3-nxtm1-tnsrpoc03-vyos01 bgpd[970]: %ADJCHANGE: neighbor 10.0.1.2(Unknown) in vrf default Up
Apr 28 05:54:13 3-nxtm1-tnsrpoc03-vyos01 bgpd[970]: [EC 33554454] 10.0.1.2 [Error] bgp_read_packet error: Connection reset by peer
Apr 28 05:54:13 3-nxtm1-tnsrpoc03-vyos01 bgpd[970]: %ADJCHANGE: neighbor 10.0.1.2(Unknown) in vrf default Down NSF peer closed the session
Apr 28 05:54:13 3-nxtm1-tnsrpoc03-vyos01 bgpd[970]: [EC 33554503] 10.0.1.2 unrecognized capability code: 6 - ignored
Apr 28 05:54:13 3-nxtm1-tnsrpoc03-vyos01 bgpd[970]: %ADJCHANGE: neighbor 10.0.1.2(Unknown) in vrf default Up
Apr 28 05:54:27 3-nxtm1-tnsrpoc03-vyos01 bgpd[970]: [EC 33554454] 10.0.1.2 [Error] bgp_read_packet error: Connection reset by peer
Apr 28 05:54:27 3-nxtm1-tnsrpoc03-vyos01 bgpd[970]: %ADJCHANGE: neighbor 10.0.1.2(Unknown) in vrf default Down NSF peer closed the session
Apr 28 05:54:28 3-nxtm1-tnsrpoc03-vyos01 bgpd[970]: [EC 33554503] 10.0.1.2 unrecognized capability code: 6 - ignored
Apr 28 05:54:28 3-nxtm1-tnsrpoc03-vyos01 bgpd[970]: %ADJCHANGE: neighbor 10.0.1.2(Unknown) in vrf default Up
Apr 28 05:54:30 3-nxtm1-tnsrpoc03-vyos01 bgpd[970]: [EC 33554454] 10.0.1.2 [Error] bgp_read_packet error: Connection reset by peer
Apr 28 05:54:30 3-nxtm1-tnsrpoc03-vyos01 bgpd[970]: %ADJCHANGE: neighbor 10.0.1.2(Unknown) in vrf default Down NSF peer closed the session

Also tested ExaBGP against TNSR peer as well and saw the same behaviour (i.e. working with ExaBGP 4.2.18 and crashing ExaBGP on git master version).

thomas-mangin commented 2 years ago

Thank you, this was a nasty bug which was introduced a few months back on EBGP connections (only), for which there is no functional test (something else I will need to fix - but later on).

NoifP commented 2 years ago

Thanks very much Thomas, this is working now.