{"action":"closed","issue":{"url":"https://api.github.com/repos/ngn-colorado/yanc/issues/1","repository_url":"https://api.github.com/repos/ngn-colorado/yanc","labels_url":"https://api.github.com/repos/ngn-colorado/yanc/issues/1/labels{/name}","comments_url":"https://api.github.com/repos/ngn-colorado/yanc/issues/1/comments","events_url":"https://api.github.com/repos/ngn-colorado/yanc/issues/1/events","html_url":"https://github.com/ngn-colorado/yanc/issues/1","id":134527519,"number":1,"title":"Encountered a bug related to change in OpenFlow version","user":{"login":"sohilladhani","id":2020729,"avatar_url":"https://avatars.githubusercontent.com/u/2020729?v=3","gravatar_id":"","url":"https://api.github.com/users/sohilladhani","html_url":"https://github.com/sohilladhani","followers_url":"https://api.github.com/users/sohilladhani/followers","following_url":"https://api.github.com/users/sohilladhani/following{/other_user}","gists_url":"https://api.github.com/users/sohilladhani/gists{/gist_id}","starred_url":"https://api.github.com/users/sohilladhani/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sohilladhani/subscriptions","organizations_url":"https://api.github.com/users/sohilladhani/orgs","repos_url":"https://api.github.com/users/sohilladhani/repos","events_url":"https://api.github.com/users/sohilladhani/events{/privacy}","received_events_url":"https://api.github.com/users/sohilladhani/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-02-18T09:34:00Z","updated_at":"2016-02-22T16:54:21Z","closed_at":"2016-02-22T16:54:21Z","body":"Bug description:\r\n\r\nWhile working with the current code of yanc-of-adapter, I encountered a segmentation fault. I created 2 hosts and an OpenFlow switch under mininet. While analyzing using 'valgrind', I found memory errors pointing to the method OFSwitch::handle_packet_in in the file of_switch.cc. Upon further analysis I found that it is related to the difference between the packet_in size used in OpenFlow 1.0 v/s OpenFlow 1.1. Size of packet_in is 24 bytes in OpenFlow 1.1 as opposed to 20 bytes in OpenFlow 1.0. \r\n\r\nI have proposed a file change for of_switch.cc. My fix contains adding 4 bytes to the packet length in of_switch.cc.\r\n\r\nBelow is a part of valgrind report I got:\r\n\r\n_\r\n\r\n> ==6001== Memcheck, a memory error detector\r\n> ==6001== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.\r\n> ==6001== Using Valgrind-3.10.1 and LibVEX; rerun with -h for copyright info\r\n> ==6001== Command: yanc-of-adapter /net unix:path=/var/run/dbus/system_bus_socket -vvv\r\n> ==6001== \r\n> YancOFAdapter [INFO]:  started with pid/6001\r\n> YancOFAdapter [INFO]:  fd/4 listening on tcp:0.0.0.0:6633\r\n> YancOFAdapter [INFO]:  fd/5 dbus connection established: unix:path=/var/run/dbus/system_bus_socket\r\n> YancOFAdapter [DEBUG]: RX SIGNAL AdapterStarted\r\n> YancOFAdapter [INFO]:  fd/6 new connection StreamConnection(127.0.0.1:54405)\r\n> YancOFAdapter [ERROR]: received 0 of ofp_packet_header. Closing connection.\r\n> YancOFAdapter [INFO]:  fd/6 new connection StreamConnection(127.0.0.1:54406)\r\n> OFNetwork INFO received HELLO from StreamConnection(127.0.0.1:54406)\r\n> OFSwitch [INFO]: FEATURES_REPLY /net/switches/s1, OFP_VERSION=0x1, DPID=0x1\r\n> \r\n> ==6001== Invalid write of size 2\r\n> ==6001==    at 0x4C3090B: memcpy@@GLIBC_2.14 (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)\r\n> ==6001==    by 0x40D505: ofp11_packet_in_from_ofp_packet_in(ofp_packet_in const&, ofp11_packet_in&) (openflow_tools.cc:233)\r\n> ==6001==    by 0x411036: OFSwitch::handle_packet_in(unsigned char, ofp_packet_in const&) (of_switch.cc:130)\r\n> ==6001==    by 0x40DB21: OFNetwork::handle_message(om::net::StreamConnection&, ofp_header&) (of_network.cc:124)\r\n> ==6001==    by 0x405BFA: YancOFAdapter::receive_data(om::net::StreamConnection*) (yanc_of_adapter.cc:164)\r\n> ==6001==    by 0x40B557: void std::_Mem_fn<void (YancOFAdapter::*)(om::net::StreamConnection*)>::operator()<om::net::StreamConnection*, void>(YancOFAdapter*, om::net::StreamConnection*&&) const (in /home/sohil/Softwares/yanc/apps/of-adapter/yanc-of-adapter)\r\n> ==6001==    by 0x40A6D7: void std::_Bind<std::_Mem_fn<void (YancOFAdapter::*)(om::net::StreamConnection*)> (YancOFAdapter*, std::_Placeholder<1>)>::__call<void, om::net::StreamConnection*&&, 0ul, 1ul>(std::tuple<om::net::StreamConnection*&&>&&, std::_Index_tuple<0ul, 1ul>) (functional:1264)\r\n> ==6001==    by 0x40933B: void std::_Bind<std::_Mem_fn<void (YancOFAdapter::*)(om::net::StreamConnection*)> (YancOFAdapter*, std::_Placeholder<1>)>::operator()<om::net::StreamConnection*, void>(om::net::StreamConnection*&&) (functional:1323)\r\n> ==6001==    by 0x408444: std::_Function_handler<void (om::net::StreamConnection*), std::_Bind<std::_Mem_fn<void (YancOFAdapter::*)(om::net::StreamConnection*)> (YancOFAdapter*, std::_Placeholder<1>)> >::_M_invoke(std::_Any_data const&, om::net::StreamConnection*) (functional:2039)\r\n> ==6001==    by 0x425B46: std::function<void (om::net::StreamConnection*)>::operator()(om::net::StreamConnection*) const (in /home/sohil/Softwares/yanc/apps/of-adapter/yanc-of-adapter)\r\n> ==6001==    by 0x4254A4: om::net::StreamConnection::ready() (in /home/sohil/Softwares/yanc/apps/of-adapter/yanc-of-adapter)\r\n> ==6001==    by 0x42A30D: om::async::EPollWrapper::dispatch() (in /home/sohil/Softwares/yanc/apps/of-adapter/yanc-of-adapter)\r\n> \r\n> ==6001==  Address 0x5f1d4c0 is 0 bytes after a block of size 96 alloc'd\r\n> ==6001==    at 0x4C2C820: operator new[](unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)\r\n> ==6001==    by 0x41101F: OFSwitch::handle_packet_in(unsigned char, ofp_packet_in const&) (of_switch.cc:128)\r\n> ==6001==    by 0x40DB21: OFNetwork::handle_message(om::net::StreamConnection&, ofp_header&) (of_network.cc:124)\r\n> ==6001==    by 0x405BFA: YancOFAdapter::receive_data(om::net::StreamConnection*) (yanc_of_adapter.cc:164)\r\n> ==6001==    by 0x40B557: void std::_Mem_fn<void (YancOFAdapter::*)(om::net::StreamConnection*)>::operator()<om::net::StreamConnection*, void>(YancOFAdapter*, om::net::StreamConnection*&&) const (in /home/sohil/Softwares/yanc/apps/of-adapter/yanc-of-adapter)\r\n> ==6001==    by 0x40A6D7: void std::_Bind<std::_Mem_fn<void (YancOFAdapter::*)(om::net::StreamConnection*)> (YancOFAdapter*, std::_Placeholder<1>)>::__call<void, om::net::StreamConnection*&&, 0ul, 1ul>(std::tuple<om::net::StreamConnection*&&>&&, std::_Index_tuple<0ul, 1ul>) (functional:1264)\r\n> ==6001==    by 0x40933B: void std::_Bind<std::_Mem_fn<void (YancOFAdapter::*)(om::net::StreamConnection*)> (YancOFAdapter*, std::_Placeholder<1>)>::operator()<om::net::StreamConnection*, void>(om::net::StreamConnection*&&) (functional:1323)\r\n> ==6001==    by 0x408444: std::_Function_handler<void (om::net::StreamConnection*), std::_Bind<std::_Mem_fn<void (YancOFAdapter::*)(om::net::StreamConnection*)> (YancOFAdapter*, std::_Placeholder<1>)> >::_M_invoke(std::_Any_data const&, om::net::StreamConnection*) (functional:2039)\r\n> ==6001==    by 0x425B46: std::function<void (om::net::StreamConnection*)>::operator()(om::net::StreamConnection*) const (in /home/sohil/Softwares/yanc/apps/of-adapter/yanc-of-adapter)\r\n> ==6001==    by 0x4254A4: om::net::StreamConnection::ready() (in /home/sohil/Softwares/yanc/apps/of-adapter/yanc-of-adapter)\r\n> ==6001==    by 0x42A30D: om::async::EPollWrapper::dispatch() (in /home/sohil/Softwares/yanc/apps/of-adapter/yanc-of-adapter)\r\n> ==6001==    by 0x40645B: YancOFAdapter::run() (yanc_of_adapter.cc:268)\r\n> ==6001== \r\n> OFSwitch[/net/switches/s1] DEBUG received PACKET_IN on port 1 for NO_MATCH\r\n> ==6001== Invalid read of size 2\r\n> ==6001==    at 0x4C30908: memcpy@@GLIBC_2.14 (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)\r\n> ==6001==    by 0x5122FEA: std::basic_streambuf<char, std::char_traits<char> >::xsputn(char const*, long) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.20)\r\n> ==6001==    by 0x5119632: std::ostream::write(char const*, long) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.20)\r\n> ==6001==    by 0x41F208: DirentRaw::set(char const*, unsigned long) (raw.cc:24)\r\n> ==6001==    by 0x41B691: OFPacketIn::OFPacketIn(std::string, ofp11_packet_in const&, OFPort&) (of_packet_in.cc:20)\r\n> ==6001==    by 0x410C8A: OFSwitch::handle_packet_in(unsigned char, ofp11_packet_in const&) (of_switch.cc:105)\r\n> ==6001==    by 0x41104B: OFSwitch::handle_packet_in(unsigned char, ofp_packet_in const&) (of_switch.cc:131)\r\n> ==6001==    by 0x40DB21: OFNetwork::handle_message(om::net::StreamConnection&, ofp_header&) (of_network.cc:124)\r\n> ==6001==    by 0x405BFA: YancOFAdapter::receive_data(om::net::StreamConnection*) (yanc_of_adapter.cc:164)\r\n> ==6001==    by 0x40B557: void std::_Mem_fn<void (YancOFAdapter::*)(om::net::StreamConnection*)>::operator()<om::net::StreamConnection*, void>(YancOFAdapter*, om::net::StreamConnection*&&) const (in /home/sohil/Softwares/yanc/apps/of-adapter/yanc-of-adapter)\r\n> ==6001==    by 0x40A6D7: void std::_Bind<std::_Mem_fn<void (YancOFAdapter::*)(om::net::StreamConnection*)> (YancOFAdapter*, std::_Placeholder<1>)>::__call<void, om::net::StreamConnection*&&, 0ul, 1ul>(std::tuple<om::net::StreamConnection*&&>&&, std::_Index_tuple<0ul, 1ul>) (functional:1264)\r\n> ==6001==    by 0x40933B: void std::_Bind<std::_Mem_fn<void (YancOFAdapter::*)(om::net::StreamConnection*)> (YancOFAdapter*, std::_Placeholder<1>)>::operator()<om::net::StreamConnection*, void>(om::net::StreamConnection*&&) (functional:1323)\r\n> ==6001==  Address 0x5f1d4c0 is 0 bytes after a block of size 96 alloc'd\r\n> ==6001==    at 0x4C2C820: operator new[](unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)\r\n> ==6001==    by 0x41101F: OFSwitch::handle_packet_in(unsigned char, ofp_packet_in const&) (of_switch.cc:128)\r\n> ==6001==    by 0x40DB21: OFNetwork::handle_message(om::net::StreamConnection&, ofp_header&) (of_network.cc:124)\r\n> ==6001==    by 0x405BFA: YancOFAdapter::receive_data(om::net::StreamConnection*) (yanc_of_adapter.cc:164)\r\n> ==6001==    by 0x40B557: void std::_Mem_fn<void (YancOFAdapter::*)(om::net::StreamConnection*)>::operator()<om::net::StreamConnection*, void>(YancOFAdapter*, om::net::StreamConnection*&&) const (in /home/sohil/Softwares/yanc/apps/of-adapter/yanc-of-adapter)\r\n> ==6001==    by 0x40A6D7: void std::_Bind<std::_Mem_fn<void (YancOFAdapter::*)(om::net::StreamConnection*)> (YancOFAdapter*, std::_Placeholder<1>)>::__call<void, om::net::StreamConnection*&&, 0ul, 1ul>(std::tuple<om::net::StreamConnection*&&>&&, std::_Index_tuple<0ul, 1ul>) (functional:1264)\r\n> ==6001==    by 0x40933B: void std::_Bind<std::_Mem_fn<void (YancOFAdapter::*)(om::net::StreamConnection*)> (YancOFAdapter*, std::_Placeholder<1>)>::operator()<om::net::StreamConnection*, void>(om::net::StreamConnection*&&) (functional:1323)\r\n> ==6001==    by 0x408444: std::_Function_handler<void (om::net::StreamConnection*), std::_Bind<std::_Mem_fn<void (YancOFAdapter::*)(om::net::StreamConnection*)> (YancOFAdapter*, std::_Placeholder<1>)> >::_M_invoke(std::_Any_data const&, om::net::StreamConnection*) (functional:2039)\r\n> ==6001==    by 0x425B46: std::function<void (om::net::StreamConnection*)>::operator()(om::net::StreamConnection*) const (in /home/sohil/Softwares/yanc/apps/of-adapter/yanc-of-adapter)\r\n> ==6001==    by 0x4254A4: om::net::StreamConnection::ready() (in /home/sohil/Softwares/yanc/apps/of-adapter/yanc-of-adapter)\r\n> ==6001==    by 0x42A30D: om::async::EPollWrapper::dispatch() (in /home/sohil/Softwares/yanc/apps/of-adapter/yanc-of-adapter)\r\n> ==6001==    by 0x40645B: YancOFAdapter::run() (yanc_of_adapter.cc:268)\r\n> .......\r\n> .......\r\n> .......\r\n> \r\n\r\n_\r\n\r\nI can provide full valgrind report if needed."}}