From a9ae73b916bad528dcac2b8bb302fee6935fc163 Mon Sep 17 00:00:00 2001 From: Ales Musil Date: Mon, 16 Jan 2023 12:45:07 +0100 Subject: ofp, dpif: Allow CT flush based on partial match. Currently, the CT can be flushed by dpctl only by specifying the whole 5-tuple. This is not very convenient when there are only some fields known to the user of CT flush. Add new struct ofp_ct_match which represents the generic filtering that can be done for CT flush. The match is done only on fields that are non-zero with exception to the icmp fields. This allows the filtering just within dpctl, however it is a preparation for OpenFlow extension. Reported-at: https://bugzilla.redhat.com/2120546 Signed-off-by: Ales Musil Signed-off-by: Ilya Maximets --- include/openvswitch/automake.mk | 1 + include/openvswitch/ofp-ct.h | 66 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 include/openvswitch/ofp-ct.h (limited to 'include/openvswitch') diff --git a/include/openvswitch/automake.mk b/include/openvswitch/automake.mk index 84670d80a..0cc1f569e 100644 --- a/include/openvswitch/automake.mk +++ b/include/openvswitch/automake.mk @@ -15,6 +15,7 @@ openvswitchinclude_HEADERS = \ include/openvswitch/ofp-actions.h \ include/openvswitch/ofp-bundle.h \ include/openvswitch/ofp-connection.h \ + include/openvswitch/ofp-ct.h \ include/openvswitch/ofp-ed-props.h \ include/openvswitch/ofp-errors.h \ include/openvswitch/ofp-flow.h \ diff --git a/include/openvswitch/ofp-ct.h b/include/openvswitch/ofp-ct.h new file mode 100644 index 000000000..3d919ddf9 --- /dev/null +++ b/include/openvswitch/ofp-ct.h @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2023, Red Hat, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OPENVSWITCH_OFP_CT_H +#define OPENVSWITCH_OFP_CT_H 1 + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +struct ofp_ct_tuple { + struct in6_addr src; + struct in6_addr dst; + + union { + ovs_be16 src_port; + ovs_be16 icmp_id; + }; + union { + ovs_be16 dst_port; + struct { + uint8_t icmp_code; + uint8_t icmp_type; + }; + }; +}; + +struct ofp_ct_match { + uint8_t ip_proto; + uint16_t l3_type; + + struct ofp_ct_tuple tuple_orig; + struct ofp_ct_tuple tuple_reply; +}; + +bool ofp_ct_match_is_zero(const struct ofp_ct_match *); +bool ofp_ct_tuple_is_zero(const struct ofp_ct_tuple *, uint8_t ip_proto); +bool ofp_ct_tuple_is_five_tuple(const struct ofp_ct_tuple *, uint8_t ip_proto); + +void ofp_ct_match_format(struct ds *, const struct ofp_ct_match *); +bool ofp_ct_tuple_parse(struct ofp_ct_tuple *, const char *, + struct ds *, uint8_t *ip_proto, uint16_t *l3_type); + +#ifdef __cplusplus +} +#endif + +#endif /* ofp-ct.h */ -- cgit v1.2.1