Software Defined Networking
1753900 Members
7765 Online
108809 Solutions
New Discussion

How to use "set_field"

 
shcha
Visitor

How to use "set_field"

I want to create a flow that before packets send egress port, change the destination ip.

I use the RSdoc on HP VAN SDN Controller 2.0, below is flow JSON string

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++  

{"flow": {

"priority": 30000,

"table_id": 0,

"idle_timeout": 60,

"match": [

{"ipv4_src": "10.0.0.2"},

{"ipv4_dst": "10.0.0.22"},

{"ip_proto": "tcp"},

{"eth_type": "ipv4"},

{"tcp_dst": "80"}

],

"instructions": [

{"apply_actions": [{"set_field" : [{"ipv4_dst": "10.0.0.25"}]},

{"output": 66}]}]

}}

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

then result is below

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

HTTP Status 500 - com.fasterxml.jackson.databind.node.ArrayNode cannot be cast to com.fasterxml.jackson.databind.node.ObjectNode

type Exception report

message com.fasterxml.jackson.databind.node.ArrayNode cannot be cast to com.fasterxml.jackson.databind.node.ObjectNode

description The server encountered an internal error that prevented it from fulfilling this request.

exception

java.lang.ClassCastException: com.fasterxml.jackson.databind.node.ArrayNode cannot be cast to com.fasterxml.jackson.databind.node.ObjectNode

           com.hp.of.json.ActionCodec.decodeSetField(ActionCodec.java:286)

           com.hp.of.json.ActionCodec.decode(ActionCodec.java:238)

           com.hp.of.json.InstructionCodec.decodeActions(InstructionCodec.java:211)

           com.hp.of.json.InstructionCodec.decode(InstructionCodec.java:173)

           com.hp.of.json.OfmFlowModCodec.decodeInstructions(OfmFlowModCodec.java:223)

           com.hp.of.json.OfmFlowModCodec.decode(OfmFlowModCodec.java:181)

           com.hp.of.json.OfmFlowModCodec.decode(OfmFlowModCodec.java:46)

           com.hp.of.json.OfJsonCodec.decode(OfJsonCodec.java:59)

           com.hp.of.json.OfJsonCodec.decode(OfJsonCodec.java:42)

           com.hp.util.json.JSON.fromJson(JSON.java:68)

           com.hp.sdn.rs.FlowProvider.create(FlowProvider.java:73)

           com.hp.sdn.rs.DatapathsResource.createFlow(DatapathsResource.java:355)

           sun.reflect.GeneratedMethodAccessor92.invoke(Unknown Source)

           sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

           java.lang.reflect.Method.invoke(Method.java:606)

           com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvokerFactory.java:60)

           com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$ResponseOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:205)

           com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75)

           com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:302)

           com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)

           com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108)

           com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)

           com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84)

           com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1511)

           com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1442)

           com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1391)

           com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1381)

           com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:416)

           com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:538)

           com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:716)

           javax.servlet.http.HttpServlet.service(HttpServlet.java:848)

           com.hp.util.rs.SecurityFilter.doFilter(SecurityFilter.java:94)

           com.hp.util.rs.auth.AbstractTokenAuthFilter.doFilter(AbstractTokenAuthFilter.java:106)

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

 If I removed "set_field" then I can receive 200 OK.

                   

Above JSON string has problem? Please let me know how to use "set_field".

          

Thank you.

5 REPLIES 5
dave_tucker
Advisor

Re: How to use "set_field"

Hi,

 

You can follow the intructions here to check the JSON Schema. This will help a lot.

The value of "set_field" should be  "flow_match_field" object.

In the original JSON, you are passing an array ( the square brackets [])

 

{"set_field" : [{"ipv4_dst": "10.0.0.25"}]}

 

To fix this, simply remove the square brackets []

 

{"set_field" : {"ipv4_dst": "10.0.0.25"}}

 

So the new JSON would be...

 

{

  "flow": {

    "priority": 30000,

    "table_id": 0,

    "idle_timeout": 60,

    "match": [

      {

        "ipv4_src": "10.0.0.2"

      },

      {

        "ipv4_dst": "10.0.0.22"

      },

      {

        "ip_proto": "tcp"

      },

      {

        "eth_type": "ipv4"

      },

      {

        "tcp_dst": "80"

      }

    ],

    "instructions": [

      {

        "apply_actions": [

          {

            "set_field": {

              "ipv4_dst": "10.0.0.25"

            }

          },

          {

            "output": 66

          }

        ]

      }

    ]

  }

}

Technical Marketing Engineer @ HP and self-proclaimed SDN ninja. Words are my own...
shcha
Visitor

Re: How to use "set_field"

Thanks for your answer.

 

Fixed JSON was good, but I receive below. 

 

{
"error": "java.lang.IllegalArgumentException",
"message": "{ofm:[V_1_3,ERROR,76,3091],BAD_ACTION/BAD_SET_TYPE,#dataBytes=64,OFM-cause:[V_1_3,FLOW_MOD,128,3091]}"
}

 

OFS Specification describe that "BAD_ACTION/BAD_SET_TYPE" is Unsupported type in SET_FIELD action. 

 

HP OFS not ready for changing IP ( port too) ? 

 

I hope HP support flow_match_field's some property. ( ipv4_src, ipv4_dst, udp_src, udp_dst, ... ) 

 

Thanks.

dave_tucker
Advisor

Re: How to use "set_field"

Check the HP OpenFlow Administrators Guide  - Appendix A (p68)

There are several diagrams that show the capabilities of the OpenFlow implementation on HP switches.

This shows that the IP Src/IP Dst fields are currently not settable :(

 

 

Technical Marketing Engineer @ HP and self-proclaimed SDN ninja. Words are my own...
Sietze Reitsma
Respected Contributor

Re: How to use "set_field"

It can be done in software, but you should be carefull with the resources.

 

you could set the table_id to the software table.  (OF 1.3)

 

"table_id": 200,

 

 

 

 

 

 

sdnindia
Trusted Contributor

Re: How to use "set_field"

Hi,

Please let us know if your problem is solved.

Please feel free to reply incase you have more questions around the same topic or open a new thread if new topic.

 

If you feel your question has been answered, please do let us know by marking this response as an  accepted solution.

Thanks
HP SDN Team