Skip to content

Commit

Permalink
Fork and rename project to mcd
Browse files Browse the repository at this point in the history
This fork of the querierd project intends to remove all non-standard
features and add IPv6 MLD querier support.  The target remains the
standard Linux bridge run without `mcast_query_use_ifaddr`.

Signed-off-by: Joachim Wiberg <[email protected]>
  • Loading branch information
troglobit committed Feb 27, 2024
1 parent f7fb7f1 commit fd7b671
Show file tree
Hide file tree
Showing 25 changed files with 119 additions and 130 deletions.
13 changes: 7 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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/*
12 changes: 6 additions & 6 deletions .github/workflows/coverity.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ on:
- 'dev'

env:
PROJECT_NAME: querierd
PROJECT_NAME: mcd
CONTACT_EMAIL: [email protected]
COVERITY_NAME: westermo-querierd
COVERITY_PROJ: westermo%2Fquerierd
COVERITY_NAME: kernelkit-mcd
COVERITY_PROJ: kernelkit%2Fmcd

jobs:
coverity:
Expand All @@ -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
Expand Down Expand Up @@ -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
61 changes: 27 additions & 34 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -53,10 +41,15 @@ jobs:
ls -lF ../
mkdir -p artifacts/
mv ../*.tar.* artifacts/
- name: Upload release artifacts ...
uses: skx/[email protected]
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/*"
4 changes: 2 additions & 2 deletions Makefile.am
Original file line number Diff line number Diff line change
@@ -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

Expand Down
41 changes: 18 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -49,15 +46,15 @@ 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
the RFC algorithm, which may be necessary in some scenarios, it is
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.
Expand Down Expand Up @@ -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/
2 changes: 1 addition & 1 deletion TODO.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Rough Plan for querierd
Rough Plan for mcd
=======================

Planned for v0.11
Expand Down
6 changes: 3 additions & 3 deletions configure.ac
Original file line number Diff line number Diff line change
@@ -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])
Expand Down Expand Up @@ -97,7 +97,7 @@ cat <<EOF
------------------ Summary ------------------
$PACKAGE_NAME version $PACKAGE_VERSION
Install prefix........: $prefix
Configuration file....: `eval echo $sysconfdir`/querierd.conf
Configuration file....: `eval echo $sysconfdir`/mcd.conf
PID and .sock files...: `eval echo $runstatedir`/
C Compiler............: $CC $CFLAGS $CPPFLAGS $LDFLAGS $LIBS

Expand Down
2 changes: 1 addition & 1 deletion lib/pidfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ static pid_t pidfile_pid = 0;

static void pidfile_cleanup(void);

const char *__pidfile_path = _PATH_QUERIERD_RUNDIR;
const char *__pidfile_path = _PATH_MCD_RUNDIR;
const char *__pidfile_name = NULL;

int
Expand Down
4 changes: 2 additions & 2 deletions querierd.conf → mcd.conf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# /etc/querierd.conf: sample configuration
# /etc/mcd.conf: sample configuration
# Global settings followed by per-interface enable/disable of features.
# By default, querierd is disabled on all interfaces.
# By default, mcd is disabled on all interfaces.

# Query interval can be [1,1024], default 125. Recommended not go below 10
#query-interval 125
Expand Down
4 changes: 2 additions & 2 deletions src/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
.deps
.dirstamp
cfparse.c
querierd
querierctl
mcd
mctl
14 changes: 7 additions & 7 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ AM_CPPFLAGS = -D_BSD_SOURCE -D_DEFAULT_SOURCE -D_GNU_SOURCE -I$(top_srcdir)
AM_CPPFLAGS += -DSYSCONFDIR=\"@sysconfdir@\" -DRUNSTATEDIR=\"@runstatedir@\" -DPRESERVEDIR=\"@localstatedir@/lib\"
AM_CFLAGS = -W -Wall -Wextra -Wno-unused -Wno-unused-parameter

sbin_PROGRAMS = querierd querierctl
querierd_SOURCES = main.c cfparse.y config.c defs.h \
sbin_PROGRAMS = mcd mctl
mcd_SOURCES = main.c cfparse.y config.c defs.h \
iface.c iface.h netlink.c \
igmp.c igmpv2.h igmpv3.h \
inet.c ipc.c kern.c log.c \
bridge.c pev.c pev.h \
pathnames.h queue.h
querierd_CPPFLAGS = $(AM_CPPFLAGS)
querierd_LDADD = $(LIBS) $(LIBOBJS)
mcd_CPPFLAGS = $(AM_CPPFLAGS)
mcd_LDADD = $(LIBS) $(LIBOBJS)

querierctl_SOURCES = querierctl.c queue.h
querierctl_CPPFLAGS = $(AM_CPPFLAGS)
querierctl_LDADD = $(LIBS) $(LIBOBJS)
mctl_SOURCES = mctl.c queue.h
mctl_CPPFLAGS = $(AM_CPPFLAGS)
mctl_LDADD = $(LIBS) $(LIBOBJS)
4 changes: 2 additions & 2 deletions src/cfparse.y
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
%{
/*
* Configuration file parser for querierd
* Configuration file parser for mcd
*
* Written originally for mrouted by Bill Fenner, NRL, 1994
* Adapted to querierd by Joachim Wiberg, Westermo, 2022
* Adapted to mcd by Joachim Wiberg, Westermo, 2022
*
* cfparse.y,v 3.8.4.30 1998/03/01 01:48:58 fenner Exp
*/
Expand Down
6 changes: 3 additions & 3 deletions src/defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_DEFS_H_
#define QUERIERD_DEFS_H_
#ifndef MCD_DEFS_H_
#define MCD_DEFS_H_

#include "config.h"
#include <stdio.h>
Expand Down Expand Up @@ -237,4 +237,4 @@ extern FILE * tempfile(void);
extern int pidfile(const char *basename);
#endif

#endif /* QUERIERD_DEFS_H_ */
#endif /* MCD_DEFS_H_ */
6 changes: 3 additions & 3 deletions src/iface.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <net/if.h>
#include <stdint.h>
Expand Down Expand Up @@ -52,7 +52,7 @@ struct listaddr {

#define NBRF_STATIC_GROUP 0x4000 /* Static group entry */

#endif /* QUERIERD_IFACE_H_ */
#endif /* MCD_IFACE_H_ */

/**
* Local Variables:
Expand Down
2 changes: 1 addition & 1 deletion src/igmpv2.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/ipc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 <fcntl.h>
Expand Down Expand Up @@ -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);
Expand Down
Loading

0 comments on commit fd7b671

Please sign in to comment.