beba-eu / beba-switch

BEBA Software Switch implementation
http://www.beba-project.eu
15 stars 12 forks source link

Too short ofp_header #34

Closed benycze closed 7 years ago

benycze commented 7 years ago

Hello, I have found a behavior which seems to be a bug. So far, I suppose that it is a bug in beba-switch but it could be also a bug in beba-ctrl (or it could be a combination of both). However, the controller application is not working when the bug appears.

The following steps reproduce it: 1) Compile the switch (bash -x ./compile_switch.sh; the latest version in the time of compilation was f96b386eeb7bb47148e15eca2b4a791b657c84f2) 2) Run the ofdatapath: ofdatapath -i vs1-to-h1,vs1-to-vs2,lo -d 000000000001 punix:/var/run/sock 4) Install the controller (fork https://github.com/reboz86/beba-ctrl/, branch merged_DDoS, the latest version in the time of the instalation was 6bf6446b07abbdb8b6583e5e34b453c78c48f884) 5) Run the merged DDoS ryu-manager ryu/app/beba/merged_DDoS 6) Run the ofprotocol: ofprotocol unix:/var/run/sock tcp:10.0.0.2:6633 7) The following should be displayed on the controller:

loading app ryu/app/beba/merged_ddos.py
loading app ryu.controller.ofp_handler
instantiating app ryu/app/beba/merged_ddos.py of MergedDdosMitigation
Starting DDoS detection ...
instantiating app ryu.controller.ofp_handler of OFPHandler
Sleeping for 5 seconds..
Sleeping for 5 seconds..
Sleeping for 5 seconds..
Sleeping for 5 seconds..
Configuring switch 1...
Setting up Table 0 ...
Setting up Table 1 ...
Setting up Table 2 ...
Setting up Table 3 ...
Setting up Table 4 ...
Setting up Table 5 ...
Setting up Table 6 ...
Setting up Table 7 ...
Done
Setting up Table 8 ...
Loading Normal mode Table 6 (MATCH) on datapath 1.
Done.
Loading Normal mode Table 7 (SYN counter) for datapath 1.
1
1487599459 20.02. 15:04:19 Requested stats to switch 1
Sleeping for 5 seconds..
1487599459 20.02. 15:04:19 New flow count for switch 1 is 0

8) Replay the test traffic to the vs1-to-h1 interface (connection of the switch and virtual host machine). You can use following command: tcpreplay -h -i vs1-to-h1 -l 1000 -t *.pcap. I provide you all used pcap files via email.

The following was reported by controller:

Encounter an error during parsing OpenFlow packet from switch.This implies switch sending a malformed OpenFlow packet.version 0x04 msg_type 19 msg_len 8 xid 404071800 buf 0x04 0x13 0x00 0x08 0x18 0x15 0xa5 0x78
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/ryu/ofproto/ofproto_parser.py", line 63, in msg
    return msg_parser(datapath, version, msg_type, msg_len, xid, buf)
  File "/usr/local/lib/python2.7/dist-packages/ryu/ofproto/ofproto_v1_3_parser.py", line 80, in msg_parser
    return parser(datapath, version, msg_type, msg_len, xid, buf)
  File "/usr/local/lib/python2.7/dist-packages/ryu/ofproto/ofproto_v1_3_parser.py", line 3790, in parser
    ofproto.OFP_HEADER_SIZE)
error: unpack_from requires a buffer of at least 8 bytes

This is reported by ofprotocol:

Feb 20 15:25:26|00117|vconn_stream|ERR|received too-short ofp_header (0 bytes)
Feb 20 15:25:26|00118|rconn|WARN|unix:/var/run/sock: connection dropped (Protocol error)
Feb 20 15:25:27|00119|rconn|INFO|unix:/var/run/sock: connecting...
Feb 20 15:25:27|00120|rconn|INFO|unix:/var/run/sock: connected

The following is reported by ofdatapath:

Feb 20 15:29:36|00176|dp_exp|WARN|Trying to execute unknown experimenter action (3199909562)

The following message is not reported during tcpreplay of traffic but it is reported during testing with live data:

Error in the datapath 0000000000000001 from ('10.0.0.202', 47192)
hub: uncaught exception: Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/ryu/lib/hub.py", line 52, in _launch
    func(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/ryu/controller/controller.py", line 345, in datapath_connection_factory
    datapath.serve()
  File "/usr/local/lib/python2.7/dist-packages/ryu/controller/controller.py", line 265, in serve
    self._recv_loop()
  File "/usr/local/lib/python2.7/dist-packages/ryu/controller/controller.py", line 104, in deactivate
    method(self)
  File "/usr/local/lib/python2.7/dist-packages/ryu/controller/controller.py", line 193, in _recv_loop
    self, version, msg_type, msg_len, xid, buf[:msg_len])
  File "/usr/local/lib/python2.7/dist-packages/ryu/ofproto/ofproto_parser.py", line 60, in msg
    raise exception.OFPUnknownVersion(version=version)
OFPUnknownVersion: unknown version 80 

Everything seems to be quite fine when the input traffic slows down.

DavideSanvito commented 7 years ago

Hi Pavel, we provided a fix for the warning ("Trying to execute unknown experimenter action") which seems to be a false positive. Can you confirm the message is not showed anymore in the log? Exceptions on the controller are not raised by code from BEBA extension: it seems the switch is sending out malformed packets, so I'd exclude the controller side. We are now investigating code portions related to the encapsulation of packets towards the controller. Best, Davide

benycze commented 7 years ago

Hi Davide, the warning is not showed anymore in the log. Thanks!