Index: lib/libnetgraph/msg.c =================================================================== --- lib/libnetgraph/msg.c +++ lib/libnetgraph/msg.c @@ -71,10 +71,9 @@ /* Prepare message header */ memset(&msg, 0, sizeof(msg)); - msg.header.version = NG_VERSION; + msg.header.version = NGM_VERSION; msg.header.typecookie = cookie; msg.header.token = atomic_fetch_add(&gMsgId, 1) & INT_MAX; - msg.header.flags = NGF_ORIG; msg.header.cmd = cmd; snprintf((char *)msg.header.cmdstr, NG_CMDSTRSIZ, "cmd%d", cmd); @@ -143,7 +142,7 @@ /* Now send binary version */ binary = (struct ng_mesg *)reply->data; binary->header.token = atomic_fetch_add(&gMsgId, 1) & INT_MAX; - binary->header.version = NG_VERSION; + binary->header.version = NGM_VERSION; if (NgDeliverMsg(cs, path, binary, binary->data, binary->header.arglen) < 0) { free(reply); @@ -166,7 +165,7 @@ /* Prepare message header */ rep = *msg; - rep.header.flags = NGF_RESP; + rep.header.flags |= NGF_RESP; /* Deliver message */ return (NgDeliverMsg(cs, path, &rep, args, arglen)); Index: libexec/pppoed/pppoed.c =================================================================== --- libexec/pppoed/pppoed.c +++ libexec/pppoed/pppoed.c @@ -386,12 +386,6 @@ _exit(EX_TEMPFAIL); } - if (rep->header.version != NG_VERSION) { - syslog(LOG_ERR, "%ld: Unexpected netgraph version, expected %ld", - (long)rep->header.version, (long)NG_VERSION); - _exit(EX_PROTOCOL); - } - if (rep->header.typecookie != NGM_PPPOE_COOKIE) { syslog(LOG_INFO, "%ld: Unexpected netgraph cookie, expected %ld", (long)rep->header.typecookie, (long)NGM_PPPOE_COOKIE); Index: share/man/man4/netgraph.4 =================================================================== --- share/man/man4/netgraph.4 +++ share/man/man4/netgraph.4 @@ -842,11 +842,10 @@ .Bd -literal #define NG_CMDSTRSIZ 32 /* Max command string (including null) */ +/* real structures can differ, these are the names which can be used */ struct ng_mesg { struct ng_msghdr { - u_char version; /* Must equal NG_VERSION */ - u_char spare; /* Pad to 4 bytes */ - uint16_t spare2; + u_char version; /* Must equal NGM_VERSION */ uint32_t arglen; /* Length of cmd/resp data */ uint32_t cmd; /* Command identifier */ uint32_t flags; /* Message status flags */ @@ -858,8 +857,7 @@ }; #define NG_ABI_VERSION 12 /* Netgraph kernel ABI version */ -#define NG_VERSION 8 /* Netgraph message version */ -#define NGF_ORIG 0x00000000 /* The msg is the original request */ +#define NGM_VERSION 8 /* Netgraph message version */ #define NGF_RESP 0x00000001 /* The message is a response */ .Ed .Pp @@ -873,7 +871,7 @@ .Nm message protocol itself. The current version is -.Dv NG_VERSION . +.Dv NGM_VERSION . .It Va arglen This is the length of any extra arguments, which begin at .Va data . Index: sys/netgraph/ng_base.c =================================================================== --- sys/netgraph/ng_base.c +++ sys/netgraph/ng_base.c @@ -3252,7 +3252,7 @@ SYSCTL_NODE(_net, OID_AUTO, graph, CTLFLAG_RW | CTLFLAG_MPSAFE, 0, "netgraph Family"); SYSCTL_INT(_net_graph, OID_AUTO, abi_version, CTLFLAG_RD, SYSCTL_NULL_INT_PTR, NG_ABI_VERSION,""); -SYSCTL_INT(_net_graph, OID_AUTO, msg_version, CTLFLAG_RD, SYSCTL_NULL_INT_PTR, NG_VERSION, ""); +SYSCTL_INT(_net_graph, OID_AUTO, msg_version, CTLFLAG_RD, SYSCTL_NULL_INT_PTR, NGM_VERSION, ""); #ifdef NETGRAPH_DEBUG void Index: sys/netgraph/ng_message.h =================================================================== --- sys/netgraph/ng_message.h +++ sys/netgraph/ng_message.h @@ -58,7 +58,7 @@ struct ng_msghdr { u_char version; /* == NGM_VERSION */ u_char spare; /* pad to 4 bytes */ - u_int16_t spare2; + u_int16_t spare2; u_int32_t arglen; /* length of data */ u_int32_t cmd; /* command identifier */ u_int32_t flags; /* message status */ @@ -69,6 +69,23 @@ char data[]; /* placeholder for actual data */ }; +/* A netgraph message */ +struct ng_mesg2 { + struct ng_msghdr2 { + u_char version; /* == NGM_VERSION2 */ + u_char spare; /* pad to 4 bytes */ + u_int16_t spare2; + u_int32_t arglen; /* length of data */ + u_int32_t cmd; /* command identifier */ + u_int32_t flags; /* message status */ + u_int32_t offset; /* fragmentation offset */ + u_int32_t token; /* match with reply */ + u_int32_t typecookie; /* node's type cookie */ + u_char cmdstr[NG_CMDSTRSIZ]; /* cmd string + \0 */ + } header; + char data[]; /* placeholder for actual data */ +}; + /* This command is guaranteed to not alter data (or'd into the command). */ #define NGM_READONLY 0x10000000 /* This command is guaranteed to have a reply (or'd into the command). */ @@ -93,12 +110,15 @@ * Netgraph message header compatibility field * Interfaces within the kernel are defined by a different * value (see NG_ABI_VERSION in netgraph.h) + * + * Support both NGM_VERSION and NGM_VERSION2 as long as needed. */ -#define NG_VERSION 8 +#define NGM_VERSION 8 +#define NGM_VERSION2 9 /* Flags field flags */ -#define NGF_ORIG 0x00000000 /* the msg is the original request */ #define NGF_RESP 0x00000001 /* the message is a response */ +#define NGF_FRAG 0x00000002 /* more fragments (NGM_VERSION2 only) */ /* Type of a unique node ID. */ #define ng_ID_t uint32_t @@ -382,7 +402,7 @@ + (len), M_NETGRAPH_MSG, (how) | M_ZERO); \ if ((msg) == NULL) \ break; \ - (msg)->header.version = NG_VERSION; \ + (msg)->header.version = NGM_VERSION; \ (msg)->header.typecookie = (cookie); \ (msg)->header.cmd = (cmdid); \ (msg)->header.arglen = (len); \ @@ -400,7 +420,7 @@ + (len), M_NETGRAPH_MSG, (how) | M_ZERO); \ if ((rsp) == NULL) \ break; \ - (rsp)->header.version = NG_VERSION; \ + (rsp)->header.version = NGM_VERSION; \ (rsp)->header.arglen = (len); \ (rsp)->header.token = (msg)->header.token; \ (rsp)->header.typecookie = (msg)->header.typecookie; \ @@ -419,7 +439,7 @@ + (msg)->header.arglen, M_NETGRAPH_MSG, (how) | M_ZERO); \ if ((copy) == NULL) \ break; \ - (copy)->header.version = NG_VERSION; \ + (copy)->header.version = NGM_VERSION; \ (copy)->header.arglen = (msg)->header.arglen; \ (copy)->header.token = (msg)->header.token; \ (copy)->header.typecookie = (msg)->header.typecookie; \ Index: sys/netgraph/ng_socket.c =================================================================== --- sys/netgraph/ng_socket.c +++ sys/netgraph/ng_socket.c @@ -187,6 +187,7 @@ }; #define NGS_FLAG_NOLINGER 1 /* close with last hook */ +#define NGS_FLAG_FRAGMENT 2 /* allow fragmented packets */ /*************************************************************** Control sockets @@ -263,7 +264,7 @@ msg = malloc(len + 1, M_NETGRAPH_MSG, M_WAITOK); m_copydata(m, 0, len, (char *)msg); - if (msg->header.version != NG_VERSION) { + if (msg->header.version != NGM_VERSION) { free(msg, M_NETGRAPH_MSG); error = EINVAL; goto release; @@ -604,6 +605,10 @@ /* Allocate the pcb. */ pcbp = malloc(sizeof(struct ngpcb), M_PCB, M_WAITOK | M_ZERO); pcbp->type = type; + + /* Store the current parameters of socket initialization */ + pcbp->recvspace = ngpdg_recvspace; + pcbp->sendspace = ngpdg_sendspace; /* Link the pcb and the socket. */ so->so_pcb = (caddr_t)pcbp; Index: sys/netgraph/ng_socketvar.h =================================================================== --- sys/netgraph/ng_socketvar.h +++ sys/netgraph/ng_socketvar.h @@ -51,5 +51,7 @@ LIST_ENTRY(ngpcb) socks; /* linked list of sockets */ int type; /* NG_CONTROL or NG_DATA */ ng_ID_t node_id; /* a hint for netstat(1) to find the node */ + u_long sendspace; /* buffer space for socket */ + u_long recvspace; /* buffer space for socket */ }; #endif /* _NETGRAPH_NG_SOCKETVAR_H_ */ Index: usr.sbin/ppp/ether.c =================================================================== --- usr.sbin/ppp/ether.c +++ usr.sbin/ppp/ether.c @@ -246,12 +246,6 @@ if (NgRecvMsg(dev->cs, rep, sizeof msgbuf, NULL) <= 0) break; - if (rep->header.version != NG_VERSION) { - log_Printf(LogWARN, "%ld: Unexpected netgraph version, expected %ld\n", - (long)rep->header.version, (long)NG_VERSION); - break; - } - if (rep->header.typecookie != NGM_PPPOE_COOKIE) { log_Printf(LogWARN, "%ld: Unexpected netgraph cookie, expected %ld\n", (long)rep->header.typecookie, (long)NGM_PPPOE_COOKIE);