Hi Iwase,
Thanks again for such speedy reply.

1. OFPActionSetField works fine instead of NXActionRegLoad

2. With your changes for length calculation OFPActionCopyField is also
working.


Thanks and Regards,
Rahul



On Wed, Dec 13, 2017 at 12:13 PM, Iwase Yusuke <iwase.yusu...@gmail.com>
wrote:

> Hi again Rahul,
>
> I tried it on my environment, OVS seems to suppose to use
> OFPActionSetField and
> OFPActionCopyField instead of NXActionRegLoad and NXActionRegMove.
> OFPActionSetField(OpenFlow 1.2 or later) is corresponding to
> NXActionRegLoad and
> OFPActionCopyField(Only OpenFlow 1.5) is corresponding to NXActionRegMove.
>
>
> Example:
>
> $ git diff
> diff --git a/ryu/app/simple_switch_15.py b/ryu/app/simple_switch_15.py
> index 6a86ba7..cad47a0 100644
> --- a/ryu/app/simple_switch_15.py
> +++ b/ryu/app/simple_switch_15.py
> @@ -18,6 +18,7 @@ from ryu.controller import ofp_event
>  from ryu.controller.handler import CONFIG_DISPATCHER, MAIN_DISPATCHER
>  from ryu.controller.handler import set_ev_cls
>  from ryu.ofproto import ofproto_v1_5
> +from ryu.ofproto import nicira_ext
>  from ryu.lib.packet import packet
>  from ryu.lib.packet import ethernet
>  from ryu.lib.packet import ether_types
> @@ -48,6 +49,30 @@ class SimpleSwitch15(app_manager.RyuApp):
>                                            ofproto.OFPCML_NO_BUFFER)]
>          self.add_flow(datapath, 0, match, actions)
>
> +        match = parser.OFPMatch(eth_type=0x0800)
> +        # actions = [
> +        #     parser.NXActionRegMove('tunnel_id', 'vlan_vid', 12),
> +        # ]
> +        actions = [
> +            parser.OFPActionCopyField(
> +                n_bits=32, oxm_ids=[
> +                    parser.OFPOxmId('ipv4_src'),
> +                    parser.OFPOxmId('ipv4_dst'),
> +                ]),
> +        ]
> +        self.add_flow(datapath, 1, match, actions)
> +
> +        match = parser.OFPMatch()
> +        # actions = [
> +        #     parser.NXActionRegLoad2(
> +        #         dst="eth_dst",
> +        #         value="aa:bb:cc:dd:ee:ff"),
> +        # ]
> +        actions = [
> +            parser.OFPActionSetField(eth_src="aa:bb:cc:dd:ee:ff"),
> +        ]
> +        self.add_flow(datapath, 1, match, actions)
> +
>      def add_flow(self, datapath, priority, match, actions):
>          ofproto = datapath.ofproto
>          parser = datapath.ofproto_parser
>
>
> $ sudo mn --controller remote --switch ovs,protocols=OpenFlow15
> ...(snip)...
> mininet> sh ovs-ofctl dump-flows s1 -O OpenFlow15
>  cookie=0x0, duration=3.454s, table=0, n_packets=0, n_bytes=0,
> priority=1,ip actions=move:NXM_OF_IP_SRC[]->NXM_OF_IP_DST[]
>  cookie=0x0, duration=3.454s, table=0, n_packets=0, n_bytes=0, priority=0
> actions=CONTROLLER:65535
>  cookie=0x0, duration=3.454s, table=0, n_packets=0, n_bytes=0, priority=1
> actions=set_field:aa:bb:cc:dd:ee:ff->eth_src
>
>
> But to use OFPActionCopyField, this action has a bug at its length
> calculation, so I needed to apply the following patch.
> (The above result was gotten after applying this patch)
>
>
> $ git diff
> diff --git a/ryu/ofproto/ofproto_v1_5_parser.py
> b/ryu/ofproto/ofproto_v1_5_parser.py
> index c89bc37..13b15f9 100644
> --- a/ryu/ofproto/ofproto_v1_5_parser.py
> +++ b/ryu/ofproto/ofproto_v1_5_parser.py
> @@ -2223,7 +2223,9 @@ class OFPOxmId(StringifyMixin):
>          # fixup
>          self.length = 0  # XXX see the comment on OFPOxmId
>
> -        (n, _v, _m) = ofproto.oxm_from_user(self.type, None)
> +        n, t = ofproto.oxm_field_info_by_name(self.type)
> +        self.length = t.size
> +        # (n, _v, _m) = ofproto.oxm_from_user(self.type, None)
>          oxm = (n << (1 + 8)) | (self.hasmask << 8) | self.length
>          buf = bytearray()
>          msg_pack_into(self._PACK_STR, buf, 0, oxm)
> @@ -5944,7 +5946,16 @@ class OFPActionCopyField(OFPAction):
>          self.n_bits = n_bits
>          self.src_offset = src_offset
>          self.dst_offset = dst_offset
> -        self.oxm_ids = oxm_ids
> +        assert len(oxm_ids) == 2
> +        self.oxm_ids = []
> +        for i in oxm_ids:
> +            if isinstance(i, OFPOxmId):
> +                i.hasmask = False  # fixup
> +                self.oxm_ids.append(i)
> +            elif isinstance(i, six.text_type):
> +                self.oxm_ids.append(OFPOxmId(i, hasmask=False))
> +            else:
> +                raise ValueError('invalid value for oxm_ids: %s' %
> oxm_ids)
>
>      @classmethod
>      def parser(cls, buf, offset):
> @@ -5960,14 +5971,16 @@ class OFPActionCopyField(OFPAction):
>          return cls(n_bits, src_offset, dst_offset, oxm_ids, type_, len_)
>
>      def serialize(self, buf, offset):
> -        oxm_ids_buf = bytearray()
> +        oxm_ids_buf = b''
>          for i in self.oxm_ids:
>              oxm_ids_buf += i.serialize()
> -        self.len += len(oxm_ids_buf)
> +        action_len = ofproto.OFP_ACTION_COPY_FIELD_SIZE +
> len(oxm_ids_buf)
> +        self.len = utils.round_up(action_len, 8)
> +        pad_len = self.len - action_len
>          msg_pack_into(ofproto.OFP_ACTION_COPY_FIELD_PACK_STR, buf,
>                        offset, self.type, self.len,
>                        self.n_bits, self.src_offset, self.dst_offset)
> -        buf += oxm_ids_buf
> +        buf += oxm_ids_buf + b'\x00' * pad_len
>
>
>  @OFPAction.register_action_type(ofproto.OFPAT_METER,
> diff --git a/ryu/ofproto/oxm_fields.py b/ryu/ofproto/oxm_fields.py
> index 0c5e459..80b8472 100644
> --- a/ryu/ofproto/oxm_fields.py
> +++ b/ryu/ofproto/oxm_fields.py
> @@ -65,6 +65,7 @@
>  # +-------------------------------+---------------+
>
>  from ryu.ofproto.oxx_fields import (
> +    _get_field_info_by_name,
>      _from_user,
>      _from_user_header,
>      _to_user,
> @@ -177,6 +178,8 @@ def generate(modname):
>      num_to_field = dict((f.num, f) for f in mod.oxm_types)
>
>      # create functions by using oxx_fields module.
> +    add_attr('oxm_field_info_by_name',
> +             functools.partial(_get_field_info_by_name, oxx,
> name_to_field))
>      add_attr('oxm_from_user',
>               functools.partial(_from_user, oxx, name_to_field))
>      add_attr('oxm_from_user_header',
>
>
> If this patch fixes your problem, I will post this later.
>
>
> Thanks,
> Iwase
>
>
> On 2017年12月13日 00:47, rahul b wrote:
>
>> Hi,
>> I read over here some of the nicira extensions are not supported on OF
>> 1.5 in OVS. https://sourceforge.net/p/ryu/mailman/message/34538059/
>>
>> I am using OF 1.5 and have tried both |NXActionRegLoad and
>> |NXActionRegLoadbut both seems to be
>> failing with
>>   |-- type: OFPET_BAD_ACTION(2)
>>   |-- code: OFPBAC_BAD_EXP_TYPE(3)
>>   `-- data: version=0x6, msg_type=0xe, msg_len=0x78, xid=0x87723d23
>>       `-- msg_type: OFPT_FLOW_MOD(14)
>> OFPErrorMsg received: type=0x02 code=0x03 message=0x06 0x0e 0x00 0x78
>> 0x87 0x72 0x3d 0x23 0x07 0x00 0x00 0x00 0x00 0x00 0x00 0x64 0xff 0xff 0xff
>> 0xff 0xff 0xff 0xff 0xff 0x42 0x00 0x00 0x00 0x00 0x00 0x00 0x64 0xff 0xff
>> 0xff 0xff 0xff 0xff 0xff 0xff 0x00 0x00 0x00 0x00 0x00 0x01 0x00 0x00 0x00
>> 0x01 0x00 0x14 0x80 0x00 0x06 0x06 0x00 0x00 0x00 0x00 0x00 0x55 0x80 0x00
>>
>>
>> Is there any known workaround to overcome this on OF version 1.5
>>
>> Thanks,
>> Rahul
>>
>>
>> ------------------------------------------------------------
>> ------------------
>> Check out the vibrant tech community on one of the world's most
>> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
>>
>>
>>
>> _______________________________________________
>> Ryu-devel mailing list
>> Ryu-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/ryu-devel
>>
>>
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Ryu-devel mailing list
Ryu-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to