diff options
author | Paul Atkins <patkins@graphiant.com> | 2021-09-22 10:06:23 +0100 |
---|---|---|
committer | Neale Ranns <neale@graphiant.com> | 2021-11-22 09:30:09 +0000 |
commit | 40f9a7ac7ea0c22ee1aade671c871c67af4a5d51 (patch) | |
tree | b30a39fa3b929c944cd9eeb84e763a797091de27 /src/vnet | |
parent | 9e827819a7a442e35fcd171de48d859f84d6bf28 (diff) |
ipfix-export: pass an exp to flow_report_add_del
Pass an ipfix_exporter to this function so that callers can choose which
exporter they are modifying.
Type: improvement
Signed-off-by: Paul Atkins <patkins@graphiant.com>
Change-Id: Ice0ed19a57baf15b1dc85cd27fe01913e36d7f4f
Diffstat (limited to 'src/vnet')
-rw-r--r-- | src/vnet/ipfix-export/flow_api.c | 8 | ||||
-rw-r--r-- | src/vnet/ipfix-export/flow_report.c | 36 | ||||
-rw-r--r-- | src/vnet/ipfix-export/flow_report.h | 43 | ||||
-rw-r--r-- | src/vnet/ipfix-export/flow_report_classify.c | 27 | ||||
-rw-r--r-- | src/vnet/ipfix-export/flow_report_classify.h | 19 |
5 files changed, 60 insertions, 73 deletions
diff --git a/src/vnet/ipfix-export/flow_api.c b/src/vnet/ipfix-export/flow_api.c index 7e4f1fe8626..3636168139d 100644 --- a/src/vnet/ipfix-export/flow_api.c +++ b/src/vnet/ipfix-export/flow_api.c @@ -117,7 +117,7 @@ vl_api_set_ipfix_exporter_t_handler (vl_api_set_ipfix_exporter_t * mp) if (exp->ipfix_collector.as_u32 != collector.as_u32 || exp->src_address.as_u32 != src.as_u32 || exp->collector_port != collector_port) - vnet_flow_reports_reset (frm); + vnet_flow_reports_reset (exp); exp->ipfix_collector.as_u32 = collector.as_u32; exp->collector_port = collector_port; @@ -183,6 +183,7 @@ static void vl_api_set_ipfix_classify_stream_reply_t *rmp; flow_report_classify_main_t *fcm = &flow_report_classify_main; flow_report_main_t *frm = &flow_report_main; + ipfix_exporter_t *exp = &frm->exporters[0]; u32 domain_id = 0; u32 src_port = UDP_DST_PORT_ipfix; int rv = 0; @@ -193,7 +194,7 @@ static void if (fcm->src_port != 0 && (fcm->domain_id != domain_id || fcm->src_port != (u16) src_port)) { - int rv = vnet_stream_change (frm, fcm->domain_id, fcm->src_port, + int rv = vnet_stream_change (exp, fcm->domain_id, fcm->src_port, domain_id, (u16) src_port); ASSERT (rv == 0); } @@ -234,6 +235,7 @@ static void vl_api_registration_t *reg; flow_report_classify_main_t *fcm = &flow_report_classify_main; flow_report_main_t *frm = &flow_report_main; + ipfix_exporter_t *exp = &frm->exporters[0]; vnet_flow_report_add_del_args_t args; ipfix_classify_table_t *table; int is_add; @@ -299,7 +301,7 @@ static void args.domain_id = fcm->domain_id; args.src_port = fcm->src_port; - rv = vnet_flow_report_add_del (frm, &args, NULL); + rv = vnet_flow_report_add_del (exp, &args, NULL); /* If deleting, or add failed */ if (is_add == 0 || (rv && is_add)) diff --git a/src/vnet/ipfix-export/flow_report.c b/src/vnet/ipfix-export/flow_report.c index 0da47e11cb4..cc042799d5a 100644 --- a/src/vnet/ipfix-export/flow_report.c +++ b/src/vnet/ipfix-export/flow_report.c @@ -101,7 +101,7 @@ send_template_packet (flow_report_main_t * frm, if (fr->update_rewrite) { fr->rewrite = fr->rewrite_callback ( - frm, fr, &exp->ipfix_collector, &exp->src_address, exp->collector_port, + exp, fr, &exp->ipfix_collector, &exp->src_address, exp->collector_port, fr->report_elements, fr->n_report_elements, fr->stream_indexp); fr->update_rewrite = 0; } @@ -155,13 +155,12 @@ send_template_packet (flow_report_main_t * frm, } u8 * -vnet_flow_rewrite_generic_callback (flow_report_main_t * frm, - flow_report_t * fr, - ip4_address_t * collector_address, - ip4_address_t * src_address, +vnet_flow_rewrite_generic_callback (ipfix_exporter_t *exp, flow_report_t *fr, + ip4_address_t *collector_address, + ip4_address_t *src_address, u16 collector_port, - ipfix_report_element_t * report_elts, - u32 n_elts, u32 * stream_indexp) + ipfix_report_element_t *report_elts, + u32 n_elts, u32 *stream_indexp) { ip4_header_t *ip; udp_header_t *udp; @@ -175,7 +174,6 @@ vnet_flow_rewrite_generic_callback (flow_report_main_t * frm, flow_report_stream_t *stream; int i; ipfix_report_element_t *ep; - ipfix_exporter_t *exp = pool_elt_at_index (frm->exporters, 0); ASSERT (stream_indexp); ASSERT (n_elts); @@ -316,7 +314,7 @@ flow_report_process (vlib_main_t * vm, nf->n_vectors++; } - nf = fr->flow_data_callback (frm, fr, nf, to_next, + nf = fr->flow_data_callback (frm, exp, fr, nf, to_next, ip4_lookup_node_index); if (nf) vlib_put_frame_to_node (vm, ip4_lookup_node_index, nf); @@ -335,16 +333,14 @@ VLIB_REGISTER_NODE (flow_report_process_node) = { /* *INDENT-ON* */ int -vnet_flow_report_add_del (flow_report_main_t * frm, - vnet_flow_report_add_del_args_t * a, - u16 * template_id) +vnet_flow_report_add_del (ipfix_exporter_t *exp, + vnet_flow_report_add_del_args_t *a, u16 *template_id) { int i; int found_index = ~0; flow_report_t *fr; flow_report_stream_t *stream; u32 si; - ipfix_exporter_t *exp = pool_elt_at_index (frm->exporters, 0); si = find_stream (exp, a->domain_id, a->src_port); if (si == -2) @@ -437,11 +433,10 @@ flow_report_add_del_error_to_clib_error (int error) } void -vnet_flow_reports_reset (flow_report_main_t * frm) +vnet_flow_reports_reset (ipfix_exporter_t *exp) { flow_report_t *fr; u32 i; - ipfix_exporter_t *exp = pool_elt_at_index (frm->exporters, 0); for (i = 0; i < vec_len (exp->streams); i++) if (stream_index_valid (exp, i)) @@ -455,10 +450,9 @@ vnet_flow_reports_reset (flow_report_main_t * frm) } void -vnet_stream_reset (flow_report_main_t * frm, u32 stream_index) +vnet_stream_reset (ipfix_exporter_t *exp, u32 stream_index) { flow_report_t *fr; - ipfix_exporter_t *exp = pool_elt_at_index (frm->exporters, 0); exp->streams[stream_index].sequence_number = 0; @@ -471,11 +465,9 @@ vnet_stream_reset (flow_report_main_t * frm, u32 stream_index) } int -vnet_stream_change (flow_report_main_t * frm, - u32 old_domain_id, u16 old_src_port, +vnet_stream_change (ipfix_exporter_t *exp, u32 old_domain_id, u16 old_src_port, u32 new_domain_id, u16 new_src_port) { - ipfix_exporter_t *exp = pool_elt_at_index (frm->exporters, 0); i32 stream_index = find_stream (exp, old_domain_id, old_src_port); if (stream_index < 0) @@ -484,7 +476,7 @@ vnet_stream_change (flow_report_main_t * frm, stream->domain_id = new_domain_id; stream->src_port = new_src_port; if (old_domain_id != new_domain_id || old_src_port != new_src_port) - vnet_stream_reset (frm, stream_index); + vnet_stream_reset (exp, stream_index); return 0; } @@ -546,7 +538,7 @@ set_ipfix_exporter_command_fn (vlib_main_t * vm, if (exp->ipfix_collector.as_u32 != collector.as_u32 || exp->src_address.as_u32 != src.as_u32 || exp->collector_port != collector_port) - vnet_flow_reports_reset (frm); + vnet_flow_reports_reset (exp); exp->ipfix_collector.as_u32 = collector.as_u32; exp->collector_port = collector_port; diff --git a/src/vnet/ipfix-export/flow_report.h b/src/vnet/ipfix-export/flow_report.h index d1f308011b8..7f0c92d3a92 100644 --- a/src/vnet/ipfix-export/flow_report.h +++ b/src/vnet/ipfix-export/flow_report.h @@ -47,25 +47,23 @@ typedef struct struct flow_report_main; struct flow_report; +struct ipfix_exporter; -typedef vlib_frame_t *(vnet_flow_data_callback_t) (struct flow_report_main *, - struct flow_report *, - vlib_frame_t *, u32 *, - u32); +typedef vlib_frame_t *(vnet_flow_data_callback_t) ( + struct flow_report_main *frm, struct ipfix_exporter *exp, + struct flow_report *, vlib_frame_t *, u32 *, u32); -typedef u8 *(vnet_flow_rewrite_callback_t) (struct flow_report_main *, +typedef u8 *(vnet_flow_rewrite_callback_t) (struct ipfix_exporter *exp, struct flow_report *, - ip4_address_t *, - ip4_address_t *, u16, - ipfix_report_element_t * elts, - u32 n_elts, u32 * stream_index); - -u8 *vnet_flow_rewrite_generic_callback (struct flow_report_main *, - struct flow_report *, - ip4_address_t *, + ip4_address_t *, ip4_address_t *, + u16, ipfix_report_element_t *elts, + u32 n_elts, u32 *stream_index); + +u8 *vnet_flow_rewrite_generic_callback (struct ipfix_exporter *exp, + struct flow_report *, ip4_address_t *, ip4_address_t *, u16, - ipfix_report_element_t * elts, - u32 n_elts, u32 * stream_index); + ipfix_report_element_t *elts, + u32 n_elts, u32 *stream_index); typedef union { @@ -174,19 +172,18 @@ typedef struct u32 *stream_indexp; } 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, - u16 * template_id); +int vnet_flow_report_add_del (ipfix_exporter_t *exp, + vnet_flow_report_add_del_args_t *a, + u16 *template_id); clib_error_t *flow_report_add_del_error_to_clib_error (int error); -void vnet_flow_reports_reset (flow_report_main_t * frm); +void vnet_flow_reports_reset (ipfix_exporter_t *exp); -void vnet_stream_reset (flow_report_main_t * frm, u32 stream_index); +void vnet_stream_reset (ipfix_exporter_t *exp, u32 stream_index); -int vnet_stream_change (flow_report_main_t * frm, - u32 old_domain_id, u16 old_src_port, - u32 new_domain_id, u16 new_src_port); +int vnet_stream_change (ipfix_exporter_t *exp, u32 old_domain_id, + u16 old_src_port, u32 new_domain_id, u16 new_src_port); #endif /* __included_vnet_flow_report_h__ */ diff --git a/src/vnet/ipfix-export/flow_report_classify.c b/src/vnet/ipfix-export/flow_report_classify.c index 35abf979bd9..717d2966fbf 100644 --- a/src/vnet/ipfix-export/flow_report_classify.c +++ b/src/vnet/ipfix-export/flow_report_classify.c @@ -29,13 +29,12 @@ typedef struct flow_report_classify_main_t flow_report_classify_main; u8 * -ipfix_classify_template_rewrite (flow_report_main_t * frm, - flow_report_t * fr, - ip4_address_t * collector_address, - ip4_address_t * src_address, +ipfix_classify_template_rewrite (ipfix_exporter_t *exp, flow_report_t *fr, + ip4_address_t *collector_address, + ip4_address_t *src_address, u16 collector_port, - ipfix_report_element_t * elts, - u32 n_elts, u32 * stream_index) + ipfix_report_element_t *elts, u32 n_elts, + u32 *stream_index) { flow_report_classify_main_t *fcm = &flow_report_classify_main; vnet_classify_table_t *tblp; @@ -60,7 +59,6 @@ ipfix_classify_template_rewrite (flow_report_main_t * frm, u8 transport_protocol; u8 *virt_mask; u8 *real_mask; - ipfix_exporter_t *exp = pool_elt_at_index (frm->exporters, 0); stream = &exp->streams[fr->stream_index]; @@ -159,9 +157,9 @@ ipfix_classify_template_rewrite (flow_report_main_t * frm, } vlib_frame_t * -ipfix_classify_send_flows (flow_report_main_t * frm, - flow_report_t * fr, - vlib_frame_t * f, u32 * to_next, u32 node_index) +ipfix_classify_send_flows (flow_report_main_t *frm, ipfix_exporter_t *exp, + flow_report_t *fr, vlib_frame_t *f, u32 *to_next, + u32 node_index) { flow_report_classify_main_t *fcm = &flow_report_classify_main; vnet_classify_main_t *vcm = &vnet_classify_main; @@ -191,7 +189,6 @@ ipfix_classify_send_flows (flow_report_main_t * frm, u8 ip_version; u8 transport_protocol; u8 *virt_key; - ipfix_exporter_t *exp = pool_elt_at_index (frm->exporters, 0); stream = &exp->streams[fr->stream_index]; @@ -399,7 +396,7 @@ ipfix_classify_table_add_del_command_fn (vlib_main_t * vm, vlib_cli_command_t * cmd) { flow_report_classify_main_t *fcm = &flow_report_classify_main; - flow_report_main_t *frm = &flow_report_main; + ipfix_exporter_t *exp = &flow_report_main.exporters[0]; vnet_flow_report_add_del_args_t args; ipfix_classify_table_t *table; int rv; @@ -477,7 +474,7 @@ ipfix_classify_table_add_del_command_fn (vlib_main_t * vm, args.domain_id = fcm->domain_id; args.src_port = fcm->src_port; - rv = vnet_flow_report_add_del (frm, &args, NULL); + rv = vnet_flow_report_add_del (exp, &args, NULL); error = flow_report_add_del_error_to_clib_error (rv); @@ -502,7 +499,7 @@ set_ipfix_classify_stream_command_fn (vlib_main_t * vm, vlib_cli_command_t * cmd) { flow_report_classify_main_t *fcm = &flow_report_classify_main; - flow_report_main_t *frm = &flow_report_main; + ipfix_exporter_t *exp = &flow_report_main.exporters[0]; u32 domain_id = 1; u32 src_port = UDP_DST_PORT_ipfix; @@ -520,7 +517,7 @@ set_ipfix_classify_stream_command_fn (vlib_main_t * vm, if (fcm->src_port != 0 && (fcm->domain_id != domain_id || fcm->src_port != (u16) src_port)) { - int rv = vnet_stream_change (frm, fcm->domain_id, fcm->src_port, + int rv = vnet_stream_change (exp, fcm->domain_id, fcm->src_port, domain_id, (u16) src_port); ASSERT (rv == 0); } diff --git a/src/vnet/ipfix-export/flow_report_classify.h b/src/vnet/ipfix-export/flow_report_classify.h index a923f36714a..3199c85f68f 100644 --- a/src/vnet/ipfix-export/flow_report_classify.h +++ b/src/vnet/ipfix-export/flow_report_classify.h @@ -112,18 +112,17 @@ ipfix_classify_delete_table (u32 index) fcm->tables[index].classify_table_index = ~0; } -u8 *ipfix_classify_template_rewrite (flow_report_main_t * frm, - flow_report_t * fr, - ip4_address_t * collector_address, - ip4_address_t * src_address, +u8 *ipfix_classify_template_rewrite (ipfix_exporter_t *exp, flow_report_t *fr, + ip4_address_t *collector_address, + ip4_address_t *src_address, u16 collector_port, - ipfix_report_element_t * elts, - u32 n_elts, u32 * stream_index); + ipfix_report_element_t *elts, u32 n_elts, + u32 *stream_index); -vlib_frame_t *ipfix_classify_send_flows (flow_report_main_t * frm, - flow_report_t * fr, - vlib_frame_t * f, - u32 * to_next, u32 node_index); +vlib_frame_t *ipfix_classify_send_flows (flow_report_main_t *frm, + ipfix_exporter_t *exp, + flow_report_t *fr, vlib_frame_t *f, + u32 *to_next, u32 node_index); #endif /* __included_flow_report_classify_h__ */ |