diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a6ab518..ed6ddd2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -28,7 +28,7 @@ jobs: run: | sudo apt-get -y update sudo apt-get -y install pkg-config libsystemd-dev ethtool socat tshark tree - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Configure # Build in a sub-directory so we can safely set a+w on all # directories. Needed for `make check` since it runs with @@ -43,14 +43,15 @@ jobs: run: | DESTDIR=~/tmp make install-strip tree ~/tmp - ldd ~/tmp/sbin/querierd - size ~/tmp/sbin/querierd - ~/tmp/sbin/querierd -h + ldd ~/tmp/sbin/mcd + size ~/tmp/sbin/mcd + ~/tmp/sbin/mcd -h + ~/tmp/sbin/mctl -h - name: Test run: | make check || (cat test/test-suite.log; false) - name: Upload Test Results - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: - name: querierd-test-${{ matrix.compiler }} + name: mcd-test-${{ matrix.compiler }} path: test/* diff --git a/.github/workflows/coverity.yml b/.github/workflows/coverity.yml index 00dadcc..79fb958 100644 --- a/.github/workflows/coverity.yml +++ b/.github/workflows/coverity.yml @@ -6,10 +6,10 @@ on: - 'dev' env: - PROJECT_NAME: querierd + PROJECT_NAME: mcd CONTACT_EMAIL: troglobit@gmail.com - COVERITY_NAME: westermo-querierd - COVERITY_PROJ: westermo%2Fquerierd + COVERITY_NAME: kernelkit-mcd + COVERITY_PROJ: kernelkit%2Fmcd jobs: coverity: @@ -19,8 +19,8 @@ jobs: run: | sudo apt-get -y update sudo apt-get -y install pkg-config - - uses: actions/checkout@v2 - - uses: actions/cache@v2 + - uses: actions/checkout@v4 + - uses: actions/cache@v4 id: coverity-toolchain-cache with: path: cov-analysis-linux64 @@ -57,7 +57,7 @@ jobs: --form description="${PROJECT_NAME} $(git rev-parse HEAD)" \ https://scan.coverity.com/builds?project=${COVERITY_PROJ} - name: Upload build.log - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: coverity-build.log path: cov-int/build-log.txt diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 818608d..f10d462 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -7,38 +7,26 @@ on: jobs: release: - name: Create GitHub release + name: Build and upload release tarball runs-on: ubuntu-latest if: startsWith(github.ref, 'refs/tags/') - outputs: - upload_url: ${{ steps.create_release.outputs.upload_url }} - release_id: ${{ steps.create_release.outputs.id }} steps: - - uses: actions/checkout@v2 - - name: Extract ChangeLog entry ... - # Hack to extract latest entry for body_path below + - uses: actions/checkout@v4 + - name: Setting release variables ... + id: build run: | - awk '/-----*/{if (x == 1) exit; x=1;next}x' ChangeLog.md \ - |head -n -1 > release.md - cat release.md - - name: Create release ... - id: create_release - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: ${{ github.ref }} - release_name: querierd ${{ github.ref }} - body_path: release.md - draft: false - prerelease: false - tarball: - name: Build and upload release tarball - needs: release - if: startsWith(github.ref, 'refs/tags/') - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 + ver=${GITHUB_REF#refs/tags/} + echo "ver=${ver}" >> $GITHUB_OUTPUT + if echo $ver | grep -qE '^v[0-9]+\.[0-9]+(\.[0-9]+)?(-alpha|-beta|-rc)[0-9]*$'; then + echo "pre=true" >> $GITHUB_OUTPUT + else + echo "pre=false" >> $GITHUB_OUTPUT + fi + if echo $ver | grep -qE '^v[0-9.]+\.[0-9.]+(\.[0-9]+)?$'; then + echo "latest=true" >> $GITHUB_OUTPUT + else + echo "latest=false" >> $GITHUB_OUTPUT + fi - name: Installing dependencies ... run: | sudo apt-get -y update @@ -53,10 +41,15 @@ jobs: ls -lF ../ mkdir -p artifacts/ mv ../*.tar.* artifacts/ - - name: Upload release artifacts ... - uses: skx/github-action-publish-binaries@release-0.15 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Extract ChangeLog entry ... + run: | + awk '/-----*/{if (x == 1) exit; x=1;next}x' ChangeLog.md \ + |head -n -1 > release.md + cat release.md + - uses: ncipollo/release-action@v1 with: - releaseId: ${{ needs.release.outputs.release_id }} - args: artifacts/* + name: mcd v${{ github.ref_name }} + prerelease: ${{ steps.build.outputs.pre }} + makeLatest: ${{ steps.build.outputs.latest }} + bodyFile: "release.md" + artifacts: "artifacts/*" diff --git a/Makefile.am b/Makefile.am index 18f0fb6..ebc319a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,5 +1,5 @@ -doc_DATA = README.md ChangeLog.md LICENSE querierd.conf -EXTRA_DIST = README.md ChangeLog.md LICENSE querierd.conf +doc_DATA = README.md ChangeLog.md LICENSE mcd.conf +EXTRA_DIST = README.md ChangeLog.md LICENSE mcd.conf DISTCLEANFILES = *~ DEADJOE semantic.cache *.gdb *.elf core core.* *.d SUBDIRS = src diff --git a/README.md b/README.md index bd93a57..c7d4093 100644 --- a/README.md +++ b/README.md @@ -5,30 +5,27 @@ Bridge Querier Helper This daemon is a querier helper for the Linux bridge. Currently IGMP (IPv4) is supported, MLD (IPv6) querier support is planned. -The daemon comes with a little helper tool called `querierctl` which +The daemon comes with a little helper tool called `mctl` which can be used to check the status of IGMP per interface, but also to -dump the bridge's MDB in a more human-friendly format. There is a -blog post describing how to set the bridge up and use `querierd` +dump the bridge's MDB in a more human-friendly format. - * https://westermo.github.io/2022/02/17/bridge-igmp-snooping/ +For controlling `mcd` from another application, use the basic IPC +support that `mctl` employs: -For controlling `querierd` from another application, use the basic IPC -support that `querierctl` employs: + echo "help" |socat - UNIX-CONNECT:/run/mcd.sock - echo "help" |socat - UNIX-CONNECT:/run/querierd.sock - -> See `querierd -h` for help, e.g. to customize the IPC path. +> See `mcd -h` for help, e.g. to customize the IPC path. Configuration ------------- -By default `querierd` is passive on all interfaces. Use the following +By default `mcd` is passive on all interfaces. Use the following settings to enable and tweak the defaults. There is no way to configure different IGMP/MLD settings per interface at the moment, only protocol version. - # /etc/querierd.conf syntax + # /etc/mcd.conf syntax query-interval [1-1024] # default: 125 sec query-response-interval [1-1024] # default: 10 sec query-last-member-interval [1-1024] # default: 1 @@ -49,7 +46,7 @@ Description: devices and the loss of elected queriers (above) * `router-timeout`: also known as *"other querier present interval"*, controls the timer used to detect when an elected querier stops - sending queries. When the timer expires `querierd` will initiate a + sending queries. When the timer expires `mcd` will initiate a query. The default, when this is unset (commented out) is calculated based on: `robustness * query-interval + query-response-interval / 2`. Setting this to any value overrides @@ -57,7 +54,7 @@ Description: however strongly recommended to leave this setting commented out! > **Note:** the daemon needs an address on interfaces to operate, it is -> expected that querierd runs on top of a bridge. Also, currently the +> expected that mcd runs on top of a bridge. Also, currently the > daemon does not react automatically to IP address changes, so it needs > to be SIGHUP'ed to use any new interface or address. @@ -115,21 +112,19 @@ _____ Origin & References ------------------- -This project is based on the [mrouted][] project, with DNA strands also from -the [pimd][] project. It should be quite easy to also add MLD/MLDv2 querier -functionality from the [pim6sd][] project, because they all share a the same -ancestor (mrouted). - -The [project][1] is maintained by Westermo Network Technologies, and due to -its origin, licensed under the same license as mrouted. +This is a fork of [querierd][], by Westermo Network Technologies, which +in turn was based on the [mrouted][] project, with DNA strands from the +[pimd][] project. It should be quite easy to also add MLD/MLDv2 querier +functionality from the [pim6sd][] project, because they all share a the +same ancestor (mrouted). -[1]: https://github.com/westermo/querierd/ -[GitHub]: https://github.com/westermo/querierd/actions/workflows/build.yml/ -[GitHub Status]: https://github.com/westermo/querierd/actions/workflows/build.yml/badge.svg +[GitHub]: https://github.com/kernelkit/mcd/actions/workflows/build.yml/ +[GitHub Status]: https://github.com/kernelkit/mcd/actions/workflows/build.yml/badge.svg [License]: http://www.openbsd.org/cgi-bin/cvsweb/src/usr.sbin/mrouted/LICENSE [License Badge]: https://img.shields.io/badge/License-BSD%203--Clause-blue.svg [Coverity Scan]: https://scan.coverity.com/projects/24475 [Coverity Status]: https://scan.coverity.com/projects/24475/badge.svg +[querierd]: https://github.com/westermo/querierd/ [mrouted]: https://github.com/troglobit/mrouted/ [pimd]: https://github.com/troglobit/pimd/ [pim6sd]: https://github.com/troglobit/pim6sd/ diff --git a/TODO.md b/TODO.md index efb808c..291d0c5 100644 --- a/TODO.md +++ b/TODO.md @@ -1,4 +1,4 @@ -Rough Plan for querierd +Rough Plan for mcd ======================= Planned for v0.11 diff --git a/configure.ac b/configure.ac index d0d7cbb..2c3cede 100644 --- a/configure.ac +++ b/configure.ac @@ -1,6 +1,6 @@ AC_PREREQ(2.61) -AC_INIT([querierd], [0.10], [https://github.com/troglobit/querierd/issues],, - [https://troglobit.com/projects/querierd/]) +AC_INIT([mcd], [0.10], [https://github.com/troglobit/mcd/issues],, + [https://troglobit.com/projects/mcd/]) AC_CONFIG_AUX_DIR(aux) AM_INIT_AUTOMAKE([1.11 foreign]) AM_SILENT_RULES([yes]) @@ -97,7 +97,7 @@ cat < @@ -237,4 +237,4 @@ extern FILE * tempfile(void); extern int pidfile(const char *basename); #endif -#endif /* QUERIERD_DEFS_H_ */ +#endif /* MCD_DEFS_H_ */ diff --git a/src/iface.h b/src/iface.h index c5f8b0f..459392b 100644 --- a/src/iface.h +++ b/src/iface.h @@ -2,8 +2,8 @@ * Parts of this program has been derived from mrouted. It is covered * by the license in the accompanying file named "LICENSE". */ -#ifndef QUERIERD_IFACE_H_ -#define QUERIERD_IFACE_H_ +#ifndef MCD_IFACE_H_ +#define MCD_IFACE_H_ #include #include @@ -52,7 +52,7 @@ struct listaddr { #define NBRF_STATIC_GROUP 0x4000 /* Static group entry */ -#endif /* QUERIERD_IFACE_H_ */ +#endif /* MCD_IFACE_H_ */ /** * Local Variables: diff --git a/src/igmpv2.h b/src/igmpv2.h index 786e9f0..1ab169c 100644 --- a/src/igmpv2.h +++ b/src/igmpv2.h @@ -43,7 +43,7 @@ * IGMP_HOST_{MEMBERSHIP_QUERY,MEMBERSHIP_REPORT,NEW_MEMBERSHIP_REPORT * ,LEAVE_MESSAGE}. Later releases removed the HOST and inserted * the IGMP version number. NetBSD inserted the version number in - * a different way. querierd use the new names, so we #define them + * a different way. mcd use the new names, so we #define them * to the old ones if needed. */ #if !defined(IGMP_MEMBERSHIP_QUERY) && defined(IGMP_HOST_MEMBERSHIP_QUERY) diff --git a/src/ipc.c b/src/ipc.c index 1e1a407..1560b9e 100644 --- a/src/ipc.c +++ b/src/ipc.c @@ -41,7 +41,7 @@ * it to the daemon. * * Example: - * echo "help" |socat - UNIX-CONNECT:/run/querierd.sock + * echo "help" |socat - UNIX-CONNECT:/run/mcd.sock */ #include @@ -518,7 +518,7 @@ void ipc_init(char *sockfile) if (sockfile) strlcpy(sun.sun_path, sockfile, sizeof(sun.sun_path)); else - snprintf(sun.sun_path, sizeof(sun.sun_path), _PATH_QUERIERD_SOCK, ident); + snprintf(sun.sun_path, sizeof(sun.sun_path), _PATH_MCD_SOCK, ident); unlink(sun.sun_path); logit(LOG_DEBUG, 0, "Binding IPC socket to %s", sun.sun_path); diff --git a/src/main.c b/src/main.c index 8b090bb..22d06b8 100644 --- a/src/main.c +++ b/src/main.c @@ -13,7 +13,7 @@ int haveterminal = 1; int running = 1; int use_syslog = 1; -time_t querierd_init_time; +time_t mcd_init_time; char *config_file = NULL; char *pid_file = NULL; @@ -21,7 +21,7 @@ char *sock_file = NULL; char *ident = PACKAGE_NAME; char *prognm = NULL; -const char *versionstring = "querierd version " PACKAGE_VERSION; +const char *versionstring = "mcd version " PACKAGE_VERSION; /* * Forward declarations. @@ -34,7 +34,7 @@ static void cleanup(void); static int compose_paths(void) { - /* Default .conf file path: "/etc" + '/' + "querierd" + ".conf" */ + /* Default .conf file path: "/etc" + '/' + "mcd" + ".conf" */ if (!config_file) { size_t len = strlen(SYSCONFDIR) + strlen(ident) + 7; @@ -44,7 +44,7 @@ static int compose_paths(void) exit(1); } - snprintf(config_file, len, _PATH_QUERIERD_CONF, ident); + snprintf(config_file, len, _PATH_MCD_CONF, ident); } /* Default is to let pidfile() API construct PID file from ident */ diff --git a/src/querierctl.c b/src/mctl.c similarity index 95% rename from src/querierctl.c rename to src/mctl.c index 7f9311d..06bfd1d 100644 --- a/src/querierctl.c +++ b/src/mctl.c @@ -155,7 +155,7 @@ static int try_connect(struct sockaddr_un *sun) close(sd); if (errno == ENOENT) { if (debug) - warnx("no querierd at %s", sun->sun_path); + warnx("no mcd at %s", sun->sun_path); return -1; } @@ -432,10 +432,10 @@ static int get(char *cmd, FILE *fp) sd = ipc_connect(); if (-1 == sd) { if (errno == ENOENT) - errx(1, "no querierd running."); + errx(1, "no mcd running."); else if (errno == EACCES) errx(1, "not enough permissions."); - err(1, "failed connecting to querierd"); + err(1, "failed connecting to mcd"); return 1; /* we never get here, make gcc happy */ } @@ -585,23 +585,23 @@ static int usage(int rc) char buf[120]; printf("Usage:\n" - " querierctl [OPTIONS] [COMMAND]\n" + " mctl [OPTIONS] [COMMAND]\n" "\n" "Options:\n" - " -i, --ident=NAME Connect to named querierd instance\n" + " -i, --ident=NAME Connect to named mcd instance\n" " -m, --monitor Run 'COMMAND' every two seconds, like watch(1)\n" " -p, --plain Use plain table headings, no ctrl chars\n" " -t, --no-heading Skip table headings\n" " -h, --help This help text\n" " -u, --ipc=FILE Override UNIX domain socket file, default based on -i\n" - " -v, --version Show querierctl version\n" + " -v, --version Show mctl version\n" "\n"); if (ipc_fetch()) { if (errno == EACCES) - printf("Not enough permissions to query querierd for commands.\n"); + printf("Not enough permissions to query mcd for commands.\n"); else - printf("No querierd running, no commands available.\n"); + printf("No mcd running, no commands available.\n"); return rc; } @@ -625,7 +625,7 @@ static int usage(int rc) static int version(void) { - printf("querierctl version %s (%s)\n", PACKAGE_VERSION, PACKAGE_NAME); + printf("mctl version %s (%s)\n", PACKAGE_VERSION, PACKAGE_NAME); return 0; } @@ -636,9 +636,9 @@ static int cmd(int argc, char *argv[]) if (ipc_fetch()) { if (errno == EACCES) - printf("Not enough permissions to send commands to querierd.\n"); + printf("Not enough permissions to send commands to mcd.\n"); else - printf("No querierd running, no commands available.\n"); + printf("No mcd running, no commands available.\n"); return 1; } diff --git a/src/pathnames.h b/src/pathnames.h index bb517df..81ce907 100644 --- a/src/pathnames.h +++ b/src/pathnames.h @@ -2,13 +2,13 @@ * Parts of this program has been derived from mrouted. It is covered * by the license in the accompanying file named "LICENSE". */ -#ifndef QUERIERD_PATHNAMES_H_ -#define QUERIERD_PATHNAMES_H_ +#ifndef MCD_PATHNAMES_H_ +#define MCD_PATHNAMES_H_ #include -#define _PATH_QUERIERD_CONF SYSCONFDIR "/%s.conf" -#define _PATH_QUERIERD_RUNDIR RUNSTATEDIR -#define _PATH_QUERIERD_SOCK RUNSTATEDIR "/%s.sock" +#define _PATH_MCD_CONF SYSCONFDIR "/%s.conf" +#define _PATH_MCD_RUNDIR RUNSTATEDIR +#define _PATH_MCD_SOCK RUNSTATEDIR "/%s.sock" -#endif /* QUERIERD_PATHNAMES_H_ */ +#endif /* MCD_PATHNAMES_H_ */ diff --git a/test/basic.sh b/test/basic.sh index 068d6c8..e2b7cd4 100755 --- a/test/basic.sh +++ b/test/basic.sh @@ -45,8 +45,8 @@ tshark -lni eth1 -w "/tmp/$NM/eth1.pcap" 2>/dev/null & echo $! >> "/tmp/$NM/PIDs" sleep 1 -print "Starting querierd ..." -../src/querierd -f "/tmp/$NM/config" -p "/tmp/$NM/pid" -l debug -n & +print "Starting mcd ..." +../src/mcd -f "/tmp/$NM/config" -p "/tmp/$NM/pid" -l debug -n & echo $! >> "/tmp/$NM/PIDs" sleep 2 diff --git a/test/ipc.sh b/test/ipc.sh index 623998b..b2ca951 100755 --- a/test/ipc.sh +++ b/test/ipc.sh @@ -32,8 +32,8 @@ iface eth3 enable EOF cat "/tmp/$NM/config" -print "Starting querierd ..." -../src/querierd -f "/tmp/$NM/config" -p "/tmp/$NM/pid" -l debug -n -u "/tmp/$NM/sock" & +print "Starting mcd ..." +../src/mcd -f "/tmp/$NM/config" -p "/tmp/$NM/pid" -l debug -n -u "/tmp/$NM/sock" & echo $! >> "/tmp/$NM/PIDs" sleep 2 diff --git a/test/late.sh b/test/late.sh index c6120b2..85742a5 100755 --- a/test/late.sh +++ b/test/late.sh @@ -23,8 +23,8 @@ iface eth3 enable EOF cat "/tmp/$NM/config" -print "Starting querierd ..." -../src/querierd -f "/tmp/$NM/config" -p "/tmp/$NM/pid" -l debug -n -u "/tmp/$NM/sock" & +print "Starting mcd ..." +../src/mcd -f "/tmp/$NM/config" -p "/tmp/$NM/pid" -l debug -n -u "/tmp/$NM/sock" & echo $! >> "/tmp/$NM/PIDs" sleep 2 diff --git a/test/lib.sh b/test/lib.sh index fad4d07..f55dae3 100755 --- a/test/lib.sh +++ b/test/lib.sh @@ -1,5 +1,5 @@ #!/bin/sh -# Helper functions for testing querierd +# Helper functions for testing mcd # Test name, used everywhere as /tmp/$NM/foo NM=$(basename "$0" .sh) diff --git a/test/sleepy.sh b/test/sleepy.sh index b5c88b9..2145d3b 100755 --- a/test/sleepy.sh +++ b/test/sleepy.sh @@ -57,9 +57,9 @@ tshark -lni eth1 -w "/tmp/$NM/eth1.pcap" 2>/dev/null & echo $! >> "/tmp/$NM/PIDs" sleep 1 -print "Starting querierd ..." +print "Starting mcd ..." # shellcheck disable=SC2086 -../src/querierd -f "/tmp/$NM/config" -p "/tmp/$NM/pid" $DEBUG -n & +../src/mcd -f "/tmp/$NM/config" -p "/tmp/$NM/pid" $DEBUG -n & echo $! >> "/tmp/$NM/PIDs" sleep 4 diff --git a/test/two.sh b/test/two.sh index 769af22..0095779 100755 --- a/test/two.sh +++ b/test/two.sh @@ -38,8 +38,8 @@ tshark -lni eth1 -w "/tmp/$NM/eth1.pcap" 2>/dev/null & echo $! >> "/tmp/$NM/PIDs" sleep 1 -print "Starting querierd ..." -../src/querierd -f "/tmp/$NM/config" -p "/tmp/$NM/pid" -l debug -n & +print "Starting mcd ..." +../src/mcd -f "/tmp/$NM/config" -p "/tmp/$NM/pid" -l debug -n & echo $! >> "/tmp/$NM/PIDs" sleep 6