diff options
author | Hadi Rayan Al-Sandid <halsandi@cisco.com> | 2024-11-26 15:58:40 +0100 |
---|---|---|
committer | Hadi Rayan Al-Sandid <halsandi@cisco.com> | 2024-12-11 08:58:32 +0000 |
commit | fb8f51697c748d28d4b542554a96a83ab74f6678 (patch) | |
tree | 670ea73a70444973658797bfdf4648ccabc9c708 /src/vnet | |
parent | dd02eb893b485a290a47ddca7d76ecedb45a5063 (diff) |
bpf_trace_filter: allow pcap filtering without classifier
Type: improvement
Change-Id: I7ca860dbee0d0a24b7f00943142d8c878ed90e80
Signed-off-by: Hadi Rayan Al-Sandid <halsandi@cisco.com>
Diffstat (limited to 'src/vnet')
-rw-r--r-- | src/vnet/classify/pcap_classify.h | 2 | ||||
-rw-r--r-- | src/vnet/interface_cli.c | 21 | ||||
-rw-r--r-- | src/vnet/vnet.h | 2 |
3 files changed, 12 insertions, 13 deletions
diff --git a/src/vnet/classify/pcap_classify.h b/src/vnet/classify/pcap_classify.h index a4ebcd1241c..c23267fd504 100644 --- a/src/vnet/classify/pcap_classify.h +++ b/src/vnet/classify/pcap_classify.h @@ -46,7 +46,7 @@ vnet_is_packet_pcaped (vnet_pcap_t *pp, vlib_buffer_t *b, u32 sw_if_index) if (pcap_error_index != (vlib_error_t) ~0 && pcap_error_index != b->error) return 0; /* wrong error */ - if (filter_classify_table_index != ~0 && + if (pp->pcap_filter_enable && pp->current_filter_function (b, filter_classify_table_index, 0 /* full classify */) != 1) return 0; /* not matching the filter, skip */ diff --git a/src/vnet/interface_cli.c b/src/vnet/interface_cli.c index c56eb9777cf..cc214c10f6b 100644 --- a/src/vnet/interface_cli.c +++ b/src/vnet/interface_cli.c @@ -2041,6 +2041,12 @@ format_vnet_pcap (u8 * s, va_list * args) s = format (s, "drop"); printed = 1; } + + if (printed && pp->pcap_filter_enable) + { + s = format (s, "with filter"); + printed = 1; + } return s; } s = format (s, "unknown type %d!", type); @@ -2092,12 +2098,6 @@ vnet_pcap_dispatch_trace_configure (vnet_pcap_dispatch_trace_args_t * a) && (pm->n_packets_to_capture != a->packets_to_capture)) return VNET_API_ERROR_INVALID_VALUE_2; - /* Classify filter specified, but no classify filter configured */ - if ((a->rx_enable + a->tx_enable + a->drop_enable) && a->filter && - (!cm->classify_table_index_by_sw_if_index || - cm->classify_table_index_by_sw_if_index[0] == ~0)) - return VNET_API_ERROR_NO_SUCH_LABEL; - if (a->rx_enable + a->tx_enable + a->drop_enable) { void *save_pcap_data; @@ -2151,11 +2151,13 @@ vnet_pcap_dispatch_trace_configure (vnet_pcap_dispatch_trace_args_t * a) } pm->n_packets_to_capture = a->packets_to_capture; pp->pcap_sw_if_index = a->sw_if_index; - if (a->filter) + if (a->filter && cm->classify_table_index_by_sw_if_index && + cm->classify_table_index_by_sw_if_index[0] != ~0) pp->filter_classify_table_index = cm->classify_table_index_by_sw_if_index[0]; else pp->filter_classify_table_index = ~0; + pp->pcap_filter_enable = a->filter; pp->pcap_error_index = a->drop_err; pp->pcap_rx_enable = a->rx_enable; pp->pcap_tx_enable = a->tx_enable; @@ -2164,6 +2166,7 @@ vnet_pcap_dispatch_trace_configure (vnet_pcap_dispatch_trace_args_t * a) } else { + pp->pcap_filter_enable = 0; pp->pcap_rx_enable = 0; pp->pcap_tx_enable = 0; pp->pcap_drop_enable = 0; @@ -2312,10 +2315,6 @@ pcap_trace_command_fn (vlib_main_t * vm, return clib_error_return (0, "Max bytes per pkt must be > 32, < 9000..."); - case VNET_API_ERROR_NO_SUCH_LABEL: - return clib_error_return - (0, "No classify filter configured, see 'classify filter...'"); - default: vlib_cli_output (vm, "WARNING: trace configure returned %d", rv); break; diff --git a/src/vnet/vnet.h b/src/vnet/vnet.h index 54988aec667..6e436cc3952 100644 --- a/src/vnet/vnet.h +++ b/src/vnet/vnet.h @@ -66,7 +66,7 @@ typedef struct u8 pcap_tx_enable; /* Trace drop pkts */ u8 pcap_drop_enable; - u8 pad1; + u8 pcap_filter_enable; u32 max_bytes_per_pkt; u32 pcap_sw_if_index; pcap_main_t pcap_main; |