inex / IXP-Manager

Full stack web application powering peering at over 200 Internet Exchange Points (IXPs) globally.
https://www.ixpmanager.org/
GNU General Public License v2.0
377 stars 161 forks source link

ASN max length too short, and 'artisan irrdb:update-asn-db' failing due to bogon #664

Closed Edrichdelange closed 4 years ago

Edrichdelange commented 4 years ago
ISSUE TYPE

Bug Report

OS
VERSION
define( 'APPLICATION_VERSION', '5.6.0' );
define( 'APPLICATION_VERDATE', '2020052300' );
ENVIRONMENT
PHP 7.4.8 (cli) (built: Jul 13 2020 16:45:47) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.8, Copyright (c), by Zend Technologies
rc  libapache2-mod-php7.0                   7.0.33-0ubuntu0.16.04.4                                        amd64        server-side, HTML-embedded scripting language (Apache 2 module)
ii  libapache2-mod-php7.3                   7.3.20-1+ubuntu18.04.1+deb.sury.org+1                          amd64        server-side, HTML-embedded scripting language (Apache 2 module)
ii  php-bcmath                              2:7.4+76+ubuntu18.04.1+deb.sury.org+9                          all          Bcmath module for PHP [default]
ii  php-cli-prompt                          1.0.3+dfsg-1                                                   all          tiny helper prompting for user input
ii  php-common                              2:76+ubuntu18.04.1+deb.sury.org+9                              all          Common files for PHP packages
ii  php-composer-ca-bundle                  1.1.0-1                                                        all          utility library to find a path to the system CA bundle
ii  php-composer-semver                     1.4.2-1                                                        all          utilities, version constraint parsing and validation
ii  php-composer-spdx-licenses              1.3.0-1                                                        all          SPDX licenses list and validation library
ii  php-curl                                2:7.4+76+ubuntu18.04.1+deb.sury.org+9                          all          CURL module for PHP [default]
ii  php-ds                                  1.2.9-1+ubuntu18.04.1+deb.sury.org+20191129                    amd64        PHP extension providing efficient data structures for PHP 7
ii  php-gd                                  2:7.4+76+ubuntu18.04.1+deb.sury.org+9                          all          GD module for PHP [default]
ii  php-gettext                             1.0.12-0.1                                                     all          transitional dummy package for php-php-gettext
ii  php-igbinary                            3.1.2+2.0.8-1+ubuntu18.04.1+deb.sury.org+1                     amd64        igbinary PHP serializer
ii  php-intl                                2:7.4+76+ubuntu18.04.1+deb.sury.org+9                          all          Internationalisation module for PHP [default]
ii  php-json-schema                         5.2.6-1                                                        all          implementation of JSON schema
ii  php-mbstring                            2:7.4+76+ubuntu18.04.1+deb.sury.org+9                          all          MBSTRING module for PHP [default]
ii  php-memcache                            4.0.5.2+3.0.9~20170802.e702b5f9-1+ubuntu18.04.1+deb.sury.org+1 amd64        memcache extension module for PHP
ii  php-memcached                           3.1.4+2.2.0-1+ubuntu18.04.1+deb.sury.org+20191129              amd64        memcached extension module for PHP, uses libmemcached
ii  php-msgpack                             2.1.0+0.5.7-1+ubuntu18.04.1+deb.sury.org+1                     amd64        PHP extension for interfacing with MessagePack
ii  php-mysql                               2:7.4+76+ubuntu18.04.1+deb.sury.org+9                          all          MySQL module for PHP [default]
ii  php-pear                                1:1.10.8+submodules+notgz-1+ubuntu18.04.1+deb.sury.org+1       all          PEAR Base System
ii  php-php-gettext                         1.0.12-0.1                                                     all          read gettext MO files directly, without requiring anything other than PHP
ii  php-psr-log                             1.0.2-1                                                        all          common interface for logging libraries
ii  php-rrd                                 2.0.1+1.1.3-7+ubuntu18.04.1+deb.sury.org+20191129              amd64        PHP bindings to rrd tool system
ii  php-symfony-console                     3.4.6+dfsg-1ubuntu0.1                                          all          run tasks from the command line
ii  php-symfony-debug                       3.4.6+dfsg-1ubuntu0.1                                          all          tools to make debugging of PHP code easier
ii  php-symfony-filesystem                  3.4.6+dfsg-1ubuntu0.1                                          all          basic filesystem utilities
ii  php-symfony-finder                      3.4.6+dfsg-1ubuntu0.1                                          all          find files and directories
ii  php-symfony-polyfill-mbstring           1.6.0-2                                                        all          Symfony polyfill for the Mbstring extension
ii  php-symfony-process                     3.4.6+dfsg-1ubuntu0.1                                          all          execute commands in sub-processes
ii  php-xml                                 2:7.4+76+ubuntu18.04.1+deb.sury.org+9                          all          DOM, SimpleXML, WDDX, XML, and XSL module for PHP [default]
ii  php-yaml                                2.1.0+2.0.4+1.3.2-1+ubuntu18.04.1+deb.sury.org+1               amd64        YAML-1.1 parser and emitter for PHP
ii  php-zip                                 2:7.4+76+ubuntu18.04.1+deb.sury.org+9                          all          Zip module for PHP [default]
rc  php7.0-bcmath                           7.0.33-0ubuntu0.16.04.4                                        amd64        Bcmath module for PHP
rc  php7.0-cgi                              7.0.33-0ubuntu0.16.04.4                                        amd64        server-side, HTML-embedded scripting language (CGI binary)
rc  php7.0-cli                              7.0.33-0ubuntu0.16.04.4                                        amd64        command-line interpreter for the PHP scripting language
rc  php7.0-common                           7.0.33-0ubuntu0.16.04.4                                        amd64        documentation, examples and common module for PHP
rc  php7.0-curl                             7.0.33-0ubuntu0.16.04.4                                        amd64        CURL module for PHP
rc  php7.0-gd                               7.0.33-0ubuntu0.16.04.4                                        amd64        GD module for PHP
rc  php7.0-intl                             7.0.33-0ubuntu0.16.04.4                                        amd64        Internationalisation module for PHP
rc  php7.0-json                             7.0.33-0ubuntu0.16.04.4                                        amd64        JSON module for PHP
rc  php7.0-mbstring                         7.0.33-0ubuntu0.16.04.4                                        amd64        MBSTRING module for PHP
rc  php7.0-mcrypt                           7.0.33-0ubuntu0.16.04.4                                        amd64        libmcrypt module for PHP
rc  php7.0-mysql                            7.0.33-0ubuntu0.16.04.4                                        amd64        MySQL module for PHP
rc  php7.0-opcache                          7.0.33-0ubuntu0.16.04.4                                        amd64        Zend OpCache module for PHP
rc  php7.0-readline                         7.0.33-0ubuntu0.16.04.4                                        amd64        readline module for PHP
rc  php7.0-snmp                             7.0.33-0ubuntu0.16.04.4                                        amd64        SNMP module for PHP
rc  php7.0-xml                              7.0.33-0ubuntu0.16.04.4                                        amd64        DOM, SimpleXML, WDDX, XML, and XSL module for PHP
rc  php7.0-zip                              7.0.33-0ubuntu0.16.04.4                                        amd64        Zip module for PHP
rc  php7.2-cli                              7.2.19-1+ubuntu18.04.1+deb.sury.org+1                          amd64        command-line interpreter for the PHP scripting language
rc  php7.2-common                           7.2.19-1+ubuntu18.04.1+deb.sury.org+1                          amd64        documentation, examples and common module for PHP
rc  php7.2-json                             7.2.19-1+ubuntu18.04.1+deb.sury.org+1                          amd64        JSON module for PHP
rc  php7.2-mysql                            7.2.17-0ubuntu0.18.04.1                                        amd64        MySQL module for PHP
rc  php7.2-opcache                          7.2.19-1+ubuntu18.04.1+deb.sury.org+1                          amd64        Zend OpCache module for PHP
rc  php7.2-phpdbg                           7.2.17-0ubuntu0.18.04.1                                        amd64        server-side, HTML-embedded scripting language (PHPDBG binary)
rc  php7.2-readline                         7.2.19-1+ubuntu18.04.1+deb.sury.org+1                          amd64        readline module for PHP
rc  php7.2-zip                              7.2.17-0ubuntu0.18.04.1                                        amd64        Zip module for PHP
ii  php7.3                                  7.3.20-1+ubuntu18.04.1+deb.sury.org+1                          all          server-side, HTML-embedded scripting language (metapackage)
ii  php7.3-bcmath                           7.3.20-1+ubuntu18.04.1+deb.sury.org+1                          amd64        Bcmath module for PHP
ii  php7.3-cgi                              7.3.20-1+ubuntu18.04.1+deb.sury.org+1                          amd64        server-side, HTML-embedded scripting language (CGI binary)
ii  php7.3-cli                              7.3.20-1+ubuntu18.04.1+deb.sury.org+1                          amd64        command-line interpreter for the PHP scripting language
ii  php7.3-common                           7.3.20-1+ubuntu18.04.1+deb.sury.org+1                          amd64        documentation, examples and common module for PHP
ii  php7.3-curl                             7.3.20-1+ubuntu18.04.1+deb.sury.org+1                          amd64        CURL module for PHP
ii  php7.3-gd                               7.3.20-1+ubuntu18.04.1+deb.sury.org+1                          amd64        GD module for PHP
ii  php7.3-intl                             7.3.20-1+ubuntu18.04.1+deb.sury.org+1                          amd64        Internationalisation module for PHP
ii  php7.3-json                             7.3.20-1+ubuntu18.04.1+deb.sury.org+1                          amd64        JSON module for PHP
ii  php7.3-mbstring                         7.3.20-1+ubuntu18.04.1+deb.sury.org+1                          amd64        MBSTRING module for PHP
ii  php7.3-mysql                            7.3.20-1+ubuntu18.04.1+deb.sury.org+1                          amd64        MySQL module for PHP
ii  php7.3-opcache                          7.3.20-1+ubuntu18.04.1+deb.sury.org+1                          amd64        Zend OpCache module for PHP
ii  php7.3-readline                         7.3.20-1+ubuntu18.04.1+deb.sury.org+1                          amd64        readline module for PHP
ii  php7.3-snmp                             7.3.20-1+ubuntu18.04.1+deb.sury.org+1                          amd64        SNMP module for PHP
ii  php7.3-xml                              7.3.20-1+ubuntu18.04.1+deb.sury.org+1                          amd64        DOM, SimpleXML, WDDX, XML, and XSL module for PHP
rc  php7.3-zip                              7.3.13-1+ubuntu18.04.1+deb.sury.org+1                          amd64        Zip module for PHP
ii  php7.4-bcmath                           7.4.8-1+ubuntu18.04.1+deb.sury.org+3                           amd64        Bcmath module for PHP
ii  php7.4-cli                              7.4.8-1+ubuntu18.04.1+deb.sury.org+3                           amd64        command-line interpreter for the PHP scripting language
ii  php7.4-common                           7.4.8-1+ubuntu18.04.1+deb.sury.org+3                           amd64        documentation, examples and common module for PHP
ii  php7.4-curl                             7.4.8-1+ubuntu18.04.1+deb.sury.org+3                           amd64        CURL module for PHP
ii  php7.4-fpm                              7.4.8-1+ubuntu18.04.1+deb.sury.org+3                           amd64        server-side, HTML-embedded scripting language (FPM-CGI binary)
ii  php7.4-gd                               7.4.8-1+ubuntu18.04.1+deb.sury.org+3                           amd64        GD module for PHP
ii  php7.4-intl                             7.4.8-1+ubuntu18.04.1+deb.sury.org+3                           amd64        Internationalisation module for PHP
ii  php7.4-json                             7.4.8-1+ubuntu18.04.1+deb.sury.org+3                           amd64        JSON module for PHP
ii  php7.4-mbstring                         7.4.8-1+ubuntu18.04.1+deb.sury.org+3                           amd64        MBSTRING module for PHP
ii  php7.4-mysql                            7.4.8-1+ubuntu18.04.1+deb.sury.org+3                           amd64        MySQL module for PHP
ii  php7.4-opcache                          7.4.8-1+ubuntu18.04.1+deb.sury.org+3                           amd64        Zend OpCache module for PHP
ii  php7.4-readline                         7.4.8-1+ubuntu18.04.1+deb.sury.org+3                           amd64        readline module for PHP
ii  php7.4-snmp                             7.4.8-1+ubuntu18.04.1+deb.sury.org+3                           amd64        SNMP module for PHP
ii  php7.4-xml                              7.4.8-1+ubuntu18.04.1+deb.sury.org+3                           amd64        DOM, SimpleXML, XML, and XSL module for PHP
ii  php7.4-zip                              7.4.8-1+ubuntu18.04.1+deb.sury.org+3                           amd64        Zip module for PHP
CONFIGURATION
APP_DEBUG=false
APP_URL="https://portal.xxx"
SESSION_DOMAIN="portal.xxx"
APP_LOG="daily"
IXP_API_JSONEXPORTSCHEMA_PUBLIC=true
IXP_AS112_UI_ACTIVE=false
IXP_RESELLER_ENABLED=true
GRAPHER_BACKENDS="mrtg|smokeping|sflow"
GRAPHER_BACKEND_MRTG_DBTYPE="rrd"
GRAPHER_BACKEND_MRTG_WORKDIR="/srv/mrtg"
GRAPHER_BACKEND_MRTG_LOGDIR="/srv/mrtg"
GRAPHER_BACKEND_SFLOW_ROOT="http://xx/grapher-sflow"
GRAPHER_BACKEND_SFLOW_ENABLED=true
GRAPHER_CACHE_ENABLED=true
GRAPHER_BACKEND_SMOKEPING_ENABLED=true
GRAPHER_BACKEND_SMOKEPING_URL="http://smokeping.xxx/smokeping/smokeping.cgi"
VIEW_SKIN="inx"
CACHE_DRIVER=memcached
SESSION_DRIVER=file
DOCTRINE_PROXY_AUTOGENERATE=true
DOCTRINE_CACHE=memcached
DOCTRINE_CACHE_NAMESPACE=IXPMANAGERNAMESPACE
IXP_IRRDB_BGPQ3_PATH=/usr/bin/bgpq3
IXP_FE_FRONTEND_DISABLED_LOOKING_GLASS=false
IXP_FE_FRONTEND_DISABLED_LOGO=false
IXP_FE_FRONTEND_DISABLED_FILTERED_PREFIXES=false
GRAPHER_ACCESS_TRUNK=3
GRAPHER_ACCESS_SWITCH=1
IXP_FE_LAYER2_ADDRESSES_CUST_CAN_EDIT=true
IXP_FE_LAYER2_ADDRESSES_CUST_PARAMS_MIN_ADDRESSES=1
IXP_FE_LAYER2_ADDRESSES_CUST_PARAMS_MAX_ADDRESSES=2
IXP_FE_LAYER2_ADDRESSES_EMAIL_ON_SUPERUSER_CHANGE=true
IXP_FE_LAYER2_ADDRESSES_EMAIL_ON_CUSTOMER_CHANGE=true
IXP_FE_LAYER2_ADDRESSES_EMAIL_ON_CHANGE_DEST=sysadmin@xxx
IXP_FE_CUSTOMER_BILLING_UPDATES_NOTIFY="sysadmin@xxx"

AUTH_PEERINGDB_ENABLED=true
AUTH_PEERINGDB_PRIVS=2
SUMMARY

We noticed because HE had a bogus ASN in their IRR, which was longer than ixpmanager expected, our IRR updates were failing with An exception occurred while executing 'INSERT INTO irrdb_asn ( customer_id, asn, protocol, last_seen, first_seen ) VALUES ( ?, ?, ?, ?, ? )' with params [56, 3741437414, 4, "2020-08-04 17:34:42", "2020-08-04 17:34:42"]:
Even though its a boon at the moment, this could be a valid asn in the future as it is smaller than 4294967295, which is the last 32 bit ASN

STEPS TO REPRODUCE

Have HE as a peer, with their ASSet, run ./artisan irrdb:update-asn-db 6939

EXPECTED RESULTS

For it to not fail, or to avoid the bad ASN

ACTUAL RESULTS

root@portal:/srv/ixpmanager# ./artisan irrdb:update-asn-db 6939

In AbstractMySQLDriver.php line 106:

An exception occurred while executing 'INSERT INTO irrdb_asn ( customer_id, asn, protocol, last_seen, first_seen ) VALUES ( ?, ?, ?, ?, ? )' with params [56, 3741437414, 4, "2020-08-04 17:34:42", "2020-08-04 17:34:42"]:

SQLSTATE[22003]: Numeric value out of range: 1264 Out of range value for column 'asn' at row 1

In PDOStatement.php line 129:

SQLSTATE[22003]: Numeric value out of range: 1264 Out of range value for column 'asn' at row 1

In PDOStatement.php line 127:

SQLSTATE[22003]: Numeric value out of range: 1264 Out of range value for column 'asn' at row 1

IMPORTANCE

Yes, Im assuming this is blocking the filter updates for HE.net

RELEVANT LOGS
nickhilliard commented 4 years ago

hm, irrdb_asn.asn is defined as INT where it should be UNSIGNED INT.

barryo commented 4 years ago

Thanks for the detailed bug report @Edrichdelange - it certainly made finding, testing, fixing, testing the fix very easy.

For a quick fix, run the following SQL:

ALTER TABLE irrdb_asn CHANGE asn asn INT UNSIGNED NOT NULL

Doing this now without waiting for a release should not cause any issues later.