2013/10/15 YAMAMOTO Takashi <[email protected]>: >> 2013/10/15 YAMAMOTO Takashi <[email protected]>: >>>> 2013/10/10 YAMAMOTO Takashi <[email protected]>: >>>>>> OVS has not yet supported table-miss flow, but this patch changes >>>>>> simple_switch_13 to install table-miss flow entry in accordance >>>>>> with OF1.3 spec. >>>>>> >>>>>> Signed-off-by: Yoshihiro Kaneko <[email protected]> >>>>>> --- >>>>>> ryu/app/simple_switch_13.py | 42 >>>>>> ++++++++++++++++++++++++++---------------- >>>>>> 1 file changed, 26 insertions(+), 16 deletions(-) >>>>>> >>>>>> diff --git a/ryu/app/simple_switch_13.py b/ryu/app/simple_switch_13.py >>>>>> index 18f874c..b211498 100644 >>>>>> --- a/ryu/app/simple_switch_13.py >>>>>> +++ b/ryu/app/simple_switch_13.py >>>>>> @@ -13,12 +13,9 @@ >>>>>> # See the License for the specific language governing permissions and >>>>>> # limitations under the License. >>>>>> >>>>>> -import logging >>>>>> -import struct >>>>>> - >>>>>> from ryu.base import app_manager >>>>>> from ryu.controller import ofp_event >>>>>> -from ryu.controller.handler import MAIN_DISPATCHER >>>>>> +from ryu.controller.handler import CONFIG_DISPATCHER, MAIN_DISPATCHER >>>>>> from ryu.controller.handler import set_ev_cls >>>>>> from ryu.ofproto import ofproto_v1_3 >>>>>> from ryu.lib.packet import packet >>>>>> @@ -32,18 +29,29 @@ class SimpleSwitch13(app_manager.RyuApp): >>>>>> super(SimpleSwitch13, self).__init__(*args, **kwargs) >>>>>> self.mac_to_port = {} >>>>>> >>>>>> - def add_flow(self, datapath, port, dst, actions): >>>>>> + @set_ev_cls(ofp_event.EventOFPSwitchFeatures, CONFIG_DISPATCHER) >>>>>> + def switch_features_handler(self, ev): >>>>>> + datapath = ev.msg.datapath >>>>>> + ofproto = datapath.ofproto >>>>>> + parser = datapath.ofproto_parser >>>>>> + >>>>>> + # install table-miss flow entry >>>>>> + match = parser.OFPMatch() >>>>>> + actions = [parser.OFPActionOutput(ofproto.OFPP_CONTROLLER, >>>>>> + ofproto.OFPCML_NO_BUFFER)] >>>>> >>>>> why no_buffer? >>>> >>>> packet_in handler extracts source mac address and destination >>>> mac address from msg.data. >>> >>> sure, but the current value (128 bytes) is enough for the purpose, >>> isn't it? >> >> Besides, msg.data is used by Packet-Out to send a packet. >> I think that the entire packet is needed when buffer_id is invalid. > > it shouldn't be a problem because, if a switch failed to allocate a buffer > for some reasons, it should send us the entire packet regardless of max_len.
Thanks for the clarification. I understand. > > however, at a glance at OVS code, it seems to send us packets unbuffered > but truncated for reason=action. i think it's their bug. Hmm, we cannot reach a good example for OF1.3... > >> >>> >>> having said that, i'm not necessarily against to the change >>> if it's for simplicity. >>> regardless of max_len, a switch is allowed to send us the entire >>> packet at any time and the current code seems broken in that case. >> >> Sorry. I'm not sure what you talk about. >> Is it a case of reason of packet-in except OFPR_ACTION? > > i meant that, the current code (without your change) is broken because > it assumes packet_in always has a valid buffer_id. Ah, I see. > > YAMAMOTO Takashi > >> >>> >>> YAMAMOTO Takashi >>> >>>> >>>>> >>>>> YAMAMOTO Takashi >>>>> >>>>>> + self.add_flow(datapath, 0, match, actions) >>>>>> + >>>>>> + def add_flow(self, datapath, priority, match, actions): >>>>>> ofproto = datapath.ofproto >>>>>> + parser = datapath.ofproto_parser >>>>>> >>>>>> - match = datapath.ofproto_parser.OFPMatch(in_port=port, >>>>>> - eth_dst=dst) >>>>>> - inst = [datapath.ofproto_parser.OFPInstructionActions( >>>>>> - ofproto.OFPIT_APPLY_ACTIONS, actions)] >>>>>> + inst = >>>>>> [parser.OFPInstructionActions(ofproto.OFPIT_APPLY_ACTIONS, >>>>>> + actions)] >>>>>> >>>>>> - mod = datapath.ofproto_parser.OFPFlowMod( >>>>>> + mod = parser.OFPFlowMod( >>>>>> datapath=datapath, cookie=0, cookie_mask=0, table_id=0, >>>>>> command=ofproto.OFPFC_ADD, idle_timeout=0, hard_timeout=0, >>>>>> - priority=0, buffer_id=ofproto.OFP_NO_BUFFER, >>>>>> + priority=priority, buffer_id=ofproto.OFP_NO_BUFFER, >>>>>> out_port=ofproto.OFPP_ANY, >>>>>> out_group=ofproto.OFPG_ANY, >>>>>> flags=0, match=match, instructions=inst) >>>>>> @@ -54,6 +62,7 @@ class SimpleSwitch13(app_manager.RyuApp): >>>>>> msg = ev.msg >>>>>> datapath = msg.datapath >>>>>> ofproto = datapath.ofproto >>>>>> + parser = datapath.ofproto_parser >>>>>> in_port = msg.match['in_port'] >>>>>> >>>>>> pkt = packet.Packet(msg.data) >>>>>> @@ -75,13 +84,14 @@ class SimpleSwitch13(app_manager.RyuApp): >>>>>> else: >>>>>> out_port = ofproto.OFPP_FLOOD >>>>>> >>>>>> - actions = [datapath.ofproto_parser.OFPActionOutput(out_port)] >>>>>> + actions = [parser.OFPActionOutput(out_port)] >>>>>> >>>>>> # install a flow to avoid packet_in next time >>>>>> if out_port != ofproto.OFPP_FLOOD: >>>>>> - self.add_flow(datapath, in_port, dst, actions) >>>>>> + match = parser.OFPMatch(in_port=in_port, eth_dst=dst) >>>>>> + self.add_flow(datapath, 1, match, actions) >>>>>> >>>>>> - out = datapath.ofproto_parser.OFPPacketOut( >>>>>> - datapath=datapath, buffer_id=msg.buffer_id, in_port=in_port, >>>>>> - actions=actions) >>>>>> + out = parser.OFPPacketOut( >>>>>> + datapath=datapath, buffer_id=ofproto.OFP_NO_BUFFER, >>>>>> + in_port=in_port, actions=actions, data=msg.data) >>>>>> datapath.send_msg(out) >>>>>> -- >>>>>> 1.7.9.5 >>>>>> >>>>>> >>>>>> ------------------------------------------------------------------------------ >>>>>> October Webinars: Code for Performance >>>>>> Free Intel webinars can help you accelerate application performance. >>>>>> Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most >>>>>> from >>>>>> the latest Intel processors and coprocessors. See abstracts and register >>>>>> > >>>>>> http://pubads.g.doubleclick.net/gampad/clk?id=60134071&iu=/4140/ostg.clktrk >>>>>> _______________________________________________ >>>>>> Ryu-devel mailing list >>>>>> [email protected] >>>>>> https://lists.sourceforge.net/lists/listinfo/ryu-devel >>>> >>>> ------------------------------------------------------------------------------ >>>> October Webinars: Code for Performance >>>> Free Intel webinars can help you accelerate application performance. >>>> Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most >>>> from >>>> the latest Intel processors and coprocessors. See abstracts and register > >>>> http://pubads.g.doubleclick.net/gampad/clk?id=60134071&iu=/4140/ostg.clktrk >>>> _______________________________________________ >>>> Ryu-devel mailing list >>>> [email protected] >>>> https://lists.sourceforge.net/lists/listinfo/ryu-devel >> >> ------------------------------------------------------------------------------ >> October Webinars: Code for Performance >> Free Intel webinars can help you accelerate application performance. >> Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from >> the latest Intel processors and coprocessors. See abstracts and register > >> http://pubads.g.doubleclick.net/gampad/clk?id=60135031&iu=/4140/ostg.clktrk >> _______________________________________________ >> Ryu-devel mailing list >> [email protected] >> https://lists.sourceforge.net/lists/listinfo/ryu-devel ------------------------------------------------------------------------------ October Webinars: Code for Performance Free Intel webinars can help you accelerate application performance. Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from the latest Intel processors and coprocessors. See abstracts and register > http://pubads.g.doubleclick.net/gampad/clk?id=60135031&iu=/4140/ostg.clktrk _______________________________________________ Ryu-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ryu-devel
