So there's an assert in there that checks for value being None... running 
pox.py instead of debug-pox.py with CPython has assertions disabled, so this 
didn't trip for you.

I think I actually do want this assertion in there -- it's what catches the 
programming error when a value for an nxm entry doesn't get set.  So rather 
than have None mean "header only", like your patch, I suggest the following 
(untested) patch, which basically just makes packing just the header part of 
the API for pack().

We could try to force the value to something arbitrary (it ends up getting 
chopped off anyway), but we can't do that without constraining how subclasses 
store/manipulate the value... this might be fine, but I'd rather not do it if 
we don't have to.  I think this is actually briefly how it worked and I 
apparently removed it and then didn't fix the problem that caused.

Thoughts?

This will require the corresponding change to your move patch.

-- Murphy

Attachment: nxm_header_only.diff
Description: Binary data


On Mar 5, 2013, at 12:57 PM, Saul St. John wrote:

> I might be missing something here, but this (correct?) code:
> 
>    msg = nx.nx_flow_mod()
>    action = nx.nx_reg_load()
>    action.dst = nx.NXM_NX_REG0
>    action.nbits = 32
>    action.value = 0xdeadbeef
>    msg.actions.append(action)
>    connection.send(msg)
> 
> gives me this error:
> 
>    ERROR:core:Exception while handling OpenFlowNexus!ConnectionUp...
>    Traceback (most recent call last):
>      File "/src/pox/pox/lib/revent/revent.py", line 234, in raiseEventNoErrors
>        return self.raiseEvent(event, *args, **kw)
>      File "/src/pox/pox/lib/revent/revent.py", line 281, in raiseEvent
>        rv = event._invoke(handler, *args, **kw)
>      File "/src/pox/pox/lib/revent/revent.py", line 159, in _invoke
>        return handler(self, *args, **kw)
>      File "/src/pox/ext/werk.py", line 68, in start_switch
>        SwitchWerker(event.connection)
>      File "/src/pox/ext/werk.py", line 27, in __init__
>        connection.send(msg)
>      File "/src/pox/pox/openflow/of_01.py", line 687, in send
>        data = data.pack()
>      File "/src/pox/pox/openflow/nicira.py", line 403, in pack
>        packed += i.pack()
>      File "/src/pox/pox/openflow/libopenflow_01.py", line 1958, in pack
>        body = self._pack_body()
>      File "/src/pox/pox/openflow/nicira.py", line 510, in _pack_body
>        dst = o.pack(omittable=False)[:4]
>      File "/src/pox/pox/openflow/nicira.py", line 911, in pack
>        r += value
>    TypeError: cannot concatenate 'str' and 'NoneType' objects
> 
> without this patch:
> 
> Signed-off-by: Saul St. John <[email protected]>
> ---
> pox/openflow/nicira.py |    7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/pox/openflow/nicira.py b/pox/openflow/nicira.py
> index 35499a3..8c86206 100644
> --- a/pox/openflow/nicira.py
> +++ b/pox/openflow/nicira.py
> @@ -905,10 +905,11 @@ class nxm_entry (object):
>     r = struct.pack("!L", h)
> 
>     value = self._value
> -    assert value is not None
> -    assert len(value) == self._nxm_length, "value is wrong length"
> 
> -    r += value
> +    if value is not None:
> +        assert len(value) == self._nxm_length, "value is wrong length"
> +        r += value
> +    
>     if mask is not None:
>       assert 0 == sum(ord(v)&(0xff&~ord(m)) for v,m in zip(value,mask)), \
>              "nonzero masked bits"
> -- 
> 1.7.10.4
> 

Reply via email to