summaryrefslogtreecommitdiffstats
path: root/meta-networking
diff options
context:
space:
mode:
authorYi Zhao <yi.zhao@windriver.com>2017-06-07 13:42:51 +0800
committerJoe MacDonald <joe_macdonald@mentor.com>2017-06-28 10:28:18 -0400
commitc4b9c4886a4a6f70870e4090d9a35b5c1f0d4b90 (patch)
treec08fca39876511bad890f01a0940b298dd61b6e6 /meta-networking
parent58e88534df2ae3bb16ca9e8ba85bea4db29f4899 (diff)
downloadmeta-openembedded-c4b9c4886a4a6f70870e4090d9a35b5c1f0d4b90.tar.gz
ippool: add new recipe
IpPool is a userspace daemon for managing one or more pools of IP addresses. It was developed as part of the OpenL2TP project but has since been repackaged so that it may be used independently of OpenL2TP. Signed-off-by: Yi Zhao <yi.zhao@windriver.com> Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com> Signed-off-by: Joe MacDonald <joe_macdonald@mentor.com>
Diffstat (limited to 'meta-networking')
-rw-r--r--meta-networking/recipes-daemons/ippool/ippool/always_syslog.patch22
-rw-r--r--meta-networking/recipes-daemons/ippool/ippool/ippool.service19
-rw-r--r--meta-networking/recipes-daemons/ippool/ippool/ippool_init.d.patch65
-rw-r--r--meta-networking/recipes-daemons/ippool/ippool/ippool_parallel_make_and_pic.patch89
-rw-r--r--meta-networking/recipes-daemons/ippool/ippool/ippool_usl_timer.patch49
-rw-r--r--meta-networking/recipes-daemons/ippool/ippool/makefile-add-ldflags.patch21
-rw-r--r--meta-networking/recipes-daemons/ippool/ippool/runtest.sh26
-rw-r--r--meta-networking/recipes-daemons/ippool/ippool_1.3.bb105
8 files changed, 396 insertions, 0 deletions
diff --git a/meta-networking/recipes-daemons/ippool/ippool/always_syslog.patch b/meta-networking/recipes-daemons/ippool/ippool/always_syslog.patch
new file mode 100644
index 000000000..e475276c0
--- /dev/null
+++ b/meta-networking/recipes-daemons/ippool/ippool/always_syslog.patch
@@ -0,0 +1,22 @@
1ippool: always log to syslog
2
3Even when running in the foreground, send log messages to syslog.
4
5Upstream-Status: Inappropriate [embedded specific]
6
7Signed-off-by: Joe Slater <jslater@windriver.com>
8
9
10--- a/ippool_main.c
11+++ b/ippool_main.c
12@@ -251,9 +251,8 @@ void ippool_vlog(int level, const char *
13 if (ippool_opt_nodaemon) {
14 vprintf(fmt, ap);
15 printf("\n");
16- } else {
17- vsyslog(level, fmt, ap);
18 }
19+ vsyslog(level, fmt, ap);
20 DMALLOC_VMESSAGE(fmt, ap);
21 }
22
diff --git a/meta-networking/recipes-daemons/ippool/ippool/ippool.service b/meta-networking/recipes-daemons/ippool/ippool/ippool.service
new file mode 100644
index 000000000..e5917fc14
--- /dev/null
+++ b/meta-networking/recipes-daemons/ippool/ippool/ippool.service
@@ -0,0 +1,19 @@
1[Unit]
2Description=ip address pool allocator
3Requires=rpcbind.service
4After=rpcbind.service
5
6[Service]
7Type=simple
8# Start ippoold in the foreground!
9ExecStart=@SBINDIR@/ippoold -f
10# Normal output will go to syslog, so suppress stdout.
11StandardOutput=null
12StandardError=syslog
13# ExecStop is not needed. systemd will send SIGTERM
14# and ippoold will exit status 1.
15SuccessExitStatus=1
16
17[Install]
18WantedBy=multi-user.target
19
diff --git a/meta-networking/recipes-daemons/ippool/ippool/ippool_init.d.patch b/meta-networking/recipes-daemons/ippool/ippool/ippool_init.d.patch
new file mode 100644
index 000000000..14a768d0f
--- /dev/null
+++ b/meta-networking/recipes-daemons/ippool/ippool/ippool_init.d.patch
@@ -0,0 +1,65 @@
1Fix start error if lsb init-functions doesn't exist
2
3Upstream-Status: Inappropriate [embedded specific]
4
5Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
6
7diff --git a/debian/init.d b/debian/init.d
8index 363ba89..0327fec 100644
9--- a/debian/init.d
10+++ b/debian/init.d
11@@ -10,6 +10,9 @@
12 # Description: Start ippool daemon
13 ### END INIT INFO
14
15+# Source function library.
16+. /etc/init.d/functions
17+
18 DAEMON=/usr/sbin/ippoold
19 NAME=ippoold
20 MODULE=pppol2tp
21@@ -18,7 +21,23 @@ MODULE=pppol2tp
22 test -x $DAEMON || exit 0
23
24 # Get lsb functions
25-. /lib/lsb/init-functions
26+if [ -f /lib/lsb/init-functions ]
27+then
28+ . /lib/lsb/init-functions
29+else
30+ log_begin_msg() {
31+ echo -n $*
32+ }
33+
34+ log_end_msg() {
35+ if [ $1 -eq 0 ]; then
36+ echo "done"
37+ else
38+ echo "failed"
39+ fi
40+ }
41+fi
42+
43 . /etc/default/rcS
44
45 case "$1" in
46@@ -35,6 +54,10 @@ case "$1" in
47 fi
48 log_end_msg $?
49 ;;
50+ status)
51+ status /usr/sbin/ippoold;
52+ exit $?
53+ ;;
54 restart)
55 $0 stop
56 sleep 1
57@@ -46,7 +69,7 @@ case "$1" in
58 log_end_msg $?
59 ;;
60 *)
61- log_success_msg "Usage: /etc/init.d/ippoold {start|stop|restart|reload|force-reload}"
62+ log_success_msg "Usage: /etc/init.d/ippoold {start|stop|status|restart|reload|force-reload}"
63 exit 1
64 esac
65
diff --git a/meta-networking/recipes-daemons/ippool/ippool/ippool_parallel_make_and_pic.patch b/meta-networking/recipes-daemons/ippool/ippool/ippool_parallel_make_and_pic.patch
new file mode 100644
index 000000000..1ebd95ea1
--- /dev/null
+++ b/meta-networking/recipes-daemons/ippool/ippool/ippool_parallel_make_and_pic.patch
@@ -0,0 +1,89 @@
11)add -fPIC for $(IPPOOL_RPC_STEM)_xdr.o, $(IPPOOL_RPC_STEM)_client.o
22)add sub target for subdirs-all, and those dependencies below
3 pppd plugin directory build depends on $(IPPOOL_RPC_STEM)_xdr.o
4$(IPPOOL_RPC_STEM)_client.o ippool_rpc.h
5
6 ippoold depends on libusl
7 ippoolconfig depends on libcli
8
9 $(IPPOOL_RPC_STEM)_xdr.o, $(IPPOOL_RPC_STEM)_client.o
10$(IPPOOL_RPC_STEM)_server.o *.o in main directory depends on ippool_rpc.h
11as those all directly or indirectly include ippool_rpc.h which is
12dynamically generated by rpcgen
13
14to make parallel make working.
153)include dependency files for pppd.
16
17Upstream-Status: Pending
18
19Signed-off-by: Yao Zhao <yao.zhao@windriver.com>
20---
21diff --git a/Makefile b/Makefile
22index 73aa72f..4f7af1d 100644
23--- a/Makefile
24+++ b/Makefile
25@@ -106,14 +106,14 @@ all: generated-files $(IPPOOL_RPC_STEM)_xdr.o $(IPPOOL_RPC_STEM)_client.o \
26 subdirs-all $(PROGS.sbin) $(PROGS.bin)
27
28 # Compile without -Wall because rpcgen-generated code is full of warnings
29-$(IPPOOL_RPC_STEM)_xdr.o: $(IPPOOL_RPC_STEM)_xdr.c
30- $(CC) -I. -MMD -g -c -w $(CPPFLAGS) $(CFLAGS.optimize) $<
31+$(IPPOOL_RPC_STEM)_xdr.o: $(IPPOOL_RPC_STEM)_xdr.c $(IPPOOL_RPC_STEM).h
32+ $(CC) -I. -MMD -g -c -w $(CPPFLAGS) $(CFLAGS.optimize) $< -fPIC
33
34-$(IPPOOL_RPC_STEM)_client.o: $(IPPOOL_RPC_STEM)_client.c
35- $(CC) -I. -MMD -g -c -w $(CPPFLAGS) $(CFLAGS.optimize) $<
36+$(IPPOOL_RPC_STEM)_client.o: $(IPPOOL_RPC_STEM)_client.c $(IPPOOL_RPC_STEM).h
37+ $(CC) -I. -MMD -g -c -w $(CPPFLAGS) $(CFLAGS.optimize) $< -fPIC
38
39-$(IPPOOL_RPC_STEM)_server.o: $(IPPOOL_RPC_STEM)_server.c
40- $(CC) -I. -MMD -g -c -w $(CPPFLAGS) $(CFLAGS.optimize) $<
41+$(IPPOOL_RPC_STEM)_server.o: $(IPPOOL_RPC_STEM)_server.c $(IPPOOL_RPC_STEM).h
42+ $(CC) -I. -MMD -g -c -w $(CPPFLAGS) $(CFLAGS.optimize) $< -fPIC
43
44 $(IPPOOL_RPC_STEM)_xdr.c: $(IPPOOL_RPC_STEM).x
45 -$(RM) $@
46@@ -136,8 +136,12 @@ $(IPPOOL_RPC_STEM).h: $(IPPOOL_RPC_STEM).x
47
48 generated-files: $(RPC_FILES)
49
50-subdirs-all:
51- @for d in $(SUBDIRS); do $(MAKE) -C $$d $(MFLAGS) EXTRA_CFLAGS="$(CPPFLAGS)" all; if [ $$? -ne 0 ]; then exit 1; fi; done
52+subdirs-all: $(patsubst %,%-dir, $(SUBDIRS))
53+
54+pppd-dir: $(IPPOOL_RPC_STEM)_xdr.o $(IPPOOL_RPC_STEM)_client.o $(IPPOOL_RPC_STEM).h
55+
56+$(patsubst %,%-dir,$(SUBDIRS)):
57+ @for d in $(patsubst %-dir,%,$@); do $(MAKE) -C $$d $(MFLAGS) EXTRA_CFLAGS="$(CPPFLAGS)" all; if [ $$? -ne 0 ]; then exit 1; fi; done
58
59 clean:
60 @for d in $(SUBDIRS); do $(MAKE) -C $$d $(MFLAGS) $@; if [ $$? -ne 0 ]; then exit 1; fi; done
61@@ -151,13 +155,13 @@ TAGS:
62 @for d in $(SUBDIRS); do $(MAKE) -C $$d $(MFLAGS) $@; done
63 etags -t $(wildcard *.c) $(wildcard *.h)
64
65-ippoold: $(IPPOOLD_SRCS.o)
66- $(CC) -o $@ $^ $(LDFLAGS.ippoold)
67+ippoold: $(IPPOOLD_SRCS.o) usl-dir
68+ $(CC) -o $@ $(IPPOOLD_SRCS.o) $(LDFLAGS.ippoold)
69
70-ippoolconfig: $(IPPOOLCONFIG_SRCS.o)
71- $(CC) -o $@ $^ $(LDFLAGS.ippoolconfig)
72+ippoolconfig: $(IPPOOLCONFIG_SRCS.o) cli-dir
73+ $(CC) -o $@ $(IPPOOLCONFIG_SRCS.o) $(LDFLAGS.ippoolconfig)
74
75-%.o: %.c
76+%.o: %.c $(IPPOOL_RPC_STEM).h
77 $(CC) -c $(CFLAGS) $< -o $@
78
79 install: all
80diff --git a/pppd/Makefile b/pppd/Makefile
81index 78d9b33..106deca 100644
82--- a/pppd/Makefile
83+++ b/pppd/Makefile
84@@ -24,3 +24,5 @@ install: ippool.so
85
86 clean:
87 -rm -rf *.o *.so
88+
89+include $(wildcard *.d /dev/null)
diff --git a/meta-networking/recipes-daemons/ippool/ippool/ippool_usl_timer.patch b/meta-networking/recipes-daemons/ippool/ippool/ippool_usl_timer.patch
new file mode 100644
index 000000000..ca0e3320c
--- /dev/null
+++ b/meta-networking/recipes-daemons/ippool/ippool/ippool_usl_timer.patch
@@ -0,0 +1,49 @@
1include limits.h to avoid UINT_MAX undefined compiling error.
2remove the unused assign which caused compiling error with -Werror.
3
4Upstream-Status: Pending
5
6Signed-off-by: Yao Zhao <yao.zhao@windriver.com>
7---
8
9diff --git a/usl/usl_timer.c b/usl/usl_timer.c
10index 734b820..fda752b 100644
11--- a/usl/usl_timer.c
12+++ b/usl/usl_timer.c
13@@ -42,6 +42,7 @@
14 #include <signal.h>
15 #include <string.h>
16 #include <sys/time.h>
17+#include <limits.h>
18
19 #include "usl.h"
20
21@@ -87,14 +88,13 @@ void (*usl_timer_tick_hook)(void);
22 */
23 void usl_timer_tick(void)
24 {
25- int result;
26 char msg = '\0';
27
28 usl_tick++;
29
30 if (!usl_tick_pending) {
31 usl_tick_pending = 1;
32- result = write(usl_tick_pipe[1], &msg, sizeof(msg));
33+ write(usl_tick_pipe[1], &msg, sizeof(msg));
34 }
35 }
36
37@@ -111,11 +111,10 @@ static void usl_timer_tick_handler(int fd, void *arg)
38 struct usl_ord_list_head *tmp;
39 struct usl_list_head *iwalk;
40 struct usl_list_head *itmp;
41- int result;
42 char msg;
43 USL_LIST_HEAD(expire_list);
44
45- result = usl_fd_read(usl_tick_pipe[0], &msg, sizeof(msg));
46+ usl_fd_read(usl_tick_pipe[0], &msg, sizeof(msg));
47 usl_tick_pending = 0;
48
49 usl_list_for_each(walk, tmp, &usl_timer_list) {
diff --git a/meta-networking/recipes-daemons/ippool/ippool/makefile-add-ldflags.patch b/meta-networking/recipes-daemons/ippool/ippool/makefile-add-ldflags.patch
new file mode 100644
index 000000000..7d5b715ae
--- /dev/null
+++ b/meta-networking/recipes-daemons/ippool/ippool/makefile-add-ldflags.patch
@@ -0,0 +1,21 @@
1Add LDFLAGS variable to Makefile so that extra linker flags can be sent via this variable.
2
3Upstream-Status: Pending
4
5Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
6
7diff --git a/Makefile b/Makefile
8index 4f7af1d..a05a000 100644
9--- a/Makefile
10+++ b/Makefile
11@@ -83,8 +83,8 @@ endif
12
13 CPPFLAGS= $(CPPFLAGS.ippooltest)
14 CFLAGS= -I. -Iusl -Icli -MMD -Wall -g $(CPPFLAGS) $(CPPFLAGS.dmalloc)
15-LDFLAGS.ippoold= -Wl,-E -L. -Lusl -lusl -lnsl -ldl $(LIBS.dmalloc) -lc
16-LDFLAGS.ippoolconfig= -Lcli -lcli -lreadline -lcurses -lnsl $(LIBS.dmalloc) -lc
17+LDFLAGS.ippoold= $(LDFLAGS) -Wl,-E -L. -Lusl -lusl -lnsl -ldl $(LIBS.dmalloc) -lc
18+LDFLAGS.ippoolconfig= $(LDFLAGS) -Lcli -lcli -lreadline -lcurses -lnsl $(LIBS.dmalloc) -lc
19
20 OPT_CFLAGS?= -O
21
diff --git a/meta-networking/recipes-daemons/ippool/ippool/runtest.sh b/meta-networking/recipes-daemons/ippool/ippool/runtest.sh
new file mode 100644
index 000000000..f91f58237
--- /dev/null
+++ b/meta-networking/recipes-daemons/ippool/ippool/runtest.sh
@@ -0,0 +1,26 @@
1#!/bin/sh
2BANNER="----------------------------------------------------------------------------"
3TCLSH="tclsh all.tcl -preservecore 3 -verbose bps -tmpdir ./results -outfile test-ippool.result"
4
5test_setup() {
6 if [ -d ./results ]; then rm -fr ./results; fi
7 mkdir ./results
8}
9
10test_ippool() {
11 echo "${BANNER}"
12 eval $TCLSH -constraints "ipPool"
13}
14test_postprocess() {
15 echo "${BANNER}"
16 (failed=`grep FAILED results/*.result | wc -l`; \
17 let failed2=failed/2 ;\
18 passed=`grep PASSED results/*.result | wc -l`; \
19 echo "TEST SUMMARY: $passed tests PASSED, $failed2 tests FAILED" ;\
20 exit $failed2)
21}
22
23test_setup
24test_ippool
25test_postprocess
26
diff --git a/meta-networking/recipes-daemons/ippool/ippool_1.3.bb b/meta-networking/recipes-daemons/ippool/ippool_1.3.bb
new file mode 100644
index 000000000..969f434cc
--- /dev/null
+++ b/meta-networking/recipes-daemons/ippool/ippool_1.3.bb
@@ -0,0 +1,105 @@
1SUMMARY = "An IP address pool manager"
2DESCRIPTION = "IpPool is implemented as a separate server daemon \
3to allow any application to use its address pools. This makes it possible \
4to define address pools that are shared by PPP, L2TP, PPTP etc. It may be \
5useful in some VPN server setups. IpPool comes with a command line \
6management application, ippoolconfig to manage and query address pool \
7status. A pppd plugin is supplied which allows pppd to request IP \
8addresses from ippoold. \
9"
10HOMEPAGE = "http://www.openl2tp.org/"
11SECTION = "console/network"
12LICENSE = "GPLv2+"
13
14SRC_URI = "\
15 https://sourceforge.net/projects/openl2tp/files/${BPN}/${PV}/${BPN}-${PV}.tar.gz \
16 file://ippool_usl_timer.patch \
17 file://ippool_parallel_make_and_pic.patch \
18 file://ippool_init.d.patch \
19 file://always_syslog.patch \
20 file://makefile-add-ldflags.patch \
21 file://runtest.sh \
22 file://ippool.service \
23 "
24
25LIC_FILES_CHKSUM = "file://LICENSE;md5=4c59283b82fc2b166455e0fc23c71c6f"
26SRC_URI[md5sum] = "e2401e65db26a3764585b97212888fae"
27SRC_URI[sha256sum] = "d3eab7d6cad5da8ccc9d1e31d5303e27a39622c07bdb8fa3618eea314412075b"
28
29inherit systemd
30
31DEPENDS = "readline ppp ncurses gzip-native"
32RDEPENDS_${PN} = "rpcbind"
33
34EXTRA_OEMAKE = "CC='${CC}' AS='${AS}' LD='${LD}' AR='${AR}' NM='${NM}' STRIP='${STRIP}'"
35EXTRA_OEMAKE += "PPPD_VERSION=${PPPD_VERSION} SYS_LIBDIR=${libdir}"
36# enable self tests
37EXTRA_OEMAKE += "IPPOOL_TEST=y"
38
39
40SYSTEMD_SERVICE_${PN} = "ippool.service"
41SYSTEMD_AUTO_ENABLE = "disable"
42
43
44do_compile_prepend() {
45 # fix the CFLAGS= and CPPFLAGS= in main Makefile, to have the extra CFLAGS in env
46 sed -i -e "s/^CFLAGS=/CFLAGS+=/" ${S}/Makefile
47 sed -i -e "s/^CPPFLAGS=/CPPFLAGS+=/" ${S}/Makefile
48
49 sed -i -e "s:-I/usr/include/pppd:-I=/usr/include/pppd:" ${S}/pppd/Makefile
50
51 # ignore the OPT_CFLAGS?= in Makefile,
52 # it should be in CFLAGS from env
53 export OPT_CFLAGS=
54}
55
56
57do_install() {
58 oe_runmake DESTDIR=${D} install
59
60 install -D -m 0755 ${S}/debian/init.d ${D}${sysconfdir}/init.d/ippoold
61 install -D -m 0644 ${WORKDIR}/ippool.service ${D}${systemd_system_unitdir}/ippool.service
62 sed -i -e 's:@SBINDIR@:${sbindir}:g' ${D}${systemd_system_unitdir}/ippool.service
63
64 # install self test
65 install -d ${D}/opt/${BPN}
66 install ${S}/test/all.tcl ${S}/test/ippool.test \
67 ${S}/test/test_procs.tcl ${D}/opt/${BPN}
68 install ${WORKDIR}/runtest.sh ${D}/opt/${BPN}
69 # fix the ../ippoolconfig in test_procs.tcl
70 sed -i -e "s:../ippoolconfig:ippoolconfig:" \
71 ${D}/opt/${BPN}/test_procs.tcl
72}
73
74
75PACKAGES =+ "${PN}-test"
76
77FILES_${PN} += "${libdir}/pppd/${PPPD_VERSION}/ippool.so"
78FILES_${PN}-dbg += "${libdir}/pppd/${PPPD_VERSION}/.debug/ippool.so"
79FILES_${PN}-test = "/opt/${BPN}"
80
81# needs tcl to run tests
82RDEPENDS_${PN}-test += "tcl ${BPN}"
83
84PPPD_VERSION="${@get_ppp_version(d)}"
85
86def get_ppp_version(d):
87 import re
88
89 pppd_plugin = d.expand('${STAGING_LIBDIR}/pppd')
90 if not os.path.isdir(pppd_plugin):
91 return None
92
93 bb.debug(1, "pppd plugin dir %s" % pppd_plugin)
94 r = re.compile("\d*\.\d*\.\d*")
95 for f in os.listdir(pppd_plugin):
96 if os.path.isdir(os.path.join(pppd_plugin, f)):
97 ma = r.match(f)
98 if ma:
99 bb.debug(1, "pppd version dir %s" % f)
100 return f
101 else:
102 bb.debug(1, "under pppd plugin dir %s" % f)
103
104 return None
105