svinota / pyroute2

Python Netlink and PF_ROUTE library — network configuration and monitoring
https://pyroute2.org/
Other
959 stars 249 forks source link

NDB: 'NoneType' object does not support item assignment #823

Closed dulek closed 2 years ago

dulek commented 3 years ago

Trying to convert IPDB code to use NDB I started to see following exceptions happening:

2021-07-06 08:18:44.418 173 ERROR pyroute2.ndb.140281246630856.main [-] could not load event:                                                                                                  
{'family': 0, '__align': (), 'ifi_type': 1, 'index': 86, 'flags': 69699, 'change': 0, 'attrs': [('IFLA_IFNAME', 'tapb660404b-2d'), ('IFLA_TXQLEN', 1000), ('IFLA_OPERSTATE', 'UNKNOWN'), ('IFLA
_LINKMODE', 0), ('IFLA_MTU', 1442), ('IFLA_GROUP', 0), ('IFLA_PROMISCUITY', 1), ('IFLA_NUM_TX_QUEUES', 1), ('IFLA_GSO_MAX_SEGS', 65535), ('IFLA_GSO_MAX_SIZE', 65536), ('IFLA_NUM_RX_QUEUES', 1
), ('IFLA_MASTER', 24), ('IFLA_CARRIER', 1), ('IFLA_QDISC', 'fq_codel'), ('IFLA_CARRIER_CHANGES', 0), ('IFLA_PROTO_DOWN', 0), ('IFLA_CARRIER_UP_COUNT', 0), ('IFLA_CARRIER_DOWN_COUNT', 0), ('I
FLA_MAP', {'mem_start': 0, 'mem_end': 0, 'base_addr': 0, 'irq': 0, 'dma': 0, 'port': 0}), ('IFLA_ADDRESS', 'fe:16:3e:ef:f7:33'), ('IFLA_BROADCAST', 'ff:ff:ff:ff:ff:ff'), ('IFLA_STATS64', {'rx
_packets': 76977282, 'tx_packets': 83181677, 'rx_bytes': 50071951590, 'tx_bytes': 50468010005, 'rx_errors': 0, 'tx_errors': 0, 'rx_dropped': 0, 'tx_dropped': 0, 'multicast': 0, 'collisions': 
0, 'rx_length_errors': 0, 'rx_over_errors': 0, 'rx_crc_errors': 0, 'rx_frame_errors': 0, 'rx_fifo_errors': 0, 'rx_missed_errors': 0, 'tx_aborted_errors': 0, 'tx_carrier_errors': 0, 'tx_fifo_e
rrors': 0, 'tx_heartbeat_errors': 0, 'tx_window_errors': 0, 'rx_compressed': 0, 'tx_compressed': 0}), ('IFLA_STATS', {'rx_packets': 76977282, 'tx_packets': 83181677, 'rx_bytes': 2827311334, '
tx_bytes': 3223369749, 'rx_errors': 0, 'tx_errors': 0, 'rx_dropped': 0, 'tx_dropped': 0, 'multicast': 0, 'collisions': 0, 'rx_length_errors': 0, 'rx_over_errors': 0, 'rx_crc_errors': 0, 'rx_f
rame_errors': 0, 'rx_fifo_errors': 0, 'rx_missed_errors': 0, 'tx_aborted_errors': 0, 'tx_carrier_errors': 0, 'tx_fifo_errors': 0, 'tx_heartbeat_errors': 0, 'tx_window_errors': 0, 'rx_compress
ed': 0, 'tx_compressed': 0}), ('IFLA_XDP', '05:00:02:00:00:00:00:00'), ('IFLA_LINKINFO', {'attrs': [('IFLA_INFO_KIND', 'tun'), ('IFLA_INFO_SLAVE_KIND', 'openvswitch')]}), ('IFLA_AF_SPEC', {'a
ttrs': [('AF_INET', {'dummy': 65664, 'forwarding': 1, 'mc_forwarding': 0, 'proxy_arp': 0, 'accept_redirects': 1, 'secure_redirects': 1, 'send_redirects': 1, 'shared_media': 1, 'rp_filter': 1,
 'accept_source_route': 1, 'bootp_relay': 0, 'log_martians': 0, 'tag': 0, 'arpfilter': 0, 'medium_id': 0, 'noxfrm': 0, 'nopolicy': 0, 'force_igmp_version': 0, 'arp_announce': 0, 'arp_ignore':
 0, 'promote_secondaries': 0, 'arp_accept': 0, 'arp_notify': 0, 'accept_local': 0, 'src_vmark': 0, 'proxy_arp_pvlan': 0, 'route_localnet': 0, 'igmpv2_unsolicited_report_interval': 10000, 'igm
pv3_unsolicited_report_interval': 1000}), ('AF_INET6', {'attrs': [('IFLA_INET6_FLAGS', 2147483664), ('IFLA_INET6_CACHEINFO', {'max_reasm_len': 65535, 'tstamp': 179735790, 'reachable_time': 38
376, 'retrans_time': 1000}), ('IFLA_INET6_CONF', {'forwarding': 0, 'hop_limit': 64, 'mtu': 1442, 'accept_ra': 1, 'accept_redirects': 1, 'autoconf': 1, 'dad_transmits': 1, 'router_solicitation
s': 4294967295, 'router_solicitation_interval': 4000, 'router_solicitation_delay': 1000, 'use_tempaddr': 0, 'temp_valid_lft': 604800, 'temp_preferred_lft': 86400, 'regen_max_retry': 3, 'max_d
esync_factor': 600, 'max_addresses': 16, 'force_mld_version': 0, 'accept_ra_defrtr': 1, 'accept_ra_pinfo': 1, 'accept_ra_rtr_pref': 1, 'router_probe_interval': 60000, 'accept_ra_rt_info_max_p
len': 0, 'proxy_ndp': 0, 'optimistic_dad': 0, 'accept_source_route': 0, 'mc_forwarding': 0, 'disable_ipv6': 0, 'accept_dad': 1, 'force_tllao': 0, 'ndisc_notify': 0}), ('IFLA_INET6_STATS', {'n
um': 37, 'inpkts': 0, 'inoctets': 0, 'indelivers': 0, 'outforwdatagrams': 0, 'outpkts': 1918, 'outoctets': 107504, 'inhdrerrors': 0, 'intoobigerrors': 0, 'innoroutes': 0, 'inaddrerrors': 0, '
inunknownprotos': 0, 'intruncatedpkts': 0, 'indiscards': 0, 'outdiscards': 0, 'outnoroutes': 0, 'reasmtimeout': 0, 'reasmreqds': 0, 'reasmoks': 0, 'reasmfails': 0, 'fragoks': 0, 'fragfails': 
0, 'fragcreates': 0, 'inmcastpkts': 0, 'outmcastpkts': 1918, 'inbcastpkts': 0, 'outbcastpkts': 0, 'inmcastoctets': 0, 'outmcastoctets': 107504, 'inbcastoctets': 0, 'outbcastoctets': 0, 'csume
rrors': 0, 'noectpkts': 0, 'ect1pkts': 0, 'ect0pkts': 0, 'cepkts': 0}), ('IFLA_INET6_ICMP6STATS', {'num': 6, 'inmsgs': 0, 'inerrors': 0, 'outmsgs': 1918, 'outerrors': 0, 'csumerrors': 0}), ('
IFLA_INET6_TOKEN', '::'), ('IFLA_INET6_ADDR_GEN_MODE', 0)]})]})], 'header': {'length': 1348, 'type': 16, 'flags': 2, 'sequence_number': 255, 'pid': 4052996555, 'error': None, 'target': 'local
host', 'stats': Stats(qsize=0, delta=0, delay=0)}, 'state': 'up', 'event': 'RTM_NEWLINK'}                                                                                                      
Traceback (most recent call last):                                                                                                                                                             
  File "/usr/local/lib/python3.6/site-packages/pr2modules/ndb/main.py", line 1211, in __dbm__                                                                                                  
    handler(target, event)                                                                                                                                                                     
  File "/usr/local/lib/python3.6/site-packages/pr2modules/ndb/objects/interface.py", line 186, in load_ifinfmsg                                                                                
    ifdata['header'] = {}                                                                                                                                                                      
TypeError: 'NoneType' object does not support item assignment
dulek commented 3 years ago

This is happening with 0.6.4:

[root@mdulko-devstack-ovnvm-0 /]# pip freeze | grep pyroute2
pyroute2==0.6.4
pyroute2.core==0.6.4
pyroute2.ethtool==0.6.4
pyroute2.ipdb==0.6.4
pyroute2.ipset==0.6.4
pyroute2.ndb==0.6.4
pyroute2.nftables==0.6.4
pyroute2.nslink==0.6.4