summaryrefslogtreecommitdiffstats
path: root/sys/netgraph
diff options
context:
space:
mode:
authormelifaro <melifaro@FreeBSD.org>2012-10-11 16:15:18 +0000
committermelifaro <melifaro@FreeBSD.org>2012-10-11 16:15:18 +0000
commit564aca31ca58875f0f040f6f1f2d82116b1b5499 (patch)
treef115ad5010daaf490d9c3921a98d3d5b602131b0 /sys/netgraph
parente867826c0224f87edbf44239bd842027cd13de79 (diff)
downloadFreeBSD-src-564aca31ca58875f0f040f6f1f2d82116b1b5499.zip
FreeBSD-src-564aca31ca58875f0f040f6f1f2d82116b1b5499.tar.gz
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
Diffstat (limited to 'sys/netgraph')
-rw-r--r--sys/netgraph/netflow/netflow_v9.c11
-rw-r--r--sys/netgraph/netflow/ng_netflow.c26
-rw-r--r--sys/netgraph/netflow/ng_netflow.h19
3 files changed, 56 insertions, 0 deletions
diff --git a/sys/netgraph/netflow/netflow_v9.c b/sys/netgraph/netflow/netflow_v9.c
index b918feb..e040665 100644
--- a/sys/netgraph/netflow/netflow_v9.c
+++ b/sys/netgraph/netflow/netflow_v9.c
@@ -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;
+}
+
diff --git a/sys/netgraph/netflow/ng_netflow.c b/sys/netgraph/netflow/ng_netflow.c
index d2c136c..9048cdb 100644
--- a/sys/netgraph/netflow/ng_netflow.c
+++ b/sys/netgraph/netflow/ng_netflow.c
@@ -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;
diff --git a/sys/netgraph/netflow/ng_netflow.h b/sys/netgraph/netflow/ng_netflow.h
index ee56c28..22b2bc0 100644
--- a/sys/netgraph/netflow/ng_netflow.h
+++ b/sys/netgraph/netflow/ng_netflow.h
@@ -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);
OpenPOWER on IntegriCloud