From e93d3296963195868bf04a7a6820ceef4c6a679d Mon Sep 17 00:00:00 2001 From: glebius Date: Fri, 12 Mar 2010 15:04:59 +0000 Subject: 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 --- sys/netgraph/ng_socket.c | 3 +++ sys/netgraph/ng_socketvar.h | 1 + 2 files changed, 4 insertions(+) (limited to 'sys') 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 */ -- cgit v1.1