Discussion:
[Ryu-devel] ryu action for outputing to input port
Mahdieh Shariat
2017-06-22 07:24:28 UTC
Permalink
Tahere Yaghou:
Hi,
I want an ovs switch outputs a packet to its receiving port, but in ovs doc
I read:

actions=[action][,action...]
port
output:port
Outputs the packet to OpenFlow port number port. If
port is the packet's input port, the packet is not output.

so with bellow Ryu code:
» actions = [ofproto_parser.OFPActionOutput(output_port)]
when input_port== output_port, the packet is dropped.

I find a new action in ovs :
in_port
Outputs the packet on the port from which it
was
received.
but I can't find this action in Ryu... could you please help me to write a
code like this:
» if (in_port == port):
actions=[ofproto_parser.OFPActionInPort()]

I'm using ovs 2.7 and openflow 1.3

Thanks in advance
Mahdieh Shariat
2017-06-22 07:30:04 UTC
Permalink
Hi,
I want an ovs switch outputs a packet to its receiving port, but in ovs doc
I read:

actions=[action][,action...]
port
output:port
Outputs the packet to OpenFlow port number port. If
port is the packet's input port, the packet is not output.

so with bellow Ryu code:
» actions = [ofproto_parser.OFPActionOutput(output_port)]
when input_port== output_port, the packet is dropped.

I find a new action in ovs :
in_port
Outputs the packet on the port from which it
was
received.
but I can't find this action in Ryu... could you please help me to write a
code like this:
» if (in_port == port):
actions=[ofproto_parser.OFPActionInPort()]

I'm using ovs 2.7 and openflow 1.3

Thanks in advance
Fujimoto Satoshi
2017-06-22 07:55:44 UTC
Permalink
Hi, Mahdieh

You can use "ofproto.OFPP_IN_PORT" to do it.

actions = [parser.OFPActionOutput(ofproto.OFPP_IN_PORT)]
self.add_flow(datapath, 0, match, actions)

Then, the flow shown below will be installed.

$ovs-ofctl -O OpenFlow13 dump-flows s1
OFPST_FLOW reply (OF1.3) (xid=0x2): cookie=0x0, duration=2.975s,
table=0, n_packets=13, n_bytes=1026, priority=0 actions=IN_PORT


Thanks,
Fujimoto
Post by Mahdieh Shariat
Hi,
I want an ovs switch outputs a packet to its receiving port, but in
actions=[action][,action...]
port
output:port
Outputs the packet to OpenFlow port number port.
If port is the packet's input port, the packet is not output.
» actions = [ofproto_parser.OFPActionOutput(output_port)]
when input_port== output_port, the packet is dropped.
in_port
Outputs the packet on the port from which
it was
received.
but I can't find this action in Ryu... could you please help me to
actions=[ofproto_parser.OFPActionInPort()]
I'm using ovs 2.7 and openflow 1.3
Thanks in advance
------------------------------------------------------------------------------
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
https://lists.sourceforge.net/lists/listinfo/ryu-devel
Mahdieh Shariat
2017-06-23 18:16:15 UTC
Permalink
Hi, ​Fujimoto

Thank you very much for the prompt reply. It works.

But I have another problem in developing my app. In my app when I'm
installing rules on tables, I have a rule for two situations in a switch:
1. when a packet is incoming to in_port_1 and will go to out_port_2
2. when a packet is incoming to in_port_2 and will go to out_port_2

should I have two separate rules for these situations? May I have a common
action for them? Is there any ryu action for changing the input_port field
in ovs switch, like this:

» ovs-ofctl add-flow br0 in_port=2,actions=load:0->NXM_OF_IN_PORT[],2

Thanks

On Thu, Jun 22, 2017 at 12:25 PM, Fujimoto Satoshi <
Post by Fujimoto Satoshi
Hi, Mahdieh
You can use "ofproto.OFPP_IN_PORT" to do it.
actions = [parser.OFPActionOutput(ofproto.OFPP_IN_PORT)]
self.add_flow(datapath, 0, match, actions)
Then, the flow shown below will be installed.
$ovs-ofctl -O OpenFlow13 dump-flows s1
OFPST_FLOW reply (OF1.3) (xid=0x2): cookie=0x0, duration=2.975s,
table=0, n_packets=13, n_bytes=1026, priority=0 actions=IN_PORT
Thanks,
Fujimoto
Hi,
I want an ovs switch outputs a packet to its receiving port, but in ovs
actions=[action][,action...]
port
output:port
Outputs the packet to OpenFlow port number port. If
port is the packet's input port, the packet is not output.
» actions = [ofproto_parser.OFPActionOutput(output_port)]
when input_port== output_port, the packet is dropped.
in_port
Outputs the packet on the port from which it
was
received.
but I can't find this action in Ryu... could you please help me to write a
actions=[ofproto_parser.OFPActionInPort()]
I'm using ovs 2.7 and openflow 1.3
Thanks in advance
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Iwase Yusuke
2017-06-26 00:34:31 UTC
Permalink
Hi Mahdieh,

Excuse me for jumping in.
Hi, ​Fujimoto
Thank you very much for the prompt reply. It works.
But I have another problem in developing my app. In my app when I'm installing rules on tables, I
1. when a packet is incoming to in_port_1 and will go to out_port_2
2. when a packet is incoming to in_port_2 and will go to out_port_2
should I have two separate rules for these situations? May I have a common action for them? Is there
» ovs-ofctl add-flow br0 in_port=2,actions=load:0->NXM_OF_IN_PORT[],2
How about using OFPActionSetField?
This action is almost equivalent to "load" action of OVS.

http://ryu.readthedocs.io/en/latest/ofproto_v1_3_ref.html#ryu.ofproto.ofproto_v1_3_parser.OFPActionSetField

If you want to use "load" action of OVS via Ryu, please refer to the following document.

http://ryu.readthedocs.io/en/latest/nicira_ext_ref.html#ryu.ofproto.ofproto_v1_3_parser.NXActionRegLoad

Thanks,
Iwase
Thanks
Hi, Mahdieh
You can use "ofproto.OFPP_IN_PORT" to do it.
actions = [parser.OFPActionOutput(ofproto.OFPP_IN_PORT)]
self.add_flow(datapath, 0, match, actions)
Then, the flow shown below will be installed.
$ovs-ofctl -O OpenFlow13 dump-flows s1
OFPST_FLOW reply (OF1.3) (xid=0x2): cookie=0x0, duration=2.975s, table=0, n_packets=13,
n_bytes=1026, priority=0 actions=IN_PORT
Thanks,
Fujimoto
Post by Mahdieh Shariat
Hi,
actions=[action][,action...]
port
output:port
Outputs the packet to OpenFlow port number port. If port is the packet's
input port, the packet is not output.
» actions = [ofproto_parser.OFPActionOutput(output_port)]
when input_port== output_port, the packet is dropped.
in_port
Outputs the packet on the port from which it was
received.
actions=[ofproto_parser.OFPActionInPort()]
I'm using ovs 2.7 and openflow 1.3
Thanks in advance
------------------------------------------------------------------------------
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
https://lists.sourceforge.net/lists/listinfo/ryu-devel
<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
https://lists.sourceforge.net/lists/listinfo/ryu-devel
Mahdieh Shariat
2017-06-28 09:28:46 UTC
Permalink
Hi Iwase,
Thank you for your reply.
Post by Iwase Yusuke
Post by Mahdieh Shariat
actions = [
parser.NXActionRegLoad(ofs_nbits=nicira_ext.ofs_nbits(4, 31),
dst="NXM_OF_IN_PORT[]", value=0x0),
parser.OFPActionOutput(_port)]
Post by Iwase Yusuke
Post by Mahdieh Shariat
File
"/home/mahdie/.local/lib/python2.7/site-packages/ryu/ofproto/oxx_fields.py",
line 58, in _from_user_header
(num, t) = _get_field_info_by_name(oxx, name_to_field, name)
File
"/home/mahdie/.local/lib/python2.7/site-packages/ryu/ofproto/oxx_fields.py",
line 53, in _get_field_info_by_name
raise KeyError('unknown %s field: %s' % (oxx.upper(), name))
KeyError: 'unknown OXM field: NXM_OF_IN_PORT[]'
​
try:
f = name_to_field[name]
t = f.type
num = f.num
except KeyError:
t = type_desc.UnknownType
if name.startswith('field_'):
num = int(name.split('_')[1])
else:
raise KeyError('unknown %s field: %s' % (oxx.upper(), name))
return num, t

Unfortunately I can't find the related field name of "NXM_OF_IN_PORT[]" in
Ryu. How can I find that?
Thanks for your assistance
Post by Iwase Yusuke
Hi Mahdieh,
Excuse me for jumping in.
Post by Mahdieh Shariat
Hi, ​Fujimoto
Thank you very much for the prompt reply. It works.
But I have another problem in developing my app. In my app when I'm
1. when a packet is incoming to in_port_1 and will go to out_port_2
2. when a packet is incoming to in_port_2 and will go to out_port_2
should I have two separate rules for these situations? May I have a
common action for them? Is there any ryu action for changing the input_port
» ovs-ofctl add-flow br0 in_port=2,actions=load:0->NXM_OF_IN_PORT[],2
How about using OFPActionSetField?
This action is almost equivalent to "load" action of OVS.
http://ryu.readthedocs.io/en/latest/ofproto_v1_3_ref.html#ry
u.ofproto.ofproto_v1_3_parser.OFPActionSetField
If you want to use "load" action of OVS via Ryu, please refer to the following document.
http://ryu.readthedocs.io/en/latest/nicira_ext_ref.html#ryu.
ofproto.ofproto_v1_3_parser.NXActionRegLoad
Thanks,
Iwase
Post by Mahdieh Shariat
Thanks
On Thu, Jun 22, 2017 at 12:25 PM, Fujimoto Satoshi <
Hi, Mahdieh
You can use "ofproto.OFPP_IN_PORT" to do it.
actions = [parser.OFPActionOutput(ofproto.OFPP_IN_PORT)]
self.add_flow(datapath, 0, match, actions)
Then, the flow shown below will be installed.
$ovs-ofctl -O OpenFlow13 dump-flows s1
OFPST_FLOW reply (OF1.3) (xid=0x2): cookie=0x0, duration=2.975s,
table=0, n_packets=13,
n_bytes=1026, priority=0 actions=IN_PORT
Thanks,
Fujimoto
Post by Mahdieh Shariat
Hi,
actions=[action][,action...]
port
output:port
Outputs the packet to OpenFlow port number
port. If port is the packet's
input port, the packet is not output.
» actions = [ofproto_parser.OFPActionOutput(output_port)]
when input_port== output_port, the packet is dropped.
in_port
Outputs the packet on the port from which it was
received.
but I can't find this action in Ryu... could you please help me to
actions=[ofproto_parser.OFPActionInPort()]
I'm using ovs 2.7 and openflow 1.3
Thanks in advance
------------------------------------------------------------
------------------
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
forge.net>
https://lists.sourceforge.net/lists/listinfo/ryu-devel
<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
https://lists.sourceforge.net/lists/listinfo/ryu-devel
Iwase Yusuke
2017-06-29 05:25:10 UTC
Permalink
Hi Mahdieh,

NXM fields in Ryu are defined as the following.
http://ryu.readthedocs.io/en/latest/nicira_ext_ref.html#module-ryu.ofproto.nicira_ext

For "NXM_OF_IN_PORT", you can use "in_port_nxm", I guess.

Thanks,
Iwase
Post by Mahdieh Shariat
Hi Iwase,
Thank you for your reply.
Post by Mahdieh Shariat
actions = [
parser.NXActionRegLoad(ofs_nbits=nicira_ext.ofs_nbits(4, 31), dst="NXM_OF_IN_PORT[]", value=0x0),
parser.OFPActionOutput(_port)]
Post by Mahdieh Shariat
File "/home/mahdie/.local/lib/python2.7/site-packages/ryu/ofproto/oxx_fields.py", line 58, in
_from_user_header
(num, t) = _get_field_info_by_name(oxx, name_to_field, name)
File "/home/mahdie/.local/lib/python2.7/site-packages/ryu/ofproto/oxx_fields.py", line 53, in
_get_field_info_by_name
raise KeyError('unknown %s field: %s' % (oxx.upper(), name))
KeyError: 'unknown OXM field: NXM_OF_IN_PORT[]'

f = name_to_field[name]
t = f.type
num = f.num
t = type_desc.UnknownType
num = int(name.split('_')[1])
raise KeyError('unknown %s field: %s' % (oxx.upper(), name))
return num, t
Unfortunately I can't find the related field name of "NXM_OF_IN_PORT[]" in Ryu. How can I find that?
Thanks for your assistance
Hi Mahdieh,
Excuse me for jumping in.
Hi, ​Fujimoto
Thank you very much for the prompt reply. It works.
But I have another problem in developing my app. In my app when I'm installing rules on
1. when a packet is incoming to in_port_1 and will go to out_port_2
2. when a packet is incoming to in_port_2 and will go to out_port_2
should I have two separate rules for these situations? May I have a common action for them?
» ovs-ofctl add-flow br0 in_port=2,actions=load:0->NXM_OF_IN_PORT[],2
How about using OFPActionSetField?
This action is almost equivalent to "load" action of OVS.
http://ryu.readthedocs.io/en/latest/ofproto_v1_3_ref.html#ryu.ofproto.ofproto_v1_3_parser.OFPActionSetField
<http://ryu.readthedocs.io/en/latest/ofproto_v1_3_ref.html#ryu.ofproto.ofproto_v1_3_parser.OFPActionSetField>
If you want to use "load" action of OVS via Ryu, please refer to the following document.
http://ryu.readthedocs.io/en/latest/nicira_ext_ref.html#ryu.ofproto.ofproto_v1_3_parser.NXActionRegLoad
<http://ryu.readthedocs.io/en/latest/nicira_ext_ref.html#ryu.ofproto.ofproto_v1_3_parser.NXActionRegLoad>
Thanks,
Iwase
Thanks
Hi, Mahdieh
You can use "ofproto.OFPP_IN_PORT" to do it.
actions = [parser.OFPActionOutput(ofproto.OFPP_IN_PORT)]
self.add_flow(datapath, 0, match, actions)
Then, the flow shown below will be installed.
$ovs-ofctl -O OpenFlow13 dump-flows s1
OFPST_FLOW reply (OF1.3) (xid=0x2): cookie=0x0, duration=2.975s, table=0,
n_packets=13,
n_bytes=1026, priority=0 actions=IN_PORT
Thanks,
Fujimoto
Hi,
actions=[action][,action...]
port
output:port
Outputs the packet to OpenFlow port number port. If port is
the packet's
input port, the packet is not output.
» actions = [ofproto_parser.OFPActionOutput(output_port)]
when input_port== output_port, the packet is dropped.
in_port
Outputs the packet on the port from which it was
received.
but I can't find this action in Ryu... could you please help me to write a code
actions=[ofproto_parser.OFPActionInPort()]
I'm using ovs 2.7 and openflow 1.3
Thanks in advance
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org!http://sdm.link/slashdot <http://sdm.link/slashdot>
_______________________________________________
Ryu-devel mailing list
https://lists.sourceforge.net/lists/listinfo/ryu-devel
<https://lists.sourceforge.net/lists/listinfo/ryu-devel>
<https://lists.sourceforge.net/lists/listinfo/ryu-devel
<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
https://lists.sourceforge.net/lists/listinfo/ryu-devel
<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
https://lists.sourceforge.net/lists/listinfo/ryu-devel
Loading...