Re: iproute2: fix build on glibc < 2.21 / uClibc

2018-10-28 Thread Petr Vorel
Subject: [iproute] utils.h: provide fallback CLOCK_TAI definition
In-Reply-To: <20181027153102.32302-1-pe...@korsgaard.com>
To: Stephen Hemminger ,
 Vinicius Costa Gomes 
Cc: netdev@vger.kernel.org, Peter Korsgaard 
From: Petr Vorel 
List-Id: 

> q_{etf,taprio}.c uses CLOCK_TAI, which isn't exposed by glibc < 2.21 or
> uClibc, breaking the build. Provide a fallback definition like it is done
> for IPPROTO_MPLS and others.
> 
> Signed-off-by: Peter Korsgaard 
Reviewed-by: Petr Vorel 
> ---
>  include/utils.h | 4 
>  1 file changed, 4 insertions(+)


Kind regards,
Petr


Re: [PATCH iproute2 1/1] DEBUG: Fix make check when need build generate_nlmsg

2018-10-22 Thread Petr Vorel
Hi Stephen,

> Applied, it seem to have gotten lost somewhere between my laptop and the repo.
Thanks a lot for merging :).

There is a patchset "Minor shell code cleanup", which has state Accepted, but
not in git
https://patchwork.ozlabs.org/project/netdev/list/?series=67063=*
Did they got lost as well, or you don't agree with it?


Kind regards,
Petr


Re: [PATCH iproute2 1/1] DEBUG: Fix make check when need build generate_nlmsg

2018-10-20 Thread Petr Vorel
Hi Stephen,

> make check from top level Makefile defines several flags which break
> building generate_nlmsg:

> $ make check
> make -C tools
> gcc  -Wall -Wstrict-prototypes  -Wmissing-prototypes -Wmissing-declarations 
> -Wold-style-definition -Wformat=2 -O2 -I../include -I../include/uapi 
> -DRESOLVE_HOSTNAMES -DLIBDIR=\"/usr/lib\" -DCONFDIR=\"/etc/iproute2\" 
> -DNETNS_RUN_DIR=\"/var/run/netns\" -DNETNS_ETC_DIR=\"/etc/netns\" 
> -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE 
> -D_LARGEFILE64_SOURCE  -DHAVE_SETNS -DHAVE_SELINUX -DHAVE_ELF -DHAVE_LIBMNL 
> -I/usr/include/libmnl -DNEED_STRLCPY -DHAVE_LIBCAP ../lib/libutil.a 
> ../lib/libnetlink.a -lselinux -lelf -lmnl -lcap  -I../../include 
> -include../../include/uapi/linux/netlink.h -o generate_nlmsg generate_nlmsg.c 
> ../../lib/libnetlink.c -lmnl
> gcc: error: ../lib/libutil.a: No such file or directory
> gcc: error: ../lib/libnetlink.a: No such file or directory
> make[2]: *** [Makefile:5: generate_nlmsg] Error 1
> make[1]: *** [Makefile:40: generate_nlmsg] Error 2

> To fix it reset CFLAGS in sub Makefile and remove LDLIBS entirely (as
> required -lmnl flag was specified in 5dc2204c ("testsuite: add libmnl").

> Fixes: 8804a8c0 ("Makefile: Add check target")

> Signed-off-by: Petr Vorel 
> ---
> Hi Stephen,

> I'm sorry for this regression.

> Kind regards,
> Petr
> ---
>  testsuite/tools/Makefile | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)

> diff --git a/testsuite/tools/Makefile b/testsuite/tools/Makefile
> index 7d53d226..e1d9bfef 100644
> --- a/testsuite/tools/Makefile
> +++ b/testsuite/tools/Makefile
> @@ -1,8 +1,9 @@
>  # SPDX-License-Identifier: GPL-2.0
> +CFLAGS=
>  include ../../config.mk

>  generate_nlmsg: generate_nlmsg.c ../../lib/libnetlink.c
> - $(CC) $(CPPFLAGS) $(CFLAGS) $(LDLIBS) $(EXTRA_CFLAGS) -I../../include 
> -include../../include/uapi/linux/netlink.h -o $@ $^ -lmnl
> + $(CC) $(CPPFLAGS) $(CFLAGS) $(EXTRA_CFLAGS) -I../../include 
> -include../../include/uapi/linux/netlink.h -o $@ $^ -lmnl

>  clean:
>   rm -f generate_nlmsg

ping, please. Patch is in state "accepted in patchwork [1], but not merged.
Subject should be "testsuite: Fix make check when need build generate_nlmsg".


Kind regards,
Petr

[1] https://patchwork.ozlabs.org/patch/974391/


[PATCH iproute2 1/1] DEBUG: Fix make check when need build generate_nlmsg

2018-09-25 Thread Petr Vorel
make check from top level Makefile defines several flags which break
building generate_nlmsg:

$ make check
make -C tools
gcc  -Wall -Wstrict-prototypes  -Wmissing-prototypes -Wmissing-declarations 
-Wold-style-definition -Wformat=2 -O2 -I../include -I../include/uapi 
-DRESOLVE_HOSTNAMES -DLIBDIR=\"/usr/lib\" -DCONFDIR=\"/etc/iproute2\" 
-DNETNS_RUN_DIR=\"/var/run/netns\" -DNETNS_ETC_DIR=\"/etc/netns\" -D_GNU_SOURCE 
-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE  -DHAVE_SETNS 
-DHAVE_SELINUX -DHAVE_ELF -DHAVE_LIBMNL -I/usr/include/libmnl -DNEED_STRLCPY 
-DHAVE_LIBCAP ../lib/libutil.a ../lib/libnetlink.a -lselinux -lelf -lmnl -lcap  
-I../../include -include../../include/uapi/linux/netlink.h -o generate_nlmsg 
generate_nlmsg.c ../../lib/libnetlink.c -lmnl
gcc: error: ../lib/libutil.a: No such file or directory
gcc: error: ../lib/libnetlink.a: No such file or directory
make[2]: *** [Makefile:5: generate_nlmsg] Error 1
make[1]: *** [Makefile:40: generate_nlmsg] Error 2

To fix it reset CFLAGS in sub Makefile and remove LDLIBS entirely (as
required -lmnl flag was specified in 5dc2204c ("testsuite: add libmnl").

Fixes: 8804a8c0 ("Makefile: Add check target")

Signed-off-by: Petr Vorel 
---
Hi Stephen,

I'm sorry for this regression.

Kind regards,
Petr
---
 testsuite/tools/Makefile | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/testsuite/tools/Makefile b/testsuite/tools/Makefile
index 7d53d226..e1d9bfef 100644
--- a/testsuite/tools/Makefile
+++ b/testsuite/tools/Makefile
@@ -1,8 +1,9 @@
 # SPDX-License-Identifier: GPL-2.0
+CFLAGS=
 include ../../config.mk
 
 generate_nlmsg: generate_nlmsg.c ../../lib/libnetlink.c
-   $(CC) $(CPPFLAGS) $(CFLAGS) $(LDLIBS) $(EXTRA_CFLAGS) -I../../include 
-include../../include/uapi/linux/netlink.h -o $@ $^ -lmnl
+   $(CC) $(CPPFLAGS) $(CFLAGS) $(EXTRA_CFLAGS) -I../../include 
-include../../include/uapi/linux/netlink.h -o $@ $^ -lmnl
 
 clean:
rm -f generate_nlmsg
-- 
2.19.0



[PATCH iproute2 4/7] configure: Remove non-posix shell expansion

2018-09-22 Thread Petr Vorel
+ change shebang to /bin/sh

Signed-off-by: Petr Vorel 
---
 configure | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/configure b/configure
index 34325f99..8f4a7f1e 100755
--- a/configure
+++ b/configure
@@ -1,4 +1,4 @@
-#! /bin/bash
+#!/bin/sh
 # SPDX-License-Identifier: GPL-2.0
 # This is not an autoconf generated configure
 #
@@ -180,7 +180,8 @@ check_ipt_lib_dir()
 
for dir in /lib /usr/lib /usr/local/lib
do
-   for file in $dir/{xtables,iptables}/lib*t_*so ; do
+   for file in "xtables" "iptables"; do
+   file="$dir/$file/lib*t_*so"
if [ -f $file ]; then
echo ${file%/*}
echo "IPT_LIB_DIR:=${file%/*}" >> $CONFIG
-- 
2.19.0.rc2



[PATCH iproute2 5/7] configure: Code cleanup

2018-09-22 Thread Petr Vorel
Signed-off-by: Petr Vorel 
---
 configure | 65 +++
 1 file changed, 18 insertions(+), 47 deletions(-)

diff --git a/configure b/configure
index 8f4a7f1e..86c4cf58 100755
--- a/configure
+++ b/configure
@@ -32,9 +32,7 @@ int main(int argc, char **argv) {
 }
 EOF
 
-$CC -I$INCLUDE -o $TMPDIR/atmtest $TMPDIR/atmtest.c -latm >/dev/null 2>&1
-if [ $? -eq 0 ]
-then
+if $CC -I$INCLUDE -o $TMPDIR/atmtest $TMPDIR/atmtest.c -latm >/dev/null 
2>&1; then
echo "TC_CONFIG_ATM:=y" >>$CONFIG
echo yes
 else
@@ -45,8 +43,7 @@ EOF
 
 check_xtables()
 {
-   if ! ${PKG_CONFIG} xtables --exists
-   then
+   if ! ${PKG_CONFIG} xtables --exists; then
echo "TC_CONFIG_NO_XT:=y" >>$CONFIG
fi
 }
@@ -85,10 +82,7 @@ EOF
 check_xt_old()
 {
 # bail if previous XT checks has already succeded.
-if grep -q TC_CONFIG_XT $CONFIG
-then
-   return
-fi
+grep -q TC_CONFIG_XT $CONFIG && return
 
 #check if we dont need our internal header ..
 cat >$TMPDIR/ipttest.c </dev/null 2>&1
-if [ $? -eq 0 ]
-then
+if $CC -I$INCLUDE $IPTC -o $TMPDIR/ipttest $TMPDIR/ipttest.c $IPTL -ldl 
>/dev/null 2>&1; then
echo "TC_CONFIG_XT_OLD:=y" >>$CONFIG
echo "using old xtables (no need for xt-internal.h)"
 fi
@@ -124,10 +116,7 @@ EOF
 check_xt_old_internal_h()
 {
 # bail if previous XT checks has already succeded.
-if grep -q TC_CONFIG_XT $CONFIG
-then
-   return
-fi
+grep -q TC_CONFIG_XT $CONFIG && return
 
 #check if we need our own internal.h
 cat >$TMPDIR/ipttest.c </dev/null 2>&1
-
-   if [ $? -eq 0 ]
-   then
+   if $CC -I$INCLUDE $IPTC -o $TMPDIR/ipttest $TMPDIR/ipttest.c $IPTL -ldl 
>/dev/null 2>&1; then
echo "using old xtables with xt-internal.h"
echo "TC_CONFIG_XT_OLD_H:=y" >>$CONFIG
fi
@@ -163,8 +149,7 @@ EOF
 
 check_ipt()
 {
-   if ! grep TC_CONFIG_XT $CONFIG > /dev/null
-   then
+   if ! grep TC_CONFIG_XT $CONFIG > /dev/null; then
echo "using iptables"
fi
 }
@@ -178,8 +163,7 @@ check_ipt_lib_dir()
return
fi
 
-   for dir in /lib /usr/lib /usr/local/lib
-   do
+   for dir in /lib /usr/lib /usr/local/lib; do
for file in "xtables" "iptables"; do
file="$dir/$file/lib*t_*so"
if [ -f $file ]; then
@@ -202,9 +186,7 @@ int main(int argc, char **argv)
return 0;
 }
 EOF
-$CC -I$INCLUDE -o $TMPDIR/setnstest $TMPDIR/setnstest.c >/dev/null 2>&1
-if [ $? -eq 0 ]
-then
+if $CC -I$INCLUDE -o $TMPDIR/setnstest $TMPDIR/setnstest.c >/dev/null 
2>&1; then
echo "IP_CONFIG_SETNS:=y" >>$CONFIG
echo "yes"
echo "CFLAGS += -DHAVE_SETNS" >>$CONFIG
@@ -235,8 +217,7 @@ int main(void)
 #endif
 EOF
 
-if $CC -I$INCLUDE -o $TMPDIR/ipsettest $TMPDIR/ipsettest.c >/dev/null 2>&1
-then
+if $CC -I$INCLUDE -o $TMPDIR/ipsettest $TMPDIR/ipsettest.c >/dev/null 
2>&1; then
echo "TC_CONFIG_IPSET:=y" >>$CONFIG
echo "yes"
 else
@@ -247,8 +228,7 @@ EOF
 
 check_elf()
 {
-if ${PKG_CONFIG} libelf --exists
-then
+if ${PKG_CONFIG} libelf --exists; then
echo "HAVE_ELF:=y" >>$CONFIG
echo "yes"
 
@@ -262,8 +242,7 @@ check_elf()
 check_selinux()
 # SELinux is a compile time option in the ss utility
 {
-   if ${PKG_CONFIG} libselinux --exists
-   then
+   if ${PKG_CONFIG} libselinux --exists; then
echo "HAVE_SELINUX:=y" >>$CONFIG
echo "yes"
 
@@ -276,8 +255,7 @@ check_selinux()
 
 check_mnl()
 {
-   if ${PKG_CONFIG} libmnl --exists
-   then
+   if ${PKG_CONFIG} libmnl --exists; then
echo "HAVE_MNL:=y" >>$CONFIG
echo "yes"
 
@@ -299,9 +277,7 @@ int main(int argc, char **argv) {
return 0;
 }
 EOF
-$CC -I$INCLUDE -o $TMPDIR/dbtest $TMPDIR/dbtest.c -ldb >/dev/null 2>&1
-if [ $? -eq 0 ]
-then
+if $CC -I$INCLUDE -o $TMPDIR/dbtest $TMPDIR/dbtest.c -ldb >/dev/null 2>&1; 
then
echo "HAVE_BERKELEY_DB:=y" >>$CONFIG
echo "yes"
 else
@@ -320,9 +296,7 @@ int main(int argc, char **argv) {
return 0;
 }
 EOF
-$CC -I$INCLUDE -o $TMPDIR/strtest $TMPDIR/strtest.c >/dev/null 2>&1
-if [ $? -eq 0 ]
-then
+if $CC -I$INCLUDE -o $TMPDIR/strtest $TMPDIR/strtest.c >/dev/null 2>&1; 
then
echo "no"
   

[PATCH iproute2 2/7] tests: Use /bin/sh shebang

2018-09-22 Thread Petr Vorel
Bashisms for both tests were removed in ecd44e68 ("tests: Remove
bashisms (s/source/.)"), so no need to use bash shebang.

+ remove trailing whitespace.

Signed-off-by: Petr Vorel 
---
 testsuite/tests/tc/cls-testbed.t | 4 ++--
 testsuite/tests/tc/dsmark.t  | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/testsuite/tests/tc/cls-testbed.t b/testsuite/tests/tc/cls-testbed.t
index d5c21e5c..cf34dd63 100755
--- a/testsuite/tests/tc/cls-testbed.t
+++ b/testsuite/tests/tc/cls-testbed.t
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
 # vim: ft=sh
 
 . lib/generic.sh
@@ -61,7 +61,7 @@ for q in ${QDISCS}; do
ts_tc "cls-testbed" "tree listing" qdisc list dev eth0
ts_tc "cls-testbed" "tree class listing" class list dev eth0
ts_log "cls-testbed: starting classifier test $c"
-   $c 
+   $c
 
case "$q" in
*)
diff --git a/testsuite/tests/tc/dsmark.t b/testsuite/tests/tc/dsmark.t
index 177585e6..3f1d5ef2 100755
--- a/testsuite/tests/tc/dsmark.t
+++ b/testsuite/tests/tc/dsmark.t
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
 # vim: ft=sh
 
 . lib/generic.sh
-- 
2.19.0.rc2



[PATCH iproute2 6/7] examples: Remove dhcp-client-script

2018-09-22 Thread Petr Vorel
This script is obsolete.

Signed-off-by: Petr Vorel 
---
 examples/dhcp-client-script | 446 
 1 file changed, 446 deletions(-)
 delete mode 100644 examples/dhcp-client-script

diff --git a/examples/dhcp-client-script b/examples/dhcp-client-script
deleted file mode 100644
index f39bc109..
--- a/examples/dhcp-client-script
+++ /dev/null
@@ -1,446 +0,0 @@
-#!/bin/bash
-#
-# dhclient-script for Linux.
-#
-#  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.
-#
-# Authors: Alexey Kuznetsov, 
-#
-# Probably, I did not understand, what this funny feature as "alias"
-# means exactly. For now I suppose, that it is a static address, which
-# we should install and preserve.
-#
-
-exec >> /var/log/DHS.log 2>&1
-
-echo dhc-script $* reason=$reason
-set | grep "^\(old_\|new_\|check_\)"
-
-LOG () {
-echo LOG $* ;
-}
-
-# convert 8bit mask to length
-# arg: $1 = mask
-#
-Mask8ToLen() {
-   local l=0;
-
-   while [ $l -le 7 ]; do
-   if [ $[ ( 1 << $l ) + $1 ] -eq 256 ]; then
-   return  $[ 8 - $l ]
-   fi
-   l=$[ $l + 1 ]
-   done
-   return 0;
-}
-
-# convert inet dotted quad mask to length
-# arg: $1 = dotquad mask
-#
-MaskToLen() {
- local masklen=0
- local mask8=$1
-
- case $1 in
- 0.0.0.0)
-   return 0;
-   ;;
- 255.*.0.0)
-   masklen=8
-   mask8=${mask8#255.}
-   mask8=${mask8%.0.0}
-   ;;
- 255.255.*.0)
-   masklen=16
-   mask8=${mask8#255.255.}
-   mask8=${mask8%.0}
-   ;;
- 255.255.255.*)
-   masklen=24
-   mask8=${mask8#255.255.255.}
-   ;;
- *)
-   return 255
-   ;;
- esac
- Mask8ToLen $mask8
- return $[ $? + $masklen ]
-}
-
-# calculate ABC "natural" mask
-# arg: $1 = dotquad address
-#
-ABCMask () {
- local class;
-
- class=${1%%.*}
-
- if [ "$1" = "255.255.255.255" ]; then
-echo $1
- elif [ "$1" = "0.0.0.0" ]; then
-echo $1
- elif [ $class -ge 224 ]; then
-echo 240.0.0.0
- elif [ $class -ge 192 ]; then
-echo 255.255.255.0
- elif [ $class -ge 128 ]; then
-echo 255.255.0.0
- else
-echo 255.0.0.0
- fi
-}
-
-# calculate ABC "natural" mask length
-# arg: $1 = dotquad address
-#
-ABCMaskLen () {
- local class;
-
- class=${1%%.*}
-
- if [ "$1" = "255.255.255.255" ]; then
-return 32
- elif [ "$1" = "0.0.0.0" ]; then
-return 0
- elif [ $class -ge 224 ]; then
-return 4;
- elif [ $class -ge 192 ]; then
-return 24;
- elif [ $class -ge 128 ]; then
-return 16;
- else
-return 8;
- fi
-}
-
-# Delete IP address
-# args: $1 = interface
-#   $2 = address
-#   $3 = mask
-#   $4 = broadcast
-#   $5 = label
-#
-DelINETAddr () {
-  local masklen=32
-  local addrid=$1
-
-  LOG DelINETAddr $*
-
-  if [ "$5" ]; then
-addrid=$addrid:$5
-  fi
-  LOG ifconfig $addrid down
-  ifconfig $addrid down
-}
-
-# Add IP address
-# args: $1 = interface
-#   $2 = address
-#   $3 = mask
-#   $4 = broadcast
-#   $5 = label
-#
-AddINETAddr () {
-  local mask_arg
-  local brd_arg
-  local addrid=$1
-
-  LOG AddINETAddr $*
-
-  if [ "$5" ]; then
-addrid=$addrid:$5
-  fi
-  if [ "$3" ]; then
-mask_arg="netmask $3"
-  fi
-  if [ "$4" ]; then
-brd_arg="broadcast $4"
-  fi
-
-  LOG ifconfig $addrid $2 $mask_arg $brd_arg up
-  ifconfig $addrid $2 $mask_arg $brd_arg up
-}
-
-# Add default routes
-# args: $1 = routers list
-#
-AddDefaultRoutes() {
-local router
-
-if [ "$1" ]; then
-  LOG AddDefaultRoutes $*
-  for router in $1; do
-LOG route add default gw $router
-route add default gw $router
-  done ;
-fi
-}
-
-# Delete default routes
-# args: $1 = routers list
-#
-DelDefaultRoutes() {
-local router
-
-if [ "$1" ]; then
-  LOG DelDefaultRoutes $*
-
-  for router in $1; do
-LOG route del default gw $router
-route del default gw $router
-  done
-fi
-}
-
-# ping a host
-# args: $1 = dotquad address of the host
-#
-PingNode() {
-LOG PingNode $*
-if ping -q -c 1 -w 2 $1 ; then
-   return 0;
-fi
-return 1;
-}
-
-# Check (and add route, if alive) default routers
-# args: $1 = routers list
-# returns: 0 if at least one router is alive.
-#
-CheckRouterList() {
-local router
-local succeed=1
-
-LOG CheckRouterList $*
-
-for router in $1; do
-  if PingNode $router ; then
-   succeed=0
-route add default gw $router
-  fi
-done
-return $succeed
-}
-
-# Delete/create static routes.
-# args:

[PATCH iproute2 1/7] man: rtpr: Rename s/bash/shell/

2018-09-22 Thread Petr Vorel
ip/rtpr mentioned in man as bash script is actually posix shell script
(doesn't require to use bash).

Signed-off-by: Petr Vorel 
---
 man/man8/rtpr.8 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/man/man8/rtpr.8 b/man/man8/rtpr.8
index 1b04a821..87f291ab 100644
--- a/man/man8/rtpr.8
+++ b/man/man8/rtpr.8
@@ -5,7 +5,7 @@ rtpr \- replace backslashes with newlines.
 
 .SH DESCRIPTION
 .B rtpr
-is a trivial bash script which converts backslashes in standard input to 
newlines. It's sole purpose is to be fed with input from
+is a trivial shell script which converts backslashes in standard input to 
newlines. It's sole purpose is to be fed with input from
 .B ip
 when executed with it's
 .B --oneline
-- 
2.19.0.rc2



[PATCH iproute2 7/7] examples: Remove cbq.init-v0.7.3

2018-09-22 Thread Petr Vorel
This script is obsolete.

Signed-off-by: Petr Vorel 
---
 examples/cbq.init-v0.7.3 | 983 ---
 1 file changed, 983 deletions(-)
 delete mode 100644 examples/cbq.init-v0.7.3

diff --git a/examples/cbq.init-v0.7.3 b/examples/cbq.init-v0.7.3
deleted file mode 100644
index 66448d88..
--- a/examples/cbq.init-v0.7.3
+++ /dev/null
@@ -1,983 +0,0 @@
-#!/bin/bash
-#
-#cbq.init v0.7.3
-#Copyright (C) 1999  Pavel Golubev 
-#Copyright (C) 2001-2004  Lubomir Bulej 
-#
-#chkconfig:   2345 11 89
-#description: sets up CBQ-based traffic control
-#
-#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, see <http://www.gnu.org/licenses/>.
-#
-#To get the latest version, check on Freshmeat for actual location:
-#
-#  http://freshmeat.net/projects/cbq.init
-#
-#
-# VERSION HISTORY
-# ---
-# v0.7.3- Deepak Singhal 
-#- fix timecheck to not ignore regular TIME rules after
-#  encountering a TIME rule that spans over midnight
-#  - Nathan Shafer 
-#- allow symlinks to class files
-#  - Seth J. Blank 
-#- replace hardcoded ip/tc location with variables
-#  - Mark Davis 
-#- allow setting of PRIO_{MARK,RULE,REALM} in class file
-#  - Fernando Sanch 
-#- allow underscores in interface names
-# v0.7.2- Paulo Sedrez
-#- fix time2abs to allow hours with leading zero in TIME rules
-#  - Svetlin Simeonov 
-#- fix cbq_device_list to allow VLAN interfaces
-#  - Mark Davis 
-#- ignore *~ backup files when looking for classes
-#  - Mike Boyer 
-#- fix to allow arguments to be passed to "restart" command
-# v0.7.1- Lubomir Bulej 
-#- default value for PERTURB
-#- fixed small bug in RULE parser to correctly parse rules with
-#  identical source and destination fields
-#- faster initial scanning of DEVICE fields
-# v0.7 - Lubomir Bulej 
-#- lots of various cleanups and reorganizations; the parsing is now
-#  some 40% faster, but the class ID must be in range 0x0002-0x
-#  (again). Because of the number of internal changes and the above
-#  class ID restriction, I bumped the version to 0.7 to indicate
-#  something might have got broken :)
-#- changed PRIO_{U32,FW,ROUTE} to PRIO_{RULE,MARK,REALM}
-#  for consistency with filter keywords
-#- exposed "compile" command
-#  - Catalin Petrescu 
-#- support for port masks in RULE (u32) filter
-#  - Jordan Vrtanoski 
-#- support for week days in TIME rules
-# v0.6.4- Lubomir Bulej 
-#- added PRIO_* variables to allow easy control of filter priorities
-#- added caching to speed up CBQ start, the cache is invalidated
-#  whenever any of the configuration files changes
-#- updated the readme section + some cosmetic fixes
-# v0.6.3- Lubomir Bulej 
-#- removed setup of (unnecessary) class 1:1 - all classes
-#  now use qdisc's default class 1:0 as their parent
-#- minor fix in the timecheck branch - classes
-#  without leaf qdisc were not updated
-#- minor fix to avoid timecheck failure when run
-#  at time with minutes equal to 08 or 09
-#- respect CBQ_PATH setting in environment
-#- made PRIO=5 default, rendering it optional in configs
-#- added support for route filter, see notes about REALM keyword
-#- added support for fw filter, see notes about MARK keyword
-#- added filter display to "list" and "stats" commands
-#- readme section update + various cosmetic fixes
-# v0.6.2- Catalin Petrescu 
-#- added tunnels interface handling
-# v0.6.1- Pavel Golubev 
-#- added sch_prio module loading
-#  (thanks johan at iglo.virtual.or.id for reminding)
-#- resolved errors resulting from stricter syntax checking in bash2
-#  - Lubomir Bulej 
-#- various cosmetic fixes
-# v0.6 - Lubomir Bulej 
-#- attempt to limit number of spawned processes by utilizing
-#  more of sed power (use sed instead of grep+cut)
-#- simplified TIME parser, using bash builtins
-#- added initial support for SFQ as leaf qdisc
-#- reworked the documentation part a little
-#- in

[PATCH iproute2 0/7] Minor shell code cleanup

2018-09-22 Thread Petr Vorel
Hi,

this patchset does minor cleanup in shell scripts:
* remove bashisms
* use /bin/sh shebang
* remove obsolete code from examples
* remove unused code

Kind regards,
Petr

Petr Vorel (7):
  man: rtpr: Rename s/bash/shell/
  tests: Use /bin/sh shebang
  configure: Remove unused function check_prog()
  configure: Remove non-posix shell expansion
  configure: Code cleanup
  examples: Remove dhcp-client-script
  examples: Remove cbq.init-v0.7.3

 configure|  76 +--
 examples/cbq.init-v0.7.3 | 983 ---
 examples/dhcp-client-script  | 446 --
 man/man8/rtpr.8  |   2 +-
 testsuite/tests/tc/cls-testbed.t |   4 +-
 testsuite/tests/tc/dsmark.t  |   2 +-
 6 files changed, 25 insertions(+), 1488 deletions(-)
 delete mode 100644 examples/cbq.init-v0.7.3
 delete mode 100644 examples/dhcp-client-script

-- 
2.19.0.rc2



[PATCH iproute2 3/7] configure: Remove unused function check_prog()

2018-09-22 Thread Petr Vorel
Signed-off-by: Petr Vorel 
---
 configure | 6 --
 1 file changed, 6 deletions(-)

diff --git a/configure b/configure
index 5ef5cd4c..34325f99 100755
--- a/configure
+++ b/configure
@@ -11,12 +11,6 @@ CONFIG=config.mk
 TMPDIR=$(mktemp -d config.XX)
 trap 'status=$?; rm -rf $TMPDIR; exit $status' EXIT HUP INT QUIT TERM
 
-check_prog()
-{
-echo -n "$2"
-command -v $1 >/dev/null 2>&1 && (echo "$3:=y" >> $CONFIG; echo "yes") || 
(echo "no"; return 1)
-}
-
 check_toolchain()
 {
 : ${PKG_CONFIG:=pkg-config}
-- 
2.19.0.rc2



[PATCH iproute2 1/1] Makefile: Add check target

2018-09-21 Thread Petr Vorel
Signed-off-by: Petr Vorel 
---
 Makefile | 4 
 1 file changed, 4 insertions(+)

diff --git a/Makefile b/Makefile
index 25de3893..b7488add 100644
--- a/Makefile
+++ b/Makefile
@@ -77,6 +77,7 @@ help:
@echo " clean   - remove products of build"
@echo " distclean   - remove configuration and build"
@echo " install - install binaries on local machine"
+   @echo " check   - run tests"
@echo " cscope  - build cscope database"
@echo " snapshot- generate version number header"
@echo ""
@@ -118,6 +119,9 @@ clobber:
 
 distclean: clobber
 
+check:
+   cd testsuite && $(MAKE) && $(MAKE) alltests
+
 cscope:
cscope -b -q -R -Iinclude -sip -slib -smisc -snetem -stc
 
-- 
2.19.0.rc2



[PATCH iproute2 v2 0/3] testsuite: make alltests fixes

2018-09-19 Thread Petr Vorel
Hi,

here are simply fixes to restore 'make alltests'.
Currently it does not run.

Kind regards,
Petr

Petr Vorel (3):
  testsuite: Fix missing generate_nlmsg
  testsuite: Generate generate_nlmsg when needed
  testsuite: Warn about empty $(IPVERS)

 testsuite/Makefile | 21 ++---
 1 file changed, 14 insertions(+), 7 deletions(-)

-- 
2.19.0.rc2



[PATCH iproute2 v2 1/3] testsuite: Fix missing generate_nlmsg

2018-09-19 Thread Petr Vorel
Commit ad23e152 caused generate_nlmsg to be always missing:

$ make alltests
make: ./tools/generate_nlmsg: Command not found

Create testclean: to remove only results directory.

Fixes: ad23e152 testsuite: remove all temp files and implement make clean

Signed-off-by: Petr Vorel 
---
 testsuite/Makefile | 11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/testsuite/Makefile b/testsuite/Makefile
index d1ac997d..a31d4531 100644
--- a/testsuite/Makefile
+++ b/testsuite/Makefile
@@ -30,7 +30,6 @@ configure:
 
 compile: configure
echo "Entering iproute2" && cd iproute2 && $(MAKE) && cd ..;
-   $(MAKE) -C tools
 
 listtests:
@for t in $(TESTS); do \
@@ -39,9 +38,11 @@ listtests:
 
 alltests: $(TESTS)
 
-clean:
+testclean:
@echo "Removing $(RESULTS_DIR) dir ..."
@rm -rf $(RESULTS_DIR)
+
+clean: testclean
@rm -f iproute2/iproute2-this
@rm -f tests/ip/link/dev_wo_vf_rate.nl
$(MAKE) -C tools clean
@@ -49,18 +50,18 @@ clean:
 distclean: clean
echo "Entering iproute2" && cd iproute2 && $(MAKE) distclean && cd ..;
 
-$(TESTS): clean
+$(TESTS): testclean
 ifeq (,$(HAVE_UNSHARED_UTIL))
$(error Please install util-linux tools to run tests in separated 
network namespace)
 endif
@./tools/generate_nlmsg
 
@mkdir -p $(RESULTS_DIR)
-   
+
@for d in $(TESTS_DIR); do \
mkdir -p $(RESULTS_DIR)/$$d; \
done
-   
+
@if [ "$(KCPATH)" = "/proc/config.gz" ]; then \
gunzip -c $(KCPATH) >$(KENVFN); \
elif [ "$(KCPATH)" != "" ]; then \
-- 
2.19.0.rc2



[PATCH iproute2 v2 3/3] testsuite: Warn about empty $(IPVERS)

2018-09-19 Thread Petr Vorel
alltests target requires having symlink created by configure target
(default target). Without that there is no test being run.

Signed-off-by: Petr Vorel 
---
 testsuite/Makefile | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/testsuite/Makefile b/testsuite/Makefile
index 1c2467f5..b3aebec1 100644
--- a/testsuite/Makefile
+++ b/testsuite/Makefile
@@ -54,6 +54,9 @@ distclean: clean
echo "Entering iproute2" && cd iproute2 && $(MAKE) distclean && cd ..;
 
 $(TESTS): testclean
+ifeq (,$(IPVERS))
+   $(error Please run make first)
+endif
 ifeq (,$(HAVE_UNSHARED_UTIL))
$(error Please install util-linux tools to run tests in separated 
network namespace)
 endif
-- 
2.19.0.rc2



[PATCH iproute2 v2 2/3] testsuite: Generate generate_nlmsg when needed

2018-09-19 Thread Petr Vorel
Commit 886f2c43 added generate_nlmsg.c. Running alltests
target, which uses the binary required to run 'make -C tools' before.

Fixes: 886f2c43 testsuite: Generate nlmsg blob at runtime

Signed-off-by: Petr Vorel 
---
 testsuite/Makefile | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/testsuite/Makefile b/testsuite/Makefile
index a31d4531..1c2467f5 100644
--- a/testsuite/Makefile
+++ b/testsuite/Makefile
@@ -28,7 +28,7 @@ endif
 configure:
echo "Entering iproute2" && cd iproute2 && $(MAKE) configure && cd ..;
 
-compile: configure
+compile: configure generate_nlmsg
echo "Entering iproute2" && cd iproute2 && $(MAKE) && cd ..;
 
 listtests:
@@ -36,7 +36,10 @@ listtests:
echo "$$t"; \
done
 
-alltests: $(TESTS)
+generate_nlmsg:
+   $(MAKE) -C tools
+
+alltests: generate_nlmsg $(TESTS)
 
 testclean:
@echo "Removing $(RESULTS_DIR) dir ..."
-- 
2.19.0.rc2



Re: [PATCH iproute2] ip maddr: fix filtering by device

2017-10-19 Thread Petr Vorel
> On Thu, Oct 19, 2017 at 10:21:08AM +0200, Michal Kubecek wrote:
> > Commit 530903dd9003 ("ip: fix igmp parsing when iface is long") uses
> > variable len to keep trailing colon from interface name comparison.  This
> > variable is local to loop body but we set it in one pass and use it in
> > following one(s) so that we are actually using (pseudo)random length for
> > comparison. This became apparent since commit b48a1161f5f9 ("ipmaddr: Avoid
> > accessing uninitialized data") always initializes len to zero so that the
> > name comparison is always true. As a result, "ip maddr show dev eth0" shows
> > IPv4 multicast addresses for all interfaces.

> > Instead of keeping the length, let's simply replace the trailing colon with
> > a null byte. The bonus is that we get correct interface name in ma.name.

> > Fixes: 530903dd9003 ("ip: fix igmp parsing when iface is long")
> > Signed-off-by: Michal Kubecek <mkube...@suse.cz>

> Acked-by: Phil Sutter <p...@nwl.cc>

Acked-by: Petr Vorel <pvo...@suse.cz>

Thanks for fixing, Michal.
Petr


Re: [PATCH] tests: Remove bashisms (s/source/.)

2017-10-15 Thread Petr Vorel
Hi Mark,

> > --- a/testsuite/tests/ip/route/add_default_route.t
> > +++ b/testsuite/tests/ip/route/add_default_route.t
> > @@ -1,6 +1,6 @@
> > -#!/bin/sh
> > +#!/bin/bash

> Funny - ^^^ choosing bash explicitly while
> removing the bashism?
Eh, this is really silly, sorry. I've sent a patch to revert it back as it was 
unintentional.


> I noticed a couple other files already specified /bin/bash, yet you removed 
> the bashisms. But the above struck me as something that would not seem to 
> have been intended.
I plan to remove all bashisms. Although having explicit dependency on bash 
(i.e. /bin/bash
in shebang), it would be nice have posix compliant shell scripts (as Randy 
Dunlap also
noted). Or at least don't have bashisms in script with /bin/sh shebang.


Kind regards,
Petr


[PATCH iproute2 1/1] tests: Revert back /bin/sh in shebang

2017-10-15 Thread Petr Vorel
This was added by mistake in commit ecd44e68
("tests: Remove bashisms (s/source/.)")

Signed-off-by: Petr Vorel <petr.vo...@gmail.com>
---
 testsuite/tests/ip/route/add_default_route.t | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/testsuite/tests/ip/route/add_default_route.t 
b/testsuite/tests/ip/route/add_default_route.t
index 0b566f1f..569ba1f8 100755
--- a/testsuite/tests/ip/route/add_default_route.t
+++ b/testsuite/tests/ip/route/add_default_route.t
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
 
 . lib/generic.sh
 
-- 
2.14.2



[PATCH iproute2 v2 2/4] color: Fix another ip segfault when using --color switch

2017-10-13 Thread Petr Vorel
Commit 959f1428 ("color: add new COLOR_NONE and disable_color function")
introducing color enum COLOR_NONE, which is not only duplicite of
COLOR_CLEAR, but also caused segfault, when running ip with --color
switch, as 'attr + 8' in color_fprintf() access array item out of
bounds. Thus removing it and restoring "magic" offset + 7.

Reproduce with:
$ ip -c a

Signed-off-by: Petr Vorel <petr.vo...@gmail.com>
---
 include/color.h | 1 -
 lib/color.c | 4 ++--
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/include/color.h b/include/color.h
index 1cd6f7d2..c183ef79 100644
--- a/include/color.h
+++ b/include/color.h
@@ -2,7 +2,6 @@
 #define __COLOR_H__ 1
 
 enum color_attr {
-   COLOR_NONE,
COLOR_IFNAME,
COLOR_MAC,
COLOR_INET,
diff --git a/lib/color.c b/lib/color.c
index 79d5e289..05afcb21 100644
--- a/lib/color.c
+++ b/lib/color.c
@@ -104,13 +104,13 @@ int color_fprintf(FILE *fp, enum color_attr attr, const 
char *fmt, ...)
 
va_start(args, fmt);
 
-   if (!color_is_enabled || attr == COLOR_NONE) {
+   if (!color_is_enabled || attr == COLOR_CLEAR) {
ret = vfprintf(fp, fmt, args);
goto end;
}
 
ret += fprintf(fp, "%s",
-  color_codes[attr_colors[is_dark_bg ? attr + 8 : attr]]);
+  color_codes[attr_colors[is_dark_bg ? attr + 7 : attr]]);
ret += vfprintf(fp, fmt, args);
ret += fprintf(fp, "%s", color_codes[C_CLEAR]);
 
-- 
2.14.2



[PATCH iproute2 v2 4/4] color: Rename enum

2017-10-13 Thread Petr Vorel
COLOR_NONE is more descriptive than COLOR_CLEAR.

Signed-off-by: Petr Vorel <petr.vo...@gmail.com>
---
 include/color.h  | 2 +-
 include/json_print.h | 2 +-
 lib/color.c  | 6 +++---
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/include/color.h b/include/color.h
index c183ef79..7fd685d0 100644
--- a/include/color.h
+++ b/include/color.h
@@ -8,7 +8,7 @@ enum color_attr {
COLOR_INET6,
COLOR_OPERSTATE_UP,
COLOR_OPERSTATE_DOWN,
-   COLOR_CLEAR
+   COLOR_NONE
 };
 
 void enable_color(void);
diff --git a/include/json_print.h b/include/json_print.h
index 596af35a..dc4d2bb3 100644
--- a/include/json_print.h
+++ b/include/json_print.h
@@ -53,7 +53,7 @@ void close_json_array(enum output_type type, const char 
*delim);
 const char *fmt,   \
 type value)\
{   \
-   print_color_##type_name(t, COLOR_CLEAR, key, fmt, value);   
\
+   print_color_##type_name(t, COLOR_NONE, key, fmt, value);
\
}
 _PRINT_FUNC(int, int);
 _PRINT_FUNC(bool, bool);
diff --git a/lib/color.c b/lib/color.c
index 497f5e1b..8d049a01 100644
--- a/lib/color.c
+++ b/lib/color.c
@@ -106,7 +106,7 @@ int color_fprintf(FILE *fp, enum color_attr attr, const 
char *fmt, ...)
 
va_start(args, fmt);
 
-   if (!color_is_enabled || attr == COLOR_CLEAR) {
+   if (!color_is_enabled || attr == COLOR_NONE) {
ret = vfprintf(fp, fmt, args);
goto end;
}
@@ -130,7 +130,7 @@ enum color_attr ifa_family_color(__u8 ifa_family)
case AF_INET6:
return COLOR_INET6;
default:
-   return COLOR_CLEAR;
+   return COLOR_NONE;
}
 }
 
@@ -142,6 +142,6 @@ enum color_attr oper_state_color(__u8 state)
case IF_OPER_DOWN:
return COLOR_OPERSTATE_DOWN;
default:
-   return COLOR_CLEAR;
+   return COLOR_NONE;
}
 }
-- 
2.14.2



[PATCH iproute2 v2 3/4] color: Cleanup code to remove "magic" offset + 7

2017-10-13 Thread Petr Vorel
Signed-off-by: Petr Vorel <petr.vo...@gmail.com>
---
 lib/color.c | 13 -
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/lib/color.c b/lib/color.c
index 05afcb21..497f5e1b 100644
--- a/lib/color.c
+++ b/lib/color.c
@@ -45,8 +45,8 @@ static const char * const color_codes[] = {
NULL,
 };
 
-static enum color attr_colors[] = {
-   /* light background */
+/* light background */
+static enum color attr_colors_light[] = {
C_CYAN,
C_YELLOW,
C_MAGENTA,
@@ -54,8 +54,10 @@ static enum color attr_colors[] = {
C_GREEN,
C_RED,
C_CLEAR,
+};
 
-   /* dark background */
+/* dark background */
+static enum color attr_colors_dark[] = {
C_BOLD_CYAN,
C_BOLD_YELLOW,
C_BOLD_MAGENTA,
@@ -109,8 +111,9 @@ int color_fprintf(FILE *fp, enum color_attr attr, const 
char *fmt, ...)
goto end;
}
 
-   ret += fprintf(fp, "%s",
-  color_codes[attr_colors[is_dark_bg ? attr + 7 : attr]]);
+   ret += fprintf(fp, "%s", color_codes[is_dark_bg ?
+   attr_colors_dark[attr] : attr_colors_light[attr]]);
+
ret += vfprintf(fp, fmt, args);
ret += fprintf(fp, "%s", color_codes[C_CLEAR]);
 
-- 
2.14.2



[PATCH iproute2 v2 1/4] color: Fix ip segfault when using --color switch

2017-10-13 Thread Petr Vorel
Commit d0e72011 ("ip: ipaddress.c: add support for json output")
introduced passing -1 as enum color_attr. This is not only wrong as no
color_attr has value -1, but also causes another segfault in color_fprintf()
on this setup as there is no item with index -1 in array of enum attr_colors[].
Using COLOR_CLEAR is valid option.

Reproduce with:
$ COLORFGBG='0;15' ip -c a

NOTE: COLORFGBG is environmental variable used for defining whether user
has light or dark background.
COLORFGBG="0;15" is used to ask for color set suitable for light background,
COLORFGBG="15;0" is used to ask for color set suitable for dark background.

Signed-off-by: Petr Vorel <petr.vo...@gmail.com>
---
 include/json_print.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/json_print.h b/include/json_print.h
index b6ce1f9f..596af35a 100644
--- a/include/json_print.h
+++ b/include/json_print.h
@@ -53,7 +53,7 @@ void close_json_array(enum output_type type, const char 
*delim);
 const char *fmt,   \
 type value)\
{   \
-   print_color_##type_name(t, -1, key, fmt, value);\
+   print_color_##type_name(t, COLOR_CLEAR, key, fmt, value);   
\
}
 _PRINT_FUNC(int, int);
 _PRINT_FUNC(bool, bool);
-- 
2.14.2



[PATCH iproute2 v2 0/4] Fix ip segfault when using --color switch

2017-10-13 Thread Petr Vorel
Hi Stephen,

I cleanup code not to use magic offsets. I kept it in separate commits,
as it's clearer what happened.

Petr Vorel (4):
  color: Fix ip segfault when using --color switch
  color: Fix another ip segfault when using --color switch
  color: Cleanup code to remove "magic" offset + 7
  color: Rename enum

 include/color.h  |  3 +--
 include/json_print.h |  2 +-
 lib/color.c  | 17 ++---
 3 files changed, 12 insertions(+), 10 deletions(-)

-- 
2.14.2



[PATCH] tests: Remove bashisms (s/source/.)

2017-10-08 Thread Petr Vorel
Signed-off-by: Petr Vorel <petr.vo...@gmail.com>
---
 testsuite/tests/ip/link/new_link.t| 2 +-
 testsuite/tests/ip/link/show_dev_wo_vf_rate.t | 2 +-
 testsuite/tests/ip/netns/set_nsid.t   | 2 +-
 testsuite/tests/ip/netns/set_nsid_batch.t | 2 +-
 testsuite/tests/ip/route/add_default_route.t  | 4 ++--
 testsuite/tests/ip/tunnel/add_tunnel.t| 2 +-
 testsuite/tests/tc/cls-testbed.t  | 2 +-
 testsuite/tests/tc/dsmark.t   | 2 +-
 testsuite/tests/tc/pedit.t| 2 +-
 9 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/testsuite/tests/ip/link/new_link.t 
b/testsuite/tests/ip/link/new_link.t
index 699adbcd..c17650a2 100755
--- a/testsuite/tests/ip/link/new_link.t
+++ b/testsuite/tests/ip/link/new_link.t
@@ -1,6 +1,6 @@
 #!/bin/sh
 
-source lib/generic.sh
+. lib/generic.sh
 
 ts_log "[Testing add/del virtual links]"
 
diff --git a/testsuite/tests/ip/link/show_dev_wo_vf_rate.t 
b/testsuite/tests/ip/link/show_dev_wo_vf_rate.t
index a600ba65..5b3c004e 100755
--- a/testsuite/tests/ip/link/show_dev_wo_vf_rate.t
+++ b/testsuite/tests/ip/link/show_dev_wo_vf_rate.t
@@ -1,6 +1,6 @@
 #!/bin/sh
 
-source lib/generic.sh
+. lib/generic.sh
 
 NL_FILE="tests/ip/link/dev_wo_vf_rate.nl"
 ts_ip "$0" "Show VF devices w/o VF rate info" -d monitor file $NL_FILE
diff --git a/testsuite/tests/ip/netns/set_nsid.t 
b/testsuite/tests/ip/netns/set_nsid.t
index 606d45ab..8f8c7792 100755
--- a/testsuite/tests/ip/netns/set_nsid.t
+++ b/testsuite/tests/ip/netns/set_nsid.t
@@ -1,6 +1,6 @@
 #!/bin/sh
 
-source lib/generic.sh
+. lib/generic.sh
 
 ts_log "[Testing netns nsid]"
 
diff --git a/testsuite/tests/ip/netns/set_nsid_batch.t 
b/testsuite/tests/ip/netns/set_nsid_batch.t
index abb3f1bb..196fd4b3 100755
--- a/testsuite/tests/ip/netns/set_nsid_batch.t
+++ b/testsuite/tests/ip/netns/set_nsid_batch.t
@@ -1,6 +1,6 @@
 #!/bin/sh
 
-source lib/generic.sh
+. lib/generic.sh
 
 ts_log "[Testing netns nsid in batch mode]"
 
diff --git a/testsuite/tests/ip/route/add_default_route.t 
b/testsuite/tests/ip/route/add_default_route.t
index e5ea6473..0b566f1f 100755
--- a/testsuite/tests/ip/route/add_default_route.t
+++ b/testsuite/tests/ip/route/add_default_route.t
@@ -1,6 +1,6 @@
-#!/bin/sh
+#!/bin/bash
 
-source lib/generic.sh
+. lib/generic.sh
 
 ts_log "[Testing add default route]"
 
diff --git a/testsuite/tests/ip/tunnel/add_tunnel.t 
b/testsuite/tests/ip/tunnel/add_tunnel.t
index 18f6e370..3f5a9d3c 100755
--- a/testsuite/tests/ip/tunnel/add_tunnel.t
+++ b/testsuite/tests/ip/tunnel/add_tunnel.t
@@ -1,6 +1,6 @@
 #!/bin/sh
 
-source lib/generic.sh
+. lib/generic.sh
 
 TUNNEL_NAME="tunnel_test_ip"
 
diff --git a/testsuite/tests/tc/cls-testbed.t b/testsuite/tests/tc/cls-testbed.t
index 2afc26fc..d5c21e5c 100755
--- a/testsuite/tests/tc/cls-testbed.t
+++ b/testsuite/tests/tc/cls-testbed.t
@@ -1,7 +1,7 @@
 #!/bin/bash
 # vim: ft=sh
 
-source lib/generic.sh
+. lib/generic.sh
 
 QDISCS="cbq htb dsmark"
 
diff --git a/testsuite/tests/tc/dsmark.t b/testsuite/tests/tc/dsmark.t
index 6934165e..177585e6 100755
--- a/testsuite/tests/tc/dsmark.t
+++ b/testsuite/tests/tc/dsmark.t
@@ -1,7 +1,7 @@
 #!/bin/bash
 # vim: ft=sh
 
-source lib/generic.sh
+. lib/generic.sh
 
 ts_qdisc_available "dsmark"
 if [ $? -eq 0 ]; then
diff --git a/testsuite/tests/tc/pedit.t b/testsuite/tests/tc/pedit.t
index e9b6c333..8d531a05 100755
--- a/testsuite/tests/tc/pedit.t
+++ b/testsuite/tests/tc/pedit.t
@@ -1,6 +1,6 @@
 #!/bin/sh
 
-source lib/generic.sh
+. lib/generic.sh
 
 DEV="$(rand_dev)"
 ts_ip "$0" "Add $DEV dummy interface" link add dev $DEV type dummy
-- 
2.14.2



[PATCH iproute2 1/1] color: Fix ip segfault in color_fprintf() when using --color switch

2017-10-08 Thread Petr Vorel
This fixes two regressions:

Commit 959f1428 ("color: add new COLOR_NONE and disable_color function")
caused segfault, when running ip with --color switch, as 'attr + 8' in
color_fprintf() access array item out of bounds.
Changing latter value of ternar operator in attr_colors[] index is for
restoring the same colors.
Reproduce the bug with:
$ ip -c a

Commit d0e72011 ("ip: ipaddress.c: add support for json output")
introduced passing -1 as enum color_attr. This is not only wrong as no
color_attr has value -1, but also causes another segfault in color_fprintf()
on this setup as there is no item with index -1 in array of enum attr_colors[].
Using 0 is valid option.

Reproduce the bug with:
$ COLORFGBG='0;15' ip -c a

NOTE: COLORFGBG is environmental variable used for defining whether user
has light or dark background.
COLORFGBG="0;15" is used to ask for color set suitable for light background,
COLORFGBG="15;0" is used to ask for color set suitable for dark background.

Signed-off-by: Petr Vorel <petr.vo...@gmail.com>
---
 include/json_print.h | 2 +-
 lib/color.c  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/json_print.h b/include/json_print.h
index b6ce1f9f..2f3f07c8 100644
--- a/include/json_print.h
+++ b/include/json_print.h
@@ -53,7 +53,7 @@ void close_json_array(enum output_type type, const char 
*delim);
 const char *fmt,   \
 type value)\
{   \
-   print_color_##type_name(t, -1, key, fmt, value);\
+   print_color_##type_name(t, 0, key, fmt, value); \
}
 _PRINT_FUNC(int, int);
 _PRINT_FUNC(bool, bool);
diff --git a/lib/color.c b/lib/color.c
index 79d5e289..e597798f 100644
--- a/lib/color.c
+++ b/lib/color.c
@@ -110,7 +110,7 @@ int color_fprintf(FILE *fp, enum color_attr attr, const 
char *fmt, ...)
}
 
ret += fprintf(fp, "%s",
-  color_codes[attr_colors[is_dark_bg ? attr + 8 : attr]]);
+  color_codes[attr_colors[is_dark_bg ? attr + 6 : attr - 
1]]);
ret += vfprintf(fp, fmt, args);
ret += fprintf(fp, "%s", color_codes[C_CLEAR]);
 
-- 
2.14.2



Re: [PATCH net] r8152: fix the list rx_done may be used without initialization

2017-03-14 Thread Petr Vorel
Hi Hayes,

> The list rx_done would be initialized when the linking on occurs.
> Therefore, if a napi is scheduled without any linking on before,
> the following kernel panic would happen.

>   BUG: unable to handle kernel NULL pointer dereference at 008
>   IP: [] r8152_poll+0xe1e/0x1210 [r8152]
>   PGD 0
>   Oops: 0002 [#1] SMP

thanks for fixing!

Kind regards,
Petr


Re: [PATCH 1/1] r8152: fix NULL pointer dereference in r8152_poll

2017-03-13 Thread Petr Vorel
> > > Unfortunately this doesn't work. Code in r8152.c doesn't use
> > > local_bh_enable()/local_bh_disable(). I tried to lock it with
> > > spin_lock_bh()/spin_unlock_bh() and with mutex_lock()/mutex_unlock()
> > > but neither work.

> > The local_bh_disable() / local_bh_enable() definitely is the right
> > answer to the issue you described.

> > It does not matter what code in r8152.c currently does.

> > https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git/commit/?id=8cf699ec849f4ca1413cea01289bd7d37dbcc626


> You also have to protect other napi_schedule(), like the ones in
> rtl_work_func_t() or rtl8152_post_reset()

I've tested that before :-). I'll be more precise what "not working" means: it 
fixes
invalid pointer issue, but kernel crashes for different reason:

 ...
Call Trace:
 
 net_rx_action+0x23c/0x3f0
 __do_softirq+0x104/0x2e1
 ? usb_runtime_suspend+0x70/0x70 [usbcore]
 do_softirq_own_stack+8x1c/0x30
 
 do_softirq.part.18+0x41/0x50
 __local_bh_enable_ip+0x88/0xa0
 rtl8152_resume+0xe2/0x1a0 [r8152]
 usb_resume_interface.isra.60x99/0xf0 [usbcore]
 usb_resume_both+0x6a/0x130 [usbcore]
 __rpm_callback+0xb9/0x1f0
 rpm_callback+Ox5f/0x80
 ? usb_runtime_suspend+0x70/0x70 [usbcore]
 usb_resume+0x495/0x6b0
 ? update_load_avg+Ox79/0x520
 ? update_load_avg+Ox79/0x520
 ? refcount_dec_and_test+0x11/0x20
 __pm_runtime_resume+0x3f/0x60
 usb_autoresume_device+0x23/0x50 [usbcore]
 usb_dev_open+0xe7/0x250 [usbcore]
 chrdev_open+0xa1/0x200
 do_dentry_open+0x20a/0x2f0
 ? cdev_put+0x30/0x30
 vfs_open+0x4c/0x70
 ? may_open+0x9b/0x100
 path_openat+0x5ec/0x1430
 do_filp_open+0x7e/0xe0
 ? __vfs_write+0x28/0x140
 ? __alloc_fd+0xb2/0x160
 do_sys_open+0x123/0x200
 SyS_open+0x1e/0x20
 entry_SYSCALL_64_fastpath+0x1e/0xad
 ...
 Kernel panic - not syncing: Fatal exception in interrupt
 ...

Patch: http://pastebin.com/Uejjc0Bh (I don't post patch here, as it's not 
working).


Kind regards,
Petr


Re: [PATCH 1/1] r8152: fix NULL pointer dereference in r8152_poll

2017-03-13 Thread Petr Vorel
Hi Eric,

> > The proper work around is to enclose the napi_schedule() in a
> > local_bh_enable()/local_bh_disable()  pair.

> Something like :
> --- a/drivers/net/usb/r8152.c
> +++ b/drivers/net/usb/r8152.c
> @@ -3703,8 +3703,10 @@ static int rtl8152_resume(struct usb_interface *intf)
>   napi_enable(>napi);
>   clear_bit(SELECTIVE_SUSPEND, >flags);
>   smp_mb__after_atomic();
> + local_bh_disable();
>   if (!list_empty(>rx_done))
>   napi_schedule(>napi);
> + local_bh_enable();

Unfortunately this doesn't work. Code in r8152.c doesn't use 
local_bh_enable()/local_bh_disable(). I tried to lock it with 
spin_lock_bh()/spin_unlock_bh() and with mutex_lock()/mutex_unlock() but 
neither work.


Kind regards,
Petr


[PATCH 1/1] r8152: fix NULL pointer dereference in r8152_poll

2017-03-13 Thread Petr Vorel
commit 7489bdadb7d1 (r8152: check rx after napi is enabled) causes null
pointer dereference when using device as under root:

 # rmmod r8152 # or lsusb -v
NOHZ: local_softirq_pending 08
BUG: unable to handle kernel NULL pointer dereference at 0008
IP: r8152_poll+0x125/0x570 [r8152]
PGD 89b4cf067
PUD 898ff2067
PMD 0
Oops: 0002 [#1] PREEMPT SMP

Signed-off-by: Petr Vorel <petr.vo...@gmail.com>
---
NOTE: This is just a workaround, I suppose, there is better way how to fix that
(which allows keeping scheduling the napi for rx after napi_enable()).
---
 drivers/net/usb/r8152.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index 986243c932cc..79c665a89a47 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -3703,8 +3703,6 @@ static int rtl8152_resume(struct usb_interface *intf)
napi_enable(>napi);
clear_bit(SELECTIVE_SUSPEND, >flags);
smp_mb__after_atomic();
-   if (!list_empty(>rx_done))
-   napi_schedule(>napi);
} else {
tp->rtl_ops.up(tp);
netif_carrier_off(tp->netdev);
-- 
2.12.0



[iproute PATCH v3 1/1] color: use "light" colors for dark background

2017-03-01 Thread Petr Vorel
COLORFGBG environment variable is used to detect dark background.

Idea and a bit of code is borrowed from Vim, thanks.

Signed-off-by: Petr Vorel <pvo...@suse.cz>
---
Changes v2->v3: remove unnecessary cast.
---
 include/color.h |  1 +
 lib/color.c | 45 -
 2 files changed, 45 insertions(+), 1 deletion(-)

diff --git a/include/color.h b/include/color.h
index c1c29831..ba0b237e 100644
--- a/include/color.h
+++ b/include/color.h
@@ -12,6 +12,7 @@ enum color_attr {
 };
 
 void enable_color(void);
+void set_color_palette(void);
 int color_fprintf(FILE *fp, enum color_attr attr, const char *fmt, ...);
 enum color_attr ifa_family_color(__u8 ifa_family);
 enum color_attr oper_state_color(__u8 state);
diff --git a/lib/color.c b/lib/color.c
index 95596be2..810fb1fa 100644
--- a/lib/color.c
+++ b/lib/color.c
@@ -1,5 +1,7 @@
 #include 
 #include 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -14,6 +16,13 @@ enum color {
C_MAGENTA,
C_CYAN,
C_WHITE,
+   C_BOLD_RED,
+   C_BOLD_GREEN,
+   C_BOLD_YELLOW,
+   C_BOLD_BLUE,
+   C_BOLD_MAGENTA,
+   C_BOLD_CYAN,
+   C_BOLD_WHITE,
C_CLEAR
 };
 
@@ -25,25 +34,59 @@ static const char * const color_codes[] = {
"\e[35m",
"\e[36m",
"\e[37m",
+   "\e[1;31m",
+   "\e[1;32m",
+   "\e[1;33m",
+   "\e[1;34m",
+   "\e[1;35m",
+   "\e[1;36m",
+   "\e[1;37m",
"\e[0m",
NULL,
 };
 
 static enum color attr_colors[] = {
+   /* light background */
C_CYAN,
C_YELLOW,
C_MAGENTA,
C_BLUE,
C_GREEN,
C_RED,
+   C_CLEAR,
+
+   /* dark background */
+   C_BOLD_CYAN,
+   C_BOLD_YELLOW,
+   C_BOLD_MAGENTA,
+   C_BOLD_BLUE,
+   C_BOLD_GREEN,
+   C_BOLD_RED,
C_CLEAR
 };
 
+static int is_dark_bg;
 static int color_is_enabled;
 
 void enable_color(void)
 {
color_is_enabled = 1;
+   set_color_palette();
+}
+
+void set_color_palette(void)
+{
+   char *p = getenv("COLORFGBG");
+
+   /*
+* COLORFGBG environment variable usually contains either two or three
+* values separated by semicolons; we want the last value in either 
case.
+* If this value is 0-6 or 8, background is dark.
+*/
+   if (p && (p = strrchr(p, ';')) != NULL
+   && ((p[1] >= '0' && p[1] <= '6') || p[1] == '8')
+   && p[2] == '\0')
+   is_dark_bg = 1;
 }
 
 int color_fprintf(FILE *fp, enum color_attr attr, const char *fmt, ...)
@@ -58,7 +101,7 @@ int color_fprintf(FILE *fp, enum color_attr attr, const char 
*fmt, ...)
goto end;
}
 
-   ret += fprintf(fp, "%s", color_codes[attr_colors[attr]]);
+   ret += fprintf(fp, "%s", color_codes[attr_colors[is_dark_bg ? attr + 7 
: attr]]);
ret += vfprintf(fp, fmt, args);
ret += fprintf(fp, "%s", color_codes[C_CLEAR]);
 
-- 
2.11.0



[iproute PATCH v2 1/1] color: use "light" colors for dark background

2017-02-27 Thread Petr Vorel
COLORFGBG environment variable is used to detect dark background.

Idea and a bit of code is borrowed from Vim, thanks.

Signed-off-by: Petr Vorel <pvo...@suse.cz>
---
Changes v1->V2:
* Rename function and enum values
* Add missing bold white enum + it's code.
---
 include/color.h |  1 +
 lib/color.c | 45 -
 2 files changed, 45 insertions(+), 1 deletion(-)

diff --git a/include/color.h b/include/color.h
index c1c29831..ba0b237e 100644
--- a/include/color.h
+++ b/include/color.h
@@ -12,6 +12,7 @@ enum color_attr {
 };
 
 void enable_color(void);
+void set_color_palette(void);
 int color_fprintf(FILE *fp, enum color_attr attr, const char *fmt, ...);
 enum color_attr ifa_family_color(__u8 ifa_family);
 enum color_attr oper_state_color(__u8 state);
diff --git a/lib/color.c b/lib/color.c
index 95596be2..c048c76e 100644
--- a/lib/color.c
+++ b/lib/color.c
@@ -1,5 +1,7 @@
 #include 
 #include 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -14,6 +16,13 @@ enum color {
C_MAGENTA,
C_CYAN,
C_WHITE,
+   C_BOLD_RED,
+   C_BOLD_GREEN,
+   C_BOLD_YELLOW,
+   C_BOLD_BLUE,
+   C_BOLD_MAGENTA,
+   C_BOLD_CYAN,
+   C_BOLD_WHITE,
C_CLEAR
 };
 
@@ -25,25 +34,59 @@ static const char * const color_codes[] = {
"\e[35m",
"\e[36m",
"\e[37m",
+   "\e[1;31m",
+   "\e[1;32m",
+   "\e[1;33m",
+   "\e[1;34m",
+   "\e[1;35m",
+   "\e[1;36m",
+   "\e[1;37m",
"\e[0m",
NULL,
 };
 
 static enum color attr_colors[] = {
+   /* light background */
C_CYAN,
C_YELLOW,
C_MAGENTA,
C_BLUE,
C_GREEN,
C_RED,
+   C_CLEAR,
+
+   /* dark background */
+   C_BOLD_CYAN,
+   C_BOLD_YELLOW,
+   C_BOLD_MAGENTA,
+   C_BOLD_BLUE,
+   C_BOLD_GREEN,
+   C_BOLD_RED,
C_CLEAR
 };
 
+static int is_dark_bg;
 static int color_is_enabled;
 
 void enable_color(void)
 {
color_is_enabled = 1;
+   set_color_palette();
+}
+
+void set_color_palette(void)
+{
+   char *p = getenv("COLORFGBG");
+
+   /*
+* COLORFGBG environment variable usually contains either two or three
+* values separated by semicolons; we want the last value in either 
case.
+* If this value is 0-6 or 8, background is dark.
+*/
+   if (p && (p = (char *)strrchr(p, ';')) != NULL
+   && ((p[1] >= '0' && p[1] <= '6') || p[1] == '8')
+   && p[2] == '\0')
+   is_dark_bg = 1;
 }
 
 int color_fprintf(FILE *fp, enum color_attr attr, const char *fmt, ...)
@@ -58,7 +101,7 @@ int color_fprintf(FILE *fp, enum color_attr attr, const char 
*fmt, ...)
goto end;
}
 
-   ret += fprintf(fp, "%s", color_codes[attr_colors[attr]]);
+   ret += fprintf(fp, "%s", color_codes[attr_colors[is_dark_bg ? attr + 7 
: attr]]);
ret += vfprintf(fp, fmt, args);
ret += fprintf(fp, "%s", color_codes[C_CLEAR]);
 
-- 
2.11.0



Re: [PATCH 1/1] color: use "light" colors for dark background

2017-02-27 Thread Petr Vorel
Hi,

> Yea, I admit, the original color palette is kind of horrendous. I
> wouldn't say the current colors are suitable for a light background
> either.

> I propose you just replace the current colors with their bold
> variants, and leave the background hue guessing out all together. That
> would be an all-round improvement for everyone.
Well, I agree that original colors aren't the best ones for a light background 
either, but
not all bold variants are suitable for light background - yellow, white and 
cyan are
problematic at least on some terminals with light background (e.g. konsole; 
white isn't
used). So I'd really keep separate sets of colors.

> I'll include some comments on this patch-set anyway, as I had a look
> at it.
Thanks for your review, I'll post fixed version with two sets of colors.


Kind regards,
Petr


Re: [PATCH 1/1] color: use "light" colors for dark background

2017-02-27 Thread Petr Vorel
Hi,

> This really needs to be standardized with some convention. So that ls, grep, 
> git
> all behave the same and done by some standard library.

> The current method is hack that keeps on growing.

It would be easier, if the code could be adapted by some broadly used library, 
than start
new project for it. But, as there is probably no suitable existing library, it 
would have
to be a new one.


Kind regards,
Petr


[PATCH 1/1] color: use "light" colors for dark background

2017-02-24 Thread Petr Vorel
COLORFGBG environment variable is used to detect dark background.

Idea and a bit of code is borrowed from Vim, thanks.

Signed-off-by: Petr Vorel <pvo...@suse.cz>
---
Colors are nice, but the ones chosen aren't suitable for dark background.
COLORFGBG environment variable is used in some libraries and software (e.g.
ncurses, Vim). COLORFGBG is set by various terminal emulators (e.g. konsole,
rxvt and rxvt-unicode).

Chosen colors are questionable. Best solution would be also allow user to
redefine colors, like ls does with LS_COLORS or grep with GREP_COLORS. But that
is maybe overkill.
---
 include/color.h |  1 +
 lib/color.c | 43 ++-
 2 files changed, 43 insertions(+), 1 deletion(-)

diff --git a/include/color.h b/include/color.h
index c1c29831..43190db4 100644
--- a/include/color.h
+++ b/include/color.h
@@ -12,6 +12,7 @@ enum color_attr {
 };
 
 void enable_color(void);
+void set_background(void);
 int color_fprintf(FILE *fp, enum color_attr attr, const char *fmt, ...);
 enum color_attr ifa_family_color(__u8 ifa_family);
 enum color_attr oper_state_color(__u8 state);
diff --git a/lib/color.c b/lib/color.c
index 95596be2..69375b26 100644
--- a/lib/color.c
+++ b/lib/color.c
@@ -1,5 +1,7 @@
 #include 
 #include 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -14,6 +16,12 @@ enum color {
C_MAGENTA,
C_CYAN,
C_WHITE,
+   C_LIGHT_RED,
+   C_LIGHT_GREEN,
+   C_LIGHT_YELLOW,
+   C_LIGHT_BLUE,
+   C_LIGHT_MAGENTA,
+   C_LIGHT_CYAN,
C_CLEAR
 };
 
@@ -25,25 +33,58 @@ static const char * const color_codes[] = {
"\e[35m",
"\e[36m",
"\e[37m",
+   "\e[1;31m",
+   "\e[1;32m",
+   "\e[1;33m",
+   "\e[1;34m",
+   "\e[1;35m",
+   "\e[1;36m",
"\e[0m",
NULL,
 };
 
 static enum color attr_colors[] = {
+   /* light background */
C_CYAN,
C_YELLOW,
C_MAGENTA,
C_BLUE,
C_GREEN,
C_RED,
+   C_CLEAR,
+
+   /* dark background */
+   C_LIGHT_CYAN,
+   C_LIGHT_YELLOW,
+   C_LIGHT_MAGENTA,
+   C_LIGHT_BLUE,
+   C_LIGHT_GREEN,
+   C_LIGHT_RED,
C_CLEAR
 };
 
+static int is_dark_bg;
 static int color_is_enabled;
 
 void enable_color(void)
 {
color_is_enabled = 1;
+   set_background();
+}
+
+void set_background(void)
+{
+   char *p = getenv("COLORFGBG");
+
+   /*
+* COLORFGBG environment variable usually contains either two or three
+* values separated by semicolons; we want the last value in either 
case.
+* If this value is 0-6 or 8, background is dark.
+*/
+   if (p && (p = (char *)strrchr(p, ';')) != NULL
+   && ((p[1] >= '0' && p[1] <= '6') || p[1] == '8')
+   && p[2] == '\0')
+   is_dark_bg = 1;
 }
 
 int color_fprintf(FILE *fp, enum color_attr attr, const char *fmt, ...)
@@ -58,7 +99,7 @@ int color_fprintf(FILE *fp, enum color_attr attr, const char 
*fmt, ...)
goto end;
}
 
-   ret += fprintf(fp, "%s", color_codes[attr_colors[attr]]);
+   ret += fprintf(fp, "%s", color_codes[attr_colors[is_dark_bg ? attr + 7 
: attr]]);
ret += vfprintf(fp, fmt, args);
ret += fprintf(fp, "%s", color_codes[C_CLEAR]);
 
-- 
2.11.0



Re: [PATCH 1/1] ip: fix igmp parsing when iface is long

2017-01-17 Thread Petr Vorel
Hi,

> Entries with long vhost names in /proc/net/igmp have no whitespace
> between name and colon, so sscanf() adds it to vhost and
> 'ip maddr show iface' doesn't include inet result.

Bug was also reported to bugzilla 
(https://bugzilla.kernel.org/show_bug.cgi?id=192741),
with updated comment in the patch.


Kind regards,
Petr


[PATCH 1/1] ip: fix igmp parsing when iface is long

2017-01-16 Thread Petr Vorel
Entries with long vhost names in /proc/net/igmp have no whitespace
between name and colon, so sscanf() adds it to vhost and
'ip maddr show iface' doesn't include inet result.

Signed-off-by: Petr Vorel <pvo...@suse.cz>
---
 ip/ipmaddr.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/ip/ipmaddr.c b/ip/ipmaddr.c
index 22eb407..4f726fd 100644
--- a/ip/ipmaddr.c
+++ b/ip/ipmaddr.c
@@ -136,13 +136,17 @@ static void read_igmp(struct ma_info **result_p)
 
while (fgets(buf, sizeof(buf), fp)) {
struct ma_info *ma;
+   size_t len;
 
if (buf[0] != '\t') {
sscanf(buf, "%d%s", , m.name);
+   len = strlen(m.name);
+   if (m.name[len - 1] == ':')
+   len--;
continue;
}
 
-   if (filter.dev && strcmp(filter.dev, m.name))
+   if (filter.dev && strncmp(filter.dev, m.name, len))
continue;
 
sscanf(buf, "%08x%d", (__u32 *), );
-- 
2.11.0