faucetsdn / ryu

Ryu component-based software defined networking framework
https://ryu-sdn.org
Apache License 2.0
1.51k stars 1.16k forks source link

Error when adding flow entry #108

Open schneider8357 opened 4 years ago

schneider8357 commented 4 years ago

Hello,

I got an error upon adding a new flow entry via ofctl_rest, using different docker images for ryu (latarc/ryu and osrg/ryu):

Error traceback

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/eventlet/wsgi.py", line 573, in handle_one_response
    result = self.application(self.environ, start_response)
  File "/usr/local/lib/python3.8/site-packages/ryu/app/wsgi.py", line 236, in __call__
    return super(wsgify_hack, self).__call__(environ, start_response)
  File "/usr/local/lib/python3.8/site-packages/webob/dec.py", line 129, in __call__
    resp = self.call_func(req, *args, **kw)
  File "/usr/local/lib/python3.8/site-packages/webob/dec.py", line 193, in call_func
    return self.func(req, *args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/ryu/app/wsgi.py", line 290, in __call__
    return controller(req)
  File "/usr/local/lib/python3.8/site-packages/ryu/app/wsgi.py", line 160, in __call__
    return getattr(self, action)(req, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/ryu/app/ofctl_rest.py", line 276, in wrapper
    method(self, req, dp, ofctl, body, *args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/ryu/app/ofctl_rest.py", line 436, in mod_flow_entry
    ofctl.mod_flow_entry(dp, flow, mod_cmd)
  File "/usr/local/lib/python3.8/site-packages/ryu/lib/ofctl_v1_4.py", line 847, in mod_flow_entry
    ofctl_utils.send_msg(dp, flow_mod, LOG)
  File "/usr/local/lib/python3.8/site-packages/ryu/lib/ofctl_utils.py", line 242, in send_msg
    dp.send_msg(msg)
  File "/usr/local/lib/python3.8/site-packages/ryu/controller/controller.py", line 438, in send_msg
    msg.serialize()
  File "/usr/local/lib/python3.8/site-packages/ryu/ofproto/ofproto_parser.py", line 270, in serialize
    self._serialize_body()
  File "/usr/local/lib/python3.8/site-packages/ryu/ofproto/ofproto_v1_4_parser.py", line 4433, in _serialize_body
    inst.serialize(self.buf, offset)
  File "/usr/local/lib/python3.8/site-packages/ryu/ofproto/ofproto_v1_4_parser.py", line 4600, in serialize
    a.serialize(buf, action_offset)
  File "/usr/local/lib/python3.8/site-packages/ryu/ofproto/ofproto_v1_4_parser.py", line 4709, in serialize
    msg_pack_into(ofproto.OFP_ACTION_OUTPUT_PACK_STR, buf,
  File "/usr/local/lib/python3.8/site-packages/ryu/lib/pack_utils.py", line 25, in msg_pack_into
    struct.pack_into(fmt, buf, offset, *args)
struct.error: required argument is not an integer

When debugging with curl, I found out that the problem was in the port field of the actions of the flow entry, as shown below:

No zero padding on osrg/ryu gives me a HTTP 200. With zero padding on osrg/ryu gives me a HTTP 200. No zero padding on latarc/ryu gives me a HTTP 200. With zero padding on latarc/ryu gives me a HTTP 400 and an error.

The curl commands and respective output are as follow:

Not zero padded port value on v4.31

curl -v -d '{ "dpid": "1", "idle_timeout": 30, "hard_timeout": 30,  "instructions": [  { "type": "APPLY_ACTIONS", "actions": [ { "max_len": 65535, "port": "3", "type": "OUTPUT" } ] } ] }' http://172.17.0.4:8080/stats/flowentry/add
*   Trying 172.17.0.4:8080...
* TCP_NODELAY set
* Connected to 172.17.0.4 (172.17.0.4) port 8080 (#0)
> POST /stats/flowentry/add HTTP/1.1
> Host: 172.17.0.4:8080
> User-Agent: curl/7.68.0
> Accept: */*
> Content-Length: 174
> Content-Type: application/x-www-form-urlencoded
> 
* upload completely sent off: 174 out of 174 bytes
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Content-Type: text/html; charset=UTF-8
< Content-Length: 0
< Date: Sat, 22 Aug 2020 04:49:14 GMT
< 
* Connection #0 to host 172.17.0.4 left intact

Zero padded port value on v4.31

curl -v -d '{ "dpid": "1", "idle_timeout": 30, "hard_timeout": 30,  "instructions": [  { "type": "APPLY_ACTIONS", "actions": [ { "max_len": 65535, "port": "000003", "type": "OUTPUT" } ] } ] }' http://172.17.0.4:8080/stats/flowentry/add
*   Trying 172.17.0.4:8080...
* TCP_NODELAY set
* Connected to 172.17.0.4 (172.17.0.4) port 8080 (#0)
> POST /stats/flowentry/add HTTP/1.1
> Host: 172.17.0.4:8080
> User-Agent: curl/7.68.0
> Accept: */*
> Content-Length: 179
> Content-Type: application/x-www-form-urlencoded
> 
* upload completely sent off: 179 out of 179 bytes
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Content-Type: text/html; charset=UTF-8
< Content-Length: 0
< Date: Sat, 22 Aug 2020 04:49:19 GMT
< 
* Connection #0 to host 172.17.0.4 left intact

Not zero padded port value on v4.34

curl -v -d '{ "dpid": "1", "idle_timeout": 30, "hard_timeout": 30,  "instructions": [  { "type": "APPLY_ACTIONS", "actions": [ { "max_len": 65535, "port": "3", "type": "OUTPUT" } ] } ] }' http://172.17.0.3:8080/stats/flowentry/add   
*   Trying 172.17.0.3:8080...
* TCP_NODELAY set
* Connected to 172.17.0.3 (172.17.0.3) port 8080 (#0)
> POST /stats/flowentry/add HTTP/1.1
> Host: 172.17.0.3:8080
> User-Agent: curl/7.68.0
> Accept: */*
> Content-Length: 174
> Content-Type: application/x-www-form-urlencoded
> 
* upload completely sent off: 174 out of 174 bytes
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Content-Type: text/html; charset=UTF-8
< Content-Length: 0
< Date: Sat, 22 Aug 2020 04:53:59 GMT
< 
* Connection #0 to host 172.17.0.3 left intact

Zero padded port value on v4.34 with traceback

curl -v -d '{ "dpid": "1", "idle_timeout": 30, "hard_timeout": 30,  "instructions": [  { "type": "APPLY_ACTIONS", "actions": [ { "max_len": 65535, "port": "000003", "type": "OUTPUT" } ] } ] }' http://172.17.0.3:8080/stats/flowentry/add
*   Trying 172.17.0.3:8080...
* TCP_NODELAY set
* Connected to 172.17.0.3 (172.17.0.3) port 8080 (#0)
> POST /stats/flowentry/add HTTP/1.1
> Host: 172.17.0.3:8080
> User-Agent: curl/7.68.0
> Accept: */*
> Content-Length: 179
> Content-Type: application/x-www-form-urlencoded
> 
* upload completely sent off: 179 out of 179 bytes
* Mark bundle as not supporting multiuse
< HTTP/1.1 500 Internal Server Error
< Content-Type: text/plain
< Content-Length: 2309
< Date: Sat, 22 Aug 2020 04:53:38 GMT
< Connection: close
< 
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/eventlet/wsgi.py", line 573, in handle_one_response
    result = self.application(self.environ, start_response)
  File "/usr/local/lib/python3.8/site-packages/ryu/app/wsgi.py", line 236, in __call__
    return super(wsgify_hack, self).__call__(environ, start_response)
  File "/usr/local/lib/python3.8/site-packages/webob/dec.py", line 129, in __call__
    resp = self.call_func(req, *args, **kw)
  File "/usr/local/lib/python3.8/site-packages/webob/dec.py", line 193, in call_func
    return self.func(req, *args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/ryu/app/wsgi.py", line 290, in __call__
    return controller(req)
  File "/usr/local/lib/python3.8/site-packages/ryu/app/wsgi.py", line 160, in __call__
    return getattr(self, action)(req, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/ryu/app/ofctl_rest.py", line 276, in wrapper
    method(self, req, dp, ofctl, body, *args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/ryu/app/ofctl_rest.py", line 436, in mod_flow_entry
    ofctl.mod_flow_entry(dp, flow, mod_cmd)
  File "/usr/local/lib/python3.8/site-packages/ryu/lib/ofctl_v1_4.py", line 847, in mod_flow_entry
    ofctl_utils.send_msg(dp, flow_mod, LOG)
  File "/usr/local/lib/python3.8/site-packages/ryu/lib/ofctl_utils.py", line 242, in send_msg
    dp.send_msg(msg)
  File "/usr/local/lib/python3.8/site-packages/ryu/controller/controller.py", line 438, in send_msg
    msg.serialize()
  File "/usr/local/lib/python3.8/site-packages/ryu/ofproto/ofproto_parser.py", line 270, in serialize
    self._serialize_body()
  File "/usr/local/lib/python3.8/site-packages/ryu/ofproto/ofproto_v1_4_parser.py", line 4433, in _serialize_body
    inst.serialize(self.buf, offset)
  File "/usr/local/lib/python3.8/site-packages/ryu/ofproto/ofproto_v1_4_parser.py", line 4600, in serialize
    a.serialize(buf, action_offset)
  File "/usr/local/lib/python3.8/site-packages/ryu/ofproto/ofproto_v1_4_parser.py", line 4709, in serialize
    msg_pack_into(ofproto.OFP_ACTION_OUTPUT_PACK_STR, buf,
  File "/usr/local/lib/python3.8/site-packages/ryu/lib/pack_utils.py", line 25, in msg_pack_into
    struct.pack_into(fmt, buf, offset, *args)
struct.error: required argument is not an integer
* Closing connection 0

I am not certain if this is intended behavior, but I'm still reporting this as an issue, mainly because legacy code using this format may break upon updating Ryu to a newer version and maybe it is preferred to maximize compatibility.

Regards, Lucas Schneider