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 know attribute dl_type #273

Closed Allamuth closed 2 years ago

Allamuth commented 2 years ago

Hello,

I'm currently trying to install a match using nx_flow_mod. I added the the following code snippet to _handle_ConnectionUp in l2_nx_self_learning for testing:

msg = nx.nx_flow_mod()
msg.table_id = 1
msg.priority = 35000
msg.match.dl_type = 0x86dd
msg.match.ipv6_dst = "fd97:a9a1:980f::d4e"
msg.match.nw_proto = 17
msg.match.tp_dst = 90
event.connection.send(msg)

When running ./pox.py log.level --DEBUG openflow.nicira forwarding.l2_nx_self_learning I get the following Traceback:

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.py", line 75, in _handle_ConnectionUp
    msg.match.dl_type = 0x0800
  File "/home/mininet/pox/pox/openflow/nicira.py", line 2726, in __setattr__
    raise AttributeError("No attribute " + name)
AttributeError: No attribute dl_type

I understand, that there are different names for attribute when using nx_match in contrast to ofp_match, but I fail to find the correct naming scheme for 'dl_type'. Could someone please explain briefly, if this is an error on my end and how to fix it, or if it is an issue with pox.

MurphyMc commented 2 years ago

The best reference for this is probably: http://www.openvswitch.org//support/dist-docs/ovs-fields.7.txt

Open vSwitch called this match "NXM_OF_ETH_TYPE". The NXM because it's using the Nicira extended match. The OF because it's also defined as part of OpenFlow (the type of match itself is not really a Nicira extension). IIRC, you can use that name, but POX also lets you drop the prefixes, so I think you can just use ".eth_type".

Allamuth commented 2 years ago

Thank you for your fast answer. After changing my code according the provided reference:

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:

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.

MurphyMc commented 2 years ago

Please file this as a new issue (and include the version of POX that you're using).