summaryrefslogtreecommitdiff
path: root/repo/vde2
diff options
context:
space:
mode:
authordavidovski <david@davidovski.xyz>2022-06-15 20:02:02 +0100
committerdavidovski <david@davidovski.xyz>2022-06-15 20:02:02 +0100
commitd2567bfbdf0e9fa6db0a6ed1534831ec859a3e03 (patch)
tree684a17eebf446aa1adab1097616f1882c8d51568 /repo/vde2
parentd1fc3393cca72e8e432f827f7624e38734fad6dc (diff)
added deps for qemu
Diffstat (limited to 'repo/vde2')
-rw-r--r--repo/vde2/inline.patch21
-rw-r--r--repo/vde2/musl-build-fix.patch15
-rw-r--r--repo/vde2/vde2.post-down37
-rw-r--r--repo/vde2/vde2.pre-install6
-rw-r--r--repo/vde2/vde2.pre-up74
-rw-r--r--repo/vde2/vde2.xibuild41
-rw-r--r--repo/vde2/vde_cryptcab-compile-against-openssl-1.1.0.patch92
7 files changed, 286 insertions, 0 deletions
diff --git a/repo/vde2/inline.patch b/repo/vde2/inline.patch
new file mode 100644
index 0000000..b11840f
--- /dev/null
+++ b/repo/vde2/inline.patch
@@ -0,0 +1,21 @@
+diff --git a/src/vde_switch/fstp.c b/src/vde_switch/fstp.c
+index ac5e313..26c5a67 100644
+--- a/src/vde_switch/fstp.c
++++ b/src/vde_switch/fstp.c
+@@ -30,14 +30,14 @@ static int numports;
+ #ifdef FSTP
+ #include <fstp.h>
+ /*********************** sending macro used by FSTP & Core ******************/
+-void inline ltonstring(unsigned long l,unsigned char *s) {
++static void ltonstring(unsigned long l,unsigned char *s) {
+ s[3]=l; l>>=8;
+ s[2]=l; l>>=8;
+ s[1]=l; l>>=8;
+ s[0]=l;
+ }
+
+-unsigned long inline nstringtol(unsigned char *s) {
++static unsigned long nstringtol(unsigned char *s) {
+ return (s[0]<<24)+(s[1]<<16)+(s[2]<<8)+s[3];
+ }
+
diff --git a/repo/vde2/musl-build-fix.patch b/repo/vde2/musl-build-fix.patch
new file mode 100644
index 0000000..c03459c
--- /dev/null
+++ b/repo/vde2/musl-build-fix.patch
@@ -0,0 +1,15 @@
+diff --git a/src/vdetaplib/libvdetap.c b/src/vdetaplib/libvdetap.c
+index 00cd401..c70f290 100644
+--- a/src/vdetaplib/libvdetap.c
++++ b/src/vdetaplib/libvdetap.c
+@@ -121,6 +121,10 @@ int open(const char *path, int flags, ...)
+ return native_open(path, flags, data);
+ }
+
++/* musl apparently defines open64 as a macro */
++#ifdef open64
++#undef open64
++#endif
+ int open64(const char *path, int flags, ...)
+ {
+ va_list ap;
diff --git a/repo/vde2/vde2.post-down b/repo/vde2/vde2.post-down
new file mode 100644
index 0000000..be5f5b3
--- /dev/null
+++ b/repo/vde2/vde2.post-down
@@ -0,0 +1,37 @@
+#!/bin/sh
+
+VDE_SWITCH=/usr/bin/vde_switch
+SLIRPVDE=/usr/bin/slirpvde
+
+# this is not an interesting stanza for us
+if [ -z "$IF_VDE2_SWITCH" -a -z "$IF_VDE2_PLUG" -a -z "$IF_VDE2_SLIRP" ]; then
+ exit 0
+fi
+
+PIDFILE="/var/run/vde2/$IFACE-plug.pid"
+CTLFILE="/var/run/vde2/$IFACE.ctl"
+if [ -f $PIDFILE ]; then
+ start-stop-daemon --stop --quiet --pidfile $PIDFILE
+ rm -f $PIDFILE
+fi
+
+PIDFILE="/var/run/vde2/$IFACE-slirp.pid"
+if [ -f $PIDFILE ]; then
+ start-stop-daemon --stop --quiet --pidfile $PIDFILE \
+ --exec $SLIRPVDE
+ rm -f $PIDFILE
+fi
+
+PIDFILE="/var/run/vde2/$IFACE.pid"
+CTLDIR="/var/run/vde2/$IFACE.ctl"
+if [ -f $PIDFILE ]; then
+ start-stop-daemon --stop --quiet --pidfile $PIDFILE \
+ --exec $VDE_SWITCH
+ rm -f $PIDFILE
+
+ # set the tap interface to non-persistant, see #568363
+ vde_tunctl -b -d $IFACE 1>/dev/null
+fi
+
+rm -rf $CTLDIR
+rm -f $CTLDIR.*
diff --git a/repo/vde2/vde2.pre-install b/repo/vde2/vde2.pre-install
new file mode 100644
index 0000000..3c3e08d
--- /dev/null
+++ b/repo/vde2/vde2.pre-install
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+addgroup -S vde2-net 2>/dev/null
+adduser -S -D -H -h /var/run/vde2 -s /sbin/nologin -G vde2-net -g vde2-net vde2-net 2>/dev/null
+
+exit 0
diff --git a/repo/vde2/vde2.pre-up b/repo/vde2/vde2.pre-up
new file mode 100644
index 0000000..991b382
--- /dev/null
+++ b/repo/vde2/vde2.pre-up
@@ -0,0 +1,74 @@
+#!/bin/sh
+
+VDE_SWITCH=/usr/bin/vde_switch
+VDE_PLUG=/usr/bin/vde_plug
+SLIRPVDE=/usr/bin/slirpvde
+DPIPE=/usr/bin/dpipe
+RUNDIR=/var/run/vde2
+
+USER=vde2-net
+GROUP=vde2-net
+
+if [ ! -x $VDE_SWITCH ] || [ ! -x $SLIRPVDE ]; then
+ exit 0
+fi
+
+# this is not an interesting stanza for us
+if [ -z "$IF_VDE2_SWITCH" -a -z "$IF_VDE2_PLUG" -a -z "$IF_VDE2_SLIRP" ]; then
+ exit 0
+fi
+
+
+# Create directory if missing
+if [ ! -d $RUNDIR ]; then
+ mkdir -p $RUNDIR
+ chown vde2-net:vde2-net $RUNDIR
+ chmod 2770 $RUNDIR
+fi
+
+# vde2-switch [-|<args>]
+if [ -n "$IF_VDE2_SWITCH" ]; then
+ set -- $IF_VDE2_SWITCH
+ test "$1" = "-" && shift
+ PIDFILE="$RUNDIR/$IFACE.pid"
+ CTLDIR="$RUNDIR/$IFACE.ctl"
+ MGMTFILE="$RUNDIR/$IFACE.mgmt"
+
+ if [ "$METHOD" = "manual" ]; then
+ TAPOPTS=""
+ else
+ TAPOPTS="-t $IFACE"
+ fi
+
+ # block to make sure the interface exists, see #568363
+ vde_tunctl -b -t $IFACE 1>/dev/null
+
+ start-stop-daemon --start --quiet --pidfile $PIDFILE \
+ --exec $VDE_SWITCH -- \
+ -s $CTLDIR -m 660 -g $GROUP -p $PIDFILE $TAPOPTS \
+ -M $MGMTFILE --mgmtmode 660 -d "$@"
+fi
+
+# vde2-plug <dpipe_cmd2>
+if [ -n "$IF_VDE2_PLUG" ]; then
+ set -- $IF_VDE2_PLUG
+ PIDFILE="$RUNDIR/$IFACE-plug.pid"
+ CTLDIR="$RUNDIR/$IFACE.ctl"
+
+ start-stop-daemon --start --quiet --pidfile $PIDFILE \
+ --make-pidfile --background \
+ --exec $DPIPE -- $VDE_PLUG -g $GROUP -m 660 $CTLDIR = "$@"
+fi
+
+# vde2-slirp [-|<args>]
+if [ -n "$IF_VDE2_SLIRP" ]; then
+ set -- $IF_VDE2_SLIRP
+ test "$1" = "-" && shift
+ PIDFILE="$RUNDIR/$IFACE-slirp.pid"
+ CTLDIR="$RUNDIR/$IFACE.ctl"
+
+ start-stop-daemon --start --quiet --pidfile $PIDFILE \
+ --chuid $USER \
+ --exec $SLIRPVDE -- \
+ -s $CTLDIR -m 660 -p $PIDFILE -d "$@"
+fi
diff --git a/repo/vde2/vde2.xibuild b/repo/vde2/vde2.xibuild
new file mode 100644
index 0000000..6809cc4
--- /dev/null
+++ b/repo/vde2/vde2.xibuild
@@ -0,0 +1,41 @@
+#!/bin/sh
+
+NAME="vde2"
+DESC="VDE: Virtual Distributed Ethernet. User mode networking for QEMU, UML, etc."
+
+MAKEDEPS="linux-headers openssl libpcap python"
+
+PKG_VER=2.3.2
+SOURCE="https://downloads.sourceforge.net/project/vde/vde2/$PKG_VER/vde2-$PKG_VER.tar.gz"
+
+ADDITIONAL="
+inline.patch
+musl-build-fix.patch
+vde2.post-down
+vde2.pre-install
+vde2.pre-up
+vde_cryptcab-compile-against-openssl-1.1.0.patch
+"
+
+prepare() {
+ apply_patches
+}
+
+build() {
+ ./configure \
+ --prefix=/usr \
+ --sysconfdir=/etc
+ make -C src/common
+ make -j1 -C src/lib
+ make
+}
+
+package() {
+ cd "$BUILD_ROOT"
+ make -j1 DESTDIR="$PKG_DEST" install
+
+ install -Dm755 "$BUILD_ROOT"/vde2.pre-up \
+ "$PKG_DEST"/etc/network/if-pre-up.d/vde2
+ install -Dm755 "$BUILD_ROOT"/vde2.post-down \
+ "$PKG_DEST"/etc/network/if-post-down.d/vde2
+}
diff --git a/repo/vde2/vde_cryptcab-compile-against-openssl-1.1.0.patch b/repo/vde2/vde_cryptcab-compile-against-openssl-1.1.0.patch
new file mode 100644
index 0000000..227312e
--- /dev/null
+++ b/repo/vde2/vde_cryptcab-compile-against-openssl-1.1.0.patch
@@ -0,0 +1,92 @@
+--- a/src/vde_cryptcab/cryptcab.c 2011-11-23 16:41:17.000000000 +0000
++++ b/src/vde_cryptcab/cryptcab.c 2017-03-20 22:54:20.452975075 +0000
+@@ -22,7 +22,7 @@
+ exit(1);
+ }
+
+-static EVP_CIPHER_CTX ctx;
++static EVP_CIPHER_CTX *ctx;
+ static int ctx_initialized = 0;
+ static int encryption_disabled = 0;
+ static int nfd;
+@@ -30,6 +30,10 @@
+ static struct vde_open_args open_args={.port=0,.group=NULL,.mode=0700};
+ static int verbose = 0;
+
++#if OPENSSL_VERSION_NUMBER < 0x10100000
++#define EVP_CIPHER_CTX_reset(x) EVP_CIPHER_CTX_cleanup(x)
++#endif
++
+ void vc_printlog(int priority, const char *format, ...)
+ {
+ va_list arg;
+@@ -103,19 +107,21 @@
+ }
+
+ if (!ctx_initialized) {
+- EVP_CIPHER_CTX_init (&ctx);
++ ctx = EVP_CIPHER_CTX_new ();
++ if (!ctx)
++ return -1;
+ ctx_initialized = 1;
+ }
+
+- EVP_EncryptInit (&ctx, EVP_bf_cbc (), p->key, p->iv);
+- if (EVP_EncryptUpdate (&ctx, dst, &olen, src, len) != 1)
++ EVP_EncryptInit (ctx, EVP_bf_cbc (), p->key, p->iv);
++ if (EVP_EncryptUpdate (ctx, dst, &olen, src, len) != 1)
+ {
+ fprintf (stderr,"error in encrypt update\n");
+ olen = -1;
+ goto cleanup;
+ }
+
+- if (EVP_EncryptFinal (&ctx, dst + olen, &tlen) != 1)
++ if (EVP_EncryptFinal (ctx, dst + olen, &tlen) != 1)
+ {
+ fprintf (stderr,"error in encrypt final\n");
+ olen = -1;
+@@ -124,7 +130,7 @@
+ olen += tlen;
+
+ cleanup:
+- EVP_CIPHER_CTX_cleanup(&ctx);
++ EVP_CIPHER_CTX_reset(ctx);
+ return olen;
+ }
+
+@@ -138,19 +144,21 @@
+ }
+
+ if (!ctx_initialized) {
+- EVP_CIPHER_CTX_init (&ctx);
++ ctx = EVP_CIPHER_CTX_new ();
++ if (!ctx)
++ return -1;
+ ctx_initialized = 1;
+ }
+
+- EVP_DecryptInit (&ctx, EVP_bf_cbc (), p->key, p->iv);
+- if (EVP_DecryptUpdate (&ctx, dst, &olen, src, len) != 1)
++ EVP_DecryptInit (ctx, EVP_bf_cbc (), p->key, p->iv);
++ if (EVP_DecryptUpdate (ctx, dst, &olen, src, len) != 1)
+ {
+ fprintf (stderr,"error in decrypt update\n");
+ olen = -1;
+ goto cleanup;
+ }
+
+- if (EVP_DecryptFinal (&ctx, dst + olen, &tlen) != 1)
++ if (EVP_DecryptFinal (ctx, dst + olen, &tlen) != 1)
+ {
+ fprintf (stderr,"error in decrypt final\n");
+ olen = -1;
+@@ -159,7 +167,7 @@
+ olen += tlen;
+
+ cleanup:
+- EVP_CIPHER_CTX_cleanup(&ctx);
++ EVP_CIPHER_CTX_reset (ctx);
+ return olen;
+ }
+