faucetsdn / faucet

FAUCET is an OpenFlow controller for multi table OpenFlow 1.3 switches, that implements layer 2 switching, VLANs, ACLs, and layer 3 IPv4 and IPv6 routing.
http://faucet.nz
Apache License 2.0
554 stars 190 forks source link

Unhandled exception when acl rule doesn't have a valid ipv4 address #1322

Closed mab68 closed 6 years ago

mab68 commented 6 years ago

Config:

acls:
    office-vlan-protect:
        - rule:
            dl_type: 0x800
            ipv4_src: 10.0.100.0/24
            ipv4_src: q0.0.200.0/24
vlans:
    office:
        vid: 100
        acl_in: office-vlan-protect
dps:
    sw1:
        dp_id: 0x1
        interfaces:
            1:
                native_vlan: office
                acl_in: access-port-protect

Error:

Dec 01 01:07:28 faucet.exception ERROR    Unhandled exception, killing RYU
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/netaddr/strategy/ipv4.py", line 125, in str_to_int
    return _struct.unpack('>I', _inet_pton(AF_INET, addr))[0]
OSError: illegal IP address string passed to inet_pton

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/netaddr/ip/__init__.py", line 311, in __init__
    self._value = self._module.str_to_int(addr, flags)
  File "/usr/lib/python3.6/site-packages/netaddr/strategy/ipv4.py", line 129, in str_to_int
    raise AddrFormatError('%r is not a valid IPv4 address string!' % addr)
netaddr.core.AddrFormatError: 'q0.0.200.0' is not a valid IPv4 address string!

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/netaddr/ip/__init__.py", line 791, in parse_ip_network
    ip = IPAddress(val1, module.version, flags=INET_PTON)
  File "/usr/lib/python3.6/site-packages/netaddr/ip/__init__.py", line 314, in __init__
    % (addr, self._module.version))
netaddr.core.AddrFormatError: base address 'q0.0.200.0' is not IPv4

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/netaddr/strategy/ipv4.py", line 263, in expand_partial_address
    tokens = ['%d' % int(o) for o in addr.split('.')]
  File "/usr/lib/python3.6/site-packages/netaddr/strategy/ipv4.py", line 263, in <listcomp>
    tokens = ['%d' % int(o) for o in addr.split('.')]
ValueError: invalid literal for int() with base 10: 'q0'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/netaddr/ip/__init__.py", line 928, in __init__
    implicit_prefix, flags)
  File "/usr/lib/python3.6/site-packages/netaddr/ip/__init__.py", line 795, in parse_ip_network
    expanded_addr = _ipv4.expand_partial_address(val1)
  File "/usr/lib/python3.6/site-packages/netaddr/strategy/ipv4.py", line 267, in expand_partial_address
    raise error
netaddr.core.AddrFormatError: invalid partial IPv4 address: 'q0.0.200.0'!

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/faucet/valve_util.py", line 34, in __koe
    func(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/faucet/faucet.py", line 198, in _load_configs
    new_config_hashes, new_dps = dp_parser(new_config_file, self.logname)
  File "/usr/lib/python3.6/site-packages/faucet/config_parser.py", line 51, in dp_parser
    config_hashes, dps = _config_parser_v2(config_file, logname)
  File "/usr/lib/python3.6/site-packages/faucet/config_parser.py", line 188, in _config_parser_v2
    top_confs['vlans'])
  File "/usr/lib/python3.6/site-packages/faucet/config_parser.py", line 162, in _dp_parser_v2
    dp.finalize_config(dps)
  File "/usr/lib/python3.6/site-packages/faucet/dp.py", line 560, in finalize_config
    resolve_acls()
  File "/usr/lib/python3.6/site-packages/faucet/dp.py", line 521, in resolve_acls
    build_acl(vlan.acl_in, vid=1)
  File "/usr/lib/python3.6/site-packages/faucet/dp.py", line 511, in build_acl
    vlan_vid=vid)
  File "/usr/lib/python3.6/site-packages/faucet/valve_acl.py", line 140, in build_acl_ofmsgs
    rule_conf, acl_allow_inst, meters, port_num, vlan_vid)
  File "/usr/lib/python3.6/site-packages/faucet/valve_acl.py", line 128, in build_acl_entry
    acl_match = valve_of.match_from_dict(match_dict)
  File "/usr/lib/python3.6/site-packages/faucet/valve_of.py", line 386, in match_from_dict
    value = convert[key](value)
  File "/usr/lib/python3.6/site-packages/ryu/lib/ofctl_utils.py", line 165, in to_match_ip
    ip = netaddr.ip.IPNetwork(value)
  File "/usr/lib/python3.6/site-packages/netaddr/ip/__init__.py", line 938, in __init__
    raise AddrFormatError('invalid IPNetwork %s' % addr)
netaddr.core.AddrFormatError: invalid IPNetwork q0.0.200.0/24
mab68 commented 6 years ago

ipv4_src: 10.0.200.0o24 Produces:

Dec 01 01:14:16 faucet.exception ERROR    Unhandled exception, killing RYU
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/netaddr/strategy/ipv4.py", line 127, in str_to_int
    return _struct.unpack('>I', _inet_aton(addr))[0]
OSError: illegal IP address string passed to inet_aton

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/netaddr/ip/__init__.py", line 311, in __init__
    self._value = self._module.str_to_int(addr, flags)
  File "/usr/lib/python3.6/site-packages/netaddr/strategy/ipv4.py", line 129, in str_to_int
    raise AddrFormatError('%r is not a valid IPv4 address string!' % addr)
netaddr.core.AddrFormatError: '10.0.200.0o24' is not a valid IPv4 address string!

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/ryu/lib/addrconv.py", line 29, in text_to_bin
    return self._addr(text, **self._addr_kwargs).packed
  File "/usr/lib/python3.6/site-packages/netaddr/ip/__init__.py", line 314, in __init__
    % (addr, self._module.version))
netaddr.core.AddrFormatError: base address '10.0.200.0o24' is not IPv4

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/netaddr/strategy/ipv4.py", line 125, in str_to_int
    return _struct.unpack('>I', _inet_pton(AF_INET, addr))[0]
OSError: illegal IP address string passed to inet_pton

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/netaddr/ip/__init__.py", line 311, in __init__
    self._value = self._module.str_to_int(addr, flags)
  File "/usr/lib/python3.6/site-packages/netaddr/strategy/ipv4.py", line 129, in str_to_int
    raise AddrFormatError('%r is not a valid IPv4 address string!' % addr)
netaddr.core.AddrFormatError: '10.0.200.0o24' is not a valid IPv4 address string!

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/netaddr/ip/__init__.py", line 791, in parse_ip_network
    ip = IPAddress(val1, module.version, flags=INET_PTON)
  File "/usr/lib/python3.6/site-packages/netaddr/ip/__init__.py", line 314, in __init__
    % (addr, self._module.version))
netaddr.core.AddrFormatError: base address '10.0.200.0o24' is not IPv4

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/netaddr/strategy/ipv4.py", line 263, in expand_partial_address
    tokens = ['%d' % int(o) for o in addr.split('.')]
  File "/usr/lib/python3.6/site-packages/netaddr/strategy/ipv4.py", line 263, in <listcomp>
    tokens = ['%d' % int(o) for o in addr.split('.')]
ValueError: invalid literal for int() with base 10: '0o24'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/faucet/valve_util.py", line 34, in __koe
    func(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/faucet/faucet.py", line 198, in _load_configs
    new_config_hashes, new_dps = dp_parser(new_config_file, self.logname)
  File "/usr/lib/python3.6/site-packages/faucet/config_parser.py", line 51, in dp_parser
    config_hashes, dps = _config_parser_v2(config_file, logname)
  File "/usr/lib/python3.6/site-packages/faucet/config_parser.py", line 188, in _config_parser_v2
    top_confs['vlans'])
  File "/usr/lib/python3.6/site-packages/faucet/config_parser.py", line 162, in _dp_parser_v2
    dp.finalize_config(dps)
  File "/usr/lib/python3.6/site-packages/faucet/dp.py", line 560, in finalize_config
    resolve_acls()
  File "/usr/lib/python3.6/site-packages/faucet/dp.py", line 521, in resolve_acls
    build_acl(vlan.acl_in, vid=1)
  File "/usr/lib/python3.6/site-packages/faucet/dp.py", line 511, in build_acl
    vlan_vid=vid)
  File "/usr/lib/python3.6/site-packages/faucet/valve_acl.py", line 140, in build_acl_ofmsgs
    rule_conf, acl_allow_inst, meters, port_num, vlan_vid)
  File "/usr/lib/python3.6/site-packages/faucet/valve_acl.py", line 128, in build_acl_entry
    acl_match = valve_of.match_from_dict(match_dict)
  File "/usr/lib/python3.6/site-packages/faucet/valve_of.py", line 398, in match_from_dict
    return parser.OFPMatch(**kwargs)
  File "/usr/lib/python3.6/site-packages/ryu/ofproto/ofproto_v1_3_parser.py", line 865, in __init__
    in kwargs.items()]
  File "/usr/lib/python3.6/site-packages/ryu/ofproto/ofproto_v1_3_parser.py", line 864, in <listcomp>
    fields = [ofproto.oxm_from_user(k, v) for (k, v)
  File "/usr/lib/python3.6/site-packages/ryu/ofproto/oxx_fields.py", line 72, in _from_user
    value = t.from_user(value)
  File "/usr/lib/python3.6/site-packages/ryu/lib/addrconv.py", line 36, in text_to_bin
    ip = self._fallback(text, **self._addr_kwargs)
  File "/usr/lib/python3.6/site-packages/netaddr/ip/__init__.py", line 916, in __init__
    implicit_prefix=implicit_prefix, flags=flags)
  File "/usr/lib/python3.6/site-packages/netaddr/ip/__init__.py", line 795, in parse_ip_network
    expanded_addr = _ipv4.expand_partial_address(val1)
  File "/usr/lib/python3.6/site-packages/netaddr/strategy/ipv4.py", line 267, in expand_partial_address
    raise error
netaddr.core.AddrFormatError: invalid partial IPv4 address: '10.0.200.0o24'!
anarkiwi commented 6 years ago

https://github.com/faucetsdn/faucet/commit/d606e9be245e643651a3e6574d4f14e29598c6ac