summaryrefslogtreecommitdiffstats
path: root/usr.sbin/ppp
diff options
context:
space:
mode:
authorbrian <brian@FreeBSD.org>1999-06-05 21:36:00 +0000
committerbrian <brian@FreeBSD.org>1999-06-05 21:36:00 +0000
commitb4fbb76a1315606ed5232890a285663987ef1808 (patch)
treea7dc4874df8a78ef11f5c3f4c17fade049036085 /usr.sbin/ppp
parent66658a0618328716b17140aeb1f74f883b3fd45b (diff)
downloadFreeBSD-src-b4fbb76a1315606ed5232890a285663987ef1808.zip
FreeBSD-src-b4fbb76a1315606ed5232890a285663987ef1808.tar.gz
Correct the way ppp transfers links on the server side in MP
mode by padding out the ``struct device'' to the maximum device size. Bump the ppp version number to indicate the transfer format change. This should make MP over tty and udp devices functional again.
Diffstat (limited to 'usr.sbin/ppp')
-rw-r--r--usr.sbin/ppp/command.c6
-rw-r--r--usr.sbin/ppp/exec.c4
-rw-r--r--usr.sbin/ppp/exec.h3
-rw-r--r--usr.sbin/ppp/physical.c81
-rw-r--r--usr.sbin/ppp/physical.h5
-rw-r--r--usr.sbin/ppp/tcp.c4
-rw-r--r--usr.sbin/ppp/tcp.h3
-rw-r--r--usr.sbin/ppp/tty.c31
-rw-r--r--usr.sbin/ppp/tty.h3
-rw-r--r--usr.sbin/ppp/udp.c29
-rw-r--r--usr.sbin/ppp/udp.h3
11 files changed, 137 insertions, 35 deletions
diff --git a/usr.sbin/ppp/command.c b/usr.sbin/ppp/command.c
index 45f198a..390c4f6 100644
--- a/usr.sbin/ppp/command.c
+++ b/usr.sbin/ppp/command.c
@@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: command.c,v 1.196 1999/06/02 00:46:52 brian Exp $
+ * $Id: command.c,v 1.197 1999/06/02 21:28:02 brian Exp $
*
*/
#include <sys/param.h>
@@ -142,8 +142,8 @@
#define NEG_VJCOMP 51
#define NEG_DNS 52
-const char Version[] = "2.21";
-const char VersionDate[] = "$Date: 1999/06/02 00:46:52 $";
+const char Version[] = "2.22";
+const char VersionDate[] = "$Date: 1999/06/02 21:28:02 $";
static int ShowCommand(struct cmdargs const *);
static int TerminalCommand(struct cmdargs const *);
diff --git a/usr.sbin/ppp/exec.c b/usr.sbin/ppp/exec.c
index 93f7fe0..28c03e0 100644
--- a/usr.sbin/ppp/exec.c
+++ b/usr.sbin/ppp/exec.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: exec.c,v 1.3 1999/05/24 16:39:10 brian Exp $
+ * $Id: exec.c,v 1.4 1999/06/01 19:08:57 brian Exp $
*/
#include <sys/param.h>
@@ -41,6 +41,7 @@
#include <stdlib.h>
#include <string.h>
#include <sys/wait.h>
+#include <sys/uio.h>
#include <termios.h>
#include <unistd.h>
@@ -98,6 +99,7 @@ exec_iov2device(int type, struct physical *p, struct iovec *iov,
int *niov, int maxiov)
{
if (type == EXEC_DEVICE) {
+ free(iov[(*niov)++].iov_base);
physical_SetupStack(p, execdevice.name, PHYSICAL_FORCE_ASYNC);
return &execdevice;
}
diff --git a/usr.sbin/ppp/exec.h b/usr.sbin/ppp/exec.h
index 0b7f891..45351d7 100644
--- a/usr.sbin/ppp/exec.h
+++ b/usr.sbin/ppp/exec.h
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: exec.h,v 1.1 1999/05/08 11:06:31 brian Exp $
+ * $Id: exec.h,v 1.2 1999/05/12 09:48:50 brian Exp $
*/
struct physical;
@@ -32,3 +32,4 @@ struct device;
extern struct device *exec_Create(struct physical *);
extern struct device *exec_iov2device(int, struct physical *,
struct iovec *, int *, int);
+#define exec_DeviceSize physical_DeviceSize
diff --git a/usr.sbin/ppp/physical.c b/usr.sbin/ppp/physical.c
index 7c36e4a..8de5cc3 100644
--- a/usr.sbin/ppp/physical.c
+++ b/usr.sbin/ppp/physical.c
@@ -16,7 +16,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: physical.c,v 1.15 1999/06/01 19:08:58 brian Exp $
+ * $Id: physical.c,v 1.16 1999/06/02 00:46:54 brian Exp $
*
*/
@@ -98,15 +98,22 @@ static int physical_DescriptorWrite(struct descriptor *, struct bundle *,
static void physical_DescriptorRead(struct descriptor *, struct bundle *,
const fd_set *);
+static int
+physical_DeviceSize(void)
+{
+ return sizeof(struct device);
+}
+
struct {
struct device *(*create)(struct physical *);
struct device *(*iov2device)(int, struct physical *, struct iovec *iov,
int *niov, int maxiov);
+ int (*DeviceSize)(void);
} devices[] = {
- { tty_Create, tty_iov2device },
- { tcp_Create, tcp_iov2device },
- { udp_Create, udp_iov2device },
- { exec_Create, exec_iov2device }
+ { tty_Create, tty_iov2device, tty_DeviceSize },
+ { tcp_Create, tcp_iov2device, tcp_DeviceSize },
+ { udp_Create, udp_iov2device, udp_DeviceSize },
+ { exec_Create, exec_iov2device, exec_DeviceSize }
};
#define NDEVICES (sizeof devices / sizeof devices[0])
@@ -559,6 +566,20 @@ iov2physical(struct datalink *dl, struct iovec *iov, int *niov, int maxiov,
p->fd = fd;
+ type = (long)p->handler;
+ p->handler = NULL;
+ for (h = 0; h < NDEVICES && p->handler == NULL; h++)
+ p->handler = (*devices[h].iov2device)(type, p, iov, niov, maxiov);
+
+ if (p->handler == NULL) {
+ log_Printf(LogPHASE, "%s: Device %s, unknown link type\n",
+ p->link.name, p->name.full);
+ free(iov[(*niov)++].iov_base);
+ physical_SetupStack(p, "unknown", PHYSICAL_NOFORCE);
+ } else
+ log_Printf(LogPHASE, "%s: Device %s, link type is %s\n",
+ p->link.name, p->name.full, p->handler->name);
+
if (p->hdlc.lqm.method && p->hdlc.lqm.timer.load)
lqr_reStart(&p->link.lcp);
hdlc_StartTimer(&p->hdlc);
@@ -566,20 +587,33 @@ iov2physical(struct datalink *dl, struct iovec *iov, int *niov, int maxiov,
throughput_start(&p->link.throughput, "physical throughput",
Enabled(dl->bundle, OPT_THROUGHPUT));
- type = (long)p->handler;
- for (h = 0; h < NDEVICES && p->handler == NULL; h++)
- p->handler = (*devices[h].iov2device)(type, p, iov, niov, maxiov);
+ return p;
+}
- if (p->handler == NULL)
- physical_SetupStack(p, "unknown", PHYSICAL_NOFORCE);
+int
+physical_MaxDeviceSize()
+{
+ int biggest, sz, n;
- return p;
+ biggest = sizeof(struct device);
+ for (sz = n = 0; n < NDEVICES; n++)
+ if (devices[n].DeviceSize) {
+ sz = (*devices[n].DeviceSize)();
+ if (biggest < sz)
+ biggest = sz;
+ }
+
+ return biggest;
}
int
physical2iov(struct physical *p, struct iovec *iov, int *niov, int maxiov,
pid_t newpid)
{
+ struct device *h;
+ int sz;
+
+ h = NULL;
if (p) {
hdlc_StopTimer(&p->hdlc);
lqr_StopTimer(p);
@@ -591,7 +625,7 @@ physical2iov(struct physical *p, struct iovec *iov, int *niov, int maxiov,
timer_Stop(&p->link.ccp.fsm.StoppedTimer);
if (p->handler) {
if (p->handler->device2iov)
- (*p->handler->device2iov)(p, iov, niov, maxiov, newpid);
+ h = p->handler;
p->handler = (struct device *)(long)p->handler->type;
}
@@ -604,17 +638,34 @@ physical2iov(struct physical *p, struct iovec *iov, int *niov, int maxiov,
physical_ChangedPid(p, newpid);
}
- if (*niov >= maxiov) {
- log_Printf(LogERROR, "physical2iov: No room for physical !\n");
+ if (*niov + 1 >= maxiov) {
+ log_Printf(LogERROR, "physical2iov: No room for physical + device !\n");
if (p)
free(p);
return -1;
}
- iov[*niov].iov_base = p ? p : malloc(sizeof *p);
+ iov[*niov].iov_base = p ? (void *)p : malloc(sizeof *p);
iov[*niov].iov_len = sizeof *p;
(*niov)++;
+ sz = physical_MaxDeviceSize();
+ if (p) {
+ if (h)
+ (*h->device2iov)(h, iov, niov, maxiov, newpid);
+ else {
+ iov[*niov].iov_base = malloc(sz);
+ if (p->handler)
+ memcpy(iov[*niov].iov_base, p->handler, sizeof *p->handler);
+ iov[*niov].iov_len = sz;
+ (*niov)++;
+ }
+ } else {
+ iov[*niov].iov_base = malloc(sz);
+ iov[*niov].iov_len = sz;
+ (*niov)++;
+ }
+
return p ? p->fd : 0;
}
diff --git a/usr.sbin/ppp/physical.h b/usr.sbin/ppp/physical.h
index 1f39412..18212b3 100644
--- a/usr.sbin/ppp/physical.h
+++ b/usr.sbin/ppp/physical.h
@@ -16,7 +16,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: physical.h,v 1.11 1999/05/24 16:39:14 brian Exp $
+ * $Id: physical.h,v 1.12 1999/06/01 19:08:59 brian Exp $
*
*/
@@ -44,7 +44,7 @@ struct device {
void (*destroy)(struct physical *);
ssize_t (*read)(struct physical *, void *, size_t);
ssize_t (*write)(struct physical *, const void *, size_t);
- void (*device2iov)(struct physical *, struct iovec *, int *, int, pid_t);
+ void (*device2iov)(struct device *, struct iovec *, int *, int, pid_t);
int (*speed)(struct physical *);
const char *(*openinfo)(struct physical *);
};
@@ -136,3 +136,4 @@ extern int physical_SetMode(struct physical *, int);
extern void physical_DeleteQueue(struct physical *);
extern void physical_SetupStack(struct physical *, const char *, int);
extern void physical_StopDeviceTimer(struct physical *);
+extern int physical_MaxDeviceSize(void);
diff --git a/usr.sbin/ppp/tcp.c b/usr.sbin/ppp/tcp.c
index ab7c32c..2277b3c 100644
--- a/usr.sbin/ppp/tcp.c
+++ b/usr.sbin/ppp/tcp.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: tcp.c,v 1.2 1999/05/12 09:49:04 brian Exp $
+ * $Id: tcp.c,v 1.3 1999/05/24 16:39:15 brian Exp $
*/
#include <sys/types.h>
@@ -36,6 +36,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <sys/uio.h>
#include <termios.h>
#include <unistd.h>
@@ -116,6 +117,7 @@ tcp_iov2device(int type, struct physical *p, struct iovec *iov,
int *niov, int maxiov)
{
if (type == TCP_DEVICE) {
+ free(iov[(*niov)++].iov_base);
physical_SetupStack(p, tcpdevice.name, PHYSICAL_FORCE_ASYNC);
return &tcpdevice;
}
diff --git a/usr.sbin/ppp/tcp.h b/usr.sbin/ppp/tcp.h
index 9eea417..53cbcfb 100644
--- a/usr.sbin/ppp/tcp.h
+++ b/usr.sbin/ppp/tcp.h
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: tcp.h,v 1.1 1999/05/08 11:07:45 brian Exp $
+ * $Id: tcp.h,v 1.2 1999/05/12 09:49:05 brian Exp $
*/
struct physical;
@@ -31,3 +31,4 @@ struct physical;
extern struct device *tcp_Create(struct physical *);
extern struct device *tcp_iov2device(int, struct physical *,
struct iovec *, int *, int);
+#define tcp_DeviceSize physical_DeviceSize
diff --git a/usr.sbin/ppp/tty.c b/usr.sbin/ppp/tty.c
index c8a2c9a..72b3bae 100644
--- a/usr.sbin/ppp/tty.c
+++ b/usr.sbin/ppp/tty.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: tty.c,v 1.7 1999/05/24 16:39:16 brian Exp $
+ * $Id: tty.c,v 1.8 1999/05/27 08:42:49 brian Exp $
*/
#include <sys/param.h>
@@ -47,6 +47,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <sysexits.h>
#include <sys/wait.h>
#include <sys/uio.h>
#include <termios.h>
@@ -85,6 +86,7 @@
#include "chap.h"
#include "cbcp.h"
#include "datalink.h"
+#include "main.h"
#include "tty.h"
#define Online(dev) ((dev)->mbits & TIOCM_CD)
@@ -98,6 +100,12 @@ struct ttydevice {
#define device2tty(d) ((d)->type == TTY_DEVICE ? (struct ttydevice *)d : NULL)
+int
+tty_DeviceSize(void)
+{
+ return sizeof(struct ttydevice);
+}
+
/*
* tty_Timeout() watches the DCD signal and mentions it if it's status
* changes.
@@ -292,13 +300,18 @@ tty_OpenInfo(struct physical *p)
}
static void
-tty_device2iov(struct physical *p, struct iovec *iov, int *niov,
+tty_device2iov(struct device *d, struct iovec *iov, int *niov,
int maxiov, pid_t newpid)
{
- struct ttydevice *dev = p ? device2tty(p->handler) : NULL;
+ struct ttydevice *dev = device2tty(d);
+ int sz = physical_MaxDeviceSize();
- iov[*niov].iov_base = p ? p->handler : malloc(sizeof(struct ttydevice));
- iov[*niov].iov_len = sizeof(struct ttydevice);
+ iov[*niov].iov_base = realloc(d, sz);
+ if (iov[*niov].iov_base == NULL) {
+ log_Printf(LogALERT, "Failed to allocate memory: %d\n", sz);
+ AbortProgram(EX_OSERR);
+ }
+ iov[*niov].iov_len = sz;
(*niov)++;
if (dev->Timer.state != TIMER_STOPPED) {
@@ -329,12 +342,20 @@ tty_iov2device(int type, struct physical *p, struct iovec *iov, int *niov,
if (type == TTY_DEVICE) {
struct ttydevice *dev = (struct ttydevice *)iov[(*niov)++].iov_base;
+ dev = realloc(dev, sizeof *dev); /* Reduce to the correct size */
+ if (dev == NULL) {
+ log_Printf(LogALERT, "Failed to allocate memory: %d\n",
+ (int)(sizeof *dev));
+ AbortProgram(EX_OSERR);
+ }
+
/* Refresh function pointers etc */
memcpy(&dev->dev, &basettydevice, sizeof dev->dev);
physical_SetupStack(p, dev->dev.name, PHYSICAL_NOFORCE);
if (dev->Timer.state != TIMER_STOPPED) {
dev->Timer.state = TIMER_STOPPED;
+ p->handler = &dev->dev; /* For the benefit of StartTimer */
tty_StartTimer(p);
}
return &dev->dev;
diff --git a/usr.sbin/ppp/tty.h b/usr.sbin/ppp/tty.h
index 9dc4417..b253b76 100644
--- a/usr.sbin/ppp/tty.h
+++ b/usr.sbin/ppp/tty.h
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: tty.h,v 1.1 1999/05/08 11:07:52 brian Exp $
+ * $Id: tty.h,v 1.2 1999/05/12 09:49:08 brian Exp $
*/
struct physical;
@@ -32,3 +32,4 @@ struct device;
extern struct device *tty_Create(struct physical *);
extern struct device *tty_iov2device(int, struct physical *,
struct iovec *, int *, int);
+extern int tty_DeviceSize(void);
diff --git a/usr.sbin/ppp/udp.c b/usr.sbin/ppp/udp.c
index 38a82d4..e9a4a4a 100644
--- a/usr.sbin/ppp/udp.c
+++ b/usr.sbin/ppp/udp.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: udp.c,v 1.1 1999/05/12 09:49:09 brian Exp $
+ * $Id: udp.c,v 1.2 1999/05/24 16:39:17 brian Exp $
*/
#include <sys/types.h>
@@ -36,6 +36,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <sysexits.h>
#include <sys/uio.h>
#include <termios.h>
#include <unistd.h>
@@ -56,6 +57,7 @@
#include "async.h"
#include "descriptor.h"
#include "physical.h"
+#include "main.h"
#include "udp.h"
struct udpdevice {
@@ -66,6 +68,12 @@ struct udpdevice {
#define device2udp(d) ((d)->type == UDP_DEVICE ? (struct udpdevice *)d : NULL)
+int
+udp_DeviceSize(void)
+{
+ return sizeof(struct udpdevice);
+}
+
static ssize_t
udp_Sendto(struct physical *p, const void *v, size_t n)
{
@@ -108,11 +116,17 @@ udp_Free(struct physical *p)
}
static void
-udp_device2iov(struct physical *p, struct iovec *iov, int *niov,
+udp_device2iov(struct device *d, struct iovec *iov, int *niov,
int maxiov, pid_t newpid)
{
- iov[*niov].iov_base = p ? p->handler : malloc(sizeof(struct udpdevice));
- iov[*niov].iov_len = sizeof(struct udpdevice);
+ int sz = physical_MaxDeviceSize();
+
+ iov[*niov].iov_base = realloc(d, sz);
+ if (iov[*niov].iov_base == NULL) {
+ log_Printf(LogALERT, "Failed to allocate memory: %d\n", sz);
+ AbortProgram(EX_OSERR);
+ }
+ iov[*niov].iov_len = sz;
(*niov)++;
}
@@ -138,6 +152,13 @@ udp_iov2device(int type, struct physical *p, struct iovec *iov, int *niov,
if (type == UDP_DEVICE) {
struct udpdevice *dev = (struct udpdevice *)iov[(*niov)++].iov_base;
+ dev = realloc(dev, sizeof *dev); /* Reduce to the correct size */
+ if (dev == NULL) {
+ log_Printf(LogALERT, "Failed to allocate memory: %d\n",
+ (int)(sizeof *dev));
+ AbortProgram(EX_OSERR);
+ }
+
/* Refresh function pointers etc */
memcpy(&dev->dev, &baseudpdevice, sizeof dev->dev);
diff --git a/usr.sbin/ppp/udp.h b/usr.sbin/ppp/udp.h
index 38dd016..9149f18 100644
--- a/usr.sbin/ppp/udp.h
+++ b/usr.sbin/ppp/udp.h
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: tcp.h,v 1.1 1999/05/08 11:07:45 brian Exp $
+ * $Id: udp.h,v 1.1 1999/05/12 09:49:11 brian Exp $
*/
struct physical;
@@ -32,3 +32,4 @@ struct device;
extern struct device *udp_Create(struct physical *);
extern struct device *udp_iov2device(int, struct physical *,
struct iovec *, int *, int);
+extern int udp_DeviceSize(void);
OpenPOWER on IntegriCloud