diff -Nru radvd-2.16/aclocal.m4 radvd-2.17/aclocal.m4 --- radvd-2.16/aclocal.m4 2017-02-20 14:49:14.000000000 +0000 +++ radvd-2.17/aclocal.m4 2017-07-04 03:30:26.000000000 +0000 @@ -20,32 +20,63 @@ If you have problems, you may need to regenerate the build system entirely. To do so, use the procedure documented by the package, typically 'autoreconf'.])]) -# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*- -# serial 1 (pkg-config-0.24) -# -# Copyright © 2004 Scott James Remnant . -# -# This program 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 program 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, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -# PKG_PROG_PKG_CONFIG([MIN-VERSION]) -# ---------------------------------- +dnl pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*- +dnl serial 11 (pkg-config-0.29.1) +dnl +dnl Copyright © 2004 Scott James Remnant . +dnl Copyright © 2012-2015 Dan Nicholson +dnl +dnl This program is free software; you can redistribute it and/or modify +dnl it under the terms of the GNU General Public License as published by +dnl the Free Software Foundation; either version 2 of the License, or +dnl (at your option) any later version. +dnl +dnl This program is distributed in the hope that it will be useful, but +dnl WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +dnl General Public License for more details. +dnl +dnl You should have received a copy of the GNU General Public License +dnl along with this program; if not, write to the Free Software +dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +dnl 02111-1307, USA. +dnl +dnl As a special exception to the GNU General Public License, if you +dnl distribute this file as part of a program that contains a +dnl configuration script generated by Autoconf, you may include it under +dnl the same distribution terms that you use for the rest of that +dnl program. + +dnl PKG_PREREQ(MIN-VERSION) +dnl ----------------------- +dnl Since: 0.29 +dnl +dnl Verify that the version of the pkg-config macros are at least +dnl MIN-VERSION. Unlike PKG_PROG_PKG_CONFIG, which checks the user's +dnl installed version of pkg-config, this checks the developer's version +dnl of pkg.m4 when generating configure. +dnl +dnl To ensure that this macro is defined, also add: +dnl m4_ifndef([PKG_PREREQ], +dnl [m4_fatal([must install pkg-config 0.29 or later before running autoconf/autogen])]) +dnl +dnl See the "Since" comment for each macro you use to see what version +dnl of the macros you require. +m4_defun([PKG_PREREQ], +[m4_define([PKG_MACROS_VERSION], [0.29.1]) +m4_if(m4_version_compare(PKG_MACROS_VERSION, [$1]), -1, + [m4_fatal([pkg.m4 version $1 or higher is required but ]PKG_MACROS_VERSION[ found])]) +])dnl PKG_PREREQ + +dnl PKG_PROG_PKG_CONFIG([MIN-VERSION]) +dnl ---------------------------------- +dnl Since: 0.16 +dnl +dnl Search for the pkg-config tool and set the PKG_CONFIG variable to +dnl first found in the path. Checks that the version of pkg-config found +dnl is at least MIN-VERSION. If MIN-VERSION is not specified, 0.9.0 is +dnl used since that's the first version where most current features of +dnl pkg-config existed. AC_DEFUN([PKG_PROG_PKG_CONFIG], [m4_pattern_forbid([^_?PKG_[A-Z_]+$]) m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$]) @@ -67,18 +98,19 @@ PKG_CONFIG="" fi fi[]dnl -])# PKG_PROG_PKG_CONFIG +])dnl PKG_PROG_PKG_CONFIG -# PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) -# -# Check to see whether a particular set of modules exists. Similar -# to PKG_CHECK_MODULES(), but does not set variables or print errors. -# -# Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG]) -# only at the first occurence in configure.ac, so if the first place -# it's called might be skipped (such as if it is within an "if", you -# have to call PKG_CHECK_EXISTS manually -# -------------------------------------------------------------- +dnl PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) +dnl ------------------------------------------------------------------- +dnl Since: 0.18 +dnl +dnl Check to see whether a particular set of modules exists. Similar to +dnl PKG_CHECK_MODULES(), but does not set variables or print errors. +dnl +dnl Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG]) +dnl only at the first occurence in configure.ac, so if the first place +dnl it's called might be skipped (such as if it is within an "if", you +dnl have to call PKG_CHECK_EXISTS manually AC_DEFUN([PKG_CHECK_EXISTS], [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl if test -n "$PKG_CONFIG" && \ @@ -88,8 +120,10 @@ $3])dnl fi]) -# _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES]) -# --------------------------------------------- +dnl _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES]) +dnl --------------------------------------------- +dnl Internal wrapper calling pkg-config via PKG_CONFIG and setting +dnl pkg_failed based on the result. m4_define([_PKG_CONFIG], [if test -n "$$1"; then pkg_cv_[]$1="$$1" @@ -101,10 +135,11 @@ else pkg_failed=untried fi[]dnl -])# _PKG_CONFIG +])dnl _PKG_CONFIG -# _PKG_SHORT_ERRORS_SUPPORTED -# ----------------------------- +dnl _PKG_SHORT_ERRORS_SUPPORTED +dnl --------------------------- +dnl Internal check to see if pkg-config supports short errors. AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED], [AC_REQUIRE([PKG_PROG_PKG_CONFIG]) if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then @@ -112,19 +147,17 @@ else _pkg_short_errors_supported=no fi[]dnl -])# _PKG_SHORT_ERRORS_SUPPORTED +])dnl _PKG_SHORT_ERRORS_SUPPORTED -# PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], -# [ACTION-IF-NOT-FOUND]) -# -# -# Note that if there is a possibility the first call to -# PKG_CHECK_MODULES might not happen, you should be sure to include an -# explicit call to PKG_PROG_PKG_CONFIG in your configure.ac -# -# -# -------------------------------------------------------------- +dnl PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], +dnl [ACTION-IF-NOT-FOUND]) +dnl -------------------------------------------------------------- +dnl Since: 0.4.0 +dnl +dnl Note that if there is a possibility the first call to +dnl PKG_CHECK_MODULES might not happen, you should be sure to include an +dnl explicit call to PKG_PROG_PKG_CONFIG in your configure.ac AC_DEFUN([PKG_CHECK_MODULES], [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl @@ -178,16 +211,40 @@ AC_MSG_RESULT([yes]) $3 fi[]dnl -])# PKG_CHECK_MODULES +])dnl PKG_CHECK_MODULES -# PKG_INSTALLDIR(DIRECTORY) -# ------------------------- -# Substitutes the variable pkgconfigdir as the location where a module -# should install pkg-config .pc files. By default the directory is -# $libdir/pkgconfig, but the default can be changed by passing -# DIRECTORY. The user can override through the --with-pkgconfigdir -# parameter. +dnl PKG_CHECK_MODULES_STATIC(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], +dnl [ACTION-IF-NOT-FOUND]) +dnl --------------------------------------------------------------------- +dnl Since: 0.29 +dnl +dnl Checks for existence of MODULES and gathers its build flags with +dnl static libraries enabled. Sets VARIABLE-PREFIX_CFLAGS from --cflags +dnl and VARIABLE-PREFIX_LIBS from --libs. +dnl +dnl Note that if there is a possibility the first call to +dnl PKG_CHECK_MODULES_STATIC might not happen, you should be sure to +dnl include an explicit call to PKG_PROG_PKG_CONFIG in your +dnl configure.ac. +AC_DEFUN([PKG_CHECK_MODULES_STATIC], +[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl +_save_PKG_CONFIG=$PKG_CONFIG +PKG_CONFIG="$PKG_CONFIG --static" +PKG_CHECK_MODULES($@) +PKG_CONFIG=$_save_PKG_CONFIG[]dnl +])dnl PKG_CHECK_MODULES_STATIC + + +dnl PKG_INSTALLDIR([DIRECTORY]) +dnl ------------------------- +dnl Since: 0.27 +dnl +dnl Substitutes the variable pkgconfigdir as the location where a module +dnl should install pkg-config .pc files. By default the directory is +dnl $libdir/pkgconfig, but the default can be changed by passing +dnl DIRECTORY. The user can override through the --with-pkgconfigdir +dnl parameter. AC_DEFUN([PKG_INSTALLDIR], [m4_pushdef([pkg_default], [m4_default([$1], ['${libdir}/pkgconfig'])]) m4_pushdef([pkg_description], @@ -198,16 +255,18 @@ AC_SUBST([pkgconfigdir], [$with_pkgconfigdir]) m4_popdef([pkg_default]) m4_popdef([pkg_description]) -]) dnl PKG_INSTALLDIR +])dnl PKG_INSTALLDIR -# PKG_NOARCH_INSTALLDIR(DIRECTORY) -# ------------------------- -# Substitutes the variable noarch_pkgconfigdir as the location where a -# module should install arch-independent pkg-config .pc files. By -# default the directory is $datadir/pkgconfig, but the default can be -# changed by passing DIRECTORY. The user can override through the -# --with-noarch-pkgconfigdir parameter. +dnl PKG_NOARCH_INSTALLDIR([DIRECTORY]) +dnl -------------------------------- +dnl Since: 0.27 +dnl +dnl Substitutes the variable noarch_pkgconfigdir as the location where a +dnl module should install arch-independent pkg-config .pc files. By +dnl default the directory is $datadir/pkgconfig, but the default can be +dnl changed by passing DIRECTORY. The user can override through the +dnl --with-noarch-pkgconfigdir parameter. AC_DEFUN([PKG_NOARCH_INSTALLDIR], [m4_pushdef([pkg_default], [m4_default([$1], ['${datadir}/pkgconfig'])]) m4_pushdef([pkg_description], @@ -218,13 +277,15 @@ AC_SUBST([noarch_pkgconfigdir], [$with_noarch_pkgconfigdir]) m4_popdef([pkg_default]) m4_popdef([pkg_description]) -]) dnl PKG_NOARCH_INSTALLDIR +])dnl PKG_NOARCH_INSTALLDIR -# PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE, -# [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) -# ------------------------------------------- -# Retrieves the value of the pkg-config variable for the given module. +dnl PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE, +dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) +dnl ------------------------------------------- +dnl Since: 0.28 +dnl +dnl Retrieves the value of the pkg-config variable for the given module. AC_DEFUN([PKG_CHECK_VAR], [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl @@ -233,7 +294,7 @@ AS_VAR_COPY([$1], [pkg_cv_][$1]) AS_VAR_IF([$1], [""], [$5], [$4])dnl -])# PKG_CHECK_VAR +])dnl PKG_CHECK_VAR # Copyright (C) 2002-2014 Free Software Foundation, Inc. # diff -Nru radvd-2.16/CHANGES radvd-2.17/CHANGES --- radvd-2.16/CHANGES 2017-02-20 14:49:14.000000000 +0000 +++ radvd-2.17/CHANGES 2017-07-04 03:30:02.000000000 +0000 @@ -1,3 +1,12 @@ +2017/07/03 Release v2.17 + +2017/07/01 Fix STDERR_SYSLOG log level bug. + Always close stdout and stderr when daemonizing. + +2017/03/15 Implement RFC 7772 Section 5.1.1, 5.1.2, defaulted to on. + +2017/02/04 clang-format the code + 2017/02/01 Release v2.16 2017/01/10 Fixed ExecReload in systemd service file diff -Nru radvd-2.16/config.guess radvd-2.17/config.guess --- radvd-2.16/config.guess 2017-02-20 14:49:14.000000000 +0000 +++ radvd-2.17/config.guess 2017-07-04 03:30:28.000000000 +0000 @@ -1,8 +1,8 @@ #! /bin/sh # Attempt to guess a canonical system name. -# Copyright 1992-2014 Free Software Foundation, Inc. +# Copyright 1992-2015 Free Software Foundation, Inc. -timestamp='2014-03-23' +timestamp='2015-08-20' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -24,12 +24,12 @@ # program. This Exception is an additional permission under section 7 # of the GNU General Public License, version 3 ("GPLv3"). # -# Originally written by Per Bothner. +# Originally written by Per Bothner; maintained since 2000 by Ben Elliston. # # You can get the latest version of this script from: # http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD # -# Please send patches with a ChangeLog entry to config-patches@gnu.org. +# Please send patches to . me=`echo "$0" | sed -e 's,.*/,,'` @@ -50,7 +50,7 @@ GNU config.guess ($timestamp) Originally written by Per Bothner. -Copyright 1992-2014 Free Software Foundation, Inc. +Copyright 1992-2015 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." @@ -168,20 +168,27 @@ # Note: NetBSD doesn't particularly care about the vendor # portion of the name. We always set it to "unknown". sysctl="sysctl -n hw.machine_arch" - UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ - /usr/sbin/$sysctl 2>/dev/null || echo unknown)` + UNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \ + /sbin/$sysctl 2>/dev/null || \ + /usr/sbin/$sysctl 2>/dev/null || \ + echo unknown)` case "${UNAME_MACHINE_ARCH}" in armeb) machine=armeb-unknown ;; arm*) machine=arm-unknown ;; sh3el) machine=shl-unknown ;; sh3eb) machine=sh-unknown ;; sh5el) machine=sh5le-unknown ;; + earmv*) + arch=`echo ${UNAME_MACHINE_ARCH} | sed -e 's,^e\(armv[0-9]\).*$,\1,'` + endian=`echo ${UNAME_MACHINE_ARCH} | sed -ne 's,^.*\(eb\)$,\1,p'` + machine=${arch}${endian}-unknown + ;; *) machine=${UNAME_MACHINE_ARCH}-unknown ;; esac # The Operating System including object format, if it has switched # to ELF recently, or will in the future. case "${UNAME_MACHINE_ARCH}" in - arm*|i386|m68k|ns32k|sh3*|sparc|vax) + arm*|earm*|i386|m68k|ns32k|sh3*|sparc|vax) eval $set_cc_for_build if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ELF__ @@ -197,6 +204,13 @@ os=netbsd ;; esac + # Determine ABI tags. + case "${UNAME_MACHINE_ARCH}" in + earm*) + expr='s/^earmv[0-9]/-eabi/;s/eb$//' + abi=`echo ${UNAME_MACHINE_ARCH} | sed -e "$expr"` + ;; + esac # The OS release # Debian GNU/NetBSD machines have a different userland, and # thus, need a distinct triplet. However, they do not need @@ -207,13 +221,13 @@ release='-gnu' ;; *) - release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` + release=`echo ${UNAME_RELEASE} | sed -e 's/[-_].*//' | cut -d. -f1,2` ;; esac # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: # contains redundant information, the shorter form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. - echo "${machine}-${os}${release}" + echo "${machine}-${os}${release}${abi}" exit ;; *:Bitrig:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` @@ -235,6 +249,9 @@ *:MirBSD:*:*) echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} exit ;; + *:Sortix:*:*) + echo ${UNAME_MACHINE}-unknown-sortix + exit ;; alpha:OSF1:*:*) case $UNAME_RELEASE in *4.0) @@ -579,8 +596,9 @@ else IBM_ARCH=powerpc fi - if [ -x /usr/bin/oslevel ] ; then - IBM_REV=`/usr/bin/oslevel` + if [ -x /usr/bin/lslpp ] ; then + IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc | + awk -F: '{ print $3 }' | sed s/[0-9]*$/0/` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi @@ -932,6 +950,9 @@ crisv32:Linux:*:*) echo ${UNAME_MACHINE}-axis-linux-${LIBC} exit ;; + e2k:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; frv:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; @@ -1020,7 +1041,7 @@ echo ${UNAME_MACHINE}-dec-linux-${LIBC} exit ;; x86_64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo ${UNAME_MACHINE}-pc-linux-${LIBC} exit ;; xtensa*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} diff -Nru radvd-2.16/config.sub radvd-2.17/config.sub --- radvd-2.16/config.sub 2017-02-20 14:49:14.000000000 +0000 +++ radvd-2.17/config.sub 2017-07-04 03:30:28.000000000 +0000 @@ -1,8 +1,8 @@ #! /bin/sh # Configuration validation subroutine script. -# Copyright 1992-2014 Free Software Foundation, Inc. +# Copyright 1992-2015 Free Software Foundation, Inc. -timestamp='2014-09-11' +timestamp='2015-08-20' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -25,7 +25,7 @@ # of the GNU General Public License, version 3 ("GPLv3"). -# Please send patches with a ChangeLog entry to config-patches@gnu.org. +# Please send patches to . # # Configuration subroutine to validate and canonicalize a configuration type. # Supply the specified configuration type as an argument. @@ -68,7 +68,7 @@ version="\ GNU config.sub ($timestamp) -Copyright 1992-2014 Free Software Foundation, Inc. +Copyright 1992-2015 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." @@ -117,7 +117,7 @@ case $maybe_os in nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ - knetbsd*-gnu* | netbsd*-gnu* | \ + knetbsd*-gnu* | netbsd*-gnu* | netbsd*-eabi* | \ kopensolaris*-gnu* | \ storm-chaos* | os2-emx* | rtmk-nova*) os=-$maybe_os @@ -255,12 +255,13 @@ | arc | arceb \ | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \ | avr | avr32 \ + | ba \ | be32 | be64 \ | bfin \ | c4x | c8051 | clipper \ | d10v | d30v | dlx | dsp16xx \ - | epiphany \ - | fido | fr30 | frv \ + | e2k | epiphany \ + | fido | fr30 | frv | ft32 \ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ | hexagon \ | i370 | i860 | i960 | ia64 \ @@ -305,7 +306,7 @@ | riscv32 | riscv64 \ | rl78 | rx \ | score \ - | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ + | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[234]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ | sh64 | sh64le \ | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ @@ -313,6 +314,7 @@ | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ | ubicom32 \ | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \ + | visium \ | we32k \ | x86 | xc16x | xstormy16 | xtensa \ | z8k | z80) @@ -327,6 +329,9 @@ c6x) basic_machine=tic6x-unknown ;; + leon|leon[3-9]) + basic_machine=sparc-$basic_machine + ;; m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | picochip) basic_machine=$basic_machine-unknown os=-none @@ -372,12 +377,13 @@ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ | avr-* | avr32-* \ + | ba-* \ | be32-* | be64-* \ | bfin-* | bs2000-* \ | c[123]* | c30-* | [cjt]90-* | c4x-* \ | c8051-* | clipper-* | craynv-* | cydra-* \ | d10v-* | d30v-* | dlx-* \ - | elxsi-* \ + | e2k-* | elxsi-* \ | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ | h8300-* | h8500-* \ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ @@ -424,12 +430,13 @@ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ | pyramid-* \ + | riscv32-* | riscv64-* \ | rl78-* | romp-* | rs6000-* | rx-* \ | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ | sparclite-* \ - | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \ + | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx*-* \ | tahoe-* \ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ | tile*-* \ @@ -437,6 +444,7 @@ | ubicom32-* \ | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ | vax-* \ + | visium-* \ | we32k-* \ | x86-* | x86_64-* | xc16x-* | xps100-* \ | xstormy16-* | xtensa*-* \ @@ -513,6 +521,9 @@ basic_machine=i386-pc os=-aros ;; + asmjs) + basic_machine=asmjs-unknown + ;; aux) basic_machine=m68k-apple os=-aux @@ -774,6 +785,9 @@ basic_machine=m68k-isi os=-sysv ;; + leon-*|leon[3-9]-*) + basic_machine=sparc-`echo $basic_machine | sed 's/-.*//'` + ;; m68knommu) basic_machine=m68k-unknown os=-linux @@ -1365,7 +1379,7 @@ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ | -sym* | -kopensolaris* | -plan9* \ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ - | -aos* | -aros* \ + | -aos* | -aros* | -cloudabi* | -sortix* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ diff -Nru radvd-2.16/configure radvd-2.17/configure --- radvd-2.16/configure 2017-02-20 14:49:14.000000000 +0000 +++ radvd-2.17/configure 2017-07-04 03:30:27.000000000 +0000 @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for radvd 2.16. +# Generated by GNU Autoconf 2.69 for radvd 2.17. # # # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. @@ -577,8 +577,8 @@ # Identity of this package. PACKAGE_NAME='radvd' PACKAGE_TARNAME='radvd' -PACKAGE_VERSION='2.16' -PACKAGE_STRING='radvd 2.16' +PACKAGE_VERSION='2.17' +PACKAGE_STRING='radvd 2.17' PACKAGE_BUGREPORT='' PACKAGE_URL='' @@ -726,6 +726,7 @@ docdir oldincludedir includedir +runstatedir localstatedir sharedstatedir sysconfdir @@ -811,6 +812,7 @@ sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' +runstatedir='${localstatedir}/run' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' @@ -1063,6 +1065,15 @@ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; + -runstatedir | --runstatedir | --runstatedi | --runstated \ + | --runstate | --runstat | --runsta | --runst | --runs \ + | --run | --ru | --r) + ac_prev=runstatedir ;; + -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \ + | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \ + | --run=* | --ru=* | --r=*) + runstatedir=$ac_optarg ;; + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ @@ -1200,7 +1211,7 @@ for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ - libdir localedir mandir + libdir localedir mandir runstatedir do eval ac_val=\$$ac_var # Remove trailing slashes. @@ -1313,7 +1324,7 @@ # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures radvd 2.16 to adapt to many kinds of systems. +\`configure' configures radvd 2.17 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1353,6 +1364,7 @@ --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] + --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] @@ -1384,7 +1396,7 @@ if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of radvd 2.16:";; + short | recursive ) echo "Configuration of radvd 2.17:";; esac cat <<\_ACEOF @@ -1500,7 +1512,7 @@ test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -radvd configure 2.16 +radvd configure 2.17 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -1865,7 +1877,7 @@ This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by radvd $as_me 2.16, which was +It was created by radvd $as_me 2.17, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -2840,7 +2852,7 @@ # Define the identity of the package. PACKAGE='radvd' - VERSION='2.16' + VERSION='2.17' cat >>confdefs.h <<_ACEOF @@ -6483,7 +6495,7 @@ # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by radvd $as_me 2.16, which was +This file was extended by radvd $as_me 2.17, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -6549,7 +6561,7 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -radvd config.status 2.16 +radvd config.status 2.17 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff -Nru radvd-2.16/configure.ac radvd-2.17/configure.ac --- radvd-2.16/configure.ac 2017-02-20 14:49:14.000000000 +0000 +++ radvd-2.17/configure.ac 2017-07-04 03:28:39.000000000 +0000 @@ -13,7 +13,7 @@ dnl dnl If adding rcX to version, be sure to separate with a '-' -AC_INIT(radvd, [2.16]) +AC_INIT(radvd, [2.17]) AC_CONFIG_SRCDIR(radvd.c) AC_CANONICAL_SYSTEM AM_INIT_AUTOMAKE diff -Nru radvd-2.16/debian/changelog radvd-2.17/debian/changelog --- radvd-2.16/debian/changelog 2017-06-08 20:06:46.000000000 +0000 +++ radvd-2.17/debian/changelog 2018-03-08 22:19:42.000000000 +0000 @@ -1,3 +1,11 @@ +radvd (1:2.17-1) unstable; urgency=medium + + * Moved to Salsa. Closes: #843502 + * New upstream release + * No changes for Standards-Version from 3.9.8 to 4.1.3 + + -- Geert Stappers Thu, 08 Mar 2018 23:19:42 +0100 + radvd (1:2.16-3) unstable; urgency=medium * Remove linux/if_arp.h from configure.ac Closes: #864269 diff -Nru radvd-2.16/debian/control radvd-2.17/debian/control --- radvd-2.16/debian/control 2017-06-05 12:37:54.000000000 +0000 +++ radvd-2.17/debian/control 2018-03-08 22:19:42.000000000 +0000 @@ -3,13 +3,14 @@ Priority: optional # Maintainer: Ghe Rivero https://bugs.debian.org/843502 Maintainer: Geert Stappers -Standards-Version: 3.9.8 +Standards-Version: 4.1.3 Build-Depends: dh-autoreconf, debhelper (>= 9), flex, bison, pkg-config, libdaemon-dev, check XS-Testsuite: autopkgtest -Vcs-Git: http://stappers.it/git/pkg-radvd +Vcs-Git: https://salsa.debian.org/debian/radvd +Vcs-Browser: https://salsa.debian.org/debian/radvd Homepage: http://www.litech.org/radvd/ Package: radvd diff -Nru radvd-2.16/debian/README.source radvd-2.17/debian/README.source --- radvd-2.16/debian/README.source 2017-02-20 15:48:27.000000000 +0000 +++ radvd-2.17/debian/README.source 2018-03-08 22:19:42.000000000 +0000 @@ -41,9 +41,9 @@ The maintenance more in shell commands - export VER=2.16 + export VER=2.18 uscan # does download and checks integrety - gbp import-orig ../radvd_${VER}.orig.tar.gz + gbp import-orig ../radvd_${VER}.orig.tar.xz ## the actual maintaince ## ... ## ... diff -Nru radvd-2.16/defaults.h radvd-2.17/defaults.h --- radvd-2.16/defaults.h 2017-02-20 14:49:14.000000000 +0000 +++ radvd-2.17/defaults.h 2017-07-02 01:59:02.000000000 +0000 @@ -20,144 +20,147 @@ #include "radvd.h" /* maximum message size for incoming and outgoing RSs and RAs */ -#define MSG_SIZE_RECV 1500 -#define MSG_SIZE_SEND 1452 -#define RFC2460_MIN_MTU 1280 /* RFC2460 5. Packet Size Issues: lowest valid MTU supported by IPv6 */ +#define MSG_SIZE_RECV 1500 +#define MSG_SIZE_SEND 1452 +#define RFC2460_MIN_MTU 1280 /* RFC2460 5. Packet Size Issues: lowest valid MTU supported by IPv6 */ -#define MAX2(X,Y) ( (( X ) >= ( Y )) ? ( X ) : ( Y )) +#define MAX2(X, Y) (((X) >= (Y)) ? (X) : (Y)) /* Router Configuration Variables: */ /* For each multicast interface: */ -#define DFLT_IgnoreIfMissing 1 -#define DFLT_AdvSendAdv 0 -#define DFLT_MaxRtrAdvInterval 600 -#define DFLT_MinRtrAdvInterval(iface) (0.33 * (iface)->MaxRtrAdvInterval) -#define DFLT_AdvManagedFlag 0 -#define DFLT_AdvOtherConfigFlag 0 -#define DFLT_AdvLinkMTU 0 -#define DFLT_AdvReachableTime 0 -#define DFLT_AdvRetransTimer 0 -#define DFLT_AdvCurHopLimit 64 /* as per RFC 1700 or the - next incarnation of it :) */ -#define DFLT_AdvDefaultLifetime(iface) MAX2(1, (int)(3.0 * (iface)->MaxRtrAdvInterval)) -#define DFLT_MinDelayBetweenRAs MIN_DELAY_BETWEEN_RAS -#define DFLT_AdvDefaultPreference 0 -#define DFLT_AdvRAMTU RFC2460_MIN_MTU +#define DFLT_IgnoreIfMissing 1 +#define DFLT_AdvSendAdv 0 +#define DFLT_MaxRtrAdvInterval 600 +#define DFLT_MinRtrAdvInterval(iface) (0.33 * (iface)->MaxRtrAdvInterval) +#define DFLT_AdvManagedFlag 0 +#define DFLT_AdvOtherConfigFlag 0 +#define DFLT_AdvLinkMTU 0 +#define DFLT_AdvReachableTime 0 +#define DFLT_AdvRetransTimer 0 +#define DFLT_AdvCurHopLimit \ + 64 /* as per RFC 1700 or the \ + next incarnation of it :) */ +#define DFLT_AdvDefaultLifetime(iface) MAX2(1, (int)(3.0 * (iface)->MaxRtrAdvInterval)) +#define DFLT_MinDelayBetweenRAs MIN_DELAY_BETWEEN_RAS +#define DFLT_AdvDefaultPreference 0 +#define DFLT_AdvRAMTU RFC2460_MIN_MTU +#define DFLT_UnicastOnly 0 +#define DFLT_AdvRASolicitedUnicast 1 /* Options sent with RA */ -#define DFLT_AdvSourceLLAddress 1 +#define DFLT_AdvSourceLLAddress 1 /* Each prefix has an associated: */ -#define DFLT_AdvValidLifetime 86400 /* seconds */ -#define DFLT_AdvOnLinkFlag 1 -#define DFLT_AdvPreferredLifetime 14400 /* seconds */ -#define DFLT_AdvAutonomousFlag 1 -#define DFLT_DeprecatePrefixFlag 0 -#define DFLT_DecrementLifetimesFlag 0 +#define DFLT_AdvValidLifetime 86400 /* seconds */ +#define DFLT_AdvOnLinkFlag 1 +#define DFLT_AdvPreferredLifetime 14400 /* seconds */ +#define DFLT_AdvAutonomousFlag 1 +#define DFLT_DeprecatePrefixFlag 0 +#define DFLT_DecrementLifetimesFlag 0 /* Each route has an associated: */ -#define DFLT_AdvRouteLifetime(iface) (3 * (iface)->MaxRtrAdvInterval) +#define DFLT_AdvRouteLifetime(iface) (3 * (iface)->MaxRtrAdvInterval) -#define DFLT_AdvRoutePreference 0 /* medium */ -#define DFLT_RemoveRouteFlag 1 +#define DFLT_AdvRoutePreference 0 /* medium */ +#define DFLT_RemoveRouteFlag 1 /* RDNSS */ -#define DFLT_AdvRDNSSLifetime(iface) (iface)->MaxRtrAdvInterval -#define DFLT_FlushRDNSSFlag 1 +#define DFLT_AdvRDNSSLifetime(iface) (iface)->MaxRtrAdvInterval +#define DFLT_FlushRDNSSFlag 1 /* DNSSL */ -#define DFLT_AdvDNSSLLifetime(iface) (iface)->MaxRtrAdvInterval -#define DFLT_FlushDNSSLFlag 1 +#define DFLT_AdvDNSSLLifetime(iface) (iface)->MaxRtrAdvInterval +#define DFLT_FlushDNSSLFlag 1 /* Protocol (RFC4861) constants: */ /* Router constants: */ -#define MAX_INITIAL_RTR_ADVERT_INTERVAL 16 -#define MAX_INITIAL_RTR_ADVERTISEMENTS 3 -#define MAX_FINAL_RTR_ADVERTISEMENTS 3 -#define MIN_DELAY_BETWEEN_RAS 3.0 -#define MIN_DELAY_BETWEEN_RAS_MIPv6 (30.0/1000.0) -#define MAX_RA_DELAY_SECONDS (0.5) +#define MAX_INITIAL_RTR_ADVERT_INTERVAL 16 +#define MAX_INITIAL_RTR_ADVERTISEMENTS 3 +#define MAX_FINAL_RTR_ADVERTISEMENTS 3 +#define MIN_DELAY_BETWEEN_RAS 3.0 +#define MIN_DELAY_BETWEEN_RAS_MIPv6 (30.0 / 1000.0) +#define MAX_RA_DELAY_SECONDS (0.5) /* Host constants: */ -#define MAX_RTR_SOLICITATION_DELAY 1 -#define RTR_SOLICITATION_INTERVAL 4 -#define MAX_RTR_SOLICITATIONS 3 +#define MAX_RTR_SOLICITATION_DELAY 1 +#define RTR_SOLICITATION_INTERVAL 4 +#define MAX_RTR_SOLICITATIONS 3 /* Node constants: */ -#define MAX_MULTICAST_SOLICIT 3 -#define MAX_UNICAST_SOLICIT 3 -#define MAX_ANYCAST_DELAY_TIME 1 -#define MAX_NEIGHBOR_ADVERTISEMENT 3 -#define REACHABLE_TIME 30000 /* milliseconds */ -#define RETRANS_TIMER 1000 /* milliseconds */ -#define DELAY_FIRST_PROBE_TIME 5 -#define MIN_RANDOM_FACTOR (1.0/2.0) -#define MAX_RANDOM_FACTOR (3.0/2.0) +#define MAX_MULTICAST_SOLICIT 3 +#define MAX_UNICAST_SOLICIT 3 +#define MAX_ANYCAST_DELAY_TIME 1 +#define MAX_NEIGHBOR_ADVERTISEMENT 3 +#define REACHABLE_TIME 30000 /* milliseconds */ +#define RETRANS_TIMER 1000 /* milliseconds */ +#define DELAY_FIRST_PROBE_TIME 5 +#define MIN_RANDOM_FACTOR (1.0 / 2.0) +#define MAX_RANDOM_FACTOR (3.0 / 2.0) /* MAX and MIN (RFC4861), Mobile IPv6 extensions will override if in use */ -#define MIN_MaxRtrAdvInterval 4 -#define MAX_MaxRtrAdvInterval 1800 +#define MIN_MaxRtrAdvInterval 4 +#define MAX_MaxRtrAdvInterval 1800 -#define MIN_MinRtrAdvInterval 3 -#define MAX_MinRtrAdvInterval(iface) (0.75 * (iface)->MaxRtrAdvInterval) +#define MIN_MinRtrAdvInterval 3 +#define MAX_MinRtrAdvInterval(iface) (0.75 * (iface)->MaxRtrAdvInterval) -#define MIN_AdvDefaultLifetime(iface) (MAX2(1,(iface)->MaxRtrAdvInterval)) -#define MAX_AdvDefaultLifetime 9000 +#define MIN_AdvDefaultLifetime(iface) (MAX2(1, (iface)->MaxRtrAdvInterval)) +#define MAX_AdvDefaultLifetime 9000 -#define MIN_AdvLinkMTU RFC2460_MIN_MTU -#define MAX_AdvLinkMTU 131072 +#define MIN_AdvLinkMTU RFC2460_MIN_MTU +#define MAX_AdvLinkMTU 131072 -#define MIN_AdvRAMTU MIN_AdvLinkMTU -#define MAX_AdvRAMTU MAX_AdvLinkMTU +#define MIN_AdvRAMTU MIN_AdvLinkMTU +#define MAX_AdvRAMTU MAX_AdvLinkMTU -#define MIN_AdvReachableTime 100 -#define MAX_AdvReachableTime 3600000 /* 1 hour in milliseconds */ +#define MIN_AdvReachableTime 100 +#define MAX_AdvReachableTime 3600000 /* 1 hour in milliseconds */ -#define MIN_AdvRetransTimer 10 -#define MAX_AdvRetransTimer 3600000 +#define MIN_AdvRetransTimer 10 +#define MAX_AdvRetransTimer 3600000 -#define MIN_AdvCurHopLimit 2 -#define MAX_AdvCurHopLimit 255 +#define MIN_AdvCurHopLimit 2 +#define MAX_AdvCurHopLimit 255 -#define MAX_PrefixLen 128 +#define MAX_PrefixLen 128 /* SLAAC (RFC4862) Constants and Derived Values */ -#define MIN_AdvValidLifetime 7200 /* 2 hours in secs */ +#define MIN_AdvValidLifetime 7200 /* 2 hours in secs */ /* * Mobile IPv6 extensions, off by default */ -#define DFLT_AdvRouterAddr 0 -#define DFLT_AdvHomeAgentFlag 0 -#define DFLT_AdvIntervalOpt 0 -#define DFLT_AdvHomeAgentInfo 0 +#define DFLT_AdvRouterAddr 0 +#define DFLT_AdvHomeAgentFlag 0 +#define DFLT_AdvIntervalOpt 0 +#define DFLT_AdvHomeAgentInfo 0 /* Option types (defined also at least in glibc 2.2's netinet/icmp6.h) */ #ifndef ND_OPT_RTR_ADV_INTERVAL -#define ND_OPT_RTR_ADV_INTERVAL 7 +#define ND_OPT_RTR_ADV_INTERVAL 7 #endif #ifndef ND_OPT_HOME_AGENT_INFO -#define ND_OPT_HOME_AGENT_INFO 8 +#define ND_OPT_HOME_AGENT_INFO 8 #endif /* de-facto codepoint used by many implementations was '9', the official IANA assignment is '24' */ #undef ND_OPT_ROUTE_INFORMATION -#define ND_OPT_ROUTE_INFORMATION 24 +#define ND_OPT_ROUTE_INFORMATION 24 /* XXX: some libc's like KAME already had nd_opt_route_info! */ -struct nd_opt_route_info_local { /* route information */ +struct nd_opt_route_info_local { /* route information */ uint8_t nd_opt_ri_type; uint8_t nd_opt_ri_len; uint8_t nd_opt_ri_prefix_len; @@ -167,11 +170,11 @@ }; /* the reserved field is 8 bits and we're interested of the middle two: 000xx000 */ -#define ND_OPT_RI_PRF_SHIFT 3 -#define ND_OPT_RI_PRF_MASK (3 << ND_OPT_RI_PRF_SHIFT) /* 00011000 = 0x18 */ +#define ND_OPT_RI_PRF_SHIFT 3 +#define ND_OPT_RI_PRF_MASK (3 << ND_OPT_RI_PRF_SHIFT) /* 00011000 = 0x18 */ #undef ND_OPT_RDNSS_INFORMATION -#define ND_OPT_RDNSS_INFORMATION 25 +#define ND_OPT_RDNSS_INFORMATION 25 /* */ struct nd_opt_rdnss_info_local { @@ -185,14 +188,14 @@ }; /* pref/flag/reserved field : yyyyx00000000000 (big endian) - 00000000yyyyx000 (little indian); where yyyy = pref, x = flag */ #if BYTE_ORDER == BIG_ENDIAN -#define ND_OPT_RDNSSI_PREF_SHIFT 12 +#define ND_OPT_RDNSSI_PREF_SHIFT 12 #else -#define ND_OPT_RDNSSI_PREF_SHIFT 4 +#define ND_OPT_RDNSSI_PREF_SHIFT 4 #endif -#define ND_OPT_RDNSSI_PREF_MASK (0xf << ND_OPT_RDNSSI_PREF_SHIFT) +#define ND_OPT_RDNSSI_PREF_MASK (0xf << ND_OPT_RDNSSI_PREF_SHIFT) #undef ND_OPT_DNSSL_INFORMATION -#define ND_OPT_DNSSL_INFORMATION 31 +#define ND_OPT_DNSSL_INFORMATION 31 /* */ struct nd_opt_dnssl_info_local { @@ -206,48 +209,48 @@ /* Flags */ #ifndef ND_RA_FLAG_HOME_AGENT -#define ND_RA_FLAG_HOME_AGENT 0x20 +#define ND_RA_FLAG_HOME_AGENT 0x20 #endif #ifndef ND_OPT_PI_FLAG_RADDR -#define ND_OPT_PI_FLAG_RADDR 0x20 +#define ND_OPT_PI_FLAG_RADDR 0x20 #endif #ifndef ND_OPT_RDNSSI_FLAG_S #if BYTE_ORDER == BIG_ENDIAN -#define ND_OPT_RDNSSI_FLAG_S 0x0800 +#define ND_OPT_RDNSSI_FLAG_S 0x0800 #else -#define ND_OPT_RDNSSI_FLAG_S 0x0008 +#define ND_OPT_RDNSSI_FLAG_S 0x0008 #endif #endif /* Configurable values */ -#define DFLT_HomeAgentPreference 0 -#define DFLT_HomeAgentLifetime(iface) ((iface)->ra_header_info.AdvDefaultLifetime) +#define DFLT_HomeAgentPreference 0 +#define DFLT_HomeAgentLifetime(iface) ((iface)->ra_header_info.AdvDefaultLifetime) /* Other */ -#define MIN_MinRtrAdvInterval_MIPv6 (3.0/100.0) -#define MIN_MaxRtrAdvInterval_MIPv6 (7.0/100.0) -#define RTR_SOLICITATION_INTERVAL_MIPv6 1 /* Recommended value by MIPv6 */ +#define MIN_MinRtrAdvInterval_MIPv6 (3.0 / 100.0) +#define MIN_MaxRtrAdvInterval_MIPv6 (7.0 / 100.0) +#define RTR_SOLICITATION_INTERVAL_MIPv6 1 /* Recommended value by MIPv6 */ -#define Cautious_MaxRtrAdvInterval (2.0/10.0) -#define Cautious_MaxRtrAdvInterval_Leeway (2.0/100.0) +#define Cautious_MaxRtrAdvInterval (2.0 / 10.0) +#define Cautious_MaxRtrAdvInterval_Leeway (2.0 / 100.0) -#define MIN_HomeAgentLifetime 1 /* 0 must NOT be used */ -#define MAX_HomeAgentLifetime 65520 /* 18.2 hours in secs */ +#define MIN_HomeAgentLifetime 1 /* 0 must NOT be used */ +#define MAX_HomeAgentLifetime 65520 /* 18.2 hours in secs */ /* #define MAX_RTR_SOLICITATIONS This MAY be ignored by MIPv6 */ /* NEMO extensions, off by default */ -#define DFLT_AdvMobRtrSupportFlag 0 +#define DFLT_AdvMobRtrSupportFlag 0 /* Flags */ #ifndef ND_OPT_HAI_FLAG_SUPPORT_MR #if BYTE_ORDER == BIG_ENDIAN -#define ND_OPT_HAI_FLAG_SUPPORT_MR 0x8000 -#else /* BYTE_ORDER == LITTLE_ENDIAN */ -#define ND_OPT_HAI_FLAG_SUPPORT_MR 0x0080 +#define ND_OPT_HAI_FLAG_SUPPORT_MR 0x8000 +#else /* BYTE_ORDER == LITTLE_ENDIAN */ +#define ND_OPT_HAI_FLAG_SUPPORT_MR 0x0080 #endif #endif diff -Nru radvd-2.16/device-bsd44.c radvd-2.17/device-bsd44.c --- radvd-2.16/device-bsd44.c 2017-02-20 14:49:14.000000000 +0000 +++ radvd-2.17/device-bsd44.c 2017-06-29 04:32:29.000000000 +0000 @@ -13,9 +13,9 @@ */ #include "config.h" +#include "defaults.h" #include "includes.h" #include "radvd.h" -#include "defaults.h" /* * this function gets the hardware type and address of an interface, @@ -49,7 +49,7 @@ goto ret; } - for (struct ifaddrs * ifa = addresses; ifa != NULL; ifa = ifa->ifa_next) { + for (struct ifaddrs *ifa = addresses; ifa != NULL; ifa = ifa->ifa_next) { if (strcmp(ifa->ifa_name, iface->props.name) != 0) continue; @@ -101,7 +101,8 @@ struct AdvPrefix *prefix = iface->AdvPrefixList; while (prefix) { if ((iface->sllao.if_prefix_len != -1) && (iface->sllao.if_prefix_len != prefix->PrefixLen)) { - flog(LOG_WARNING, "prefix length should be %d for %s", iface->sllao.if_prefix_len, iface->props.name); + flog(LOG_WARNING, "prefix length should be %d for %s", iface->sllao.if_prefix_len, + iface->props.name); } prefix = prefix->next; @@ -114,7 +115,7 @@ return 0; } - ret: +ret: iface->sllao.if_maxmtu = -1; iface->sllao.if_hwaddr_len = -1; iface->sllao.if_prefix_len = -1; @@ -125,10 +126,7 @@ return -1; } -int setup_allrouters_membership(int sock, struct Interface *iface) -{ - return 0; -} +int setup_allrouters_membership(int sock, struct Interface *iface) { return 0; } int set_interface_linkmtu(const char *iface, uint32_t mtu) { diff -Nru radvd-2.16/device-common.c radvd-2.17/device-common.c --- radvd-2.16/device-common.c 2017-02-20 14:49:14.000000000 +0000 +++ radvd-2.17/device-common.c 2017-06-29 04:32:29.000000000 +0000 @@ -13,10 +13,10 @@ */ #include "config.h" -#include "includes.h" -#include "radvd.h" #include "defaults.h" +#include "includes.h" #include "pathnames.h" +#include "radvd.h" int check_device(int sock, struct Interface *iface) { @@ -87,11 +87,7 @@ return 0; } - -static int cmp_iface_addrs(void const *a, void const *b) -{ - return memcmp(a, b, sizeof(struct in6_addr)); -} +static int cmp_iface_addrs(void const *a, void const *b) { return memcmp(a, b, sizeof(struct in6_addr)); } /* * Return first IPv6 link local addr in if_addr. @@ -111,7 +107,7 @@ if (getifaddrs(&addresses) != 0) { flog(LOG_ERR, "getifaddrs failed on %s: %s", name, strerror(errno)); } else { - for (struct ifaddrs * ifa = addresses; ifa != NULL; ifa = ifa->ifa_next) { + for (struct ifaddrs *ifa = addresses; ifa != NULL; ifa = ifa->ifa_next) { if (!ifa->ifa_addr) continue; @@ -125,11 +121,11 @@ if (strcmp(ifa->ifa_name, name) != 0) continue; - *if_addrs = realloc(*if_addrs, (i+1) * sizeof(struct in6_addr)); + *if_addrs = realloc(*if_addrs, (i + 1) * sizeof(struct in6_addr)); (*if_addrs)[i++] = a6->sin6_addr; /* Skip if it is not a linklocal address or link locak address already found*/ - uint8_t const ll_prefix[] = { 0xfe, 0x80, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }; + uint8_t const ll_prefix[] = {0xfe, 0x80, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}; if (link_local_set || 0 != memcmp(&(a6->sin6_addr), ll_prefix, sizeof(ll_prefix))) continue; @@ -144,7 +140,7 @@ freeifaddrs(addresses); /* last item in the list is all zero (unspecified) address */ - *if_addrs = realloc(*if_addrs, (i+1) * sizeof(struct in6_addr)); + *if_addrs = realloc(*if_addrs, (i + 1) * sizeof(struct in6_addr)); memset(&(*if_addrs)[i], 0, sizeof(struct in6_addr)); /* Sort the addresses so the output is predictable. */ @@ -156,7 +152,6 @@ return i; } - /* * Saves the first link local address seen on the specified interface to iface->if_addr * and builds a list of all the other addrs. @@ -175,9 +170,9 @@ dlog(LOG_DEBUG, 4, "%s address: %s", iface->props.name, addr_str); } /* AdvRASrcAddress: allow operator selection of RA source address */ - if(iface->AdvRASrcAddressList != NULL) { + if (iface->AdvRASrcAddressList != NULL) { iface->props.if_addr_rasrc = NULL; - for (struct AdvRASrcAddress * current = iface->AdvRASrcAddressList; current; current = current->next) { + for (struct AdvRASrcAddress *current = iface->AdvRASrcAddressList; current; current = current->next) { for (int i = 0; i < iface->props.addrs_count; i++) { struct in6_addr cmp_addr = iface->props.if_addrs[i]; if (0 == memcmp(&cmp_addr, ¤t->address, sizeof(struct in6_addr))) { @@ -187,7 +182,7 @@ break; } } - if(NULL != iface->props.if_addr_rasrc) + if (NULL != iface->props.if_addr_rasrc) break; } } else { @@ -221,4 +216,3 @@ return 0; } - diff -Nru radvd-2.16/device-linux.c radvd-2.17/device-linux.c --- radvd-2.16/device-linux.c 2017-02-20 14:49:14.000000000 +0000 +++ radvd-2.17/device-linux.c 2017-06-29 04:32:29.000000000 +0000 @@ -13,18 +13,18 @@ */ #include "config.h" -#include "includes.h" -#include "radvd.h" #include "defaults.h" -#include "pathnames.h" +#include "includes.h" #include "netlink.h" +#include "pathnames.h" +#include "radvd.h" #ifndef IPV6_ADDR_LINKLOCAL -#define IPV6_ADDR_LINKLOCAL 0x0020U +#define IPV6_ADDR_LINKLOCAL 0x0020U #endif #ifndef ARPHRD_6LOWPAN -#define ARPHRD_6LOWPAN 825 /* IPv6 over LoWPAN */ +#define ARPHRD_6LOWPAN 825 /* IPv6 over LoWPAN */ #endif static char const *hwstr(unsigned short sa_family); @@ -62,7 +62,8 @@ */ iface->props.max_ra_option_size = iface->AdvRAMTU; iface->props.max_ra_option_size = MIN(iface->props.max_ra_option_size, MAX(iface->sllao.if_maxmtu, RFC2460_MIN_MTU)); - iface->props.max_ra_option_size = MIN(iface->props.max_ra_option_size, MAX(get_interface_linkmtu(iface->props.name), RFC2460_MIN_MTU)); + iface->props.max_ra_option_size = + MIN(iface->props.max_ra_option_size, MAX(get_interface_linkmtu(iface->props.name), RFC2460_MIN_MTU)); if (ioctl(sock, SIOCGIFHWADDR, &ifr) < 0) { flog(LOG_ERR, "ioctl(SIOCGIFHWADDR) failed on %s: %s", iface->props.name, strerror(errno)); @@ -75,16 +76,11 @@ case ARPHRD_ETHER: iface->sllao.if_hwaddr_len = 48; iface->sllao.if_prefix_len = 64; - /* *INDENT-OFF* */ char hwaddr[3 * 6]; - sprintf(hwaddr, "%02x:%02x:%02x:%02x:%02x:%02x", - (unsigned char)ifr.ifr_hwaddr.sa_data[0], - (unsigned char)ifr.ifr_hwaddr.sa_data[1], - (unsigned char)ifr.ifr_hwaddr.sa_data[2], - (unsigned char)ifr.ifr_hwaddr.sa_data[3], - (unsigned char)ifr.ifr_hwaddr.sa_data[4], + sprintf(hwaddr, "%02x:%02x:%02x:%02x:%02x:%02x", (unsigned char)ifr.ifr_hwaddr.sa_data[0], + (unsigned char)ifr.ifr_hwaddr.sa_data[1], (unsigned char)ifr.ifr_hwaddr.sa_data[2], + (unsigned char)ifr.ifr_hwaddr.sa_data[3], (unsigned char)ifr.ifr_hwaddr.sa_data[4], (unsigned char)ifr.ifr_hwaddr.sa_data[5]); - /* *INDENT-ON* */ dlog(LOG_DEBUG, 3, "%s hardware address: %s", iface->props.name, hwaddr); iface->props.max_ra_option_size -= 14; /* RFC 2464 */ break; @@ -94,7 +90,7 @@ iface->sllao.if_prefix_len = 64; iface->props.max_ra_option_size -= 22; /* RFC 2109 */ break; -#endif /* ARPHDR_FDDI */ +#endif /* ARPHDR_FDDI */ #ifdef ARPHRD_ARCNET case ARPHRD_ARCNET: iface->sllao.if_hwaddr_len = 8; @@ -104,7 +100,7 @@ * native packet size is 256-512 bytes */ iface->props.max_ra_option_size -= 0; break; -#endif /* ARPHDR_ARCNET */ +#endif /* ARPHDR_ARCNET */ case ARPHRD_6LOWPAN: #ifdef HAVE_NETLINK /* hwaddr length differs on some L2 type lets detect them */ @@ -206,34 +202,22 @@ } fclose(fp); } else { - flog(LOG_DEBUG, - "Correct IPv6 MTU entry not found, " "perhaps the procfs is disabled, " - "or the kernel interface has changed?"); + flog(LOG_DEBUG, "Correct IPv6 MTU entry not found, " + "perhaps the procfs is disabled, " + "or the kernel interface has changed?"); value = 1280; /* RFC2460: section 5 */ } return value; } -int set_interface_linkmtu(const char *iface, uint32_t mtu) -{ - return privsep_interface_linkmtu(iface, mtu); -} +int set_interface_linkmtu(const char *iface, uint32_t mtu) { return privsep_interface_linkmtu(iface, mtu); } -int set_interface_curhlim(const char *iface, uint8_t hlim) -{ - return privsep_interface_curhlim(iface, hlim); -} +int set_interface_curhlim(const char *iface, uint8_t hlim) { return privsep_interface_curhlim(iface, hlim); } -int set_interface_reachtime(const char *iface, uint32_t rtime) -{ - return privsep_interface_reachtime(iface, rtime); -} +int set_interface_reachtime(const char *iface, uint32_t rtime) { return privsep_interface_reachtime(iface, rtime); } -int set_interface_retranstimer(const char *iface, uint32_t rettimer) -{ - return privsep_interface_retranstimer(iface, rettimer); -} +int set_interface_retranstimer(const char *iface, uint32_t rettimer) { return privsep_interface_retranstimer(iface, rettimer); } int check_ip6_forwarding(void) { @@ -249,19 +233,19 @@ } fclose(fp); } else { - flog(LOG_DEBUG, - "Correct IPv6 forwarding procfs entry not found, " "perhaps the procfs is disabled, " - "or the kernel interface has changed?"); + flog(LOG_DEBUG, "Correct IPv6 forwarding procfs entry not found, " + "perhaps the procfs is disabled, " + "or the kernel interface has changed?"); value = -1; } #ifdef HAVE_SYSCTL - int forw_sysctl[] = { SYSCTL_IP6_FORWARDING }; + int forw_sysctl[] = {SYSCTL_IP6_FORWARDING}; size_t size = sizeof(value); if (!fp && sysctl(forw_sysctl, sizeof(forw_sysctl) / sizeof(forw_sysctl[0]), &value, &size, NULL, 0) < 0) { - flog(LOG_DEBUG, - "Correct IPv6 forwarding sysctl branch not found, " "perhaps the kernel interface has changed?"); - return 0; /* this is of advisory value only */ + flog(LOG_DEBUG, "Correct IPv6 forwarding sysctl branch not found, " + "perhaps the kernel interface has changed?"); + return 0; /* this is of advisory value only */ } #endif diff -Nru radvd-2.16/gram.y radvd-2.17/gram.y --- radvd-2.16/gram.y 2017-02-20 14:49:14.000000000 +0000 +++ radvd-2.17/gram.y 2017-07-02 01:59:02.000000000 +0000 @@ -92,6 +92,7 @@ %token T_Base6Interface %token T_Base6to4Interface %token T_UnicastOnly +%token T_AdvRASolicitedUnicast %token T_HomeAgentPreference %token T_HomeAgentLifetime @@ -332,6 +333,10 @@ { iface->UnicastOnly = $2; } + | T_AdvRASolicitedUnicast SWITCH ';' + { + iface->AdvRASolicitedUnicast = $2; + } | T_AdvMobRtrSupportFlag SWITCH ';' { iface->mipv6.AdvMobRtrSupportFlag = $2; diff -Nru radvd-2.16/includes.h radvd-2.17/includes.h --- radvd-2.16/includes.h 2017-02-20 14:49:14.000000000 +0000 +++ radvd-2.17/includes.h 2017-06-29 04:32:29.000000000 +0000 @@ -16,19 +16,19 @@ #include "config.h" -#include -#include +#include +#include +#include +#include +#include #include -#include #include -#include +#include +#include +#include #include +#include #include -#include -#include -#include -#include -#include #include #ifdef HAVE_INTTYPES_H @@ -62,13 +62,13 @@ #include #include -#include #include +#include #include -#include #include +#include #include @@ -86,9 +86,9 @@ #include #endif -#if defined(HAVE_NET_IF_ARP_H) && !defined(ARPHRD_ETHER) +#if defined(HAVE_NET_IF_ARP_H) && !defined(ARPHRD_ETHER) && !defined(HAVE_LINUX_IF_ARP_H) #include -#endif /* defined(HAVE_NET_IF_ARP_H) && !defined(ARPHRD_ETHER) */ +#endif /* defined(HAVE_NET_IF_ARP_H) && !defined(ARPHRD_ETHER) */ #ifdef HAVE_SYS_SOCKIO_H #include @@ -105,4 +105,3 @@ #ifdef HAVE_LINUX_IF_ARP_H #include #endif - diff -Nru radvd-2.16/install-sh radvd-2.17/install-sh --- radvd-2.16/install-sh 2017-02-20 14:49:14.000000000 +0000 +++ radvd-2.17/install-sh 2017-07-04 03:30:28.000000000 +0000 @@ -1,7 +1,7 @@ #!/bin/sh # install - install a program, script, or datafile -scriptversion=2013-12-25.23; # UTC +scriptversion=2014-09-12.12; # UTC # This originates from X11R5 (mit/util/scripts/install.sh), which was # later released in X11R6 (xc/config/util/install.sh) with the @@ -324,34 +324,41 @@ # is incompatible with FreeBSD 'install' when (umask & 300) != 0. ;; *) + # $RANDOM is not portable (e.g. dash); use it when possible to + # lower collision chance tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ - trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 + trap 'ret=$?; rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" 2>/dev/null; exit $ret' 0 + # As "mkdir -p" follows symlinks and we work in /tmp possibly; so + # create the $tmpdir first (and fail if unsuccessful) to make sure + # that nobody tries to guess the $tmpdir name. if (umask $mkdir_umask && - exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1 + $mkdirprog $mkdir_mode "$tmpdir" && + exec $mkdirprog $mkdir_mode -p -- "$tmpdir/a/b") >/dev/null 2>&1 then if test -z "$dir_arg" || { # Check for POSIX incompatibilities with -m. # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or # other-writable bit of parent directory when it shouldn't. # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. - ls_ld_tmpdir=`ls -ld "$tmpdir"` + test_tmpdir="$tmpdir/a" + ls_ld_tmpdir=`ls -ld "$test_tmpdir"` case $ls_ld_tmpdir in d????-?r-*) different_mode=700;; d????-?--*) different_mode=755;; *) false;; esac && - $mkdirprog -m$different_mode -p -- "$tmpdir" && { - ls_ld_tmpdir_1=`ls -ld "$tmpdir"` + $mkdirprog -m$different_mode -p -- "$test_tmpdir" && { + ls_ld_tmpdir_1=`ls -ld "$test_tmpdir"` test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" } } then posix_mkdir=: fi - rmdir "$tmpdir/d" "$tmpdir" + rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" else # Remove any dirs left behind by ancient mkdir implementations. - rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null + rmdir ./$mkdir_mode ./-p ./-- "$tmpdir" 2>/dev/null fi trap '' 0;; esac;; diff -Nru radvd-2.16/interface.c radvd-2.17/interface.c --- radvd-2.16/interface.c 2017-02-20 14:49:14.000000000 +0000 +++ radvd-2.17/interface.c 2017-07-02 01:59:02.000000000 +0000 @@ -13,11 +13,11 @@ */ #include "config.h" +#include "defaults.h" #include "includes.h" #include "radvd.h" -#include "defaults.h" -#define IFACE_SETUP_DELAY 1 +#define IFACE_SETUP_DELAY 1 void iface_init_defaults(struct Interface *iface) { @@ -31,6 +31,8 @@ iface->AdvSourceLLAddress = DFLT_AdvSourceLLAddress; iface->MinDelayBetweenRAs = DFLT_MinDelayBetweenRAs; iface->MinRtrAdvInterval = -1; + iface->UnicastOnly = DFLT_UnicastOnly; + iface->AdvRASolicitedUnicast = DFLT_AdvRASolicitedUnicast; iface->ra_header_info.AdvDefaultPreference = DFLT_AdvDefaultPreference; iface->ra_header_info.AdvDefaultLifetime = -1; @@ -47,11 +49,9 @@ iface->AdvLinkMTU = DFLT_AdvLinkMTU; iface->AdvRAMTU = DFLT_AdvRAMTU; - } - -void touch_iface(struct Interface * iface) +void touch_iface(struct Interface *iface) { iface->state_info.changed = 1; iface->state_info.ready = 0; @@ -92,7 +92,7 @@ } /* Check if we a usable RA source address */ - if(iface->props.if_addr_rasrc == NULL) { + if (iface->props.if_addr_rasrc == NULL) { dlog(LOG_DEBUG, 5, "no configured AdvRASrcAddress present, skipping send"); return -1; } @@ -175,34 +175,31 @@ if (iface->MinRtrAdvInterval < 0) iface->MinRtrAdvInterval = DFLT_MinRtrAdvInterval(iface); - if ((iface->MinRtrAdvInterval < (MIPv6 ? MIN_MinRtrAdvInterval_MIPv6 : MIN_MinRtrAdvInterval)) - || (iface->MinRtrAdvInterval > MAX_MinRtrAdvInterval(iface))) { + if ((iface->MinRtrAdvInterval < (MIPv6 ? MIN_MinRtrAdvInterval_MIPv6 : MIN_MinRtrAdvInterval)) || + (iface->MinRtrAdvInterval > MAX_MinRtrAdvInterval(iface))) { flog(LOG_ERR, "MinRtrAdvInterval for %s (%.2f) must be at least %.2f but no more than 3/4 of MaxRtrAdvInterval (%.2f)", - iface->props.name, iface->MinRtrAdvInterval, MIPv6 ? MIN_MinRtrAdvInterval_MIPv6 : (int)MIN_MinRtrAdvInterval, - MAX_MinRtrAdvInterval(iface)); + iface->props.name, iface->MinRtrAdvInterval, + MIPv6 ? MIN_MinRtrAdvInterval_MIPv6 : (int)MIN_MinRtrAdvInterval, MAX_MinRtrAdvInterval(iface)); res = -1; } - if ((iface->MaxRtrAdvInterval < (MIPv6 ? MIN_MaxRtrAdvInterval_MIPv6 : MIN_MaxRtrAdvInterval)) - || (iface->MaxRtrAdvInterval > MAX_MaxRtrAdvInterval)) { - flog(LOG_ERR, - "MaxRtrAdvInterval for %s (%.2f) must be between %.2f and %d", - iface->props.name, iface->MaxRtrAdvInterval, MIPv6 ? MIN_MaxRtrAdvInterval_MIPv6 : (int)MIN_MaxRtrAdvInterval, + if ((iface->MaxRtrAdvInterval < (MIPv6 ? MIN_MaxRtrAdvInterval_MIPv6 : MIN_MaxRtrAdvInterval)) || + (iface->MaxRtrAdvInterval > MAX_MaxRtrAdvInterval)) { + flog(LOG_ERR, "MaxRtrAdvInterval for %s (%.2f) must be between %.2f and %d", iface->props.name, + iface->MaxRtrAdvInterval, MIPv6 ? MIN_MaxRtrAdvInterval_MIPv6 : (int)MIN_MaxRtrAdvInterval, MAX_MaxRtrAdvInterval); res = -1; } if (iface->MinDelayBetweenRAs < (MIPv6 ? MIN_DELAY_BETWEEN_RAS_MIPv6 : MIN_DELAY_BETWEEN_RAS)) { - flog(LOG_ERR, - "MinDelayBetweenRAs for %s (%.2f) must be at least %.2f", iface->props.name, iface->MinDelayBetweenRAs, - MIPv6 ? MIN_DELAY_BETWEEN_RAS_MIPv6 : MIN_DELAY_BETWEEN_RAS); + flog(LOG_ERR, "MinDelayBetweenRAs for %s (%.2f) must be at least %.2f", iface->props.name, + iface->MinDelayBetweenRAs, MIPv6 ? MIN_DELAY_BETWEEN_RAS_MIPv6 : MIN_DELAY_BETWEEN_RAS); res = -1; } - if ((iface->AdvLinkMTU != 0) - && ((iface->AdvLinkMTU < MIN_AdvLinkMTU) - || (iface->sllao.if_maxmtu != -1 && (iface->AdvLinkMTU > iface->sllao.if_maxmtu)))) { + if ((iface->AdvLinkMTU != 0) && ((iface->AdvLinkMTU < MIN_AdvLinkMTU) || + (iface->sllao.if_maxmtu != -1 && (iface->AdvLinkMTU > iface->sllao.if_maxmtu)))) { flog(LOG_ERR, "AdvLinkMTU for %s (%u) must be zero or between %u and %u", iface->props.name, iface->AdvLinkMTU, MIN_AdvLinkMTU, iface->sllao.if_maxmtu); res = -1; @@ -217,9 +214,9 @@ if (iface->ra_header_info.AdvDefaultLifetime < 0) iface->ra_header_info.AdvDefaultLifetime = DFLT_AdvDefaultLifetime(iface); - if ((iface->ra_header_info.AdvDefaultLifetime != 0) - && ((iface->ra_header_info.AdvDefaultLifetime > MAX_AdvDefaultLifetime) - || (iface->ra_header_info.AdvDefaultLifetime < MIN_AdvDefaultLifetime(iface)))) { + if ((iface->ra_header_info.AdvDefaultLifetime != 0) && + ((iface->ra_header_info.AdvDefaultLifetime > MAX_AdvDefaultLifetime) || + (iface->ra_header_info.AdvDefaultLifetime < MIN_AdvDefaultLifetime(iface)))) { flog(LOG_ERR, "AdvDefaultLifetime for %s (%u) must be zero or between %u and %u", iface->props.name, iface->ra_header_info.AdvDefaultLifetime, (int)MIN_AdvDefaultLifetime(iface), MAX_AdvDefaultLifetime); res = -1; @@ -231,9 +228,9 @@ /* Mobile IPv6 ext */ if (iface->mipv6.AdvHomeAgentInfo) { - if ((iface->mipv6.HomeAgentLifetime > MAX_HomeAgentLifetime) || (iface->mipv6.HomeAgentLifetime < MIN_HomeAgentLifetime)) { - flog(LOG_ERR, - "HomeAgentLifetime for %s (%u) must be between %u and %u", iface->props.name, + if ((iface->mipv6.HomeAgentLifetime > MAX_HomeAgentLifetime) || + (iface->mipv6.HomeAgentLifetime < MIN_HomeAgentLifetime)) { + flog(LOG_ERR, "HomeAgentLifetime for %s (%u) must be between %u and %u", iface->props.name, iface->mipv6.HomeAgentLifetime, MIN_HomeAgentLifetime, MAX_HomeAgentLifetime); res = -1; } @@ -258,7 +255,8 @@ } if (prefix->AdvPreferredLifetime > prefix->AdvValidLifetime) { - flog(LOG_ERR, "AdvValidLifetime for %s (%u) must be " "greater than AdvPreferredLifetime for", + flog(LOG_ERR, "AdvValidLifetime for %s (%u) must be " + "greater than AdvPreferredLifetime for", iface->props.name, prefix->AdvValidLifetime); res = -1; } @@ -284,12 +282,14 @@ * AdvDefaultLifetime > 0 && route.AdvRouteLifetime == 0: * - default route is added and then deleted. */ - if(IN6_IS_ADDR_UNSPECIFIED(&(route->Prefix))) { + if (IN6_IS_ADDR_UNSPECIFIED(&(route->Prefix))) { int route_zerolife = (route->AdvRouteLifetime == 0); int defaultroute_zerolife = (iface->ra_header_info.AdvDefaultLifetime == 0); - if( route_zerolife ^ defaultroute_zerolife ) { - flog(LOG_ERR, "route 0::/0 lifetime (%u) conflicts with AdvDefaultLifetime (%u), default routes will flap!", - route->AdvRouteLifetime, iface->ra_header_info.AdvDefaultLifetime); + if (route_zerolife ^ defaultroute_zerolife) { + flog( + LOG_ERR, + "route 0::/0 lifetime (%u) conflicts with AdvDefaultLifetime (%u), default routes will flap!", + route->AdvRouteLifetime, iface->ra_header_info.AdvDefaultLifetime); // res = -1; // In some future version, abort on this configuration error. } } @@ -355,7 +355,7 @@ next = IFACE_SETUP_DELAY; } else #endif - if (iface->state_info.racount < MAX_INITIAL_RTR_ADVERTISEMENTS) { + if (iface->state_info.racount < MAX_INITIAL_RTR_ADVERTISEMENTS) { next = min(MAX_INITIAL_RTR_ADVERT_INTERVAL, iface->MaxRtrAdvInterval); } @@ -364,7 +364,7 @@ iface->times.next_multicast = next_timespec(next); } -void for_each_iface(struct Interface *ifaces, void (*foo) (struct Interface *, void *), void *data) +void for_each_iface(struct Interface *ifaces, void (*foo)(struct Interface *, void *), void *data) { for (; ifaces; ifaces = ifaces->next) { foo(ifaces, data); diff -Nru radvd-2.16/log.c radvd-2.17/log.c --- radvd-2.16/log.c 2017-02-20 14:49:14.000000000 +0000 +++ radvd-2.17/log.c 2017-06-29 04:54:44.000000000 +0000 @@ -16,8 +16,7 @@ #include "includes.h" #include "radvd.h" -__attribute__ ((format(printf, 2, 0))) -static int vlog(int prio, char const *format, va_list ap); +__attribute__((format(printf, 2, 0))) static int vlog(int prio, char const *format, va_list ap); static int log_method = L_NONE; static char const *log_ident; @@ -36,9 +35,9 @@ case L_STDERR: break; case L_STDERR_CLEAN: - /* fallthrough */ + /* fallthrough */ case L_STDERR_SYSLOG: - /* fallthrough */ + /* fallthrough */ case L_SYSLOG: if (facility == -1) log_facility = LOG_DAEMON; @@ -67,8 +66,7 @@ } /* note: [dfv]log() is also called from root context */ -__attribute__ ((format(printf, 2, 0))) -static int vlog(int prio, char const *format, va_list ap) +__attribute__((format(printf, 2, 0))) static int vlog(int prio, char const *format, va_list ap) { char tstamp[64], buff[1024]; struct tm *tm; @@ -84,7 +82,7 @@ break; case L_STDERR_SYSLOG: syslog(prio, "%s", buff); - if (prio > LOG_ERR) /* fall through for messages with high priority */ + if (debug_level < prio) /* fall through for messages with high priority */ break; case L_STDERR: current = time(NULL); @@ -155,12 +153,6 @@ return 0; } -void set_debuglevel(int level) -{ - debug_level = level; -} +void set_debuglevel(int level) { debug_level = level; } -int get_debuglevel(void) -{ - return debug_level; -} +int get_debuglevel(void) { return debug_level; } diff -Nru radvd-2.16/log.h radvd-2.17/log.h --- radvd-2.16/log.h 2017-02-20 14:49:14.000000000 +0000 +++ radvd-2.17/log.h 2017-06-29 04:32:29.000000000 +0000 @@ -1,9 +1,9 @@ /* * * Authors: - * Lars Fenneberg + * Lars Fenneberg * - * This software is Copyright 1996,1997 by the above mentioned author(s), + * This software is Copyright 1996,1997 by the above mentioned author(s), * All Rights Reserved. * * The license which is distributed with this software in the file COPYRIGHT @@ -14,20 +14,19 @@ #pragma once -#define L_NONE 0 -#define L_SYSLOG 1 -#define L_STDERR 2 -#define L_STDERR_SYSLOG 3 -#define L_LOGFILE 4 -#define L_STDERR_CLEAN 5 +#define L_NONE 0 +#define L_SYSLOG 1 +#define L_STDERR 2 +#define L_STDERR_SYSLOG 3 +#define L_LOGFILE 4 +#define L_STDERR_CLEAN 5 #define LOG_TIME_FORMAT "%b %d %H:%M:%S" int log_open(int, char const *, char const *, int); -void flog(int, char const *, ...) __attribute__ ((format(printf, 2, 3))); -void dlog(int, int, char const *, ...) __attribute__ ((format(printf, 3, 4))); +void flog(int, char const *, ...) __attribute__((format(printf, 2, 3))); +void dlog(int, int, char const *, ...) __attribute__((format(printf, 3, 4))); int log_close(void); int log_reopen(void); void set_debuglevel(int); int get_debuglevel(void); - diff -Nru radvd-2.16/Makefile.am radvd-2.17/Makefile.am --- radvd-2.16/Makefile.am 2017-02-20 14:49:14.000000000 +0000 +++ radvd-2.17/Makefile.am 2017-06-29 04:32:29.000000000 +0000 @@ -140,7 +140,7 @@ ### build support ### indent: - indent -linux -l125 *.c *.h + clang-format -i *.c *.h test/*.c test/*.h EXTRA_DIST = \ CHANGES \ diff -Nru radvd-2.16/Makefile.in radvd-2.17/Makefile.in --- radvd-2.16/Makefile.in 2017-02-20 14:49:14.000000000 +0000 +++ radvd-2.17/Makefile.in 2017-07-04 03:30:28.000000000 +0000 @@ -584,6 +584,7 @@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ @@ -1805,7 +1806,7 @@ ### build support ### indent: - indent -linux -l125 *.c *.h + clang-format -i *.c *.h test/*.c test/*.h sign: $(AM_V_GEN)for e in $(EXTENSIONS); do \ diff -Nru radvd-2.16/netlink.c radvd-2.17/netlink.c --- radvd-2.16/netlink.c 2017-02-20 14:49:14.000000000 +0000 +++ radvd-2.17/netlink.c 2017-06-29 04:32:29.000000000 +0000 @@ -1,10 +1,10 @@ /* * * Authors: - * Lars Fenneberg + * Lars Fenneberg * Reuben Hawkins * - * This software is Copyright 1996,1997 by the above mentioned author(s), + * This software is Copyright 1996,1997 by the above mentioned author(s), * All Rights Reserved. * * The license which is distributed with this software in the file COPYRIGHT @@ -13,37 +13,37 @@ * */ +#include "netlink.h" #include "config.h" -#include "radvd.h" #include "log.h" -#include "netlink.h" +#include "radvd.h" #include -#include +#include #include #include #include #include #include -#include #include +#include #ifndef SOL_NETLINK -#define SOL_NETLINK 270 +#define SOL_NETLINK 270 #endif struct iplink_req { - struct nlmsghdr n; - struct ifinfomsg i; - char buf[1024]; + struct nlmsghdr n; + struct ifinfomsg i; + char buf[1024]; }; int netlink_get_device_addr_len(struct Interface *iface) { struct iplink_req req = {}; - struct iovec iov = { &req, sizeof(req) }; + struct iovec iov = {&req, sizeof(req)}; struct sockaddr_nl sa = {}; - struct msghdr msg = { (void *)&sa, sizeof(sa), &iov, 1, NULL, 0, 0 }; + struct msghdr msg = {(void *)&sa, sizeof(sa), &iov, 1, NULL, 0, 0}; int sock, len, addr_len = -1; unsigned short type; char answer[32768]; @@ -94,18 +94,18 @@ return addr_len; } -void process_netlink_msg(int sock, struct Interface * ifaces) +void process_netlink_msg(int sock, struct Interface *ifaces) { char buf[4096]; - struct iovec iov = { buf, sizeof(buf) }; + struct iovec iov = {buf, sizeof(buf)}; struct sockaddr_nl sa; - struct msghdr msg = { (void *)&sa, sizeof(sa), &iov, 1, NULL, 0, 0 }; + struct msghdr msg = {(void *)&sa, sizeof(sa), &iov, 1, NULL, 0, 0}; int len = recvmsg(sock, &msg, 0); if (len == -1) { flog(LOG_ERR, "netlink: recvmsg failed: %s", strerror(errno)); } - for (struct nlmsghdr * nh = (struct nlmsghdr *)buf; NLMSG_OK(nh, len); nh = NLMSG_NEXT(nh, len)) { + for (struct nlmsghdr *nh = (struct nlmsghdr *)buf; NLMSG_OK(nh, len); nh = NLMSG_NEXT(nh, len)) { char ifnamebuf[IF_NAMESIZE]; /* The end of multipart message. */ if (nh->nlmsg_type == NLMSG_DONE) @@ -174,17 +174,16 @@ int count = get_iface_addrs(iface->props.name, NULL, &if_addrs); if (count != iface->props.addrs_count || - 0 != memcmp(if_addrs, iface->props.if_addrs, count * sizeof(struct in6_addr))) { - dlog(LOG_DEBUG, 3, "netlink: %s, ifindex %d, addresses are different", - ifname, ifaddr->ifa_index); + 0 != memcmp(if_addrs, iface->props.if_addrs, count * sizeof(struct in6_addr))) { + dlog(LOG_DEBUG, 3, "netlink: %s, ifindex %d, addresses are different", ifname, + ifaddr->ifa_index); touch_iface(iface); } else { - dlog(LOG_DEBUG, 3, "netlink: %s, ifindex %d, addresses are the same", - ifname, ifaddr->ifa_index); + dlog(LOG_DEBUG, 3, "netlink: %s, ifindex %d, addresses are the same", ifname, + ifaddr->ifa_index); } free(if_addrs); } - } } } diff -Nru radvd-2.16/netlink.h radvd-2.17/netlink.h --- radvd-2.16/netlink.h 2017-02-20 14:49:14.000000000 +0000 +++ radvd-2.17/netlink.h 2017-06-29 04:32:29.000000000 +0000 @@ -1,10 +1,10 @@ /* * * Authors: - * Lars Fenneberg + * Lars Fenneberg * Reuben Hawkins * - * This software is Copyright 1996,1997 by the above mentioned author(s), + * This software is Copyright 1996,1997 by the above mentioned author(s), * All Rights Reserved. * * The license which is distributed with this software in the file COPYRIGHT @@ -18,5 +18,5 @@ #include "radvd.h" int netlink_get_device_addr_len(struct Interface *iface); -void process_netlink_msg(int sock, struct Interface * ifaces); +void process_netlink_msg(int sock, struct Interface *ifaces); int netlink_socket(void); diff -Nru radvd-2.16/pathnames.h radvd-2.17/pathnames.h --- radvd-2.16/pathnames.h 2017-02-20 14:49:14.000000000 +0000 +++ radvd-2.17/pathnames.h 2017-06-29 04:32:29.000000000 +0000 @@ -40,6 +40,6 @@ #define PROC_SYS_IP6_BASEREACHTIME "/proc/sys/net/ipv6/neigh/%s/base_reachable_time" #define PROC_SYS_IP6_RETRANSTIMER_MS "/proc/sys/net/ipv6/neigh/%s/retrans_time_ms" #define PROC_SYS_IP6_RETRANSTIMER "/proc/sys/net/ipv6/neigh/%s/retrans_time" -#else /* BSD */ +#else /* BSD */ #define SYSCTL_IP6_FORWARDING CTL_NET, PF_INET6, IPPROTO_IPV6, IPV6CTL_FORWARDING #endif diff -Nru radvd-2.16/privsep-linux.c radvd-2.17/privsep-linux.c --- radvd-2.16/privsep-linux.c 2017-02-20 14:49:14.000000000 +0000 +++ radvd-2.17/privsep-linux.c 2017-06-29 04:32:29.000000000 +0000 @@ -16,8 +16,8 @@ #include "config.h" #include "includes.h" -#include "radvd.h" #include "pathnames.h" +#include "radvd.h" static int set_interface_var(const char *iface, const char *var, const char *name, uint32_t val); static void privsep_read_loop(void); @@ -25,10 +25,7 @@ /* For reading or writing, depending on process */ static int pfd = -1; -void privsep_set_write_fd(int fd) -{ - pfd = fd; -} +void privsep_set_write_fd(int fd) { pfd = fd; } /* Command types */ enum privsep_type { @@ -70,8 +67,8 @@ case SET_INTERFACE_LINKMTU: if (cmd.val < MIN_AdvLinkMTU || cmd.val > MAX_AdvLinkMTU) { - flog(LOG_ERR, "(privsep) %s: LinkMTU (%u) is not within the defined bounds, ignoring", - cmd.iface, cmd.val); + flog(LOG_ERR, "(privsep) %s: LinkMTU (%u) is not within the defined bounds, ignoring", cmd.iface, + cmd.val); break; } ret = set_interface_var(cmd.iface, PROC_SYS_IP6_LINKMTU, "LinkMTU", cmd.val); @@ -88,13 +85,11 @@ case SET_INTERFACE_REACHTIME: if (cmd.val < MIN_AdvReachableTime || cmd.val > MAX_AdvReachableTime) { - flog(LOG_ERR, - "(privsep) %s: BaseReachableTimer (%u) is not within the defined bounds, ignoring", + flog(LOG_ERR, "(privsep) %s: BaseReachableTimer (%u) is not within the defined bounds, ignoring", cmd.iface, cmd.val); break; } - ret = - set_interface_var(cmd.iface, PROC_SYS_IP6_BASEREACHTIME_MS, "BaseReachableTimer (ms)", cmd.val); + ret = set_interface_var(cmd.iface, PROC_SYS_IP6_BASEREACHTIME_MS, "BaseReachableTimer (ms)", cmd.val); if (ret == 0) break; set_interface_var(cmd.iface, PROC_SYS_IP6_BASEREACHTIME, "BaseReachableTimer", cmd.val / 1000); @@ -109,7 +104,8 @@ ret = set_interface_var(cmd.iface, PROC_SYS_IP6_RETRANSTIMER_MS, "RetransTimer (ms)", cmd.val); if (ret == 0) break; - set_interface_var(cmd.iface, PROC_SYS_IP6_RETRANSTIMER, "RetransTimer", cmd.val / 1000 * USER_HZ); /* XXX user_hz */ + set_interface_var(cmd.iface, PROC_SYS_IP6_RETRANSTIMER, "RetransTimer", + cmd.val / 1000 * USER_HZ); /* XXX user_hz */ break; default: @@ -178,8 +174,8 @@ static int set_interface_var(const char *iface, const char *var, const char *name, uint32_t val) { int retval = -1; - FILE * fp = 0; - char * spath = strdupf(var, iface); + FILE *fp = 0; + char *spath = strdupf(var, iface); /* No path traversal */ if (!iface[0] || !strcmp(iface, ".") || !strcmp(iface, "..") || strchr(iface, '/')) @@ -209,4 +205,3 @@ return retval; } - diff -Nru radvd-2.16/process.c radvd-2.17/process.c --- radvd-2.16/process.c 2017-02-20 14:49:14.000000000 +0000 +++ radvd-2.17/process.c 2017-07-02 01:59:02.000000000 +0000 @@ -24,7 +24,7 @@ void process(int sock, struct Interface *interfaces, unsigned char *msg, int len, struct sockaddr_in6 *addr, struct in6_pktinfo *pkt_info, int hoplimit) { - char if_namebuf[IF_NAMESIZE] = { "" }; + char if_namebuf[IF_NAMESIZE] = {""}; char *if_name = if_indextoname(pkt_info->ipi6_ifindex, if_namebuf); if (!if_name) { if_name = "unknown interface"; @@ -61,19 +61,22 @@ if (icmph->icmp6_type == ND_ROUTER_ADVERT) { if (len < sizeof(struct nd_router_advert)) { - flog(LOG_WARNING, "%s received icmpv6 RA packet with invalid length (%d) from %s", if_name, len, addr_str); + flog(LOG_WARNING, "%s received icmpv6 RA packet with invalid length (%d) from %s", if_name, len, + addr_str); return; } if (!IN6_IS_ADDR_LINKLOCAL(&addr->sin6_addr)) { - flog(LOG_WARNING, "%s received icmpv6 RA packet with non-linklocal source address from %s", if_name, addr_str); + flog(LOG_WARNING, "%s received icmpv6 RA packet with non-linklocal source address from %s", if_name, + addr_str); return; } } if (icmph->icmp6_type == ND_ROUTER_SOLICIT) { if (len < sizeof(struct nd_router_solicit)) { - flog(LOG_WARNING, "%s received icmpv6 RS packet with invalid length (%d) from %s", if_name, len, addr_str); + flog(LOG_WARNING, "%s received icmpv6 RS packet with invalid length (%d) from %s", if_name, len, + addr_str); return; } } @@ -94,8 +97,8 @@ } if (!iface->state_info.ready && (0 != setup_iface(sock, iface))) { - flog(LOG_WARNING, "%s received RS or RA on %s but %s is not ready and setup_iface failed", if_name, iface->props.name, - iface->props.name); + flog(LOG_WARNING, "%s received RS or RA on %s but %s is not ready and setup_iface failed", if_name, + iface->props.name, iface->props.name); return; } @@ -119,10 +122,38 @@ static void process_rs(int sock, struct Interface *iface, unsigned char *msg, int len, struct sockaddr_in6 *addr) { + /* RFC 7772, section 5.1: + * 5.1. Network-Side Recommendations + * 1. Router manufacturers SHOULD allow network administrators to + * configure the routers to respond to Router Solicitations with + * unicast Router Advertisements if: + * * The Router Solicitation's source address is not the + * unspecified address, and: + * * The solicitation contains a valid Source Link-Layer Address + * option. + * + * However, testing shows that many clients do not set the SLLA option: + * https://github.com/reubenhwk/radvd/issues/63#issuecomment-287172252 + * As of 2017/03/16: + * - macOS 10.12.3 sierra - sends SLLA 2 times out of 4 + * - iOS 10.2.1 (iPhone 5s) - no SLLA + * - Android 7.0 (sony xperia phone) - sends SLLA + * - Android 5.1 (nexus 7 tablet) - sends SLLA + * - Ubuntu 16.04.2 LTS w/ Network Manager, running 4.9 kernel (dell laptop) - no SLLA + * - Windows 10 (dell laptop) - no SLLA + * + * We decide to ignore the SLLA option for now, and only require the + * unspecified address check. Clients that did not set the SLLA option will + * trigger a neighbour solicit to the solicited-node address trying to + * resolve the link-local address to, this would still be less traffic than + * the all-nodes multicast. + */ + int rfc7772_unicast_response = iface->AdvRASolicitedUnicast && !IN6_IS_ADDR_UNSPECIFIED(&addr->sin6_addr); + /* validation */ len -= sizeof(struct nd_router_solicit); - uint8_t *opt_str = (uint8_t *) (msg + sizeof(struct nd_router_solicit)); + uint8_t *opt_str = (uint8_t *)(msg + sizeof(struct nd_router_solicit)); while (len > 0) { if (len < 2) { @@ -155,14 +186,12 @@ double const delay = (MAX_RA_DELAY_SECONDS * rand() / (RAND_MAX + 1.0)); - if (iface->UnicastOnly) { + if (iface->UnicastOnly || rfc7772_unicast_response) { send_ra_forall(sock, iface, &addr->sin6_addr); } else if (timespecdiff(&ts, &iface->times.last_multicast) / 1000.0 < iface->MinDelayBetweenRAs) { /* last RA was sent only a few moments ago, don't send another immediately. */ - double next = - iface->MinDelayBetweenRAs - (ts.tv_sec + ts.tv_nsec / 1000000000.0) + (iface->times.last_multicast.tv_sec + - iface->times.last_multicast.tv_nsec / - 1000000000.0) + delay; + double next = iface->MinDelayBetweenRAs - (ts.tv_sec + ts.tv_nsec / 1000000000.0) + + (iface->times.last_multicast.tv_sec + iface->times.last_multicast.tv_nsec / 1000000000.0) + delay; dlog(LOG_DEBUG, 5, "%s: rate limiting RA's, rescheduling RA %f seconds from now", iface->props.name, next); reschedule_iface(iface, next); } else { @@ -184,7 +213,8 @@ struct nd_router_advert *radvert = (struct nd_router_advert *)msg; - if ((radvert->nd_ra_curhoplimit && iface->ra_header_info.AdvCurHopLimit) && (radvert->nd_ra_curhoplimit != iface->ra_header_info.AdvCurHopLimit)) { + if ((radvert->nd_ra_curhoplimit && iface->ra_header_info.AdvCurHopLimit) && + (radvert->nd_ra_curhoplimit != iface->ra_header_info.AdvCurHopLimit)) { flog(LOG_WARNING, "our AdvCurHopLimit on %s doesn't agree with %s", iface->props.name, addr_str); } @@ -198,13 +228,13 @@ /* note: we don't check the default router preference here, because they're likely different */ - if ((radvert->nd_ra_reachable && iface->ra_header_info.AdvReachableTime) - && (ntohl(radvert->nd_ra_reachable) != iface->ra_header_info.AdvReachableTime)) { + if ((radvert->nd_ra_reachable && iface->ra_header_info.AdvReachableTime) && + (ntohl(radvert->nd_ra_reachable) != iface->ra_header_info.AdvReachableTime)) { flog(LOG_WARNING, "our AdvReachableTime on %s doesn't agree with %s", iface->props.name, addr_str); } - if ((radvert->nd_ra_retransmit && iface->ra_header_info.AdvRetransTimer) - && (ntohl(radvert->nd_ra_retransmit) != iface->ra_header_info.AdvRetransTimer)) { + if ((radvert->nd_ra_retransmit && iface->ra_header_info.AdvRetransTimer) && + (ntohl(radvert->nd_ra_retransmit) != iface->ra_header_info.AdvRetransTimer)) { flog(LOG_WARNING, "our AdvRetransTimer on %s doesn't agree with %s", iface->props.name, addr_str); } @@ -213,7 +243,7 @@ if (len == 0) return; - uint8_t *opt_str = (uint8_t *) (msg + sizeof(struct nd_router_advert)); + uint8_t *opt_str = (uint8_t *)(msg + sizeof(struct nd_router_advert)); while (len > 0) { @@ -228,55 +258,53 @@ flog(LOG_ERR, "zero length option in RA on %s from %s", iface->props.name, addr_str); break; } else if (optlen > len) { - flog(LOG_ERR, "option length (%d) greater than total" " length (%d) in RA on %s from %s", optlen, - len, iface->props.name, addr_str); + flog(LOG_ERR, "option length (%d) greater than total" + " length (%d) in RA on %s from %s", + optlen, len, iface->props.name, addr_str); break; } switch (*opt_str) { - case ND_OPT_MTU:{ - struct nd_opt_mtu *mtu = (struct nd_opt_mtu *)opt_str; - if (len < sizeof(*mtu)) - return; + case ND_OPT_MTU: { + struct nd_opt_mtu *mtu = (struct nd_opt_mtu *)opt_str; + if (len < sizeof(*mtu)) + return; - if (iface->AdvLinkMTU && (ntohl(mtu->nd_opt_mtu_mtu) != iface->AdvLinkMTU)) { - flog(LOG_WARNING, "our AdvLinkMTU on %s doesn't agree with %s", iface->props.name, - addr_str); - } - break; + if (iface->AdvLinkMTU && (ntohl(mtu->nd_opt_mtu_mtu) != iface->AdvLinkMTU)) { + flog(LOG_WARNING, "our AdvLinkMTU on %s doesn't agree with %s", iface->props.name, addr_str); } - case ND_OPT_PREFIX_INFORMATION:{ - struct nd_opt_prefix_info *pinfo = (struct nd_opt_prefix_info *)opt_str; - if (len < sizeof(*pinfo)) - return; - int preferred = ntohl(pinfo->nd_opt_pi_preferred_time); - int valid = ntohl(pinfo->nd_opt_pi_valid_time); - - struct AdvPrefix *prefix = iface->AdvPrefixList; - while (prefix) { - char prefix_str[INET6_ADDRSTRLEN]; - if ((prefix->PrefixLen == pinfo->nd_opt_pi_prefix_len) - && addr_match(&prefix->Prefix, &pinfo->nd_opt_pi_prefix, prefix->PrefixLen)) { - addrtostr(&prefix->Prefix, prefix_str, sizeof(prefix_str)); - - if (!prefix->DecrementLifetimesFlag && valid != prefix->AdvValidLifetime) { - flog(LOG_WARNING, - "our AdvValidLifetime on" " %s for %s doesn't agree with %s", - iface->props.name, prefix_str, addr_str); - } - if (!prefix->DecrementLifetimesFlag - && preferred != prefix->AdvPreferredLifetime) { - flog(LOG_WARNING, - "our AdvPreferredLifetime on" - " %s for %s doesn't agree with %s", iface->props.name, prefix_str, - addr_str); - } + break; + } + case ND_OPT_PREFIX_INFORMATION: { + struct nd_opt_prefix_info *pinfo = (struct nd_opt_prefix_info *)opt_str; + if (len < sizeof(*pinfo)) + return; + int preferred = ntohl(pinfo->nd_opt_pi_preferred_time); + int valid = ntohl(pinfo->nd_opt_pi_valid_time); + + struct AdvPrefix *prefix = iface->AdvPrefixList; + while (prefix) { + char prefix_str[INET6_ADDRSTRLEN]; + if ((prefix->PrefixLen == pinfo->nd_opt_pi_prefix_len) && + addr_match(&prefix->Prefix, &pinfo->nd_opt_pi_prefix, prefix->PrefixLen)) { + addrtostr(&prefix->Prefix, prefix_str, sizeof(prefix_str)); + + if (!prefix->DecrementLifetimesFlag && valid != prefix->AdvValidLifetime) { + flog(LOG_WARNING, "our AdvValidLifetime on" + " %s for %s doesn't agree with %s", + iface->props.name, prefix_str, addr_str); + } + if (!prefix->DecrementLifetimesFlag && preferred != prefix->AdvPreferredLifetime) { + flog(LOG_WARNING, "our AdvPreferredLifetime on" + " %s for %s doesn't agree with %s", + iface->props.name, prefix_str, addr_str); } - - prefix = prefix->next; } - break; + + prefix = prefix->next; } + break; + } case ND_OPT_ROUTE_INFORMATION: /* not checked: these will very likely vary a lot */ break; @@ -287,108 +315,103 @@ case ND_OPT_REDIRECTED_HEADER: flog(LOG_ERR, "invalid option %d in RA on %s from %s", (int)*opt_str, iface->props.name, addr_str); break; - /* Mobile IPv6 extensions */ + /* Mobile IPv6 extensions */ case ND_OPT_RTR_ADV_INTERVAL: case ND_OPT_HOME_AGENT_INFO: /* not checked */ break; - case ND_OPT_RDNSS_INFORMATION:{ - char rdnss_str[INET6_ADDRSTRLEN]; - struct AdvRDNSS *rdnss = 0; - struct nd_opt_rdnss_info_local *rdnssinfo = (struct nd_opt_rdnss_info_local *)opt_str; - if (len < sizeof(*rdnssinfo)) - return; - int count = rdnssinfo->nd_opt_rdnssi_len; - - /* Check the RNDSS addresses received */ - switch (count) { - case 7: - rdnss = iface->AdvRDNSSList; - if (!check_rdnss_presence(rdnss, &rdnssinfo->nd_opt_rdnssi_addr3)) { - /* no match found in iface->AdvRDNSSList */ - addrtostr(&rdnssinfo->nd_opt_rdnssi_addr3, rdnss_str, sizeof(rdnss_str)); - flog(LOG_WARNING, - "RDNSS address %s received on %s from %s is not advertised by us", - rdnss_str, iface->props.name, addr_str); - } - /* FALLTHROUGH */ - case 5: - rdnss = iface->AdvRDNSSList; - if (!check_rdnss_presence(rdnss, &rdnssinfo->nd_opt_rdnssi_addr2)) { - /* no match found in iface->AdvRDNSSList */ - addrtostr(&rdnssinfo->nd_opt_rdnssi_addr2, rdnss_str, sizeof(rdnss_str)); - flog(LOG_WARNING, - "RDNSS address %s received on %s from %s is not advertised by us", - rdnss_str, iface->props.name, addr_str); - } - /* FALLTHROUGH */ - case 3: - rdnss = iface->AdvRDNSSList; - if (!check_rdnss_presence(rdnss, &rdnssinfo->nd_opt_rdnssi_addr1)) { - /* no match found in iface->AdvRDNSSList */ - addrtostr(&rdnssinfo->nd_opt_rdnssi_addr1, rdnss_str, sizeof(rdnss_str)); - flog(LOG_WARNING, - "RDNSS address %s received on %s from %s is not advertised by us", - rdnss_str, iface->props.name, addr_str); - } - - break; - default: - flog(LOG_ERR, "invalid len %i in RDNSS option on %s from %s", count, iface->props.name, - addr_str); + case ND_OPT_RDNSS_INFORMATION: { + char rdnss_str[INET6_ADDRSTRLEN]; + struct AdvRDNSS *rdnss = 0; + struct nd_opt_rdnss_info_local *rdnssinfo = (struct nd_opt_rdnss_info_local *)opt_str; + if (len < sizeof(*rdnssinfo)) + return; + int count = rdnssinfo->nd_opt_rdnssi_len; + + /* Check the RNDSS addresses received */ + switch (count) { + case 7: + rdnss = iface->AdvRDNSSList; + if (!check_rdnss_presence(rdnss, &rdnssinfo->nd_opt_rdnssi_addr3)) { + /* no match found in iface->AdvRDNSSList */ + addrtostr(&rdnssinfo->nd_opt_rdnssi_addr3, rdnss_str, sizeof(rdnss_str)); + flog(LOG_WARNING, "RDNSS address %s received on %s from %s is not advertised by us", + rdnss_str, iface->props.name, addr_str); + } + /* FALLTHROUGH */ + case 5: + rdnss = iface->AdvRDNSSList; + if (!check_rdnss_presence(rdnss, &rdnssinfo->nd_opt_rdnssi_addr2)) { + /* no match found in iface->AdvRDNSSList */ + addrtostr(&rdnssinfo->nd_opt_rdnssi_addr2, rdnss_str, sizeof(rdnss_str)); + flog(LOG_WARNING, "RDNSS address %s received on %s from %s is not advertised by us", + rdnss_str, iface->props.name, addr_str); + } + /* FALLTHROUGH */ + case 3: + rdnss = iface->AdvRDNSSList; + if (!check_rdnss_presence(rdnss, &rdnssinfo->nd_opt_rdnssi_addr1)) { + /* no match found in iface->AdvRDNSSList */ + addrtostr(&rdnssinfo->nd_opt_rdnssi_addr1, rdnss_str, sizeof(rdnss_str)); + flog(LOG_WARNING, "RDNSS address %s received on %s from %s is not advertised by us", + rdnss_str, iface->props.name, addr_str); } break; + default: + flog(LOG_ERR, "invalid len %i in RDNSS option on %s from %s", count, iface->props.name, addr_str); } - case ND_OPT_DNSSL_INFORMATION:{ - struct nd_opt_dnssl_info_local *dnsslinfo = (struct nd_opt_dnssl_info_local *)opt_str; - if (len < sizeof(*dnsslinfo)) - return; - for (int offset = 0; offset < (dnsslinfo->nd_opt_dnssli_len - 1) * 8;) { - char suffix[256] = { "" }; - if (&dnsslinfo->nd_opt_dnssli_suffixes[offset] - opt_str >= len) - return; - int label_len = dnsslinfo->nd_opt_dnssli_suffixes[offset++]; - - if (label_len == 0) { - /* - * Ignore empty suffixes. They're - * probably just padding... - */ - if (suffix[0] == '\0') - continue; - - if (!check_dnssl_presence(iface->AdvDNSSLList, suffix)) { - flog(LOG_WARNING, - "DNSSL suffix %s received on %s from %s is not advertised by us", - suffix, iface->props.name, addr_str); - } - - suffix[0] = '\0'; - continue; - } + break; + } + case ND_OPT_DNSSL_INFORMATION: { + struct nd_opt_dnssl_info_local *dnsslinfo = (struct nd_opt_dnssl_info_local *)opt_str; + if (len < sizeof(*dnsslinfo)) + return; + + for (int offset = 0; offset < (dnsslinfo->nd_opt_dnssli_len - 1) * 8;) { + char suffix[256] = {""}; + if (&dnsslinfo->nd_opt_dnssli_suffixes[offset] - opt_str >= len) + return; + int label_len = dnsslinfo->nd_opt_dnssli_suffixes[offset++]; + if (label_len == 0) { /* - * 1) must not overflow int: label + 2, offset + label_len - * 2) last byte of dnssli_suffix must not overflow opt_str + len + * Ignore empty suffixes. They're + * probably just padding... */ - if ((sizeof(suffix) - strlen(suffix)) < (label_len + 2) || - label_len >= (INT_MAX-1) - || &dnsslinfo->nd_opt_dnssli_suffixes[offset + label_len] - opt_str >= len - || offset + label_len < offset) { - flog(LOG_ERR, "oversized suffix in DNSSL option on %s from %s", iface->props.name, - addr_str); - break; + if (suffix[0] == '\0') + continue; + + if (!check_dnssl_presence(iface->AdvDNSSLList, suffix)) { + flog(LOG_WARNING, + "DNSSL suffix %s received on %s from %s is not advertised by us", suffix, + iface->props.name, addr_str); } - if (suffix[0] != '\0') - strcat(suffix, "."); - strncat(suffix, (char *)&dnsslinfo->nd_opt_dnssli_suffixes[offset], label_len); - offset += label_len; + suffix[0] = '\0'; + continue; } - break; + + /* + * 1) must not overflow int: label + 2, offset + label_len + * 2) last byte of dnssli_suffix must not overflow opt_str + len + */ + if ((sizeof(suffix) - strlen(suffix)) < (label_len + 2) || label_len >= (INT_MAX - 1) || + &dnsslinfo->nd_opt_dnssli_suffixes[offset + label_len] - opt_str >= len || + offset + label_len < offset) { + flog(LOG_ERR, "oversized suffix in DNSSL option on %s from %s", iface->props.name, + addr_str); + break; + } + + if (suffix[0] != '\0') + strcat(suffix, "."); + strncat(suffix, (char *)&dnsslinfo->nd_opt_dnssli_suffixes[offset], label_len); + offset += label_len; } + break; + } default: dlog(LOG_DEBUG, 1, "unknown option %d in RA on %s from %s", (int)*opt_str, iface->props.name, addr_str); break; @@ -402,18 +425,18 @@ static int addr_match(struct in6_addr *a1, struct in6_addr *a2, int prefixlen) { - unsigned int pdw = prefixlen >> 0x05; /* num of whole uint32_t in prefix */ + unsigned int pdw = prefixlen >> 0x05; /* num of whole uint32_t in prefix */ if (pdw) { if (memcmp(a1, a2, pdw << 2)) return 0; } - unsigned int pbi = prefixlen & 0x1f; /* num of bits in incomplete uint32_t in prefix */ + unsigned int pbi = prefixlen & 0x1f; /* num of bits in incomplete uint32_t in prefix */ if (pbi) { - uint32_t w1 = *((uint32_t *) a1 + pdw); - uint32_t w2 = *((uint32_t *) a2 + pdw); + uint32_t w1 = *((uint32_t *)a1 + pdw); + uint32_t w2 = *((uint32_t *)a2 + pdw); - uint32_t mask = htonl(((uint32_t) 0xffffffff) << (0x20 - pbi)); + uint32_t mask = htonl(((uint32_t)0xffffffff) << (0x20 - pbi)); if ((w1 ^ w2) & mask) return 0; diff -Nru radvd-2.16/radvd.c radvd-2.17/radvd.c --- radvd-2.16/radvd.c 2017-02-20 14:49:14.000000000 +0000 +++ radvd-2.17/radvd.c 2017-07-02 02:04:47.000000000 +0000 @@ -13,22 +13,22 @@ * */ +#include "radvd.h" #include "config.h" #include "includes.h" -#include "radvd.h" #include "pathnames.h" #ifdef HAVE_NETLINK #include "netlink.h" #endif +#include #include #include -#include #ifdef HAVE_GETOPT_LONG -/* *INDENT-OFF* */ +/* clang-format off */ static char usage_str[] = { "\n" " -C, --config=PATH Set the config file. Default is /etc/radvd.d.\n" @@ -69,7 +69,7 @@ "\t[-f facility] [-p pid_file] [-u username] [-t chrootdir]" }; -/* *INDENT-ON* */ +/* clang-format on */ #endif @@ -80,13 +80,13 @@ static int check_conffile_perm(const char *, const char *); static int drop_root_privileges(const char *); -static int open_and_lock_pid_file(char const * daemon_pid_file_ident); -static int write_pid_file(char const * daemon_pid_file_ident, pid_t pid); -static pid_t daemonp(int nochdir, int noclose, char const * daemon_pid_file_ident); -static pid_t do_daemonize(int log_method, char const * daemon_pid_file_ident); -static struct Interface * main_loop(int sock, struct Interface *ifaces, char const *conf_path); +static int open_and_lock_pid_file(char const *daemon_pid_file_ident); +static int write_pid_file(char const *daemon_pid_file_ident, pid_t pid); +static pid_t daemonp(char const *daemon_pid_file_ident); +static pid_t do_daemonize(int log_method, char const *daemon_pid_file_ident); +static struct Interface *main_loop(int sock, struct Interface *ifaces, char const *conf_path); static struct Interface *reload_config(int sock, struct Interface *ifaces, char const *conf_path); -static void check_pid_file(char const * daemon_pid_file_ident); +static void check_pid_file(char const *daemon_pid_file_ident); static void config_interface(struct Interface *iface); static void kickoff_adverts(int sock, struct Interface *iface); static void reset_prefix_lifetimes(struct Interface *ifaces); @@ -106,7 +106,7 @@ /* daemonize and write pid file. The pid of the daemon child process * will be written to the pid file from the *parent* process. This * insures there is no race condition as described in redhat bug 664783. */ -static pid_t daemonp(int nochdir, int noclose, char const * daemon_pid_file_ident) +static pid_t daemonp(char const *daemon_pid_file_ident) { int pipe_ends[2]; @@ -138,28 +138,24 @@ exit(-1); } - if (nochdir == 0) { - if (chdir("/") == -1) { - perror("chdir"); - exit(1); - } + if (chdir("/") == -1) { + perror("chdir"); + exit(1); } - if (noclose == 0) { - close(STDIN_FILENO); - close(STDOUT_FILENO); - close(STDERR_FILENO); - if (open("/dev/null", O_RDONLY) == -1) { - flog(LOG_ERR, "unable to redirect stdin to /dev/null"); - exit(-1); - } - if (open("/dev/null", O_WRONLY) == -1) { - flog(LOG_ERR, "unable to redirect stdout to /dev/null"); - exit(-1); - } - if (open("/dev/null", O_RDWR) == -1) { - flog(LOG_ERR, "unable to redirect stderr to /dev/null"); - exit(-1); - } + close(STDIN_FILENO); + close(STDOUT_FILENO); + close(STDERR_FILENO); + if (open("/dev/null", O_RDONLY) == -1) { + flog(LOG_ERR, "unable to redirect stdin to /dev/null"); + exit(-1); + } + if (open("/dev/null", O_WRONLY) == -1) { + flog(LOG_ERR, "unable to redirect stdout to /dev/null"); + exit(-1); + } + if (open("/dev/null", O_RDWR) == -1) { + flog(LOG_ERR, "unable to redirect stderr to /dev/null"); + exit(-1); } } else { /* Parent. Make sure the pid file is written before exiting. */ @@ -200,7 +196,7 @@ char const *conf_path = PATH_RADVD_CONF; char const *daemon_pid_file_ident = PATH_RADVD_PID; - /* parse args */ +/* parse args */ #define OPTIONS_STR "d:C:l:m:p:t:u:vhcn" #ifdef HAVE_GETOPT_LONG int opt_idx; @@ -293,15 +289,15 @@ if (configtest) { set_debuglevel(1); switch (log_method) { - case L_STDERR: - case L_STDERR_CLEAN: - break; - case L_STDERR_SYSLOG: - case L_NONE: - case L_SYSLOG: - case L_LOGFILE: - default: - log_method = L_STDERR; + case L_STDERR: + case L_STDERR_CLEAN: + break; + case L_STDERR_SYSLOG: + case L_NONE: + case L_SYSLOG: + case L_LOGFILE: + default: + log_method = L_STDERR; break; } } @@ -457,7 +453,7 @@ return 0; } -static struct Interface * main_loop(int sock, struct Interface *ifaces, char const *conf_path) +static struct Interface *main_loop(int sock, struct Interface *ifaces, char const *conf_path) { struct pollfd fds[2]; sigset_t sigmask; @@ -523,7 +519,7 @@ #ifdef HAVE_PPOLL int rc = ppoll(fds, sizeof(fds) / sizeof(fds[0]), tsp, &sigempty); #else - int rc = poll(fds, sizeof(fds) / sizeof(fds[0]), 1000*tsp->tv_sec); + int rc = poll(fds, sizeof(fds) / sizeof(fds[0]), 1000 * tsp->tv_sec); #endif if (rc > 0) { @@ -581,21 +577,16 @@ reset_prefix_lifetimes(ifaces); sigusr1_received = 0; } - } return ifaces; } -static pid_t do_daemonize(int log_method, char const * daemon_pid_file_ident) +static pid_t do_daemonize(int log_method, char const *daemon_pid_file_ident) { pid_t pid = -1; - if (L_STDERR_SYSLOG == log_method || L_STDERR == log_method) { - pid = daemonp(1, 1, daemon_pid_file_ident); - } else { - pid = daemonp(0, 0, daemon_pid_file_ident); - } + pid = daemonp(daemon_pid_file_ident); if (-1 == pid) { flog(LOG_ERR, "unable to daemonize: %s", strerror(errno)); @@ -604,7 +595,7 @@ return pid; } -static int open_pid_file(char const * daemon_pid_file_ident) +static int open_pid_file(char const *daemon_pid_file_ident) { int pidfd = open(daemon_pid_file_ident, O_SYNC | O_CREAT | O_RDWR, 0644); if (-1 == pidfd) { @@ -616,7 +607,7 @@ return pidfd; } -static int open_and_lock_pid_file(char const * daemon_pid_file_ident) +static int open_and_lock_pid_file(char const *daemon_pid_file_ident) { dlog(LOG_DEBUG, 3, "radvd startup PID is %d", getpid()); @@ -633,7 +624,7 @@ return pidfd; } -static int write_pid_file(char const * daemon_pid_file_ident, pid_t pid) +static int write_pid_file(char const *daemon_pid_file_ident, pid_t pid) { int pidfd = open_pid_file(daemon_pid_file_ident); char pid_str[20] = {""}; @@ -658,8 +649,8 @@ if (rc != 0) { dlog(LOG_DEBUG, 4, "failed to close pid file: %s", daemon_pid_file_ident); } - char * dirstrcopy = strdup(daemon_pid_file_ident); - char * dirstr = dirname(dirstrcopy); + char *dirstrcopy = strdup(daemon_pid_file_ident); + char *dirstr = dirname(dirstrcopy); int dirfd = open(dirstr, O_RDONLY); rc = fsync(dirfd); if (rc != 0) { @@ -674,9 +665,9 @@ return rc; } -static void check_pid_file(char const * daemon_pid_file_ident) +static void check_pid_file(char const *daemon_pid_file_ident) { - FILE * pidfile = fopen(daemon_pid_file_ident, "r"); + FILE *pidfile = fopen(daemon_pid_file_ident, "r"); if (!pidfile) { flog(LOG_ERR, "unable to open pid file, %s: %s", daemon_pid_file_ident, strerror(errno)); @@ -700,7 +691,6 @@ dlog(LOG_DEBUG, 4, "validated pid file, %s: %d", daemon_pid_file_ident, pid); } - static void timer_handler(int sock, struct Interface *iface) { dlog(LOG_DEBUG, 1, "timer_handler called for %s", iface->props.name); @@ -786,10 +776,7 @@ kickoff_adverts(sock, iface); } -static void setup_ifaces(int sock, struct Interface *ifaces) -{ - for_each_iface(ifaces, setup_iface_foo, &sock); -} +static void setup_ifaces(int sock, struct Interface *ifaces) { for_each_iface(ifaces, setup_iface_foo, &sock); } static struct Interface *reload_config(int sock, struct Interface *ifaces, char const *conf_path) { @@ -810,10 +797,7 @@ return ifaces; } -static void sighup_handler(int sig) -{ - sighup_received = 1; -} +static void sighup_handler(int sig) { sighup_received = 1; } static void sigterm_handler(int sig) { @@ -833,16 +817,13 @@ } } -static void sigusr1_handler(int sig) -{ - sigusr1_received = 1; -} +static void sigusr1_handler(int sig) { sigusr1_received = 1; } static void reset_prefix_lifetimes_foo(struct Interface *iface, void *data) { flog(LOG_INFO, "Resetting prefix lifetimes on %s", iface->props.name); - for (struct AdvPrefix * prefix = iface->AdvPrefixList; prefix; prefix = prefix->next) { + for (struct AdvPrefix *prefix = iface->AdvPrefixList; prefix; prefix = prefix->next) { if (prefix->DecrementLifetimesFlag) { char pfx_str[INET6_ADDRSTRLEN]; addrtostr(&prefix->Prefix, pfx_str, sizeof(pfx_str)); @@ -856,10 +837,7 @@ } } -static void reset_prefix_lifetimes(struct Interface *ifaces) -{ - for_each_iface(ifaces, reset_prefix_lifetimes_foo, 0); -} +static void reset_prefix_lifetimes(struct Interface *ifaces) { for_each_iface(ifaces, reset_prefix_lifetimes_foo, 0); } static int drop_root_privileges(const char *username) { @@ -904,8 +882,8 @@ } /* for non-root: must not be writable by self/own group */ - if (strncmp(username, "root", 5) != 0 && ((stbuf.st_mode & S_IWGRP && pw->pw_gid == stbuf.st_gid) - || (stbuf.st_mode & S_IWUSR && pw->pw_uid == stbuf.st_uid))) { + if (strncmp(username, "root", 5) != 0 && ((stbuf.st_mode & S_IWGRP && pw->pw_gid == stbuf.st_gid) || + (stbuf.st_mode & S_IWUSR && pw->pw_uid == stbuf.st_uid))) { flog(LOG_ERR, "Insecure file permissions (writable by self/group): %s", conf_file); return -1; } diff -Nru radvd-2.16/radvd.conf.5.man radvd-2.17/radvd.conf.5.man --- radvd-2.16/radvd.conf.5.man 2017-02-20 14:49:14.000000000 +0000 +++ radvd-2.17/radvd.conf.5.man 2017-07-02 01:59:02.000000000 +0000 @@ -93,7 +93,7 @@ .B }; .fi -By default radvd will send route advertisements so that every node on the link can use them. +By default radvd will send multicast route advertisements so that every node on the link can use them. The list of clients (IPv6 address) to advertise to, and accept route solicitations from can be configured. If done, radvd does not send send messages to the multicast addresses but to the configured unicast addresses only. Solicitations from other addresses are refused. @@ -173,6 +173,19 @@ Default: off .TP +.BR AdvRASolicitedUnicast " " on | off + +Indicates that router solicitations will be responded to with unicast +router advertisements, as recommended by RFC7772. Large networks with a +high concentration of mobile devices might experience like battery +depletion, when solicited Router Advertisement messages are multicast. + +This corresponds to the Cisco IOS option +.B ipv6 nd ra solicited unicast + +Default: on + +.TP .BR "MaxRtrAdvInterval " seconds The maximum time allowed between sending unsolicited multicast diff -Nru radvd-2.16/radvd.conf.example radvd-2.17/radvd.conf.example --- radvd-2.16/radvd.conf.example 2017-02-20 14:49:14.000000000 +0000 +++ radvd-2.17/radvd.conf.example 2017-06-29 04:47:19.000000000 +0000 @@ -8,7 +8,7 @@ # NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE # -interface eth0 +interface lo { AdvSendAdvert on; diff -Nru radvd-2.16/radvd.h radvd-2.17/radvd.h --- radvd-2.16/radvd.h 2017-02-20 14:49:14.000000000 +0000 +++ radvd-2.17/radvd.h 2017-07-02 01:59:02.000000000 +0000 @@ -16,17 +16,17 @@ #pragma once #include "config.h" -#include "includes.h" #include "defaults.h" +#include "includes.h" #include "log.h" -#define CONTACT_EMAIL "Reuben Hawkins " +#define CONTACT_EMAIL "Reuben Hawkins " extern int sock; extern int disableigmp6check; -#define min(a,b) (((a) < (b)) ? (a) : (b)) +#define min(a, b) (((a) < (b)) ? (a) : (b)) struct AdvPrefix; struct Clients; @@ -38,10 +38,11 @@ int should_free; size_t allocated; size_t used; - unsigned char * buffer; + unsigned char *buffer; }; -#define SAFE_BUFFER_INIT (struct safe_buffer){.should_free = 0, .allocated = 0, .used = 0, .buffer = 0} +#define SAFE_BUFFER_INIT \ + (struct safe_buffer) { .should_free = 0, .allocated = 0, .used = 0, .buffer = 0 } struct safe_buffer_list { struct safe_buffer *sb; @@ -58,19 +59,20 @@ double MinDelayBetweenRAs; int AdvSourceLLAddress; int UnicastOnly; + int AdvRASolicitedUnicast; struct Clients *ClientList; struct state_info { - int ready; /* Info whether this interface has been initialized successfully */ - int changed; /* Info whether this interface's settings have changed */ + int ready; /* Info whether this interface has been initialized successfully */ + int changed; /* Info whether this interface's settings have changed */ int cease_adv; uint32_t racount; } state_info; struct properties { - char name[IFNAMSIZ]; /* interface name */ + char name[IFNAMSIZ]; /* interface name */ unsigned int if_index; - struct in6_addr if_addr; /* the first link local addr */ + struct in6_addr if_addr; /* the first link local addr */ struct in6_addr *if_addrs; /* all the addrs */ int addrs_count; struct in6_addr *if_addr_rasrc; /* selected AdvRASrcAddress or NULL */ @@ -82,7 +84,7 @@ int AdvOtherConfigFlag; uint8_t AdvCurHopLimit; int AdvHomeAgentFlag; - int32_t AdvDefaultLifetime; /* XXX: really uint16_t but we need to use -1 */ + int32_t AdvDefaultLifetime; /* XXX: really uint16_t but we need to use -1 */ int AdvDefaultPreference; uint32_t AdvReachableTime; uint32_t AdvRetransTimer; @@ -100,7 +102,7 @@ struct AdvDNSSL *AdvDNSSLList; uint32_t AdvLinkMTU; /* XXX: sllao also has an if_maxmtu value...Why? */ - uint32_t AdvRAMTU; /* MTU used for RA */ + uint32_t AdvRAMTU; /* MTU used for RA */ struct sllao { uint8_t if_hwaddr[HWADDR_MAX]; @@ -115,7 +117,7 @@ int AdvHomeAgentInfo; uint16_t HomeAgentPreference; - int32_t HomeAgentLifetime; /* XXX: really uint16_t but we need to use -1 */ + int32_t HomeAgentLifetime; /* XXX: really uint16_t but we need to use -1 */ /* NEMO extensions */ int AdvMobRtrSupportFlag; @@ -240,9 +242,9 @@ }; /* Uclibc : include/netinet/icmpv6.h - Added by Bhadram*/ -#define ND_OPT_ARO 33 -#define ND_OPT_6CO 34 -#define ND_OPT_ABRO 35 +#define ND_OPT_ARO 33 +#define ND_OPT_6CO 34 +#define ND_OPT_ABRO 35 struct nd_opt_abro { uint8_t nd_opt_abro_type; @@ -257,13 +259,13 @@ uint8_t nd_opt_6co_type; uint8_t nd_opt_6co_len; uint8_t nd_opt_6co_context_len; - uint8_t nd_opt_6co_res:3; - uint8_t nd_opt_6co_c:1; - uint8_t nd_opt_6co_cid:4; + uint8_t nd_opt_6co_res : 3; + uint8_t nd_opt_6co_c : 1; + uint8_t nd_opt_6co_cid : 4; uint16_t nd_opt_6co_reserved; uint16_t nd_opt_6co_valid_lifetime; struct in6_addr nd_opt_6co_con_prefix; -}; /*Added by Bhadram */ +}; /*Added by Bhadram */ /* gram.y */ struct Interface *readin_config(char const *fname); @@ -288,11 +290,9 @@ int setup_iface_addrs(struct Interface *); int update_device_index(struct Interface *iface); int update_device_info(int sock, struct Interface *); -int get_iface_addrs( - char const *name, - struct in6_addr *if_addr, /* the first link local addr */ - struct in6_addr **if_addrs /* all the addrs */ - ); +int get_iface_addrs(char const *name, struct in6_addr *if_addr, /* the first link local addr */ + struct in6_addr **if_addrs /* all the addrs */ + ); /* interface.c */ int check_iface(struct Interface *); @@ -301,14 +301,14 @@ struct Interface *find_iface_by_name(struct Interface *iface, const char *name); struct Interface *find_iface_by_time(struct Interface *iface_list); void dnssl_init_defaults(struct AdvDNSSL *, struct Interface *); -void for_each_iface(struct Interface *ifaces, void (*foo) (struct Interface * iface, void *), void *data); +void for_each_iface(struct Interface *ifaces, void (*foo)(struct Interface *iface, void *), void *data); void free_ifaces(struct Interface *ifaces); void iface_init_defaults(struct Interface *); void prefix_init_defaults(struct AdvPrefix *); void rdnss_init_defaults(struct AdvRDNSS *, struct Interface *); void reschedule_iface(struct Interface *iface, double next); void route_init_defaults(struct AdvRoute *, struct Interface *); -void touch_iface(struct Interface * iface); +void touch_iface(struct Interface *iface); /* socket.c */ int open_icmpv6_socket(void); @@ -320,28 +320,28 @@ void process(int sock, struct Interface *, unsigned char *, int, struct sockaddr_in6 *, struct in6_pktinfo *, int); /* recv.c */ -int recv_rs_ra(int sock, unsigned char *, struct sockaddr_in6 *, struct in6_pktinfo **, int *, unsigned char*); +int recv_rs_ra(int sock, unsigned char *, struct sockaddr_in6 *, struct in6_pktinfo **, int *, unsigned char *); /* util.c */ int countbits(int b); int count_mask(struct sockaddr_in6 *m); struct in6_addr get_prefix6(struct in6_addr const *addr, struct in6_addr const *mask); -char * strdupf(char const * format, ...) __attribute__ ((format(printf, 1, 2))); +char *strdupf(char const *format, ...) __attribute__((format(printf, 1, 2))); double rand_between(double, double); int check_dnssl_presence(struct AdvDNSSL *, const char *); int check_rdnss_presence(struct AdvRDNSS *, struct in6_addr *); -void safe_buffer_resize(struct safe_buffer * sb, size_t new_capacity); -size_t safe_buffer_append(struct safe_buffer * sb, void const * m, size_t count); -size_t safe_buffer_pad(struct safe_buffer * sb, size_t count); +void safe_buffer_resize(struct safe_buffer *sb, size_t new_capacity); +size_t safe_buffer_append(struct safe_buffer *sb, void const *m, size_t count); +size_t safe_buffer_pad(struct safe_buffer *sb, size_t count); ssize_t readn(int fd, void *buf, size_t count); ssize_t writen(int fd, const void *buf, size_t count); -struct safe_buffer * new_safe_buffer(void); +struct safe_buffer *new_safe_buffer(void); void addrtostr(struct in6_addr const *, char *, size_t); -void safe_buffer_free(struct safe_buffer * sb); -struct safe_buffer_list * new_safe_buffer_list(void); -void safe_buffer_list_free(struct safe_buffer_list * sbl); -struct safe_buffer_list * safe_buffer_list_append(struct safe_buffer_list * sbl); -void safe_buffer_list_to_safe_buffer(struct safe_buffer_list * sbl, struct safe_buffer *sb); +void safe_buffer_free(struct safe_buffer *sb); +struct safe_buffer_list *new_safe_buffer_list(void); +void safe_buffer_list_free(struct safe_buffer_list *sbl); +struct safe_buffer_list *safe_buffer_list_append(struct safe_buffer_list *sbl); +void safe_buffer_list_to_safe_buffer(struct safe_buffer_list *sbl, struct safe_buffer *sb); /* privsep.c */ int privsep_interface_curhlim(const char *iface, uint32_t hlim); @@ -366,7 +366,7 @@ #ifdef __linux__ #if defined IPV6_RECVHOPLIMIT || defined IPV6_RECVPKTINFO #include -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14) +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 14) #if defined IPV6_RECVHOPLIMIT && defined IPV6_2292HOPLIMIT #undef IPV6_RECVHOPLIMIT #define IPV6_RECVHOPLIMIT IPV6_2292HOPLIMIT diff -Nru radvd-2.16/radvdump.c radvd-2.17/radvdump.c --- radvd-2.16/radvdump.c 2017-02-20 14:49:14.000000000 +0000 +++ radvd-2.17/radvdump.c 2017-06-29 04:32:29.000000000 +0000 @@ -13,27 +13,21 @@ * */ +#include "radvd.h" #include "config.h" #include "includes.h" -#include "radvd.h" static char usage_str[] = "[-vhfe] [-d level]"; #ifdef HAVE_GETOPT_LONG -struct option prog_opt[] = { - {"debug", 1, 0, 'd'}, - {"file-format", 0, 0, 'f'}, - {"exclude-defaults", 0, 0, 'e'}, - {"version", 0, 0, 'v'}, - {"help", 0, 0, 'h'}, - {NULL, 0, 0, 0} -}; +struct option prog_opt[] = {{"debug", 1, 0, 'd'}, {"file-format", 0, 0, 'f'}, {"exclude-defaults", 0, 0, 'e'}, + {"version", 0, 0, 'v'}, {"help", 0, 0, 'h'}, {NULL, 0, 0, 0}}; #endif int sock = -1; static void version(void); -static void usage(char const * pname); +static void usage(char const *pname); static void print_ff(unsigned char *, int, struct sockaddr_in6 *, int, unsigned int, int); static void print_preferences(int); @@ -44,9 +38,9 @@ #ifdef HAVE_GETOPT_LONG int opt_idx; #endif - char const * pname = ((pname = strrchr(argv[0], '/')) != NULL) ? pname + 1 : argv[0]; + char const *pname = ((pname = strrchr(argv[0], '/')) != NULL) ? pname + 1 : argv[0]; - /* parse args */ +/* parse args */ #ifdef HAVE_GETOPT_LONG while ((c = getopt_long(argc, argv, "d:fehv", prog_opt, &opt_idx)) > 0) #else @@ -146,7 +140,7 @@ addrtostr(&addr->sin6_addr, addr_str, sizeof(addr_str)); printf("#\n# radvd configuration generated by radvdump %s\n", VERSION); printf("# based on Router Advertisement from %s\n", addr_str); - char if_name[IFNAMSIZ] = { "" }; + char if_name[IFNAMSIZ] = {""}; if_indextoname(if_index, if_name); printf("# received by interface %s\n", if_name); printf("#\n\ninterface %s\n{\n\tAdvSendAdvert on;\n", if_name); @@ -174,8 +168,7 @@ printf("\tAdvDefaultLifetime %hu;\n", ntohs(radvert->nd_ra_router_lifetime)); /* Mobile IPv6 ext */ - if (!edefs - || DFLT_AdvHomeAgentFlag != (ND_RA_FLAG_HOME_AGENT == (radvert->nd_ra_flags_reserved & ND_RA_FLAG_HOME_AGENT))) + if (!edefs || DFLT_AdvHomeAgentFlag != (ND_RA_FLAG_HOME_AGENT == (radvert->nd_ra_flags_reserved & ND_RA_FLAG_HOME_AGENT))) printf("\tAdvHomeAgentFlag %s;\n", (radvert->nd_ra_flags_reserved & ND_RA_FLAG_HOME_AGENT) ? "on" : "off"); /* Route Preferences and more specific routes */ @@ -191,7 +184,7 @@ if (len == 0) return; - uint8_t *opt_str = (uint8_t *) (msg + sizeof(struct nd_router_advert)); + uint8_t *opt_str = (uint8_t *)(msg + sizeof(struct nd_router_advert)); while (len > 0) { @@ -206,51 +199,51 @@ flog(LOG_ERR, "zero length option in RA"); break; } else if (optlen > len) { - flog(LOG_ERR, "option length greater than total" " length in RA (type %d, optlen %d, len %d)", + flog(LOG_ERR, "option length greater than total" + " length in RA (type %d, optlen %d, len %d)", (int)*opt_str, optlen, len); break; } switch (*opt_str) { - case ND_OPT_MTU:{ - struct nd_opt_mtu *mtu = (struct nd_opt_mtu *)opt_str; + case ND_OPT_MTU: { + struct nd_opt_mtu *mtu = (struct nd_opt_mtu *)opt_str; - if (!edefs || DFLT_AdvLinkMTU != ntohl(mtu->nd_opt_mtu_mtu)) - printf("\tAdvLinkMTU %u;\n", ntohl(mtu->nd_opt_mtu_mtu)); - break; - } + if (!edefs || DFLT_AdvLinkMTU != ntohl(mtu->nd_opt_mtu_mtu)) + printf("\tAdvLinkMTU %u;\n", ntohl(mtu->nd_opt_mtu_mtu)); + break; + } case ND_OPT_SOURCE_LINKADDR: /* XXX: !DFLT depends on current DFLT_ value */ if (!edefs || !DFLT_AdvSourceLLAddress) printf("\tAdvSourceLLAddress on;\n"); break; - /* Mobile IPv6 ext */ + /* Mobile IPv6 ext */ case ND_OPT_RTR_ADV_INTERVAL: /* XXX: !DFLT depends on current DFLT_ value */ if (!edefs || !DFLT_AdvIntervalOpt) printf("\tAdvIntervalOpt on;\n"); break; - /* Mobile IPv6 ext */ - case ND_OPT_HOME_AGENT_INFO:{ - struct HomeAgentInfo *ha_info = (struct HomeAgentInfo *)opt_str; - - /* XXX: we check DFLT_HomeAgentInfo by interface, and it's outside - of context here, so we always need to print it out.. */ - printf("\tAdvHomeAgentInfo on;\n"); - - /* NEMO ext */ - if (!edefs - || DFLT_AdvMobRtrSupportFlag != (ha_info->flags_reserved & ND_OPT_HAI_FLAG_SUPPORT_MR)) - printf("\tAdvMobRtrSupportFlag %s;\n", - (ha_info->flags_reserved & ND_OPT_HAI_FLAG_SUPPORT_MR) ? "on" : "off"); - - if (!edefs || DFLT_HomeAgentPreference != ntohs(ha_info->preference)) - printf("\tHomeAgentPreference %hu;\n", ntohs(ha_info->preference)); - /* Hum.. */ - if (!edefs || (3 * DFLT_MaxRtrAdvInterval) != ntohs(ha_info->lifetime)) - printf("\tHomeAgentLifetime %hu;\n", ntohs(ha_info->lifetime)); - break; - } + /* Mobile IPv6 ext */ + case ND_OPT_HOME_AGENT_INFO: { + struct HomeAgentInfo *ha_info = (struct HomeAgentInfo *)opt_str; + + /* XXX: we check DFLT_HomeAgentInfo by interface, and it's outside + of context here, so we always need to print it out.. */ + printf("\tAdvHomeAgentInfo on;\n"); + + /* NEMO ext */ + if (!edefs || DFLT_AdvMobRtrSupportFlag != (ha_info->flags_reserved & ND_OPT_HAI_FLAG_SUPPORT_MR)) + printf("\tAdvMobRtrSupportFlag %s;\n", + (ha_info->flags_reserved & ND_OPT_HAI_FLAG_SUPPORT_MR) ? "on" : "off"); + + if (!edefs || DFLT_HomeAgentPreference != ntohs(ha_info->preference)) + printf("\tHomeAgentPreference %hu;\n", ntohs(ha_info->preference)); + /* Hum.. */ + if (!edefs || (3 * DFLT_MaxRtrAdvInterval) != ntohs(ha_info->lifetime)) + printf("\tHomeAgentLifetime %hu;\n", ntohs(ha_info->lifetime)); + break; + } case ND_OPT_TARGET_LINKADDR: case ND_OPT_REDIRECTED_HEADER: flog(LOG_ERR, "invalid option %d in RA", (int)*opt_str); @@ -277,7 +270,7 @@ if (orig_len == 0) return; - opt_str = (uint8_t *) (msg + sizeof(struct nd_router_advert)); + opt_str = (uint8_t *)(msg + sizeof(struct nd_router_advert)); while (orig_len > 0) { char prefix_str[INET6_ADDRSTRLEN]; @@ -293,158 +286,157 @@ flog(LOG_ERR, "zero length option in RA"); break; } else if (optlen > orig_len) { - flog(LOG_ERR, "option length greater than total" " length in RA (type %d, optlen %d, len %d)", + flog(LOG_ERR, "option length greater than total" + " length in RA (type %d, optlen %d, len %d)", (int)*opt_str, optlen, orig_len); break; } switch (*opt_str) { - case ND_OPT_PREFIX_INFORMATION:{ - struct nd_opt_prefix_info *pinfo = (struct nd_opt_prefix_info *)opt_str; - - addrtostr(&pinfo->nd_opt_pi_prefix, prefix_str, sizeof(prefix_str)); - - printf("\n\tprefix %s/%d\n\t{\n", prefix_str, pinfo->nd_opt_pi_prefix_len); + case ND_OPT_PREFIX_INFORMATION: { + struct nd_opt_prefix_info *pinfo = (struct nd_opt_prefix_info *)opt_str; - if (ntohl(pinfo->nd_opt_pi_valid_time) == 0xffffffff) { - if (!edefs || DFLT_AdvValidLifetime != 0xffffffff) - printf("\t\tAdvValidLifetime infinity; # (0xffffffff)\n"); - } else { - if (!edefs || DFLT_AdvValidLifetime != ntohl(pinfo->nd_opt_pi_valid_time)) - printf("\t\tAdvValidLifetime %u;\n", ntohl(pinfo->nd_opt_pi_valid_time)); - } - if (ntohl(pinfo->nd_opt_pi_preferred_time) == 0xffffffff) { - if (!edefs || DFLT_AdvPreferredLifetime != 0xffffffff) - printf("\t\tAdvPreferredLifetime infinity; # (0xffffffff)\n"); - } else { - if (!edefs || DFLT_AdvPreferredLifetime != ntohl(pinfo->nd_opt_pi_preferred_time)) - printf("\t\tAdvPreferredLifetime %u;\n", - ntohl(pinfo->nd_opt_pi_preferred_time)); - } + addrtostr(&pinfo->nd_opt_pi_prefix, prefix_str, sizeof(prefix_str)); - if (!edefs - || DFLT_AdvOnLinkFlag != (ND_OPT_PI_FLAG_ONLINK == - (pinfo->nd_opt_pi_flags_reserved & ND_OPT_PI_FLAG_ONLINK))) - printf("\t\tAdvOnLink %s;\n", - (pinfo->nd_opt_pi_flags_reserved & ND_OPT_PI_FLAG_ONLINK) ? "on" : "off"); - - if (!edefs - || DFLT_AdvAutonomousFlag != (ND_OPT_PI_FLAG_AUTO == - (pinfo->nd_opt_pi_flags_reserved & ND_OPT_PI_FLAG_AUTO))) - printf("\t\tAdvAutonomous %s;\n", - (pinfo->nd_opt_pi_flags_reserved & ND_OPT_PI_FLAG_AUTO) ? "on" : "off"); - - /* Mobile IPv6 ext */ - if (!edefs - || DFLT_AdvRouterAddr != (ND_OPT_PI_FLAG_RADDR == - (pinfo->nd_opt_pi_flags_reserved & ND_OPT_PI_FLAG_RADDR))) - printf("\t\tAdvRouterAddr %s;\n", - (pinfo->nd_opt_pi_flags_reserved & ND_OPT_PI_FLAG_RADDR) ? "on" : "off"); + printf("\n\tprefix %s/%d\n\t{\n", prefix_str, pinfo->nd_opt_pi_prefix_len); - printf("\t}; # End of prefix definition\n\n"); - break; + if (ntohl(pinfo->nd_opt_pi_valid_time) == 0xffffffff) { + if (!edefs || DFLT_AdvValidLifetime != 0xffffffff) + printf("\t\tAdvValidLifetime infinity; # (0xffffffff)\n"); + } else { + if (!edefs || DFLT_AdvValidLifetime != ntohl(pinfo->nd_opt_pi_valid_time)) + printf("\t\tAdvValidLifetime %u;\n", ntohl(pinfo->nd_opt_pi_valid_time)); + } + if (ntohl(pinfo->nd_opt_pi_preferred_time) == 0xffffffff) { + if (!edefs || DFLT_AdvPreferredLifetime != 0xffffffff) + printf("\t\tAdvPreferredLifetime infinity; # (0xffffffff)\n"); + } else { + if (!edefs || DFLT_AdvPreferredLifetime != ntohl(pinfo->nd_opt_pi_preferred_time)) + printf("\t\tAdvPreferredLifetime %u;\n", ntohl(pinfo->nd_opt_pi_preferred_time)); } - case ND_OPT_ROUTE_INFORMATION:{ - struct nd_opt_route_info_local *rinfo = (struct nd_opt_route_info_local *)opt_str; - if (optlen == 8) { - printf("\n\troute ::/0\n\t{\n"); - } else { - struct in6_addr addr; - memset(&addr, 0, sizeof(addr)); - if (rinfo->nd_opt_ri_len > 1) - memcpy(&addr, &rinfo->nd_opt_ri_prefix, (rinfo->nd_opt_ri_len - 1) * 8); - addrtostr(&addr, prefix_str, sizeof(prefix_str)); - printf("\n\troute %s/%d\n\t{\n", prefix_str, rinfo->nd_opt_ri_prefix_len); - } + if (!edefs || + DFLT_AdvOnLinkFlag != + (ND_OPT_PI_FLAG_ONLINK == (pinfo->nd_opt_pi_flags_reserved & ND_OPT_PI_FLAG_ONLINK))) + printf("\t\tAdvOnLink %s;\n", + (pinfo->nd_opt_pi_flags_reserved & ND_OPT_PI_FLAG_ONLINK) ? "on" : "off"); + + if (!edefs || + DFLT_AdvAutonomousFlag != + (ND_OPT_PI_FLAG_AUTO == (pinfo->nd_opt_pi_flags_reserved & ND_OPT_PI_FLAG_AUTO))) + printf("\t\tAdvAutonomous %s;\n", + (pinfo->nd_opt_pi_flags_reserved & ND_OPT_PI_FLAG_AUTO) ? "on" : "off"); - if (!edefs - || (((radvert->nd_ra_flags_reserved & 0x18) >> 3) & 0xff) != DFLT_AdvRoutePreference) { - printf("\t\tAdvRoutePreference "); - print_preferences(((rinfo->nd_opt_ri_flags_reserved & 0x18) >> 3) & 0xff); - printf(";\n"); - } + /* Mobile IPv6 ext */ + if (!edefs || + DFLT_AdvRouterAddr != + (ND_OPT_PI_FLAG_RADDR == (pinfo->nd_opt_pi_flags_reserved & ND_OPT_PI_FLAG_RADDR))) + printf("\t\tAdvRouterAddr %s;\n", + (pinfo->nd_opt_pi_flags_reserved & ND_OPT_PI_FLAG_RADDR) ? "on" : "off"); + + printf("\t}; # End of prefix definition\n\n"); + break; + } + case ND_OPT_ROUTE_INFORMATION: { + struct nd_opt_route_info_local *rinfo = (struct nd_opt_route_info_local *)opt_str; - /* XXX: we check DFLT_AdvRouteLifetime by interface, and it's outside of context here */ - if (ntohl(rinfo->nd_opt_ri_lifetime) == 0xffffffff) - printf("\t\tAdvRouteLifetime infinity; # (0xffffffff)\n"); - else - printf("\t\tAdvRouteLifetime %u;\n", ntohl(rinfo->nd_opt_ri_lifetime)); + if (optlen == 8) { + printf("\n\troute ::/0\n\t{\n"); + } else { + struct in6_addr addr; + memset(&addr, 0, sizeof(addr)); + if (rinfo->nd_opt_ri_len > 1) + memcpy(&addr, &rinfo->nd_opt_ri_prefix, (rinfo->nd_opt_ri_len - 1) * 8); + addrtostr(&addr, prefix_str, sizeof(prefix_str)); + printf("\n\troute %s/%d\n\t{\n", prefix_str, rinfo->nd_opt_ri_prefix_len); + } - printf("\t}; # End of route definition\n\n"); - break; + if (!edefs || (((radvert->nd_ra_flags_reserved & 0x18) >> 3) & 0xff) != DFLT_AdvRoutePreference) { + printf("\t\tAdvRoutePreference "); + print_preferences(((rinfo->nd_opt_ri_flags_reserved & 0x18) >> 3) & 0xff); + printf(";\n"); } - case ND_OPT_RDNSS_INFORMATION:{ - struct nd_opt_rdnss_info_local *rdnss_info = (struct nd_opt_rdnss_info_local *)opt_str; - printf("\n\tRDNSS"); + /* XXX: we check DFLT_AdvRouteLifetime by interface, and it's outside of context here */ + if (ntohl(rinfo->nd_opt_ri_lifetime) == 0xffffffff) + printf("\t\tAdvRouteLifetime infinity; # (0xffffffff)\n"); + else + printf("\t\tAdvRouteLifetime %u;\n", ntohl(rinfo->nd_opt_ri_lifetime)); - addrtostr(&rdnss_info->nd_opt_rdnssi_addr1, prefix_str, sizeof(prefix_str)); - printf(" %s", prefix_str); + printf("\t}; # End of route definition\n\n"); + break; + } + case ND_OPT_RDNSS_INFORMATION: { + struct nd_opt_rdnss_info_local *rdnss_info = (struct nd_opt_rdnss_info_local *)opt_str; - if (rdnss_info->nd_opt_rdnssi_len >= 5) { - addrtostr(&rdnss_info->nd_opt_rdnssi_addr2, prefix_str, sizeof(prefix_str)); - printf(" %s", prefix_str); - } - if (rdnss_info->nd_opt_rdnssi_len >= 7) { - addrtostr(&rdnss_info->nd_opt_rdnssi_addr3, prefix_str, sizeof(prefix_str)); - printf(" %s", prefix_str); - } + printf("\n\tRDNSS"); - printf("\n\t{\n"); - /* as AdvRDNSSLifetime may depend on MaxRtrAdvInterval, it could change */ - if (ntohl(rdnss_info->nd_opt_rdnssi_lifetime) == 0xffffffff) - printf("\t\tAdvRDNSSLifetime infinity; # (0xffffffff)\n"); - else - printf("\t\tAdvRDNSSLifetime %u;\n", ntohl(rdnss_info->nd_opt_rdnssi_lifetime)); + addrtostr(&rdnss_info->nd_opt_rdnssi_addr1, prefix_str, sizeof(prefix_str)); + printf(" %s", prefix_str); - printf("\t}; # End of RDNSS definition\n\n"); - break; + if (rdnss_info->nd_opt_rdnssi_len >= 5) { + addrtostr(&rdnss_info->nd_opt_rdnssi_addr2, prefix_str, sizeof(prefix_str)); + printf(" %s", prefix_str); + } + if (rdnss_info->nd_opt_rdnssi_len >= 7) { + addrtostr(&rdnss_info->nd_opt_rdnssi_addr3, prefix_str, sizeof(prefix_str)); + printf(" %s", prefix_str); } - case ND_OPT_DNSSL_INFORMATION:{ - struct nd_opt_dnssl_info_local *dnssl_info = (struct nd_opt_dnssl_info_local *)opt_str; - printf("\n\tDNSSL"); + printf("\n\t{\n"); + /* as AdvRDNSSLifetime may depend on MaxRtrAdvInterval, it could change */ + if (ntohl(rdnss_info->nd_opt_rdnssi_lifetime) == 0xffffffff) + printf("\t\tAdvRDNSSLifetime infinity; # (0xffffffff)\n"); + else + printf("\t\tAdvRDNSSLifetime %u;\n", ntohl(rdnss_info->nd_opt_rdnssi_lifetime)); - char suffix[256] = { "" }; - for (int offset = 0; offset < (dnssl_info->nd_opt_dnssli_len - 1) * 8;) { - int label_len = dnssl_info->nd_opt_dnssli_suffixes[offset++]; - - if (label_len == 0) { - /* - * Ignore empty suffixes. They're - * probably just padding... - */ - if (suffix[0] == '\0') - continue; + printf("\t}; # End of RDNSS definition\n\n"); + break; + } + case ND_OPT_DNSSL_INFORMATION: { + struct nd_opt_dnssl_info_local *dnssl_info = (struct nd_opt_dnssl_info_local *)opt_str; - printf(" %s", suffix); + printf("\n\tDNSSL"); - suffix[0] = '\0'; + char suffix[256] = {""}; + for (int offset = 0; offset < (dnssl_info->nd_opt_dnssli_len - 1) * 8;) { + int label_len = dnssl_info->nd_opt_dnssli_suffixes[offset++]; + + if (label_len == 0) { + /* + * Ignore empty suffixes. They're + * probably just padding... + */ + if (suffix[0] == '\0') continue; - } - if ((sizeof(suffix) - strlen(suffix)) < (label_len + 2)) { - flog(LOG_ERR, "oversized suffix in DNSSL option from %s", addr_str); - break; - } - - if (suffix[0] != '\0') - strcat(suffix, "."); - strncat(suffix, (char *)&dnssl_info->nd_opt_dnssli_suffixes[offset], label_len); - offset += label_len; + printf(" %s", suffix); + + suffix[0] = '\0'; + continue; } - printf("\n\t{\n"); - /* as AdvDNSSLLifetime may depend on MaxRtrAdvInterval, it could change */ - if (ntohl(dnssl_info->nd_opt_dnssli_lifetime) == 0xffffffff) - printf("\t\tAdvDNSSLLifetime infinity; # (0xffffffff)\n"); - else - printf("\t\tAdvDNSSLLifetime %u;\n", ntohl(dnssl_info->nd_opt_dnssli_lifetime)); + if ((sizeof(suffix) - strlen(suffix)) < (label_len + 2)) { + flog(LOG_ERR, "oversized suffix in DNSSL option from %s", addr_str); + break; + } - printf("\t}; # End of DNSSL definition\n\n"); - break; + if (suffix[0] != '\0') + strcat(suffix, "."); + strncat(suffix, (char *)&dnssl_info->nd_opt_dnssli_suffixes[offset], label_len); + offset += label_len; } + + printf("\n\t{\n"); + /* as AdvDNSSLLifetime may depend on MaxRtrAdvInterval, it could change */ + if (ntohl(dnssl_info->nd_opt_dnssli_lifetime) == 0xffffffff) + printf("\t\tAdvDNSSLLifetime infinity; # (0xffffffff)\n"); + else + printf("\t\tAdvDNSSLLifetime %u;\n", ntohl(dnssl_info->nd_opt_dnssli_lifetime)); + + printf("\t}; # End of DNSSL definition\n\n"); + break; + } default: break; } @@ -482,9 +474,8 @@ exit(-1); } -static void usage(char const * pname) +static void usage(char const *pname) { fprintf(stderr, "usage: %s %s\n", pname, usage_str); exit(-1); } - diff -Nru radvd-2.16/recv.c radvd-2.17/recv.c --- radvd-2.16/recv.c 2017-02-20 14:49:14.000000000 +0000 +++ radvd-2.17/recv.c 2017-06-29 04:32:29.000000000 +0000 @@ -17,15 +17,16 @@ #include "includes.h" #include "radvd.h" -int recv_rs_ra(int sock, unsigned char *msg, struct sockaddr_in6 *addr, struct in6_pktinfo **pkt_info, int *hoplimit, unsigned char * chdr) +int recv_rs_ra(int sock, unsigned char *msg, struct sockaddr_in6 *addr, struct in6_pktinfo **pkt_info, int *hoplimit, + unsigned char *chdr) { struct iovec iov; iov.iov_len = MSG_SIZE_RECV; - iov.iov_base = (caddr_t) msg; + iov.iov_base = (caddr_t)msg; struct msghdr mhdr; memset(&mhdr, 0, sizeof(mhdr)); - mhdr.msg_name = (caddr_t) addr; + mhdr.msg_name = (caddr_t)addr; mhdr.msg_namelen = sizeof(*addr); mhdr.msg_iov = &iov; mhdr.msg_iovlen = 1; @@ -50,8 +51,8 @@ switch (cmsg->cmsg_type) { #ifdef IPV6_HOPLIMIT case IPV6_HOPLIMIT: - if ((cmsg->cmsg_len == CMSG_LEN(sizeof(int))) && (*(int *)CMSG_DATA(cmsg) >= 0) - && (*(int *)CMSG_DATA(cmsg) < 256)) { + if ((cmsg->cmsg_len == CMSG_LEN(sizeof(int))) && (*(int *)CMSG_DATA(cmsg) >= 0) && + (*(int *)CMSG_DATA(cmsg) < 256)) { *hoplimit = *(int *)CMSG_DATA(cmsg); } else { flog(LOG_ERR, "received a bogus IPV6_HOPLIMIT from the kernel! len=%d, data=%d", @@ -59,10 +60,10 @@ return -1; } break; -#endif /* IPV6_HOPLIMIT */ +#endif /* IPV6_HOPLIMIT */ case IPV6_PKTINFO: - if ((cmsg->cmsg_len == CMSG_LEN(sizeof(struct in6_pktinfo))) - && ((struct in6_pktinfo *)CMSG_DATA(cmsg))->ipi6_ifindex) { + if ((cmsg->cmsg_len == CMSG_LEN(sizeof(struct in6_pktinfo))) && + ((struct in6_pktinfo *)CMSG_DATA(cmsg))->ipi6_ifindex) { *pkt_info = (struct in6_pktinfo *)CMSG_DATA(cmsg); } else { flog(LOG_ERR, "received a bogus IPV6_PKTINFO from the kernel! len=%d, index=%d", @@ -73,7 +74,7 @@ } } - char if_namebuf[IF_NAMESIZE] = { "" }; + char if_namebuf[IF_NAMESIZE] = {""}; char *if_name = 0; if (pkt_info && *pkt_info) { if_name = if_indextoname((*pkt_info)->ipi6_ifindex, if_namebuf); diff -Nru radvd-2.16/redhat/radvd.spec radvd-2.17/redhat/radvd.spec --- radvd-2.16/redhat/radvd.spec 2017-02-20 14:49:14.000000000 +0000 +++ radvd-2.17/redhat/radvd.spec 2017-07-04 03:31:12.000000000 +0000 @@ -5,7 +5,7 @@ Summary: A Router Advertisement daemon Name: radvd -Version: 2.16 +Version: 2.17 Release: 1 # The code includes the advertising clause, so it's GPL-incompatible License: BSD with advertising diff -Nru radvd-2.16/scanner.l radvd-2.17/scanner.l --- radvd-2.16/scanner.l 2017-02-20 14:49:14.000000000 +0000 +++ radvd-2.17/scanner.l 2017-07-02 01:59:02.000000000 +0000 @@ -79,6 +79,7 @@ AdvIntervalOpt { return T_AdvIntervalOpt; } AdvHomeAgentInfo { return T_AdvHomeAgentInfo; } UnicastOnly { return T_UnicastOnly; } +AdvRASolicitedUnicast { return T_AdvRASolicitedUnicast; } Base6Interface { return T_Base6Interface; } Base6to4Interface { return T_Base6to4Interface; } diff -Nru radvd-2.16/send.c radvd-2.17/send.c --- radvd-2.16/send.c 2017-02-20 14:49:14.000000000 +0000 +++ radvd-2.17/send.c 2017-06-29 04:32:29.000000000 +0000 @@ -19,30 +19,35 @@ static int really_send(int sock, struct in6_addr const *dest, struct properties const *props, struct safe_buffer const *sb); static int send_ra(int sock, struct Interface *iface, struct in6_addr const *dest); -static struct safe_buffer_list * build_ra_options(struct Interface const * iface, struct in6_addr const *dest); +static struct safe_buffer_list *build_ra_options(struct Interface const *iface, struct in6_addr const *dest); static int ensure_iface_setup(int sock, struct Interface *iface); -static void decrement_lifetime(const time_t secs, uint32_t * lifetime); -static void update_iface_times(struct Interface * iface); +static void decrement_lifetime(const time_t secs, uint32_t *lifetime); +static void update_iface_times(struct Interface *iface); // Option helpers -static size_t serialize_domain_names(struct safe_buffer * safe_buffer, struct AdvDNSSL const *dnssl); +static size_t serialize_domain_names(struct safe_buffer *safe_buffer, struct AdvDNSSL const *dnssl); // Options that only need a single block -static void add_ra_header(struct safe_buffer * sb, struct ra_header_info const * ra_header_info, int cease_adv); -static void add_ra_option_prefix(struct safe_buffer * sb, struct AdvPrefix const * prefix, int cease_adv); -static void add_ra_option_mtu(struct safe_buffer * sb, uint32_t AdvLinkMTU); -static void add_ra_option_sllao(struct safe_buffer * sb, struct sllao const *sllao); -static void add_ra_option_mipv6_rtr_adv_interval(struct safe_buffer * sb, double MaxRtrAdvInterval); -static void add_ra_option_mipv6_home_agent_info(struct safe_buffer * sb, struct mipv6 const * mipv6); -static void add_ra_option_lowpanco(struct safe_buffer * sb, struct AdvLowpanCo const *lowpanco); -static void add_ra_option_abro(struct safe_buffer * sb, struct AdvAbro const *abroo); +static void add_ra_header(struct safe_buffer *sb, struct ra_header_info const *ra_header_info, int cease_adv); +static void add_ra_option_prefix(struct safe_buffer *sb, struct AdvPrefix const *prefix, int cease_adv); +static void add_ra_option_mtu(struct safe_buffer *sb, uint32_t AdvLinkMTU); +static void add_ra_option_sllao(struct safe_buffer *sb, struct sllao const *sllao); +static void add_ra_option_mipv6_rtr_adv_interval(struct safe_buffer *sb, double MaxRtrAdvInterval); +static void add_ra_option_mipv6_home_agent_info(struct safe_buffer *sb, struct mipv6 const *mipv6); +static void add_ra_option_lowpanco(struct safe_buffer *sb, struct AdvLowpanCo const *lowpanco); +static void add_ra_option_abro(struct safe_buffer *sb, struct AdvAbro const *abroo); // Options that generate 0 or more blocks -static struct safe_buffer_list* add_ra_options_prefix(struct safe_buffer_list * sbl, struct Interface const * iface, char const * ifname, struct AdvPrefix const * prefix, int cease_adv, struct in6_addr const *dest); -static struct safe_buffer_list* add_ra_options_route(struct safe_buffer_list * sbl, struct Interface const * iface, struct AdvRoute const *route, int cease_adv, struct in6_addr const *dest); -static struct safe_buffer_list* add_ra_options_rdnss(struct safe_buffer_list * sbl, struct Interface const * iface, struct AdvRDNSS const *rdnss, int cease_adv, struct in6_addr const *dest); -static struct safe_buffer_list* add_ra_options_dnssl(struct safe_buffer_list * sbl, struct Interface const * iface, struct AdvDNSSL const *dnssl, int cease_adv, struct in6_addr const *dest); +static struct safe_buffer_list *add_ra_options_prefix(struct safe_buffer_list *sbl, struct Interface const *iface, + char const *ifname, struct AdvPrefix const *prefix, int cease_adv, + struct in6_addr const *dest); +static struct safe_buffer_list *add_ra_options_route(struct safe_buffer_list *sbl, struct Interface const *iface, + struct AdvRoute const *route, int cease_adv, struct in6_addr const *dest); +static struct safe_buffer_list *add_ra_options_rdnss(struct safe_buffer_list *sbl, struct Interface const *iface, + struct AdvRDNSS const *rdnss, int cease_adv, struct in6_addr const *dest); +static struct safe_buffer_list *add_ra_options_dnssl(struct safe_buffer_list *sbl, struct Interface const *iface, + struct AdvDNSSL const *dnssl, int cease_adv, struct in6_addr const *dest); // Scheduling of options per RFC7772 static int schedule_helper(struct in6_addr const *dest, struct Interface const *iface, int option_lifetime); @@ -61,7 +66,6 @@ #include "test/send.c" #endif - /* * Sends an advertisement for all specified clients of this interface * (or via broadcast, if there are no restrictions configured). @@ -91,7 +95,7 @@ } /* If clients are configured, send the advertisement to all of them via unicast */ - for (struct Clients * current = iface->ClientList; current; current = current->next) { + for (struct Clients *current = iface->ClientList; current; current = current->next) { /* If a non-authorized client sent a solicitation, ignore it (logging later) */ if (dest != NULL && memcmp(dest, ¤t->Address, sizeof(struct in6_addr)) != 0) continue; @@ -108,7 +112,7 @@ /* If we refused a client's solicitation, log it if debugging is high enough */ if (get_debuglevel() >= 5) { - char address_text[INET6_ADDRSTRLEN] = { "" }; + char address_text[INET6_ADDRSTRLEN] = {""}; addrtostr(dest, address_text, INET6_ADDRSTRLEN); dlog(LOG_DEBUG, 5, "Not answering request from %s, not configured", address_text); } @@ -116,9 +120,6 @@ return 0; } - - - /******************************************************************************** * support functions * ********************************************************************************/ @@ -135,7 +136,7 @@ return (iface->state_info.ready ? 0 : -1); } -static void decrement_lifetime(const time_t secs, uint32_t * lifetime) +static void decrement_lifetime(const time_t secs, uint32_t *lifetime) { if (*lifetime > secs) { *lifetime -= secs; @@ -144,7 +145,7 @@ } } -static void update_iface_times(struct Interface * iface) +static void update_iface_times(struct Interface *iface) { struct timespec last_time = iface->times.last_ra_time; clock_gettime(CLOCK_MONOTONIC, &iface->times.last_ra_time); @@ -167,7 +168,8 @@ if (prefix->curr_preferredlft == 0) { char pfx_str[INET6_ADDRSTRLEN]; addrtostr(&prefix->Prefix, pfx_str, sizeof(pfx_str)); - dlog(LOG_DEBUG, 3, "Will cease advertising %s/%u%%%s, preferred lifetime is 0", pfx_str, prefix->PrefixLen, iface->props.name); + dlog(LOG_DEBUG, 3, "Will cease advertising %s/%u%%%s, preferred lifetime is 0", + pfx_str, prefix->PrefixLen, iface->props.name); } } } @@ -176,12 +178,11 @@ } } - /******************************************************************************** * add_ra_* * ********************************************************************************/ -static void add_ra_header(struct safe_buffer * sb, struct ra_header_info const * ra_header_info, int cease_adv) +static void add_ra_header(struct safe_buffer *sb, struct ra_header_info const *ra_header_info, int cease_adv) { struct nd_router_advert radvert; @@ -200,7 +201,7 @@ radvert.nd_ra_router_lifetime = 0; } else { /* if forwarding is disabled, send zero router lifetime */ - radvert.nd_ra_router_lifetime = !check_ip6_forwarding()? htons(ra_header_info->AdvDefaultLifetime) : 0; + radvert.nd_ra_router_lifetime = !check_ip6_forwarding() ? htons(ra_header_info->AdvDefaultLifetime) : 0; } radvert.nd_ra_flags_reserved |= (ra_header_info->AdvDefaultPreference << ND_OPT_RI_PRF_SHIFT) & ND_OPT_RI_PRF_MASK; @@ -210,7 +211,7 @@ safe_buffer_append(sb, &radvert, sizeof(radvert)); } -static void add_ra_option_prefix(struct safe_buffer * sb, struct AdvPrefix const * prefix, int cease_adv) +static void add_ra_option_prefix(struct safe_buffer *sb, struct AdvPrefix const *prefix, int cease_adv) { struct nd_opt_prefix_info pinfo; @@ -243,7 +244,9 @@ safe_buffer_append(sb, &pinfo, sizeof(pinfo)); } -static struct safe_buffer_list * add_auto_prefixes_6to4(struct safe_buffer_list * sbl, struct Interface const * iface, char const * ifname, struct AdvPrefix const *prefix, int cease_adv, struct in6_addr const *dest) +static struct safe_buffer_list *add_auto_prefixes_6to4(struct safe_buffer_list *sbl, struct Interface const *iface, + char const *ifname, struct AdvPrefix const *prefix, int cease_adv, + struct in6_addr const *dest) { #ifdef HAVE_IFADDRS_H struct AdvPrefix xprefix = *prefix; @@ -257,14 +260,13 @@ char pfx_str[INET6_ADDRSTRLEN]; addrtostr(&xprefix.Prefix, pfx_str, sizeof(pfx_str)); - dlog(LOG_DEBUG, 3, "auto-selected prefix %s/%d on interface %s", - pfx_str, xprefix.PrefixLen, ifname); + dlog(LOG_DEBUG, 3, "auto-selected prefix %s/%d on interface %s", pfx_str, xprefix.PrefixLen, ifname); /* TODO: Something must be done with these. */ (void)xprefix.curr_validlft; (void)xprefix.curr_preferredlft; - if(cease_adv || schedule_option_prefix(dest, iface, &xprefix)) { + if (cease_adv || schedule_option_prefix(dest, iface, &xprefix)) { sbl = safe_buffer_list_append(sbl); add_ra_option_prefix(sbl->sb, &xprefix, cease_adv); } @@ -273,8 +275,8 @@ return sbl; } - -static struct safe_buffer_list * add_auto_prefixes(struct safe_buffer_list * sbl, struct Interface const * iface, char const * ifname, struct AdvPrefix const *prefix, int cease_adv, struct in6_addr const *dest) +static struct safe_buffer_list *add_auto_prefixes(struct safe_buffer_list *sbl, struct Interface const *iface, char const *ifname, + struct AdvPrefix const *prefix, int cease_adv, struct in6_addr const *dest) { #ifdef HAVE_IFADDRS_H struct AdvPrefix xprefix; @@ -303,14 +305,13 @@ char pfx_str[INET6_ADDRSTRLEN]; addrtostr(&xprefix.Prefix, pfx_str, sizeof(pfx_str)); - dlog(LOG_DEBUG, 3, "auto-selected prefix %s/%d on interface %s", - pfx_str, xprefix.PrefixLen, ifname); + dlog(LOG_DEBUG, 3, "auto-selected prefix %s/%d on interface %s", pfx_str, xprefix.PrefixLen, ifname); /* TODO: Something must be done with these. */ (void)xprefix.curr_validlft; (void)xprefix.curr_preferredlft; - if(cease_adv || schedule_option_prefix(dest, iface, &xprefix)) { + if (cease_adv || schedule_option_prefix(dest, iface, &xprefix)) { sbl = safe_buffer_list_append(sbl); add_ra_option_prefix(sbl->sb, &xprefix, cease_adv); } @@ -322,7 +323,9 @@ return sbl; } -static struct safe_buffer_list* add_ra_options_prefix(struct safe_buffer_list * sbl, struct Interface const * iface, char const * ifname, struct AdvPrefix const *prefix, int cease_adv, struct in6_addr const *dest) +static struct safe_buffer_list *add_ra_options_prefix(struct safe_buffer_list *sbl, struct Interface const *iface, + char const *ifname, struct AdvPrefix const *prefix, int cease_adv, + struct in6_addr const *dest) { while (prefix) { if ((!prefix->DecrementLifetimesFlag || prefix->curr_preferredlft > 0)) { @@ -341,7 +344,7 @@ sbl = add_auto_prefixes(sbl, iface, iface->props.name, prefix, cease_adv, dest); } } else { - if(cease_adv || schedule_option_prefix(dest, iface, prefix)) { + if (cease_adv || schedule_option_prefix(dest, iface, prefix)) { sbl = safe_buffer_list_append(sbl); add_ra_option_prefix(sbl->sb, prefix, cease_adv); } @@ -353,9 +356,7 @@ return sbl; } - - -/* *INDENT-OFF* */ +/* clang-format off */ /* * Domain Names of DNS Search List * One or more domain names of DNS Search List that MUST @@ -374,8 +375,8 @@ * encoding parts of the domain name representations * MUST be padded with zeros. */ -/* *INDENT-ON* */ -static size_t serialize_domain_names(struct safe_buffer * safe_buffer, struct AdvDNSSL const *dnssl) +/* clang-format on */ +static size_t serialize_domain_names(struct safe_buffer *safe_buffer, struct AdvDNSSL const *dnssl) { size_t len = 0; @@ -410,12 +411,13 @@ return len; } -static struct safe_buffer_list* add_ra_options_route(struct safe_buffer_list *sbl, struct Interface const * iface, struct AdvRoute const *route, int cease_adv, struct in6_addr const *dest) +static struct safe_buffer_list *add_ra_options_route(struct safe_buffer_list *sbl, struct Interface const *iface, + struct AdvRoute const *route, int cease_adv, struct in6_addr const *dest) { while (route) { struct nd_opt_route_info_local rinfo; - if(!cease_adv && !schedule_option_route(dest, iface, route)) { + if (!cease_adv && !schedule_option_route(dest, iface, route)) { route = route->next; continue; } @@ -444,12 +446,13 @@ return sbl; } -static struct safe_buffer_list * add_ra_options_rdnss(struct safe_buffer_list * sbl, struct Interface const * iface, struct AdvRDNSS const *rdnss, int cease_adv, struct in6_addr const *dest) +static struct safe_buffer_list *add_ra_options_rdnss(struct safe_buffer_list *sbl, struct Interface const *iface, + struct AdvRDNSS const *rdnss, int cease_adv, struct in6_addr const *dest) { while (rdnss) { struct nd_opt_rdnss_info_local rdnssinfo; - if(!cease_adv && !schedule_option_rdnss(dest, iface, rdnss)) { + if (!cease_adv && !schedule_option_rdnss(dest, iface, rdnss)) { rdnss = rdnss->next; continue; } @@ -471,7 +474,8 @@ memcpy(&rdnssinfo.nd_opt_rdnssi_addr3, &rdnss->AdvRDNSSAddr3, sizeof(struct in6_addr)); sbl = safe_buffer_list_append(sbl); - safe_buffer_append(sbl->sb, &rdnssinfo, sizeof(rdnssinfo) - (3 - rdnss->AdvRDNSSNumber) * sizeof(struct in6_addr)); + safe_buffer_append(sbl->sb, &rdnssinfo, + sizeof(rdnssinfo) - (3 - rdnss->AdvRDNSSNumber) * sizeof(struct in6_addr)); rdnss = rdnss->next; } @@ -479,70 +483,15 @@ return sbl; } -static struct safe_buffer_list * add_ra_options_dnssl(struct safe_buffer_list * sbl, struct Interface const * iface, struct AdvDNSSL const *dnssl, int cease_adv, struct in6_addr const *dest) +static struct safe_buffer_list *add_ra_options_dnssl(struct safe_buffer_list *sbl, struct Interface const *iface, + struct AdvDNSSL const *dnssl, int cease_adv, struct in6_addr const *dest) { struct safe_buffer *serialized_domains = new_safe_buffer(); while (dnssl) { - /* *INDENT-OFF* */ - /* - * Snippet from RFC 6106... - * - * 5.2. DNS Search List Option - * - * - * The DNSSL option contains one or more domain names of DNS suffixes. - * All of the domain names share the same Lifetime value. If it is - * desirable to have different Lifetime values, multiple DNSSL options - * can be used. Figure 2 shows the format of the DNSSL option. - * - * 0 1 2 3 - * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | Type | Length | Reserved | - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | Lifetime | - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | | - * : Domain Names of DNS Search List : - * | | - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * - * Figure 2: DNS Search List (DNSSL) Option Format - * - * Fields: - * Type 8-bit identifier of the DNSSL option type as assigned - * by the IANA: 31 - * - * Length 8-bit unsigned integer. The length of the option - * (including the Type and Length fields) is in units of - * 8 octets. The minimum value is 2 if at least one - * domain name is contained in the option. The Length - * field is set to a multiple of 8 octets to accommodate - * all the domain names in the field of Domain Names of - * DNS Search List. - * - * Lifetime 32-bit unsigned integer. The maximum time, in - * seconds (relative to the time the packet is sent), - * over which this DNSSL domain name MAY be used for - * name resolution. The Lifetime value has the same - * semantics as with the RDNSS option. That is, Lifetime - * SHOULD be bounded as follows: - * MaxRtrAdvInterval <= Lifetime <= 2*MaxRtrAdvInterval. - * A value of all one bits (0xffffffff) represents - * infinity. A value of zero means that the DNSSL - * domain name MUST no longer be used. - * - * Domain Names of DNS Search List - * One or more domain names of DNS Search List that MUST - * be encoded using the technique described in Section - * 3.1 of [RFC1035]. - * - */ - /* *INDENT-ON* */ struct nd_opt_dnssl_info_local dnsslinfo; - if(!cease_adv && !schedule_option_dnssl(dest, iface, dnssl)) { + if (!cease_adv && !schedule_option_dnssl(dest, iface, dnssl)) { dnssl = dnssl->next; continue; } @@ -552,11 +501,11 @@ serialized_domains->used = 0; size_t const domain_name_bytes = serialize_domain_names(serialized_domains, dnssl); size_t const bytes = sizeof(dnsslinfo) + domain_name_bytes; - if(bytes > (256 * 8)) { + if (bytes > (256 * 8)) { flog(LOG_ERR, "DNSSL too long for RA option, must be < 2048 bytes. Exiting."); exit(1); } - + dnsslinfo.nd_opt_dnssli_type = ND_OPT_DNSSL_INFORMATION; dnsslinfo.nd_opt_dnssli_len = (bytes + 7) / 8; dnsslinfo.nd_opt_dnssli_reserved = 0; @@ -574,53 +523,19 @@ safe_buffer_append(sbl->sb, &dnsslinfo, sizeof(dnsslinfo)); safe_buffer_append(sbl->sb, serialized_domains->buffer, serialized_domains->used); safe_buffer_pad(sbl->sb, padding); - //abort(); + // abort(); dnssl = dnssl->next; } return sbl; safe_buffer_free(serialized_domains); - } /* * add Source Link-layer Address option */ -static void add_ra_option_sllao(struct safe_buffer * sb, struct sllao const *sllao) +static void add_ra_option_sllao(struct safe_buffer *sb, struct sllao const *sllao) { - /* *INDENT-OFF* */ - /* - 4.6.1. Source/Target Link-layer Address - - 0 1 2 3 - 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | Type | Length | Link-Layer Address ... - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - - Fields: - - Type - 1 for Source Link-layer Address - 2 for Target Link-layer Address - - Length The length of the option (including the type and - length fields) in units of 8 octets. For example, - the length for IEEE 802 addresses is 1 [IPv6- - ETHER]. - - Link-Layer Address - The variable length link-layer address. - - The content and format of this field (including - byte and bit ordering) is expected to be specified - in specific documents that describe how IPv6 - operates over different link layers. For instance, - [IPv6-ETHER]. - - */ - /* *INDENT-ON* */ - /* +2 for the ND_OPT_SOURCE_LINKADDR and the length (each occupy one byte) */ size_t const sllao_bytes = (sllao->if_hwaddr_len / 8) + 2; size_t const sllao_len = (sllao_bytes + 7) / 8; @@ -633,7 +548,7 @@ safe_buffer_pad(sb, sllao_len * 8 - sllao_bytes); } -static void add_ra_option_mtu(struct safe_buffer * sb, uint32_t AdvLinkMTU) +static void add_ra_option_mtu(struct safe_buffer *sb, uint32_t AdvLinkMTU) { struct nd_opt_mtu mtu; @@ -651,7 +566,7 @@ * Mobile IPv6 ext: Advertisement Interval Option to support * movement detection of mobile nodes */ -static void add_ra_option_mipv6_rtr_adv_interval(struct safe_buffer * sb, double MaxRtrAdvInterval) +static void add_ra_option_mipv6_rtr_adv_interval(struct safe_buffer *sb, double MaxRtrAdvInterval) { uint32_t ival = 1000; @@ -677,7 +592,7 @@ * Mobile IPv6 ext: Home Agent Information Option to support * Dynamic Home Agent Address Discovery */ -static void add_ra_option_mipv6_home_agent_info(struct safe_buffer * sb, struct mipv6 const * mipv6) +static void add_ra_option_mipv6_home_agent_info(struct safe_buffer *sb, struct mipv6 const *mipv6) { struct HomeAgentInfo ha_info; @@ -695,7 +610,7 @@ /* * Add 6co option */ -static void add_ra_option_lowpanco(struct safe_buffer * sb, struct AdvLowpanCo const *lowpanco) +static void add_ra_option_lowpanco(struct safe_buffer *sb, struct AdvLowpanCo const *lowpanco) { struct nd_opt_6co co; @@ -712,7 +627,7 @@ safe_buffer_append(sb, &co, sizeof(co)); } -static void add_ra_option_abro(struct safe_buffer * sb, struct AdvAbro const *abroo) +static void add_ra_option_abro(struct safe_buffer *sb, struct AdvAbro const *abroo) { struct nd_opt_abro abro; @@ -728,14 +643,14 @@ safe_buffer_append(sb, &abro, sizeof(abro)); } - -static struct safe_buffer_list * build_ra_options(struct Interface const * iface, struct in6_addr const *dest) +static struct safe_buffer_list *build_ra_options(struct Interface const *iface, struct in6_addr const *dest) { struct safe_buffer_list *sbl = new_safe_buffer_list(); struct safe_buffer_list *cur = sbl; if (iface->AdvPrefixList) { - cur = add_ra_options_prefix(cur, iface, iface->props.name, iface->AdvPrefixList, iface->state_info.cease_adv, dest); + cur = + add_ra_options_prefix(cur, iface, iface->props.name, iface->AdvPrefixList, iface->state_info.cease_adv, dest); } if (iface->AdvRouteList) { @@ -768,9 +683,9 @@ add_ra_option_mipv6_rtr_adv_interval(cur->sb, iface->MaxRtrAdvInterval); } - if (iface->mipv6.AdvHomeAgentInfo && schedule_option_mipv6_home_agent_info(dest, iface) - && (iface->mipv6.AdvMobRtrSupportFlag || iface->mipv6.HomeAgentPreference != 0 - || iface->mipv6.HomeAgentLifetime != iface->ra_header_info.AdvDefaultLifetime)) { + if (iface->mipv6.AdvHomeAgentInfo && schedule_option_mipv6_home_agent_info(dest, iface) && + (iface->mipv6.AdvMobRtrSupportFlag || iface->mipv6.HomeAgentPreference != 0 || + iface->mipv6.HomeAgentLifetime != iface->ra_header_info.AdvDefaultLifetime)) { cur->next = new_safe_buffer_list(); cur = cur->next; add_ra_option_mipv6_home_agent_info(cur->sb, &iface->mipv6); @@ -800,15 +715,15 @@ } if (dest == NULL) { - static uint8_t const all_hosts_addr[] = { 0xff, 0x02, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }; + static uint8_t const all_hosts_addr[] = {0xff, 0x02, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}; dest = (struct in6_addr const *)all_hosts_addr; clock_gettime(CLOCK_MONOTONIC, &iface->times.last_multicast); } update_iface_times(iface); - char dest_text[INET6_ADDRSTRLEN] = { "" }; - char src_text[INET6_ADDRSTRLEN] = { "" }; + char dest_text[INET6_ADDRSTRLEN] = {""}; + char src_text[INET6_ADDRSTRLEN] = {""}; addrtostr(dest, dest_text, INET6_ADDRSTRLEN); addrtostr(iface->props.if_addr_rasrc, src_text, INET6_ADDRSTRLEN); @@ -818,32 +733,6 @@ // Build RA option list struct safe_buffer_list *ra_opts = build_ra_options(iface, dest); - /* *INDENT-OFF* */ - /* - * RFC4861: 6.2.3. Router Advertisement Message Content - * If including all options causes the size of an advertisement to - * exceed the link MTU, multiple advertisements can be sent, each - * containing a subset of the options. - * - * RFC6980: 5. Specification - * Nodes MUST NOT employ IPv6 fragmentation for sending any of the - * following Neighbor Discovery and SEcure Neighbor Discovery messages: - * - * o Neighbor Solicitation - * o Neighbor Advertisement - * o Router Solicitation - * o Router Advertisement - * o Redirect - * o Certification Path Solicitation - * - * Nodes SHOULD NOT employ IPv6 fragmentation for sending the following - * messages (see Section 6.4.2 of [RFC3971]): - * - * o Certification Path Advertisement - * - */ - /* *INDENT-ON* */ - // Send out one or more RAs, all in the form of (hdr+options), // such that none of the RAs exceed the link MTU // (max size is pre-computed in iface->props.max_ra_option_size) @@ -857,8 +746,8 @@ // Duplicate the RA header safe_buffer_append(sb, ra_hdr->buffer, ra_hdr->used); // Copy in as many RA options as we can fit. - while(NULL != cur) { - if(sb->used == 0) { + while (NULL != cur) { + if (sb->used == 0) { dlog(LOG_DEBUG, 5, "send_ra: Saw empty buffer!"); cur = cur->next; continue; @@ -866,12 +755,12 @@ // Ok, it's more than 0 bytes in length total_seen_options++; // Not enough room for the next option in our buffer, just send the buffer now. - if(sb->used + cur->sb->used > iface->props.max_ra_option_size) { + if (sb->used + cur->sb->used > iface->props.max_ra_option_size) { // But make sure we send at least one option in each RA // TODO: a future improvement would be to optimize packing of // the options in the minimal number of RAs, such that each one // does not exceed the MTU where possible. - if(option_count > 0) + if (option_count > 0) break; } // It's possible that a single option is larger than the MTU, so @@ -881,10 +770,10 @@ // In this case, the RA will contain a single option, consisting of // ONLY the DNSSL, without other options. RFC6980-conforming nodes // should then ignore the DNSSL. - if(cur->sb->used > iface->props.max_ra_option_size) { + if (cur->sb->used > iface->props.max_ra_option_size) { flog(LOG_WARNING, - "send_ra: RA option (type=%hhd) too long for MTU, fragmenting anyway (violates RFC6980)", - (unsigned char)(cur->sb->buffer[0])); + "send_ra: RA option (type=%hhd) too long for MTU, fragmenting anyway (violates RFC6980)", + (unsigned char)(cur->sb->buffer[0])); } // Add this option to the buffer. safe_buffer_append(sb, cur->sb->buffer, cur->sb->used); @@ -897,17 +786,19 @@ cur = cur->next; } - if(option_count == 0 && total_seen_options > 0) { + if (option_count == 0 && total_seen_options > 0) { // If option_count == 0 and total_seen_options==0 we make sure to // send ONE RA out, so that clients get the RA header fields. - } else if(option_count == 0 && total_seen_options > 0) { + } else if (option_count == 0 && total_seen_options > 0) { // None of the RA options are scheduled for this window. - dlog(LOG_DEBUG, 5, "No RA options scheduled in this pass, staying quiet; already sent at least one RA packet"); + dlog(LOG_DEBUG, 5, + "No RA options scheduled in this pass, staying quiet; already sent at least one RA packet"); break; } // RA built, now send it. - dlog(LOG_DEBUG, 5, "sending RA to %s on %s (%s), %lu options (using %lu/%u bytes)", dest_text, iface->props.name, src_text, option_count, sb->used, iface->props.max_ra_option_size); + dlog(LOG_DEBUG, 5, "sending RA to %s on %s (%s), %lu options (using %lu/%u bytes)", dest_text, iface->props.name, + src_text, option_count, sb->used, iface->props.max_ra_option_size); int err = really_send(sock, dest, &iface->props, sb); if (err < 0) { if (!iface->IgnoreIfMissing || !(errno == EINVAL || errno == ENODEV)) @@ -920,7 +811,7 @@ return -1; } - } while(NULL != cur); + } while (NULL != cur); safe_buffer_free(sb); safe_buffer_list_free(ra_opts); @@ -941,7 +832,7 @@ iov.iov_len = sb->used; iov.iov_base = (caddr_t)sb->buffer; - char __attribute__ ((aligned(8))) chdr[CMSG_SPACE(sizeof(struct in6_pktinfo))]; + char __attribute__((aligned(8))) chdr[CMSG_SPACE(sizeof(struct in6_pktinfo))]; memset(chdr, 0, sizeof(chdr)); struct cmsghdr *cmsg = (struct cmsghdr *)chdr; @@ -960,7 +851,7 @@ struct msghdr mhdr; memset(&mhdr, 0, sizeof(mhdr)); - mhdr.msg_name = (caddr_t) & addr; + mhdr.msg_name = (caddr_t)&addr; mhdr.msg_namelen = sizeof(struct sockaddr_in6); mhdr.msg_iov = &iov; mhdr.msg_iovlen = 1; @@ -970,7 +861,6 @@ return sendmsg(sock, &mhdr, 0); } - static int schedule_option_prefix(struct in6_addr const *dest, struct Interface const *iface, struct AdvPrefix const *prefix) { return schedule_helper(dest, iface, prefix->curr_preferredlft); diff -Nru radvd-2.16/test/check.c radvd-2.17/test/check.c --- radvd-2.16/test/check.c 2017-02-20 14:49:14.000000000 +0000 +++ radvd-2.17/test/check.c 2017-06-29 04:32:29.000000000 +0000 @@ -2,24 +2,23 @@ #include "config.h" #include -#include #include -#include +#include #include +#include #ifdef HAVE_GETOPT_H #include #endif - static void usage(char const *pname); static void version(void); -Suite * util_suite(); -Suite * send_suite(); +Suite *util_suite(); +Suite *send_suite(); #ifdef HAVE_GETOPT_LONG -/* *INDENT-OFF* */ +/* clang-format off */ static char usage_str[] = { "\n" " -h, --help Print the help and quit.\n" @@ -43,25 +42,25 @@ static char usage_str[] = { "[-hv] [-m mode] [-s suite] [-t test]" }; -/* *INDENT-ON* */ +/* clang-format on */ #endif struct options { - char * suite; - char * test; + char *suite; + char *test; int mode; }; -static void process_command_line_args(int argc, char * argv[], struct options * options) +static void process_command_line_args(int argc, char *argv[], struct options *options) { char const *pname = ((pname = strrchr(argv[0], '/')) != NULL) ? pname + 1 : argv[0]; int c; - char * suite = 0; - char * test = 0; + char *suite = 0; + char *test = 0; int mode = CK_VERBOSE; - - /* parse args */ + +/* parse args */ #define OPTIONS_STR "s:t:m:vh" #ifdef HAVE_GETOPT_LONG int opt_idx; @@ -72,22 +71,17 @@ { switch (c) { case 'm': - if (0 == strcmp(optarg, "SILENT")){ + if (0 == strcmp(optarg, "SILENT")) { mode = CK_SILENT; - } - else if (0 == strcmp(optarg, "MINIMAL")){ + } else if (0 == strcmp(optarg, "MINIMAL")) { mode = CK_MINIMAL; - } - else if (0 == strcmp(optarg, "NORMAL")){ + } else if (0 == strcmp(optarg, "NORMAL")) { mode = CK_NORMAL; - } - else if (0 == strcmp(optarg, "VERBOSE")){ + } else if (0 == strcmp(optarg, "VERBOSE")) { mode = CK_VERBOSE; - } - else if (0 == strcmp(optarg, "ENV")){ + } else if (0 == strcmp(optarg, "ENV")) { mode = CK_ENV; - } - else { + } else { fprintf(stderr, "%s: mode, \"%s\", unknown.\n", pname, optarg); exit(1); } @@ -124,15 +118,14 @@ } } - -int main(int argc, char * argv[]) +int main(int argc, char *argv[]) { srand((unsigned int)time(NULL)); struct options options = {0, 0, 0}; process_command_line_args(argc, argv, &options); - SRunner * sr = srunner_create(util_suite()); + SRunner *sr = srunner_create(util_suite()); srunner_add_suite(sr, send_suite()); srunner_run(sr, options.suite, options.test, options.mode); int number_failed = srunner_ntests_failed(sr); @@ -152,4 +145,3 @@ fprintf(stderr, "Version: %s\n\n", VERSION); exit(0); } - diff -Nru radvd-2.16/test/print_safe_buffer.c radvd-2.17/test/print_safe_buffer.c --- radvd-2.16/test/print_safe_buffer.c 2017-02-20 14:49:14.000000000 +0000 +++ radvd-2.17/test/print_safe_buffer.c 2017-06-29 04:32:29.000000000 +0000 @@ -1,33 +1,33 @@ +#include "print_safe_buffer.h" #include "../config.h" #include "../radvd.h" -#include "print_safe_buffer.h" #include -void print_safe_buffer(struct safe_buffer const * sb) +void print_safe_buffer(struct safe_buffer const *sb) { char buf[4096]; snprint_safe_buffer(buf, sizeof(buf), sb); printf("%s", buf); } -size_t snprint_safe_buffer(char *s, size_t size, struct safe_buffer const * sb) +size_t snprint_safe_buffer(char *s, size_t size, struct safe_buffer const *sb) { size_t count = 0; - count += snprintf((s+count), (size-count), "unsigned char expected[] = {"); + count += snprintf((s + count), (size - count), "unsigned char expected[] = {"); count--; for (size_t i = 0; i < sb->used; ++i) { if (i % 8 == 0) { - count += snprintf((s+count), (size-count), "\n\t0x%02x,", sb->buffer[i]); + count += snprintf((s + count), (size - count), "\n\t0x%02x,", sb->buffer[i]); } else { - count += snprintf((s+count), (size-count), " 0x%02x,", sb->buffer[i]); + count += snprintf((s + count), (size - count), " 0x%02x,", sb->buffer[i]); } count--; } - count += snprintf((s+count), (size-count), "\n};\n"); + count += snprintf((s + count), (size - count), "\n};\n"); return count; } diff -Nru radvd-2.16/test/print_safe_buffer.h radvd-2.17/test/print_safe_buffer.h --- radvd-2.16/test/print_safe_buffer.h 2017-02-20 14:49:14.000000000 +0000 +++ radvd-2.17/test/print_safe_buffer.h 2017-06-29 04:32:29.000000000 +0000 @@ -4,6 +4,5 @@ #include "../config.h" #include "../radvd.h" -size_t snprint_safe_buffer(char *s, size_t size, struct safe_buffer const * sb); -void print_safe_buffer(struct safe_buffer const * sb); - +size_t snprint_safe_buffer(char *s, size_t size, struct safe_buffer const *sb); +void print_safe_buffer(struct safe_buffer const *sb); diff -Nru radvd-2.16/test/send.c radvd-2.17/test/send.c --- radvd-2.16/test/send.c 2017-02-20 14:49:14.000000000 +0000 +++ radvd-2.17/test/send.c 2017-06-29 04:32:29.000000000 +0000 @@ -1,6 +1,6 @@ -#include #include "test/print_safe_buffer.h" +#include /* * http://check.sourceforge.net/doc/check_html/check_3.html @@ -8,7 +8,7 @@ * http://entrenchant.blogspot.com/2010/08/unit-testing-in-c.html */ -START_TEST (test_decrement_lifetime) +START_TEST(test_decrement_lifetime) { uint32_t lifetime = 10; decrement_lifetime(7, &lifetime); @@ -18,7 +18,7 @@ } END_TEST -static struct Interface * iface = 0; +static struct Interface *iface = 0; static void iface_setup(void) { @@ -34,7 +34,7 @@ iface = 0; } -START_TEST (test_add_ra_header) +START_TEST(test_add_ra_header) { struct safe_buffer sb = SAFE_BUFFER_INIT; @@ -46,8 +46,7 @@ ck_assert_msg(0, "\n%s", &buf); #else unsigned char expected[] = { - 0x86, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x86, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; ck_assert_int_eq(sizeof(expected), sb.used); @@ -58,7 +57,7 @@ } END_TEST -START_TEST (test_add_ra_options_prefix) +START_TEST(test_add_ra_options_prefix) { ck_assert_ptr_ne(0, iface); @@ -76,18 +75,12 @@ ck_assert_msg(0, "\n%s", &buf); #else unsigned char expected[] = { - 0x03, 0x04, 0x40, 0xe0, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, - 0xfe, 0x80, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x03, 0x04, 0x30, 0x80, 0x00, 0x00, 0x27, 0x10, - 0x00, 0x00, 0x03, 0xe8, 0x00, 0x00, 0x00, 0x00, - 0xfe, 0x80, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x03, 0x04, 0x40, 0xc0, 0x00, 0x01, 0x51, 0x80, - 0x00, 0x00, 0x38, 0x40, 0x00, 0x00, 0x00, 0x00, - 0xfe, 0x80, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x03, 0x04, 0x40, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, + 0xfe, 0x80, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x03, 0x04, 0x30, 0x80, 0x00, 0x00, 0x27, 0x10, 0x00, 0x00, 0x03, 0xe8, 0x00, 0x00, 0x00, 0x00, + 0xfe, 0x80, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x03, 0x04, 0x40, 0xc0, 0x00, 0x01, 0x51, 0x80, 0x00, 0x00, 0x38, 0x40, 0x00, 0x00, 0x00, 0x00, + 0xfe, 0x80, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; ck_assert_int_eq(sizeof(expected), sb.used); @@ -98,7 +91,7 @@ } END_TEST -START_TEST (test_add_ra_options_route) +START_TEST(test_add_ra_options_route) { ck_assert_ptr_ne(0, iface); @@ -116,15 +109,10 @@ ck_assert_msg(0, "\n%s", &buf); #else unsigned char expected[] = { - 0x18, 0x03, 0x30, 0x18, 0x00, 0x00, 0x27, 0x10, - 0xfe, 0x80, 0x00, 0x0f, 0x00, 0x01, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x18, 0x03, 0x28, 0x08, 0xff, 0xff, 0xff, 0xff, - 0xfe, 0x80, 0x00, 0x0f, 0x00, 0x02, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x18, 0x03, 0x20, 0x00, 0x00, 0x00, 0x0b, 0xb8, - 0xfe, 0x80, 0x00, 0x0f, 0x00, 0x02, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x18, 0x03, 0x30, 0x18, 0x00, 0x00, 0x27, 0x10, 0xfe, 0x80, 0x00, 0x0f, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x03, 0x28, 0x08, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x80, 0x00, 0x0f, + 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x03, 0x20, 0x00, 0x00, 0x00, + 0x0b, 0xb8, 0xfe, 0x80, 0x00, 0x0f, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; ck_assert_int_eq(sizeof(expected), sb.used); @@ -134,8 +122,7 @@ } END_TEST - -START_TEST (test_add_ra_options_rdnss) +START_TEST(test_add_ra_options_rdnss) { ck_assert_ptr_ne(0, iface); @@ -153,13 +140,9 @@ ck_assert_msg(0, "\n%s", &buf); #else unsigned char expected[] = { - 0x19, 0x07, 0x00, 0x00, 0x00, 0x00, 0x04, 0xd2, - 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, - 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, - 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, + 0x19, 0x07, 0x00, 0x00, 0x00, 0x00, 0x04, 0xd2, 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x02, 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, }; ck_assert_int_eq(sizeof(expected), sb.used); @@ -170,10 +153,9 @@ } END_TEST - -START_TEST (test_add_ra_options_rdnss2) +START_TEST(test_add_ra_options_rdnss2) { - static struct Interface * iface = 0; + static struct Interface *iface = 0; iface = readin_config("test/test_rdnss.conf"); ck_assert_ptr_ne(0, iface); @@ -192,9 +174,8 @@ ck_assert_msg(0, "\n%s", &buf); #else unsigned char expected[] = { - 0x19, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2d, - 0x12, 0x34, 0x04, 0x23, 0xfe, 0xfe, 0x04, 0x93, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, + 0x19, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2d, 0x12, 0x34, 0x04, 0x23, + 0xfe, 0xfe, 0x04, 0x93, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, }; ck_assert_int_eq(sizeof(expected), sb.used); @@ -205,8 +186,7 @@ } END_TEST - -START_TEST (test_add_ra_options_dnssl) +START_TEST(test_add_ra_options_dnssl) { ck_assert_ptr_ne(0, iface); @@ -224,31 +204,17 @@ ck_assert_msg(0, "\n%s", &buf); #else unsigned char expected[] = { - 0x1f, 0x09, 0x00, 0x00, 0x00, 0x00, 0x03, 0xe8, - 0x06, 0x6f, 0x66, 0x66, 0x69, 0x63, 0x65, 0x06, - 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x07, 0x65, - 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x03, 0x63, - 0x6f, 0x6d, 0x00, 0x06, 0x62, 0x72, 0x61, 0x6e, - 0x63, 0x68, 0x07, 0x65, 0x78, 0x61, 0x6d, 0x70, - 0x6c, 0x65, 0x03, 0x63, 0x6f, 0x6d, 0x00, 0x07, - 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x03, - 0x63, 0x6f, 0x6d, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x1f, 0x09, 0x00, 0x00, 0x00, 0x00, 0x04, 0x4b, - 0x06, 0x6f, 0x66, 0x66, 0x69, 0x63, 0x65, 0x06, - 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x07, 0x65, - 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x03, 0x6e, - 0x65, 0x74, 0x00, 0x06, 0x62, 0x72, 0x61, 0x6e, - 0x63, 0x68, 0x07, 0x65, 0x78, 0x61, 0x6d, 0x70, - 0x6c, 0x65, 0x03, 0x6e, 0x65, 0x74, 0x00, 0x07, - 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x03, - 0x6e, 0x65, 0x74, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x1f, 0x07, 0x00, 0x00, 0x00, 0x00, 0x04, 0x4c, - 0x06, 0x6f, 0x66, 0x66, 0x69, 0x63, 0x65, 0x06, - 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x07, 0x65, - 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x00, 0x06, - 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x07, 0x65, - 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x00, 0x07, - 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x00, + 0x1f, 0x09, 0x00, 0x00, 0x00, 0x00, 0x03, 0xe8, 0x06, 0x6f, 0x66, 0x66, 0x69, 0x63, 0x65, 0x06, 0x62, 0x72, 0x61, + 0x6e, 0x63, 0x68, 0x07, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x03, 0x63, 0x6f, 0x6d, 0x00, 0x06, 0x62, 0x72, + 0x61, 0x6e, 0x63, 0x68, 0x07, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x03, 0x63, 0x6f, 0x6d, 0x00, 0x07, 0x65, + 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x03, 0x63, 0x6f, 0x6d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x09, 0x00, 0x00, + 0x00, 0x00, 0x04, 0x4b, 0x06, 0x6f, 0x66, 0x66, 0x69, 0x63, 0x65, 0x06, 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x07, + 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x03, 0x6e, 0x65, 0x74, 0x00, 0x06, 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, + 0x07, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x03, 0x6e, 0x65, 0x74, 0x00, 0x07, 0x65, 0x78, 0x61, 0x6d, 0x70, + 0x6c, 0x65, 0x03, 0x6e, 0x65, 0x74, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x07, 0x00, 0x00, 0x00, 0x00, 0x04, 0x4c, + 0x06, 0x6f, 0x66, 0x66, 0x69, 0x63, 0x65, 0x06, 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x07, 0x65, 0x78, 0x61, 0x6d, + 0x70, 0x6c, 0x65, 0x00, 0x06, 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x07, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, + 0x00, 0x07, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x00, }; ck_assert_int_eq(sizeof(expected), sb.used); @@ -259,8 +225,7 @@ } END_TEST - -START_TEST (test_add_ra_option_mtu) +START_TEST(test_add_ra_option_mtu) { ck_assert_ptr_ne(0, iface); @@ -273,7 +238,7 @@ ck_assert_msg(0, "\n%s", &buf); #else unsigned char expected[] = { - 0x05, 0x01, 0x00, 0x00, 0x00, 0x00, 0x04, 0xd2, + 0x05, 0x01, 0x00, 0x00, 0x00, 0x00, 0x04, 0xd2, }; ck_assert_int_eq(sb.used, sizeof(expected)); @@ -284,15 +249,12 @@ } END_TEST -START_TEST (test_add_ra_option_sllao) +START_TEST(test_add_ra_option_sllao) { struct sllao sllao48 = { - {1, 2, 3, 4, 5, 6, 7, 8}, - 48, - 64, - 1500, + {1, 2, 3, 4, 5, 6, 7, 8}, 48, 64, 1500, }; - + struct safe_buffer sb = SAFE_BUFFER_INIT; add_ra_option_sllao(&sb, &sllao48); @@ -302,7 +264,7 @@ ck_assert_msg(0, "\n%s", &buf); #else unsigned char expected48[] = { - 0x01, 0x01, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, + 0x01, 0x01, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, }; ck_assert_int_eq(sizeof(expected48), sb.used); @@ -312,12 +274,9 @@ safe_buffer_free(&sb); struct sllao sllao64 = { - {1, 2, 3, 4, 5, 6, 7, 8}, - 64, - 64, - 1500, + {1, 2, 3, 4, 5, 6, 7, 8}, 64, 64, 1500, }; - + sb = SAFE_BUFFER_INIT; add_ra_option_sllao(&sb, &sllao64); @@ -326,8 +285,7 @@ ck_assert_msg(0, "\n%s", &buf); #else unsigned char expected64[] = { - 0x01, 0x02, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, - 0x07, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x01, 0x02, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; ck_assert_int_eq(sizeof(expected64), sb.used); @@ -338,7 +296,7 @@ } END_TEST -START_TEST (test_add_ra_option_lowpanco) +START_TEST(test_add_ra_option_lowpanco) { ck_assert_ptr_ne(0, iface); @@ -351,9 +309,8 @@ ck_assert_msg(0, "\n%s", &buf); #else unsigned char expected[] = { - 0x22, 0x03, 0x32, 0x48, 0x00, 0x00, 0xe8, 0x03, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x22, 0x03, 0x32, 0x48, 0x00, 0x00, 0xe8, 0x03, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; ck_assert_int_eq(sb.used, sizeof(expected)); @@ -364,8 +321,7 @@ } END_TEST - -START_TEST (test_add_ra_option_abro) +START_TEST(test_add_ra_option_abro) { ck_assert_ptr_ne(0, iface); @@ -378,9 +334,8 @@ ck_assert_msg(0, "\n%s", &buf); #else unsigned char expected[] = { - 0x23, 0x03, 0x0a, 0x00, 0x02, 0x00, 0x02, 0x00, - 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xa2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x23, 0x03, 0x0a, 0x00, 0x02, 0x00, 0x02, 0x00, 0xfe, 0x80, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xa2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, }; ck_assert_int_eq(sb.used, sizeof(expected)); @@ -391,13 +346,12 @@ } END_TEST - -Suite * send_suite(void) +Suite *send_suite(void) { - TCase * tc_update = tcase_create("update"); + TCase *tc_update = tcase_create("update"); tcase_add_test(tc_update, test_decrement_lifetime); - TCase * tc_build = tcase_create("build"); + TCase *tc_build = tcase_create("build"); tcase_add_unchecked_fixture(tc_build, iface_setup, iface_teardown); tcase_add_test(tc_build, test_add_ra_header); tcase_add_test(tc_build, test_add_ra_options_prefix); @@ -414,6 +368,5 @@ suite_add_tcase(s, tc_update); suite_add_tcase(s, tc_build); - return s; + return s; } - diff -Nru radvd-2.16/test/util.c radvd-2.17/test/util.c --- radvd-2.16/test/util.c 2017-02-20 14:49:14.000000000 +0000 +++ radvd-2.17/test/util.c 2017-06-29 04:32:29.000000000 +0000 @@ -7,7 +7,7 @@ * http://entrenchant.blogspot.com/2010/08/unit-testing-in-c.html */ -START_TEST (test_safe_buffer) +START_TEST(test_safe_buffer) { struct safe_buffer sb = SAFE_BUFFER_INIT; ck_assert_ptr_eq(0, sb.buffer); @@ -16,7 +16,7 @@ ck_assert_int_eq(0, sb.should_free); safe_buffer_free(&sb); - struct safe_buffer * sbptr = new_safe_buffer(); + struct safe_buffer *sbptr = new_safe_buffer(); ck_assert_ptr_eq(0, sbptr->buffer); ck_assert_int_eq(0, sbptr->allocated); ck_assert_int_eq(0, sbptr->used); @@ -25,10 +25,10 @@ } END_TEST -START_TEST (test_safe_buffer_resize) +START_TEST(test_safe_buffer_resize) { struct safe_buffer sb = SAFE_BUFFER_INIT; - for(int i = 0; i < 5000; i += 17) { + for (int i = 0; i < 5000; i += 17) { safe_buffer_resize(&sb, i); ck_assert_int_ge(sb.allocated, i); } @@ -36,7 +36,7 @@ } END_TEST -START_TEST (test_safe_buffer_append) +START_TEST(test_safe_buffer_append) { struct safe_buffer sb = SAFE_BUFFER_INIT; char array[] = {"This is a test"}; @@ -47,7 +47,7 @@ } END_TEST -START_TEST (test_safe_buffer_append2) +START_TEST(test_safe_buffer_append2) { struct safe_buffer sb = SAFE_BUFFER_INIT; char array[] = {"This is a test"}; @@ -55,26 +55,26 @@ safe_buffer_append(&sb, array, sizeof(array)); ck_assert_str_eq(sb.buffer, array); ck_assert_str_eq(sb.buffer + sizeof(array), array); - ck_assert_int_eq(sb.used, 2*sizeof(array)); - + ck_assert_int_eq(sb.used, 2 * sizeof(array)); + safe_buffer_free(&sb); } END_TEST -START_TEST (test_safe_buffer_pad) +START_TEST(test_safe_buffer_pad) { struct safe_buffer sb = SAFE_BUFFER_INIT; char array[] = {"This is a test"}; safe_buffer_append(&sb, array, sizeof(array)); safe_buffer_pad(&sb, 10); ck_assert_str_eq(sb.buffer, array); - ck_assert_int_eq(sb.used, 10+sizeof(array)); - + ck_assert_int_eq(sb.used, 10 + sizeof(array)); + safe_buffer_free(&sb); } END_TEST -START_TEST (test_safe_buffer_list) +START_TEST(test_safe_buffer_list) { struct safe_buffer_list *sbl = new_safe_buffer_list(); ck_assert_ptr_ne(0, sbl->sb); @@ -85,7 +85,7 @@ } END_TEST -START_TEST (test_safe_buffer_list_to_safe_buffer) +START_TEST(test_safe_buffer_list_to_safe_buffer) { struct safe_buffer_list *sbl = new_safe_buffer_list(); struct safe_buffer sb = SAFE_BUFFER_INIT; @@ -99,48 +99,42 @@ ck_assert_str_eq(sb.buffer, array); ck_assert_str_eq(sb.buffer + sizeof(array), array); - ck_assert_int_eq(sb.used, 2*sizeof(array)); - + ck_assert_int_eq(sb.used, 2 * sizeof(array)); + safe_buffer_free(&sb); safe_buffer_list_free(sbl); } END_TEST -START_TEST (test_addrtostr) +START_TEST(test_addrtostr) { char buffer[INET6_ADDRSTRLEN] = {""}; struct in6_addr addr = { - { - 0xfe, 0x80, 0xfe, 0x80, - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, - 0xff, 0x00, 0x12, 0x34, - }, + { + 0xfe, 0x80, 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x12, 0x34, + }, }; addrtostr(&addr, buffer, sizeof(buffer)); ck_assert_str_eq(buffer, "fe80:fe80::ff00:1234"); } END_TEST -START_TEST (test_addrtostr_overflow) +START_TEST(test_addrtostr_overflow) { char buffer[18] = {""}; struct in6_addr addr = { - { - 0xfe, 0x80, 0xfe, 0x80, - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, - 0xff, 0x00, 0x12, 0x34, - }, + { + 0xfe, 0x80, 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x12, 0x34, + }, }; addrtostr(&addr, buffer, sizeof(buffer)); ck_assert_str_eq(buffer, "[invalid address]"); } END_TEST -START_TEST (test_strdupf) +START_TEST(test_strdupf) { - char * str = strdupf("%d %s %zu %c %% char", 1234, "str", (size_t)10, 'c'); + char *str = strdupf("%d %s %zu %c %% char", 1234, "str", (size_t)10, 'c'); ck_assert_str_eq(str, "1234 str 10 c % char"); @@ -148,7 +142,7 @@ } END_TEST -START_TEST (test_readn) +START_TEST(test_readn) { int fd = open("/dev/zero", O_RDONLY); @@ -161,14 +155,14 @@ int count = readn(fd, buffer, sizeof(buffer)); ck_assert_int_eq(count, 10000); - + for (int i = 0; i < sizeof(buffer); ++i) { ck_assert_int_eq(buffer[i], 0); } } END_TEST -START_TEST (test_writen) +START_TEST(test_writen) { int fd = open("/dev/null", O_WRONLY); @@ -184,7 +178,7 @@ } END_TEST -static struct Interface * iface = 0; +static struct Interface *iface = 0; static void iface_setup(void) { @@ -200,7 +194,7 @@ iface = 0; } -START_TEST (test_check_dnssl_presence) +START_TEST(test_check_dnssl_presence) { int rc = check_dnssl_presence(iface->AdvDNSSLList, "example.com"); ck_assert_int_ne(0, rc); @@ -213,32 +207,32 @@ } END_TEST -START_TEST (test_check_rdnss_presence) +START_TEST(test_check_rdnss_presence) { struct in6_addr addr; int rc; /* The next three should be found */ - addr = (struct in6_addr){ 0xff, 0x02, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }; + addr = (struct in6_addr){0xff, 0x02, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}; rc = check_rdnss_presence(iface->AdvRDNSSList, &addr); ck_assert_int_ne(0, rc); - addr = (struct in6_addr){ 0xff, 0x02, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2 }; + addr = (struct in6_addr){0xff, 0x02, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2}; rc = check_rdnss_presence(iface->AdvRDNSSList, &addr); ck_assert_int_ne(0, rc); - addr = (struct in6_addr){ 0xff, 0x02, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3 }; + addr = (struct in6_addr){0xff, 0x02, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3}; rc = check_rdnss_presence(iface->AdvRDNSSList, &addr); ck_assert_int_ne(0, rc); /* The next one should *not* be found */ - addr = (struct in6_addr){ 0xff, 0x02, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6 }; + addr = (struct in6_addr){0xff, 0x02, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6}; rc = check_rdnss_presence(iface->AdvRDNSSList, &addr); ck_assert_int_eq(0, rc); } END_TEST -START_TEST (test_rand_between) +START_TEST(test_rand_between) { int const RAND_TEST_MAX = 1000; for (int i = 0; i < RAND_TEST_MAX; ++i) { @@ -265,34 +259,34 @@ } END_TEST -Suite * util_suite(void) +Suite *util_suite(void) { - TCase * tc_safe_buffer = tcase_create("safe_buffer"); + TCase *tc_safe_buffer = tcase_create("safe_buffer"); tcase_add_test(tc_safe_buffer, test_safe_buffer); tcase_add_test(tc_safe_buffer, test_safe_buffer_resize); tcase_add_test(tc_safe_buffer, test_safe_buffer_append); tcase_add_test(tc_safe_buffer, test_safe_buffer_append2); tcase_add_test(tc_safe_buffer, test_safe_buffer_pad); - - TCase * tc_safe_buffer_list = tcase_create("safe_buffer_list"); + + TCase *tc_safe_buffer_list = tcase_create("safe_buffer_list"); tcase_add_test(tc_safe_buffer, test_safe_buffer_list); tcase_add_test(tc_safe_buffer, test_safe_buffer_list_to_safe_buffer); - TCase * tc_str = tcase_create("str"); + TCase *tc_str = tcase_create("str"); tcase_add_test(tc_str, test_addrtostr); tcase_add_test(tc_str, test_addrtostr_overflow); tcase_add_test(tc_str, test_strdupf); - TCase * tc_ion = tcase_create("ion"); + TCase *tc_ion = tcase_create("ion"); tcase_add_test(tc_ion, test_readn); tcase_add_test(tc_ion, test_writen); - TCase * tc_presence = tcase_create("presence"); + TCase *tc_presence = tcase_create("presence"); tcase_add_unchecked_fixture(tc_presence, iface_setup, iface_teardown); tcase_add_test(tc_presence, test_check_dnssl_presence); tcase_add_test(tc_presence, test_check_rdnss_presence); - TCase * tc_misc = tcase_create("misc"); + TCase *tc_misc = tcase_create("misc"); tcase_add_test(tc_misc, test_rand_between); Suite *s = suite_create("util"); @@ -302,6 +296,5 @@ suite_add_tcase(s, tc_presence); suite_add_tcase(s, tc_misc); - return s; + return s; } - diff -Nru radvd-2.16/TODO radvd-2.17/TODO --- radvd-2.16/TODO 2017-02-20 14:49:14.000000000 +0000 +++ radvd-2.17/TODO 2017-07-02 01:59:02.000000000 +0000 @@ -58,3 +58,20 @@ Ethernet frames with the old MAC until interface is flapped. More: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=508466 +AdvRASolicitedUnicast: Further improvement is possible. +- If we get a RS and are about to send a multicast RA, then we can further save + battery on the client device by NOT sending a unicast response, and just + letting the client wait for the multicast response. This should be + implemented as a new time value, specifying the maximum amount of time + remaining to as a deciding factor between send-solicited-RA-now vs + wait-for-next-multicast. +- The above can also form part of rate-limiting of unicast RA responses when + network topology has recently changed. + +The following parts of RFC7222 are not yet implemented: +- Section 5.1.3: Networks that serve battery-powered devices SHOULD NOT send + multicast RAs too frequently (see Section 4) unless the information in the RA + packet has substantially changed. If there is a desire to ensure that hosts + pick up configuration changes quickly, those networks MAY send frequent + Router Advertisements for a limited period of time (e.g., not more than one + minute) immediately after a configuration change. diff -Nru radvd-2.16/util.c radvd-2.17/util.c --- radvd-2.16/util.c 2017-02-20 14:49:14.000000000 +0000 +++ radvd-2.17/util.c 2017-06-29 04:32:29.000000000 +0000 @@ -20,15 +20,15 @@ #include "test/util.c" #endif -struct safe_buffer * new_safe_buffer(void) +struct safe_buffer *new_safe_buffer(void) { - struct safe_buffer * sb = malloc(sizeof(struct safe_buffer)); + struct safe_buffer *sb = malloc(sizeof(struct safe_buffer)); *sb = SAFE_BUFFER_INIT; sb->should_free = 1; return sb; } -void safe_buffer_free(struct safe_buffer * sb) +void safe_buffer_free(struct safe_buffer *sb) { if (sb->buffer) { free(sb->buffer); @@ -51,15 +51,15 @@ * @param sb safe_buffer to enlarge * @param b Minimum capacity for the safe_buffer. */ -void safe_buffer_resize(struct safe_buffer * sb, size_t n) +void safe_buffer_resize(struct safe_buffer *sb, size_t n) { const int blocksize = 1 << 6; // MUST BE POWER OF 2. if (sb->allocated < n) { - if(n % blocksize > 0) { - n |= (blocksize-1); // Set all the low bits + if (n % blocksize > 0) { + n |= (blocksize - 1); // Set all the low bits n++; } - if (n > 64*1024) { + if (n > 64 * 1024) { flog(LOG_ERR, "Requested buffer too large for any possible IPv6 ND, even with jumbogram. Exiting."); exit(1); } @@ -68,7 +68,7 @@ } } -size_t safe_buffer_pad(struct safe_buffer * sb, size_t count) +size_t safe_buffer_pad(struct safe_buffer *sb, size_t count) { safe_buffer_resize(sb, sb->used + count); memset(&sb->buffer[sb->used], (uint8_t)0, count); @@ -76,10 +76,10 @@ return count; } -size_t safe_buffer_append(struct safe_buffer * sb, void const * v, size_t count) +size_t safe_buffer_append(struct safe_buffer *sb, void const *v, size_t count) { if (sb) { - unsigned const char * m = (unsigned const char *)v; + unsigned const char *m = (unsigned const char *)v; safe_buffer_resize(sb, sb->used + count); memcpy(&sb->buffer[sb->used], m, count); sb->used += count; @@ -93,9 +93,9 @@ * * @return new safe_buffer_list, with a safe_buffer on the heap. */ -struct safe_buffer_list * new_safe_buffer_list(void) +struct safe_buffer_list *new_safe_buffer_list(void) { - struct safe_buffer_list * sbl = malloc(sizeof(struct safe_buffer_list)); + struct safe_buffer_list *sbl = malloc(sizeof(struct safe_buffer_list)); sbl->sb = new_safe_buffer(); sbl->next = NULL; return sbl; @@ -110,11 +110,11 @@ * @param sbl safe_buffer_list. * @return new tail of list. */ -struct safe_buffer_list * safe_buffer_list_append(struct safe_buffer_list * sbl) +struct safe_buffer_list *safe_buffer_list_append(struct safe_buffer_list *sbl) { // Only allocate a new entry if this one has bytes in it. - if(sbl->sb && sbl->sb->used > 0) { - struct safe_buffer_list * next = new_safe_buffer_list(); + if (sbl->sb && sbl->sb->used > 0) { + struct safe_buffer_list *next = new_safe_buffer_list(); sbl->next = next; sbl = next; } @@ -127,11 +127,11 @@ * @param sbl safe_buffer_list source. * @param sb safe_buffer destination. */ -void safe_buffer_list_to_safe_buffer(struct safe_buffer_list * sbl, struct safe_buffer *sb) +void safe_buffer_list_to_safe_buffer(struct safe_buffer_list *sbl, struct safe_buffer *sb) { struct safe_buffer_list *cur; - for(cur = sbl; cur; cur = cur->next) { - if(cur->sb) + for (cur = sbl; cur; cur = cur->next) { + if (cur->sb) safe_buffer_append(sb, cur->sb->buffer, cur->sb->used); } } @@ -141,23 +141,22 @@ * * @param sbl safe_buffer_list to free. */ -void safe_buffer_list_free(struct safe_buffer_list * sbl) +void safe_buffer_list_free(struct safe_buffer_list *sbl) { - struct safe_buffer_list * next; + struct safe_buffer_list *next; for (struct safe_buffer_list *current = sbl; current; current = next) { - if(current->sb) + if (current->sb) safe_buffer_free(current->sb); next = current->next; free(current); } } -__attribute__ ((format(printf, 1, 2))) -char * strdupf(char const * format, ...) +__attribute__((format(printf, 1, 2))) char *strdupf(char const *format, ...) { va_list va; va_start(va, format); - char * strp = 0; + char *strp = 0; int rc = vasprintf(&strp, format, va); if (rc == -1 || !strp) { flog(LOG_ERR, "vasprintf failed: %s", strerror(errno)); @@ -168,17 +167,14 @@ return strp; } -double rand_between(double lower, double upper) -{ - return ((upper - lower) / (RAND_MAX + 1.0) * rand() + lower); -} +double rand_between(double lower, double upper) { return ((upper - lower) / (RAND_MAX + 1.0) * rand() + lower); } /* This assumes that str is not null and str_size > 0 */ void addrtostr(struct in6_addr const *addr, char *str, size_t str_size) { const char *res; - res = inet_ntop(AF_INET6, (void const*)addr, str, str_size); + res = inet_ntop(AF_INET6, (void const *)addr, str, str_size); if (res == NULL) { flog(LOG_ERR, "addrtostr: inet_ntop: %s", strerror(errno)); @@ -191,10 +187,10 @@ int check_rdnss_presence(struct AdvRDNSS *rdnss, struct in6_addr *addr) { while (rdnss) { - if (!memcmp(&rdnss->AdvRDNSSAddr1, addr, sizeof(struct in6_addr)) - || !memcmp(&rdnss->AdvRDNSSAddr2, addr, sizeof(struct in6_addr)) - || !memcmp(&rdnss->AdvRDNSSAddr3, addr, sizeof(struct in6_addr))) - return 1; /* rdnss address found in the list */ + if (!memcmp(&rdnss->AdvRDNSSAddr1, addr, sizeof(struct in6_addr)) || + !memcmp(&rdnss->AdvRDNSSAddr2, addr, sizeof(struct in6_addr)) || + !memcmp(&rdnss->AdvRDNSSAddr3, addr, sizeof(struct in6_addr))) + return 1; /* rdnss address found in the list */ rdnss = rdnss->next; } return 0; @@ -206,7 +202,7 @@ while (dnssl) { for (int i = 0; i < dnssl->AdvDNSSLNumber; ++i) { if (0 == strcmp(dnssl->AdvDNSSLSuffixes[i], suffix)) - return 1; /* suffix found in the list */ + return 1; /* suffix found in the list */ } dnssl = dnssl->next; } @@ -287,5 +283,3 @@ return prefix; } - -