Re: [openflowplugin-dev] sanity check of flows to OF1.3 Spec


Brent Salisbury <brent.salisbury@...>
 


Sorry for the delay, meant to get this done Friday night, I’ve been grinding through some sticking points this weekend on trying to extend OXMs. Here is a rough draft for a start hacking on the tests. I will add a couple posts and a couple screencasts as soon as time clears up this week. 

### Setup your ODL username in Gerrit ###
----------------------------------------------------------
1. Setup your ODL account https://identity.opendaylight.org/carbon/admin/login.jsp
2. Log into https://git.opendaylight.org/gerrit/#/admin/projects/
3. Setup your ssh key with your credentials.
- Links to get you going:
* https://wiki.opendaylight.org/view/OpenDaylight_Controller:Gerrit_Setup
* https://help.github.com/articles/generating-ssh-keys
* https://help.github.com/articles/set-up-git


### Clone the openflowplugin project ###
-------------------------------------------------------
1. Clone the project: git clone ssh://<odl_gerrit_username>@git.opendaylight.org:29418/openflowplugin.git
2. cd openflowplugin
3. download the SCP hooks. This isn't required but it will make it easier for you in tracking Gerrit-IDs. In the openflowplugin project directory run:
scp -p -P 29418 <odl_gerrit_username>@git.opendaylight.org:hooks/commit-msg .git/hooks/
4. Build the project using Maven (v3.04+ or greater):
mvn clean install -DskipTests  -Dmaven.compile.fork=true
5. Import the project into your IDE (I personally build and run from the CLI rather then trying to do that within an IDE).
6. In your IDE find the class OpenflowpluginTestCommandProvider and look around. org.opendaylight.openflowplugin.test.OpenflowpluginTestCommandProvider located in: ~/openflowplugin/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginTestCommandProvider.java
7. Each test function in the class are referenced in the case statements with an 'f' followed by a unique number like so:

case "f14":
    id += 14;
    flow.setMatch(createMatch1().build());
    flow.setInstructions(createAppyActionInstruction7().build());
    break; 
case "f15":
    id += 15;
    flow.setMatch(createMatch1().build());
    flow.setInstructions(createAppyActionInstruction8().build());
    break;

8. Each method has a match and instruction (list of actions in OF v1.1+) call. E.g. "flow.setMatch(...)" and "flow.setInstructions(...)"


### Run OpenFlow TestCommandProvider ###
---------------------------------------------------------------
1. cd ~/openflowplugin/distribution/base/target/distributions-openflowplugin-base-0.0.3-SNAPSHOT-osgipackage/opendaylight
2. ./run.sh

### Test FooNodes() ###
1. This will test the OpenFlow builders in the project. It doesn't however test installing a flowmod into a datapath, it merely tests that the ofplugin as able to build the pseudo json structure that would eventually be serialzed into a real vswitch or physwich.
2. In the OSGI CLI, run the following:
addMDFlow foo:node:14
3. The output should look something like the following Gist https://gist.github.com/24a0d7a7ca9f5dc78142 
** you can copy the output and use your favorite Json editor to fancy it into a readable structure or head to http://jsonlint.com and run it through the validator to format it. It will fail JSON validation of course but will still format it into a readable tree.
4. When you find on that fails, then you can dig in and patch it!


### Test on a real datapath ###
-----------------------------------------
1. You can also test on a real datapath. Install OVS and setup the bridge and define the IP address where your controller is running.
$ sudo yum install openvswitch || sudo apt-get install openvswitch
$ (only needed after a reboot, install will start the services magicaly) service openvswitch start
$ sudo ovs-vsctl add-br br-int
$ sudo ovs-vsctl set bridge br-int protocols=OpenFlow13
$ sudo ovs-vsctl set-controller br-int tcp:172.16.86.1:6633
$ sudo ovs-vsctl show
*Should look something like this:
    Bridge br-int
        Controller "tcp:172.16.86.1:6633"
            is_connected: true
        Port br-int
            Interface br-int
                type: internal
2. Now you can test the CommandProvider methods but first you need to get the DPID of your OVS datapath.
3. An easy way is to start the controller, verify it is attached in the OVS "sudo ovs-vsctl show" like above.
4. Type "printNodes" in the OSGI CLI like so:
osgi> printNodes
Nodes connected to this controller : 
[MD_SAL|openflow:108448937000521]
5. 108448937000521 is the datapath ID (DPID) of your ovs instance.
6. with the DPID you can now craft the test command like so: addMDFlow openflow:108448937000521 f14
7. Run that and check OVS to see if the flow installed with: sudo ovs-ofctl -O OpenFlow13  dump-flows br-int
8. I setup a doc and started adding some of the results from when I went through the Foo() methods last week. I don't know if it makes sense tracking them somewhere or not. http://goo.gl/BlTCYm


### Patch a bug ###
---------------------------
1. Add the change you want to make to fix an issue. An example being this patch. https://git.opendaylight.org/gerrit/#/c/7371/1

2. I am replaying that patch as an example. From the openflowplugin directory, type 'git diff' to show  your local changes and the difference from the ODL upstream repository branch you checked out, likely 'HEAD'/'master'.

openflowplugin # git diff
diff --git a/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginTestCommandProvider.java b/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginTestComma
index 620efed..aaf96b0 100644
--- a/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginTestCommandProvider.java
+++ b/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginTestCommandProvider.java
@@ -1262,8 +1262,7 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
         ActionBuilder ab = new ActionBuilder();
 
         SetVlanPcpActionBuilder pcp = new SetVlanPcpActionBuilder();
-        // the code point is a 3-bit(0-7) field representing the frame priority level
-        VlanPcp pcp1 = new VlanPcp((short) 4);
+        VlanPcp pcp1 = new VlanPcp((short) 9);
         pcp.setVlanPcp(pcp1);
         ab.setAction(new SetVlanPcpActionCaseBuilder().setSetVlanPcpAction(pcp.build()).build());
         ab.setKey(new ActionKey(0));


3. From the openflowplugin directory type 'git status' to view what files have changed and what is not yet committed.

openflowplugin #  git status
HEAD detached at FETCH_HEAD
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

modified:   test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginTestCommandProvider.java

no changes added to commit (use "git add" and/or "git commit -a")

4. Once you are ready to submit the patch, you need to add what files you want committed with 'git add /path/to/changed/file/foobar.class'.

openflowplugin # git add test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginTestCommandProvider.java

5. You now need to commit the change.

openflowplugin # git commit --signoff

6. This will take you to a vim editor. Here type in a relevant first line that is what is visible in Gerrit and then relevant info in the body. When complete save and exit. If you make a typo, you can restart with :q! (vi commands)
-------------------------------------------------------------------------------
Bug 1071: Invalid value used for frame priority code point in OFCommandProvider
    
-Adjusted to a magic number in bounds for PCP (0-7) to enable the test to stop failing for the function f80 in OpenFlowPluginTestCommandProvider.
    
Change-Id: Ib146f228e174b6785dfe9fecf93fa7cabba79f4f
Signed-off-by: Brent Salisbury <brent.salisbury@...>
-------------------------------------------------------------------------------
[detached HEAD 58f622d] Bug 1071: Invalid value used for frame priority code point in OFCommandProvider
 1 file changed, 1 insertion(+), 2 deletions(-)

// view your local git branch status after committing the changes:
openflowplugin # git status
HEAD detached from FETCH_HEAD
nothing to commit, working directory clean

//Git logs are very handy also:
openflowplugin # git status
HEAD detached from FETCH_HEAD
nothing to commit, working directory clean
openflowplugin # git log
commit 58f622d142e36deae5c8b8d303de4c01a30d8678
Author: Brent Salisbury <brent.salisbury@...>
Date:   Mon Jun 2 03:02:38 2014 -0400

    Bug 1071: Invalid value used for frame priority code point in OFCommandProvider
    
    -Adjusted to a magic number in bounds for PCP (0-7) to enable the test to stop failing for the function f80 in OpenFlowPluginTestCommandProvider.
    
    Change-Id: Ib146f228e174b6785dfe9fecf93fa7cabba79f4f

7. Now you can push the patch. Gerrit has a super handy feature which is "drafts" that you will see a link for in the web ui. https://git.opendaylight.org/gerrit/#/q/is:draft,n,z

When starting out I recommend getting used to using the ODL git/gerrit repository there. You are the only one that can see it unless you explicitly add a reviewer. From drafts you can use the 'publish draft' button to submit to the master for that branch. This and Github are your friends for learning Git/Gerrit workflows.

-Drafts:
git push  ssh://brentsalisbury@...:29418/openflowplugin.git HEAD:refs/drafts/master

-or if your patch is ready for a merge review push directly to master:
git push  ssh://<username>@git.opendaylight.org:29418/controller.git HEAD:refs/for/master

8. Lastly, if you need to patch your already pushed commit and you need to modify if for example a reviewer asked you to change something, you can do that with the following:

git commit --signoff --amend

9. --amend will reopen the commit message. This is where the "scp" command above was useful, if you added commit hooks your change-id will be in that message automatically. If it isn't, don't freak out, we can simply go to the initial commit in the Gerrit web page and look for:

Change-Id: Ib146f228e174b6785dfe9fecf93fa7cabba79f4f

Screencap: https://www.dropbox.com/s/r4ua9eqzdqwsdad/Screenshot%202014-06-02%2003.14.39.png

10. Simply copy and paste that into your commit amendment, optionally, but useful, add a brief description of the new changes with the apatch-setmend and save the patch.

11. Push the commit again, and as long as you are using the same Change-ID, you will see a new patch-set on the original commit in Gerrit like so:
https://www.dropbox.com/s/zsezzw8je6wshf5/Screenshot%202014-06-02%2003.16.11.png
haven't
12. Lastly if your patch has been waiting on review for too long, or you haven't had time to get back and patch it, your commit may come out of sync with the upstream branch. If this happens, there are a number of ways to solve this ranging in varying levels of insanity, but the easiest is to simply rebase using 'git pull --rebase origin master' (or some variant of rebase depending on interactivity desired).

openflowplugin # git pull --rebase origin master
From ssh://git.opendaylight.org:29418/openflowplugin
 * branch            master     -> FETCH_HEAD
First, rewinding head to replay your work on top of it...
Applying: Bug 1071: Invalid value used for frame priority code point in OFCommandProvider

13. Git applies an algorithm that combines the latest upstream code and your code to synchronize them magicaly.

Thats it. Please don't hesitate to hit me or any of the dozens of awesome ODL devs in the IRC channels up for assistance if you get stuck.

Cheers,
-Brent

From: Brent Salisbury <brent.salisbury@...>
Date: Friday, May 30, 2014 at 7:14 PM
To: Ed Henry <networkn3rd@...>, Christopher O'SHEA <christopher.o.shea@...>
Cc: Abhijit Kumbhare <abhijitkoss@...>, "openflowplugin-dev@..." <openflowplugin-dev@...>, "integration-dev@..." <integration-dev@...>
Subject: Re: [openflowplugin-dev] [integration-dev] sanity check of flows to OF1.3 Spec

Excellent, I feel a vHackfest coming on! Let’s get some content together and get rolling! 
-B

From: Ed Henry <networkn3rd@...>
Date: Friday, May 30, 2014 at 7:07 PM
To: Christopher O'SHEA <christopher.o.shea@...>
Cc: Abhijit Kumbhare <abhijitkoss@...>, "openflowplugin-dev@..." <openflowplugin-dev@...>, Brent Salisbury <brent.salisbury@...>, "integration-dev@..." <integration-dev@...>
Subject: Re: [openflowplugin-dev] [integration-dev] sanity check of flows to OF1.3 Spec

+1 as well. I'd love to tackle low hanging fruit like this as well.

-Ed

On May 30, 2014 6:18 PM, "Christopher O'SHEA" <christopher.o.shea@...> wrote:
Yea Brent awesome idea.

Would love to get my hands dirty, so +1 to the instructions.

Chris 

From: Abhijit Kumbhare <abhijitkoss@...>
Date: Friday, May 30, 2014 at 2:41 PM
To: Brent Salisbury <brent.salisbury@...>
Cc: Ericsson <christopher.o.shea@...>, "integration-dev@..." <integration-dev@...>, "openflowplugin-dev@..." <openflowplugin-dev@...>
Subject: Re: [integration-dev] [openflowplugin-dev] sanity check of flows to OF1.3 Spec

Sounds a good idea Brent!


On Fri, May 30, 2014 at 2:21 PM, Brent Salisbury <brent.salisbury@...> wrote:
Hey Chris, I did a quick audit last weekend and started patching a couple of them.  I will clean the list up tonight and reply with them this evening. Fwiw it's a good low hanging fruit for folks that are new to Java, ODL or dev in general to get their feet wet. Will include instructions  if anyone is interested. 

Thanks Chris!
Brent


On May 30, 2014, at 4:57 PM, Christopher O'SHEA <christopher.o.shea@...> wrote:

Hi,

I’m just wonder if there any sanity check performed on the flows before they are pushed to the switch? 

Something like 
  1. EtherType of IPv4  but having a match on IPv6 src address? 
  2. IPv6 ND Target but not matching on ICMPv6 type code of 135/136
I only bring this up as I’m convert some the XML file in the test-script/xmls to be run in the CSIT via robot. 
I notice some of the flows don’t get pushed to OVS but when I check the flow they break the spec so OVS reject the flow. 

Chris 
_______________________________________________
openflowplugin-dev mailing list
openflowplugin-dev@...
https://lists.opendaylight.org/mailman/listinfo/openflowplugin-dev

_______________________________________________
integration-dev mailing list
integration-dev@...
https://lists.opendaylight.org/mailman/listinfo/integration-dev



_______________________________________________
openflowplugin-dev mailing list
openflowplugin-dev@...
https://lists.opendaylight.org/mailman/listinfo/openflowplugin-dev

Join {integration-dev@lists.opendaylight.org to automatically receive all group messages.