OpendayLight: How to specify the destination IP address of the flow table

1.2k views Asked by At

I'm using OpendayLight(Carbon SR1) to send a flow table to the switch, everything is OK except working with the set-nw-dst-action-case instruction. Once I use this instruction, the flow can not be set to switch correctly(check via http://opendaylight_ip:8181/restconf/operational/opendaylight-inventory:nodes/node/openflow:1/flow-node-inventory:table/0) and this is my json code to set the flow:

{
    "flow": [
        {
            "id": "test",
            "match": {
                "ethernet-match": {
                    "ethernet-destination": {
                        "address": "02:42:4a:46:fc:02"
                    }
                }
            },
            "instructions": {
                "instruction": [
                    {
                        "order": "0",
                        "apply-actions": {
                            "action": [
                                {
                                    "order": "0",
                                    "set-nw-dst-action": {
                                        "_Opps": "Remove this action goes normal"
                                        "ipv4-address": "192.168.1.3/32"
                                    }
                                },
                                {
                                    "order": "1",
                                    "set-dl-dst-action": {
                                        "address": "02:42:4a:46:fc:03"
                                    }
                                },
                                {
                                    "order": "2",
                                    "output-action": {
                                        "output-node-connector": "3",
                                        "max-length": "65535"
                                    }
                                }
                            ]
                        }
                    }
                ]
            },
            "priority": "16",
            "table_id": "0"
        }
    ]
}

The json code above follows the OpendayLight specification, but I found this message in Open vSwitch logs:

2017-09-07T16:35:26.713Z|00103|ofp_actions|WARN|set_field ip_dst lacks correct prerequisities

This question is similar to my one. I have tried to add flow with ovs-ofctl tools and succeed, is there any way to add the flow with set-nw-dst-action-case instruction in OpendayLight?

p.s. The ovs-ofctl command let:

ovs-ofctl add-flow s1 "table=0,dl_dst=02:42:4a:46:fc:02,priority=12,action=mod_dl_dst:02:42:4a:46:fc:03,mod_nw_dst:192.168.1.3,output:3"

EDIT(2017-9-8 21:14 GMT+8)
I have tried to match the ip criteria and the ovs log complain about this:

2017-09-08T12:49:30.567Z|00032|nx_match|WARN|Rejecting NXM/OXM entry 0:32768:12:1:8 with 1-bits in value for bits wildcarded by the mask.
2017-09-08T12:49:30.567Z|00033|ofp_actions|WARN|bad action at offset 0 (OFPBMC_BAD_WILDCARDS):
00000000  00 19 00 10 80 00 19 08-0a 00 00 03 ff 00 00 00
2017-09-08T12:49:30.567Z|00034|connmgr|INFO|s1<->tcp:192.168.43.171:6633: sending OFPBMC_BAD_WILDCARDS error reply to OFPT_FLOW_MOD message
2017-09-08T12:49:30.567Z|00035|ofp_actions|WARN|set_field ip_dst lacks correct prerequisities

and I use this json code(OpendayLight Yang UI passed):

{
    "flow": [
        {
            "id": "bwt",
            "match": {
                "ethernet-match": {
                    "ethernet-destination": {
                        "address": "02:42:4a:46:fc:02"
                    }
                },
                "ipv4-destination": "192.168.1.2/32"
            },
            "instructions": {
                "instruction": [
                    {
                        "order": "0",
                        "apply-actions": {
                            "action": [
                                {
                                    "order": "0",
                                    "set-dl-dst-action": {
                                        "address": "02:42:4a:46:fc:03"
                                    }
                                },
                                {
                                    "order": "1",
                                    "set-nw-src-action": {
                                        "ipv4-address": "192.168.1.3/32"
                                    }
                                },
                                {
                                    "order": "2",
                                    "output-action": {
                                        "output-node-connector": "3",
                                        "max-length": "65535"
                                    }
                                }
                            ]
                        }
                    }
                ]
            },
            "priority": "12",
            "table_id": "0"
        }
    ]
}

EDIT(2017-9-9 23:48 GMT+8)
The problem has been solved, see my answer.

2

There are 2 answers

0
Weitan Bai On BEST ANSWER

Specification

According to OpenFlow Switch Specification Version 1.3.5 ( Protocol version 0x04 ) section 7.2.3.6 Flow Match Field Prerequisite and section 7.2.3.8 Header Match Fields, the flow to modify the ip address(dst_ip or src_ip) have to:
1. set ethernet-destination-mask to ff:ff:ff:ff:ff:ff
2. ethernet-type-type to 0x0800.
3. The mask of ipv4 should be 255.255.255.255 or ip_addr/32

Code

The effective flow json code in OpendayLight platform as follows(Carbon SR1, opendaylight-inventory rev.2013-08-19):

{
    "flow": [
        {
            "id": "bwt",
            "match": {
                "ethernet-match": {
                    "ethernet-destination": {
                        "address": "02:42:4a:46:fc:01",
                        "mask": "ff:ff:ff:ff:ff:ff"
                    },
                    "ethernet-type": {
                        "type": "0x0800"
                    }
                },
                "ipv4-destination": "192.168.1.2/32"
            },
            "instructions": {
                "instruction": [
                    {
                        "order": "0",
                        "apply-actions": {
                            "action": [
                                {
                                    "order": "0",
                                    "set-dl-dst-action": {
                                        "address": "02:42:4a:46:fc:03"
                                    }
                                },
                                {
                                    "order": "1",
                                    "set-nw-dst-action": {
                                        "ipv4-address": "192.168.1.3/32"
                                    }
                                },
                                {
                                    "order": "2",
                                    "output-action": {
                                        "output-node-connector": "3",
                                        "max-length": "65535"
                                    }
                                }
                            ]
                        }
                    }
                ]
            },
            "priority": "12",
            "table_id": "0"
        }
    ]
}

Acknowledgment

Thanks to Karthik Prasad who guides me to read the specification and Peder Zickler who met the same problem as me.

5
Karthik Prasad On

Checkout openflow spec section 7.2.3.8, table:13(OXM_OF_IPV4_DST), as also error described in ovs log, you need to match packet type of ipv4 before setting action destination ip.

Sample Flow

ovs-ofctl add-flow s1 -O OpenFlow13 "table=0,ip,dl_dst=02:42:4a:46:fc:02,priority=12,action=set_field:02:42:4a:46:fc:03->eth_dst,set_field:192.168.1.3->ip_dst,output:3"