Flowprobe: Stateful flows and IPv6, L4 recording

Change-Id: I67839281623721bf42f0a918a53356143d9dc78a
Signed-off-by: Ole Troan <ot@cisco.com>
Signed-off-by: Pavel Kotucek <pkotucek@cisco.com>
Signed-off-by: Ole Troan <ot@cisco.com>
diff --git a/src/vnet/flow/flow_api.c b/src/vnet/flow/flow_api.c
index b975dda..52a608c 100644
--- a/src/vnet/flow/flow_api.c
+++ b/src/vnet/flow/flow_api.c
@@ -296,7 +296,7 @@
   args.domain_id = fcm->domain_id;
   args.src_port = fcm->src_port;
 
-  rv = vnet_flow_report_add_del (frm, &args);
+  rv = vnet_flow_report_add_del (frm, &args, NULL);
 
   /* If deleting, or add failed */
   if (is_add == 0 || (rv && is_add))
diff --git a/src/vnet/flow/flow_report.c b/src/vnet/flow/flow_report.c
index c78a78a..ccc8423 100644
--- a/src/vnet/flow/flow_report.c
+++ b/src/vnet/flow/flow_report.c
@@ -87,7 +87,6 @@
       if (frm->ipfix_collector.as_u32 == 0 
           || frm->src_address.as_u32 == 0)
         {
-          clib_warning ("no collector: disabling flow collector process");
           vlib_node_set_state (frm->vlib_main, flow_report_process_node.index,
                                VLIB_NODE_STATE_DISABLED);
           return -1;
@@ -238,7 +237,8 @@
 };
 
 int vnet_flow_report_add_del (flow_report_main_t *frm, 
-                              vnet_flow_report_add_del_args_t *a)
+                              vnet_flow_report_add_del_args_t *a,
+			      u16 *template_id)
 {
   int i;
   int found_index = ~0;
@@ -260,6 +260,8 @@
           && fr->flow_data_callback == a->flow_data_callback)
         {
           found_index = i;
+          if (template_id)
+            *template_id = fr->template_id;
           break;
         }
     }
@@ -304,7 +306,10 @@
   fr->opaque = a->opaque;
   fr->rewrite_callback = a->rewrite_callback;
   fr->flow_data_callback = a->flow_data_callback;
-  
+
+  if (template_id)
+    *template_id = fr->template_id;
+
   return 0;
 }
 
@@ -415,10 +420,7 @@
       break;
   }
   
-  if (collector.as_u32 == 0)
-    return clib_error_return (0, "collector address required");
-
-  if (src.as_u32 == 0)
+  if (collector.as_u32 != 0 && src.as_u32 == 0)
     return clib_error_return (0, "src address required");
 
   if (path_mtu > 1450 /* vpp does not support fragmentation */)
@@ -441,7 +443,8 @@
   frm->template_interval = template_interval;
   frm->udp_checksum = udp_checksum;
   
-  vlib_cli_output (vm, "Collector %U, src address %U, "
+  if (collector.as_u32)
+    vlib_cli_output (vm, "Collector %U, src address %U, "
 		           "fib index %d, path MTU %u, "
 		           "template resend interval %us, "
 		           "udp checksum %s",
@@ -449,6 +452,8 @@
                    format_ip4_address, &frm->src_address,
                    fib_index, path_mtu, template_interval,
                    udp_checksum ? "enabled" : "disabled");
+  else
+    vlib_cli_output (vm, "IPFIX Collector is disabled");
 
   /* Turn on the flow reporting process */
   vlib_process_signal_event (vm, flow_report_process_node.index,
diff --git a/src/vnet/flow/flow_report.h b/src/vnet/flow/flow_report.h
index e8ed381..01859ce 100644
--- a/src/vnet/flow/flow_report.h
+++ b/src/vnet/flow/flow_report.h
@@ -130,7 +130,8 @@
 } vnet_flow_report_add_del_args_t;  
 
 int vnet_flow_report_add_del (flow_report_main_t *frm, 
-                              vnet_flow_report_add_del_args_t *a);
+                              vnet_flow_report_add_del_args_t *a,
+			      u16 *template_id);
 
 clib_error_t * flow_report_add_del_error_to_clib_error (int error);
 
diff --git a/src/vnet/flow/flow_report_classify.c b/src/vnet/flow/flow_report_classify.c
index 27f03dd..d4c3049 100644
--- a/src/vnet/flow/flow_report_classify.c
+++ b/src/vnet/flow/flow_report_classify.c
@@ -458,7 +458,7 @@
   args.domain_id = fcm->domain_id;
   args.src_port = fcm->src_port;
 
-  rv = vnet_flow_report_add_del (frm, &args);
+  rv = vnet_flow_report_add_del (frm, &args, NULL);
 
   error = flow_report_add_del_error_to_clib_error(rv);