owenh / rpms / openvswitch

Forked from rpms/openvswitch a month ago
Clone
ef58f0
diff --git a/Documentation/ref/ovs-actions.7.rst b/Documentation/ref/ovs-actions.7.rst
ef58f0
index b59b7634f..d13895655 100644
ef58f0
--- a/Documentation/ref/ovs-actions.7.rst
ef58f0
+++ b/Documentation/ref/ovs-actions.7.rst
ef58f0
@@ -1380,7 +1380,7 @@ The ``delete_field`` action
ef58f0
   | ``delete_field:``\ *field*
ef58f0
 
ef58f0
 The ``delete_field`` action deletes a *field* in the syntax described under
ef58f0
-`Field Specifications`_ above.  Currently, only the ``tun_metadta`` fields are
ef58f0
+`Field Specifications`_ above.  Currently, only the ``tun_metadata`` fields are
ef58f0
 supported.
ef58f0
 
ef58f0
 This action was added in Open vSwitch 2.14.
ef58f0
diff --git a/NEWS b/NEWS
ef58f0
index 37a01dea5..58a52120b 100644
ef58f0
--- a/NEWS
ef58f0
+++ b/NEWS
ef58f0
@@ -1,3 +1,6 @@
ef58f0
+v3.1.1 - xx xxx xxxx
ef58f0
+--------------------
ef58f0
+
ef58f0
 v3.1.0 - 16 Feb 2023
ef58f0
 --------------------
ef58f0
    - ovs-vswitchd now detects changes in CPU affinity and adjusts the number
ef58f0
diff --git a/configure.ac b/configure.ac
ef58f0
index 9bf896c01..dea3b6f0b 100644
ef58f0
--- a/configure.ac
ef58f0
+++ b/configure.ac
ef58f0
@@ -13,7 +13,7 @@
ef58f0
 # limitations under the License.
ef58f0
 
ef58f0
 AC_PREREQ(2.63)
ef58f0
-AC_INIT(openvswitch, 3.1.0, bugs@openvswitch.org)
ef58f0
+AC_INIT(openvswitch, 3.1.1, bugs@openvswitch.org)
ef58f0
 AC_CONFIG_SRCDIR([vswitchd/ovs-vswitchd.c])
ef58f0
 AC_CONFIG_MACRO_DIR([m4])
ef58f0
 AC_CONFIG_AUX_DIR([build-aux])
ef58f0
diff --git a/debian/changelog b/debian/changelog
ef58f0
index a5ad222c4..83cc8e010 100644
ef58f0
--- a/debian/changelog
ef58f0
+++ b/debian/changelog
ef58f0
@@ -1,3 +1,9 @@
ef58f0
+openvswitch (3.1.1-1) unstable; urgency=low
ef58f0
+   [ Open vSwitch team ]
ef58f0
+   * New upstream version
ef58f0
+
ef58f0
+ -- Open vSwitch team <dev@openvswitch.org>  Thu, 16 Feb 2023 13:52:24 +0100
ef58f0
+
ef58f0
 openvswitch (3.1.0-1) unstable; urgency=low
ef58f0
 
ef58f0
    * New upstream version
ef58f0
diff --git a/lib/conntrack.c b/lib/conntrack.c
ef58f0
index 524670e45..8cf7779c6 100644
ef58f0
--- a/lib/conntrack.c
ef58f0
+++ b/lib/conntrack.c
ef58f0
@@ -1512,12 +1512,12 @@ conntrack_clean(struct conntrack *ct, long long now)
ef58f0
     clean_end = n_conn_limit / 64;
ef58f0
 
ef58f0
     for (i = ct->next_sweep; i < N_EXP_LISTS; i++) {
ef58f0
-        count += ct_sweep(ct, &ct->exp_lists[i], now);
ef58f0
-
ef58f0
         if (count > clean_end) {
ef58f0
             next_wakeup = 0;
ef58f0
             break;
ef58f0
         }
ef58f0
+
ef58f0
+        count += ct_sweep(ct, &ct->exp_lists[i], now);
ef58f0
     }
ef58f0
 
ef58f0
     ct->next_sweep = (i < N_EXP_LISTS) ? i : 0;
ef58f0
diff --git a/ofproto/ofproto-dpif-ipfix.c b/ofproto/ofproto-dpif-ipfix.c
ef58f0
index 742eed399..f13478a88 100644
ef58f0
--- a/ofproto/ofproto-dpif-ipfix.c
ef58f0
+++ b/ofproto/ofproto-dpif-ipfix.c
ef58f0
@@ -124,11 +124,18 @@ struct dpif_ipfix_port {
ef58f0
     uint32_t ifindex;
ef58f0
 };
ef58f0
 
ef58f0
+struct dpif_ipfix_domain {
ef58f0
+    struct hmap_node hmap_node; /* In struct dpif_ipfix_exporter's domains. */
ef58f0
+    time_t last_template_set_time;
ef58f0
+};
ef58f0
+
ef58f0
 struct dpif_ipfix_exporter {
ef58f0
     uint32_t exporter_id; /* Exporting Process identifier */
ef58f0
-    struct collectors *collectors;
ef58f0
     uint32_t seq_number;
ef58f0
-    time_t last_template_set_time;
ef58f0
+    struct collectors *collectors;
ef58f0
+    struct hmap domains; /* Contains struct dpif_ipfix_domain indexed by
ef58f0
+                            observation domain id. */
ef58f0
+    time_t last_stats_sent_time;
ef58f0
     struct hmap cache_flow_key_map;  /* ipfix_flow_cache_entry. */
ef58f0
     struct ovs_list cache_flow_start_timestamp_list;  /* ipfix_flow_cache_entry. */
ef58f0
     uint32_t cache_active_timeout;  /* In seconds. */
ef58f0
@@ -617,6 +624,9 @@ static void get_export_time_now(uint64_t *, uint32_t *);
ef58f0
 
ef58f0
 static void dpif_ipfix_cache_expire_now(struct dpif_ipfix_exporter *, bool);
ef58f0
 
ef58f0
+static void dpif_ipfix_exporter_del_domain(struct dpif_ipfix_exporter *,
ef58f0
+                                           struct dpif_ipfix_domain *);
ef58f0
+
ef58f0
 static bool
ef58f0
 ofproto_ipfix_bridge_exporter_options_equal(
ef58f0
     const struct ofproto_ipfix_bridge_exporter_options *a,
ef58f0
@@ -697,13 +707,14 @@ dpif_ipfix_exporter_init(struct dpif_ipfix_exporter *exporter)
ef58f0
     exporter->exporter_id = ++exporter_total_count;
ef58f0
     exporter->collectors = NULL;
ef58f0
     exporter->seq_number = 1;
ef58f0
-    exporter->last_template_set_time = 0;
ef58f0
+    exporter->last_stats_sent_time = 0;
ef58f0
     hmap_init(&exporter->cache_flow_key_map);
ef58f0
     ovs_list_init(&exporter->cache_flow_start_timestamp_list);
ef58f0
     exporter->cache_active_timeout = 0;
ef58f0
     exporter->cache_max_flows = 0;
ef58f0
     exporter->virtual_obs_id = NULL;
ef58f0
     exporter->virtual_obs_len = 0;
ef58f0
+    hmap_init(&exporter->domains);
ef58f0
 
ef58f0
     memset(&exporter->ipfix_global_stats, 0,
ef58f0
            sizeof(struct dpif_ipfix_global_stats));
ef58f0
@@ -711,6 +722,7 @@ dpif_ipfix_exporter_init(struct dpif_ipfix_exporter *exporter)
ef58f0
 
ef58f0
 static void
ef58f0
 dpif_ipfix_exporter_clear(struct dpif_ipfix_exporter *exporter)
ef58f0
+    OVS_REQUIRES(mutex)
ef58f0
 {
ef58f0
     /* Flush the cache with flow end reason "forced end." */
ef58f0
     dpif_ipfix_cache_expire_now(exporter, true);
ef58f0
@@ -719,22 +731,29 @@ dpif_ipfix_exporter_clear(struct dpif_ipfix_exporter *exporter)
ef58f0
     exporter->exporter_id = 0;
ef58f0
     exporter->collectors = NULL;
ef58f0
     exporter->seq_number = 1;
ef58f0
-    exporter->last_template_set_time = 0;
ef58f0
+    exporter->last_stats_sent_time = 0;
ef58f0
     exporter->cache_active_timeout = 0;
ef58f0
     exporter->cache_max_flows = 0;
ef58f0
     free(exporter->virtual_obs_id);
ef58f0
     exporter->virtual_obs_id = NULL;
ef58f0
     exporter->virtual_obs_len = 0;
ef58f0
 
ef58f0
+    struct dpif_ipfix_domain *dom;
ef58f0
+    HMAP_FOR_EACH_SAFE (dom, hmap_node, &exporter->domains) {
ef58f0
+        dpif_ipfix_exporter_del_domain(exporter, dom);
ef58f0
+    }
ef58f0
+
ef58f0
     memset(&exporter->ipfix_global_stats, 0,
ef58f0
            sizeof(struct dpif_ipfix_global_stats));
ef58f0
 }
ef58f0
 
ef58f0
 static void
ef58f0
 dpif_ipfix_exporter_destroy(struct dpif_ipfix_exporter *exporter)
ef58f0
+    OVS_REQUIRES(mutex)
ef58f0
 {
ef58f0
     dpif_ipfix_exporter_clear(exporter);
ef58f0
     hmap_destroy(&exporter->cache_flow_key_map);
ef58f0
+    hmap_destroy(&exporter->domains);
ef58f0
 }
ef58f0
 
ef58f0
 static bool
ef58f0
@@ -742,7 +761,7 @@ dpif_ipfix_exporter_set_options(struct dpif_ipfix_exporter *exporter,
ef58f0
                                 const struct sset *targets,
ef58f0
                                 const uint32_t cache_active_timeout,
ef58f0
                                 const uint32_t cache_max_flows,
ef58f0
-                                const char *virtual_obs_id)
ef58f0
+                                const char *virtual_obs_id) OVS_REQUIRES(mutex)
ef58f0
 {
ef58f0
     size_t virtual_obs_len;
ef58f0
     collectors_destroy(exporter->collectors);
ef58f0
@@ -769,6 +788,37 @@ dpif_ipfix_exporter_set_options(struct dpif_ipfix_exporter *exporter,
ef58f0
     return true;
ef58f0
 }
ef58f0
 
ef58f0
+static struct dpif_ipfix_domain *
ef58f0
+dpif_ipfix_exporter_find_domain(const struct dpif_ipfix_exporter *exporter,
ef58f0
+                                uint32_t domain_id) OVS_REQUIRES(mutex)
ef58f0
+{
ef58f0
+    struct dpif_ipfix_domain *dom;
ef58f0
+    HMAP_FOR_EACH_WITH_HASH (dom, hmap_node, hash_int(domain_id, 0),
ef58f0
+                             &exporter->domains) {
ef58f0
+        return dom;
ef58f0
+    }
ef58f0
+    return NULL;
ef58f0
+}
ef58f0
+
ef58f0
+static struct dpif_ipfix_domain *
ef58f0
+dpif_ipfix_exporter_insert_domain(struct dpif_ipfix_exporter *exporter,
ef58f0
+                                  const uint32_t domain_id) OVS_REQUIRES(mutex)
ef58f0
+{
ef58f0
+    struct dpif_ipfix_domain *dom = xmalloc(sizeof *dom);
ef58f0
+    dom->last_template_set_time = 0;
ef58f0
+    hmap_insert(&exporter->domains, &dom->hmap_node, hash_int(domain_id, 0));
ef58f0
+    return dom;
ef58f0
+}
ef58f0
+
ef58f0
+static void
ef58f0
+dpif_ipfix_exporter_del_domain(struct dpif_ipfix_exporter *exporter,
ef58f0
+                               struct dpif_ipfix_domain *dom)
ef58f0
+    OVS_REQUIRES(mutex)
ef58f0
+{
ef58f0
+    hmap_remove(&exporter->domains, &dom->hmap_node);
ef58f0
+    free(dom);
ef58f0
+}
ef58f0
+
ef58f0
 static struct dpif_ipfix_port *
ef58f0
 dpif_ipfix_find_port(const struct dpif_ipfix *di,
ef58f0
                      odp_port_t odp_port) OVS_REQUIRES(mutex)
ef58f0
@@ -909,6 +959,7 @@ dpif_ipfix_bridge_exporter_init(struct dpif_ipfix_bridge_exporter *exporter)
ef58f0
 
ef58f0
 static void
ef58f0
 dpif_ipfix_bridge_exporter_clear(struct dpif_ipfix_bridge_exporter *exporter)
ef58f0
+    OVS_REQUIRES(mutex)
ef58f0
 {
ef58f0
     dpif_ipfix_exporter_clear(&exporter->exporter);
ef58f0
     ofproto_ipfix_bridge_exporter_options_destroy(exporter->options);
ef58f0
@@ -918,6 +969,7 @@ dpif_ipfix_bridge_exporter_clear(struct dpif_ipfix_bridge_exporter *exporter)
ef58f0
 
ef58f0
 static void
ef58f0
 dpif_ipfix_bridge_exporter_destroy(struct dpif_ipfix_bridge_exporter *exporter)
ef58f0
+    OVS_REQUIRES(mutex)
ef58f0
 {
ef58f0
     dpif_ipfix_bridge_exporter_clear(exporter);
ef58f0
     dpif_ipfix_exporter_destroy(&exporter->exporter);
ef58f0
@@ -927,7 +979,7 @@ static void
ef58f0
 dpif_ipfix_bridge_exporter_set_options(
ef58f0
     struct dpif_ipfix_bridge_exporter *exporter,
ef58f0
     const struct ofproto_ipfix_bridge_exporter_options *options,
ef58f0
-    bool *options_changed)
ef58f0
+    bool *options_changed) OVS_REQUIRES(mutex)
ef58f0
 {
ef58f0
     if (!options || sset_is_empty(&options->targets)) {
ef58f0
         /* No point in doing any work if there are no targets. */
ef58f0
@@ -1003,6 +1055,7 @@ dpif_ipfix_flow_exporter_init(struct dpif_ipfix_flow_exporter *exporter)
ef58f0
 
ef58f0
 static void
ef58f0
 dpif_ipfix_flow_exporter_clear(struct dpif_ipfix_flow_exporter *exporter)
ef58f0
+    OVS_REQUIRES(mutex)
ef58f0
 {
ef58f0
     dpif_ipfix_exporter_clear(&exporter->exporter);
ef58f0
     ofproto_ipfix_flow_exporter_options_destroy(exporter->options);
ef58f0
@@ -1011,6 +1064,7 @@ dpif_ipfix_flow_exporter_clear(struct dpif_ipfix_flow_exporter *exporter)
ef58f0
 
ef58f0
 static void
ef58f0
 dpif_ipfix_flow_exporter_destroy(struct dpif_ipfix_flow_exporter *exporter)
ef58f0
+    OVS_REQUIRES(mutex)
ef58f0
 {
ef58f0
     dpif_ipfix_flow_exporter_clear(exporter);
ef58f0
     dpif_ipfix_exporter_destroy(&exporter->exporter);
ef58f0
@@ -1020,7 +1074,7 @@ static bool
ef58f0
 dpif_ipfix_flow_exporter_set_options(
ef58f0
     struct dpif_ipfix_flow_exporter *exporter,
ef58f0
     const struct ofproto_ipfix_flow_exporter_options *options,
ef58f0
-    bool *options_changed)
ef58f0
+    bool *options_changed) OVS_REQUIRES(mutex)
ef58f0
 {
ef58f0
     if (sset_is_empty(&options->targets)) {
ef58f0
         /* No point in doing any work if there are no targets. */
ef58f0
@@ -1071,6 +1125,7 @@ dpif_ipfix_flow_exporter_set_options(
ef58f0
 static void
ef58f0
 remove_flow_exporter(struct dpif_ipfix *di,
ef58f0
                      struct dpif_ipfix_flow_exporter_map_node *node)
ef58f0
+                     OVS_REQUIRES(mutex)
ef58f0
 {
ef58f0
     hmap_remove(&di->flow_exporter_map, &node->node);
ef58f0
     dpif_ipfix_flow_exporter_destroy(&node->exporter);
ef58f0
@@ -2000,6 +2055,7 @@ static void
ef58f0
 ipfix_cache_update(struct dpif_ipfix_exporter *exporter,
ef58f0
                    struct ipfix_flow_cache_entry *entry,
ef58f0
                    enum ipfix_sampled_packet_type sampled_pkt_type)
ef58f0
+                   OVS_REQUIRES(mutex)
ef58f0
 {
ef58f0
     struct ipfix_flow_cache_entry *old_entry;
ef58f0
     size_t current_flows = 0;
ef58f0
@@ -2811,14 +2867,36 @@ dpif_ipfix_flow_sample(struct dpif_ipfix *di, const struct dp_packet *packet,
ef58f0
     ovs_mutex_unlock(&mutex);
ef58f0
 }
ef58f0
 
ef58f0
+static bool
ef58f0
+dpif_ipfix_should_send_template(struct dpif_ipfix_exporter *exporter,
ef58f0
+                                const uint32_t observation_domain_id,
ef58f0
+                                const uint32_t export_time_sec)
ef58f0
+    OVS_REQUIRES(mutex)
ef58f0
+{
ef58f0
+    struct dpif_ipfix_domain *domain;
ef58f0
+    domain = dpif_ipfix_exporter_find_domain(exporter,
ef58f0
+                                             observation_domain_id);
ef58f0
+    if (!domain) {
ef58f0
+        /* First time we see this obs_domain_id. */
ef58f0
+        domain = dpif_ipfix_exporter_insert_domain(exporter,
ef58f0
+                                                   observation_domain_id);
ef58f0
+    }
ef58f0
+
ef58f0
+    if ((domain->last_template_set_time + IPFIX_TEMPLATE_INTERVAL)
ef58f0
+        <= export_time_sec) {
ef58f0
+        domain->last_template_set_time = export_time_sec;
ef58f0
+        return true;
ef58f0
+    }
ef58f0
+    return false;
ef58f0
+}
ef58f0
+
ef58f0
 static void
ef58f0
 dpif_ipfix_cache_expire(struct dpif_ipfix_exporter *exporter,
ef58f0
                         bool forced_end, const uint64_t export_time_usec,
ef58f0
-                        const uint32_t export_time_sec)
ef58f0
+                        const uint32_t export_time_sec) OVS_REQUIRES(mutex)
ef58f0
 {
ef58f0
     struct ipfix_flow_cache_entry *entry;
ef58f0
     uint64_t max_flow_start_timestamp_usec;
ef58f0
-    bool template_msg_sent = false;
ef58f0
     enum ipfix_flow_end_reason flow_end_reason;
ef58f0
 
ef58f0
     if (ovs_list_is_empty(&exporter->cache_flow_start_timestamp_list)) {
ef58f0
@@ -2844,25 +2922,28 @@ dpif_ipfix_cache_expire(struct dpif_ipfix_exporter *exporter,
ef58f0
             break;
ef58f0
         }
ef58f0
 
ef58f0
-        ovs_list_remove(&entry->cache_flow_start_timestamp_list_node);
ef58f0
-        hmap_remove(&exporter->cache_flow_key_map,
ef58f0
-                    &entry->flow_key_map_node);
ef58f0
+        /* XXX: Make frequency of the (Options) Template and Exporter Process
ef58f0
+         * Statistics transmission configurable.
ef58f0
+         * Cf. IETF RFC 5101 Section 4.3. and 10.3.6. */
ef58f0
+        if ((exporter->last_stats_sent_time + IPFIX_TEMPLATE_INTERVAL)
ef58f0
+             <= export_time_sec) {
ef58f0
+            exporter->last_stats_sent_time = export_time_sec;
ef58f0
+            ipfix_send_exporter_data_msg(exporter, export_time_sec);
ef58f0
+        }
ef58f0
 
ef58f0
-         /* XXX: Make frequency of the (Options) Template and Exporter Process
ef58f0
-          * Statistics transmission configurable.
ef58f0
-          * Cf. IETF RFC 5101 Section 4.3. and 10.3.6. */
ef58f0
-        if (!template_msg_sent
ef58f0
-            && (exporter->last_template_set_time + IPFIX_TEMPLATE_INTERVAL)
ef58f0
-                <= export_time_sec) {
ef58f0
+        if (dpif_ipfix_should_send_template(exporter,
ef58f0
+                                            entry->flow_key.obs_domain_id,
ef58f0
+                                            export_time_sec)) {
ef58f0
+            VLOG_DBG("Sending templates for ObservationDomainID %"PRIu32,
ef58f0
+                     entry->flow_key.obs_domain_id);
ef58f0
             ipfix_send_template_msgs(exporter, export_time_sec,
ef58f0
                                      entry->flow_key.obs_domain_id);
ef58f0
-            exporter->last_template_set_time = export_time_sec;
ef58f0
-            template_msg_sent = true;
ef58f0
-
ef58f0
-            /* Send Exporter Process Statistics. */
ef58f0
-            ipfix_send_exporter_data_msg(exporter, export_time_sec);
ef58f0
         }
ef58f0
 
ef58f0
+        ovs_list_remove(&entry->cache_flow_start_timestamp_list_node);
ef58f0
+        hmap_remove(&exporter->cache_flow_key_map,
ef58f0
+                    &entry->flow_key_map_node);
ef58f0
+
ef58f0
         /* XXX: Group multiple data records for the same obs domain id
ef58f0
          * into the same message. */
ef58f0
         ipfix_send_data_msg(exporter, export_time_sec, entry, flow_end_reason);
ef58f0
@@ -2883,7 +2964,7 @@ get_export_time_now(uint64_t *export_time_usec, uint32_t *export_time_sec)
ef58f0
 
ef58f0
 static void
ef58f0
 dpif_ipfix_cache_expire_now(struct dpif_ipfix_exporter *exporter,
ef58f0
-                            bool forced_end)
ef58f0
+                            bool forced_end) OVS_REQUIRES(mutex)
ef58f0
 {
ef58f0
     uint64_t export_time_usec;
ef58f0
     uint32_t export_time_sec;