diff mbox series

[ovs-dev,04/15] northd: introduce separate function to look up chassis

Message ID 20220215035737.1820679-5-ihrachys@redhat.com
State Superseded, archived
Headers show
Series Support additional-chassis for ports | expand

Checks

Context Check Description
ovsrobot/apply-robot success apply and check: success
ovsrobot/github-robot-_Build_and_Test fail github build: failed
ovsrobot/github-robot-_ovn-kubernetes fail github build: failed

Commit Message

Ihar Hrachyshka Feb. 15, 2022, 3:57 a.m. UTC
This function will be reused later.

Signed-off-by: Ihar Hrachyshka <ihrachys@redhat.com>
---
 northd/northd.c | 21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/northd/northd.c b/northd/northd.c
index fc7a64f99..0f694cb2d 100644
--- a/northd/northd.c
+++ b/northd/northd.c
@@ -3120,6 +3120,18 @@  ovn_update_ipv6_prefix(struct hmap *ports)
     }
 }
 
+static const struct sbrec_chassis *
+chassis_lookup(struct ovsdb_idl_index *sbrec_chassis_by_name,
+               struct ovsdb_idl_index *sbrec_chassis_by_hostname,
+               const char *name_or_hostname)
+{
+    const struct sbrec_chassis *chassis; /* May be NULL. */
+    chassis = chassis_lookup_by_name(sbrec_chassis_by_name,
+                                     name_or_hostname);
+    return chassis ? chassis : chassis_lookup_by_hostname(
+                    sbrec_chassis_by_hostname, name_or_hostname);
+}
+
 static void
 ovn_port_update_sbrec(struct northd_input *input_data,
                       struct ovsdb_idl_txn *ovnsb_txn,
@@ -3315,12 +3327,9 @@  ovn_port_update_sbrec(struct northd_input *input_data,
             requested_chassis = smap_get(&op->nbsp->options,
                                          "requested-chassis");
             if (requested_chassis) {
-                const struct sbrec_chassis *chassis; /* May be NULL. */
-                chassis = chassis_lookup_by_name(sbrec_chassis_by_name,
-                                                 requested_chassis);
-                chassis = chassis ? chassis : chassis_lookup_by_hostname(
-                                sbrec_chassis_by_hostname, requested_chassis);
-
+                const struct sbrec_chassis *chassis = chassis_lookup(
+                    sbrec_chassis_by_name, sbrec_chassis_by_hostname,
+                    requested_chassis);
                 if (chassis) {
                     sbrec_port_binding_set_requested_chassis(op->sb, chassis);
                 } else {