Compare commits

..

15 commits

Author SHA1 Message Date
lagertonne
dd5f5d1024 drone: Add gitea releases
All checks were successful
continuous-integration/drone/push Build is passing
2022-01-01 15:36:13 +01:00
lagertonne
122ac098ab Debugging.
All checks were successful
continuous-integration/drone/push Build is passing
2022-01-01 11:39:07 +01:00
lagertonne
0a63ec863a debian: Do not run any tests
All checks were successful
continuous-integration/drone/push Build is passing
2022-01-01 11:30:27 +01:00
lagertonne
de12939f58 debian: Add kyua as build dependency for check
Some checks failed
continuous-integration/drone/push Build is failing
2022-01-01 11:15:55 +01:00
lagertonne
e54997251b debian: Build package without auto_build
Some checks failed
continuous-integration/drone/push Build is failing
2022-01-01 11:12:47 +01:00
lagertonne
e6fb603bf9 debian: Add needed env variables
Some checks failed
continuous-integration/drone/push Build is failing
2022-01-01 10:53:59 +01:00
lagertonne
8d6a744a91 drone: Fix build command
Some checks failed
continuous-integration/drone/push Build is failing
2022-01-01 10:32:41 +01:00
lagertonne
e4f92a48f0 drone: Install deps noninteractively
Some checks failed
continuous-integration/drone/push Build is failing
2022-01-01 10:29:38 +01:00
lagertonne
b81b059b43 drone: Install less packages and fix typo
Some checks failed
continuous-integration/drone/push Build is failing
2021-12-30 21:11:35 +01:00
lagertonne
a4761889e9 drone: Fix typo
Some checks failed
continuous-integration/drone/push Build is failing
2021-12-30 20:58:32 +01:00
lagertonne
cd11e6d1d7 drone: Fix automation
Some checks failed
continuous-integration/drone/push Build is failing
2021-12-30 20:57:36 +01:00
lagertonne
96ae8cced2 drone: Fix indetation
Some checks failed
continuous-integration/drone/push Build is failing
2021-12-30 20:55:54 +01:00
lagertonne
51813d88b1 drone: Add upgrade. 2021-12-30 20:52:44 +01:00
lagertonne
e3f066af12 Add basic automatic building 2021-12-30 20:50:35 +01:00
lagertonne
a96648cfd3 Add initial debian foo 2021-12-30 20:50:17 +01:00
40 changed files with 395 additions and 268 deletions

22
.drone.yml Normal file
View file

@ -0,0 +1,22 @@
kind: pipeline
name: default
steps:
- name: Build
image: debian:bullseye
commands:
- apt update
- apt -y upgrade
- apt -y install --no-install-recommends build-essential equivs devscripts
- mk-build-deps --install --tool='apt-get -o Debug::pkgProblemResolver=yes --no-install-recommends --yes' debian/control
- dpkg-buildpackage -b -uc
- find ..
- name: gitea_release
image: plugins/gitea-release
settings:
api_key:
from_secret: GITEA_KEY
base_url: https://git.neulandlabor.de/
files: ../ifupdown-ng_*_amd64.deb
when:
event: tag

View file

@ -1,5 +1,4 @@
Copyright (c) 2020-2021 Ariadne Conill <ariadne@dereferenced.org> Copyright (c) 2020 Ariadne Conill <ariadne@dereferenced.org>
Copyright (c) 2020-2021 Maximilian Wilhelm <max@sdn.clinic>
Permission to use, copy, modify, and/or distribute this software for any Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above purpose with or without fee is hereby granted, provided that the above

View file

@ -14,8 +14,7 @@ CONFIG_FILE := /etc/network/ifupdown-ng.conf
EXECUTOR_PATH := /usr/libexec/ifupdown-ng EXECUTOR_PATH := /usr/libexec/ifupdown-ng
CFLAGS ?= -ggdb3 -Os CFLAGS ?= -ggdb3 -Os
CFLAGS += -Wall -Wextra -Werror CFLAGS += -Wall -Wextra
CFLAGS += -Wmissing-declarations -Wmissing-prototypes -Wcast-align -Wpointer-arith -Wreturn-type
CFLAGS += ${LIBBSD_CFLAGS} CFLAGS += ${LIBBSD_CFLAGS}
CPPFLAGS = -I. CPPFLAGS = -I.
CPPFLAGS += -DINTERFACES_FILE=\"${INTERFACES_FILE}\" CPPFLAGS += -DINTERFACES_FILE=\"${INTERFACES_FILE}\"
@ -120,8 +119,6 @@ EXECUTOR_SCRIPTS ?= ${EXECUTOR_SCRIPTS_CORE} ${EXECUTOR_SCRIPTS_OPT}
EXECUTOR_SCRIPTS_STUB ?= EXECUTOR_SCRIPTS_STUB ?=
EXECUTOR_SCRIPTS_NATIVE ?=
TARGET_LIBS = ${LIBIFUPDOWN_LIB} TARGET_LIBS = ${LIBIFUPDOWN_LIB}
LIBS += ${TARGET_LIBS} ${LIBBSD_LIBS} LIBS += ${TARGET_LIBS} ${LIBBSD_LIBS}
@ -156,9 +153,6 @@ install: all
for i in ${EXECUTOR_SCRIPTS_STUB}; do \ for i in ${EXECUTOR_SCRIPTS_STUB}; do \
install -D -m755 executor-scripts/stub/$$i ${DESTDIR}${EXECUTOR_PATH}/$$i; \ install -D -m755 executor-scripts/stub/$$i ${DESTDIR}${EXECUTOR_PATH}/$$i; \
done done
for i in ${EXECUTOR_SCRIPTS_NATIVE}; do \
install -D -m755 executor-scripts/${LAYOUT}-native/$$i ${DESTDIR}${EXECUTOR_PATH}/$$i; \
done
install -D -m644 dist/ifupdown-ng.conf.example ${DESTDIR}${CONFIG_FILE}.example install -D -m644 dist/ifupdown-ng.conf.example ${DESTDIR}${CONFIG_FILE}.example
.scd.1 .scd.2 .scd.3 .scd.4 .scd.5 .scd.6 .scd.7 .scd.8: .scd.1 .scd.2 .scd.3 .scd.4 .scd.5 .scd.6 .scd.7 .scd.8:

View file

@ -39,7 +39,7 @@ On glibc systems, you must install `libbsd-dev` or equivalent and additionally d
make LIBBSD_CFLAGS="$(pkg-config --cflags libbsd-overlay)" LIBBSD_LIBS="$(pkg-config --cflags --libs libbsd-overlay)" make LIBBSD_CFLAGS="$(pkg-config --cflags libbsd-overlay)" LIBBSD_LIBS="$(pkg-config --cflags --libs libbsd-overlay)"
make install make install
To run the tests, do `make check`. Running the checks requires `kyua` (`apk add kyua` / `apt install kyua`). To run the tests, do `make check`. Running the checks requires `kyua` (`apk add kyua`, not packaged for Debian).
To build the documentation, do `make docs` and `make install_docs`. Building To build the documentation, do `make docs` and `make install_docs`. Building
the documentation requires scdoc (`apk add scdoc` / `apt install scdoc`). the documentation requires scdoc (`apk add scdoc` / `apt install scdoc`).

View file

@ -17,8 +17,7 @@
#include <limits.h> #include <limits.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "cmd/multicall.h" #include "multicall.h"
#include "cmd/ifctrstat-linux.h"
struct counter_desc { struct counter_desc {
const char *name; const char *name;
@ -42,7 +41,7 @@ counter_compare(const void *key, const void *candidate)
return strcasecmp((const char *)key, ((struct counter_desc *)candidate)->name); return strcasecmp((const char *)key, ((struct counter_desc *)candidate)->name);
} }
const char * char *
read_counter(const char *interface, const char *counter) read_counter(const char *interface, const char *counter)
{ {
FILE *fp; FILE *fp;

View file

@ -1,22 +0,0 @@
/*
* cmd/ifctrstat-linux.c
* Purpose: Implement ifctrstat system-specific routines for Linux
*
* Copyright (c) 2021 Maximilian Wilhelm <max@sdn.clinic>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* This software is provided 'as is' and without any warranty, express or
* implied. In no event shall the authors be liable for any damages arising
* from the use of this software.
*/
#ifndef IFUPDOWN_IFCTRSTAT_LINUX__H__GUARD
#define IFUPDOWN_IFCTRSTAT_LINUX__H__GUARD
extern const char * read_counter(const char *interface, const char *counter);
#endif

View file

@ -20,11 +20,12 @@
#include <string.h> #include <string.h>
#include "libifupdown/libifupdown.h" #include "libifupdown/libifupdown.h"
#include "cmd/multicall.h" #include "cmd/multicall.h"
#include "cmd/ifctrstat-linux.h"
extern struct counter_desc { const char *name; const void *data; } avail_counters[]; extern struct counter_desc { const char *name; const void *data; } avail_counters[];
extern int avail_counters_count; extern int avail_counters_count;
extern const char *read_counter(const char *interface, const char *counter);
static bool show_label = true; static bool show_label = true;
static bool static bool
@ -95,7 +96,7 @@ ifctrstat_set_nolabel(const char *opt_arg)
show_label = false; show_label = false;
} }
static int int
ifctrstat_main(int argc, char *argv[]) ifctrstat_main(int argc, char *argv[])
{ {
if (optind >= argc) if (optind >= argc)

View file

@ -131,7 +131,7 @@ pp_impl_cmp(const void *a, const void *b)
return strcmp(key, impl->name); return strcmp(key, impl->name);
} }
static int int
ifparse_main(int argc, char *argv[]) ifparse_main(int argc, char *argv[])
{ {
struct lif_dict state = {}; struct lif_dict state = {};

View file

@ -22,7 +22,7 @@
#include "cmd/multicall.h" #include "cmd/multicall.h"
#include "cmd/pretty-print-iface.h" #include "cmd/pretty-print-iface.h"
static void void
print_interface_dot(struct lif_dict *collection, struct lif_interface *iface, struct lif_interface *parent) print_interface_dot(struct lif_dict *collection, struct lif_interface *iface, struct lif_interface *parent)
{ {
if (!lif_lifecycle_query_dependents(&exec_opts, iface, iface->ifname)) if (!lif_lifecycle_query_dependents(&exec_opts, iface, iface->ifname))
@ -57,7 +57,7 @@ print_interface_dot(struct lif_dict *collection, struct lif_interface *iface, st
} }
} }
static void void
print_interface_property(struct lif_interface *iface, const char *property) print_interface_property(struct lif_interface *iface, const char *property)
{ {
struct lif_node *iter; struct lif_node *iter;
@ -83,7 +83,7 @@ print_interface_property(struct lif_interface *iface, const char *property)
} }
} }
static void void
list_interfaces(struct lif_dict *collection, struct match_options *opts) list_interfaces(struct lif_dict *collection, struct match_options *opts)
{ {
struct lif_node *iter; struct lif_node *iter;
@ -126,7 +126,7 @@ list_interfaces(struct lif_dict *collection, struct match_options *opts)
static bool listing = false, listing_stat = false, listing_running = false; static bool listing = false, listing_stat = false, listing_running = false;
static bool allow_undefined = false; static bool allow_undefined = false;
static void void
list_state(struct lif_dict *state, struct match_options *opts) list_state(struct lif_dict *state, struct match_options *opts)
{ {
struct lif_node *iter; struct lif_node *iter;
@ -217,7 +217,7 @@ static struct if_option_group local_option_group = {
.group = local_options .group = local_options
}; };
static int int
ifquery_main(int argc, char *argv[]) ifquery_main(int argc, char *argv[])
{ {
struct lif_dict state = {}; struct lif_dict state = {};

View file

@ -27,7 +27,7 @@
static bool up; static bool up;
static bool bool
is_ifdown() is_ifdown()
{ {
if (strstr(argv0, "ifdown") != NULL) if (strstr(argv0, "ifdown") != NULL)
@ -36,7 +36,7 @@ is_ifdown()
return false; return false;
} }
static int int
acquire_state_lock(const char *state_path, const char *lifname) acquire_state_lock(const char *state_path, const char *lifname)
{ {
if (exec_opts.mock || exec_opts.no_lock) if (exec_opts.mock || exec_opts.no_lock)
@ -94,7 +94,7 @@ acquire_state_lock(const char *state_path, const char *lifname)
return fd; return fd;
} }
static bool bool
skip_interface(struct lif_interface *iface, const char *ifname, struct lif_dict *state, bool update_state) skip_interface(struct lif_interface *iface, const char *ifname, struct lif_dict *state, bool update_state)
{ {
if (iface->is_template) if (iface->is_template)
@ -146,7 +146,7 @@ skip_interface(struct lif_interface *iface, const char *ifname, struct lif_dict
return false; return false;
} }
static bool bool
change_interface(struct lif_interface *iface, struct lif_dict *collection, struct lif_dict *state, const char *ifname, bool update_state) change_interface(struct lif_interface *iface, struct lif_dict *collection, struct lif_dict *state, const char *ifname, bool update_state)
{ {
int lockfd = acquire_state_lock(exec_opts.state_file, ifname); int lockfd = acquire_state_lock(exec_opts.state_file, ifname);
@ -194,7 +194,7 @@ change_interface(struct lif_interface *iface, struct lif_dict *collection, struc
return true; return true;
} }
static bool bool
change_auto_interfaces(struct lif_dict *collection, struct lif_dict *state, struct match_options *opts) change_auto_interfaces(struct lif_dict *collection, struct lif_dict *state, struct match_options *opts)
{ {
struct lif_node *iter; struct lif_node *iter;
@ -222,7 +222,7 @@ change_auto_interfaces(struct lif_dict *collection, struct lif_dict *state, stru
return true; return true;
} }
static int int
update_state_file_and_exit(int rc, struct lif_dict *state) update_state_file_and_exit(int rc, struct lif_dict *state)
{ {
if (exec_opts.mock) if (exec_opts.mock)
@ -243,7 +243,7 @@ update_state_file_and_exit(int rc, struct lif_dict *state)
return rc; return rc;
} }
static int int
ifupdown_main(int argc, char *argv[]) ifupdown_main(int argc, char *argv[])
{ {
up = !is_ifdown(); up = !is_ifdown();

View file

@ -21,13 +21,10 @@
#include <getopt.h> #include <getopt.h>
#include "cmd/multicall.h" #include "cmd/multicall.h"
#define DEFAULT_TIMEOUT 300
struct lif_execute_opts exec_opts = { struct lif_execute_opts exec_opts = {
.interfaces_file = INTERFACES_FILE, .interfaces_file = INTERFACES_FILE,
.executor_path = EXECUTOR_PATH, .executor_path = EXECUTOR_PATH,
.state_file = STATE_FILE, .state_file = STATE_FILE
.timeout = DEFAULT_TIMEOUT,
}; };
static void static void
@ -77,14 +74,6 @@ set_force(const char *opt_arg)
exec_opts.force = true; exec_opts.force = true;
} }
static void
set_timeout(const char *opt_arg)
{
exec_opts.timeout = atoi(opt_arg);
if (exec_opts.timeout < 0)
exec_opts.timeout = DEFAULT_TIMEOUT;
}
static struct if_option exec_options[] = { static struct if_option exec_options[] = {
{'f', "force", NULL, "force (de)configuration", false, set_force}, {'f', "force", NULL, "force (de)configuration", false, set_force},
{'i', "interfaces", "interfaces FILE", "use FILE for interface definitions", true, set_interfaces_file}, {'i', "interfaces", "interfaces FILE", "use FILE for interface definitions", true, set_interfaces_file},
@ -93,7 +82,6 @@ static struct if_option exec_options[] = {
{'v', "verbose", NULL, "show what commands are being run", false, set_verbose}, {'v', "verbose", NULL, "show what commands are being run", false, set_verbose},
{'E', "executor-path", "executor-path PATH", "use PATH for executor directory", true, set_executor_path}, {'E', "executor-path", "executor-path PATH", "use PATH for executor directory", true, set_executor_path},
{'S', "state-file", "state-file FILE", "use FILE for state", true, set_state_file}, {'S', "state-file", "state-file FILE", "use FILE for state", true, set_state_file},
{'T', "timeout", "timeout TIMEOUT", "wait TIMEOUT seconds for executors to complete", true, set_timeout},
}; };
struct if_option_group exec_option_group = { struct if_option_group exec_option_group = {

View file

@ -62,7 +62,7 @@ struct if_applet *applet_table[] = {
&ifupdown_applet, &ifupdown_applet,
}; };
static int int
applet_cmp(const void *a, const void *b) applet_cmp(const void *a, const void *b)
{ {
const char *key = a; const char *key = a;
@ -101,7 +101,7 @@ main(int argc, char *argv[])
return self_applet->main(argc, argv); return self_applet->main(argc, argv);
} }
static int int
multicall_main(int argc, char *argv[]) multicall_main(int argc, char *argv[])
{ {
if (argc < 2) if (argc < 2)

6
debian/README.Debian vendored Normal file
View file

@ -0,0 +1,6 @@
ifupdown-ng for Debian
---------------------
<possible notes regarding this package - if none, delete this file>
-- unknown <lagertonne@unknown> Thu, 30 Dec 2021 20:41:21 +0100

10
debian/README.source vendored Normal file
View file

@ -0,0 +1,10 @@
ifupdown-ng for Debian
---------------------
<this file describes information about the source package, see Debian policy
manual section 4.14. You WILL either need to modify or delete this file>
-- unknown <lagertonne@unknown> Thu, 30 Dec 2021 20:41:21 +0100

5
debian/changelog vendored Normal file
View file

@ -0,0 +1,5 @@
ifupdown-ng (0.11.3-1) UNRELEASED; urgency=medium
* Initial release (Closes: #nnnn) <nnnn is the bug number of your ITP>
-- unknown <lagertonne@unknown> Thu, 30 Dec 2021 20:41:21 +0100

16
debian/control vendored Normal file
View file

@ -0,0 +1,16 @@
Source: ifupdown-ng
Section: unknown
Priority: optional
Maintainer: unknown <lagertonne@unknown>
Build-Depends: debhelper-compat (= 13), libbsd0, libbsd-dev, pkg-config, kyua
Standards-Version: 4.6.0
Homepage: https://github.com/ifupdown-ng/ifupdown-ng
#Vcs-Browser: https://salsa.debian.org/debian/ifupdown-ng
#Vcs-Git: https://salsa.debian.org/debian/ifupdown-ng.git
Rules-Requires-Root: no
Package: ifupdown-ng
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}
Description:
ifupdown-ng is a network device manager that is largely compatible with Debian ifupdown, BusyBox ifupdown and Cumulus Networks' ifupdown2.

43
debian/copyright vendored Normal file
View file

@ -0,0 +1,43 @@
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: ifupdown-ng
Upstream-Contact: <preferred name and address to reach the upstream project>
Source: <url://example.com>
Files: *
Copyright: <years> <put author's name and email here>
<years> <likewise for another author>
License: <special license>
<Put the license of the package here indented by 1 space>
<This follows the format of Description: lines in control file>
.
<Including paragraphs>
# If you want to use GPL v2 or later for the /debian/* files use
# the following clauses, or change it to suit. Delete these two lines
Files: debian/*
Copyright: 2021 unknown <lagertonne@unknown>
License: GPL-2+
This package is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
.
This package is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>
.
On Debian systems, the complete text of the GNU General
Public License version 2 can be found in "/usr/share/common-licenses/GPL-2".
# Please also look if there are files or directories which have a
# different copyright/license attached and list them here.
# Please avoid picking licenses with terms that are more restrictive than the
# packaged work, as it may make Debian's contributions unacceptable upstream.
#
# If you need, there are some extra license texts available in two places:
# /usr/share/debhelper/dh_make/licenses/
# /usr/share/common-licenses/

39
debian/postinst.ex vendored Normal file
View file

@ -0,0 +1,39 @@
#!/bin/sh
# postinst script for ifupdown-ng
#
# see: dh_installdeb(1)
set -e
# summary of how this script can be called:
# * <postinst> `configure' <most-recently-configured-version>
# * <old-postinst> `abort-upgrade' <new version>
# * <conflictor's-postinst> `abort-remove' `in-favour' <package>
# <new-version>
# * <postinst> `abort-remove'
# * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
# <failed-install-package> <version> `removing'
# <conflicting-package> <version>
# for details, see https://www.debian.org/doc/debian-policy/ or
# the debian-policy package
case "$1" in
configure)
;;
abort-upgrade|abort-remove|abort-deconfigure)
;;
*)
echo "postinst called with unknown argument \`$1'" >&2
exit 1
;;
esac
# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.
#DEBHELPER#
exit 0

37
debian/postrm.ex vendored Normal file
View file

@ -0,0 +1,37 @@
#!/bin/sh
# postrm script for ifupdown-ng
#
# see: dh_installdeb(1)
set -e
# summary of how this script can be called:
# * <postrm> `remove'
# * <postrm> `purge'
# * <old-postrm> `upgrade' <new-version>
# * <new-postrm> `failed-upgrade' <old-version>
# * <new-postrm> `abort-install'
# * <new-postrm> `abort-install' <old-version>
# * <new-postrm> `abort-upgrade' <old-version>
# * <disappearer's-postrm> `disappear' <overwriter>
# <overwriter-version>
# for details, see https://www.debian.org/doc/debian-policy/ or
# the debian-policy package
case "$1" in
purge|remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
;;
*)
echo "postrm called with unknown argument \`$1'" >&2
exit 1
;;
esac
# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.
#DEBHELPER#
exit 0

35
debian/preinst.ex vendored Normal file
View file

@ -0,0 +1,35 @@
#!/bin/sh
# preinst script for ifupdown-ng
#
# see: dh_installdeb(1)
set -e
# summary of how this script can be called:
# * <new-preinst> `install'
# * <new-preinst> `install' <old-version>
# * <new-preinst> `upgrade' <old-version>
# * <old-preinst> `abort-upgrade' <new-version>
# for details, see https://www.debian.org/doc/debian-policy/ or
# the debian-policy package
case "$1" in
install|upgrade)
;;
abort-upgrade)
;;
*)
echo "preinst called with unknown argument \`$1'" >&2
exit 1
;;
esac
# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.
#DEBHELPER#
exit 0

38
debian/prerm.ex vendored Normal file
View file

@ -0,0 +1,38 @@
#!/bin/sh
# prerm script for ifupdown-ng
#
# see: dh_installdeb(1)
set -e
# summary of how this script can be called:
# * <prerm> `remove'
# * <old-prerm> `upgrade' <new-version>
# * <new-prerm> `failed-upgrade' <old-version>
# * <conflictor's-prerm> `remove' `in-favour' <package> <new-version>
# * <deconfigured's-prerm> `deconfigure' `in-favour'
# <package-being-installed> <version> `removing'
# <conflicting-package> <version>
# for details, see https://www.debian.org/doc/debian-policy/ or
# the debian-policy package
case "$1" in
remove|upgrade|deconfigure)
;;
failed-upgrade)
;;
*)
echo "prerm called with unknown argument \`$1'" >&2
exit 1
;;
esac
# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.
#DEBHELPER#
exit 0

31
debian/rules vendored Executable file
View file

@ -0,0 +1,31 @@
#!/usr/bin/make -f
# See debhelper(7) (uncomment to enable)
# output every command that modifies files on the build system.
#export DH_VERBOSE = 1
# see FEATURE AREAS in dpkg-buildflags(1)
#export DEB_BUILD_MAINT_OPTIONS = hardening=+all
# see ENVIRONMENT in dpkg-buildflags(1)
# package maintainers to append CFLAGS
#export DEB_CFLAGS_MAINT_APPEND = -Wall -pedantic
# package maintainers to append LDFLAGS
#export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed
%:
dh $@
override_dh_auto_build:
make \
LIBBSD_CFLAGS="-isystem /usr/include/bsd -DLIBBSD_OVERLAY -lbsd " \
LIBBSD_LIBS="-isystem /usr/include/bsd -DLIBBSD_OVERLAY -lbsd "
override_dh_auto_test:
# dh_make generated override targets
# This is example for Cmake (See https://bugs.debian.org/641051 )
#override_dh_auto_configure:
# dh_auto_configure -- \
# -DCMAKE_LIBRARY_PATH=$(DEB_HOST_MULTIARCH)

11
debian/salsa-ci.yml.ex vendored Normal file
View file

@ -0,0 +1,11 @@
# For more information on what jobs are run see:
# https://salsa.debian.org/salsa-ci-team/pipeline
#
# To enable the jobs, go to your repository (at salsa.debian.org)
# and click over Settings > CI/CD > Expand (in General pipelines).
# In "CI/CD configuration file" write debian/salsa-ci.yml and click
# in "Save Changes". The CI tests will run after the next commit.
---
include:
- https://salsa.debian.org/salsa-ci-team/pipeline/raw/master/salsa-ci.yml
- https://salsa.debian.org/salsa-ci-team/pipeline/raw/master/pipeline-jobs.yml

1
debian/source/format vendored Normal file
View file

@ -0,0 +1 @@
3.0 (quilt)

38
debian/watch.ex vendored Normal file
View file

@ -0,0 +1,38 @@
# Example watch control file for uscan
# Rename this file to "watch" and then you can run the "uscan" command
# to check for upstream updates and more.
# See uscan(1) for format
# Compulsory line, this is a version 4 file
version=4
# PGP signature mangle, so foo.tar.gz has foo.tar.gz.sig
#opts="pgpsigurlmangle=s%$%.sig%"
# HTTP site (basic)
#http://example.com/downloads.html \
# files/ifupdown-ng-([\d\.]+)\.tar\.gz debian uupdate
# Uncomment to examine an FTP server
#ftp://ftp.example.com/pub/ifupdown-ng-(.*)\.tar\.gz debian uupdate
# SourceForge hosted projects
# http://sf.net/ifupdown-ng/ ifupdown-ng-(.*)\.tar\.gz debian uupdate
# GitHub hosted projects
#opts="filenamemangle=s%(?:.*?)?v?(\d[\d.]*)\.tar\.gz%<project>-$1.tar.gz%" \
# https://github.com/<user>/ifupdown-ng/tags \
# (?:.*?/)?v?(\d[\d.]*)\.tar\.gz debian uupdate
# PyPI
# https://pypi.debian.net/ifupdown-ng/ifupdown-ng-(.+)\.(?:zip|tgz|tbz|txz|(?:tar\.(?:gz|bz2|xz)))
# Direct Git
# opts="mode=git" http://git.example.com/ifupdown-ng.git \
# refs/tags/v([\d\.]+) debian uupdate
# Uncomment to find new files on GooglePages
# http://example.googlepages.com/foo.html ifupdown-ng-(.*)\.tar\.gz

View file

@ -45,10 +45,6 @@ configured in the configuration database.
*-S, --state-file* _FILE_ *-S, --state-file* _FILE_
Use _FILE_ as the state database. Use _FILE_ as the state database.
*-T, --timeout* _TIMEOUT_
Wait up to _TIMEOUT_ seconds for executors to complete before
raising an error.
*-V, --version* *-V, --version*
Print the ifupdown-ng version and exit. Print the ifupdown-ng version and exit.

View file

@ -43,10 +43,6 @@ stanzas between different formats.
*-S, --state-file* _FILE_ *-S, --state-file* _FILE_
Use _FILE_ as the state database. Use _FILE_ as the state database.
*-T, --timeout* _TIMEOUT_
Wait up to _TIMEOUT_ seconds for executors to complete before
raising an error.
*-V, --version* *-V, --version*
Print the ifupdown-ng version and exit. Print the ifupdown-ng version and exit.

View file

@ -62,10 +62,6 @@ configuration file to the current format.
*-S, --state-file* _FILE_ *-S, --state-file* _FILE_
Use _FILE_ as the state database. Use _FILE_ as the state database.
*-T, --timeout* _TIMEOUT_
Wait up to _TIMEOUT_ seconds for executors to complete before
raising an error.
*-V, --version* *-V, --version*
Print the ifupdown-ng version and exit. Print the ifupdown-ng version and exit.

View file

@ -48,10 +48,6 @@ configured in the configuration database.
*-S, --state-file* _FILE_ *-S, --state-file* _FILE_
Use _FILE_ as the state database. Use _FILE_ as the state database.
*-T, --timeout* _TIMEOUT_
Wait up to _TIMEOUT_ seconds for executors to complete before
raising an error.
*-V, --version* *-V, --version*
Print the ifupdown-ng version and exit. Print the ifupdown-ng version and exit.

View file

@ -32,33 +32,26 @@ other options are optional.
*vxlan-physdev* _interface_ *vxlan-physdev* _interface_
Specifies the physical ("underlay") device to use for tunnel Specifies the physical ("underlay") device to use for tunnel
endpoint communication. This is required for setups using endpoint communication.
multicast.
*vxlan-local-ip* _address_ *vxlan-local-ip* _address_
Specifies the source IP address to use in outgoing packets. Specifies the source IP address to use in outgoing packets.
For compatiblity with ifupdown2 _vxlan-local-tunnelip_ is an For compatiblity with ifupdown2 _vxlan-local-tunnelip_ is an
alias for this parameter. alias for this parameter.
*vxlan-peer-ips* _list of IP addresses_ *vxlan-remote-ip* _address_
Specifies the unicast destination IP address(es) to use in outgoing Specifies the unicast destination IP address to use in outgoing
packets when the destination link layer address is not known in packets when the destination link layer address is not known in
the VXLAN device forwarding database. This option can be used to the VXLAN device forwarding database. This parameter cannot be
form Point-to-Point as well as Point-to-Multipoint VXLAN tunnels/ specified with the _vxlan-remote-group_ parameter.
overlays depending on how many peer IPs are given. If more than one For compatiblity with ifupdown2 _vxlan-remoteip_ is an alias for
IP address is given a Point-to-Multipoint overlay is being set up this parameter.
and ingress / head-end replication will be used by the Linux Kernel.
This option cannot be used together with _vxlan-peer-group_ option.
For compatiblity with ifupdown2 _vxlan-remoteip_ is an alias for this option
and for compatibility with previos versions of ifupdown-ng _vxlan-remote-ip_
is an alias for this option, too.
*vxlan-peer-group* _multicast group_ *vxlan-remote-group* _multicast group_
Specifies the multicast group address to join, requires _vxlan-phsydev_ Specifies the multicast group IP address to join. This parameter
to be set as well. This parameter cannot be specified in combination cannot be specified with the _vxlan-remote-ip_ parameter.
with the _vxlan-peer-ips_ parameter. For compatibility with ifupdown2 For compatibility with ifupdown2 _vxlan-svcnodeip_ is an alias for
_vxlan-svcnodeip_ is an alias for this option and for compatibility this parameter.
with previos version of ifupdown-ng _vxlan-remote-group_ is an alias, too.
*vxlan-learning* _on/off_ *vxlan-learning* _on/off_
Specifies if unknown source link layer addresses and IP addresses Specifies if unknown source link layer addresses and IP addresses
@ -86,46 +79,22 @@ iface vx_v1001_padcty
mtu 1560 mtu 1560
``` ```
The same works just fine with IPv6 in the underlay:
```
auto vx_v1400_padcty
iface vx_v1400_padcty
vxlan-id 917505
vxlan-physdev vlan1400
vxlan-peer-group ff42:1400::1
#
hwaddress f2:00:0d:01:14:00
mtu 1560
```
Note that the underlay must have an MTU of at least 1610 to Note that the underlay must have an MTU of at least 1610 to
carry the encapsulated packets of the two VTEPs above. carry the encapsulated packets.
A VTEP with one peer (unicast point-to-point configuration): A VTEP with one peer (point-to-point configuration):
``` ```
auto vx_ptp1 auto vx_ptp1
iface vx_ptp1 iface vx_ptp1
vxlan-id 2342 vxlan-id 2342
vxlan-local-ip 192.0.2.42 vxlan-local-ip 192.0.2.42
vxlan-peer-ips 198.51.100.23 vxlan-remote-ip 198.51.100.23
# #
hwaddress f2:00:c1:01:10:01 hwaddress f2:00:c1:01:10:01
``` ```
A VTEP with multiple peers (unicast point-to-multipoint with ingress / head-end replication):
```
auto vx_her
iface vx_her
vxlan-id 1337
vxlan-local-ip 2001:db8:1::1
vxlan-peer-ips 2001:db8:2::23 2001:db8:3::42 2001:db8:4::84
```
# AUTHORS # AUTHORS
Maximilian Wilhelm <max@sdn.clinic> Maximilian Wilhelm <max@sdn.clinic>

View file

@ -18,15 +18,6 @@ allow to set up Wireguard VPN tunnels.
used. In the latter case _use wireguard_ has to be explicitly used. In the latter case _use wireguard_ has to be explicitly
set to the interface configuration. set to the interface configuration.
Be aware that the given configuration file will be loaded using
*wg setconf* and not with *wg-quick*. The file format for both
tools isn't compatible so you have to make sure you provide a
valid configuration file for the *wg* tool. If you already have
a configuration file for *wg-quick* you can set up the tunnel
manually once and then dump the configuration using *wg showconf*
and save this to _path_.
# EXAMPLES # EXAMPLES
A Wireguard VPN tunnel with explicit configuration file specified A Wireguard VPN tunnel with explicit configuration file specified

View file

@ -10,8 +10,8 @@
# IF_VXLAN_ID The VXLAN Network Identifier (VNI) # IF_VXLAN_ID The VXLAN Network Identifier (VNI)
# IF_VXLAN_PHYSDEV Specifies the physical device to use for tunnel endpoint communication # IF_VXLAN_PHYSDEV Specifies the physical device to use for tunnel endpoint communication
# IF_VXLAN_LOCAL_IP Specifies the source IP address to use in outgoing packets # IF_VXLAN_LOCAL_IP Specifies the source IP address to use in outgoing packets
# IF_VXLAN_PEER_IPS Space separated list of IPs of the remote VTEP endpoint (for ptp/ptmp mode with ingress replication) # IF_VXLAN_REMOTE_IP IP of the remote VTEP endpoint (for ptp mode)
# IF_VXLAN_PEER_GROUP Multicast group to use for this VNI (for ptmp mode with multicast) # IF_VXLAN_REMOTE_GROUP Multicast group to use for this VNI (for ptmp mode)
# IF_VXLAN_LEARNING Wether to activate MAC learning on this instance (on/off) # IF_VXLAN_LEARNING Wether to activate MAC learning on this instance (on/off)
# IF_VXLAN_AGEING Specifies the lifetime in seconds of FDB entries learnt by the kernel # IF_VXLAN_AGEING Specifies the lifetime in seconds of FDB entries learnt by the kernel
# IF_VXLAN_DSTPORT UDP destination port to communicate to the remote VXLAN tunnel endpoint (default 4789) # IF_VXLAN_DSTPORT UDP destination port to communicate to the remote VXLAN tunnel endpoint (default 4789)
@ -36,27 +36,17 @@ case "$PHASE" in
fi fi
# Input validation # Input validation
if [ "${IF_VXLAN_PEER_IPS}" -a "${IF_VXLAN_PEER_GROUP}" ]; then if [ "${IF_VXLAN_REMOTE_IP}" -a "${IF_VXLAN_REMOTE_GROUP}" ]; then
echo "Error on ${IFACE} (vxlan): Only one of 'vxlan-peer-ips' and 'vxlan-peer-group' can be used!" >&2 echo "Error on ${IFACE} (vxlan): Only one of 'remote' and 'group' can be given!" >&2
exit 1 exit 1
fi fi
# Check if we should operate in unicast ptp or ptmp mode
if [ "${IF_VXLAN_PEER_IPS}" ]; then
# If it's only one thing which looks like an IPv4/IPv6 address we assume it's ptp
if echo "${IF_VXLAN_PEER_IPS}" | grep -q '^[[:space:]]*[[:xdigit:].:]\+[[:space:]]*$'; then
UCAST_MODE="ptp"
else
UCAST_MODE="ptmp"
fi
fi
# Gather arguments # Gather arguments
ARGS="" ARGS=""
[ "${IF_VXLAN_PHYSDEV}" ] && ARGS="${ARGS} dev ${IF_VXLAN_PHYSDEV}" [ "${IF_VXLAN_PHYSDEV}" ] && ARGS="${ARGS} dev ${IF_VXLAN_PHYSDEV}"
[ "${IF_VXLAN_LOCAL_IP}" ] && ARGS="${ARGS} local ${IF_VXLAN_LOCAL_IP}" [ "${IF_VXLAN_LOCAL_IP}" ] && ARGS="${ARGS} local ${IF_VXLAN_LOCAL_IP}"
[ "${UCAST_MODE}" = "ptp" ] && ARGS="${ARGS} remote ${IF_VXLAN_PEER_IPS}" [ "${IF_VXLAN_REMOTE_IP}" ] && ARGS="${ARGS} remote ${IF_VXLAN_REMOTE_IP}"
[ "${IF_VXLAN_PEER_GROUP}" ] && ARGS="${ARGS} group ${IF_VXLAN_PEER_GROUP}" [ "${IF_VXLAN_REMOTE_GROUP}" ] && ARGS="${ARGS} group ${IF_VXLAN_REMOTE_GROUP}"
[ "${IF_VXLAN_AGEING}" ] && ARGS="${ARGS} ageing ${IF_VXLAN_AGEING}" [ "${IF_VXLAN_AGEING}" ] && ARGS="${ARGS} ageing ${IF_VXLAN_AGEING}"
# Linux uses non-standard default port - WTF? # Linux uses non-standard default port - WTF?
@ -77,13 +67,6 @@ case "$PHASE" in
esac esac
${MOCK} ip link add "${IFACE}" type vxlan id "${IF_VXLAN_ID}" ${ARGS} ${MOCK} ip link add "${IFACE}" type vxlan id "${IF_VXLAN_ID}" ${ARGS}
# Set up FDB entries for peer VTEPs
if [ "${UCAST_MODE}" = "ptmp" ]; then
for peer in ${IF_VXLAN_PEER_IPS}; do
${MOCK} bridge fdb append 00:00:00:00:00:00 dev "${IFACE}" dst "${peer}" self permanent
done
fi
;; ;;
destroy) destroy)

View file

@ -79,7 +79,7 @@ stop_wpa_supplicant() {
[ -z "$IF_WIFI_CONFIG_PATH" ] && rm -- "$WIFI_CONFIG_PATH" [ -z "$IF_WIFI_CONFIG_PATH" ] && rm -- "$WIFI_CONFIG_PATH"
# If there is no PIDFILE, there is nothing we can do # If there is no PIDFILE, there is nothing we can do
[ ! -f "$PIDFILE" ] && return [ ! -d "$PIDFILE" ] && return
pid=$(cat "$PIDFILE") pid=$(cat "$PIDFILE")
rm -- "$PIDFILE" rm -- "$PIDFILE"

View file

@ -16,7 +16,6 @@
#include <stdbool.h> #include <stdbool.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "libifupdown/compat.h"
#include "libifupdown/config-file.h" #include "libifupdown/config-file.h"
#include "libifupdown/dict.h" #include "libifupdown/dict.h"
#include "libifupdown/interface.h" #include "libifupdown/interface.h"
@ -103,7 +102,7 @@ compat_ifupdown2_bridge_ports_inherit_vlans(struct lif_dict *collection)
return true; return true;
} }
bool extern bool
lif_compat_apply(struct lif_dict *collection) lif_compat_apply(struct lif_dict *collection)
{ {
if (lif_config.compat_ifupdown2_bridge_ports_inherit_vlans && if (lif_config.compat_ifupdown2_bridge_ports_inherit_vlans &&

View file

@ -17,7 +17,6 @@
#define LIBIFUPDOWN__COMPAT_H #define LIBIFUPDOWN__COMPAT_H
#include "libifupdown/config-file.h" #include "libifupdown/config-file.h"
#include "libifupdown/dict.h"
extern bool lif_compat_apply (struct lif_dict *collection); extern bool lif_compat_apply (struct lif_dict *collection);

View file

@ -30,86 +30,6 @@
#define SHELL "/bin/sh" #define SHELL "/bin/sh"
#if defined(__linux__)
# include <sys/syscall.h>
#endif
/* POSIX compatible fallback using waitpid(2) and usleep(3) */
static inline bool
lif_process_monitor_busyloop(pid_t child, int timeout_sec, int *status)
{
int ticks = 0;
while (ticks < timeout_sec * 20)
{
/* Ugly hack: most executors finish very quickly,
* so give them a chance to finish before sleeping.
*/
usleep(50);
if (waitpid(child, status, WNOHANG) == child)
return true;
usleep(49950);
ticks++;
}
return false;
}
#if defined(__linux__) && defined(__NR_pidfd_open)
/* TODO: remove this wrapper once musl and glibc gain pidfd_open() directly. */
static inline int
lif_pidfd_open(pid_t pid, unsigned int flags)
{
return syscall(__NR_pidfd_open, pid, flags);
}
static inline bool
lif_process_monitor_procdesc(pid_t child, int timeout_sec, int *status)
{
int pidfd = lif_pidfd_open(child, 0);
/* pidfd_open() not available, fall back to busyloop */
if (pidfd == -1 && errno == ENOSYS)
return lif_process_monitor_busyloop(child, timeout_sec, status);
struct pollfd pfd = {
.fd = pidfd,
.events = POLLIN,
};
if (poll(&pfd, 1, timeout_sec * 1000) < 1)
return false;
waitpid(child, status, 0);
close(pidfd);
return true;
}
#endif
static inline bool
lif_process_monitor(const char *cmdbuf, pid_t child, int timeout_sec)
{
int status;
#if defined(__linux__) && defined(__NR_pidfd_open)
if (lif_process_monitor_procdesc(child, timeout_sec, &status))
return WIFEXITED(status) && WEXITSTATUS(status) == 0;
#else
if (lif_process_monitor_busyloop(child, timeout_sec, &status))
return WIFEXITED(status) && WEXITSTATUS(status) == 0;
#endif
fprintf(stderr, "execution of '%s': timeout after %d seconds\n", cmdbuf, timeout_sec);
kill(child, SIGKILL);
waitpid(child, &status, 0);
return false;
}
bool bool
lif_execute_fmt(const struct lif_execute_opts *opts, char *const envp[], const char *fmt, ...) lif_execute_fmt(const struct lif_execute_opts *opts, char *const envp[], const char *fmt, ...)
{ {
@ -135,7 +55,10 @@ lif_execute_fmt(const struct lif_execute_opts *opts, char *const envp[], const c
return false; return false;
} }
return lif_process_monitor(cmdbuf, child, opts->timeout); int status;
waitpid(child, &status, 0);
return WIFEXITED(status) && WEXITSTATUS(status) == 0;
} }
bool bool
@ -195,8 +118,11 @@ lif_execute_fmt_with_result(const struct lif_execute_opts *opts, char *buf, size
return false; return false;
} }
int status;
no_result: no_result:
return lif_process_monitor(cmdbuf, child, opts->timeout); waitpid(child, &status, 0);
return WIFEXITED(status) && WEXITSTATUS(status) == 0;
} }
bool bool

View file

@ -27,7 +27,6 @@ struct lif_execute_opts {
const char *executor_path; const char *executor_path;
const char *interfaces_file; const char *interfaces_file;
const char *state_file; const char *state_file;
int timeout;
}; };
extern bool lif_execute_fmt(const struct lif_execute_opts *opts, char *const envp[], const char *fmt, ...); extern bool lif_execute_fmt(const struct lif_execute_opts *opts, char *const envp[], const char *fmt, ...);

View file

@ -100,10 +100,8 @@ static const struct remap_token tokens[] = {
{"vendor", "dhcp-vendor"}, /* legacy ifupdown */ {"vendor", "dhcp-vendor"}, /* legacy ifupdown */
{"vrf", "vrf-member"}, /* ifupdown2 */ {"vrf", "vrf-member"}, /* ifupdown2 */
{"vxlan-local-tunnelip", "vxlan-local-ip"}, /* ifupdown2 */ {"vxlan-local-tunnelip", "vxlan-local-ip"}, /* ifupdown2 */
{"vxlan-remote-group", "vxlan-peer-group"}, /* ifupdown-ng */ {"vxlan-remoteip", "vxlan-remote-ip"}, /* ifupdown2 */
{"vxlan-remoteip", "vxlan-peer-ips"}, /* ifupdown2 */ {"vxlan-svcnodeip", "vxlan-remote-group"}, /* ifupdown2 */
{"vxlan-remote-ip", "vxlan-peer-ips"}, /* ifupdown-ng */
{"vxlan-svcnodeip", "vxlan-peer-group"}, /* ifupdown2 */
}; };
static int static int

View file

@ -94,8 +94,7 @@ query_dependents_from_executors(const struct lif_execute_opts *opts, char *const
struct lif_execute_opts exec_opts = { struct lif_execute_opts exec_opts = {
.verbose = opts->verbose, .verbose = opts->verbose,
.executor_path = opts->executor_path, .executor_path = opts->executor_path,
.interfaces_file = opts->interfaces_file, .interfaces_file = opts->interfaces_file
.timeout = opts->timeout,
}; };
if (strcmp(entry->key, "use")) if (strcmp(entry->key, "use"))
@ -115,7 +114,7 @@ query_dependents_from_executors(const struct lif_execute_opts *opts, char *const
return true; return true;
} }
static bool bool
append_to_buffer(char **buffer, size_t *buffer_len, char **end, const char *value) append_to_buffer(char **buffer, size_t *buffer_len, char **end, const char *value)
{ {
size_t value_len = strlen (value); size_t value_len = strlen (value);

View file

@ -5,8 +5,7 @@ EXECUTOR="$(atf_get_srcdir)/../../executor-scripts/linux/vxlan"
tests_init \ tests_init \
create_simple \ create_simple \
create_ucast_ptp \ create_ucast \
create_ucast_ptmp \
create_mcast \ create_mcast \
create_physdev \ create_physdev \
create_dstport \ create_dstport \
@ -19,24 +18,14 @@ create_simple_body() {
${EXECUTOR} ${EXECUTOR}
} }
create_ucast_ptp_body() { create_ucast_body() {
export IFACE=vx_foo PHASE=create MOCK=echo IF_VXLAN_ID=2342 IF_VXLAN_PEER_IPS=192.2.0.42 export IFACE=vx_foo PHASE=create MOCK=echo IF_VXLAN_ID=2342 IF_VXLAN_REMOTE_IP=192.2.0.42
atf_check -s exit:0 -o match:'ip link add vx_foo type vxlan id 2342 remote 192.2.0.42' \ atf_check -s exit:0 -o match:'ip link add vx_foo type vxlan id 2342 remote 192.2.0.42' \
${EXECUTOR} ${EXECUTOR}
} }
create_ucast_ptmp_body() {
export IFACE=vx_foo PHASE=create MOCK=echo IF_VXLAN_ID=2342 IF_VXLAN_PEER_IPS="10.0.0.1 10.0.0.2 10.0.0.3"
atf_check -s exit:0 \
-o match:'ip link add vx_foo type vxlan id 2342 dstport 4789' \
-o match:'bridge fdb append 00:00:00:00:00:00 dev vx_foo dst 10.0.0.1 self permanent' \
-o match:'bridge fdb append 00:00:00:00:00:00 dev vx_foo dst 10.0.0.2 self permanent' \
-o match:'bridge fdb append 00:00:00:00:00:00 dev vx_foo dst 10.0.0.3 self permanent' \
${EXECUTOR}
}
create_mcast_body() { create_mcast_body() {
export IFACE=vx_foo PHASE=create MOCK=echo IF_VXLAN_ID=2342 IF_VXLAN_PEER_GROUP=225.0.8.15 export IFACE=vx_foo PHASE=create MOCK=echo IF_VXLAN_ID=2342 IF_VXLAN_REMOTE_GROUP=225.0.8.15
atf_check -s exit:0 -o match:'ip link add vx_foo type vxlan id 2342 group 225.0.8.15' \ atf_check -s exit:0 -o match:'ip link add vx_foo type vxlan id 2342 group 225.0.8.15' \
${EXECUTOR} ${EXECUTOR}
} }