When new stages are added to the pipelines the code authors also need to update LOG_PIPELINE_INGRESS_LEN and LOG_PIPELINE_EGRESS_LEN.
That's still the case with this patch but we now add a build-time assertion to ensure the values are correct. The alternative would be to add the northd.h pipeline definitions to a common place from where ovn-controller code could also include them but that seems far from ideal. Signed-off-by: Dumitru Ceara <[email protected]> --- lib/ovn-util.c | 2 +- northd/northd.c | 34 ++++++++++++++++++++++++++++++++++ northd/northd.h | 31 ++++++++++++++++++++----------- 3 files changed, 55 insertions(+), 12 deletions(-) diff --git a/lib/ovn-util.c b/lib/ovn-util.c index 90ab27fc63..de65208f62 100644 --- a/lib/ovn-util.c +++ b/lib/ovn-util.c @@ -1007,7 +1007,7 @@ ip_address_and_port_from_lb_key(const char *key, char **ip_address, * * NOTE: If OVN_NORTHD_PIPELINE_CSUM is updated make sure to double check * whether an update of OVN_INTERNAL_MINOR_VER is required. */ -#define OVN_NORTHD_PIPELINE_CSUM "3951531131 11381" +#define OVN_NORTHD_PIPELINE_CSUM "826401206 11374" #define OVN_INTERNAL_MINOR_VER 15 /* Returns the OVN version. The caller must free the returned value. */ diff --git a/northd/northd.c b/northd/northd.c index 2883e89058..30fdd9d398 100644 --- a/northd/northd.c +++ b/northd/northd.c @@ -407,6 +407,40 @@ static const char *reg_ct_state[] = { PIPELINE_STAGES #undef PIPELINE_STAGE +/* Count how many switch/router pipeline stages we have and check + * that LOG_PIPELINE_INGRESS_LEN and LOG_PIPELINE_EGRESS_LEN + * reflect reality. */ +#define PIPELINE_STAGE(DP_TYPE, PIPELINE, STAGE, TABLE, NAME) \ + _COUNTER_##DP_TYPE##_##PIPELINE##_##STAGE, + +#define PIPELINE_LEN_COUNTER(DP_TYPE, PIPELINE) \ + enum { \ + DP_TYPE##_##PIPELINE##_PIPELINE_STAGES \ + DP_TYPE##_##PIPELINE##_N_STAGES \ + }; + +PIPELINE_LEN_COUNTER(SWITCH, IN) +PIPELINE_LEN_COUNTER(SWITCH, OUT) +PIPELINE_LEN_COUNTER(ROUTER, IN) +PIPELINE_LEN_COUNTER(ROUTER, OUT) +#undef PIPELINE_STAGE + +BUILD_ASSERT_DECL( + (size_t) SWITCH_IN_N_STAGES > (size_t) ROUTER_IN_N_STAGES + ? LOG_PIPELINE_INGRESS_LEN == SWITCH_IN_N_STAGES + : LOG_PIPELINE_INGRESS_LEN == ROUTER_IN_N_STAGES +); + +BUILD_ASSERT_DECL( + (size_t) SWITCH_OUT_N_STAGES > (size_t) ROUTER_OUT_N_STAGES + ? LOG_PIPELINE_EGRESS_LEN == SWITCH_OUT_N_STAGES + : LOG_PIPELINE_EGRESS_LEN == ROUTER_OUT_N_STAGES +); + +BUILD_ASSERT_DECL( + LOG_PIPELINE_EGRESS_LEN == SWITCH_OUT_N_STAGES || + LOG_PIPELINE_EGRESS_LEN == ROUTER_OUT_N_STAGES); + bool ovn_stage_equal(const struct ovn_stage *a, const struct ovn_stage *b) { diff --git a/northd/northd.h b/northd/northd.h index f713017b58..a895345f50 100644 --- a/northd/northd.h +++ b/northd/northd.h @@ -509,8 +509,14 @@ ls_has_localnet_port(const struct ovn_datapath *od) } /* Pipeline stages. */ -#define PIPELINE_STAGES \ - /* Logical switch ingress stages. */ \ +#define PIPELINE_STAGES \ + SWITCH_IN_PIPELINE_STAGES \ + SWITCH_OUT_PIPELINE_STAGES \ + ROUTER_IN_PIPELINE_STAGES \ + ROUTER_OUT_PIPELINE_STAGES + +/* Logical switch ingress stages. */ +#define SWITCH_IN_PIPELINE_STAGES \ PIPELINE_STAGE(SWITCH, IN, CHECK_PORT_SEC, 0, "ls_in_check_port_sec") \ PIPELINE_STAGE(SWITCH, IN, APPLY_PORT_SEC, 1, "ls_in_apply_port_sec") \ PIPELINE_STAGE(SWITCH, IN, MIRROR, 2, "ls_in_mirror") \ @@ -550,9 +556,10 @@ ls_has_localnet_port(const struct ovn_datapath *od) PIPELINE_STAGE(SWITCH, IN, DNS_RESPONSE, 31, "ls_in_dns_response") \ PIPELINE_STAGE(SWITCH, IN, EXTERNAL_PORT, 32, "ls_in_external_port") \ PIPELINE_STAGE(SWITCH, IN, L2_LKUP, 33, "ls_in_l2_lkup") \ - PIPELINE_STAGE(SWITCH, IN, L2_UNKNOWN, 34, "ls_in_l2_unknown") \ - \ - /* Logical switch egress stages. */ \ + PIPELINE_STAGE(SWITCH, IN, L2_UNKNOWN, 34, "ls_in_l2_unknown") + +/* Logical switch egress stages. */ +#define SWITCH_OUT_PIPELINE_STAGES \ PIPELINE_STAGE(SWITCH, OUT, LOOKUP_FDB, 0, "ls_out_lookup_fdb") \ PIPELINE_STAGE(SWITCH, OUT, PUT_FDB, 1, "ls_out_put_fdb") \ PIPELINE_STAGE(SWITCH, OUT, PRE_ACL, 2, "ls_out_pre_acl") \ @@ -570,9 +577,10 @@ ls_has_localnet_port(const struct ovn_datapath *od) PIPELINE_STAGE(SWITCH, OUT, NF, 13, \ "ls_out_network_function") \ PIPELINE_STAGE(SWITCH, OUT, CHECK_PORT_SEC, 14, "ls_out_check_port_sec") \ - PIPELINE_STAGE(SWITCH, OUT, APPLY_PORT_SEC, 15, "ls_out_apply_port_sec") \ - \ - /* Logical router ingress stages. */ \ + PIPELINE_STAGE(SWITCH, OUT, APPLY_PORT_SEC, 15, "ls_out_apply_port_sec") + +/* Logical router ingress stages. */ +#define ROUTER_IN_PIPELINE_STAGES \ PIPELINE_STAGE(ROUTER, IN, ADMISSION, 0, "lr_in_admission") \ PIPELINE_STAGE(ROUTER, IN, LOOKUP_NEIGHBOR, 1, "lr_in_lookup_neighbor") \ PIPELINE_STAGE(ROUTER, IN, LEARN_NEIGHBOR, 2, "lr_in_learn_neighbor") \ @@ -604,9 +612,10 @@ ls_has_localnet_port(const struct ovn_datapath *od) PIPELINE_STAGE(ROUTER, IN, NETWORK_ID, 26, "lr_in_network_id") \ PIPELINE_STAGE(ROUTER, IN, ARP_REQUEST, 27, "lr_in_arp_request") \ PIPELINE_STAGE(ROUTER, IN, ECMP_STATEFUL_EGR, 28, \ - "lr_in_ecmp_stateful_egr") \ - \ - /* Logical router egress stages. */ \ + "lr_in_ecmp_stateful_egr") + +/* Logical router egress stages. */ +#define ROUTER_OUT_PIPELINE_STAGES \ PIPELINE_STAGE(ROUTER, OUT, CHECK_DNAT_LOCAL, 0, \ "lr_out_chk_dnat_local") \ PIPELINE_STAGE(ROUTER, OUT, UNDNAT, 1, "lr_out_undnat") \ -- 2.54.0 _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
