Hello,
I encountered unexpected behaviour today with Ryu 2.0 and also after a pull. I was sending a Flow Mod as a test to a switch (the flow mod content itself is likely not valid).

Basically, I tried the following for convenience:

            eth_src_field = datapath.ofproto_parser.OFPMatchField.make(
datapath.ofproto.OXM_OF_ETH_SRC,
haddr_to_bin("AA:AA:AA:AA:AA:AA"))
actions = [datapath.ofproto_parser.OFPActionSetField(eth_src_field)]

inst = [ofproto_par.OFPInstructionActions(ofproto.OFPIT_WRITE_ACTIONS,
                                                      actions),
ofproto_par.OFPInstructionActions(ofproto.OFPIT_APPLY_ACTIONS,
                                                      actions)]

And found that by reusing OFPActionSetField, the second instruction, apply actions, would be corrupt in the packet. So it appears the OFPActionSetField class is being modified which I was not expecting. I have included some test code which should demonstrate this as well as a pcap file showing when the same actions class is used, the transmitted data varies by 8 bytes compared to when independent OFPActionSetField classes are used.

I wasn't too sure if what I was doing was considered correct behaviour or not - but presumably if it was not, a raised error would be preferred?

Regards,
Alan Barr

Attachment: actions_not_reuseable.pcap
Description: Binary data

# Copyright (C) 2011 Nippon Telegraph and Telephone Corporation.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# 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 mac_to_port
from ryu.controller import ofp_event
from ryu.controller.handler import MAIN_DISPATCHER
from ryu.controller.handler import set_ev_cls
from ryu.ofproto import ofproto_v1_3
from ryu.lib.mac import haddr_to_bin

class Test(app_manager.RyuApp):
    OFP_VERSIONS = [ofproto_v1_3.OFP_VERSION]
    def __init__(self, *args, **kwargs):
        super(Test, self).__init__(*args, **kwargs)
    
    @set_ev_cls(ofp_event.EventOFPStateChange, MAIN_DISPATCHER)
    def negotiation_sucessful(self, ev):
        datapath = ev.datapath
        ofproto = datapath.ofproto
        ofproto_par = datapath.ofproto_parser
        
        work = True
        ########## Working Code ########## 
        if work:
            eth_src_field1 = datapath.ofproto_parser.OFPMatchField.make(
                                                datapath.ofproto.OXM_OF_ETH_SRC,
                                                
haddr_to_bin("AA:AA:AA:AA:AA:AA"))
            actions1 = 
[datapath.ofproto_parser.OFPActionSetField(eth_src_field1)]
 
            eth_src_field2 = datapath.ofproto_parser.OFPMatchField.make(
                                                datapath.ofproto.OXM_OF_ETH_SRC,
                                                
haddr_to_bin("AA:AA:AA:AA:AA:AA"))
            actions2 = 
[datapath.ofproto_parser.OFPActionSetField(eth_src_field2)]

            
            inst = 
[ofproto_par.OFPInstructionActions(ofproto.OFPIT_WRITE_ACTIONS,
                                                      actions1),
                    
ofproto_par.OFPInstructionActions(ofproto.OFPIT_APPLY_ACTIONS,
                                                      actions2)]

        ########## Not Working Code ########## 
        else:
            eth_src_field = datapath.ofproto_parser.OFPMatchField.make(
                                                datapath.ofproto.OXM_OF_ETH_SRC,
                                                
haddr_to_bin("AA:AA:AA:AA:AA:AA"))
            actions = [datapath.ofproto_parser.OFPActionSetField(eth_src_field)]
            
            inst = 
[ofproto_par.OFPInstructionActions(ofproto.OFPIT_WRITE_ACTIONS,
                                                      actions),
                    
ofproto_par.OFPInstructionActions(ofproto.OFPIT_APPLY_ACTIONS,
                                                      actions)]

        match = datapath.ofproto_parser.OFPMatch()
        match.set_in_port(1)

        mod = datapath.ofproto_parser.OFPFlowMod(
                datapath=datapath, cookie=0, cookie_mask=0,
                table_id=0, command=ofproto.OFPFC_ADD, idle_timeout=10,
                hard_timeout=10, priority=32768, buffer_id=0xffffffff, 
out_port=0,
                out_group=0, flags=ofproto.OFPFF_SEND_FLOW_REM,
                match=match, instructions=inst)
        datapath.send_msg(mod)

------------------------------------------------------------------------------
Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
Discover the easy way to master current and previous Microsoft technologies
and advance your career. Get an incredible 1,500+ hours of step-by-step
tutorial videos with LearnDevNow. Subscribe today and save!
http://pubads.g.doubleclick.net/gampad/clk?id=58040911&iu=/4140/ostg.clktrk
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to