[ovs-dev] [RFC PATCH ovn 1/6] ovn-sb: Add plugged_by column to Port_Binding.

Frode Nordahl frode.nordahl at gmail.com
Thu Aug 5 14:50:08 UTC 2021


ovn-northd will fill this column with UUID of Chassis referenced
in Logical_Switch_Port options:requested-chassis when
options:plug-type is defined.

Signed-off-by: Frode Nordahl <frode.nordahl at canonical.com>
---
 northd/ovn-northd.c | 31 +++++++++++++++++++++++++++++++
 ovn-nb.xml          | 38 ++++++++++++++++++++++++++++++++++++++
 ovn-sb.ovsschema    | 10 +++++++---
 ovn-sb.xml          | 15 +++++++++++++++
 4 files changed, 91 insertions(+), 3 deletions(-)

diff --git a/northd/ovn-northd.c b/northd/ovn-northd.c
index a0eaa1247..847860219 100644
--- a/northd/ovn-northd.c
+++ b/northd/ovn-northd.c
@@ -3164,6 +3164,35 @@ ovn_port_update_sbrec(struct northd_context *ctx,
                  * ha_chassis_group cleared in the same transaction. */
                 sbrec_port_binding_set_ha_chassis_group(op->sb, NULL);
             }
+
+            const char *plug_type;         /* May be NULL. */
+            const char *requested_chassis; /* May be NULL. */
+            bool reset_plugged_by = false;
+            plug_type = smap_get(&op->nbsp->options, "plug-type");
+            requested_chassis = smap_get(&op->nbsp->options,
+                                         "requested-chassis");
+            if (plug_type && requested_chassis) {
+                const struct sbrec_chassis *chassis; /* May be NULL. */
+                chassis = chassis_lookup_by_name(sbrec_chassis_by_name,
+                                                 requested_chassis);
+                if (chassis) {
+                    sbrec_port_binding_set_plugged_by(op->sb, chassis);
+                } else {
+                    reset_plugged_by = true;
+                    static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(
+                        1, 1);
+                    VLOG_WARN_RL(
+                        &rl,
+                        "Unknown chassis '%s' set as "
+                        "options:requested-chassis on LSP '%s'.",
+                        requested_chassis, op->nbsp->name);
+                }
+            } else if (op->sb->plugged_by) {
+                reset_plugged_by = true;
+            }
+            if (reset_plugged_by) {
+                sbrec_port_binding_set_plugged_by(op->sb, NULL);
+            }
         } else {
             const char *chassis = NULL;
             if (op->peer && op->peer->od && op->peer->od->nbr) {
@@ -14883,6 +14912,8 @@ main(int argc, char *argv[])
     add_column_noalert(ovnsb_idl_loop.idl,
                        &sbrec_port_binding_col_nat_addresses);
     ovsdb_idl_add_column(ovnsb_idl_loop.idl, &sbrec_port_binding_col_chassis);
+    ovsdb_idl_add_column(ovnsb_idl_loop.idl,
+                         &sbrec_port_binding_col_plugged_by);
     ovsdb_idl_add_column(ovnsb_idl_loop.idl,
                          &sbrec_port_binding_col_gateway_chassis);
     ovsdb_idl_add_column(ovnsb_idl_loop.idl,
diff --git a/ovn-nb.xml b/ovn-nb.xml
index c1176e81f..d2cf3a984 100644
--- a/ovn-nb.xml
+++ b/ovn-nb.xml
@@ -1020,6 +1020,44 @@
             DHCP reply.
           </p>
         </column>
+
+        <group title="VIF Plugging Options">
+          <p>
+            These options apply to logical ports with
+            <ref column="options" key="requested-chassis"/> and
+            <ref column="options" key="plug-type"/> set.
+          </p>
+
+          <column name="options" key="plug-type">
+            If set, OVN will attempt to to perform plugging of this VIF.  In
+            order to get this port plugged by the OVN controller, OVN must be
+            built with support for VIF plugging.  The default behavior is for
+            the CMS to do the VIF plugging.
+            Supported values: representor
+          </column>
+
+          <column name="options" key="plug-pf-mac">
+            MAC address for identifying PF device.  When
+            <ref column="options" key="plug-vf-num"/> is also set, this
+            option is used to identify PF to use as base to locate the correct
+            VF representor port.  When
+            <ref column="options" key="plug-vf-num"/> is not set this
+            option is used to locate a PF representor port.
+          </column>
+
+          <column name="options" key="plug-vf-num">
+            Logical VF number relative to PF device specified in
+            <ref column="options" key="plug-pf-mac"/>.
+          </column>
+
+          <column name="options" key="plug-mtu-request">
+            Requested MTU for plugged interfaces.  When set the OVN controller
+            will fill the <ref table="Interface" column="mtu_request"/> column
+            of the Open vSwitch database's
+            <ref table="Interface" db="vswitch"/> table.  This in turn will
+            make OVS vswitchd update the MTU of the linked interface.
+          </column>
+        </group>
       </group>
 
       <group title="Virtual port Options">
diff --git a/ovn-sb.ovsschema b/ovn-sb.ovsschema
index e5ab41db9..4df326ff4 100644
--- a/ovn-sb.ovsschema
+++ b/ovn-sb.ovsschema
@@ -1,7 +1,7 @@
 {
     "name": "OVN_Southbound",
-    "version": "20.20.0",
-    "cksum": "605270161 26670",
+    "version": "20.21.0",
+    "cksum": "888060012 26935",
     "tables": {
         "SB_Global": {
             "columns": {
@@ -232,7 +232,11 @@
                 "external_ids": {"type": {"key": "string",
                                  "value": "string",
                                  "min": 0,
-                                 "max": "unlimited"}}},
+                                 "max": "unlimited"}},
+                "plugged_by": {"type": {"key": {"type": "uuid",
+                                                "refTable": "Chassis",
+                                                "refType": "weak"},
+                                        "min": 0, "max": 1}}},
             "indexes": [["datapath", "tunnel_key"], ["logical_port"]],
             "isRoot": true},
         "MAC_Binding": {
diff --git a/ovn-sb.xml b/ovn-sb.xml
index e6ce243cf..536b9a31b 100644
--- a/ovn-sb.xml
+++ b/ovn-sb.xml
@@ -2992,6 +2992,21 @@ tcp.flags = RST;
           </dd>
         </dl>
       </column>
+      <column name="plugged_by">
+        Chassis that should plug this port, this column must be a
+        <ref table="Chassis"/> record.  This is populated by
+        <code>ovn-northd</code> when the <ref
+        table="Logical_Switch_Port"
+        column="options"
+        key="requested-chassis"
+        db="OVN_Northbound"/> and <ref
+        table="Logical_Switch_Port"
+        column="options"
+        key="plug-type"
+        db="OVN_Northbound"/> is defined.  In order to get this port plugged by
+        the OVN controller, OVN must be built with support for VIF plugging.
+        The default behavior is for the CMS to do the VIF plugging.
+      </column>
     </group>
 
     <group title="Patch Options">
-- 
2.31.1



More information about the dev mailing list