When the Geneve options of an upcall in udpif format can't be parsed,
e.g., there is a critical option that is not in the TLV mapping table,
or an option with a length different from the mapped one, the
translation bails out early with XLATE_INVALID_TUNNEL_METADATA.
This early exit skips the conversion of the tunnel metadata masks into
udpif format at the end of xlate_actions(), so the installed drop flow
has the option bytes fully wildcarded. Since the datapath always
matches on the total options length, this drop flow matches every
packet from the same tunnel with options of the same length, including
packets with perfectly valid metadata, e.g.:
recirc_id(0),tunnel(tun_id=0x7b,src=1.1.2.92,dst=1.1.2.88,
geneve({}{}),flags(+key)),in_port(6081),eth_type(0x0800),
ipv4(frag=no), actions:drop
Packets with valid options that hit this flow never reach userspace and
are silently dropped for as long as the flow stays in the datapath.
And since the revalidator re-translates the flow with the same invalid
key, the flow is kept while it has traffic. With OVN, where every
packet carries the same option class, type and length, a single
malformed packet is enough to black-hole the traffic of all the ports
behind that tunnel that don't already have more specific flows, e.g.,
new connections, while established ones keep working.
Fix that by exact matching on all the received options when they fail
to parse, so the drop flow only covers packets with the same invalid
metadata.
Fixes: 8d8ab6c2d574 ("tun-metadata: Manage tunnel TLV mapping table on a
per-bridge basis.")
Signed-off-by: Lucas Vargas Dias <[email protected]>
---
ofproto/ofproto-dpif-xlate.c | 14 ++++++++++
tests/tunnel-push-pop.at | 54 ++++++++++++++++++++++++++++++++++++
2 files changed, 68 insertions(+)
diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c
index 4e7d6fb40..439e884ba 100644
--- a/ofproto/ofproto-dpif-xlate.c
+++ b/ofproto/ofproto-dpif-xlate.c
@@ -8493,8 +8493,22 @@ xlate_actions(struct xlate_in *xin, struct xlate_out
*xout)
&xin->upcall_flow->tunnel,
&flow->tunnel);
if (err) {
+ const struct flow_tnl *upcall_tnl = &xin->upcall_flow->tunnel;
+
xlate_report_error(&ctx, "Invalid Geneve tunnel metadata");
ctx.error = XLATE_INVALID_TUNNEL_METADATA;
+
+ /* The resulting drop flow must match on the exact options that
+ * failed to parse. Otherwise, it will have the options fully
+ * wildcarded and will also drop all packets with valid options
+ * of the same total length, because the conversion of the masks
+ * into udpif format at the end of this function is skipped. */
+ memset(&ctx.wc->masks.tunnel.metadata, 0,
+ sizeof ctx.wc->masks.tunnel.metadata);
+ memset(ctx.wc->masks.tunnel.metadata.opts.u8, 0xff,
+ upcall_tnl->metadata.present.len);
+ ctx.wc->masks.tunnel.metadata.present.len = 0xff;
+ ctx.wc->masks.tunnel.flags |= FLOW_TNL_F_UDPIF;
goto exit;
}
} else if (!flow->tunnel.metadata.tab) {
diff --git a/tests/tunnel-push-pop.at b/tests/tunnel-push-pop.at
index ab393cfc7..dc7dea90d 100644
--- a/tests/tunnel-push-pop.at
+++ b/tests/tunnel-push-pop.at
@@ -1616,3 +1616,57 @@ AT_CHECK([ovs-appctl ofproto/trace ovs-dummy
'in_port(int-br),dnl
OVS_VSWITCHD_STOP
AT_CLEANUP
+
+AT_SETUP([tunnel_push_pop - Geneve invalid metadata drop flow])
+
+OVS_VSWITCHD_START(
+ [add-port br0 p0 \
+ -- set Interface p0 type=dummy ofport_request=1 \
+ other-config:hwaddr=aa:55:aa:55:00:00])
+AT_CHECK([ovs-vsctl add-br int-br -- set bridge int-br datapath_type=dummy])
+AT_CHECK([ovs-vsctl add-port int-br t2 \
+ -- set Interface t2 type=geneve \
+ options:remote_ip=1.1.2.92 \
+ options:key=123 ofport_request=2])
+AT_CHECK([ovs-appctl netdev-dummy/ip4addr br0 1.1.2.88/24], [0], [OK
+])
+AT_CHECK([ovs-ofctl add-flow br0 action=normal])
+AT_CHECK([ovs-ofctl add-tlv-map int-br \
+ "{class=0xffff,type=0x80,len=4}->tun_metadata0"])
+AT_CHECK([ovs-ofctl add-flow int-br \
+ "in_port=t2,tun_metadata0=0xa,actions=LOCAL"])
+AT_CHECK([ovs-appctl revalidator/wait])
+
+eth=aa55aa550000001b213cab640800
+ip4=45000096794640004011ba5b0101025c01010258
+udp=308817c100820000
+geneve=0400655800007b00
+inner=fe71d883724fbeb6f4e1494a080045000054ba200000400184861e0000011e00000200004227e75400030af3195500000000f265010000000000101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f3031323334353637
+dnl Unknown critical option (type 0x81) followed by a non-critical one.
+bad_opts=ffff81010000000affff00010000000b
+dnl Known option (type 0x80) with the same total options length.
+good_opts=ffff80010000000affff00010000000b
+
+dnl A packet with invalid Geneve metadata must be dropped.
+AT_CHECK([ovs-appctl netdev-dummy/receive p0 \
+ "${eth}${ip4}${udp}${geneve}${bad_opts}${inner}"])
+OVS_WAIT_UNTIL([grep -q 'Invalid Geneve tunnel metadata' ovs-vswitchd.log])
+
+dnl The drop flow must not swallow packets with valid metadata.
+AT_CHECK([ovs-appctl netdev-dummy/receive p0 \
+ "${eth}${ip4}${udp}${geneve}${good_opts}${inner}"])
+
+AT_CHECK([ovs-appctl dpctl/dump-flows | grep 'in_port(6081)' \
+ | strip_ufid | strip_used | sort], [0], [dnl
+recirc_id(0),tunnel(tun_id=0x7b,src=1.1.2.92,dst=1.1.2.88,dnl
+geneve({class=0xffff,type=0x80,len=4,0xa}{class=0xffff,type=0,len=4}),dnl
+flags(+key)),in_port(6081),packet_type(ns=0,id=0),eth_type(0x0800),dnl
+ipv4(frag=no), packets:0, bytes:0, used:never, actions:2
+recirc_id(0),tunnel(tun_id=0x7b,src=1.1.2.92,dst=1.1.2.88,dnl
+geneve({class=0xffff,type=0x81,len=4,0xa}{class=0xffff,type=0,len=4,0xb}),dnl
+flags(+key)),in_port(6081),packet_type(ns=0,id=0),eth_type(0x0800),dnl
+ipv4(frag=no), packets:0, bytes:0, used:never, actions:drop
+])
+
+OVS_VSWITCHD_STOP(["/Invalid Geneve tunnel metadata/d"])
+AT_CLEANUP
--
2.43.0
--
_'Esta mensagem é direcionada apenas para os endereços constantes no
cabeçalho inicial. Se você não está listado nos endereços constantes no
cabeçalho, pedimos-lhe que desconsidere completamente o conteúdo dessa
mensagem e cuja cópia, encaminhamento e/ou execução das ações citadas estão
imediatamente anuladas e proibidas'._
* **'Apesar do Magazine Luiza tomar
todas as precauções razoáveis para assegurar que nenhum vírus esteja
presente nesse e-mail, a empresa não poderá aceitar a responsabilidade por
quaisquer perdas ou danos causados por esse e-mail ou por seus anexos'.*
_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev