noxrepo / pox

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

nx_match doesn't take string as ipv6_dst #274

Closed Allamuth closed 1 year ago

Allamuth commented 2 years ago

After changing my code according the provided reference in issue #273. I add the following code snippet to to _handle_ConnectionUp in l2_nx_self_learning for testing:

msg = nx.nx_flow_mod()
msg.priority = 35000
msg.match.eth_type = 0x86dd
msg.match.ipv6_dst = 'fd97:a9a1:980f::d4e'  # or 'fd97:a9a1:980f::d4e/128'
msg.match.ip_proto = 17
msg.match.udp_dst = 90
event.connection.send(msg)

This leads to the following traceback when running ./pox.py log.level --DEBUG openflow.nicira forwarding.l2_nx_self_learning:

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_nx_self_learning_filtering.py", line 77, in _handle_ConnectionUp
    msg.match.ipv6_dst = 'fd97:a9a1:980f::d4e'
  File "/home/mininet/pox/pox/openflow/nicira.py", line 2760, in __setattr__
    entry.value = value
  File "/home/mininet/pox/pox/openflow/nicira.py", line 1837, in value
    self.mask = mask
  File "/home/mininet/pox/pox/openflow/nicira.py", line 2011, in mask
    self._mask = self._pack_mask(value)
  File "/home/mininet/pox/pox/openflow/nicira.py", line 1853, in _pack_mask
    return IPAddr6.from_num(n).raw
AttributeError: 'bytes' object has no attribute 'raw'

What is the format needed for specifying IPv6 Addresses as match? As this seems to be causing the error.

Pox branch is gar-experimental, git log last commit was 2020-05-20. This is the version shipped with the current VM provided by mininet.

MurphyMc commented 2 years ago

Thanks for the report. This was a regression introduced in the Python 3 port. It's been addressed in my fork: MurphyMc/pox@56939984363101912fb97f6a3ee3ff82c20b86c5

It should eventually find its way upstream.

If you don't want to patch your POX, you may be able to work your way around it by giving an explicit mask in string format. For an exact match, I think that'd be something like:

msg.match.ipv6_dst = ('fd97:a9a1:980f::d4e', 'ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff')

Allamuth commented 2 years ago

Thank you for your fast answer and the quick fix. For now I will be using your alternative solution without patching POX.

MurphyMc commented 1 year ago

Closed (fix is in halosaur).