summaryrefslogtreecommitdiffstats
path: root/sys/netgraph
diff options
context:
space:
mode:
authorjulian <julian@FreeBSD.org>2000-12-18 20:03:32 +0000
committerjulian <julian@FreeBSD.org>2000-12-18 20:03:32 +0000
commit0c949560a12dd18943b66fe09bd06d3c34e5cf7a (patch)
tree5466b04ac515e8d01f9b135b6c119744a1138d82 /sys/netgraph
parente6bd476191c5b338634a02b0a6de56aa7f23cf37 (diff)
downloadFreeBSD-src-0c949560a12dd18943b66fe09bd06d3c34e5cf7a.zip
FreeBSD-src-0c949560a12dd18943b66fe09bd06d3c34e5cf7a.tar.gz
Divorce the kernel binary ABI version number from the message
format version number. (userland programs should not need to be recompiled when the netgraph kernel internal ABI is changed. Also fix modules that don;t handle the fact that a caller may not supply a return message pointer. (benign at the moment because the calling code checks, but that will change)
Diffstat (limited to 'sys/netgraph')
-rw-r--r--sys/netgraph/netgraph.h9
-rw-r--r--sys/netgraph/ng_UI.c2
-rw-r--r--sys/netgraph/ng_async.c2
-rw-r--r--sys/netgraph/ng_base.c16
-rw-r--r--sys/netgraph/ng_bpf.c2
-rw-r--r--sys/netgraph/ng_bridge.c2
-rw-r--r--sys/netgraph/ng_cisco.c2
-rw-r--r--sys/netgraph/ng_echo.c2
-rw-r--r--sys/netgraph/ng_ether.c2
-rw-r--r--sys/netgraph/ng_frame_relay.c2
-rw-r--r--sys/netgraph/ng_hole.c2
-rw-r--r--sys/netgraph/ng_iface.c2
-rw-r--r--sys/netgraph/ng_ksocket.c2
-rw-r--r--sys/netgraph/ng_lmi.c27
-rw-r--r--sys/netgraph/ng_message.h9
-rw-r--r--sys/netgraph/ng_mppc.c2
-rw-r--r--sys/netgraph/ng_one2many.c2
-rw-r--r--sys/netgraph/ng_ppp.c2
-rw-r--r--sys/netgraph/ng_pppoe.c2
-rw-r--r--sys/netgraph/ng_pptpgre.c4
-rw-r--r--sys/netgraph/ng_rfc1490.c2
-rw-r--r--sys/netgraph/ng_sample.c2
-rw-r--r--sys/netgraph/ng_socket.c2
-rw-r--r--sys/netgraph/ng_tee.c2
-rw-r--r--sys/netgraph/ng_tty.c2
-rw-r--r--sys/netgraph/ng_vjc.c2
26 files changed, 70 insertions, 37 deletions
diff --git a/sys/netgraph/netgraph.h b/sys/netgraph/netgraph.h
index 48fb4f5..56cf7d6f 100644
--- a/sys/netgraph/netgraph.h
+++ b/sys/netgraph/netgraph.h
@@ -172,7 +172,7 @@ struct ng_cmdlist {
*/
struct ng_type {
- u_int32_t version; /* must equal NG_VERSION */
+ u_int32_t version; /* must equal NG_API_VERSION */
const char *name; /* Unique type name */
modeventhand_t mod_event; /* Module event handler (optional) */
ng_constructor_t *constructor; /* Node constructor */
@@ -191,6 +191,13 @@ struct ng_type {
int refs; /* number of instances */
};
+/*
+ * This defines the in-kernel binary interface version.
+ * It is possible to change this but leave the external message
+ * API the same. Each type also has it's own cookies for versioning as well.
+ */
+#define NG_ABI_VERSION 5
+
/* Send data packet with meta-data */
#define NG_SEND_DATA(err, hook, m, meta) \
do { \
diff --git a/sys/netgraph/ng_UI.c b/sys/netgraph/ng_UI.c
index 9d490b9..0e2ef10 100644
--- a/sys/netgraph/ng_UI.c
+++ b/sys/netgraph/ng_UI.c
@@ -77,7 +77,7 @@ static ng_disconnect_t ng_UI_disconnect;
/* Node type descriptor */
static struct ng_type typestruct = {
- NG_VERSION,
+ NG_ABI_VERSION,
NG_UI_NODE_TYPE,
NULL,
ng_UI_constructor,
diff --git a/sys/netgraph/ng_async.c b/sys/netgraph/ng_async.c
index 8dc951a..cbc51bb 100644
--- a/sys/netgraph/ng_async.c
+++ b/sys/netgraph/ng_async.c
@@ -148,7 +148,7 @@ static const struct ng_cmdlist nga_cmdlist[] = {
/* Define the netgraph node type */
static struct ng_type typestruct = {
- NG_VERSION,
+ NG_ABI_VERSION,
NG_ASYNC_NODE_TYPE,
NULL,
nga_constructor,
diff --git a/sys/netgraph/ng_base.c b/sys/netgraph/ng_base.c
index 981d0bf..d9b26f4 100644
--- a/sys/netgraph/ng_base.c
+++ b/sys/netgraph/ng_base.c
@@ -856,7 +856,9 @@ ng_newtype(struct ng_type *tp)
const size_t namelen = strlen(tp->name);
/* Check version and type name fields */
- if (tp->version != NG_VERSION || namelen == 0 || namelen > NG_TYPELEN) {
+ if ((tp->version != NG_ABI_VERSION)
+ || (namelen == 0)
+ || (namelen > NG_TYPELEN)) {
TRAP_ERROR;
return (EINVAL);
}
@@ -1489,6 +1491,12 @@ ng_generic_msg(node_p here, struct ng_mesg *msg, const char *retaddr,
break;
}
+ /* Check response pointer */
+ if (resp == NULL) {
+ error = EINVAL;
+ break;
+ }
+
/* Get a response message with lots of room */
NG_MKRESPONSE(rp, msg, sizeof(*ascii) + bufSize, M_NOWAIT);
if (rp == NULL) {
@@ -1565,6 +1573,12 @@ ng_generic_msg(node_p here, struct ng_mesg *msg, const char *retaddr,
}
ascii->data[ascii->header.arglen - 1] = '\0';
+ /* Check response pointer */
+ if (resp == NULL) {
+ error = EINVAL;
+ break;
+ }
+
/* Get a response message with lots of room */
NG_MKRESPONSE(rp, msg, sizeof(*binary) + bufSize, M_NOWAIT);
if (rp == NULL) {
diff --git a/sys/netgraph/ng_bpf.c b/sys/netgraph/ng_bpf.c
index 49cc3e7..6d19550 100644
--- a/sys/netgraph/ng_bpf.c
+++ b/sys/netgraph/ng_bpf.c
@@ -186,7 +186,7 @@ static const struct ng_cmdlist ng_bpf_cmdlist[] = {
/* Netgraph type descriptor */
static struct ng_type typestruct = {
- NG_VERSION,
+ NG_ABI_VERSION,
NG_BPF_NODE_TYPE,
NULL,
ng_bpf_constructor,
diff --git a/sys/netgraph/ng_bridge.c b/sys/netgraph/ng_bridge.c
index 68a4c0c..59ba0cc 100644
--- a/sys/netgraph/ng_bridge.c
+++ b/sys/netgraph/ng_bridge.c
@@ -266,7 +266,7 @@ static const struct ng_cmdlist ng_bridge_cmdlist[] = {
/* Node type descriptor */
static struct ng_type ng_bridge_typestruct = {
- NG_VERSION,
+ NG_ABI_VERSION,
NG_BRIDGE_NODE_TYPE,
NULL,
ng_bridge_constructor,
diff --git a/sys/netgraph/ng_cisco.c b/sys/netgraph/ng_cisco.c
index 76316c4..539e684 100644
--- a/sys/netgraph/ng_cisco.c
+++ b/sys/netgraph/ng_cisco.c
@@ -171,7 +171,7 @@ static const struct ng_cmdlist ng_cisco_cmdlist[] = {
/* Node type */
static struct ng_type typestruct = {
- NG_VERSION,
+ NG_ABI_VERSION,
NG_CISCO_NODE_TYPE,
NULL,
cisco_constructor,
diff --git a/sys/netgraph/ng_echo.c b/sys/netgraph/ng_echo.c
index 8ef95a4..6c46341 100644
--- a/sys/netgraph/ng_echo.c
+++ b/sys/netgraph/ng_echo.c
@@ -61,7 +61,7 @@ static ng_disconnect_t nge_disconnect;
/* Netgraph type */
static struct ng_type typestruct = {
- NG_VERSION,
+ NG_ABI_VERSION,
NG_ECHO_NODE_TYPE,
NULL,
NULL,
diff --git a/sys/netgraph/ng_ether.c b/sys/netgraph/ng_ether.c
index 806798a..194b5ee 100644
--- a/sys/netgraph/ng_ether.c
+++ b/sys/netgraph/ng_ether.c
@@ -180,7 +180,7 @@ static const struct ng_cmdlist ng_ether_cmdlist[] = {
};
static struct ng_type ng_ether_typestruct = {
- NG_VERSION,
+ NG_ABI_VERSION,
NG_ETHER_NODE_TYPE,
ng_ether_mod_event,
ng_ether_constructor,
diff --git a/sys/netgraph/ng_frame_relay.c b/sys/netgraph/ng_frame_relay.c
index 830800b..96d56bf 100644
--- a/sys/netgraph/ng_frame_relay.c
+++ b/sys/netgraph/ng_frame_relay.c
@@ -137,7 +137,7 @@ static int ngfrm_allocate_CTX(sc_p sc, int dlci);
/* Netgraph type */
static struct ng_type typestruct = {
- NG_VERSION,
+ NG_ABI_VERSION,
NG_FRAMERELAY_NODE_TYPE,
NULL,
ngfrm_constructor,
diff --git a/sys/netgraph/ng_hole.c b/sys/netgraph/ng_hole.c
index 43ed1f2..1da47b6 100644
--- a/sys/netgraph/ng_hole.c
+++ b/sys/netgraph/ng_hole.c
@@ -57,7 +57,7 @@ static ng_rcvdata_t ngh_rcvdata;
static ng_disconnect_t ngh_disconnect;
static struct ng_type typestruct = {
- NG_VERSION,
+ NG_ABI_VERSION,
NG_HOLE_NODE_TYPE,
NULL,
NULL,
diff --git a/sys/netgraph/ng_iface.c b/sys/netgraph/ng_iface.c
index 992d9b9..3df564a 100644
--- a/sys/netgraph/ng_iface.c
+++ b/sys/netgraph/ng_iface.c
@@ -181,7 +181,7 @@ static const struct ng_cmdlist ng_iface_cmds[] = {
/* Node type descriptor */
static struct ng_type typestruct = {
- NG_VERSION,
+ NG_ABI_VERSION,
NG_IFACE_NODE_TYPE,
NULL,
ng_iface_constructor,
diff --git a/sys/netgraph/ng_ksocket.c b/sys/netgraph/ng_ksocket.c
index c01f679..9898da9 100644
--- a/sys/netgraph/ng_ksocket.c
+++ b/sys/netgraph/ng_ksocket.c
@@ -459,7 +459,7 @@ static const struct ng_cmdlist ng_ksocket_cmds[] = {
/* Node type descriptor */
static struct ng_type ng_ksocket_typestruct = {
- NG_VERSION,
+ NG_ABI_VERSION,
NG_KSOCKET_NODE_TYPE,
NULL,
ng_ksocket_constructor,
diff --git a/sys/netgraph/ng_lmi.c b/sys/netgraph/ng_lmi.c
index 7019464..9bede71 100644
--- a/sys/netgraph/ng_lmi.c
+++ b/sys/netgraph/ng_lmi.c
@@ -98,7 +98,7 @@ static ng_disconnect_t nglmi_disconnect;
static int nglmi_checkdata(hook_p hook, struct mbuf *m, meta_p meta);
static struct ng_type typestruct = {
- NG_VERSION,
+ NG_ABI_VERSION,
NG_LMI_NODE_TYPE,
NULL,
nglmi_constructor,
@@ -450,10 +450,11 @@ ngauto_state_machine(sc_p sc)
*/
static int
nglmi_rcvmsg(node_p node, struct ng_mesg *msg, const char *retaddr,
- struct ng_mesg **resp, hook_p lasthook)
+ struct ng_mesg **rptr, hook_p lasthook)
{
- int error = 0;
sc_p sc = node->private;
+ struct ng_mesg *resp = NULL;
+ int error = 0;
switch (msg->header.typecookie) {
case NGM_GENERIC_COOKIE:
@@ -463,12 +464,12 @@ nglmi_rcvmsg(node_p node, struct ng_mesg *msg, const char *retaddr,
char *arg;
int pos, count;
- NG_MKRESPONSE(*resp, msg, NG_TEXTRESPONSE, M_NOWAIT);
- if (*resp == NULL) {
+ NG_MKRESPONSE(resp, msg, NG_TEXTRESPONSE, M_NOWAIT);
+ if (resp == NULL) {
error = ENOMEM;
break;
}
- arg = (*resp)->data;
+ arg = resp->data;
pos = sprintf(arg, "protocol %s ", sc->protoname);
if (sc->flags & SCF_FIXED)
pos += sprintf(arg + pos, "fixed\n");
@@ -494,7 +495,7 @@ nglmi_rcvmsg(node_p node, struct ng_mesg *msg, const char *retaddr,
== DLCI_UP) ? "up" : "down");
}
}
- (*resp)->header.arglen = pos + 1;
+ resp->header.arglen = pos + 1;
break;
}
default:
@@ -509,12 +510,12 @@ nglmi_rcvmsg(node_p node, struct ng_mesg *msg, const char *retaddr,
struct nglmistat *stat;
int k;
- NG_MKRESPONSE(*resp, msg, sizeof(*stat), M_NOWAIT);
- if (!*resp) {
+ NG_MKRESPONSE(resp, msg, sizeof(*stat), M_NOWAIT);
+ if (!resp) {
error = ENOMEM;
break;
}
- stat = (struct nglmistat *) (*resp)->data;
+ stat = (struct nglmistat *) resp->data;
strncpy(stat->proto,
sc->protoname, sizeof(stat->proto) - 1);
strncpy(stat->hook,
@@ -542,6 +543,12 @@ nglmi_rcvmsg(node_p node, struct ng_mesg *msg, const char *retaddr,
error = EINVAL;
break;
}
+
+ if (rptr)
+ *rptr = resp;
+ else if (resp != NULL)
+ FREE(resp, M_NETGRAPH);
+
FREE(msg, M_NETGRAPH);
return (error);
}
diff --git a/sys/netgraph/ng_message.h b/sys/netgraph/ng_message.h
index 3eb6096..993768d 100644
--- a/sys/netgraph/ng_message.h
+++ b/sys/netgraph/ng_message.h
@@ -54,7 +54,7 @@
/* A netgraph message */
struct ng_mesg {
struct ng_msghdr {
- u_char version; /* must == NG_VERSION */
+ u_char version; /* == NGM_VERSION */
u_char spare; /* pad to 2 bytes */
u_int16_t arglen; /* length of data */
u_int32_t flags; /* message status */
@@ -66,6 +66,7 @@ struct ng_mesg {
char data[0]; /* placeholder for actual data */
};
+
/* Keep this in sync with the above structure definition */
#define NG_GENERIC_NG_MESG_INFO(dtype) { \
{ \
@@ -82,7 +83,11 @@ struct ng_mesg {
} \
}
-/* Negraph type binary compatibility field */
+/*
+ * Netgraph message header compatibility field
+ * Interfaces within the kernel are defined by a different
+ * value (see NG_ABI_VERSION in netgraph.g)
+ */
#define NG_VERSION 4
/* Flags field flags */
diff --git a/sys/netgraph/ng_mppc.c b/sys/netgraph/ng_mppc.c
index 6c84cda..d9c5a31 100644
--- a/sys/netgraph/ng_mppc.c
+++ b/sys/netgraph/ng_mppc.c
@@ -143,7 +143,7 @@ static void ng_mppc_reset_req(node_p node);
/* Node type descriptor */
static struct ng_type ng_mppc_typestruct = {
- NG_VERSION,
+ NG_ABI_VERSION,
NG_MPPC_NODE_TYPE,
NULL,
ng_mppc_constructor,
diff --git a/sys/netgraph/ng_one2many.c b/sys/netgraph/ng_one2many.c
index 96f93c9..ad0f90f 100644
--- a/sys/netgraph/ng_one2many.c
+++ b/sys/netgraph/ng_one2many.c
@@ -162,7 +162,7 @@ static const struct ng_cmdlist ng_one2many_cmdlist[] = {
/* Node type descriptor */
static struct ng_type ng_one2many_typestruct = {
- NG_VERSION,
+ NG_ABI_VERSION,
NG_ONE2MANY_NODE_TYPE,
NULL,
ng_one2many_constructor,
diff --git a/sys/netgraph/ng_ppp.c b/sys/netgraph/ng_ppp.c
index 88caa63..a2fea53 100644
--- a/sys/netgraph/ng_ppp.c
+++ b/sys/netgraph/ng_ppp.c
@@ -342,7 +342,7 @@ static const struct ng_cmdlist ng_ppp_cmds[] = {
/* Node type descriptor */
static struct ng_type ng_ppp_typestruct = {
- NG_VERSION,
+ NG_ABI_VERSION,
NG_PPP_NODE_TYPE,
NULL,
ng_ppp_constructor,
diff --git a/sys/netgraph/ng_pppoe.c b/sys/netgraph/ng_pppoe.c
index af82ac0..14bf650 100644
--- a/sys/netgraph/ng_pppoe.c
+++ b/sys/netgraph/ng_pppoe.c
@@ -148,7 +148,7 @@ static const struct ng_cmdlist ng_pppoe_cmds[] = {
/* Netgraph node type descriptor */
static struct ng_type typestruct = {
- NG_VERSION,
+ NG_ABI_VERSION,
NG_PPPOE_NODE_TYPE,
NULL,
ng_pppoe_constructor,
diff --git a/sys/netgraph/ng_pptpgre.c b/sys/netgraph/ng_pptpgre.c
index 7d4fedf..c5306b0 100644
--- a/sys/netgraph/ng_pptpgre.c
+++ b/sys/netgraph/ng_pptpgre.c
@@ -245,7 +245,7 @@ static const struct ng_cmdlist ng_pptpgre_cmdlist[] = {
/* Node type descriptor */
static struct ng_type ng_pptpgre_typestruct = {
- NG_VERSION,
+ NG_ABI_VERSION,
NG_PPTPGRE_NODE_TYPE,
NULL,
ng_pptpgre_constructor,
@@ -378,12 +378,12 @@ ng_pptpgre_rcvmsg(node_p node, struct ng_mesg *msg,
error = EINVAL;
break;
}
+done:
if (rptr)
*rptr = resp;
else if (resp)
FREE(resp, M_NETGRAPH);
-done:
FREE(msg, M_NETGRAPH);
return (error);
}
diff --git a/sys/netgraph/ng_rfc1490.c b/sys/netgraph/ng_rfc1490.c
index 0eb090f..b31fdca 100644
--- a/sys/netgraph/ng_rfc1490.c
+++ b/sys/netgraph/ng_rfc1490.c
@@ -96,7 +96,7 @@ static ng_disconnect_t ng_rfc1490_disconnect;
/* Node type descriptor */
static struct ng_type typestruct = {
- NG_VERSION,
+ NG_ABI_VERSION,
NG_RFC1490_NODE_TYPE,
NULL,
ng_rfc1490_constructor,
diff --git a/sys/netgraph/ng_sample.c b/sys/netgraph/ng_sample.c
index 4d4bfba..831e070 100644
--- a/sys/netgraph/ng_sample.c
+++ b/sys/netgraph/ng_sample.c
@@ -96,7 +96,7 @@ static const struct ng_cmdlist ng_xxx_cmdlist[] = {
/* Netgraph node type descriptor */
static struct ng_type typestruct = {
- NG_VERSION,
+ NG_ABI_VERSION,
NG_XXX_NODE_TYPE,
NULL,
ng_xxx_constructor,
diff --git a/sys/netgraph/ng_socket.c b/sys/netgraph/ng_socket.c
index 7608aba..19ea5e0 100644
--- a/sys/netgraph/ng_socket.c
+++ b/sys/netgraph/ng_socket.c
@@ -120,7 +120,7 @@ static int ship_msg(struct ngpcb *pcbp, struct ng_mesg *msg,
/* Netgraph type descriptor */
static struct ng_type typestruct = {
- NG_VERSION,
+ NG_ABI_VERSION,
NG_SOCKET_NODE_TYPE,
ngs_mod_event,
ngs_constructor,
diff --git a/sys/netgraph/ng_tee.c b/sys/netgraph/ng_tee.c
index be6111a..89ae12e 100644
--- a/sys/netgraph/ng_tee.c
+++ b/sys/netgraph/ng_tee.c
@@ -128,7 +128,7 @@ static const struct ng_cmdlist ng_tee_cmds[] = {
/* Netgraph type descriptor */
static struct ng_type ng_tee_typestruct = {
- NG_VERSION,
+ NG_ABI_VERSION,
NG_TEE_NODE_TYPE,
NULL,
ngt_constructor,
diff --git a/sys/netgraph/ng_tty.c b/sys/netgraph/ng_tty.c
index 6236d6e..54ad7d5 100644
--- a/sys/netgraph/ng_tty.c
+++ b/sys/netgraph/ng_tty.c
@@ -159,7 +159,7 @@ static struct linesw ngt_disc = {
/* Netgraph node type descriptor */
static struct ng_type typestruct = {
- NG_VERSION,
+ NG_ABI_VERSION,
NG_TTY_NODE_TYPE,
ngt_mod_event,
ngt_constructor,
diff --git a/sys/netgraph/ng_vjc.c b/sys/netgraph/ng_vjc.c
index 41a16d6..60da6b2 100644
--- a/sys/netgraph/ng_vjc.c
+++ b/sys/netgraph/ng_vjc.c
@@ -222,7 +222,7 @@ static const struct ng_cmdlist ng_vjc_cmds[] = {
/* Node type descriptor */
static struct ng_type ng_vjc_typestruct = {
- NG_VERSION,
+ NG_ABI_VERSION,
NG_VJC_NODE_TYPE,
NULL,
ng_vjc_constructor,
OpenPOWER on IntegriCloud