diff options
author | Paul Atkins <patkins@graphiant.com> | 2021-09-21 20:49:12 +0100 |
---|---|---|
committer | Neale Ranns <neale@graphiant.com> | 2021-11-22 09:30:09 +0000 |
commit | 9ec6449e298ed10695c4afbba951ac46daa52e43 (patch) | |
tree | ef9589f9e172ea905587812e440c3dfc9d1fc5a0 /src/plugins/flowprobe/node.c | |
parent | a3767bda9817eab15dd0eca0955d5ad194ec8840 (diff) |
ipfix-export: refactor fields in flow_report_main
Pull out the fields in flow_report_main_t that are specific to a single
exporter and move them into a new structure that represents an exporter.
Add a pool of exporters to flow_report_main_t and do a pool_get() to get
the entry at index 0, so that the existing users of the code need only
change the path at which they access the old fields and have no need to
make further code changes. In functions that were accessing the fields
that now make up the ipfix_exporter create a local var that points to the
first (always valid) exporter and use this as the base for the fields
rather than finding them from flow_report_main.
This is in preparation for supporting multiple flow_exporters.
Note that at the moment the code supports multiple 'streams' for a given
exporter, where each stream has its own source port, domain id and template
space. But all streams within an exporter have the same destination address,
so this is not the same as multiple exporters.
Type: refactor
Signed-off-by: Paul Atkins <patkins@graphiant.com>
Change-Id: I49f5c7fb9e901773351d31dc8a59178c37e99301
Diffstat (limited to 'src/plugins/flowprobe/node.c')
-rw-r--r-- | src/plugins/flowprobe/node.c | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/src/plugins/flowprobe/node.c b/src/plugins/flowprobe/node.c index fd5d60f7eac..611ce62956b 100644 --- a/src/plugins/flowprobe/node.c +++ b/src/plugins/flowprobe/node.c @@ -533,6 +533,7 @@ flowprobe_export_send (vlib_main_t * vm, vlib_buffer_t * b0, { flowprobe_main_t *fm = &flowprobe_main; flow_report_main_t *frm = &flow_report_main; + ipfix_exporter_t *exp = pool_elt_at_index (frm->exporters, 0); vlib_frame_t *f; ip4_ipfix_template_packet_t *tp; ipfix_set_header_t *s; @@ -550,19 +551,19 @@ flowprobe_export_send (vlib_main_t * vm, vlib_buffer_t * b0, flowprobe_get_headersize ()) return; - u32 i, index = vec_len (frm->streams); + u32 i, index = vec_len (exp->streams); for (i = 0; i < index; i++) - if (frm->streams[i].domain_id == 1) + if (exp->streams[i].domain_id == 1) { index = i; break; } - if (i == vec_len (frm->streams)) + if (i == vec_len (exp->streams)) { - vec_validate (frm->streams, index); - frm->streams[index].domain_id = 1; + vec_validate (exp->streams, index); + exp->streams[index].domain_id = 1; } - stream = &frm->streams[index]; + stream = &exp->streams[index]; tp = vlib_buffer_get_current (b0); ip = (ip4_header_t *) & tp->ip4; @@ -574,10 +575,10 @@ flowprobe_export_send (vlib_main_t * vm, vlib_buffer_t * b0, ip->ttl = 254; ip->protocol = IP_PROTOCOL_UDP; ip->flags_and_fragment_offset = 0; - ip->src_address.as_u32 = frm->src_address.as_u32; - ip->dst_address.as_u32 = frm->ipfix_collector.as_u32; + ip->src_address.as_u32 = exp->src_address.as_u32; + ip->dst_address.as_u32 = exp->ipfix_collector.as_u32; udp->src_port = clib_host_to_net_u16 (stream->src_port); - udp->dst_port = clib_host_to_net_u16 (frm->collector_port); + udp->dst_port = clib_host_to_net_u16 (exp->collector_port); udp->checksum = 0; /* FIXUP: message header export_time */ @@ -603,7 +604,7 @@ flowprobe_export_send (vlib_main_t * vm, vlib_buffer_t * b0, ip->checksum = ip4_header_checksum (ip); udp->length = clib_host_to_net_u16 (b0->current_length - sizeof (*ip)); - if (frm->udp_checksum) + if (exp->udp_checksum) { /* RFC 7011 section 10.3.2. */ udp->checksum = ip4_tcp_udp_compute_checksum (vm, b0, ip); @@ -642,7 +643,7 @@ static vlib_buffer_t * flowprobe_get_buffer (vlib_main_t * vm, flowprobe_variant_t which) { flowprobe_main_t *fm = &flowprobe_main; - flow_report_main_t *frm = &flow_report_main; + ipfix_exporter_t *exp = pool_elt_at_index (flow_report_main.exporters, 0); vlib_buffer_t *b0; u32 bi0; u32 my_cpu_number = vm->thread_index; @@ -669,7 +670,7 @@ flowprobe_get_buffer (vlib_main_t * vm, flowprobe_variant_t which) b0->flags |= (VLIB_BUFFER_TOTAL_LENGTH_VALID | VNET_BUFFER_F_FLOW_REPORT); vnet_buffer (b0)->sw_if_index[VLIB_RX] = 0; - vnet_buffer (b0)->sw_if_index[VLIB_TX] = frm->fib_index; + vnet_buffer (b0)->sw_if_index[VLIB_TX] = exp->fib_index; fm->context[which].next_record_offset_per_worker[my_cpu_number] = b0->current_length; } @@ -682,7 +683,7 @@ flowprobe_export_entry (vlib_main_t * vm, flowprobe_entry_t * e) { u32 my_cpu_number = vm->thread_index; flowprobe_main_t *fm = &flowprobe_main; - flow_report_main_t *frm = &flow_report_main; + ipfix_exporter_t *exp = pool_elt_at_index (flow_report_main.exporters, 0); vlib_buffer_t *b0; bool collect_ip4 = false, collect_ip6 = false; flowprobe_variant_t which = e->key.which; @@ -724,7 +725,7 @@ flowprobe_export_entry (vlib_main_t * vm, flowprobe_entry_t * e) fm->context[which].next_record_offset_per_worker[my_cpu_number] = offset; /* Time to flush the buffer? */ - if (offset + fm->template_size[flags] > frm->path_mtu) + if (offset + fm->template_size[flags] > exp->path_mtu) flowprobe_export_send (vm, b0, which); } @@ -935,14 +936,14 @@ flowprobe_walker_process (vlib_main_t * vm, vlib_node_runtime_t * rt, vlib_frame_t * f) { flowprobe_main_t *fm = &flowprobe_main; - flow_report_main_t *frm = &flow_report_main; flowprobe_entry_t *e; + ipfix_exporter_t *exp = pool_elt_at_index (flow_report_main.exporters, 0); /* * $$$$ Remove this check from here and track FRM status and disable * this process if required. */ - if (frm->ipfix_collector.as_u32 == 0 || frm->src_address.as_u32 == 0) + if (exp->ipfix_collector.as_u32 == 0 || exp->src_address.as_u32 == 0) { fm->disabled = true; return 0; |