On Sun, 24 Mar 2013 13:45:52 +0100
Christopher Scherb <[email protected]> wrote:

> I extended the file nx_match.py (ryu/ryu/ofproto/nx_match.py).

Great, thanks!

> Changes:
> Extended the file nx_match.py:
> In line 317 of the file there was a FIXME ("FIXME: Add support for
> dl_vlan, fl_vlan_pcp, nw_tos, nw_proto, nw_src, nw_dst, tp_src and
> dp_dst to self").
> The function "match_tuple" of the class "ClsRule" changed to support
> "dl_vlan, fl_vlan_pcp, nw_tos, nw_proto, nw_src, nw_dst, tp_src and
> dp_dst".
> The class "Flow" was extended with fields for "dl_vlan" and "dl_vlan_pcp".
> The class "ClsRule" was extended with functions to set the "dl_vlan"
> and the "dl_vlan_pcp" (New functions: "set_dl_vlan" and
> "set_dl_vlan_pcp").
> In the functions "set_nw_src" and "set_nw_dst" where changed (mask is
> 0 for a exact match) to work correct with the mask added in the
> match_tuple function.

The last part looks wrong. With your patch, I can't set nw_dst/nw_src
without a mask. MFField->putm does nothing if mask is zero.

I think that nw_dst and nw_src with a mask works now like the
following. I'm not sure what you try to fix.

fujita@node1:~$ sudo ovs-ofctl dump-flows dp0
NXST_FLOW reply (xid=0x4):
 cookie=0x0, duration=1.879s, table=0, n_packets=0, n_bytes=0,
 idle_age=1, priority=1,ip,nw_src=18.52.86.0/24 actions=CONTROLLER:0


I dropped the nw_src/nw_dst changes and applied this patch. If you
still see some problem in the latest code, please send another patch.

Next time, please follow the instruction:

https://github.com/osrg/ryu/blob/master/SubmittingPatches.rst


Thanks!

=
import gevent

from ryu.controller import handler
from ryu.controller import dpset
from ryu.controller import ofp_event
from ryu.ofproto import nx_match
from ryu.ofproto import ofproto_v1_0
from ryu.ofproto import ofproto_v1_0_parser
from ryu.base import app_manager
from ryu.ofproto.ofproto_parser import MsgBase, msg_pack_into, msg_str_attr
from ryu.lib import mac
from ryu.ofproto import ether


class NX(app_manager.RyuApp):
    _CONTEXTS = {
        'dpset': dpset.DPSet,
        }

    def __init__(self, *args, **kwargs):
        super(NX, self).__init__(*args, **kwargs)

    @staticmethod
    def _make_command(table, command):
        return table << 8 | command

    def send_flow_mod(self, dp, command, rule, actions=None):
        flow_mod = dp.ofproto_parser.NXTFlowMod(datapath=dp,
            cookie=0, command=command, idle_timeout=0, hard_timeout=0,
            priority=0x1, buffer_id=0xffffffff,
            out_port=dp.ofproto.OFPP_NONE,
            flags=0, rule=rule, actions=actions)
        dp.send_msg(flow_mod)

    def add_flow(self, dp, rule, actions):
        command = self._make_command(0, dp.ofproto.OFPFC_ADD)
        self.send_flow_mod(dp, command, rule, actions)

    def test(self, dp):
        rule = nx_match.ClsRule()
        rule.set_dl_type(ether.ETH_TYPE_IP)
        rule.set_nw_src_masked(0x12345678, 0xffffff00)

        actions = []
        actions.append(
            dp.ofproto_parser.OFPActionOutput(dp.ofproto.OFPP_CONTROLLER))
        self.add_flow(dp, rule, actions)

    @handler.set_ev_cls(dpset.EventDP, dpset.DPSET_EV_DISPATCHER)
    def handler_datapath(self, ev):
        if ev.enter:
            print "start"
            self.test(ev.dp)



------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_mar
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to