Ask is moving to Stack Overflow and Serverfault.com! Please use the "opendaylight" tag on either of these sites. This site is now in Read-Only mode

1

How to write flow in Karaf?

asked 2015-06-22 22:58:40 -0800

ShreshthaJoshi gravatar image

I have an OVS switch configured along with integration karaf.

To push a flow, I am following the Wiki-Page: https://wiki.opendaylight.org/view/OpenDaylightOpenFlowPlugin:EndtoEnd_Flows

Pushed the flow with the following details:

With PostMan: Set headers: Content-Type: application/xml Accept: application/xml Authentication Use URL: http://<controller ip="">:8181/restconf/config/opendaylight-inventory:nodes/node/openflow:1/table/0/flow/1 PUT Use Body: <flow xmlns="urn:opendaylight:flow:inventory"> <priority>2</priority> <flow-name>Foo</flow-name> <match> <ethernet-match> <ethernet-type> <type>2048</type> </ethernet-type> </ethernet-match> <ipv4-destination>10.0.10.2/24</ipv4-destination> </match> <id>1</id> <table_id>0</table_id> <instructions> <instruction> <order>0</order> <apply-actions> <action> <order>0</order> <dec-nw-ttl> </dec-nw-ttl></action> </apply-actions> </instruction> </instructions> </flow></controller>

It returns 200 OK.

  • When checked the same in config datastore "http://<controller ip="">:8181/restconf/config/opendaylight-inventory:nodes/node/openflow:1/table/0/flow/1", it gives the response body that was pushed above.</controller>

  • But when checked in operational datastore at "http://<controller ip="">:8181/restconf/operational/opendaylight-inventory:nodes/node/openflow:1/table/0/flow/1", it returns 404 Not found.</controller>

  • Also when checked by executing command ovs-ofctl -o OpenFlow13 dump-flows br0, there are no flows found,

Please suggest, what more is required to push these flows in config to be pushed onto the switch and operational datastores.

Thanks.

edit retag flag offensive close merge delete

Comments

http://<controller ip="">:8181/restconf/operational/opendaylight-inventory:nodes/node/openflow:1 Do you get a reply from that? Also are you sure that the switch ID is 1?

Chris O'Shea ( 2015-06-23 02:58:07 -0800 )edit

6 answers

Sort by ยป oldest newest most voted
1

answered 2015-06-29 12:46:49 -0800

updated 2015-06-29 18:10:12 -0800

Hello,

As Chris O'Shea suggested, openflow:1 is the default node created in OpenDaylight. First, get the node list with this request:

Method: GET
URL: http://CONTROLLERIP:8181/restconf/operational/opendaylight-inventory:nodes/
HEADER:
Content-Type: application/xml
Accept: application/xml

This will return a list of nodes (other than openflow:1). The node you are looking for should have a flow-node-inventory:description that correspond to your Open Flow device. Once you find that field, look 1 field above and you should see id:"openflow:xxxxxxxxxxxxxx" (x = number). Now send your PUT with the node id:

Method: PUT
URL: http://CONTROLLERIP:8181/restconf/config/opendaylight-inventory:nodes/node/openflow:xxxxxxxxxxxxxx/table/0/flow/1
HEADER:
Content-Type: application/xml
Accept: application/xml

That should do the trick,

Cheers.

edit flag offensive delete publish link more

Comments

I was checking for the switch ID already and it exists. I think I'm in the same position as Edu. We followed the tutorial on the wiki step by step :/ Could be possible that that I'm working with helium 0.2.3 and OpenFlow 1.0?

Wayko ( 2015-07-02 10:58:37 -0800 )edit
0

answered 2015-06-30 05:11:27 -0800

Edu gravatar image

updated 2015-06-30 05:12:09 -0800

I have the same problem, and I have made the GET that you are saing, I recive the next reply:

enter code here<nodes xmlns="urn:opendaylight:inventory">
<node>
    <id>openflow:1</id>
    <serial-number xmlns="urn:opendaylight:flow:inventory">None</serial-number>
    <switch-features xmlns="urn:opendaylight:flow:inventory">
        <max_tables>254</max_tables>
        <max_buffers>256</max_buffers>
        <x:capabilities xmlns:x="urn:opendaylight:flow:inventory">x:flow-feature-capability-flow-stats</x:capabilities>
        <x:capabilities xmlns:x="urn:opendaylight:flow:inventory">x:flow-feature-capability-port-stats</x:capabilities>
        <x:capabilities xmlns:x="urn:opendaylight:flow:inventory">x:flow-feature-capability-queue-stats</x:capabilities>
        <x:capabilities xmlns:x="urn:opendaylight:flow:inventory">x:flow-feature-capability-table-stats</x:capabilities>
    </switch-features>
    <description xmlns="urn:opendaylight:flow:inventory">None</description>
    <hardware xmlns="urn:opendaylight:flow:inventory">Open vSwitch</hardware>
    <manufacturer xmlns="urn:opendaylight:flow:inventory">Nicira, Inc.</manufacturer>
    <software xmlns="urn:opendaylight:flow:inventory">2.0.2</software>
    <table xmlns="urn:opendaylight:flow:inventory">
        <id>36</id>
        <aggregate-flow-statistics xmlns="urn:opendaylight:flow:statistics">
            <flow-count>0</flow-count>
            <byte-count>0</byte-count>
            <packet-count>0</packet-count>
        </aggregate-flow-statistics>
        <flow-table-statistics xmlns="urn:opendaylight:flow:table:statistics">
            <packets-looked-up>0</packets-looked-up>
            <active-flows>0</active-flows>
            <packets-matched>0</packets-matched>
        </flow-table-statistics>
    </table>
    <table xmlns="urn:opendaylight:flow:inventory">
        (...)

This sais that my switch really it is the openflow:1?

edit flag offensive delete publish link more

Comments

Yes, you are correct, your switch is openflow:1 indeed. I notice the version of OVS is 2.0.2, do you mind trying to update it ? Also, do you notice any logs in karaf ? When the flows do not get copied over from config to operational, it means ODL wasn't able to push the flow.

grmontpetit ( 2015-06-30 07:31:54 -0800 )edit
0

answered 2015-06-30 22:26:54 -0800

ShreshthaJoshi gravatar image

In my case switch was not 1. Thanks to Gabriel, I was able to figure that out. I am pushing flows with correct "openflow:xxxxxxxxxxxxxx", I still can't see the flows in operational datastore.

When the flow was traced with wireshark, there is a OFTP - FLOW MOD error saying [Message : Malformed Packet [Exception occurred]] [Severity level: error] [Group: Malformed]

I am using the XML body given in the Wiki.

is there anything else missing.

edit flag offensive delete publish link more

Comments

Which XML in the wiki?

Chris O'Shea ( 2015-07-09 19:14:14 -0800 )edit
0

answered 2015-07-09 09:09:49 -0800

Ashwini_Mhatre gravatar image

hi all, I m facing same issue. I have configure br0,its getting id as openflow:xxxxxxxxx the flow is successfully added in config data store.but its not present in operational data store. as when i checked flows on br0 with ovs-ofctl dump-flows command my flow is not there. is it related to openflow version??? I am using ODL helium sr3.

please provide your hints,if you have....

Regards,

edit flag offensive delete publish link more

Comments

What is your flow doing? also have you check tcpdump to see if it being push from ODL but reject from OVS?, also which version of OVS you running and are u connecting via OF1.0 or OF1.3?

Chris O'Shea ( 2015-07-09 19:14:59 -0800 )edit

Hi charies, following are the version of openvswitch and openflow we are using: ovs-vsctl (Open vSwitch) 2.3.90 Compiled Jun 18 2015 07:06:24 DB Schema 7.12.1 openflow 1.4 please let me know if you required any further information. thanks

Ashwini_Mhatre ( 2015-07-09 20:46:10 -0800 )edit

I'm not sure ODL supports OpenFlow 1.4 i would try 1.3, Also what was the flow doing?

Chris O'Shea ( 2015-07-10 02:25:27 -0800 )edit

I have tried with 1.3 also.with existing br0. still its not working.:( do i need to delete br0 and then apply ovs-vsctl set bridge br0 protocols=OpenFlow13 this command??? also that rule is just forwording rule: <flow xmlns="urn:opendaylight:flow:inventory"><id>7</id><priority>105</priority><flow-name>myflow</flow-name><table_id>0</table_id><hard-timeout>35656</hard-timeout><idle-timeout>35656</idle-timeout><instructions><instruction><order>0</order><apply-actions><action><order>0</order><output-action><output-node-connector>2</output-node-connector></output-action></action></apply-actions></instruction></instructions><match><ipv4-destination>172.31.96.10/24</ipv4-destination><ethernet-match><ethernet-type><type>2048</type></ethernet-type></ethernet-match><ip-match><ip-protocol>1</ip-protocol></ip-match></match></flow>

Ashwini_Mhatre ( 2015-07-10 02:31:52 -0800 )edit

chris also following are the steps by which m configuring openvswitch let me know if m correct or not: root@srijit141:~# ovs-vsctl add-br br0 root@srijit141:~# ovs-vsctl set-manager tcp:<controller>:6633 root@srijit141:~# ovs-vsctl set-controller br0 tcp:<controller>:6633 root@srijit141:~# ovs-vsctl set bridge br0 protocols=OpenFlow13 root@srijit141:~# ovs-ofctl dump-flows br0

Ashwini_Mhatre ( 2015-07-10 02:46:28 -0800 )edit
0

answered 2015-07-15 07:36:51 -0800

Wayko gravatar image

May be this other answer helps you:

https://ask.opendaylight.org/question/4143/restconf-troubleshooting/?answer=4281#post-id-4281

edit flag offensive delete publish link more
0

answered 2015-07-15 15:15:52 -0800

runamuck gravatar image

Try to add an ip-match. For example:

 <ip-match>
  <ip-protocol>6</ip-protocol>
 </ip-match>
</match>

So, use this command (Notice I added an ip-protocol stanza):

With PostMan: Set headers: Content-Type: application/xml Accept: application/xml Authentication Use URL: http://<controller ip="">:8181/restconf/config/opendaylight-inventory:nodes/node/openflow:1/table/0/flow/1 PUT Use Body: <flow xmlns="urn:opendaylight:flow:inventory"> <priority>2</priority> <flow-name>Foo</flow-name> <match> <ethernet-match> <ethernet-type> <type>2048</type> </ethernet-type> </ethernet-match> <ipv4-destination>10.0.10.2/24</ipv4-destination><ip-match><ip-protocol>6</ip-protocol></ip-match></match></match> <id>1</id> <table_id>0</table_id> <instructions> <instruction> <order>0</order> <apply-actions> <action> <order>0</order> <dec-nw-ttl> </dec-nw-ttl></action> </apply-actions> </instruction> </instructions> </flow></controller>
edit flag offensive delete publish link more
Login/Signup to Answer

Question Tools

Follow
2 followers

Stats

Asked: 2015-06-22 22:58:40 -0800

Seen: 1,565 times

Last updated: Jul 15 '15