summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorglebius <glebius@FreeBSD.org>2010-03-12 15:04:59 +0000
committerglebius <glebius@FreeBSD.org>2010-03-12 15:04:59 +0000
commite93d3296963195868bf04a7a6820ceef4c6a679d (patch)
tree608f4dd8db5f440fa1f16dda8e93c606342dccf2 /sys
parentaad46e823b4427474c2bf12ea7446b15d1dc6835 (diff)
downloadFreeBSD-src-e93d3296963195868bf04a7a6820ceef4c6a679d.zip
FreeBSD-src-e93d3296963195868bf04a7a6820ceef4c6a679d.tar.gz
Now fix functionality of 'netstat -f netgraph' that hasn't worked
starting from netgraph import in 1999. netstat(8) used pointer to node as node address, oops. That didn't work, we need the node ID in brackets to successfully address a node. We can't look into ng_node, due to inability to include netgraph/netgraph.h in userland code. So let the node make a hint for a userland, storing the node ID in its private data. MFC after: 2 weeks
Diffstat (limited to 'sys')
-rw-r--r--sys/netgraph/ng_socket.c3
-rw-r--r--sys/netgraph/ng_socketvar.h1
2 files changed, 4 insertions, 0 deletions
diff --git a/sys/netgraph/ng_socket.c b/sys/netgraph/ng_socket.c
index efee333..28e4f0e 100644
--- a/sys/netgraph/ng_socket.c
+++ b/sys/netgraph/ng_socket.c
@@ -552,6 +552,9 @@ ng_attach_cntl(struct socket *so)
return (error);
}
+ /* Store a hint for netstat(1). */
+ priv->node_id = priv->node->nd_ID;
+
/* Link the node and the private data. */
NG_NODE_SET_PRIVATE(priv->node, priv);
NG_NODE_REF(priv->node);
diff --git a/sys/netgraph/ng_socketvar.h b/sys/netgraph/ng_socketvar.h
index 3cf8103..c1e59dc 100644
--- a/sys/netgraph/ng_socketvar.h
+++ b/sys/netgraph/ng_socketvar.h
@@ -61,6 +61,7 @@ struct ngsock {
int refs;
struct mtx mtx; /* mtx to wait on */
int error; /* place to store error */
+ ng_ID_t node_id; /* a hint for netstat(1) to find the node */
};
#define NGS_FLAG_NOLINGER 1 /* close with last hook */
OpenPOWER on IntegriCloud