noxrepo / pox

The POX network software platform
https://noxrepo.github.io/pox-doc/html/
Apache License 2.0
619 stars 470 forks source link

ICMP error while processing packets #258

Closed cholcombe973 closed 3 years ago

cholcombe973 commented 3 years ago

I'm writing a firewall for a school project and encountered this error while testing it. It looks like the library is calling a function that doesn't exist.

ERROR:core:Exception while handling Connection!PacketIn...
Traceback (most recent call last):
  File "/home/mininet/pox/pox/lib/revent/revent.py", line 242, in raiseEventNoErrors
    return self.raiseEvent(event, *args, **kw)
  File "/home/mininet/pox/pox/lib/revent/revent.py", line 295, in raiseEvent
    rv = event._invoke(handler, *args, **kw)
  File "/home/mininet/pox/pox/lib/revent/revent.py", line 168, in _invoke
    return handler(self, *args, **kw)
  File "/home/mininet/pox/pox/forwarding/l2_learning.py", line 99, in _handle_PacketIn
    packet = event.parsed
  File "/home/mininet/pox/pox/openflow/__init__.py", line 193, in parsed
    return self.parse()
  File "/home/mininet/pox/pox/openflow/__init__.py", line 185, in parse
    self._parsed = ethernet(self.data)
  File "/home/mininet/pox/pox/lib/packet/ethernet.py", line 106, in __init__
    self.parse(raw)
  File "/home/mininet/pox/pox/lib/packet/ethernet.py", line 127, in parse
    self.next = ethernet.parse_next(self, self.type, raw, ethernet.MIN_LEN)
  File "/home/mininet/pox/pox/lib/packet/ethernet.py", line 134, in parse_next
    return parser(raw[offset:], prev)
  File "/home/mininet/pox/pox/lib/packet/ipv4.py", line 93, in __init__
    self.parse(raw)
  File "/home/mininet/pox/pox/lib/packet/ipv4.py", line 162, in parse
    self.next = icmp(raw=raw[self.hl*4:length], prev=self)
  File "/home/mininet/pox/pox/lib/packet/icmp.py", line 290, in __init__
    self.parse(raw)
  File "/home/mininet/pox/pox/lib/packet/icmp.py", line 315, in parse
    self.next = unreach(raw=raw[self.MIN_LEN:],prev=self)
  File "/home/mininet/pox/pox/lib/packet/icmp.py", line 221, in __init__
    self.parse(raw)
  File "/home/mininet/pox/pox/lib/packet/icmp.py", line 247, in parse
    self.next = ipv4.ipv4(raw=raw[unreach.MIN_LEN:],prev=self)
AttributeError: type object 'ipv4' has no attribute 'ipv4'
MurphyMc commented 3 years ago

Seems weird.

Can you post the POX log around startup time (which includes the POX and Python versions, for example)?

And, ideally, can you post a packet trace of packets which cause it? You could do this with Wireshark or tcpdump, or if you're using OpenFlow, I think the info.packet_dump module should do it.

cholcombe973 commented 3 years ago

It looks like this error was self inflicted.

POX 0.7.0 (gar) / Copyright 2011-2020 James McCauley, et al.
Starting POX Instance
Starting date and time : 2021-03-10 21:20:39

DEBUG:core:POX 0.7.0 (gar) going up...
DEBUG:core:Running on CPython (3.8.5/Jan 27 2021 15:41:15)
DEBUG:core:Platform is Linux-5.4.0-66-generic-x86_64-with-glibc2.29
WARNING:version:Support for Python 3 is experimental.
INFO:core:POX 0.7.0 (gar) is up.
DEBUG:openflow.of_01:Listening on 0.0.0.0:6633
INFO:openflow.of_01:[00-00-00-00-00-01 2] connected
DEBUG:forwarding.l2_learning:Connection [00-00-00-00-00-01 2]
ERROR:core:Exception while handling OpenFlowNexus!ConnectionUp...
Traceback (most recent call last):
  File "/home/mininet/pox/pox/lib/revent/revent.py", line 242, in raiseEventNoErrors
    return self.raiseEvent(event, *args, **kw)
  File "/home/mininet/pox/pox/lib/revent/revent.py", line 295, in raiseEvent
    rv = event._invoke(handler, *args, **kw)
  File "/home/mininet/pox/pox/lib/revent/revent.py", line 168, in _invoke
    return handler(self, *args, **kw)
  File "/home/mininet/pox/pox/firewall/setupfirewall.py", line 85, in _handle_ConnectionUp
    policies = process_configuration(policy_filename)
  File "/home/mininet/pox/pox/firewall/setupfirewall.py", line 55, in process_configuration
    raise TypeError("Invalid Format for Source IP Address for rulenum %s" % rule['rulenum'])
TypeError: Invalid Format for Source IP Address for rulenum 22
MurphyMc commented 3 years ago

Does that mean you've gotten it straightened out?

Given that you're running gar and I just recently wrote a strange piece of code entirely based on ICMP, I'd be super surprised if ICMP in gar is very broken (not that it's not possible). Offhand, my first guess is that there's some other module called ipv4.py besides POX's one, but that is harder to believe in Python 3.

All to say that I'd be interested in understanding what is/was going on here.

(Also the exception in the log you posted... is unrelated, right?)

cholcombe973 commented 3 years ago

Yup it's all straightened out. I wasn't supplying the ipv4 address properly to it.