[ovs-dev] [PATCH 1/5] ovn-controller: Style fixes.

Ben Pfaff blp at ovn.org
Fri Jun 8 21:59:18 UTC 2018


The OVS coding style says that input parameters should come first,
followed by output parameters.  This changes a few functions in
ovn-controller to fit this style.  It also marks a number of input
parameters 'const', for clarity.

Signed-off-by: Ben Pfaff <blp at ovn.org>
---
 ovn/controller/bfd.c            | 10 ++++-----
 ovn/controller/bfd.h            |  2 +-
 ovn/controller/binding.c        |  4 ++--
 ovn/controller/binding.h        |  3 ++-
 ovn/controller/lflow.c          | 48 ++++++++++++++++++++---------------------
 ovn/controller/lflow.h          |  8 +++----
 ovn/controller/ovn-controller.c | 11 +++++-----
 ovn/controller/physical.c       | 21 +++++++++---------
 ovn/controller/physical.h       |  7 +++---
 ovn/controller/pinctrl.c        | 28 +++++++++++++-----------
 ovn/controller/pinctrl.h        |  5 +++--
 11 files changed, 76 insertions(+), 71 deletions(-)

diff --git a/ovn/controller/bfd.c b/ovn/controller/bfd.c
index 8f020d597083..6fc83554c9b0 100644
--- a/ovn/controller/bfd.c
+++ b/ovn/controller/bfd.c
@@ -102,11 +102,11 @@ bfd_calculate_active_tunnels(const struct ovsrec_bridge *br_int,
 
 struct local_datapath_node {
     struct ovs_list node;
-    struct local_datapath *dp;
+    const struct local_datapath *dp;
 };
 
 static void
-bfd_travel_gw_related_chassis(struct local_datapath *dp,
+bfd_travel_gw_related_chassis(const struct local_datapath *dp,
                               const struct hmap *local_datapaths,
                               struct ovsdb_idl_index_cursor *cursor,
                               struct sbrec_port_binding *lpval,
@@ -185,7 +185,7 @@ bfd_travel_gw_related_chassis(struct local_datapath *dp,
 static void
 bfd_calculate_chassis(struct controller_ctx *ctx,
                       const struct sbrec_chassis *our_chassis,
-                      struct hmap *local_datapaths,
+                      const struct hmap *local_datapaths,
                       const struct chassis_index *chassis_index,
                       struct sset *bfd_chassis)
 {
@@ -199,7 +199,7 @@ bfd_calculate_chassis(struct controller_ctx *ctx,
     const struct sbrec_port_binding *pb;
     struct ovsdb_idl_index_cursor cursor;
     struct sbrec_port_binding *lpval;
-    struct local_datapath *dp;
+    const struct local_datapath *dp;
 
     ovsdb_idl_initialize_cursor(ctx->ovnsb_idl,
                                 &sbrec_table_port_binding,
@@ -247,7 +247,7 @@ bfd_calculate_chassis(struct controller_ctx *ctx,
 
 void
 bfd_run(struct controller_ctx *ctx, const struct ovsrec_bridge *br_int,
-        const struct sbrec_chassis *chassis_rec, struct hmap *local_datapaths,
+        const struct sbrec_chassis *chassis_rec, const struct hmap *local_datapaths,
         const struct chassis_index *chassis_index)
 {
 
diff --git a/ovn/controller/bfd.h b/ovn/controller/bfd.h
index 91d0d9123167..7fa4775654dd 100644
--- a/ovn/controller/bfd.h
+++ b/ovn/controller/bfd.h
@@ -27,7 +27,7 @@ struct sset;
 void bfd_register_ovs_idl(struct ovsdb_idl *);
 void bfd_run(struct controller_ctx *ctx, const struct ovsrec_bridge *br_int,
              const struct sbrec_chassis *chassis_rec,
-             struct hmap *local_datapaths, const struct chassis_index *);
+             const struct hmap *local_datapaths, const struct chassis_index *);
 void  bfd_calculate_active_tunnels(const struct ovsrec_bridge *br_int,
                                    struct sset *active_tunnels);
 
diff --git a/ovn/controller/binding.c b/ovn/controller/binding.c
index 0785a9496258..3ee1f6739247 100644
--- a/ovn/controller/binding.c
+++ b/ovn/controller/binding.c
@@ -384,7 +384,7 @@ update_local_lport_ids(struct sset *local_lport_ids,
 static void
 consider_local_datapath(struct controller_ctx *ctx,
                         const struct chassis_index *chassis_index,
-                        struct sset *active_tunnels,
+                        const struct sset *active_tunnels,
                         const struct sbrec_chassis *chassis_rec,
                         const struct sbrec_port_binding *binding_rec,
                         struct hmap *qos_map,
@@ -527,7 +527,7 @@ void
 binding_run(struct controller_ctx *ctx, const struct ovsrec_bridge *br_int,
             const struct sbrec_chassis *chassis_rec,
             const struct chassis_index *chassis_index,
-            struct sset *active_tunnels,
+            const struct sset *active_tunnels,
             struct hmap *local_datapaths, struct sset *local_lports,
             struct sset *local_lport_ids)
 {
diff --git a/ovn/controller/binding.h b/ovn/controller/binding.h
index 89fc2ec8f76f..eb4c024c0e37 100644
--- a/ovn/controller/binding.h
+++ b/ovn/controller/binding.h
@@ -31,7 +31,8 @@ void binding_register_ovs_idl(struct ovsdb_idl *);
 void binding_run(struct controller_ctx *, const struct ovsrec_bridge *br_int,
                  const struct sbrec_chassis *,
                  const struct chassis_index *,
-                 struct sset *active_tunnels, struct hmap *local_datapaths,
+                 const struct sset *active_tunnels,
+                 struct hmap *local_datapaths,
                  struct sset *local_lports, struct sset *local_lport_ids);
 bool binding_cleanup(struct controller_ctx *, const struct sbrec_chassis *);
 
diff --git a/ovn/controller/lflow.c b/ovn/controller/lflow.c
index d09fd107298b..db96197828aa 100644
--- a/ovn/controller/lflow.c
+++ b/ovn/controller/lflow.c
@@ -65,8 +65,6 @@ static void consider_logical_flow(struct controller_ctx *ctx,
                                   const struct chassis_index *chassis_index,
                                   const struct sbrec_logical_flow *lflow,
                                   const struct hmap *local_datapaths,
-                                  struct ovn_extend_table *group_table,
-                                  struct ovn_extend_table *meter_table,
                                   const struct sbrec_chassis *chassis,
                                   struct hmap *dhcp_opts,
                                   struct hmap *dhcpv6_opts,
@@ -74,9 +72,11 @@ static void consider_logical_flow(struct controller_ctx *ctx,
                                   uint32_t *conj_id_ofs,
                                   const struct shash *addr_sets,
                                   const struct shash *port_groups,
+                                  const struct sset *active_tunnels,
+                                  const struct sset *local_lport_ids,
                                   struct hmap *flow_table,
-                                  struct sset *active_tunnels,
-                                  struct sset *local_lport_ids);
+                                  struct ovn_extend_table *group_table,
+                                  struct ovn_extend_table *meter_table);
 
 static bool
 lookup_port_cb(const void *aux_, const char *port_name, unsigned int *portp)
@@ -140,14 +140,14 @@ static void
 add_logical_flows(struct controller_ctx *ctx,
                   const struct chassis_index *chassis_index,
                   const struct hmap *local_datapaths,
-                  struct ovn_extend_table *group_table,
-                  struct ovn_extend_table *meter_table,
                   const struct sbrec_chassis *chassis,
                   const struct shash *addr_sets,
                   const struct shash *port_groups,
+                  const struct sset *active_tunnels,
+                  const struct sset *local_lport_ids,
                   struct hmap *flow_table,
-                  struct sset *active_tunnels,
-                  struct sset *local_lport_ids)
+                  struct ovn_extend_table *group_table,
+                  struct ovn_extend_table *meter_table)
 {
     uint32_t conj_id_ofs = 1;
     const struct sbrec_logical_flow *lflow;
@@ -171,12 +171,11 @@ add_logical_flows(struct controller_ctx *ctx,
     nd_ra_opts_init(&nd_ra_opts);
 
     SBREC_LOGICAL_FLOW_FOR_EACH (lflow, ctx->ovnsb_idl) {
-        consider_logical_flow(ctx, chassis_index,
-                              lflow, local_datapaths,
-                              group_table, meter_table, chassis,
-                              &dhcp_opts, &dhcpv6_opts, &nd_ra_opts,
+        consider_logical_flow(ctx, chassis_index, lflow, local_datapaths,
+                              chassis, &dhcp_opts, &dhcpv6_opts, &nd_ra_opts,
                               &conj_id_ofs, addr_sets, port_groups,
-                              flow_table, active_tunnels, local_lport_ids);
+                              active_tunnels, local_lport_ids,
+                              flow_table, group_table, meter_table);
     }
 
     dhcp_opts_destroy(&dhcp_opts);
@@ -189,8 +188,6 @@ consider_logical_flow(struct controller_ctx *ctx,
                       const struct chassis_index *chassis_index,
                       const struct sbrec_logical_flow *lflow,
                       const struct hmap *local_datapaths,
-                      struct ovn_extend_table *group_table,
-                      struct ovn_extend_table *meter_table,
                       const struct sbrec_chassis *chassis,
                       struct hmap *dhcp_opts,
                       struct hmap *dhcpv6_opts,
@@ -198,9 +195,11 @@ consider_logical_flow(struct controller_ctx *ctx,
                       uint32_t *conj_id_ofs,
                       const struct shash *addr_sets,
                       const struct shash *port_groups,
+                      const struct sset *active_tunnels,
+                      const struct sset *local_lport_ids,
                       struct hmap *flow_table,
-                      struct sset *active_tunnels,
-                      struct sset *local_lport_ids)
+                      struct ovn_extend_table *group_table,
+                      struct ovn_extend_table *meter_table)
 {
     /* Determine translation of logical table IDs to physical table IDs. */
     bool ingress = !strcmp(lflow->pipeline, "ingress");
@@ -444,20 +443,19 @@ lflow_run(struct controller_ctx *ctx,
           const struct sbrec_chassis *chassis,
           const struct chassis_index *chassis_index,
           const struct hmap *local_datapaths,
-          struct ovn_extend_table *group_table,
-          struct ovn_extend_table *meter_table,
           const struct shash *addr_sets,
           const struct shash *port_groups,
+          const struct sset *active_tunnels,
+          const struct sset *local_lport_ids,
           struct hmap *flow_table,
-          struct sset *active_tunnels,
-          struct sset *local_lport_ids)
+          struct ovn_extend_table *group_table,
+          struct ovn_extend_table *meter_table)
 {
     COVERAGE_INC(lflow_run);
 
-    add_logical_flows(ctx, chassis_index, local_datapaths,
-                      group_table, meter_table, chassis, addr_sets,
-                      port_groups, flow_table, active_tunnels,
-                      local_lport_ids);
+    add_logical_flows(ctx, chassis_index, local_datapaths, chassis, addr_sets,
+                      port_groups, active_tunnels, local_lport_ids,
+                      flow_table, group_table, meter_table);
     add_neighbor_flows(ctx, flow_table);
 }
 
diff --git a/ovn/controller/lflow.h b/ovn/controller/lflow.h
index dcf2fe7105f9..14d960179816 100644
--- a/ovn/controller/lflow.h
+++ b/ovn/controller/lflow.h
@@ -66,13 +66,13 @@ void lflow_run(struct controller_ctx *,
                const struct sbrec_chassis *chassis,
                const struct chassis_index *,
                const struct hmap *local_datapaths,
-               struct ovn_extend_table *group_table,
-               struct ovn_extend_table *meter_table,
                const struct shash *addr_sets,
                const struct shash *port_groups,
+               const struct sset *active_tunnels,
+               const struct sset *local_lport_ids,
                struct hmap *flow_table,
-               struct sset *active_tunnels,
-               struct sset *local_lport_ids);
+               struct ovn_extend_table *group_table,
+               struct ovn_extend_table *meter_table);
 void lflow_destroy(void);
 
 #endif /* ovn/lflow.h */
diff --git a/ovn/controller/ovn-controller.c b/ovn/controller/ovn-controller.c
index 86e1836f94ef..ec22688e4fef 100644
--- a/ovn/controller/ovn-controller.c
+++ b/ovn/controller/ovn-controller.c
@@ -735,9 +735,9 @@ main(int argc, char *argv[])
 
                     struct hmap flow_table = HMAP_INITIALIZER(&flow_table);
                     lflow_run(&ctx, chassis,
-                              &chassis_index, &local_datapaths, &group_table,
-                              &meter_table, &addr_sets, &port_groups,
-                              &flow_table, &active_tunnels, &local_lport_ids);
+                              &chassis_index, &local_datapaths, &addr_sets,
+                              &port_groups, &active_tunnels, &local_lport_ids,
+                              &flow_table, &group_table, &meter_table);
 
                     if (chassis_id) {
                         bfd_run(&ctx, br_int, chassis, &local_datapaths,
@@ -745,8 +745,9 @@ main(int argc, char *argv[])
                     }
                     physical_run(&ctx, mff_ovn_geneve,
                                  br_int, chassis, &ct_zones,
-                                 &flow_table, &local_datapaths, &local_lports,
-                                 &chassis_index, &active_tunnels);
+                                 &local_datapaths, &local_lports,
+                                 &chassis_index, &active_tunnels,
+                                 &flow_table);
 
                     stopwatch_stop(CONTROLLER_LOOP_STOPWATCH_NAME,
                                    time_msec());
diff --git a/ovn/controller/physical.c b/ovn/controller/physical.c
index fc8adcfefa58..6d62678d3337 100644
--- a/ovn/controller/physical.c
+++ b/ovn/controller/physical.c
@@ -151,11 +151,11 @@ put_stack(enum mf_field_id field, struct ofpact_stack *stack)
     stack->subfield.n_bits = stack->subfield.field->n_bits;
 }
 
-static const struct sbrec_port_binding*
-get_localnet_port(struct hmap *local_datapaths, int64_t tunnel_key)
+static const struct sbrec_port_binding *
+get_localnet_port(const struct hmap *local_datapaths, int64_t tunnel_key)
 {
-    struct local_datapath *ld = get_local_datapath(local_datapaths,
-                                                   tunnel_key);
+    const struct local_datapath *ld = get_local_datapath(local_datapaths,
+                                                         tunnel_key);
     return ld ? ld->localnet_port : NULL;
 }
 
@@ -295,8 +295,8 @@ consider_port_binding(struct controller_ctx *ctx,
                       enum mf_field_id mff_ovn_geneve,
                       const struct simap *ct_zones,
                       const struct chassis_index *chassis_index,
-                      struct sset *active_tunnels,
-                      struct hmap *local_datapaths,
+                      const struct sset *active_tunnels,
+                      const struct hmap *local_datapaths,
                       const struct sbrec_port_binding *binding,
                       const struct sbrec_chassis *chassis,
                       struct ofpbuf *ofpacts_p,
@@ -730,7 +730,7 @@ out:
 static void
 consider_mc_group(enum mf_field_id mff_ovn_geneve,
                   const struct simap *ct_zones,
-                  struct hmap *local_datapaths,
+                  const struct hmap *local_datapaths,
                   const struct sbrec_chassis *chassis,
                   const struct sbrec_multicast_group *mc,
                   struct ofpbuf *ofpacts_p,
@@ -871,10 +871,11 @@ physical_run(struct controller_ctx *ctx, enum mf_field_id mff_ovn_geneve,
              const struct ovsrec_bridge *br_int,
              const struct sbrec_chassis *chassis,
              const struct simap *ct_zones,
-             struct hmap *flow_table, struct hmap *local_datapaths,
+             const struct hmap *local_datapaths,
              const struct sset *local_lports,
-             struct chassis_index *chassis_index,
-             struct sset *active_tunnels)
+             const struct chassis_index *chassis_index,
+             const struct sset *active_tunnels,
+             struct hmap *flow_table)
 {
 
     /* This bool tracks physical mapping changes. */
diff --git a/ovn/controller/physical.h b/ovn/controller/physical.h
index f8dbb498eafc..92a6e26616ea 100644
--- a/ovn/controller/physical.h
+++ b/ovn/controller/physical.h
@@ -47,9 +47,10 @@ void physical_run(struct controller_ctx *, enum mf_field_id mff_ovn_geneve,
                   const struct ovsrec_bridge *br_int,
                   const struct sbrec_chassis *chassis,
                   const struct simap *ct_zones,
-                  struct hmap *flow_table, struct hmap *local_datapaths,
+                  const struct hmap *local_datapaths,
                   const struct sset *local_lports,
-                  struct chassis_index *chassis_index,
-                  struct sset *active_tunnels);
+                  const struct chassis_index *chassis_index,
+                  const struct sset *active_tunnels,
+                  struct hmap *flow_table);
 
 #endif /* ovn/physical.h */
diff --git a/ovn/controller/pinctrl.c b/ovn/controller/pinctrl.c
index 305f20649eba..435b436c2743 100644
--- a/ovn/controller/pinctrl.c
+++ b/ovn/controller/pinctrl.c
@@ -77,8 +77,8 @@ static void send_garp_run(struct controller_ctx *ctx,
                           const struct ovsrec_bridge *,
                           const struct sbrec_chassis *,
                           const struct chassis_index *chassis_index,
-                          struct hmap *local_datapaths,
-                          struct sset *active_tunnels);
+                          const struct hmap *local_datapaths,
+                          const struct sset *active_tunnels);
 static void pinctrl_handle_nd_na(const struct flow *ip_flow,
                                  const struct match *md,
                                  struct ofpbuf *userdata,
@@ -96,7 +96,7 @@ static void init_ipv6_ras(void);
 static void destroy_ipv6_ras(void);
 static void ipv6_ra_wait(void);
 static void send_ipv6_ras(const struct controller_ctx *,
-                          struct hmap *local_datapaths);
+                          const struct hmap *local_datapaths);
 
 COVERAGE_DEFINE(pinctrl_drop_put_mac_binding);
 
@@ -1238,8 +1238,8 @@ pinctrl_run(struct controller_ctx *ctx,
             const struct ovsrec_bridge *br_int,
             const struct sbrec_chassis *chassis,
             const struct chassis_index *chassis_index,
-            struct hmap *local_datapaths,
-            struct sset *active_tunnels)
+            const struct hmap *local_datapaths,
+            const struct sset *active_tunnels)
 {
     char *target = xasprintf("unix:%s/%s.mgmt", ovs_rundir(), br_int->name);
     if (strcmp(target, rconn_get_target(swconn))) {
@@ -1490,7 +1490,8 @@ ipv6_ra_wait(void)
 }
 
 static void
-send_ipv6_ras(const struct controller_ctx *ctx, struct hmap *local_datapaths)
+send_ipv6_ras(const struct controller_ctx *ctx,
+              const struct hmap *local_datapaths)
 {
     struct shash_node *iter, *iter_next;
 
@@ -1814,7 +1815,8 @@ add_garp(const char *name, ofp_port_t ofport, int tag,
 /* Add or update a vif for which GARPs need to be announced. */
 static void
 send_garp_update(const struct sbrec_port_binding *binding_rec,
-                 struct simap *localnet_ofports, struct hmap *local_datapaths,
+                 struct simap *localnet_ofports,
+                 const struct hmap *local_datapaths,
                  struct shash *nat_addresses)
 {
     /* Find the localnet ofport to send this GARP. */
@@ -1944,7 +1946,7 @@ static void
 get_localnet_vifs_l3gwports(struct controller_ctx *ctx,
                   const struct ovsrec_bridge *br_int,
                   const struct sbrec_chassis *chassis,
-                  struct hmap *local_datapaths,
+                  const struct hmap *local_datapaths,
                   struct sset *localnet_vifs,
                   struct simap *localnet_ofports,
                   struct sset *local_l3gw_ports)
@@ -2030,7 +2032,7 @@ static bool
 pinctrl_is_chassis_resident(struct controller_ctx *ctx,
                             const struct sbrec_chassis *chassis,
                             const struct chassis_index *chassis_index,
-                            struct sset *active_tunnels,
+                            const struct sset *active_tunnels,
                             const char *port_name)
 {
     const struct sbrec_port_binding *pb
@@ -2124,7 +2126,7 @@ consider_nat_address(struct controller_ctx *ctx,
                      struct sset *nat_address_keys,
                      const struct sbrec_chassis *chassis,
                      const struct chassis_index *chassis_index,
-                     struct sset *active_tunnels,
+                     const struct sset *active_tunnels,
                      struct shash *nat_addresses)
 {
     struct lport_addresses *laddrs = xmalloc(sizeof *laddrs);
@@ -2156,7 +2158,7 @@ get_nat_addresses_and_keys(struct controller_ctx *ctx,
                            struct sset *local_l3gw_ports,
                            const struct sbrec_chassis *chassis,
                            const struct chassis_index *chassis_index,
-                           struct sset *active_tunnels,
+                           const struct sset *active_tunnels,
                            struct shash *nat_addresses)
 {
     const char *gw_port;
@@ -2201,8 +2203,8 @@ send_garp_run(struct controller_ctx *ctx,
               const struct ovsrec_bridge *br_int,
               const struct sbrec_chassis *chassis,
               const struct chassis_index *chassis_index,
-              struct hmap *local_datapaths,
-              struct sset *active_tunnels)
+              const struct hmap *local_datapaths,
+              const struct sset *active_tunnels)
 {
     struct sset localnet_vifs = SSET_INITIALIZER(&localnet_vifs);
     struct sset local_l3gw_ports = SSET_INITIALIZER(&local_l3gw_ports);
diff --git a/ovn/controller/pinctrl.h b/ovn/controller/pinctrl.h
index fc9cca81117c..56920e8c8587 100644
--- a/ovn/controller/pinctrl.h
+++ b/ovn/controller/pinctrl.h
@@ -32,8 +32,9 @@ struct sbrec_chassis;
 void pinctrl_init(void);
 void pinctrl_run(struct controller_ctx *,
                  const struct ovsrec_bridge *, const struct sbrec_chassis *,
-                 const struct chassis_index *, struct hmap *local_datapaths,
-                 struct sset *active_tunnels);
+                 const struct chassis_index *,
+                 const struct hmap *local_datapaths,
+                 const struct sset *active_tunnels);
 void pinctrl_wait(struct controller_ctx *);
 void pinctrl_destroy(void);
 
-- 
2.16.1



More information about the dev mailing list