On Fri, Jun 24, 2016 at 05:25:57AM -0700, Wenyu Zhang wrote:
> In virtual network, users want more info about the virtual point to observe 
> the traffic.
> It should be a string to provide clear info, not a simple interger ID.
> 
> Introduce "other-config: virtual_obs_id" in IPFIX, which is a string 
> configured by user.
> Introduce an enterprise IPFIX entity "virtualObsID"(898) to export the value. 
> The entity is a
> variable-length string.
> 
> Signed-off-by: Wenyu Zhang <wen...@vmware.com>

I folded in the following changes and applied this to master.

--8<--------------------------cut here-------------------------->8--

diff --git a/NEWS b/NEWS
index d7f1783..26ebaf3 100644
--- a/NEWS
+++ b/NEWS
@@ -15,14 +15,17 @@ Post-v2.5.0
        now implemented.  Only flow mod and port mod messages are supported
        in bundles.
      * New OpenFlow extension NXM_NX_MPLS_TTL to provide access to MPLS TTL.
-     * New "sampling_port" option for "sample" action to allow sampling
-       ingress and egress tunnel metadata.
    - ovs-ofctl:
      * queue-get-config command now allows a queue ID to be specified.
      * '--bundle' option can now be used with OpenFlow 1.3.
      * New option "--color" to produce colorized output for some commands.
-     * New commands "dump-ipfix-bridge" and "dump-ipfix-flow" to dump bridge
-       IPFIX statistics and flow based IPFIX statistics.
+   - IPFIX:
+     * New "sampling_port" option for "sample" action to allow sampling
+       ingress and egress tunnel metadata with IPFIX.
+     * New ovs-ofctl commands "dump-ipfix-bridge" and "dump-ipfix-flow" to
+       dump bridge IPFIX statistics and flow based IPFIX statistics.
+     * New setting other-config:virtual_obs_id to add an arbitrary string
+       to IPFIX records.
    - Linux:
      * New QoS type "linux-noop" that prevents Open vSwitch from trying to
        manage QoS for a given port (useful when other software manages QoS).
diff --git a/ofproto/ofproto-dpif-ipfix.c b/ofproto/ofproto-dpif-ipfix.c
index 81cd07c..35f481d 100644
--- a/ofproto/ofproto-dpif-ipfix.c
+++ b/ofproto/ofproto-dpif-ipfix.c
@@ -469,6 +469,12 @@ nullable_string_is_equal(const char *a, const char *b)
     return a ? b && !strcmp(a, b) : !b;
 }
 
+static char *
+nullable_xstrdup(const char *s)
+{
+    return s ? xstrdup(s) : NULL;
+}
+
 static bool
 ofproto_ipfix_bridge_exporter_options_equal(
     const struct ofproto_ipfix_bridge_exporter_options *a,
@@ -493,8 +499,7 @@ ofproto_ipfix_bridge_exporter_options_clone(
     struct ofproto_ipfix_bridge_exporter_options *new =
         xmemdup(old, sizeof *old);
     sset_clone(&new->targets, &old->targets);
-    new->virtual_obs_id = old->virtual_obs_id ? xstrdup(old->virtual_obs_id)
-                                              : NULL;
+    new->virtual_obs_id = nullable_xstrdup(old->virtual_obs_id);
     return new;
 }
 
@@ -529,8 +534,7 @@ ofproto_ipfix_flow_exporter_options_clone(
     struct ofproto_ipfix_flow_exporter_options *new =
         xmemdup(old, sizeof *old);
     sset_clone(&new->targets, &old->targets);
-    new->virtual_obs_id = old->virtual_obs_id ? xstrdup(old->virtual_obs_id)
-                                              : NULL;
+    new->virtual_obs_id = nullable_xstrdup(old->virtual_obs_id);
     return new;
 }
 
@@ -604,14 +608,14 @@ dpif_ipfix_exporter_set_options(struct 
dpif_ipfix_exporter *exporter,
     exporter->cache_max_flows = cache_max_flows;
     virtual_obs_len = virtual_obs_id ? strlen(virtual_obs_id) : 0;
     if (virtual_obs_len > IPFIX_VIRTUAL_OBS_MAX_LEN) {
-        VLOG_WARN_RL(&rl, "Virtual obsevation ID too long(%d bytes), "
+        VLOG_WARN_RL(&rl, "Virtual obsevation ID too long (%d bytes), "
                      "should not be longer than %d bytes.",
                      exporter->virtual_obs_len, IPFIX_VIRTUAL_OBS_MAX_LEN);
         dpif_ipfix_exporter_clear(exporter);
         return false;
     }
     exporter->virtual_obs_len = virtual_obs_len;
-    exporter->virtual_obs_id = virtual_obs_id ? xstrdup(virtual_obs_id) : NULL;
+    exporter->virtual_obs_id = nullable_xstrdup(virtual_obs_id);
     return true;
 }
 
@@ -1207,7 +1211,7 @@ ipfix_define_template_fields(enum ipfix_proto_l2 l2, enum 
ipfix_proto_l3 l3,
         DEF(TUNNEL_KEY);
     }
 
-    /* 2. virtual obs ID, which is not a part of flow key */
+    /* 2. Virtual observation ID, which is not a part of flow key. */
     if (virtual_obs_id_set) {
         DEF(VIRTUAL_OBS_ID);
     }
@@ -1318,9 +1322,9 @@ ipfix_send_template_msgs(struct dpif_ipfix_exporter 
*exporter,
                     tmpl_hdr = dp_packet_put_zeros(&msg, sizeof *tmpl_hdr);
                     tmpl_hdr->template_id = htons(
                         ipfix_get_template_id(l2, l3, l4, tunnel));
-                    field_count =
-                        ipfix_define_template_fields(l2, l3, l4, tunnel,
-                             exporter->virtual_obs_id != NULL, &msg);
+                    field_count = ipfix_define_template_fields(
+                        l2, l3, l4, tunnel, exporter->virtual_obs_id != NULL,
+                        &msg);
                     tmpl_hdr = (struct ipfix_template_record_header*)
                         ((uint8_t*)dp_packet_data(&msg) + tmpl_hdr_offset);
                     tmpl_hdr->field_count = htons(field_count);
@@ -1822,7 +1826,7 @@ ipfix_put_data_set(uint32_t export_time_sec,
     dp_packet_put(msg, entry->flow_key.flow_key_msg_part,
                entry->flow_key.flow_key_msg_part_size);
 
-    /* Export virtual obs ID */
+    /* Export virtual observation ID. */
     if (virtual_obs_id) {
         dp_packet_put(msg, &virtual_obs_len, sizeof(virtual_obs_len));
         dp_packet_put(msg, virtual_obs_id, virtual_obs_len);
diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c
index b4bede0..19e9f2d 100644
--- a/vswitchd/bridge.c
+++ b/vswitchd/bridge.c
@@ -1212,8 +1212,9 @@ bridge_configure_ipfix(struct bridge *br)
                                               "enable-output-sampling", false);
 
         virtual_obs_id = smap_get(&be_cfg->other_config, "virtual_obs_id");
-        be_opts.virtual_obs_id = virtual_obs_id ? xstrdup(virtual_obs_id)
-                                                : NULL;
+        be_opts.virtual_obs_id = (virtual_obs_id
+                                  ? xstrdup(virtual_obs_id)
+                                  : NULL);
     }
 
     if (n_fe_opts > 0) {
@@ -1234,9 +1235,10 @@ bridge_configure_ipfix(struct bridge *br)
                                                    
&fe_cfg->ipfix->other_config,
                                                   "enable-tunnel-sampling", 
true);
                 virtual_obs_id = smap_get(&be_cfg->other_config,
-                                     "virtual_obs_id");
-                opts->virtual_obs_id = virtual_obs_id ? xstrdup(virtual_obs_id)
-                                                      : NULL;
+                                          "virtual_obs_id");
+                opts->virtual_obs_id = (virtual_obs_id
+                                        ? xstrdup(virtual_obs_id)
+                                        : NULL);
                 opts++;
             }
         }
diff --git a/vswitchd/vswitch.xml b/vswitchd/vswitch.xml
index 30c205c..aad4904 100644
--- a/vswitchd/vswitch.xml
+++ b/vswitchd/vswitch.xml
@@ -4749,13 +4749,15 @@
 
     <column name="other_config" key="virtual_obs_id"
             type='{"type": "string"}'>
-      The IPFIX virtual observation ID sent with each IPFIX flow reord.
-      It is an identifier of a virtual obsvervation point that is locally
-      unique in a virtual network. It describes a location in the virtual
-      network where IP packets can be observed. The max length is limited to
-      254 bytes.
-      If not specified or the length of the specified ID exceeds the max
-      length, nothing exported with IPFIX flow record.
+      <p>
+        A string that accompanies each IPFIX flow record.  Its intended use is
+        for the ``virtual observation ID,'' an identifier of a virtual
+        observation point that is locally unique in a virtual network.  It
+        describes a location in the virtual network where IP packets can be
+        observed.  The maximum length is 254 bytes.  If not specified, the
+        field is omitted from the IPFIX flow record.
+      </p>
+
       <p>
         The following enterprise entity reports the specified virtual
         observation ID:
@@ -4767,17 +4769,14 @@
           <p>ID: 898, and enterprise ID 6876 (VMware).</p>
           <p>type: variable-length string.</p>
           <p>data type semantics: identifier.</p>
-          <p>description: The Identifier of the virtual observation domain ID
-             that is locally unique in a virtual network.
+          <p>description: A virtual observation domain ID that is locally
+          unique in a virtual network.
           </p>
         </dd>
       </dl>
 
       <p>
-        Before Open vSwitch 2.5.90, <ref column="other_config"
-        key="virtual_obs_id"/> was not supported.  Open vSwitch 2.6 and later
-        support <ref column="other_config" key="virtual_obs_id"/> for
-        per-bridge and per-flow sampling.
+        This feature was introduced in Open vSwitch 2.5.90.
       </p>
     </column>
 
_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to