ipfix-export: refactor params to the callback fns

When a new flow-report is created the caller provides 2 callback functions.
These functions both take a pointer to the exporter, plus a pointer to the
source and dest address.  However the pointers to the address are not adding
any value as these are always set to the src/dest addresses of the exporter
(which is already being passed). Remove these parameters and leave the
callback functions to get the addresses out of the exporter.

Type: improvement
Signed-off-by: Paul Atkins <patkins@graphiant.com>
Change-Id: I36dec394f30e85cdca120dd8706b5d90f5e07c48
This commit is contained in:
Paul Atkins
2021-10-04 16:29:52 +01:00
committed by Neale Ranns
parent 19a5f23b23
commit c2d476b26d
9 changed files with 46 additions and 86 deletions

View File

@ -203,8 +203,6 @@ flowprobe_template_l4_fields (ipfix_field_specifier_t * f)
*/
static inline u8 *
flowprobe_template_rewrite_inline (ipfix_exporter_t *exp, flow_report_t *fr,
ip4_address_t *collector_address,
ip4_address_t *src_address,
u16 collector_port,
flowprobe_variant_t which)
{
@ -262,8 +260,8 @@ flowprobe_template_rewrite_inline (ipfix_exporter_t *exp, flow_report_t *fr,
ip->ip_version_and_header_length = 0x45;
ip->ttl = 254;
ip->protocol = IP_PROTOCOL_UDP;
ip->src_address.as_u32 = src_address->as_u32;
ip->dst_address.as_u32 = collector_address->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 (collector_port);
udp->length = clib_host_to_net_u16 (vec_len (rewrite) - sizeof (*ip));
@ -309,60 +307,51 @@ flowprobe_template_rewrite_inline (ipfix_exporter_t *exp, flow_report_t *fr,
static u8 *
flowprobe_template_rewrite_ip6 (ipfix_exporter_t *exp, flow_report_t *fr,
ip4_address_t *collector_address,
ip4_address_t *src_address, u16 collector_port,
u16 collector_port,
ipfix_report_element_t *elts, u32 n_elts,
u32 *stream_index)
{
return flowprobe_template_rewrite_inline (
exp, fr, collector_address, src_address, collector_port, FLOW_VARIANT_IP6);
return flowprobe_template_rewrite_inline (exp, fr, collector_port,
FLOW_VARIANT_IP6);
}
static u8 *
flowprobe_template_rewrite_ip4 (ipfix_exporter_t *exp, flow_report_t *fr,
ip4_address_t *collector_address,
ip4_address_t *src_address, u16 collector_port,
u16 collector_port,
ipfix_report_element_t *elts, u32 n_elts,
u32 *stream_index)
{
return flowprobe_template_rewrite_inline (
exp, fr, collector_address, src_address, collector_port, FLOW_VARIANT_IP4);
return flowprobe_template_rewrite_inline (exp, fr, collector_port,
FLOW_VARIANT_IP4);
}
static u8 *
flowprobe_template_rewrite_l2 (ipfix_exporter_t *exp, flow_report_t *fr,
ip4_address_t *collector_address,
ip4_address_t *src_address, u16 collector_port,
u16 collector_port,
ipfix_report_element_t *elts, u32 n_elts,
u32 *stream_index)
{
return flowprobe_template_rewrite_inline (
exp, fr, collector_address, src_address, collector_port, FLOW_VARIANT_L2);
return flowprobe_template_rewrite_inline (exp, fr, collector_port,
FLOW_VARIANT_L2);
}
static u8 *
flowprobe_template_rewrite_l2_ip4 (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)
{
return flowprobe_template_rewrite_inline (exp, fr, collector_address,
src_address, collector_port,
return flowprobe_template_rewrite_inline (exp, fr, collector_port,
FLOW_VARIANT_L2_IP4);
}
static u8 *
flowprobe_template_rewrite_l2_ip6 (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)
{
return flowprobe_template_rewrite_inline (exp, fr, collector_address,
src_address, collector_port,
return flowprobe_template_rewrite_inline (exp, fr, collector_port,
FLOW_VARIANT_L2_IP6);
}

View File

@ -21,10 +21,8 @@
u8 *
ioam_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)
u16 collector_port, ipfix_report_element_t *elts,
u32 n_elts, u32 *stream_index)
{
ip4_header_t *ip;
udp_header_t *udp;
@ -74,8 +72,8 @@ ioam_template_rewrite (ipfix_exporter_t *exp, flow_report_t *fr,
ip->ip_version_and_header_length = 0x45;
ip->ttl = 254;
ip->protocol = IP_PROTOCOL_UDP;
ip->src_address.as_u32 = src_address->as_u32;
ip->dst_address.as_u32 = collector_address->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 (collector_port);
udp->dst_port = clib_host_to_net_u16 (UDP_DST_PORT_ipfix);
udp->length = clib_host_to_net_u16 (vec_len (rewrite) - sizeof (*ip));

View File

@ -66,10 +66,8 @@ typedef struct
clib_error_t *ioam_flow_create (u8 del);
u8 *ioam_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);
u16 collector_port, ipfix_report_element_t *elts,
u32 n_elts, u32 *stream_index);
u16 ioam_analyse_add_ipfix_record (flow_report_t * fr,
ioam_analyser_data_t * record,

View File

@ -24,13 +24,11 @@
static u8 *
udp_ping_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)
u16 collector_port, ipfix_report_element_t *elts,
u32 n_elts, u32 *stream_index)
{
return ioam_template_rewrite (exp, fr, collector_address, src_address,
collector_port, elts, n_elts, stream_index);
return ioam_template_rewrite (exp, fr, collector_port, elts, n_elts,
stream_index);
}
static vlib_frame_t *

View File

@ -144,9 +144,8 @@ do { \
*/
static inline u8 *
nat_template_rewrite (ipfix_exporter_t *exp, flow_report_t *fr,
ip4_address_t *collector_address,
ip4_address_t *src_address, u16 collector_port,
nat_event_t event, quota_exceed_event_t quota_event)
u16 collector_port, nat_event_t event,
quota_exceed_event_t quota_event)
{
nat_ipfix_logging_main_t *silm = &nat_ipfix_logging_main;
ip4_header_t *ip;
@ -239,8 +238,8 @@ nat_template_rewrite (ipfix_exporter_t *exp, flow_report_t *fr,
ip->ip_version_and_header_length = 0x45;
ip->ttl = 254;
ip->protocol = IP_PROTOCOL_UDP;
ip->src_address.as_u32 = src_address->as_u32;
ip->dst_address.as_u32 = collector_address->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 (collector_port);
udp->length = clib_host_to_net_u16 (vec_len (rewrite) - sizeof (*ip));
@ -389,26 +388,22 @@ nat_template_rewrite (ipfix_exporter_t *exp, flow_report_t *fr,
u8 *
nat_template_rewrite_addr_exhausted (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)
{
return nat_template_rewrite (exp, fr, collector_address, src_address,
collector_port, NAT_ADDRESSES_EXHAUTED, 0);
return nat_template_rewrite (exp, fr, collector_port, NAT_ADDRESSES_EXHAUTED,
0);
}
u8 *
nat_template_rewrite_nat44_session (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)
{
return nat_template_rewrite (exp, fr, collector_address, src_address,
collector_port, NAT44_SESSION_CREATE, 0);
return nat_template_rewrite (exp, fr, collector_port, NAT44_SESSION_CREATE,
0);
}
u8 *
@ -417,57 +412,47 @@ nat_template_rewrite_max_entries_per_usr (
ip4_address_t *src_address, u16 collector_port, ipfix_report_element_t *elts,
u32 n_elts, u32 *stream_index)
{
return nat_template_rewrite (exp, fr, collector_address, src_address,
collector_port, QUOTA_EXCEEDED,
return nat_template_rewrite (exp, fr, collector_port, QUOTA_EXCEEDED,
MAX_ENTRIES_PER_USER);
}
u8 *
nat_template_rewrite_max_sessions (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)
{
return nat_template_rewrite (exp, fr, collector_address, src_address,
collector_port, QUOTA_EXCEEDED,
return nat_template_rewrite (exp, fr, collector_port, QUOTA_EXCEEDED,
MAX_SESSION_ENTRIES);
}
u8 *
nat_template_rewrite_max_bibs (ipfix_exporter_t *exp, flow_report_t *fr,
ip4_address_t *collector_address,
ip4_address_t *src_address, u16 collector_port,
u16 collector_port,
ipfix_report_element_t *elts, u32 n_elts,
u32 *stream_index)
{
return nat_template_rewrite (exp, fr, collector_address, src_address,
collector_port, QUOTA_EXCEEDED,
return nat_template_rewrite (exp, fr, collector_port, QUOTA_EXCEEDED,
MAX_BIB_ENTRIES);
}
u8 *
nat_template_rewrite_nat64_bib (ipfix_exporter_t *exp, flow_report_t *fr,
ip4_address_t *collector_address,
ip4_address_t *src_address, u16 collector_port,
u16 collector_port,
ipfix_report_element_t *elts, u32 n_elts,
u32 *stream_index)
{
return nat_template_rewrite (exp, fr, collector_address, src_address,
collector_port, NAT64_BIB_CREATE, 0);
return nat_template_rewrite (exp, fr, collector_port, NAT64_BIB_CREATE, 0);
}
u8 *
nat_template_rewrite_nat64_session (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)
{
return nat_template_rewrite (exp, fr, collector_address, src_address,
collector_port, NAT64_SESSION_CREATE, 0);
return nat_template_rewrite (exp, fr, collector_port, NAT64_SESSION_CREATE,
0);
}
static inline void

View File

@ -101,8 +101,8 @@ send_template_packet (flow_report_main_t *frm, ipfix_exporter_t *exp,
if (fr->update_rewrite)
{
fr->rewrite = fr->rewrite_callback (
exp, fr, &exp->ipfix_collector, &exp->src_address, exp->collector_port,
fr->report_elements, fr->n_report_elements, fr->stream_indexp);
exp, fr, exp->collector_port, fr->report_elements,
fr->n_report_elements, fr->stream_indexp);
fr->update_rewrite = 0;
}
@ -156,8 +156,6 @@ send_template_packet (flow_report_main_t *frm, ipfix_exporter_t *exp,
u8 *
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)
@ -200,8 +198,8 @@ vnet_flow_rewrite_generic_callback (ipfix_exporter_t *exp, flow_report_t *fr,
ip->ip_version_and_header_length = 0x45;
ip->ttl = 254;
ip->protocol = IP_PROTOCOL_UDP;
ip->src_address.as_u32 = src_address->as_u32;
ip->dst_address.as_u32 = collector_address->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 (collector_port);
udp->length = clib_host_to_net_u16 (vec_len (rewrite) - sizeof (*ip));

View File

@ -56,13 +56,11 @@ typedef vlib_frame_t *(vnet_flow_data_callback_t) (
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 ipfix_exporter *exp,
struct flow_report *, ip4_address_t *,
ip4_address_t *, u16,
struct flow_report *, u16,
ipfix_report_element_t *elts,
u32 n_elts, u32 *stream_index);

View File

@ -30,8 +30,6 @@ flow_report_classify_main_t flow_report_classify_main;
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)
@ -108,8 +106,8 @@ ipfix_classify_template_rewrite (ipfix_exporter_t *exp, flow_report_t *fr,
ip->ip_version_and_header_length = 0x45;
ip->ttl = 254;
ip->protocol = IP_PROTOCOL_UDP;
ip->src_address.as_u32 = src_address->as_u32;
ip->dst_address.as_u32 = collector_address->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 (collector_port);
udp->length = clib_host_to_net_u16 (vec_len (rewrite) - sizeof (*ip));

View File

@ -113,8 +113,6 @@ ipfix_classify_delete_table (u32 index)
}
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);