Bekei Park <[email protected]> writes:
> nl_ct_flush_tuple() can only build the delete request for an entry
> whose protocol is ICMP, ICMPv6, TCP, UDP or SCTP. For any other
> protocol it logs "Unsupported L4 protocol" and fails with EOPNOTSUPP.
>
> A flush that matches on mark, labels or a partial tuple deletes the
> entries of a dump one by one, and any error but ENOENT ends it. So a
> single entry of another protocol in the zone, GRE for example, ends
> that flush and leaves the entries that come after it in the dump.
> SCTP used to be such a protocol [0].
>
> This happens in practice. On a production system with OVN, the flush
> of the connections of a removed ECMP next hop (a match on ct_label)
> ran into a GRE entry and failed this way.
>
> The dump already has all that the kernel needs to find the entry
> again. Next to the protocol number the kernel takes a pair of ports
> for the protocols that it tracks by more than the addresses: the ports
> of TCP, UDP and SCTP, and the keys of GRE, for which it requires them.
> A protocol that it tracks by the addresses only has no parser for
> them, so they are ignored. nl_ct_parse_tuple_proto() has kept the
> ports of any protocol when the kernel sends them, and left them zero
> when it does not, since commit f55c75959e8c ("netlink-conntrack:
> Change unsupported IPPROTO log to debug.").
>
> So put the ports in the request for every protocol that is not ICMP
> or ICMPv6. This does not make a flush carry on after an error. It
> removes a cause of the error.
>
> The new test has an entry of UDP, of GRE and of two protocols without
> ports in one zone and flushes them by a partial tuple. With the
> kernel datapath it fails without this change: the flush stops with
> NXCTF_NOT_SUPPORTED and entries are left. The userspace datapath
> deletes them with and without it.
>
> Also checked by hand with Linux 6.8 for protocols 47, 41, 4 and 253.
> The 5-tuple of such a protocol, which got NXCTF_NOT_SUPPORTED in the
> previous patch, is now flushed like any other: it gets no reply when
> the connection does not exist.
>
> [0] bac34b26a721 ("netlink-conntrack: Fix partial match of entries
> with SCTP.")
>
> Fixes: a9ae73b916ba ("ofp, dpif: Allow CT flush based on partial match.")
> Assisted-by: Claude Fable 5.2, Claude Code
> Signed-off-by: Bekei Park <[email protected]>
> ---
> v3:
> - New patch.
>
> lib/netlink-conntrack.c | 12 +++++------
> tests/system-traffic.at | 47 +++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 52 insertions(+), 7 deletions(-)
>
> diff --git a/lib/netlink-conntrack.c b/lib/netlink-conntrack.c
> index 2406b1b9a..debad1126 100644
> --- a/lib/netlink-conntrack.c
> +++ b/lib/netlink-conntrack.c
> @@ -665,15 +665,13 @@ nl_ct_put_tuple_proto(struct ofpbuf *buf, const struct
> ct_dpif_tuple *tuple)
> nl_msg_put_be16(buf, CTA_PROTO_ICMPV6_ID, tuple->icmp_id);
> nl_msg_put_u8(buf, CTA_PROTO_ICMPV6_TYPE, tuple->icmp_type);
> nl_msg_put_u8(buf, CTA_PROTO_ICMPV6_CODE, tuple->icmp_code);
> - } else if (tuple->ip_proto == IPPROTO_TCP ||
> - tuple->ip_proto == IPPROTO_UDP ||
> - tuple->ip_proto == IPPROTO_SCTP) {
> + } else {
> + /* TCP, UDP and SCTP have ports. So do, as far as the kernel is
> + * concerned, the other protocols that it tracks by more than the
> + * addresses, e.g. the keys of GRE. The kernel ignores the ports
> + * of a protocol that it tracks by addresses only. */
Do we know if there is a minimum kernel requirement for this to be true?
I don't think such policy has ever changed, but I want to make sure that
we aren't sneaking in a kernel version assumption here.
> nl_msg_put_be16(buf, CTA_PROTO_SRC_PORT, tuple->src_port);
> nl_msg_put_be16(buf, CTA_PROTO_DST_PORT, tuple->dst_port);
> - } else {
> - VLOG_WARN_RL(&rl, "Unsupported L4 protocol: %"PRIu8".",
> - tuple->ip_proto);
> - return false;
Given this can't fail anymore, might be worth eliminating the dead code
from nl_ct_put_ct_tuple and making the return type 'void'
> }
>
> nl_msg_end_nested(buf, offset);
> diff --git a/tests/system-traffic.at b/tests/system-traffic.at
> index eca0f1b96..6f5c7ffac 100644
> --- a/tests/system-traffic.at
> +++ b/tests/system-traffic.at
> @@ -9629,6 +9629,53 @@ AT_CHECK([ovs-pcap client.pcap | grep
> 000000002010000000002000], [0], [dnl
> OVS_TRAFFIC_VSWITCHD_STOP
> AT_CLEANUP
>
> +AT_SETUP([conntrack - ct flush with other IP protocols])
> +CHECK_CONNTRACK()
> +OVS_TRAFFIC_VSWITCHD_START()
> +
> +ADD_NAMESPACES(at_ns0, at_ns1)
> +
> +ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24", "e6:66:c1:11:11:11")
> +ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24", "e6:66:c1:22:22:22")
> +
> +AT_DATA([flows.txt], [dnl
> +priority=1,action=drop
> +priority=10,arp,action=normal
> +priority=100,in_port=1,ip,action=ct(zone=5,commit),2
> +])
> +
> +AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt])
> +
> +m4_define([IP_PKT], [m4_join([,],
> + [eth_src=e6:66:c1:11:11:11,eth_dst=e6:66:c1:22:22:22,eth_type=0x0800],
> + [nw_src=10.1.1.1,nw_dst=10.1.1.2,nw_ttl=64,nw_frag=no])])
> +
> +dnl One UDP connection, and one connection for each of a few protocols that
> +dnl are not tracked by ports: GRE, and two that only have the addresses.
> +NS_CHECK_EXEC([at_ns0], [$PYTHON3 $srcdir/sendpkt.py p0 \
> + $(ovs-ofctl compose-packet --bare
> 'IP_PKT,nw_proto=17,udp_src=1,udp_dst=2')],
> + [0], [ignore])
> +m4_foreach([IP_PROTO], [[47], [41], [253]], [
> +NS_CHECK_EXEC([at_ns0], [$PYTHON3 $srcdir/sendpkt.py p0 \
> + $(ovs-ofctl compose-packet --bare 'IP_PKT,nw_proto=IP_PROTO')],
> + [0], [ignore])
> +])
> +
> +OVS_WAIT_UNTIL_EQUAL(
> + [ovs-appctl dpctl/dump-conntrack zone=5 | FORMAT_CT(10.1.1.2)], [dnl
> +253,orig=(src=10.1.1.1,dst=10.1.1.2,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.2,dst=10.1.1.1,sport=<cleared>,dport=<cleared>),zone=5
> +41,orig=(src=10.1.1.1,dst=10.1.1.2,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.2,dst=10.1.1.1,sport=<cleared>,dport=<cleared>),zone=5
> +47,orig=(src=10.1.1.1,dst=10.1.1.2,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.2,dst=10.1.1.1,sport=<cleared>,dport=<cleared>),zone=5
> +udp,orig=(src=10.1.1.1,dst=10.1.1.2,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.2,dst=10.1.1.1,sport=<cleared>,dport=<cleared>),zone=5])
> +
> +dnl A flush by a partial tuple has to delete the entries one by one. It
> +dnl must be able to delete all of them, whatever their protocol.
> +AT_CHECK([ovs-ofctl ct-flush br0 zone=5 'ct_nw_src=10.1.1.1'])
> +AT_CHECK([ovs-appctl dpctl/dump-conntrack zone=5 | FORMAT_CT(10.1.1.2)])
> +
> +OVS_TRAFFIC_VSWITCHD_STOP
> +AT_CLEANUP
> +
> AT_SETUP([conntrack - Flush many conntrack entries by port])
> CHECK_CONNTRACK()
> OVS_TRAFFIC_VSWITCHD_START()
_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev