Skip to content

Commit

Permalink
flow: Add list node for the conjunctive flow.
Browse files Browse the repository at this point in the history
In subsequent patches, flows need to be grouped in
a list and treated as a conjunctive flow.

Signed-off-by: Nobuhiro MIKI <[email protected]>
Signed-off-by: 0-day Robot <[email protected]>
  • Loading branch information
bobuhiro11 authored and ovsrobot committed Sep 15, 2023
1 parent bac34b2 commit a6bda3c
Show file tree
Hide file tree
Showing 11 changed files with 27 additions and 24 deletions.
9 changes: 6 additions & 3 deletions include/openvswitch/flow.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "openflow/nicira-ext.h"
#include "openvswitch/packets.h"
#include "openvswitch/util.h"
#include "openvswitch/list.h"

#ifdef __cplusplus
extern "C" {
Expand All @@ -27,7 +28,7 @@ extern "C" {
/* This sequence number should be incremented whenever anything involving flows
* or the wildcarding of flows changes. This will cause build assertion
* failures in places which likely need to be updated. */
#define FLOW_WC_SEQ 42
#define FLOW_WC_SEQ 43

/* Number of Open vSwitch extension 32-bit registers. */
#define FLOW_N_REGS 16
Expand Down Expand Up @@ -116,6 +117,7 @@ struct flow {
ovs_u128 ct_label; /* Connection label. */
uint32_t conj_id; /* Conjunction ID. */
ofp_port_t actset_output; /* Output port in action set. */
struct ovs_list list_node; /* In struct xlate_out's "conj_flows" list. */

/* L2, Order the same as in the Ethernet header! (64-bit aligned) */
struct eth_addr dl_dst; /* Ethernet destination address. */
Expand Down Expand Up @@ -166,8 +168,9 @@ BUILD_ASSERT_DECL(sizeof(struct ovs_key_nsh) % sizeof(uint64_t) == 0);

/* Remember to update FLOW_WC_SEQ when changing 'struct flow'. */
BUILD_ASSERT_DECL(offsetof(struct flow, igmp_group_ip4) + sizeof(uint32_t)
== sizeof(struct flow_tnl) + sizeof(struct ovs_key_nsh) + 300
&& FLOW_WC_SEQ == 42);
== sizeof(struct flow_tnl) + sizeof(struct ovs_key_nsh) +
sizeof(struct ovs_list) + 300
&& FLOW_WC_SEQ == 43);

/* Incremental points at which flow classification may be performed in
* segments.
Expand Down
2 changes: 1 addition & 1 deletion lib/dpif-netdev-extract-avx512.c
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ BUILD_ASSERT_DECL((OFFSETOFEND(struct dp_packet, l4_ofs)
BUILD_ASSERT_DECL(FLOWMAP_UNITS == 2);

/* Ensure the miniflow-struct ABI is the expected version. */
BUILD_ASSERT_DECL(FLOW_WC_SEQ == 42);
BUILD_ASSERT_DECL(FLOW_WC_SEQ == 43);

/* If the above build assert happens, this means that you might need to make
* some modifications to the AVX512 miniflow extractor code. In general, the
Expand Down
20 changes: 10 additions & 10 deletions lib/flow.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ struct mf_ctx {
* away. Some GCC versions gave warnings on ALWAYS_INLINE, so these are
* defined as macros. */

#if (FLOW_WC_SEQ != 42)
#if (FLOW_WC_SEQ != 43)
#define MINIFLOW_ASSERT(X) ovs_assert(X)
BUILD_MESSAGE("FLOW_WC_SEQ changed: miniflow_extract() will have runtime "
"assertions enabled. Consider updating FLOW_WC_SEQ after "
Expand Down Expand Up @@ -789,7 +789,7 @@ void
miniflow_extract(struct dp_packet *packet, struct miniflow *dst)
{
/* Add code to this function (or its callees) to extract new fields. */
BUILD_ASSERT_DECL(FLOW_WC_SEQ == 42);
BUILD_ASSERT_DECL(FLOW_WC_SEQ == 43);

const struct pkt_metadata *md = &packet->md;
const void *data = dp_packet_data(packet);
Expand Down Expand Up @@ -1309,7 +1309,7 @@ flow_get_metadata(const struct flow *flow, struct match *flow_metadata)
{
int i;

BUILD_ASSERT_DECL(FLOW_WC_SEQ == 42);
BUILD_ASSERT_DECL(FLOW_WC_SEQ == 43);

match_init_catchall(flow_metadata);
if (flow->tunnel.tun_id != htonll(0)) {
Expand Down Expand Up @@ -1895,7 +1895,7 @@ flow_wildcards_init_for_packet(struct flow_wildcards *wc,
memset(&wc->masks, 0x0, sizeof wc->masks);

/* Update this function whenever struct flow changes. */
BUILD_ASSERT_DECL(FLOW_WC_SEQ == 42);
BUILD_ASSERT_DECL(FLOW_WC_SEQ == 43);

if (flow_tnl_dst_is_set(&flow->tunnel)) {
if (flow->tunnel.flags & FLOW_TNL_F_KEY) {
Expand Down Expand Up @@ -2048,7 +2048,7 @@ void
flow_wc_map(const struct flow *flow, struct flowmap *map)
{
/* Update this function whenever struct flow changes. */
BUILD_ASSERT_DECL(FLOW_WC_SEQ == 42);
BUILD_ASSERT_DECL(FLOW_WC_SEQ == 43);

flowmap_init(map);

Expand Down Expand Up @@ -2151,7 +2151,7 @@ void
flow_wildcards_clear_non_packet_fields(struct flow_wildcards *wc)
{
/* Update this function whenever struct flow changes. */
BUILD_ASSERT_DECL(FLOW_WC_SEQ == 42);
BUILD_ASSERT_DECL(FLOW_WC_SEQ == 43);

memset(&wc->masks.metadata, 0, sizeof wc->masks.metadata);
memset(&wc->masks.regs, 0, sizeof wc->masks.regs);
Expand Down Expand Up @@ -2295,7 +2295,7 @@ flow_wildcards_set_xxreg_mask(struct flow_wildcards *wc, int idx,
uint32_t
miniflow_hash_5tuple(const struct miniflow *flow, uint32_t basis)
{
BUILD_ASSERT_DECL(FLOW_WC_SEQ == 42);
BUILD_ASSERT_DECL(FLOW_WC_SEQ == 43);
uint32_t hash = basis;

if (flow) {
Expand Down Expand Up @@ -2342,7 +2342,7 @@ ASSERT_SEQUENTIAL(ipv6_src, ipv6_dst);
uint32_t
flow_hash_5tuple(const struct flow *flow, uint32_t basis)
{
BUILD_ASSERT_DECL(FLOW_WC_SEQ == 42);
BUILD_ASSERT_DECL(FLOW_WC_SEQ == 43);
uint32_t hash = basis;

if (flow) {
Expand Down Expand Up @@ -3020,7 +3020,7 @@ flow_push_mpls(struct flow *flow, int n, ovs_be16 mpls_eth_type,

if (clear_flow_L3) {
/* Clear all L3 and L4 fields and dp_hash. */
BUILD_ASSERT(FLOW_WC_SEQ == 42);
BUILD_ASSERT(FLOW_WC_SEQ == 43);
memset((char *) flow + FLOW_SEGMENT_2_ENDS_AT, 0,
sizeof(struct flow) - FLOW_SEGMENT_2_ENDS_AT);
flow->dp_hash = 0;
Expand Down Expand Up @@ -3323,7 +3323,7 @@ flow_compose(struct dp_packet *p, const struct flow *flow,
/* Add code to this function (or its callees) for emitting new fields or
* protocols. (This isn't essential, so it can be skipped for initial
* testing.) */
BUILD_ASSERT_DECL(FLOW_WC_SEQ == 42);
BUILD_ASSERT_DECL(FLOW_WC_SEQ == 43);

uint32_t pseudo_hdr_csum;
size_t l4_len;
Expand Down
2 changes: 1 addition & 1 deletion lib/flow.h
Original file line number Diff line number Diff line change
Expand Up @@ -966,7 +966,7 @@ static inline void
pkt_metadata_from_flow(struct pkt_metadata *md, const struct flow *flow)
{
/* Update this function whenever struct flow changes. */
BUILD_ASSERT_DECL(FLOW_WC_SEQ == 42);
BUILD_ASSERT_DECL(FLOW_WC_SEQ == 43);

md->recirc_id = flow->recirc_id;
md->dp_hash = flow->dp_hash;
Expand Down
2 changes: 1 addition & 1 deletion lib/match.c
Original file line number Diff line number Diff line change
Expand Up @@ -1462,7 +1462,7 @@ match_format(const struct match *match,
bool is_megaflow = false;
int i;

BUILD_ASSERT_DECL(FLOW_WC_SEQ == 42);
BUILD_ASSERT_DECL(FLOW_WC_SEQ == 43);

if (priority != OFP_DEFAULT_PRIORITY) {
ds_put_format(s, "%spriority=%s%d,",
Expand Down
2 changes: 1 addition & 1 deletion lib/nx-match.c
Original file line number Diff line number Diff line change
Expand Up @@ -1051,7 +1051,7 @@ nx_put_raw(struct ofpbuf *b, enum ofp_version oxm, const struct match *match,
ovs_be32 spi_mask;
int match_len;

BUILD_ASSERT_DECL(FLOW_WC_SEQ == 42);
BUILD_ASSERT_DECL(FLOW_WC_SEQ == 43);

struct nxm_put_ctx ctx = { .output = b, .implied_ethernet = false };

Expand Down
6 changes: 3 additions & 3 deletions lib/odp-util.c
Original file line number Diff line number Diff line change
Expand Up @@ -6253,7 +6253,7 @@ odp_flow_key_from_flow__(const struct odp_flow_key_parms *parms,
/* New "struct flow" fields that are visible to the datapath (including all
* data fields) should be translated into equivalent datapath flow fields
* here (you will have to add a OVS_KEY_ATTR_* for them). */
BUILD_ASSERT_DECL(FLOW_WC_SEQ == 42);
BUILD_ASSERT_DECL(FLOW_WC_SEQ == 43);

struct ovs_key_ethernet *eth_key;
size_t encap[FLOW_MAX_VLAN_HEADERS] = {0};
Expand Down Expand Up @@ -7367,7 +7367,7 @@ odp_flow_key_to_flow__(const struct nlattr *key, size_t key_len,
/* New "struct flow" fields that are visible to the datapath (including all
* data fields) should be translated from equivalent datapath flow fields
* here (you will have to add a OVS_KEY_ATTR_* for them). */
BUILD_ASSERT_DECL(FLOW_WC_SEQ == 42);
BUILD_ASSERT_DECL(FLOW_WC_SEQ == 43);

enum odp_key_fitness fitness = ODP_FIT_ERROR;
if (errorp) {
Expand Down Expand Up @@ -8807,7 +8807,7 @@ commit_odp_actions(const struct flow *flow, struct flow *base,
/* If you add a field that OpenFlow actions can change, and that is visible
* to the datapath (including all data fields), then you should also add
* code here to commit changes to the field. */
BUILD_ASSERT_DECL(FLOW_WC_SEQ == 42);
BUILD_ASSERT_DECL(FLOW_WC_SEQ == 43);

enum slow_path_reason slow1, slow2;
bool mpls_done = false;
Expand Down
2 changes: 1 addition & 1 deletion lib/odp-util.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ void odp_portno_name_format(const struct hmap *portno_names,
* add another field and forget to adjust this value.
*/
#define ODPUTIL_FLOW_KEY_BYTES 640
BUILD_ASSERT_DECL(FLOW_WC_SEQ == 42);
BUILD_ASSERT_DECL(FLOW_WC_SEQ == 43);

/* A buffer with sufficient size and alignment to hold an nlattr-formatted flow
* key. An array of "struct nlattr" might not, in theory, be sufficiently
Expand Down
2 changes: 1 addition & 1 deletion lib/ofp-match.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ ofputil_netmask_to_wcbits(ovs_be32 netmask)
void
ofputil_wildcard_from_ofpfw10(uint32_t ofpfw, struct flow_wildcards *wc)
{
BUILD_ASSERT_DECL(FLOW_WC_SEQ == 42);
BUILD_ASSERT_DECL(FLOW_WC_SEQ == 43);

/* Initialize most of wc. */
flow_wildcards_init_catchall(wc);
Expand Down
2 changes: 1 addition & 1 deletion ofproto/ofproto-dpif-rid.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ struct rule;
/* Metadata for restoring pipeline context after recirculation. Helpers
* are inlined below to keep them together with the definition for easier
* updates. */
BUILD_ASSERT_DECL(FLOW_WC_SEQ == 42);
BUILD_ASSERT_DECL(FLOW_WC_SEQ == 43);

struct frozen_metadata {
/* Metadata in struct flow. */
Expand Down
2 changes: 1 addition & 1 deletion ofproto/ofproto-dpif-xlate.c
Original file line number Diff line number Diff line change
Expand Up @@ -4343,7 +4343,7 @@ compose_output_action__(struct xlate_ctx *ctx, ofp_port_t ofp_port,

/* If 'struct flow' gets additional metadata, we'll need to zero it out
* before traversing a patch port. */
BUILD_ASSERT_DECL(FLOW_WC_SEQ == 42);
BUILD_ASSERT_DECL(FLOW_WC_SEQ == 43);

if (!check_output_prerequisites(ctx, xport, flow, check_stp)) {
return;
Expand Down

0 comments on commit a6bda3c

Please sign in to comment.