1
0
mirror of https://git.FreeBSD.org/src.git synced 2025-01-17 15:27:36 +00:00

Add NG_NETFLOW_V9INFO_TYPE command to be able to request netflowv9-specific

data.

Submitted by:	Dmitry Luhtionov <dmitryluhtionov at gmail.com>
MFC after:	2 weeks
This commit is contained in:
Alexander V. Chernikov 2012-10-11 16:15:18 +00:00
parent 8cc6481cd5
commit 10fcb07c91
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=241446
3 changed files with 56 additions and 0 deletions

View File

@ -480,3 +480,14 @@ ng_netflow_v9_cache_flush(priv_p priv)
for (i = 0; i < priv->flowsets_count; i++)
free(priv->v9_flowsets[i], M_NETFLOW_GENERAL);
}
/* Get a snapshot of NetFlow v9 settings */
void
ng_netflow_copyv9info(priv_p priv, struct ng_netflow_v9info *i)
{
i->templ_time = priv->templ_time;
i->templ_packets = priv->templ_packets;
i->mtu = priv->mtu;
}

View File

@ -138,6 +138,14 @@ static const struct ng_parse_type ng_netflow_setmtu_type = {
&ng_netflow_setmtu_type_fields
};
/* Parse type for struct ng_netflow_v9info */
static const struct ng_parse_struct_field ng_netflow_v9info_type_fields[]
= NG_NETFLOW_V9INFO_TYPE;
static const struct ng_parse_type ng_netflow_v9info_type = {
&ng_parse_struct_type,
&ng_netflow_v9info_type_fields
};
/* List of commands and how to convert arguments to/from ASCII */
static const struct ng_cmdlist ng_netflow_cmds[] = {
{
@ -196,6 +204,13 @@ static const struct ng_cmdlist ng_netflow_cmds[] = {
&ng_netflow_setmtu_type,
NULL
},
{
NGM_NETFLOW_COOKIE,
NGM_NETFLOW_V9INFO,
"v9info",
NULL,
&ng_netflow_v9info_type
},
{ 0 }
};
@ -526,6 +541,17 @@ ng_netflow_rcvmsg (node_p node, item_p item, hook_p lasthook)
break;
}
case NGM_NETFLOW_V9INFO:
{
struct ng_netflow_v9info *i;
NG_MKRESPONSE(resp, msg, sizeof(struct ng_netflow_v9info),
M_NOWAIT);
i = (struct ng_netflow_v9info *)resp->data;
ng_netflow_copyv9info(priv, i);
break;
}
default:
ERROUT(EINVAL); /* unknown command */
break;

View File

@ -34,6 +34,7 @@
#define NG_NETFLOW_NODE_TYPE "netflow"
#define NGM_NETFLOW_COOKIE 1309868867
#define NGM_NETFLOW_V9_COOKIE 1349865386
#define NG_NETFLOW_MAXIFACES USHRT_MAX
@ -58,6 +59,7 @@ enum {
NGM_NETFLOW_SETCONFIG = 7, /* set flow generation options */
NGM_NETFLOW_SETTEMPLATE = 8, /* set v9 flow template periodic */
NGM_NETFLOW_SETMTU = 9, /* set outgoing interface MTU */
NGM_NETFLOW_V9INFO = 10|NGM_READONLY|NGM_HASREPLY, /* get v9 info */
};
/* This structure is returned by the NGM_NETFLOW_INFO message */
@ -147,6 +149,13 @@ struct ngnf_show_header {
uint32_t nentries; /* number of records in response */
};
/* This structure is used in NGM_NETFLOW_V9INFO message */
struct ng_netflow_v9info {
uint16_t templ_packets; /* v9 template packets */
uint16_t templ_time; /* v9 template time */
uint16_t mtu; /* v9 MTU */
};
/* XXXGL
* Somewhere flow_rec6 is casted to flow_rec, and flow6_entry_data is
* casted to flow_entry_data. After casting, fle->r.fib is accessed.
@ -347,6 +356,14 @@ struct flow6_entry {
{ NULL } \
}
/* Parse the v9info structure */
#define NG_NETFLOW_V9INFO_TYPE { \
{ "v9 template packets", &ng_parse_uint16_type },\
{ "v9 template time", &ng_parse_uint16_type },\
{ "v9 MTU", &ng_parse_uint16_type },\
{ NULL } \
}
/* Private hook data */
struct ng_netflow_iface {
hook_p hook; /* NULL when disconnected */
@ -422,6 +439,7 @@ struct netflow {
fib_export_p *fib_data; /* array of pointers to per-fib data */
uint16_t maxfibs; /* number of allocated fibs */
/* Netflow v9 configuration options */
/*
* RFC 3954 clause 7.3
* "Both options MUST be configurable by the user on the Exporter."
@ -472,6 +490,7 @@ void ng_netflow_cache_init(priv_p);
void ng_netflow_cache_flush(priv_p);
int ng_netflow_fib_init(priv_p priv, int fib);
void ng_netflow_copyinfo(priv_p, struct ng_netflow_info *);
void ng_netflow_copyv9info(priv_p, struct ng_netflow_v9info *);
timeout_t ng_netflow_expire;
int ng_netflow_flow_add(priv_p, fib_export_p, struct ip *, caddr_t, uint8_t, uint8_t, unsigned int);
int ng_netflow_flow6_add(priv_p, fib_export_p, struct ip6_hdr *, caddr_t , uint8_t, uint8_t, unsigned int);