为什么 OpenFlow select 规则具有较低的优先级?

Why does OpenFlow select rule with lower priority?

如果我在一台交换机上安装了这两条规则,根据OpenFlow交换机规范应该执行哪一条? OVS 执行第一个,尽管第二个具有更高的优先级:

第一条规则:

cookie=0x20000002000000,
duration=14647.575s,
table=0,
n_packets=1297621,
n_bytes=145897910,
idle_timeout=65535,
priority=1,
udp,
in_port=3,
dl_src=02:6d:f3:c1:b4:7b,
dl_dst=02:54:ab:ce:ba:0f,
nw_src=10.10.10.6,
nw_dst=10.10.10.1,
tp_src=46329,
tp_dst=1000
actions=output:1

第二条规则:

cookie=0xa000004039d1ae,
duration=164.680s,
table=0,
n_packets=0,
n_bytes=0,
send_flow_rem
priority=9999,
udp,
in_port=ANY,
nw_src=10.10.10.6,
nw_dst=10.10.10.1,
tp_dst=1000
actions=set_field:10.10.10.6->ip_src,
output:1

虽然目前没有记录,但 ANY 作为 in_port 的值应该只用于流 mod(删除)和流统计请求。要匹配数据包而不考虑它们的端口,您只需从 OpenFlow 规则中删除 in_port=ANY


此行为是 not documented, but several places in the source code mention it. First, OFPP_ANY is defined as a synonym of OFPP_NONE. The comment above mentions that it should only be used to match OpenFlow rules. Finally, the comment for OFPP_NONE definition 表示 OFPP_NONE 表示 Not associated with any port

我认为这应该被适当地记录下来,或者 ovs-ofctl 应该在使用不当时拒绝该值。我会在 ovs-dev 邮件列表上提出这个问题,并会根据答案更新此 post。