Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 7 Dec 2012 13:03:23 +0000 (UTC)
From:      "Alexander V. Chernikov" <melifaro@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject:   svn commit: r243983 - in stable/9: share/man/man4 sys/netgraph/netflow
Message-ID:  <201212071303.qB7D3NHN099920@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: melifaro
Date: Fri Dec  7 13:03:23 2012
New Revision: 243983
URL: http://svnweb.freebsd.org/changeset/base/243983

Log:
  MFC r241446,r241501
  
  Add NG_NETFLOW_V9INFO_TYPE command to be able to request netflowv9-specific
  data.
  
  Submitted by:	Dmitry Luhtionov <dmitryluhtionov at gmail.com>

Modified:
  stable/9/share/man/man4/ng_netflow.4
  stable/9/sys/netgraph/netflow/netflow_v9.c
  stable/9/sys/netgraph/netflow/ng_netflow.c
  stable/9/sys/netgraph/netflow/ng_netflow.h
Directory Properties:
  stable/9/share/   (props changed)
  stable/9/share/man/   (props changed)
  stable/9/share/man/man4/   (props changed)
  stable/9/sys/   (props changed)

Modified: stable/9/share/man/man4/ng_netflow.4
==============================================================================
--- stable/9/share/man/man4/ng_netflow.4	Fri Dec  7 13:00:41 2012	(r243982)
+++ stable/9/share/man/man4/ng_netflow.4	Fri Dec  7 13:03:23 2012	(r243983)
@@ -229,6 +229,9 @@ not directly from
 See also
 .Sx BUGS
 section.
+.It Dv NGM_NETFLOW_V9INFO
+Returns some NetFlow v9 related values in a
+.Vt "struct ng_netflow_v9info" .
 .El
 .Sh ASCII CONTROL MESSAGES
 Most binary control messages have an

Modified: stable/9/sys/netgraph/netflow/netflow_v9.c
==============================================================================
--- stable/9/sys/netgraph/netflow/netflow_v9.c	Fri Dec  7 13:00:41 2012	(r243982)
+++ stable/9/sys/netgraph/netflow/netflow_v9.c	Fri Dec  7 13:03:23 2012	(r243983)
@@ -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;
+}
+

Modified: stable/9/sys/netgraph/netflow/ng_netflow.c
==============================================================================
--- stable/9/sys/netgraph/netflow/ng_netflow.c	Fri Dec  7 13:00:41 2012	(r243982)
+++ stable/9/sys/netgraph/netflow/ng_netflow.c	Fri Dec  7 13:03:23 2012	(r243983)
@@ -138,6 +138,14 @@ static const struct ng_parse_type ng_net
 	&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_netflo
 	&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 i
 
 			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;

Modified: stable/9/sys/netgraph/netflow/ng_netflow.h
==============================================================================
--- stable/9/sys/netgraph/netflow/ng_netflow.h	Fri Dec  7 13:00:41 2012	(r243982)
+++ stable/9/sys/netgraph/netflow/ng_netflow.h	Fri Dec  7 13:03:23 2012	(r243983)
@@ -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 */
@@ -141,6 +143,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.
@@ -341,6 +350,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 */
@@ -416,6 +433,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."
@@ -466,6 +484,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);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201212071303.qB7D3NHN099920>