summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2021-03-04 18:41:59 +0100
committerOle Tr�an <otroan@employees.org>2021-03-05 11:59:24 +0000
commit8fb5add31885fcee1abaf60dd903aa566cc53b0d (patch)
tree774eddc57568e5cad1cb3c2d4a4956501d21a37b
parent3efd4e9998192545c32aeb33a9f8f72a1ba085a9 (diff)
interface: move vnet_pcap_t to vnet
It naturally belogns there... Type: refactor Change-Id: I05f7ba01103a5e9b3756f1ea69c8cc5d8f26f0a0 Signed-off-by: Damjan Marion <damarion@cisco.com>
-rw-r--r--src/vlib/main.h18
-rw-r--r--src/vnet/ethernet/node.c6
-rw-r--r--src/vnet/interface_cli.c3
-rw-r--r--src/vnet/interface_output.c6
-rw-r--r--src/vnet/vnet.h30
5 files changed, 33 insertions, 30 deletions
diff --git a/src/vlib/main.h b/src/vlib/main.h
index 5f78b7941a4..3925989d841 100644
--- a/src/vlib/main.h
+++ b/src/vlib/main.h
@@ -60,21 +60,6 @@
typedef struct
{
- /* Trace RX pkts */
- u8 pcap_rx_enable;
- /* Trace TX pkts */
- u8 pcap_tx_enable;
- /* Trace drop pkts */
- u8 pcap_drop_enable;
- u8 pad1;
- u32 max_bytes_per_pkt;
- u32 pcap_sw_if_index;
- pcap_main_t pcap_main;
- u32 filter_classify_table_index;
-} vnet_pcap_t;
-
-typedef struct
-{
u8 trace_filter_enable;
u32 classify_table_index;
} vlib_trace_filter_t;
@@ -202,9 +187,6 @@ typedef struct vlib_main_t
u32 *dispatch_buffer_trace_nodes;
u8 *pcap_buffer;
- /* pcap rx / tx tracing */
- vnet_pcap_t pcap;
-
/* Packet trace capture filter */
vlib_trace_filter_t trace_filter;
diff --git a/src/vnet/ethernet/node.c b/src/vnet/ethernet/node.c
index f4f84f8ca45..c31e22299b3 100644
--- a/src/vnet/ethernet/node.c
+++ b/src/vnet/ethernet/node.c
@@ -1131,6 +1131,7 @@ static_always_inline void
ethernet_input_trace (vlib_main_t * vm, vlib_node_runtime_t * node,
vlib_frame_t * from_frame)
{
+ vnet_main_t *vnm = vnet_get_main ();
u32 *from, n_left;
if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE)))
{
@@ -1159,10 +1160,10 @@ ethernet_input_trace (vlib_main_t * vm, vlib_node_runtime_t * node,
}
/* rx pcap capture if enabled */
- if (PREDICT_FALSE (vlib_global_main.pcap.pcap_rx_enable))
+ if (PREDICT_FALSE (vnm->pcap.pcap_rx_enable))
{
u32 bi0;
- vnet_pcap_t *pp = &vlib_global_main.pcap;
+ vnet_pcap_t *pp = &vnm->pcap;
from = vlib_frame_vector_args (from_frame);
n_left = from_frame->n_vectors;
@@ -1188,7 +1189,6 @@ ethernet_input_trace (vlib_main_t * vm, vlib_node_runtime_t * node,
if (pp->pcap_sw_if_index == 0 ||
pp->pcap_sw_if_index == vnet_buffer (b0)->sw_if_index[VLIB_RX])
{
- vnet_main_t *vnm = vnet_get_main ();
vnet_hw_interface_t *hi =
vnet_get_sup_hw_interface
(vnm, vnet_buffer (b0)->sw_if_index[VLIB_RX]);
diff --git a/src/vnet/interface_cli.c b/src/vnet/interface_cli.c
index 54e0673544f..9ade975937e 100644
--- a/src/vnet/interface_cli.c
+++ b/src/vnet/interface_cli.c
@@ -1930,7 +1930,8 @@ int
vnet_pcap_dispatch_trace_configure (vnet_pcap_dispatch_trace_args_t * a)
{
vlib_main_t *vm = vlib_get_main ();
- vnet_pcap_t *pp = &vm->pcap;
+ vnet_main_t *vnm = vnet_get_main ();
+ vnet_pcap_t *pp = &vnm->pcap;
pcap_main_t *pm = &pp->pcap_main;
vnet_classify_main_t *cm = &vnet_classify_main;
diff --git a/src/vnet/interface_output.c b/src/vnet/interface_output.c
index ff315f6abe0..641bd928d59 100644
--- a/src/vnet/interface_output.c
+++ b/src/vnet/interface_output.c
@@ -426,9 +426,10 @@ static_always_inline void vnet_interface_pcap_tx_trace
(vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame,
int sw_if_index_from_buffer)
{
+ vnet_main_t *vnm = vnet_get_main ();
u32 n_left_from, *from;
u32 sw_if_index;
- vnet_pcap_t *pp = &vlib_global_main.pcap;
+ vnet_pcap_t *pp = &vnm->pcap;
if (PREDICT_TRUE (pp->pcap_tx_enable == 0))
return;
@@ -1047,8 +1048,9 @@ VLIB_NODE_FN (interface_drop) (vlib_main_t * vm,
vlib_node_runtime_t * node,
vlib_frame_t * frame)
{
+ vnet_main_t *vnm = vnet_get_main ();
vnet_interface_main_t *im = &vnet_get_main ()->interface_main;
- vnet_pcap_t *pp = &vlib_global_main.pcap;
+ vnet_pcap_t *pp = &vnm->pcap;
if (PREDICT_FALSE (pp->pcap_drop_enable))
pcap_drop_trace (vm, im, pp, frame);
diff --git a/src/vnet/vnet.h b/src/vnet/vnet.h
index be680a77f98..38777b9b24f 100644
--- a/src/vnet/vnet.h
+++ b/src/vnet/vnet.h
@@ -57,6 +57,21 @@ typedef struct _vnet_ip_table_function_list_elt
clib_error_t *(*fp) (struct vnet_main_t * vnm, u32 table_id, u32 flags);
} _vnet_ip_table_function_list_elt_t;
+typedef struct
+{
+ /* Trace RX pkts */
+ u8 pcap_rx_enable;
+ /* Trace TX pkts */
+ u8 pcap_tx_enable;
+ /* Trace drop pkts */
+ u8 pcap_drop_enable;
+ u8 pad1;
+ u32 max_bytes_per_pkt;
+ u32 pcap_sw_if_index;
+ pcap_main_t pcap_main;
+ u32 filter_classify_table_index;
+} vnet_pcap_t;
+
typedef struct vnet_main_t
{
u32 local_interface_hw_if_index;
@@ -83,13 +98,16 @@ typedef struct vnet_main_t
_vnet_ip_table_function_list_elt_t
* ip_table_add_del_functions[VNET_ITF_FUNC_N_PRIO];
- /*
- * Last "api" error, preserved so we can issue reasonable diagnostics
- * at or near the top of the food chain
- */
- vnet_api_error_t api_errno;
+ /* pcap rx / tx tracing */
+ vnet_pcap_t pcap;
+
+ /*
+ * Last "api" error, preserved so we can issue reasonable diagnostics
+ * at or near the top of the food chain
+ */
+ vnet_api_error_t api_errno;
- vlib_main_t *vlib_main;
+ vlib_main_t *vlib_main;
} vnet_main_t;
extern vnet_main_t vnet_main;