Sync with latest.

This commit is contained in:
christos 2017-10-13 17:24:05 +00:00
parent 9b1e942d48
commit 5b35d8be6b
13 changed files with 91 additions and 303 deletions

View file

@ -1,9 +1,9 @@
# $NetBSD: Makefile,v 1.3 2015/06/01 14:01:21 hauke Exp $
# $NetBSD: Makefile,v 1.4 2017/10/13 17:24:05 christos Exp $
#
DISTNAME= xl2tpd-20140214
DISTNAME= xl2tpd-20171013
CATEGORIES= net
PKGREVISION= 1
#PKGREVISION= 1
MASTER_SITES= -https://github.com/xelerance/xl2tpd/archive/master.zip
EXTRACT_SUFX= .zip
WRKSRC= ${WRKDIR}/xl2tpd-master

View file

@ -1,9 +1,10 @@
@comment $NetBSD: PLIST,v 1.2 2015/06/01 14:01:21 hauke Exp $
@comment $NetBSD: PLIST,v 1.3 2017/10/13 17:24:05 christos Exp $
bin/pfc
man/man1/pfc.1
man/man5/l2tp-secrets.5
man/man5/xl2tpd.conf.5
man/man8/xl2tpd.8
man/man8/xl2tpd-control.8
sbin/xl2tpd
sbin/xl2tpd-control
share/examples/rc.d/xl2tpd

View file

@ -1,15 +1,16 @@
$NetBSD: distinfo,v 1.9 2017/08/19 00:27:13 jlam Exp $
$NetBSD: distinfo,v 1.10 2017/10/13 17:24:05 christos Exp $
SHA1 (xl2tpd-20140214.zip) = 6d5d38674b6671ef1cd1880a548645ae08725a9e
RMD160 (xl2tpd-20140214.zip) = 684f3d1d07ce3b0629123f056f8cf3f6d67c41f3
SHA512 (xl2tpd-20140214.zip) = dc3425caebf5851909912c0e53cc699b725700ff0ec6285ab2b8fc3c72e4ea862810c8c1c9606ff89217c18e7ebf518c52dedb4b6154eb3b6d25eb7fadad0802
Size (xl2tpd-20140214.zip) = 591764 bytes
SHA1 (patch-Makefile) = 1e5ba70de0510b18bb0d811970a1cb4576b802a2
SHA1 (patch-control.c) = 3b1aa772be07bdc1312d94c8e0b1543086b6fb7f
SHA1 (patch-l2tp.h) = d068d47170da6a1a3d960ef6f7a7027c10c8820f
SHA1 (patch-md5.c) = cc100db8b9314a86a96464cde4df78c387b56e9a
SHA1 (patch-misc.c) = 8c1b0bff81af1f5718cbf1d02e4f47fcad14c9a9
SHA1 (patch-misc.h) = dd7a42bee5a16cc583bfcfc31b1fc589d39515ab
SHA1 (patch-network.c) = f5aae9874b7024eb339b439b5bd0354dd4f320fc
SHA1 (patch-pty.c) = ade58a4e34f0977ebaba713b0be74ed943047a13
SHA1 (patch-xl2tpd.c) = b5ff4245b380d9aff480f9dbe961c92faf691b3d
SHA1 (xl2tpd-20171013.zip) = 6495031d98b8d803503e47ca20a1902fb116779c
RMD160 (xl2tpd-20171013.zip) = 4e6cbe6fd9792e14e4bc33ad7daeef3e917eda1b
SHA512 (xl2tpd-20171013.zip) = 95868ebcea53f55ae0c3edae6b0a5904d8aa13a046b8e0c0eb06eb1eb656ee16245aa002694dfb080e1295ceea27bc6c147d4ef7702b038925bcfdac522d7e91
Size (xl2tpd-20171013.zip) = 548262 bytes
SHA1 (patch-Makefile) = 4aca35c2abef9936dbc5d93c2bbb9a98d7ce9b5e
SHA1 (patch-control.c) = d827e19630fc5c4a8c4e4159d1cc89d07f49e540
SHA1 (patch-l2tp.h) = 7289337a0b8c72fff095df5be349ae8e60357a99
SHA1 (patch-md5.c) = 70316f37538d525693f243f3c415ea141aa6bb4e
SHA1 (patch-misc.c) = f357e60438211a8c94789712cb55c7fc690bce1a
SHA1 (patch-misc.h) = faa5bf97b2fbc853e867177686eb324e7341d341
SHA1 (patch-network.c) = 5d5a9cce0f780a24489caebc25d87a09d937a084
SHA1 (patch-osport.h) = 370d7b5c617022d4ca6d87abcd595327dcfd0cfe
SHA1 (patch-pty.c) = 3284ab1ea19d3ccce459bdb4742a7f33e8e557fe
SHA1 (patch-xl2tpd.c) = 9e94b1b0e6f6cd99c11353d1d3df37e307d6ac39

View file

@ -1,10 +1,10 @@
$NetBSD: patch-Makefile,v 1.2 2017/08/19 00:27:13 jlam Exp $
$NetBSD: patch-Makefile,v 1.3 2017/10/13 17:24:05 christos Exp $
Default to NetBSD
Fix man directory
--- Makefile.orig 2013-06-17 06:17:24.000000000 -0400
+++ Makefile 2013-06-26 14:26:45.000000000 -0400
--- Makefile.orig 2017-08-02 13:46:06.000000000 -0400
+++ Makefile 2017-10-13 12:46:33.893556318 -0400
@@ -54,7 +54,7 @@
#
#KERNELSRC=/lib/modules/`uname -r`/build/
@ -23,7 +23,7 @@ Fix man directory
#
#
# Uncomment the next line for FreeBSD
@@ -83,6 +83,11 @@
@@ -89,6 +89,11 @@
#
#OSFLAGS?= -DOPENBSD
#LDLIBS?= -lutil
@ -35,7 +35,7 @@ Fix man directory
# Feature flags
#
@@ -103,7 +108,7 @@
@@ -109,7 +114,7 @@
PREFIX?=/usr/local
SBINDIR?=$(DESTDIR)${PREFIX}/sbin
BINDIR?=$(DESTDIR)${PREFIX}/bin

View file

@ -1,58 +1,13 @@
$NetBSD: patch-control.c,v 1.2 2013/07/18 12:06:39 joerg Exp $
$NetBSD: patch-control.c,v 1.3 2017/10/13 17:24:05 christos Exp $
Remove static from inline; each inlined copy might have its own buffer and
this is not want you want if you define it static. In this case it does not
matter, since it is only 4K and we don't return it, so don't try to play
around with saving stack space for no good reason.
--- control.c.orig 2013-06-17 10:17:24.000000000 +0000
+++ control.c
@@ -75,7 +75,7 @@ struct buffer *new_outgoing (struct tunn
return tmp;
}
-inline void recycle_outgoing (struct buffer *buf, struct sockaddr_in peer)
+void recycle_outgoing (struct buffer *buf, struct sockaddr_in peer)
{
/*
* This should only be used for ZLB's!
@@ -1139,7 +1139,7 @@ int control_finish (struct tunnel *t, st
return 0;
}
-inline int check_control (const struct buffer *buf, struct tunnel *t,
+static inline int check_control (const struct buffer *buf, struct tunnel *t,
struct call *c)
{
/*
@@ -1275,7 +1275,7 @@ inline int check_control (const struct b
return 0;
}
-inline int check_payload (struct buffer *buf, struct tunnel *t,
+static inline int check_payload (struct buffer *buf, struct tunnel *t,
struct call *c)
{
/*
@@ -1381,7 +1381,7 @@ inline int check_payload (struct buffer
#endif
return 0;
}
-inline int expand_payload (struct buffer *buf, struct tunnel *t,
+static inline int expand_payload (struct buffer *buf, struct tunnel *t,
struct call *c)
{
/*
@@ -1561,7 +1561,7 @@ void send_zlb (void *data)
toss (buf);
}
-inline int write_packet (struct buffer *buf, struct tunnel *t, struct call *c,
+static inline int write_packet (struct buffer *buf, struct tunnel *t, struct call *c,
int convert)
{
/*
@@ -1571,7 +1571,7 @@ inline int write_packet (struct buffer *
--- control.c.orig 2017-08-02 13:46:06.000000000 -0400
+++ control.c 2017-10-13 12:46:33.920249976 -0400
@@ -1600,7 +1600,7 @@
int x;
unsigned char e;
int err;
@ -61,12 +16,3 @@ around with saving stack space for no good reason.
int pos = 0;
if (c->fd < 0)
@@ -1739,7 +1739,7 @@ void handle_special (struct buffer *buf,
}
}
-inline int handle_packet (struct buffer *buf, struct tunnel *t,
+int handle_packet (struct buffer *buf, struct tunnel *t,
struct call *c)
{
int res;

View file

@ -1,11 +1,10 @@
$NetBSD: patch-l2tp.h,v 1.2 2013/07/12 19:06:31 christos Exp $
$NetBSD: patch-l2tp.h,v 1.3 2017/10/13 17:24:05 christos Exp $
Include common.h first since it typedefs things other headers need
Conditionalize in_pktinfo
--- l2tp.h.orig 2013-06-17 06:17:24.000000000 -0400
+++ l2tp.h 2013-07-12 15:00:53.000000000 -0400
@@ -28,13 +28,13 @@
--- l2tp.h.orig 2017-08-02 13:46:06.000000000 -0400
+++ l2tp.h 2017-10-13 12:46:33.946695069 -0400
@@ -30,13 +30,13 @@
#endif
#include "osport.h"
#include "scheduler.h"
@ -20,13 +19,3 @@ Conditionalize in_pktinfo
#include "ipsecmast.h"
#define CONTROL_PIPE "/var/run/xl2tpd/l2tp-control"
@@ -172,7 +172,9 @@
struct call *self;
struct lns *lns; /* LNS that owns us */
struct lac *lac; /* LAC that owns us */
+#ifdef IP_PKTINFO
struct in_pktinfo my_addr; /* Address of my endpoint */
+#endif
};
struct tunnel_list

View file

@ -1,10 +1,9 @@
$NetBSD: patch-md5.c,v 1.2 2013/07/12 19:06:31 christos Exp $
$NetBSD: patch-md5.c,v 1.3 2017/10/13 17:24:05 christos Exp $
Include endian.h for NetBSD
memset the right size, not just the first sizeof(ptr) bits.
--- md5.c.orig 2013-06-17 06:17:24.000000000 -0400
+++ md5.c 2013-07-12 14:52:02.000000000 -0400
--- md5.c.orig 2017-08-02 13:46:06.000000000 -0400
+++ md5.c 2017-10-13 12:46:33.972632069 -0400
@@ -7,6 +7,8 @@
# include <endian.h>
#elif defined(SOLARIS)
@ -14,12 +13,3 @@ memset the right size, not just the first sizeof(ptr) bits.
#endif
#if __BYTE_ORDER == __BIG_ENDIAN
#define HIGHFIRST 1
@@ -166,7 +168,7 @@
MD5Transform (ctx->buf, (uint32 *) ctx->in);
byteReverse ((unsigned char *) ctx->buf, 4);
memcpy (digest, ctx->buf, 16);
- memset (ctx, 0, sizeof (ctx)); /* In case it's sensitive */
+ memset (ctx, 0, sizeof (*ctx)); /* In case it's sensitive */
}
#ifndef ASM_MD5

View file

@ -1,14 +1,14 @@
$NetBSD: patch-misc.c,v 1.1 2013/07/12 19:06:31 christos Exp $
$NetBSD: patch-misc.c,v 1.2 2017/10/13 17:24:05 christos Exp $
Declare inline in a separate file.
--- misc.c.orig 2013-06-17 06:17:24.000000000 -0400
+++ misc.c 2013-07-12 14:58:32.000000000 -0400
@@ -170,33 +170,6 @@
--- misc.c.orig 2017-08-02 13:46:06.000000000 -0400
+++ misc.c 2017-10-13 12:51:24.225866762 -0400
@@ -175,33 +175,6 @@
printf ("}\n");
}
-inline void swaps (void *buf_v, int len)
-void swaps (void *buf_v, int len)
-{
-#ifdef __alpha
- /* Reverse byte order alpha is little endian so lest save a step.

View file

@ -1,14 +1,14 @@
$NetBSD: patch-misc.h,v 1.1 2013/07/12 19:06:31 christos Exp $
$NetBSD: patch-misc.h,v 1.2 2017/10/13 17:24:05 christos Exp $
Portable inlines are in header files.
--- misc.h.orig 2013-06-17 06:17:24.000000000 -0400
+++ misc.h 2013-07-12 14:58:05.000000000 -0400
--- misc.h.orig 2017-08-02 13:46:06.000000000 -0400
+++ misc.h 2017-10-13 12:49:29.042331434 -0400
@@ -65,7 +65,6 @@
extern struct buffer *new_buf (int);
extern void udppush_handler (int);
extern int addfcs (struct buffer *buf);
-extern inline void swaps (void *, int);
-extern void swaps (void *, int);
extern void do_packet_dump (struct buffer *);
extern void status (const char *fmt, ...);
extern void status_handler (int signal);

View file

@ -1,170 +1,15 @@
$NetBSD: patch-network.c,v 1.4 2015/02/19 22:27:59 joerg Exp $
$NetBSD: patch-network.c,v 1.5 2017/10/13 17:24:05 christos Exp $
Handle not having IP_PKTINFO
Handle not having SO_NO_CHECK
Don't set control buf if controllen == 0
Avoid pointer aliasing issue and fix test that was done in the wrong
byte order
Argument to setsockopt should be int not long
--- network.c.orig 2014-01-16 22:02:04.000000000 +0000
+++ network.c
@@ -85,24 +85,26 @@ int init_network (void)
--- network.c.orig 2017-08-02 13:46:06.000000000 -0400
+++ network.c 2017-10-13 13:09:05.187604385 -0400
@@ -39,7 +39,7 @@
gconfig.ipsecsaref=0;
}
-
- arg=1;
- if(setsockopt(server_socket, IPPROTO_IP, IP_PKTINFO, (char*)&arg, sizeof(arg)) != 0) {
- l2tp_log(LOG_CRIT, "setsockopt IP_PKTINFO: %s\n", strerror(errno));
- }
#else
{
l2tp_log(LOG_INFO, "No attempt being made to use IPsec SAref's since we're not on a Linux machine.\n");
}
-
+#endif
+#ifdef IP_PKTINFO
+ arg=1;
+ if(setsockopt(server_socket, IPPROTO_IP, IP_PKTINFO, (char*)&arg, sizeof(arg)) != 0) {
+ l2tp_log(LOG_CRIT, "setsockopt IP_PKTINFO: %s\n", strerror(errno));
+ }
#endif
/* turn off UDP checksums */
+#ifdef SO_NO_CHECK
arg=1;
if (setsockopt(server_socket, SOL_SOCKET, SO_NO_CHECK , (void*)&arg,
sizeof(arg)) ==-1) {
l2tp_log(LOG_INFO, "unable to turn off UDP checksums");
}
+#endif
#ifdef USE_KERNEL
if (gconfig.forceuserspace)
@@ -135,7 +137,7 @@ int init_network (void)
return 0;
}
-inline void extract (void *buf, int *tunnel, int *call)
+static inline void extract (void *buf, int *tunnel, int *call)
int init_network (void)
{
/*
* Extract the tunnel and call #'s, and fix the order of the
@@ -155,15 +157,13 @@ inline void extract (void *buf, int *tun
}
}
-inline void fix_hdr (void *buf)
+static inline void fix_hdr (void *buf)
{
/*
* Fix the byte order of the header
*/
-
- struct payload_hdr *p = (struct payload_hdr *) buf;
- _u16 ver = ntohs (p->ver);
- if (CTBIT (p->ver))
+ _u16 ver = ntohs (*(_u16 *)buf);
+ if (CTBIT (ver))
{
/*
* Control headers are always
@@ -280,12 +280,18 @@ void control_xmit (void *b)
void udp_xmit (struct buffer *buf, struct tunnel *t)
{
struct cmsghdr *cmsg;
- char cbuf[CMSG_SPACE(sizeof (unsigned int) + sizeof (struct in_pktinfo))];
+ char cbuf[CMSG_SPACE(sizeof (unsigned int)
+#ifdef IP_PKTINFO
+ + sizeof (struct in_pktinfo)
+#endif
+ )];
unsigned int *refp;
struct msghdr msgh;
int err;
struct iovec iov;
+#ifdef IP_PKTINFO
struct in_pktinfo *pktinfo;
+#endif
int finallen;
/*
@@ -312,7 +318,7 @@ void udp_xmit (struct buffer *buf, struc
finallen = cmsg->cmsg_len;
}
-
+#ifdef IP_PKTINFO
if (t->my_addr.ipi_addr.s_addr){
if ( ! cmsg) {
@@ -331,7 +337,9 @@ void udp_xmit (struct buffer *buf, struc
finallen += cmsg->cmsg_len;
}
-
+#endif
+ if (finallen == 0)
+ msgh.msg_control = NULL;
msgh.msg_controllen = finallen;
iov.iov_base = buf->start;
@@ -426,7 +434,9 @@ void network_thread ()
* our network socket. Control handling is no longer done here.
*/
struct sockaddr_in from;
+#ifdef IP_PKTINFO
struct in_pktinfo to;
+#endif
unsigned int fromlen;
int tunnel, call; /* Tunnel and call */
int recvsize; /* Length of data received */
@@ -506,7 +516,9 @@ void network_thread ()
buf->len -= PAYLOAD_BUF;
memset(&from, 0, sizeof(from));
+#ifdef IP_PKTINFO
memset(&to, 0, sizeof(to));
+#endif
fromlen = sizeof(from);
@@ -557,13 +569,16 @@ void network_thread ()
for (cmsg = CMSG_FIRSTHDR(&msgh);
cmsg != NULL;
cmsg = CMSG_NXTHDR(&msgh,cmsg)) {
+#ifdef IP_PKTINFO
/* extract destination(our) addr */
if (cmsg->cmsg_level == IPPROTO_IP && cmsg->cmsg_type == IP_PKTINFO) {
struct in_pktinfo* pktInfo = ((struct in_pktinfo*)CMSG_DATA(cmsg));
to = *pktInfo;
+ continue;
}
+#endif
/* extract IPsec info out */
- else if (gconfig.ipsecsaref && cmsg->cmsg_level == IPPROTO_IP
+ if (gconfig.ipsecsaref && cmsg->cmsg_level == IPPROTO_IP
&& cmsg->cmsg_type == gconfig.sarefnum) {
unsigned int *refp;
@@ -592,6 +607,8 @@ void network_thread ()
if (gconfig.packet_dump)
{
+ struct payload_hdr *p = (struct payload_hdr *) buf->start;
+ l2tp_log(LOG_DEBUG, "ver = 0x%x\n", p->ver);
do_packet_dump (buf);
}
if (!
@@ -627,9 +644,11 @@ void network_thread ()
}
else
{
+#ifdef IP_PKTINFO
if (c->container) {
c->container->my_addr = to;
}
+#endif
buf->peer = from;
/* Handle the packet */
- long arg;
+ int arg;
unsigned int length = sizeof (server);
gethostname (hostname, sizeof (hostname));
server.sin_family = AF_INET;

View file

@ -0,0 +1,15 @@
$NetBSD: patch-osport.h,v 1.1 2017/10/13 17:24:05 christos Exp $
NetBSD has in_pktinfo
--- osport.h.orig 2017-08-02 13:46:06.000000000 -0400
+++ osport.h 2017-10-13 12:48:43.585921159 -0400
@@ -35,7 +35,7 @@
#endif /* defined(SOLARIS) */
-#if !defined(LINUX)
+#if !defined(LINUX) && !defined(NETBSD)
/* Declare empty structure to make code portable and keep simple */
struct in_pktinfo {

View file

@ -1,21 +1,21 @@
$NetBSD: patch-pty.c,v 1.3 2014/02/14 22:06:39 christos Exp $
$NetBSD: patch-pty.c,v 1.4 2017/10/13 17:24:05 christos Exp $
Fix pty allocation to use openpty(3) for all BSD's
Fix closing slave bug.
Set the pty queue size if we have it.
Set set _NETBSRC_SOURCE for older NetBSD versions and sockaddr_storage.
Set set _NETBSD_SOURCE for older NetBSD versions and sockaddr_storage.
--- pty.c.orig 2014-01-16 17:02:04.000000000 -0500
+++ pty.c 2014-02-14 14:28:45.000000000 -0500
--- pty.c.orig 2017-08-02 13:46:06.000000000 -0400
+++ pty.c 2017-10-13 12:57:26.789420473 -0400
@@ -17,6 +17,7 @@
#define _ISOC99_SOURCE
#define _XOPEN_SOURCE
#define _BSD_SOURCE
+#define _NETBSD_SOURCE
#define _DEFAULT_SOURCE
#define _XOPEN_SOURCE_EXTENDED
#include <stdlib.h>
@@ -25,6 +26,7 @@
@@ -26,6 +27,7 @@
#include <errno.h>
#include <stdio.h>
#include <fcntl.h>
@ -23,7 +23,7 @@ Set set _NETBSRC_SOURCE for older NetBSD versions and sockaddr_storage.
#include "l2tp.h"
@@ -41,13 +43,12 @@
@@ -42,13 +44,12 @@
#define PTY01 "0123456789abcdef"
#endif
@ -41,7 +41,7 @@ Set set _NETBSRC_SOURCE for older NetBSD versions and sockaddr_storage.
int getPtyMaster_pty (char *tty10, char *tty01)
{
char *p10;
@@ -110,56 +111,63 @@
@@ -111,14 +112,13 @@
return fd;
}
@ -52,16 +52,17 @@ Set set _NETBSRC_SOURCE for older NetBSD versions and sockaddr_storage.
+int getPtyMaster_ptmx(char *ttybuf, int ttybuflen)
{
int amaster, aslave;
char *tty = (char*) malloc(64);
char *tty = malloc(64);
- if((openpty(&amaster, &aslave, tty, NULL, NULL)) == -1)
+ if (openpty(&amaster, &aslave, tty, NULL, NULL) == -1)
+ if(openpty(&amaster, &aslave, tty, NULL, NULL) == -1)
{
l2tp_log (LOG_WARNING, "%s: openpty() returned %s\n",
__FUNCTION__, strerror(errno));
free(tty);
@@ -126,41 +126,51 @@
return -EINVAL;
}
+#ifdef TIOCSQSIZE
+ {
+ int qsize = 32768;
@ -74,7 +75,7 @@ Set set _NETBSRC_SOURCE for older NetBSD versions and sockaddr_storage.
+ l2tp_log(LOG_WARNING, "set queue size for %s to %d\n", tty, qsize);
+ }
+#endif
+
ttybuf[0] = '\0';
strncat(ttybuf, tty, ttybuflen);
@ -96,7 +97,7 @@ Set set _NETBSRC_SOURCE for older NetBSD versions and sockaddr_storage.
if(fd >= 0) {
return fd;
}
-
- l2tp_log (LOG_WARNING, "%s: failed to use pts -- using legacy ptys\n", __FUNCTION__);
- fd = getPtyMaster_pty(&a,&b);
+#ifndef ALLBSD

View file

@ -1,12 +1,12 @@
$NetBSD: patch-xl2tpd.c,v 1.2 2014/02/14 22:06:39 christos Exp $
$NetBSD: patch-xl2tpd.c,v 1.3 2017/10/13 17:24:05 christos Exp $
Expose functions
--- xl2tpd.c.orig 2014-01-16 17:02:04.000000000 -0500
+++ xl2tpd.c 2014-02-14 14:27:24.000000000 -0500
@@ -19,6 +19,7 @@
#define _BSD_SOURCE
#define _XOPEN_SOURCE_EXTENDED
--- xl2tpd.c.orig 2017-08-02 13:46:06.000000000 -0400
+++ xl2tpd.c 2017-10-13 12:50:10.384619299 -0400
@@ -20,6 +20,7 @@
#define _DEFAULT_SOURCE
#define _XOPEN_SOURCE_EXTENDED 1
#define _GNU_SOURCE
+#define _NETBSD_SOURCE