summaryrefslogtreecommitdiff
path: root/lib/tnl-ports.c
diff options
context:
space:
mode:
authorDaniele Di Proietto <diproiettod@vmware.com>2015-11-23 15:37:46 -0800
committerDaniele Di Proietto <diproiettod@vmware.com>2015-12-10 17:38:23 -0800
commit5be5370d361b91d1dcda80897d20610c752d6975 (patch)
treec3ea94e4e073404db0262f38f6fe06f7014813f3 /lib/tnl-ports.c
parentb476e2f21b1f20bd0d24c0522e4d745603599582 (diff)
downloadopenvswitch-5be5370d361b91d1dcda80897d20610c752d6975.tar.gz
tnl-ports: Generate mask with correct prerequisites.
We should match on the transport ports only if the tunnel has a UDP header. It doesn't make sense to match on transport port for GRE tunnels. Also, to match on fragment bits we should use FLOW_NW_FRAG_MASK instead of 0xFF. FLOW_NW_FRAG_MASK is what we get if we convert to the ODP netlink format and back. Adding the correct masks in the tunnel router classifier helps in making sure that the translation generates masks that respect prerequisites. If the mask has some fields that do not respect prerequisites, the flow will get deleted by revalidation, because translating to ODP format and back will generate a more generic mask, which will be perceived as too generic (compared with the one generated by the translation).
Diffstat (limited to 'lib/tnl-ports.c')
-rw-r--r--lib/tnl-ports.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/tnl-ports.c b/lib/tnl-ports.c
index 3006a8b59..e7f2066ab 100644
--- a/lib/tnl-ports.c
+++ b/lib/tnl-ports.c
@@ -126,8 +126,14 @@ map_insert(odp_port_t port, struct eth_addr mac, struct in6_addr *addr,
match.wc.masks.dl_type = OVS_BE16_MAX;
match.wc.masks.nw_proto = 0xff;
- match.wc.masks.nw_frag = 0xff; /* XXX: No fragments support. */
- match.wc.masks.tp_dst = OVS_BE16_MAX;
+ /* XXX: No fragments support. */
+ match.wc.masks.nw_frag = FLOW_NW_FRAG_MASK;
+
+ /* 'udp_port' is zero for non-UDP tunnels (e.g. GRE). In this case it
+ * doesn't make sense to match on UDP port numbers. */
+ if (udp_port) {
+ match.wc.masks.tp_dst = OVS_BE16_MAX;
+ }
if (IN6_IS_ADDR_V4MAPPED(addr)) {
match.wc.masks.nw_dst = OVS_BE32_MAX;
} else {