With the exception of two (pflow_output and lflow_output in ovn-controller), every engine_node in OVN uses the stringified form of the engine_node struct name as its NAME_STR argument.
At this point, it's clear that this NAME_STR argument is redundant, so we may as well remove it and shrink the code down by a bit. A positive side effect of this change is that it takes the guesswork out of searching for an engine node input by name. The exception to this rule is the DB-related nodes. They still differentiate between the engine node struct name (e.g. "sb_chassis") and the engine node name string (e.g. "SB_chassis"). This isn't strictly necessary, but keeping it this way makes the diff much much smaller :) Signed-off-by: Mark Michelson <mmich...@redhat.com> --- controller/ovn-controller.c | 126 ++++++++++++++--------------- lib/inc-proc-eng.h | 23 +++--- northd/inc-proc-northd.c | 155 ++++++++++++++++++------------------ tests/ovn-controller.at | 6 +- 4 files changed, 155 insertions(+), 155 deletions(-) diff --git a/controller/ovn-controller.c b/controller/ovn-controller.c index 80e6b2b3f..e70aaec7b 100644 --- a/controller/ovn-controller.c +++ b/controller/ovn-controller.c @@ -976,56 +976,56 @@ ctrl_register_ovs_idl(struct ovsdb_idl *ovs_idl) } #define SB_NODES \ - SB_NODE(sb_global, "sb_global") \ - SB_NODE(chassis, "chassis") \ - SB_NODE(ha_chassis_group, "ha_chassis_group") \ - SB_NODE(encap, "encap") \ - SB_NODE(address_set, "address_set") \ - SB_NODE(port_group, "port_group") \ - SB_NODE(multicast_group, "multicast_group") \ - SB_NODE(datapath_binding, "datapath_binding") \ - SB_NODE(logical_dp_group, "logical_dp_group") \ - SB_NODE(port_binding, "port_binding") \ - SB_NODE(mac_binding, "mac_binding") \ - SB_NODE(logical_flow, "logical_flow") \ - SB_NODE(dhcp_options, "dhcp_options") \ - SB_NODE(dhcpv6_options, "dhcpv6_options") \ - SB_NODE(dns, "dns") \ - SB_NODE(load_balancer, "load_balancer") \ - SB_NODE(fdb, "fdb") \ - SB_NODE(meter, "meter") \ - SB_NODE(static_mac_binding, "static_mac_binding") \ - SB_NODE(chassis_template_var, "chassis_template_var") \ - SB_NODE(acl_id, "acl_id") \ - SB_NODE(advertised_route, "advertised_route") \ - SB_NODE(learned_route, "learned_route") + SB_NODE(sb_global) \ + SB_NODE(chassis) \ + SB_NODE(ha_chassis_group) \ + SB_NODE(encap) \ + SB_NODE(address_set) \ + SB_NODE(port_group) \ + SB_NODE(multicast_group) \ + SB_NODE(datapath_binding) \ + SB_NODE(logical_dp_group) \ + SB_NODE(port_binding) \ + SB_NODE(mac_binding) \ + SB_NODE(logical_flow) \ + SB_NODE(dhcp_options) \ + SB_NODE(dhcpv6_options) \ + SB_NODE(dns) \ + SB_NODE(load_balancer) \ + SB_NODE(fdb) \ + SB_NODE(meter) \ + SB_NODE(static_mac_binding) \ + SB_NODE(chassis_template_var) \ + SB_NODE(acl_id) \ + SB_NODE(advertised_route) \ + SB_NODE(learned_route) enum sb_engine_node { -#define SB_NODE(NAME, NAME_STR) SB_##NAME, +#define SB_NODE(NAME) SB_##NAME, SB_NODES #undef SB_NODE }; -#define SB_NODE(NAME, NAME_STR) ENGINE_FUNC_SB(NAME); +#define SB_NODE(NAME) ENGINE_FUNC_SB(NAME); SB_NODES #undef SB_NODE #define OVS_NODES \ - OVS_NODE(open_vswitch, "open_vswitch") \ - OVS_NODE(bridge, "bridge") \ - OVS_NODE(port, "port") \ - OVS_NODE(interface, "interface") \ - OVS_NODE(qos, "qos") \ - OVS_NODE(queue, "queue") \ - OVS_NODE(flow_sample_collector_set, "flow_sample_collector_set") + OVS_NODE(open_vswitch) \ + OVS_NODE(bridge) \ + OVS_NODE(port) \ + OVS_NODE(interface) \ + OVS_NODE(qos) \ + OVS_NODE(queue) \ + OVS_NODE(flow_sample_collector_set) enum ovs_engine_node { -#define OVS_NODE(NAME, NAME_STR) OVS_##NAME, +#define OVS_NODE(NAME) OVS_##NAME, OVS_NODES #undef OVS_NODE }; -#define OVS_NODE(NAME, NAME_STR) ENGINE_FUNC_OVS(NAME); +#define OVS_NODE(NAME) ENGINE_FUNC_OVS(NAME); OVS_NODES #undef OVS_NODE @@ -5597,38 +5597,38 @@ main(int argc, char *argv[]) stopwatch_create(VIF_PLUG_RUN_STOPWATCH_NAME, SW_MS); /* Define inc-proc-engine nodes. */ - ENGINE_NODE(sb_ro, "sb_ro"); - ENGINE_NODE(template_vars, "template_vars", CLEAR_TRACKED_DATA); - ENGINE_NODE(ct_zones, "ct_zones", CLEAR_TRACKED_DATA, IS_VALID); - ENGINE_NODE(ovs_interface_shadow, "ovs_interface_shadow", CLEAR_TRACKED_DATA); - ENGINE_NODE(runtime_data, "runtime_data", CLEAR_TRACKED_DATA); - ENGINE_NODE(non_vif_data, "non_vif_data"); - ENGINE_NODE(mff_ovn_geneve, "mff_ovn_geneve"); - ENGINE_NODE(ofctrl_is_connected, "ofctrl_is_connected"); - ENGINE_NODE(activated_ports, "activated_ports", CLEAR_TRACKED_DATA); - ENGINE_NODE(postponed_ports, "postponed_ports"); - ENGINE_NODE(pflow_output, "physical_flow_output"); - ENGINE_NODE(lflow_output, "logical_flow_output", CLEAR_TRACKED_DATA); - ENGINE_NODE(controller_output, "controller_output"); - ENGINE_NODE(addr_sets, "addr_sets", CLEAR_TRACKED_DATA); - ENGINE_NODE(port_groups, "port_groups", CLEAR_TRACKED_DATA); - ENGINE_NODE(northd_options, "northd_options"); - ENGINE_NODE(dhcp_options, "dhcp_options"); - ENGINE_NODE(if_status_mgr, "if_status_mgr"); - ENGINE_NODE(lb_data, "lb_data", CLEAR_TRACKED_DATA); - ENGINE_NODE(mac_cache, "mac_cache"); - ENGINE_NODE(bfd_chassis, "bfd_chassis"); - ENGINE_NODE(dns_cache, "dns_cache"); - ENGINE_NODE(acl_id, "acl_id", IS_VALID); - ENGINE_NODE(route, "route"); - ENGINE_NODE(route_table_notify, "route_table_notify"); - ENGINE_NODE(route_exchange, "route_exchange"); - -#define SB_NODE(NAME, NAME_STR) ENGINE_NODE_SB(NAME, NAME_STR); + ENGINE_NODE(sb_ro); + ENGINE_NODE(template_vars, CLEAR_TRACKED_DATA); + ENGINE_NODE(ct_zones, CLEAR_TRACKED_DATA, IS_VALID); + ENGINE_NODE(ovs_interface_shadow, CLEAR_TRACKED_DATA); + ENGINE_NODE(runtime_data, CLEAR_TRACKED_DATA); + ENGINE_NODE(non_vif_data); + ENGINE_NODE(mff_ovn_geneve); + ENGINE_NODE(ofctrl_is_connected); + ENGINE_NODE(activated_ports, CLEAR_TRACKED_DATA); + ENGINE_NODE(postponed_ports); + ENGINE_NODE(pflow_output); + ENGINE_NODE(lflow_output, CLEAR_TRACKED_DATA); + ENGINE_NODE(controller_output); + ENGINE_NODE(addr_sets, CLEAR_TRACKED_DATA); + ENGINE_NODE(port_groups, CLEAR_TRACKED_DATA); + ENGINE_NODE(northd_options); + ENGINE_NODE(dhcp_options); + ENGINE_NODE(if_status_mgr); + ENGINE_NODE(lb_data, CLEAR_TRACKED_DATA); + ENGINE_NODE(mac_cache); + ENGINE_NODE(bfd_chassis); + ENGINE_NODE(dns_cache); + ENGINE_NODE(acl_id, IS_VALID); + ENGINE_NODE(route); + ENGINE_NODE(route_table_notify); + ENGINE_NODE(route_exchange); + +#define SB_NODE(NAME) ENGINE_NODE_SB(NAME); SB_NODES #undef SB_NODE -#define OVS_NODE(NAME, NAME_STR) ENGINE_NODE_OVS(NAME, NAME_STR); +#define OVS_NODE(NAME) ENGINE_NODE_OVS(NAME); OVS_NODES #undef OVS_NODE diff --git a/lib/inc-proc-eng.h b/lib/inc-proc-eng.h index e4c71d773..49d6f7359 100644 --- a/lib/inc-proc-eng.h +++ b/lib/inc-proc-eng.h @@ -408,8 +408,8 @@ void engine_ovsdb_node_add_index(struct engine_node *, const char *name, #define ENGINE_NODE_DEF_END }; -#define ENGINE_NODE2(NAME, NAME_STR) \ - ENGINE_NODE_DEF_START(NAME, NAME_STR) \ +#define ENGINE_NODE1(NAME) \ + ENGINE_NODE_DEF_START(NAME, #NAME) \ ENGINE_NODE_DEF_END #define CLEAR_TRACKED_DATA(NAME) \ @@ -418,12 +418,12 @@ void engine_ovsdb_node_add_index(struct engine_node *, const char *name, #define IS_VALID(NAME) \ .is_valid = en_##NAME##_is_valid -#define ENGINE_NODE3(NAME, NAME_STR, ARG1) \ +#define ENGINE_NODE2(NAME, ARG1) \ ENGINE_NODE_DEF_START(NAME, #NAME) \ ARG1(NAME), \ ENGINE_NODE_DEF_END -#define ENGINE_NODE4(NAME, NAME_STR, ARG1, ARG2) \ +#define ENGINE_NODE3(NAME, ARG1, ARG2) \ ENGINE_NODE_DEF_START(NAME, #NAME) \ ARG1(NAME), \ ARG2(NAME), \ @@ -476,19 +476,20 @@ static void en_##DB_NAME##_##TBL_NAME##_cleanup(void *data OVS_UNUSED) \ /* Macro to define an engine node which represents a table of OVSDB */ #define ENGINE_NODE_OVSDB(DB_NAME, DB_NAME_STR, TBL_NAME, TBL_NAME_STR) \ - ENGINE_NODE(DB_NAME##_##TBL_NAME, DB_NAME_STR"_"TBL_NAME_STR) + ENGINE_NODE_DEF_START(DB_NAME##_##TBL_NAME, DB_NAME_STR"_"TBL_NAME_STR) \ + ENGINE_NODE_DEF_END /* Macro to define an engine node which represents a table of OVN SB DB */ -#define ENGINE_NODE_SB(TBL_NAME, TBL_NAME_STR) \ - ENGINE_NODE_OVSDB(sb, "SB", TBL_NAME, TBL_NAME_STR); +#define ENGINE_NODE_SB(TBL_NAME) \ + ENGINE_NODE_OVSDB(sb, "SB", TBL_NAME, #TBL_NAME); /* Macro to define an engine node which represents a table of OVN NB DB */ -#define ENGINE_NODE_NB(TBL_NAME, TBL_NAME_STR) \ - ENGINE_NODE_OVSDB(nb, "NB", TBL_NAME, TBL_NAME_STR); +#define ENGINE_NODE_NB(TBL_NAME) \ + ENGINE_NODE_OVSDB(nb, "NB", TBL_NAME, #TBL_NAME); /* Macro to define an engine node which represents a table of open_vswitch * DB */ -#define ENGINE_NODE_OVS(TBL_NAME, TBL_NAME_STR) \ - ENGINE_NODE_OVSDB(ovs, "OVS", TBL_NAME, TBL_NAME_STR); +#define ENGINE_NODE_OVS(TBL_NAME) \ + ENGINE_NODE_OVSDB(ovs, "OVS", TBL_NAME, #TBL_NAME); #endif /* lib/inc-proc-eng.h */ diff --git a/northd/inc-proc-northd.c b/northd/inc-proc-northd.c index 823593e7e..6683cc311 100644 --- a/northd/inc-proc-northd.c +++ b/northd/inc-proc-northd.c @@ -55,23 +55,23 @@ VLOG_DEFINE_THIS_MODULE(inc_proc_northd); static unixctl_cb_func chassis_features_list; #define NB_NODES \ - NB_NODE(nb_global, "nb_global") \ - NB_NODE(logical_switch, "logical_switch") \ - NB_NODE(address_set, "address_set") \ - NB_NODE(port_group, "port_group") \ - NB_NODE(load_balancer, "load_balancer") \ - NB_NODE(load_balancer_group, "load_balancer_group") \ - NB_NODE(acl, "acl") \ - NB_NODE(logical_router, "logical_router") \ - NB_NODE(mirror, "mirror") \ - NB_NODE(meter, "meter") \ - NB_NODE(bfd, "bfd") \ - NB_NODE(static_mac_binding, "static_mac_binding") \ - NB_NODE(chassis_template_var, "chassis_template_var") \ - NB_NODE(sampling_app, "sampling_app") + NB_NODE(nb_global) \ + NB_NODE(logical_switch) \ + NB_NODE(address_set) \ + NB_NODE(port_group) \ + NB_NODE(load_balancer) \ + NB_NODE(load_balancer_group) \ + NB_NODE(acl) \ + NB_NODE(logical_router) \ + NB_NODE(mirror) \ + NB_NODE(meter) \ + NB_NODE(bfd) \ + NB_NODE(static_mac_binding) \ + NB_NODE(chassis_template_var) \ + NB_NODE(sampling_app) enum nb_engine_node { -#define NB_NODE(NAME, NAME_STR) NB_##NAME, +#define NB_NODE(NAME) NB_##NAME, NB_NODES #undef NB_NODE }; @@ -82,40 +82,40 @@ static unixctl_cb_func chassis_features_list; * en_nb_<TABLE_NAME>_init() * en_nb_<TABLE_NAME>_cleanup() */ -#define NB_NODE(NAME, NAME_STR) ENGINE_FUNC_NB(NAME); +#define NB_NODE(NAME) ENGINE_FUNC_NB(NAME); NB_NODES #undef NB_NODE #define SB_NODES \ - SB_NODE(sb_global, "sb_global") \ - SB_NODE(chassis, "chassis") \ - SB_NODE(address_set, "address_set") \ - SB_NODE(port_group, "port_group") \ - SB_NODE(logical_flow, "logical_flow") \ - SB_NODE(multicast_group, "multicast_group") \ - SB_NODE(mirror, "mirror") \ - SB_NODE(meter, "meter") \ - SB_NODE(datapath_binding, "datapath_binding") \ - SB_NODE(port_binding, "port_binding") \ - SB_NODE(mac_binding, "mac_binding") \ - SB_NODE(dns, "dns") \ - SB_NODE(ha_chassis_group, "ha_chassis_group") \ - SB_NODE(ip_multicast, "ip_multicast") \ - SB_NODE(igmp_group, "igmp_group") \ - SB_NODE(service_monitor, "service_monitor") \ - SB_NODE(load_balancer, "load_balancer") \ - SB_NODE(bfd, "bfd") \ - SB_NODE(fdb, "fdb") \ - SB_NODE(static_mac_binding, "static_mac_binding") \ - SB_NODE(chassis_template_var, "chassis_template_var") \ - SB_NODE(logical_dp_group, "logical_dp_group") \ - SB_NODE(ecmp_nexthop, "ecmp_nexthop") \ - SB_NODE(acl_id, "acl_id") \ - SB_NODE(advertised_route, "advertised_route") \ - SB_NODE(learned_route, "learned_route") + SB_NODE(sb_global) \ + SB_NODE(chassis) \ + SB_NODE(address_set) \ + SB_NODE(port_group) \ + SB_NODE(logical_flow) \ + SB_NODE(multicast_group) \ + SB_NODE(mirror) \ + SB_NODE(meter) \ + SB_NODE(datapath_binding) \ + SB_NODE(port_binding) \ + SB_NODE(mac_binding) \ + SB_NODE(dns) \ + SB_NODE(ha_chassis_group) \ + SB_NODE(ip_multicast) \ + SB_NODE(igmp_group) \ + SB_NODE(service_monitor) \ + SB_NODE(load_balancer) \ + SB_NODE(bfd) \ + SB_NODE(fdb) \ + SB_NODE(static_mac_binding) \ + SB_NODE(chassis_template_var) \ + SB_NODE(logical_dp_group) \ + SB_NODE(ecmp_nexthop) \ + SB_NODE(acl_id) \ + SB_NODE(advertised_route) \ + SB_NODE(learned_route) enum sb_engine_node { -#define SB_NODE(NAME, NAME_STR) SB_##NAME, +#define SB_NODE(NAME) SB_##NAME, SB_NODES #undef SB_NODE }; @@ -126,7 +126,7 @@ enum sb_engine_node { * en_sb_<TABLE_NAME>_init() * en_sb_<TABLE_NAME>_cleanup() */ -#define SB_NODE(NAME, NAME_STR) ENGINE_FUNC_SB(NAME); +#define SB_NODE(NAME) ENGINE_FUNC_SB(NAME); SB_NODES #undef SB_NODE @@ -137,48 +137,47 @@ enum sb_engine_node { * * Define nodes as static to avoid sparse errors. */ -#define NB_NODE(NAME, NAME_STR) static ENGINE_NODE_NB(NAME, NAME_STR); +#define NB_NODE(NAME) static ENGINE_NODE_NB(NAME); NB_NODES #undef NB_NODE -#define SB_NODE(NAME, NAME_STR) static ENGINE_NODE_SB(NAME, NAME_STR); +#define SB_NODE(NAME) static ENGINE_NODE_SB(NAME); SB_NODES #undef SB_NODE /* Define engine nodes for other nodes. They should be defined as static to * avoid sparse errors. */ -static ENGINE_NODE(northd, "northd", CLEAR_TRACKED_DATA); -static ENGINE_NODE(sync_from_sb, "sync_from_sb"); -static ENGINE_NODE(sampling_app, "sampling_app"); -static ENGINE_NODE(lflow, "lflow"); -static ENGINE_NODE(mac_binding_aging, "mac_binding_aging"); -static ENGINE_NODE(mac_binding_aging_waker, "mac_binding_aging_waker"); -static ENGINE_NODE(northd_output, "northd_output"); -static ENGINE_NODE(sync_meters, "sync_meters"); -static ENGINE_NODE(sync_to_sb, "sync_to_sb"); -static ENGINE_NODE(sync_to_sb_addr_set, "sync_to_sb_addr_set"); -static ENGINE_NODE(port_group, "port_group", CLEAR_TRACKED_DATA); -static ENGINE_NODE(fdb_aging, "fdb_aging"); -static ENGINE_NODE(fdb_aging_waker, "fdb_aging_waker"); -static ENGINE_NODE(sync_to_sb_lb, "sync_to_sb_lb"); -static ENGINE_NODE(sync_to_sb_pb, "sync_to_sb_pb"); -static ENGINE_NODE(global_config, "global_config", CLEAR_TRACKED_DATA); -static ENGINE_NODE(lb_data, "lb_data", CLEAR_TRACKED_DATA); -static ENGINE_NODE(lr_nat, "lr_nat", CLEAR_TRACKED_DATA); -static ENGINE_NODE(lr_stateful, "lr_stateful", CLEAR_TRACKED_DATA); -static ENGINE_NODE(ls_stateful, "ls_stateful", CLEAR_TRACKED_DATA); -static ENGINE_NODE(route_policies, "route_policies"); -static ENGINE_NODE(routes, "routes"); -static ENGINE_NODE(bfd, "bfd"); -static ENGINE_NODE(bfd_sync, "bfd_sync"); -static ENGINE_NODE(ecmp_nexthop, "ecmp_nexthop"); -static ENGINE_NODE(multicast_igmp, "multicast_igmp"); -static ENGINE_NODE(acl_id, "acl_id"); -static ENGINE_NODE(advertised_route_sync, "advertised_route_sync"); -static ENGINE_NODE(learned_route_sync, "learned_route_sync", - CLEAR_TRACKED_DATA); -static ENGINE_NODE(dynamic_routes, "dynamic_routes"); -static ENGINE_NODE(group_ecmp_route, "group_ecmp_route", CLEAR_TRACKED_DATA); +static ENGINE_NODE(northd, CLEAR_TRACKED_DATA); +static ENGINE_NODE(sync_from_sb); +static ENGINE_NODE(sampling_app); +static ENGINE_NODE(lflow); +static ENGINE_NODE(mac_binding_aging); +static ENGINE_NODE(mac_binding_aging_waker); +static ENGINE_NODE(northd_output); +static ENGINE_NODE(sync_meters); +static ENGINE_NODE(sync_to_sb); +static ENGINE_NODE(sync_to_sb_addr_set); +static ENGINE_NODE(port_group, CLEAR_TRACKED_DATA); +static ENGINE_NODE(fdb_aging); +static ENGINE_NODE(fdb_aging_waker); +static ENGINE_NODE(sync_to_sb_lb); +static ENGINE_NODE(sync_to_sb_pb); +static ENGINE_NODE(global_config, CLEAR_TRACKED_DATA); +static ENGINE_NODE(lb_data, CLEAR_TRACKED_DATA); +static ENGINE_NODE(lr_nat, CLEAR_TRACKED_DATA); +static ENGINE_NODE(lr_stateful, CLEAR_TRACKED_DATA); +static ENGINE_NODE(ls_stateful, CLEAR_TRACKED_DATA); +static ENGINE_NODE(route_policies); +static ENGINE_NODE(routes); +static ENGINE_NODE(bfd); +static ENGINE_NODE(bfd_sync); +static ENGINE_NODE(ecmp_nexthop); +static ENGINE_NODE(multicast_igmp); +static ENGINE_NODE(acl_id); +static ENGINE_NODE(advertised_route_sync); +static ENGINE_NODE(learned_route_sync, CLEAR_TRACKED_DATA); +static ENGINE_NODE(dynamic_routes); +static ENGINE_NODE(group_ecmp_route, CLEAR_TRACKED_DATA); void inc_proc_northd_init(struct ovsdb_idl_loop *nb, struct ovsdb_idl_loop *sb) diff --git a/tests/ovn-controller.at b/tests/ovn-controller.at index fdd574c20..33656f68c 100644 --- a/tests/ovn-controller.at +++ b/tests/ovn-controller.at @@ -10,7 +10,7 @@ m4_divert_push([PREPARE_TESTS]) # 4th argument is the expected compute state. # Possible values are - "nocompute" and "compute". # -# Eg. 'check_controller_engine_stats hv1 logical_flow_output recompute nocompute' +# Eg. 'check_controller_engine_stats hv1 lflow_output recompute nocompute' # will verify that if the lflow engine node recompute stat is > 0 and # compute stat is equal to 0. It fails otherwise. check_controller_engine_stats() { @@ -24,7 +24,7 @@ $recompute : compute - $compute" node_stat=$(as $hv ovn-appctl -t ovn-controller inc-engine/show-stats $node) # node_stat will be of this format : - # - Node: logical_flow_output - recompute: 3 - compute: 0 - cancel: 0 + # - Node: lflow_output - recompute: 3 - compute: 0 - cancel: 0 node_recompute_ct=$(echo $node_stat | cut -d '-' -f2 | cut -d ':' -f2) node_compute_ct=$(echo $node_stat | cut -d '-' -f3 | cut -d ':' -f2) @@ -1014,7 +1014,7 @@ OVS_WAIT_UNTIL([as hv1 ovs-ofctl dump-flows br-int | grep table=OFTABLE_LOCAL_OU # Check we have a full recompute if type column is updated check as hv1 ovn-appctl -t ovn-controller inc-engine/clear-stats check ovn-nbctl --wait=hv lsp-set-type ls0-rp localnet -check_controller_engine_stats hv1 physical_flow_output recompute nocompute +check_controller_engine_stats hv1 pflow_output recompute nocompute OVN_CLEANUP([hv1]) AT_CLEANUP -- 2.47.0 _______________________________________________ dev mailing list d...@openvswitch.org https://mail.openvswitch.org/mailman/listinfo/ovs-dev