summaryrefslogtreecommitdiffstats
path: root/sys/netgraph/ng_iface.c
diff options
context:
space:
mode:
authorjulian <julian@FreeBSD.org>2001-01-06 00:46:47 +0000
committerjulian <julian@FreeBSD.org>2001-01-06 00:46:47 +0000
commitf0c46a9d00fc9fe4644cef5784e76b360f5036c7 (patch)
tree561902279f2f361f3e137f7fc029ce2714981289 /sys/netgraph/ng_iface.c
parente06f071f56cf6badae9215f8a14ccc66a3fc0f5a (diff)
downloadFreeBSD-src-f0c46a9d00fc9fe4644cef5784e76b360f5036c7.zip
FreeBSD-src-f0c46a9d00fc9fe4644cef5784e76b360f5036c7.tar.gz
Rewrite of netgraph to start getting ready for SMP.
This version is functional and is aproaching solid.. notice I said APROACHING. There are many node types I cannot test I have tested: echo hole ppp socket vjc iface tee bpf async tty The rest compile and "Look" right. More changes to follow. DEBUGGING is enabled in this code to help if people have problems.
Diffstat (limited to 'sys/netgraph/ng_iface.c')
-rw-r--r--sys/netgraph/ng_iface.c43
1 files changed, 14 insertions, 29 deletions
diff --git a/sys/netgraph/ng_iface.c b/sys/netgraph/ng_iface.c
index 3df564a..42aa1ba 100644
--- a/sys/netgraph/ng_iface.c
+++ b/sys/netgraph/ng_iface.c
@@ -118,7 +118,7 @@ static void ng_iface_print_ioctl(struct ifnet *ifp, int cmd, caddr_t data);
/* Netgraph methods */
static ng_constructor_t ng_iface_constructor;
static ng_rcvmsg_t ng_iface_rcvmsg;
-static ng_shutdown_t ng_iface_rmnode;
+static ng_shutdown_t ng_iface_shutdown;
static ng_newhook_t ng_iface_newhook;
static ng_rcvdata_t ng_iface_rcvdata;
static ng_disconnect_t ng_iface_disconnect;
@@ -186,7 +186,7 @@ static struct ng_type typestruct = {
NULL,
ng_iface_constructor,
ng_iface_rcvmsg,
- ng_iface_rmnode,
+ ng_iface_shutdown,
ng_iface_newhook,
NULL,
NULL,
@@ -521,11 +521,10 @@ ng_iface_print_ioctl(struct ifnet *ifp, int command, caddr_t data)
* Constructor for a node
*/
static int
-ng_iface_constructor(node_p *nodep)
+ng_iface_constructor(node_p node)
{
char ifname[NG_IFACE_IFACE_NAME_MAX + 1];
struct ifnet *ifp;
- node_p node;
priv_p priv;
int error = 0;
@@ -550,15 +549,6 @@ ng_iface_constructor(node_p *nodep)
return (error);
}
- /* Call generic node constructor */
- if ((error = ng_make_node_common(&typestruct, nodep)) != 0) {
- ng_iface_free_unit(priv->unit);
- FREE(ifp, M_NETGRAPH);
- FREE(priv, M_NETGRAPH);
- return (error);
- }
- node = *nodep;
-
/* Link together node and private info */
node->private = priv;
priv->node = node;
@@ -615,14 +605,15 @@ ng_iface_newhook(node_p node, hook_p hook, const char *name)
* Receive a control message
*/
static int
-ng_iface_rcvmsg(node_p node, struct ng_mesg *msg,
- const char *retaddr, struct ng_mesg **rptr, hook_p lasthook)
+ng_iface_rcvmsg(node_p node, item_p item, hook_p lasthook)
{
const priv_p priv = node->private;
struct ifnet *const ifp = priv->ifp;
struct ng_mesg *resp = NULL;
int error = 0;
+ struct ng_mesg *msg;
+ NGI_GET_MSG(item, msg);
switch (msg->header.typecookie) {
case NGM_IFACE_COOKIE:
switch (msg->header.cmd) {
@@ -707,11 +698,8 @@ ng_iface_rcvmsg(node_p node, struct ng_mesg *msg,
error = EINVAL;
break;
}
- if (rptr)
- *rptr = resp;
- else if (resp)
- FREE(resp, M_NETGRAPH);
- FREE(msg, M_NETGRAPH);
+ NG_RESPOND_MSG(error, node, item, resp);
+ NG_FREE_MSG(msg);
return (error);
}
@@ -719,20 +707,22 @@ ng_iface_rcvmsg(node_p node, struct ng_mesg *msg,
* Recive data from a hook. Pass the packet to the correct input routine.
*/
static int
-ng_iface_rcvdata(hook_p hook, struct mbuf *m, meta_p meta,
- struct mbuf **ret_m, meta_p *ret_meta, struct ng_mesg **resp)
+ng_iface_rcvdata(hook_p hook, item_p item)
{
const priv_p priv = hook->node->private;
const iffam_p iffam = get_iffam_from_hook(priv, hook);
struct ifnet *const ifp = priv->ifp;
+ struct mbuf *m;
+ NGI_GET_M(item, m);
+ NG_FREE_ITEM(item);
/* Sanity checks */
KASSERT(iffam != NULL, ("%s: iffam", __FUNCTION__));
KASSERT(m->m_flags & M_PKTHDR, ("%s: not pkthdr", __FUNCTION__));
if (m == NULL)
return (EINVAL);
if ((ifp->if_flags & IFF_UP) == 0) {
- NG_FREE_DATA(m, meta);
+ NG_FREE_M(m);
return (ENETDOWN);
}
@@ -746,9 +736,6 @@ ng_iface_rcvdata(hook_p hook, struct mbuf *m, meta_p meta,
/* Berkeley packet filter */
ng_iface_bpftap(ifp, m, iffam->family);
- /* Ignore any meta-data */
- NG_FREE_META(meta);
-
/* Send packet */
return family_enqueue(iffam->family, m);
}
@@ -757,12 +744,10 @@ ng_iface_rcvdata(hook_p hook, struct mbuf *m, meta_p meta,
* Shutdown and remove the node and its associated interface.
*/
static int
-ng_iface_rmnode(node_p node)
+ng_iface_shutdown(node_p node)
{
const priv_p priv = node->private;
- ng_cutlinks(node);
- ng_unname(node);
bpfdetach(priv->ifp);
if_detach(priv->ifp);
priv->ifp = NULL;
OpenPOWER on IntegriCloud