OpendayLight:如何指定流的目的IP地址table

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

我正在使用 OpendayLight(Carbon SR1) 将流 table 发送到交换机,除了使用 set-nw-dst-action-case 指令。使用此指令后,无法设置流程正确切换(通过http://opendaylight_ip:8181/restconf/operational/opendaylight-inventory:nodes/node/openflow:1/flow-node-inventory:table/0检查) 这是我设置流程的 json 代码:

{
    "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"
        }
    ]
}

上面的 json 代码遵循 OpendayLight 规范,但我在 Open vSwitch 日志中发现了这条消息:

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

This 问题和我的类似。我尝试用ovs-ofctl工具添加流程并成功了,有什么方法可以在OpendayLight中使用set-nw-dst-action-case指令添加流程吗?

p.s. ovs-ofctl 命令让:

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"

编辑(2017-9-8 21:14 GMT+8)
我试图匹配 ip 标准,ovs 日志对此有抱怨:

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

我用这个json代码(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"
        }
    ]
}

编辑(2017-9-9 23:48 GMT+8)
问题已解决,请看我的回答

Checkout openflow spec section 7.2.3.8, table:13(OXM_OF_IPV4_DST), 以及 ovs 日志中描述的错误,您需要在设置操作目标 ip 之前匹配 ipv4 的数据包类型.

示例流程

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"

规格

根据 OpenFlow Switch Specification Version 1.3.5 ( Protocol version 0x04 ) 部分 7.2.3.6 流匹配字段先决条件 和部分 7.2.3.8 Header 匹配字段,修改ip地址的流程(dst_ipsrc_ip)必须:
1. 将 ethernet-destination-mask 设置为 ff:ff:ff:ff:ff:ff
2. ethernet-type-type0x0800.
3、ipv4的掩码应该是255.255.255.255或者ip_addr/32

代码

OpendayLight平台中的有效流程json代码如下(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"
        }
    ]
}

致谢

感谢指导我阅读规范的 Karthik Prasad 和遇到与我相同问题的 Peder Zickler