public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2015-11-08 14:30 Robin H. Johnson
  0 siblings, 0 replies; 109+ messages in thread
From: Robin H. Johnson @ 2015-11-08 14:30 UTC (permalink / raw
  To: gentoo-commits

commit:     8b98728ce0b3249da5cc2e6571bf19d57fe75a14
Author:     Alon Bar-Lev <alonbl <AT> gentoo <DOT> org>
AuthorDate: Sat Nov  7 20:02:22 2015 +0000
Commit:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
CommitDate: Sat Nov  7 20:02:22 2015 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=8b98728c

Revert "bridge: use/prefer iproute2/sysfs where possible"

This reverts commit 6befe06a7e72b5b7f17c7f1118fc16000a0cce13.

 net/bridge.sh | 89 ++++-------------------------------------------------------
 1 file changed, 6 insertions(+), 83 deletions(-)

diff --git a/net/bridge.sh b/net/bridge.sh
index 87e4055..60d3eeb 100644
--- a/net/bridge.sh
+++ b/net/bridge.sh
@@ -4,7 +4,7 @@
 bridge_depend()
 {
 	before interface macnet
-	program ip brctl
+	program brctl
 }
 
 _config_vars="$_config_vars bridge bridge_add brctl"
@@ -29,83 +29,6 @@ _bridge_ports()
 	done
 }
 
-_brctl()
-{
-	if [ -z "${_bridge_use_ip}" ]; then
-	       if ip -V >/dev/null 2>&1 && [ "$(ip -V | cut -c 24-29)" -ge 130430 ]; then
-			_bridge_use_ip=1
-		else
-			_bridge_use_ip=0
-		fi
-	fi
-	if [ "${_bridge_use_ip}" -eq 1 ]; then
-		case "$1" in
-			addbr)
-				ip link add "$2" type bridge
-				;;
-			delbr)
-				ip link del "$2"
-				;;
-			addif)
-				ip link set "$3" master "$2"
-				;;
-			delif)
-				ip link set "$3" nomaster
-				;;
-			setageing)
-				echo "$3" > /sys/class/net/"$2"/bridge/ageing_time
-				;;
-			setgcint)
-				# appears to have been dropped in Debian, and I don't see a sysfs file for it
-				eerror "brctl setgcint is not supported!"
-				return 1
-				;;
-			stp)
-				if [ "$3" = "on" -o "$3" = "yes" -o "$3" = "1" ]; then
-					_stp_state=1
-				elif [ "$3" = "off" -o "$3" = "no" -o "$3" = "0" ]; then
-					_stp_state=0
-				else
-					eerror "Invalid STP state for brctl stp!"
-					return 1
-				fi
-				echo ${_stp_state} > /sys/class/net/"$2"/bridge/stp_state
-				;;
-			setbridgeprio)
-				echo "$3" > /sys/class/net/"$2"/bridge/priority
-				;;
-			setfd)
-				echo "$3" > /sys/class/net/"$2"/bridge/forward_delay
-				;;
-			sethello)
-				echo "$3" > /sys/class/net/"$2"/bridge/hello_time
-				;;
-			setmaxage)
-				echo "$3" > /sys/class/net/"$2"/bridge/max_age
-				;;
-			setpathcost)
-				echo "$4" > /sys/class/net/"$2"/brif/"$3"/path_cost
-				;;
-			setportprio)
-				echo "$4" > /sys/class/net/"$2"/brif/"$3"/priority
-				;;
-			hairpin)
-				if [ "$4" -eq "on" -o "$4" -eq "yes" -o "$4" -eq "1" ]; then
-					_hairpin_mode=1
-				elif [ "$4" -eq "off" -o "$4" -eq "no" -o "$4" -eq "0" ]; then
-					_hairpin_mode=0
-				else
-					eerror "Invalid hairpin mode for brctl hairpin!"
-					return 1
-				fi
-				echo ${_hairpin_mode} > /sys/class/net/"$2"/brif/"$3"/hairpin_mode
-				;;
-		esac
-	else
-		brctl "$@"
-	fi
-}
-
 bridge_pre_start()
 {
 	local brif= oiface="${IFACE}" e= x=
@@ -147,7 +70,7 @@ bridge_pre_start()
 
 	if ! _is_bridge ; then
 		ebegin "Creating bridge ${IFACE}"
-		if ! _brctl addbr "${IFACE}"; then
+		if ! brctl addbr "${IFACE}"; then
 			eend 1
 			return 1
 		fi
@@ -166,7 +89,7 @@ bridge_pre_start()
 		x=$1
 		shift
 		set -- "${x}" "${IFACE}" "$@"
-		_brctl "$@"
+		brctl "$@"
 	done
 	unset IFS
 
@@ -197,7 +120,7 @@ bridge_pre_start()
 			fi
 			# The interface is known to exist now
 			_up
-			if ! _brctl addif "${BR_IFACE}" "${x}"; then
+			if ! brctl addif "${BR_IFACE}" "${x}"; then
 				eend 1
 				return 1
 			fi
@@ -253,13 +176,13 @@ bridge_post_stop()
 		ebegin "Removing port ${port}${extra}"
 		local IFACE="${port}"
 		_set_flag -promisc
-		_brctl delif "${iface}" "${port}"
+		brctl delif "${iface}" "${port}"
 		eend $?
 	done
 
 	if ${delete}; then
 		eoutdent
-		_brctl delbr "${iface}"
+		brctl delbr "${iface}"
 		eend $?
 	fi
 


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2024-09-29  0:28 Sam James
  0 siblings, 0 replies; 109+ messages in thread
From: Sam James @ 2024-09-29  0:28 UTC (permalink / raw
  To: gentoo-commits

commit:     ba522492a3f9e057867f4d7f1d2491cd3a7dbfc3
Author:     Alexander Zubkov <green <AT> qrator <DOT> net>
AuthorDate: Sat Sep 28 19:54:51 2024 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sun Sep 29 00:28:25 2024 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=ba522492

net: iproute2: fix missing quotes in test

Missing quotes cause incorrect evaluation of an empty string, causing
the expression to be always true. Thus every route is considered "nodev"
route, causing problems in cases where specific dev is required.

Original "nodev" patch 7c6a8de0 contained bashism that forgave missing
quoutes. But later it was fixed by 97a79cfd, and the missing quotes
became critical.

Signed-off-by: Alexander Zubkov <green <AT> qrator.net>
Closes: https://bugs.gentoo.org/940443
X-Gentoo-Bug: 940443
X-Gentoo-Bug-URL: https://bugs.gentoo.org/940443
Closes: https://github.com/gentoo/netifrc/pull/58
Signed-off-by: Sam James <sam <AT> gentoo.org>

 net/iproute2.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/iproute2.sh b/net/iproute2.sh
index ca43496..4abc47c 100644
--- a/net/iproute2.sh
+++ b/net/iproute2.sh
@@ -290,7 +290,7 @@ _add_route()
 
 	# Process dev vs nodev routes
 	# Positional parameters are used for correct array handling
-	if [ -n ${rtype} ]; then
+	if [ -n "${rtype}" ]; then
 		local nodev_routes="$(service_get_value "nodev_routes")"
 		service_set_value "nodev_routes" "${nodev_routes}
 ${family} route del ${rtype} ${cmd}"


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2024-09-23 12:02 Sam James
  0 siblings, 0 replies; 109+ messages in thread
From: Sam James @ 2024-09-23 12:02 UTC (permalink / raw
  To: gentoo-commits

commit:     25ccdf84a42bd5f39cc3577e2e1aeaabbf037a4b
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Mon Sep 23 12:02:20 2024 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Mon Sep 23 12:02:20 2024 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=25ccdf84

net: fix ip*6*token install

Fixes: c7e2531539064d3035e5ae2710e408e8975e354e
Signed-off-by: Sam James <sam <AT> gentoo.org>

 net/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/Makefile b/net/Makefile
index 02c06fb..d4f9320 100644
--- a/net/Makefile
+++ b/net/Makefile
@@ -11,7 +11,7 @@ INC-FreeBSD=	iwconfig.sh
 
 SRCS-Linux=	iwconfig.sh.in udhcpc.sh.in
 INC-Linux=	adsl.sh apipa.sh arping.sh bonding.sh br2684ctl.sh bridge.sh \
-		ccwgroup.sh clip.sh ethtool.sh iproute2.sh iptoken.sh ifplugd.sh ip6to4.sh \
+		ccwgroup.sh clip.sh ethtool.sh iproute2.sh ip6token.sh ifplugd.sh ip6to4.sh \
 		ipppd.sh iwconfig.sh netplugd.sh pppd.sh tuntap.sh udhcpc.sh \
 		vlan.sh macvlan.sh ip6rd.sh firewalld.sh dummy.sh hsr.sh l2tp.sh \
 		iw.sh iwd.sh wireguard.sh veth.sh dhclientv6.sh qmi.sh


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2024-09-09 22:43 Patrick McLean
  0 siblings, 0 replies; 109+ messages in thread
From: Patrick McLean @ 2024-09-09 22:43 UTC (permalink / raw
  To: gentoo-commits

commit:     c7e2531539064d3035e5ae2710e408e8975e354e
Author:     Jaco Kroon <jaco <AT> uls <DOT> co <DOT> za>
AuthorDate: Sat Sep  7 08:24:13 2024 +0000
Commit:     Patrick McLean <chutzpah <AT> gentoo <DOT> org>
CommitDate: Sat Sep  7 08:26:28 2024 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=c7e25315

Actually install iptoken.sh.

This is a fixup of bde6dd2ad5b393e351ae8fd8d89f3bec62e52914 where I
didn't notice that I need to additionally add to the Makefile to have
the script installed.

Signed-off-by: Jaco Kroon <jaco <AT> uls.co.za>

 net/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/Makefile b/net/Makefile
index 22bd8d1..02c06fb 100644
--- a/net/Makefile
+++ b/net/Makefile
@@ -11,7 +11,7 @@ INC-FreeBSD=	iwconfig.sh
 
 SRCS-Linux=	iwconfig.sh.in udhcpc.sh.in
 INC-Linux=	adsl.sh apipa.sh arping.sh bonding.sh br2684ctl.sh bridge.sh \
-		ccwgroup.sh clip.sh ethtool.sh iproute2.sh ifplugd.sh ip6to4.sh \
+		ccwgroup.sh clip.sh ethtool.sh iproute2.sh iptoken.sh ifplugd.sh ip6to4.sh \
 		ipppd.sh iwconfig.sh netplugd.sh pppd.sh tuntap.sh udhcpc.sh \
 		vlan.sh macvlan.sh ip6rd.sh firewalld.sh dummy.sh hsr.sh l2tp.sh \
 		iw.sh iwd.sh wireguard.sh veth.sh dhclientv6.sh qmi.sh


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2024-09-01  9:22 Sam James
  0 siblings, 0 replies; 109+ messages in thread
From: Sam James @ 2024-09-01  9:22 UTC (permalink / raw
  To: gentoo-commits

commit:     82592ff33bd3409047ae78448e55afbf7994f405
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Sun Sep  1 09:22:35 2024 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sun Sep  1 09:22:35 2024 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=82592ff3

net/ip6token.sh: cleanup whitespace

Signed-off-by: Sam James <sam <AT> gentoo.org>

 net/ip6token.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/ip6token.sh b/net/ip6token.sh
index 71e17b5..8b0ca31 100644
--- a/net/ip6token.sh
+++ b/net/ip6token.sh
@@ -14,7 +14,7 @@ ip6token_pre_start()
 	eval tconfig=\$ip6token_${IFVAR}
 
 	[ -z "${tconfig}" ] && return 0
-	ip token set "${tconfig}" dev "${IFACE}" 
+	ip token set "${tconfig}" dev "${IFACE}"
 	return $?
 }
 


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2024-09-01  9:21 Sam James
  0 siblings, 0 replies; 109+ messages in thread
From: Sam James @ 2024-09-01  9:21 UTC (permalink / raw
  To: gentoo-commits

commit:     97a79cfd068a6cc07e9feed0ac5b71f64347ae4a
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Sun Sep  1 09:21:32 2024 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sun Sep  1 09:21:32 2024 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=97a79cfd

net: iproute2: fix bashism

Reported by CyberTailor at https://github.com/gentoo/netifrc/pull/53#discussion_r1740019302.

Fixes: 7c6a8de0c521ea474bccb0dbda4338ff293cdfc6
Signed-off-by: Sam James <sam <AT> gentoo.org>

 net/iproute2.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/iproute2.sh b/net/iproute2.sh
index 7db7f5b..ca43496 100644
--- a/net/iproute2.sh
+++ b/net/iproute2.sh
@@ -290,7 +290,7 @@ _add_route()
 
 	# Process dev vs nodev routes
 	# Positional parameters are used for correct array handling
-	if [[ -n ${rtype} ]]; then
+	if [ -n ${rtype} ]; then
 		local nodev_routes="$(service_get_value "nodev_routes")"
 		service_set_value "nodev_routes" "${nodev_routes}
 ${family} route del ${rtype} ${cmd}"


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2024-08-28 18:54 Patrick McLean
  0 siblings, 0 replies; 109+ messages in thread
From: Patrick McLean @ 2024-08-28 18:54 UTC (permalink / raw
  To: gentoo-commits

commit:     e04d54da670198ce0aff2fe1577fbd3c44b15c26
Author:     Patrick McLean <chutzpah <AT> gentoo <DOT> org>
AuthorDate: Wed Aug 28 18:51:30 2024 +0000
Commit:     Patrick McLean <chutzpah <AT> gentoo <DOT> org>
CommitDate: Wed Aug 28 18:54:05 2024 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=e04d54da

Disable IPv6 on subdevices for bonding and bridges

Rather than shelling out to the `sysctl` command like the PR does,
let's write directly to `/proc/sys` after checking that it exists.

This likely needs work to do the same thing on BSD.

Closes: https://bugs.gentoo.org/515640
Closes: https://github.com/gentoo/netifrc/pull/55
Signed-off-by: Patrick McLean <chutzpah <AT> gentoo.org>

 net/bonding.sh | 2 ++
 net/bridge.sh  | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/net/bonding.sh b/net/bonding.sh
index e3fcaa7..bb8b061 100644
--- a/net/bonding.sh
+++ b/net/bonding.sh
@@ -133,6 +133,8 @@ bonding_pre_start()
 		for IFACE in ${slaves}; do
 			_delete_addresses
 			_down
+			local disable_ipv6="/proc/sys/net/ipv6/conf/${IFACE}/disable_ipv6"
+			[ -f "${disable_ipv6}" ] && printf '1\n' > "${disable_ipv6}"
 		done
 	fi
 	)

diff --git a/net/bridge.sh b/net/bridge.sh
index a380f6a..cea8a49 100644
--- a/net/bridge.sh
+++ b/net/bridge.sh
@@ -152,6 +152,8 @@ bridge_pre_start()
 				return 1
 			fi
 			# The interface is known to exist now
+			local disable_ipv6="/proc/sys/net/ipv6/conf/${IFACE}/disable_ipv6"
+			[ -f "${disable_ipv6}" ] && printf '1\n' > "${disable_ipv6}"
 			_up
 			if ${do_iproute2}; then
 				_netns ip link set "${x}" master "${BR_IFACE}"


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2024-06-11  0:39 Patrick McLean
  0 siblings, 0 replies; 109+ messages in thread
From: Patrick McLean @ 2024-06-11  0:39 UTC (permalink / raw
  To: gentoo-commits

commit:     7f323cf374035ac1c871f13d6a6ad29bb97bc930
Author:     Andrey Volkov <volkov.am <AT> ekb-info <DOT> ru>
AuthorDate: Tue Sep 28 13:40:27 2021 +0000
Commit:     Patrick McLean <chutzpah <AT> gentoo <DOT> org>
CommitDate: Fri May 24 05:51:45 2024 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=7f323cf3

Add missing wireguard_depend program

Signed-off-by: Andrey Volkov <volkov <AT> ekb-info.ru>

 net/wireguard.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/wireguard.sh b/net/wireguard.sh
index f6ca69e..301836d 100644
--- a/net/wireguard.sh
+++ b/net/wireguard.sh
@@ -5,7 +5,7 @@
 
 wireguard_depend()
 {
-	program wg
+	program ip wg
 	before interface
 }
 


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2024-06-11  0:39 Patrick McLean
  0 siblings, 0 replies; 109+ messages in thread
From: Patrick McLean @ 2024-06-11  0:39 UTC (permalink / raw
  To: gentoo-commits

commit:     9ef4fb84a7c1848c067f89f5510f448fb04c5c7a
Author:     Andrey Volkov <volkov.am <AT> ekb-info <DOT> ru>
AuthorDate: Tue Sep 28 13:43:52 2021 +0000
Commit:     Patrick McLean <chutzpah <AT> gentoo <DOT> org>
CommitDate: Fri May 24 05:51:59 2024 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=9ef4fb84

Add type_${IFVAR}=wireguard for arbitrary wireguard interface names

Signed-off-by: Andrey Volkov <volkov <AT> ekb-info.ru>

 net/wireguard.sh | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/net/wireguard.sh b/net/wireguard.sh
index 301836d..269c8f0 100644
--- a/net/wireguard.sh
+++ b/net/wireguard.sh
@@ -9,9 +9,15 @@ wireguard_depend()
 	before interface
 }
 
+_is_wireguard() {
+	is_interface_type wireguard
+}
+
 wireguard_pre_start()
 {
-	[ "${IFACE#wg}" != "$IFACE" ] || return 0
+	local wireguard=
+	eval wireguard=\$type_${IFVAR}
+	[ "${wireguard}" = "wireguard" -o "${IFACE#wg}" != "$IFACE" ] || return 0
 
 	ip link delete dev "$IFACE" type wireguard 2>/dev/null
 	ebegin "Creating WireGuard interface $IFACE"
@@ -35,6 +41,7 @@ wireguard_pre_start()
 		e=$?
 		if [ $e -eq 0 ]; then
 			eend $e
+			set_interface_type wireguard
 			return $e
 		fi
 	fi
@@ -45,7 +52,7 @@ wireguard_pre_start()
 
 wireguard_post_stop()
 {
-	[ "${IFACE#wg}" != "$IFACE" ] || return 0
+	_is_wireguard || [ "${IFACE#wg}" != "$IFACE" ] || return 0
 
 	ebegin "Removing WireGuard interface $IFACE"
 	ip link delete dev "$IFACE" type wireguard


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2024-05-23 18:12 Patrick McLean
  0 siblings, 0 replies; 109+ messages in thread
From: Patrick McLean @ 2024-05-23 18:12 UTC (permalink / raw
  To: gentoo-commits

commit:     8bb61b90c1d791bafd5cd0b6c54093cccee425f4
Author:     Alexander Zubkov <green <AT> qrator <DOT> net>
AuthorDate: Thu May 23 14:56:42 2024 +0000
Commit:     Patrick McLean <chutzpah <AT> gentoo <DOT> org>
CommitDate: Thu May 23 18:12:13 2024 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=8bb61b90

net/wireguard.sh: make wireguard module to run before interface

Wireguard module was configured to run after interface module, that
caused interface-related settings like mtu not to apply, because
wireguard interfaces was not present by that time. It seems logical
that wireguard module should be run before interface module.

Credits to lmk <lmkrawiec <AT> gmail.com> who proposed the solution and
to Louis Sautier (sbraz) <sbraz <AT> gentoo.org> who proposed the patch.

Closes: https://bugs.gentoo.org/678184
Closes: https://github.com/gentoo/netifrc/pull/54
Signed-off-by: Louis Sautier (sbraz) <sbraz <AT> gentoo.org>
Signed-off-by: Alexander Zubkov <green <AT> qrator.net>
Signed-off-by: Patrick McLean <chutzpah <AT> gentoo.org>

 net/wireguard.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/wireguard.sh b/net/wireguard.sh
index bb71d6f..f6ca69e 100644
--- a/net/wireguard.sh
+++ b/net/wireguard.sh
@@ -6,7 +6,7 @@
 wireguard_depend()
 {
 	program wg
-	after interface
+	before interface
 }
 
 wireguard_pre_start()


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2023-11-26  5:31 Robin H. Johnson
  0 siblings, 0 replies; 109+ messages in thread
From: Robin H. Johnson @ 2023-11-26  5:31 UTC (permalink / raw
  To: gentoo-commits

commit:     8b4f91a94fad6666c957304b0108aa5c895b4d1e
Author:     Matoro Mahri <matoro_gentoo <AT> matoro <DOT> tk>
AuthorDate: Sat Nov 25 18:17:41 2023 +0000
Commit:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
CommitDate: Sun Nov 26 05:30:57 2023 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=8b4f91a9

net/dummy.sh: preload module, create interface conditionally

The dummy module has a numdummies parameter which will cause it to
automatically create N dummy interfaces at load time.  Because creating
a dummy interface causes the kernel to load the module if it is not
already loaded, then if the name of the interface to be created matches
the name of one of the interfaces the kernel creates, an error will be
returned indicating that the interface already exists, despite it not
existing before the command was invoked.

Ensure we load the module before attempting to create any interface,
then only create the interface if it does not already exist, otherwise
simply configure it.

See: https://serverfault.com/q/839430
Signed-off-by: Matoro Mahri <matoro_gentoo <AT> matoro.tk>
Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org>
Closes: https://github.com/gentoo/netifrc/pull/43

 net/dummy.sh | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/net/dummy.sh b/net/dummy.sh
index 091e08c..94437c3 100644
--- a/net/dummy.sh
+++ b/net/dummy.sh
@@ -25,12 +25,18 @@ dummy_pre_start()
 	eval dummy="\$type_${IFVAR}"
 	[ "${dummy}" = "dummy" ] || return 0
 
-	ebegin "Creating dummy interface ${IFACE}"
-	if _ip link add name "${IFACE}" type dummy ; then
-		eend 0 && _up && set_interface_type dummy
-	else
-		eend 1
+	if ! test -d /sys/module/dummy && ! modprobe dummy; then
+		eerror "Couldn't load the dummy module (perhaps the CONFIG_DUMMY kernel option is disabled)"
+		return 1
 	fi
+
+	if ! _exists ; then
+		ebegin "Creating dummy interface ${IFACE}"
+		_ip link add name "${IFACE}" type dummy
+		eend $?
+	fi
+
+	_up && set_interface_type dummy
 }
 
 


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2023-11-25  4:52 Robin H. Johnson
  0 siblings, 0 replies; 109+ messages in thread
From: Robin H. Johnson @ 2023-11-25  4:52 UTC (permalink / raw
  To: gentoo-commits

commit:     acf5e9c1d505e14524dcc78a1433872ae273c491
Author:     Violet Purcell <vimproved <AT> inventati <DOT> org>
AuthorDate: Wed Nov 22 23:35:01 2023 +0000
Commit:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
CommitDate: Sat Nov 25 04:52:47 2023 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=acf5e9c1

iwd: depend on "program /usr/libexec/iwd" instead of "program iwd"

In iwd.sh, the iwd executable used is /usr/libexec/iwd, however in the
dependency block it depends on just "program iwd." Since iwd is not in
PATH, this will fail and cause iwd to not be started when it should be.
Correct this to /usr/libexec/iwd.

Signed-off-by: Violet Purcell <vimproved <AT> inventati.org>
Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org>
Closes: https://github.com/gentoo/netifrc/pull/49

 net/iwd.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/iwd.sh b/net/iwd.sh
index d8be2d5..75edb8c 100644
--- a/net/iwd.sh
+++ b/net/iwd.sh
@@ -7,7 +7,7 @@ iwd_depend()
 	before interface
 	provide wireless
 	after iwconfig
-	program iwd
+	program /usr/libexec/iwd
 }
 
 _config_vars="$_config_vars iwd"


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2023-10-19 22:57 Sam James
  0 siblings, 0 replies; 109+ messages in thread
From: Sam James @ 2023-10-19 22:57 UTC (permalink / raw
  To: gentoo-commits

commit:     bf02831a7a59f5552c916dde7dd47296a7bce0b1
Author:     kmartin36 <Kevin.Martin <AT> gtri <DOT> gatech <DOT> edu>
AuthorDate: Fri Sep 15 01:29:27 2023 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Thu Oct 19 22:57:19 2023 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=bf02831a

dhcpcd: Fixing the handling of dhcpcd arguments with spaces

Bug: https://bugs.gentoo.org/881039
Signed-off-by: Kevin Martin <kevinmbecause <AT> gmail.com>
Fixes: bd8ff4aa89e1d56e9886dad32bb2406c8f43c747
Closes: https://github.com/gentoo/netifrc/pull/48
Signed-off-by: Sam James <sam <AT> gentoo.org>

 net/dhcpcd.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/dhcpcd.sh b/net/dhcpcd.sh
index 6bd44ba..2493f27 100644
--- a/net/dhcpcd.sh
+++ b/net/dhcpcd.sh
@@ -90,8 +90,8 @@ dhcpcd_stop()
 	eval opts=\$dhcp_${IFVAR}
 	[ -z "${opts}" ] && opts=${dhcp}
 	case " ${opts} " in
-		*" release "*) dhcpcd -k "${args}" "${IFACE}" ;;
-		*) dhcpcd -x "${args}" "${IFACE}" ;;
+		*" release "*) dhcpcd -k ${args} "${IFACE}" ;;
+		*) dhcpcd -x ${args} "${IFACE}" ;;
 	esac
 	[ -f "${argsfile}" ] && rm -f "${argsfile}"
 	eend $?


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2023-09-10 15:15 Sam James
  0 siblings, 0 replies; 109+ messages in thread
From: Sam James @ 2023-09-10 15:15 UTC (permalink / raw
  To: gentoo-commits

commit:     a509a86bbfe77db20d676caa5f3c421d5a781780
Author:     Mike Gilbert <floppym <AT> gentoo <DOT> org>
AuthorDate: Thu Jun  1 19:21:23 2023 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sun Sep 10 15:15:45 2023 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=a509a86b

net/bonding.sh: fix spelling of "lose"

Signed-off-by: Mike Gilbert <floppym <AT> gentoo.org>
Closes: https://github.com/gentoo/netifrc/pull/47
Signed-off-by: Sam James <sam <AT> gentoo.org>

 net/bonding.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/bonding.sh b/net/bonding.sh
index d8f48d8..e3fcaa7 100644
--- a/net/bonding.sh
+++ b/net/bonding.sh
@@ -8,7 +8,7 @@ bonding_depend()
 	before interface macchanger
 	program ip ifconfig
 	# If you do not have sysfs, you MUST have this binary instead for ioctl
-	# Also you will loose some functionality that cannot be done via sysfs:
+	# Also you will lose some functionality that cannot be done via sysfs:
 	if [ ! -d /sys/class/net ]; then
 		program ifenslave
 	fi


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2023-05-29  0:17 Mike Gilbert
  0 siblings, 0 replies; 109+ messages in thread
From: Mike Gilbert @ 2023-05-29  0:17 UTC (permalink / raw
  To: gentoo-commits

commit:     0ac293faa15b49f08830120e7b5fa1e4523f19e5
Author:     Mike Gilbert <floppym <AT> gentoo <DOT> org>
AuthorDate: Sun May 28 20:07:47 2023 +0000
Commit:     Mike Gilbert <floppym <AT> gentoo <DOT> org>
CommitDate: Sun May 28 22:49:02 2023 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=0ac293fa

Update pidfile path for ppp-2.5.0

Bug: https://bugs.gentoo.org/907311
Signed-off-by: Mike Gilbert <floppym <AT> gentoo.org>

 net/pppd.sh | 38 ++++++++++++++++++++++++++++++--------
 1 file changed, 30 insertions(+), 8 deletions(-)

diff --git a/net/pppd.sh b/net/pppd.sh
index 22644f2..1b14fed 100644
--- a/net/pppd.sh
+++ b/net/pppd.sh
@@ -1,4 +1,4 @@
-# Copyright (c) 2005-2007 Gentoo Foundation
+# Copyright (c) 2005-2023 Gentoo Authors
 # Copyright (c) 2007-2008 Roy Marples <roy@marples.name>
 # Released under the 2-clause BSD license.
 # shellcheck shell=sh disable=SC1008
@@ -21,12 +21,28 @@ requote()
 	printf "'%s' " "$@"
 }
 
+pppd_version_int() {
+	# 002004008 is v2.4.8
+	printf '%03d' $(/usr/sbin/pppd --version | awk '/pppd version/ {print $3}' | tr '.' ' ')
+}
+
 pppd_is_ge_248()
 {
-	local ver_str="$(/usr/sbin/pppd --version 2>&1 | awk '/pppd version/ {print $3}' | tr '.' ' ')"
+	[ $(pppd_version_int) -ge 002004008 ]
+}
 
-	# 002004008 is v2.4.8
-	[ "$(printf '%03d' ${ver_str})" -ge 002004008 ]
+pppd_is_ge_250()
+{
+	[ $(pppd_version_int) -ge 002005000 ]
+}
+
+pppd_pidfile()
+{
+	if pppd_is_ge_250; then
+		echo "/run/pppd/ppp-${IFACE}.pid"
+	else
+		echo "/run/ppp-${IFACE}.pid"
+	fi
 }
 
 pppd_pre_start()
@@ -207,16 +223,18 @@ pppd_pre_start()
 	fi
 	[ "${insert_link_in_opts}" = "0" ] || opts="${link} ${opts}"
 
+	local pidfile="$(pppd_pidfile)"
+
 	ebegin "Starting pppd in ${IFACE}"
 	mark_service_inactive
 	if [ -n "${username}" ] \
 	&& [ -n "${password}" -o -z "${passwordset}" ]; then
 		printf "%s" "${password}" | \
 		eval start-stop-daemon --start --exec /usr/sbin/pppd \
-			--pidfile "/run/ppp-${IFACE}.pid" -- "${opts}" >/dev/null
+			--pidfile "${pidfile}" -- "${opts}" >/dev/null
 	else
 		eval start-stop-daemon --start --exec /usr/sbin/pppd \
-			--pidfile "/run/ppp-${IFACE}.pid" -- "${opts}" >/dev/null
+			--pidfile "${pidfile}" -- "${opts}" >/dev/null
 	fi
 
 	if ! eend $? "Failed to start PPP"; then
@@ -243,9 +261,13 @@ pppd_start()
 pppd_stop()
 {
 	yesno ${IN_BACKGROUND} && return 0
-	local pidfile="/run/ppp-${IFACE}.pid"
 
-	[ ! -s "${pidfile}" ] && return 0
+	local pidfile="$(pppd_pidfile)"
+	if [ ! -s "${pidfile}" ]; then
+		# Try the old path.
+		pidfile="/run/ppp-${IFACE}.pid"
+		[ -s "${pidfile}" ] || return 0
+	fi
 
 	# Give pppd at least 30 seconds do die, #147490
 	einfo "Stopping pppd on ${IFACE}"


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2023-04-19 17:14 Robin H. Johnson
  0 siblings, 0 replies; 109+ messages in thread
From: Robin H. Johnson @ 2023-04-19 17:14 UTC (permalink / raw
  To: gentoo-commits

commit:     baff1e37615921b37cfa166215d3d1c6531a81af
Author:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
AuthorDate: Wed Apr 19 17:11:32 2023 +0000
Commit:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
CommitDate: Wed Apr 19 17:14:32 2023 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=baff1e37

net/Makefile: include iwd

Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org>

 net/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/Makefile b/net/Makefile
index ee48294..58483cd 100644
--- a/net/Makefile
+++ b/net/Makefile
@@ -14,7 +14,7 @@ INC-Linux=	adsl.sh apipa.sh arping.sh bonding.sh br2684ctl.sh bridge.sh \
 		ccwgroup.sh clip.sh ethtool.sh iproute2.sh ifplugd.sh ip6to4.sh \
 		ipppd.sh iwconfig.sh netplugd.sh pppd.sh pump.sh tuntap.sh udhcpc.sh \
 		vlan.sh macvlan.sh ip6rd.sh firewalld.sh dummy.sh hsr.sh l2tp.sh \
-		iw.sh wireguard.sh veth.sh dhclientv6.sh
+		iw.sh iwd.sh wireguard.sh veth.sh dhclientv6.sh
 
 SRCS-NetBSD= ifwatchd.sh.in
 INC-NetBSD=	ifwatchd.sh


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2023-04-17  4:35 Sam James
  0 siblings, 0 replies; 109+ messages in thread
From: Sam James @ 2023-04-17  4:35 UTC (permalink / raw
  To: gentoo-commits

commit:     a43884bca4b34b8649574fb3ea85a2a658fd0a6f
Author:     Greg Kubaryk <kurly <AT> vt <DOT> edu>
AuthorDate: Mon Apr 17 04:34:36 2023 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Mon Apr 17 04:35:08 2023 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=a43884bc

net/dhcpcd.sh: adapt to dhcpcd-10 versioning

Closes: https://bugs.gentoo.org/904422
Signed-off-by: Greg Kubaryk <kurly <AT> vt.edu>
Signed-off-by: Sam James <sam <AT> gentoo.org>

 net/dhcpcd.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/dhcpcd.sh b/net/dhcpcd.sh
index 1380944..6bd44ba 100644
--- a/net/dhcpcd.sh
+++ b/net/dhcpcd.sh
@@ -32,7 +32,7 @@ dhcpcd_start()
 	[ -z "${opts}" ] && opts=${dhcp}
 
 	case "$(dhcpcd --version | head -n 1)" in
-		"dhcpcd "[123]*)
+		"dhcpcd "[123]\.*)
 			eerror 'The dhcpcd version is too old. Please upgrade.'
 			return 1
 			;;


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2023-02-12  6:54 Sam James
  0 siblings, 0 replies; 109+ messages in thread
From: Sam James @ 2023-02-12  6:54 UTC (permalink / raw
  To: gentoo-commits

commit:     8390af35cb89002b33acea91d2b2b641f0728398
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Sun Feb 12 06:54:09 2023 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sun Feb 12 06:54:15 2023 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=8390af35

net/arping.sh: adapt to new arping path in /usr/bin

Bug: https://bugs.gentoo.org/893290
Signed-off-by: Sam James <sam <AT> gentoo.org>

 net/arping.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/arping.sh b/net/arping.sh
index 7e178b7..bdd8284 100644
--- a/net/arping.sh
+++ b/net/arping.sh
@@ -4,7 +4,7 @@
 
 arping_depend()
 {
-	program /sbin/arping /bin/arping /usr/sbin/arping /usr/sbin/arping2
+	program /sbin/arping /bin/arping /usr/bin/arping /usr/sbin/arping /usr/sbin/arping2
 	before interface
 }
 


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2023-01-19 18:50 Sam James
  0 siblings, 0 replies; 109+ messages in thread
From: Sam James @ 2023-01-19 18:50 UTC (permalink / raw
  To: gentoo-commits

commit:     e6db37173cb70183ee983aa1aaa5224a2f8c49c3
Author:     Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Thu Jan 19 04:47:54 2023 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Thu Jan 19 18:49:22 2023 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=e6db3717

net/l2tp.sh: Don't try to evaluate l2tptunnel_${IFVAR} if unset

The "restructuring" commit went one step too far by combining the test for
whether l2tptunnel_${IFVAR} is defined with the test for whether the tunnel
exists, in a way that adversely affects the outer control flow. Fix it by
nesting the latter test.

Fixes: 0b8b9b13146c1eba04f2bd8d0b2b049c03891010
Signed-off-by: Kerin Millar <kfm <AT> plushkava.net>
Signed-off-by: Sam James <sam <AT> gentoo.org>

 net/l2tp.sh | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/net/l2tp.sh b/net/l2tp.sh
index aa8e3fd..dde86af 100644
--- a/net/l2tp.sh
+++ b/net/l2tp.sh
@@ -28,12 +28,14 @@ l2tp_pre_start() {
 		eend 1 "${key} defines a \"name\" parameter, which is forbidden by netifrc"
 	elif ! modprobe l2tp_eth; then
 		eend 1 "Couldn't load the l2tp_eth module (perhaps the CONFIG_L2TP_ETH kernel option is disabled)"
-	elif key="l2tptunnel_${IFVAR}"; ! eval "[ \${${key}+set} ]" && ! _l2tp_has_tunnel "${tunnel_id}"; then
+	elif key="l2tptunnel_${IFVAR}"; ! eval "[ \${${key}+set} ]"; then
 		# A tunnel may incorporate more than one session (link). This
 		# module allows for the user not to define a tunnel for a given
 		# session. In that case, it will be expected that the required
 		# tunnel has already been created to satisfy some other session.
-		eend 1 "Tunnel #${tunnel_id} not found (defining ${key} may be required)"
+		if ! _l2tp_has_tunnel "${tunnel_id}"; then
+			eend 1 "Tunnel #${tunnel_id} not found (defining ${key} may be required)"
+		fi
 	elif eval "l2tptunnel=\$${key}"; _is_blank "${l2tptunnel}"; then
 		eend 1 "${key} is defined but its value is blank"
 	elif ! declared_tunnel=$(_l2tp_parse_opts "${l2tptunnel}" "local peer_tunnel_id remote tunnel_id" "encap"); then


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2023-01-19 18:50 Sam James
  0 siblings, 0 replies; 109+ messages in thread
From: Sam James @ 2023-01-19 18:50 UTC (permalink / raw
  To: gentoo-commits

commit:     46f8a90fef9d9bff21760dab52124bfbbb62e064
Author:     Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Sat Jul 17 09:53:36 2021 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Thu Jan 19 18:49:25 2023 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=46f8a90f

net/iproute2.sh: Fix two regressions in _get_mac_address

Commit 4143e26 re-introduced the ip(8) parser in the course of adding
network namespace support. In doing so, it also introduced two
regressions. Firstly, in the case that no MAC address is successfully
discerned, the function will return 0. Secondly, FF:FF:FF:FF:FF:FF is
no longer handled as a special case.

This patch, once again, does away with the ip(8) parser and, instead,
collects the address from sysfs. The _netns function is used to ensure
that the procedure is carried out within the applicable network
namespace, if necessary. In the event that the address file cannot be
read, or that it contains nothing, the function will now return 1,
which addresses the first issue. The second issue is addressed by
uppercasing the applicable case pattern.

As an aside, this patch also addresses an issue whereby sed(1) was used
to match against a pattern containing \< and \>, which are GNU-specific
extensions.

Fixes: 4143e26dd4a56c08fbb99e18913eaafaf2a04f32
Signed-off-by: Kerin Millar <kfm <AT> plushkava.net>
Signed-off-by: Sam James <sam <AT> gentoo.org>

 net/iproute2.sh | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/net/iproute2.sh b/net/iproute2.sh
index bd7333e..ea0a6f7 100644
--- a/net/iproute2.sh
+++ b/net/iproute2.sh
@@ -91,17 +91,15 @@ _set_flag()
 _get_mac_address()
 {
 	local mac=
-	mac=$(LC_ALL=C _ip link show "${IFACE}" | sed -n \
-		-e 'y/abcdef/ABCDEF/' \
-		-e '/link\// s/^.*\<\(..:..:..:..:..:..\)\>.*/\1/p' | head -n1)
+	mac=$(_netns sed -e 'y/abcdef/ABCDEF/;q' /sys/class/net/"${IFACE}"/address) || return
 
 	case "${mac}" in
-		00:00:00:00:00:00) return 1 ;;
-		44:44:44:44:44:44) return 1 ;;
-		ff:ff:ff:ff:ff:ff) return 1 ;;
-	esac
-
-	printf '%s\n' "${mac}" | LC_ALL=C tr '[:lower:]' '[:upper:]'
+		'')                false ;;
+		00:00:00:00:00:00) false ;;
+		44:44:44:44:44:44) false ;;
+		FF:FF:FF:FF:FF:FF) false ;;
+	esac &&
+	printf '%s\n' "${mac}"
 }
 
 _set_mac_address()


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2023-01-17 15:06 Sam James
  0 siblings, 0 replies; 109+ messages in thread
From: Sam James @ 2023-01-17 15:06 UTC (permalink / raw
  To: gentoo-commits

commit:     9f752fd223ce8a2539874631008d9eda83aa5ba0
Author:     Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Tue Jan 17 09:25:58 2023 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Tue Jan 17 15:06:28 2023 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=9f752fd2

net/wpa_supplicant.sh: Properly expand the number of positional parameters

${#*} is undefined behaviour. Just write it as $#.

Signed-off-by: Kerin Millar <kfm <AT> plushkava.net>
Signed-off-by: Sam James <sam <AT> gentoo.org>

 net/wpa_supplicant.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/wpa_supplicant.sh b/net/wpa_supplicant.sh
index 3f8e1b1..9f024c0 100644
--- a/net/wpa_supplicant.sh
+++ b/net/wpa_supplicant.sh
@@ -57,7 +57,7 @@ wpa_supplicant_pre_start()
 	[ -z "${cliopts}" ] && cliopts=${wpa_cli}
 	set -- $opts
 	local opt_D
-	while [ ${#*} -gt 0 ]; do
+	while [ "$#" -gt 0 ]; do
 		local opt=$1 ; shift
 		case "$opt" in
 			-D) opt_D=${1} ; shift ;;


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2023-01-17 15:06 Sam James
  0 siblings, 0 replies; 109+ messages in thread
From: Sam James @ 2023-01-17 15:06 UTC (permalink / raw
  To: gentoo-commits

commit:     e5a46f30deedabef5c18a587db2984a314f61071
Author:     Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Tue Jan 17 09:11:22 2023 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Tue Jan 17 15:05:51 2023 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=e5a46f30

net/bonding.sh: Eliminate the bashism that is pattern substitution

Signed-off-by: Kerin Millar <kfm <AT> plushkava.net>
Signed-off-by: Sam James <sam <AT> gentoo.org>

 net/bonding.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/bonding.sh b/net/bonding.sh
index 1757a89..6db90fa 100644
--- a/net/bonding.sh
+++ b/net/bonding.sh
@@ -92,7 +92,7 @@ bonding_pre_start()
 		if [ -n "${s}" ]; then
 			for i in $s; do
 				einfo "Adding ${n}: ${i}"
-				_netns echo "+${i/+/}" \>"${x}" || \
+				_netns echo "+${i#+}" \>"${x}" || \
 				eerror "Failed to add $i (${n}_${IFVAR})"
 			done
 		fi


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2023-01-17 15:06 Sam James
  0 siblings, 0 replies; 109+ messages in thread
From: Sam James @ 2023-01-17 15:06 UTC (permalink / raw
  To: gentoo-commits

commit:     f9c4602fec8b4a5bb6561dbf8bbeeff8447165bc
Author:     Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Tue Jan 17 09:14:37 2023 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Tue Jan 17 15:06:12 2023 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=f9c4602f

net/veth.sh: Eliminate the bashism that is the == test operator

Signed-off-by: Kerin Millar <kfm <AT> plushkava.net>
Signed-off-by: Sam James <sam <AT> gentoo.org>

 net/veth.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/veth.sh b/net/veth.sh
index 80f9a8e..e18906c 100644
--- a/net/veth.sh
+++ b/net/veth.sh
@@ -132,7 +132,7 @@ veth_pre_start()
 
 	local createveth
 	eval createveth=\$veth_${IFVAR}_create
-	if [ "$createveth" == "no" ]; then
+	if [ "$createveth" = "no" ]; then
 		return 0
 	fi
 


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2023-01-15 20:37 Sam James
  0 siblings, 0 replies; 109+ messages in thread
From: Sam James @ 2023-01-15 20:37 UTC (permalink / raw
  To: gentoo-commits

commit:     315341e5af9dad09ca4e5c1ff8b16e3c0fc72898
Author:     Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Sun Jan 15 19:30:35 2023 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sun Jan 15 20:36:57 2023 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=315341e5

net/l2tp.sh: Really favour IFACE over IFVAR in an informational message

The previous commit intended to replace an instance of IFVAR with IFACE.
Instead, it replaced with IFNAME, which means nothing to netifrc.
Frustratingly, I had realised my error at the time of submitting the patch,
yet still managed to attach a bad one. Make it right.

Signed-off-by: Kerin Millar <kfm <AT> plushkava.net>
Signed-off-by: Sam James <sam <AT> gentoo.org>

 net/l2tp.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/l2tp.sh b/net/l2tp.sh
index 2221d26..aa8e3fd 100644
--- a/net/l2tp.sh
+++ b/net/l2tp.sh
@@ -39,7 +39,7 @@ l2tp_pre_start() {
 	elif ! declared_tunnel=$(_l2tp_parse_opts "${l2tptunnel}" "local peer_tunnel_id remote tunnel_id" "encap"); then
 		eend 1 "${key} is missing at least one required parameter"
 	elif set -- "${tunnel_id}"; eval "${declared_tunnel}"; [ "$1" != "${tunnel_id}" ]; then
-		eend 1 "${key} defines a \"tunnel_id\" parameter that contradicts l2tpsession_${IFNAME}"
+		eend 1 "${key} defines a \"tunnel_id\" parameter that contradicts l2tpsession_${IFACE:?}"
 	elif _l2tp_should_add_tunnel "${tunnel_id}" "${declared_tunnel}"; set -- $?; [ "$1" -eq 2 ]; then
 		eend 1 "Tunnel #${tunnel_id} exists but its properties mismatch those defined by ${key}"
 	elif [ "$1" -eq 1 ]; then


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2023-01-15 14:03 Sam James
  0 siblings, 0 replies; 109+ messages in thread
From: Sam James @ 2023-01-15 14:03 UTC (permalink / raw
  To: gentoo-commits

commit:     735b7e1b920874fe2f588f5b9385ff40d33c48c2
Author:     Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Sun Jan 15 06:09:40 2023 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sun Jan 15 14:03:29 2023 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=735b7e1b

net/l2tp.sh: Favour IFACE over IFVAR in an informational message

IFVAR is (supposed to be) requoted for injection, so it doesn't make any sense
to expand it within the second argument given to eend.

Signed-off-by: Kerin Millar <kfm <AT> plushkava.net>
Signed-off-by: Sam James <sam <AT> gentoo.org>

 net/l2tp.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/l2tp.sh b/net/l2tp.sh
index ad459df..2221d26 100644
--- a/net/l2tp.sh
+++ b/net/l2tp.sh
@@ -39,7 +39,7 @@ l2tp_pre_start() {
 	elif ! declared_tunnel=$(_l2tp_parse_opts "${l2tptunnel}" "local peer_tunnel_id remote tunnel_id" "encap"); then
 		eend 1 "${key} is missing at least one required parameter"
 	elif set -- "${tunnel_id}"; eval "${declared_tunnel}"; [ "$1" != "${tunnel_id}" ]; then
-		eend 1 "${key} defines a \"tunnel_id\" parameter that contradicts l2tpsession_${IFVAR}"
+		eend 1 "${key} defines a \"tunnel_id\" parameter that contradicts l2tpsession_${IFNAME}"
 	elif _l2tp_should_add_tunnel "${tunnel_id}" "${declared_tunnel}"; set -- $?; [ "$1" -eq 2 ]; then
 		eend 1 "Tunnel #${tunnel_id} exists but its properties mismatch those defined by ${key}"
 	elif [ "$1" -eq 1 ]; then


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2023-01-15 14:03 Sam James
  0 siblings, 0 replies; 109+ messages in thread
From: Sam James @ 2023-01-15 14:03 UTC (permalink / raw
  To: gentoo-commits

commit:     0b8b9b13146c1eba04f2bd8d0b2b049c03891010
Author:     Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Sun Jan 15 05:41:10 2023 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sun Jan 15 14:03:10 2023 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=0b8b9b13

net/l2tp.sh: Slightly improve the structure of l2tp_pre_start()

Restructure so as to avoid an unnecessary level of indentation. The behaviour
of the function remains the same.

Signed-off-by: Kerin Millar <kfm <AT> plushkava.net>
Signed-off-by: Sam James <sam <AT> gentoo.org>

 net/l2tp.sh | 40 +++++++++++++++++++---------------------
 1 file changed, 19 insertions(+), 21 deletions(-)

diff --git a/net/l2tp.sh b/net/l2tp.sh
index 52b5733..ad459df 100644
--- a/net/l2tp.sh
+++ b/net/l2tp.sh
@@ -28,32 +28,30 @@ l2tp_pre_start() {
 		eend 1 "${key} defines a \"name\" parameter, which is forbidden by netifrc"
 	elif ! modprobe l2tp_eth; then
 		eend 1 "Couldn't load the l2tp_eth module (perhaps the CONFIG_L2TP_ETH kernel option is disabled)"
-	elif key="l2tptunnel_${IFVAR}"; eval "[ \${${key}+set} ]"; then
-		if eval "l2tptunnel=\$${key}"; _is_blank "${l2tptunnel}"; then
-			eend 1 "${key} is defined but its value is blank"
-		elif ! declared_tunnel=$(_l2tp_parse_opts "${l2tptunnel}" "local peer_tunnel_id remote tunnel_id" "encap"); then
-			eend 1 "${key} is missing at least one required parameter"
-		elif set -- "${tunnel_id}"; eval "${declared_tunnel}"; [ "$1" != "${tunnel_id}" ]; then
-			eend 1 "${key} defines a \"tunnel_id\" parameter that contradicts l2tpsession_${IFVAR}"
-		elif _l2tp_should_add_tunnel "${tunnel_id}" "${declared_tunnel}"; set -- $?; [ "$1" -eq 2 ]; then
-			eend 1 "Tunnel #${tunnel_id} exists but its properties mismatch those defined by ${key}"
-		elif [ "$1" -eq 1 ]; then
-			# The config matches an existing tunnel.
-			true
-		elif [ "${encap}" = ip ] && ! modprobe l2tp_ip; then
-			eend 1 "Couldn't load the l2tp_ip module (perhaps the CONFIG_L2TP_IP kernel option is disabled)"
-		else
-			ebegin "Creating L2TPv3 tunnel (tunnel_id ${tunnel_id})"
-			printf %s "l2tp add tunnel ${l2tptunnel}" \
-			| xargs -E '' ip
-			eend $?
-		fi
-	elif ! _l2tp_has_tunnel "${tunnel_id}"; then
+	elif key="l2tptunnel_${IFVAR}"; ! eval "[ \${${key}+set} ]" && ! _l2tp_has_tunnel "${tunnel_id}"; then
 		# A tunnel may incorporate more than one session (link). This
 		# module allows for the user not to define a tunnel for a given
 		# session. In that case, it will be expected that the required
 		# tunnel has already been created to satisfy some other session.
 		eend 1 "Tunnel #${tunnel_id} not found (defining ${key} may be required)"
+	elif eval "l2tptunnel=\$${key}"; _is_blank "${l2tptunnel}"; then
+		eend 1 "${key} is defined but its value is blank"
+	elif ! declared_tunnel=$(_l2tp_parse_opts "${l2tptunnel}" "local peer_tunnel_id remote tunnel_id" "encap"); then
+		eend 1 "${key} is missing at least one required parameter"
+	elif set -- "${tunnel_id}"; eval "${declared_tunnel}"; [ "$1" != "${tunnel_id}" ]; then
+		eend 1 "${key} defines a \"tunnel_id\" parameter that contradicts l2tpsession_${IFVAR}"
+	elif _l2tp_should_add_tunnel "${tunnel_id}" "${declared_tunnel}"; set -- $?; [ "$1" -eq 2 ]; then
+		eend 1 "Tunnel #${tunnel_id} exists but its properties mismatch those defined by ${key}"
+	elif [ "$1" -eq 1 ]; then
+		# The config matches an existing tunnel.
+		true
+	elif [ "${encap}" = ip ] && ! modprobe l2tp_ip; then
+		eend 1 "Couldn't load the l2tp_ip module (perhaps the CONFIG_L2TP_IP kernel option is disabled)"
+	else
+		ebegin "Creating L2TPv3 tunnel (tunnel_id ${tunnel_id})"
+		printf %s "l2tp add tunnel ${l2tptunnel}" \
+		| xargs -E '' ip
+		eend $?
 	fi || return
 
 	ebegin "Creating L2TPv3 session (session_id ${session_id} tunnel_id ${tunnel_id})"


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2023-01-15  1:53 Sam James
  0 siblings, 0 replies; 109+ messages in thread
From: Sam James @ 2023-01-15  1:53 UTC (permalink / raw
  To: gentoo-commits

commit:     bd50c2ce076f2a6a5b0f884287a7940cd29cc6db
Author:     7e3f <122086774+7e3f <AT> users <DOT> noreply <DOT> github <DOT> com>
AuthorDate: Fri Jan  6 10:20:09 2023 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sun Jan 15 01:52:46 2023 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=bd50c2ce

net/macchanger.sh: Update path to macchanger to /usr

Proposing changes in diff from bug #889922, net-analyzer/macchanger-1.7.0_p5_p4
to net-analyzer/macchanger-1.7.0_p5_p4-r1 changed softlink and binary location due
to #886121.

There was a temporary tidy up in net-analyzer/macchanger-1.7.0_p5_p4-r2, but
proposing macchanger.sh change to allow netifrc to work with macchanger
binary location.

Bug: https://bugs.gentoo.org/886121
Bug: https://bugs.gentoo.org/889922
Closes: https://github.com/gentoo/netifrc/pull/42
Signed-off-by: Sam James <sam <AT> gentoo.org>

 net/macchanger.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/macchanger.sh b/net/macchanger.sh
index d87d96e..5b32b80 100644
--- a/net/macchanger.sh
+++ b/net/macchanger.sh
@@ -64,7 +64,7 @@ macchanger_pre_start()
 		*) opts="${opts} -m ${mac}";;
 	esac
 
-	if [ ! -x /sbin/macchanger ]; then
+	if [ ! -x /usr/bin/macchanger ]; then
 		eerror "For changing MAC addresses, emerge net-analyzer/macchanger"
 		return 1
 	fi
@@ -72,7 +72,7 @@ macchanger_pre_start()
 	for try in 1 2; do
 		# Sometimes the interface needs to be up
 		[ "${try}" -eq 2 ] && _up
-		output=$(/sbin/macchanger ${opts} "${IFACE}")
+		output=$(/usr/bin/macchanger ${opts} "${IFACE}")
 		rc=$?
 		[ "${rc}" -eq 0 ] && break
 	done


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2023-01-15  1:51 Sam James
  0 siblings, 0 replies; 109+ messages in thread
From: Sam James @ 2023-01-15  1:51 UTC (permalink / raw
  To: gentoo-commits

commit:     1601d0dbed5d0373f0e19f90f07612bf60c59184
Author:     Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Sat Jan 14 22:58:41 2023 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sun Jan 15 01:51:20 2023 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=1601d0db

net/l2tp.sh: Rewrite to address issues of POSIX conformance (and more besides)

Ensure that awk(1) is used portably throughout.

Eliminate the use of ${parameter^^} expansion syntax, which is a bashism.

Delegate netfirc parameter parsing to xargs(1) and awk(1). The potential for
code injection is thus eliminated, to the extent that is currently possible in
netifrc. It also eliminates potential issues pertaining to word splitting and
unintentional pathname expansion.

Add additional sanity checks and increase the rigour of those that exist. For
instance, blank values are no longer permitted and the tunnel_id parameter must
match that of l2tpsession_*, in the case that l2tptunnel_* is defined.

Add additional diagnostic messages while improving the clarity of those that
already existed. This is achieved in some instances by being more precise and,
in others, through the use of English that exhibits greater formality and
consistency. At least one grammatical error was rectified.

Simplify and refine the code in terms of both structure and syntax, and greatly
reduce the number of (local) variables. As a byproduct, all complaints previously
raised by shellcheck have been eliminated, save for the use of local, whose
behaviour is not defined by POSIX. I have not attempted to eliminate the use of
local because, for now, it continues to be used extensively throughout the
netifrc codebase.

Honour the exit status value of ip(8) for the "add" and "del" verbs, rather
than parse STDERR.

Optimise l2tp_post_stop() by refraining from executing ip(8) and awk(8) in the
case that the interface cannot be identifed as a virtual one. Further, do not
attempt to destroy the tunnels associated with an identified session in the
case that the attempt to destroy the session has failed.

Signed-off-by: Kerin Millar <kfm <AT> plushkava.net>
Bug: https://bugs.gentoo.org/890238
Signed-off-by: Sam James <sam <AT> gentoo.org>

 net/l2tp.sh | 349 +++++++++++++++++++++++++++++++++++-------------------------
 1 file changed, 206 insertions(+), 143 deletions(-)

diff --git a/net/l2tp.sh b/net/l2tp.sh
index 82649b9..51a2331 100644
--- a/net/l2tp.sh
+++ b/net/l2tp.sh
@@ -1,6 +1,11 @@
 # Copyright (c) 2016 Emeric Verschuur <emeric@mbedsys.org>
+# Copyright (c) 2023 Kerin Millar <kfm@plushkava.net>
 # All rights reserved. Released under the 2-clause BSD license.
-# shellcheck shell=sh disable=SC1008
+
+# Don't complain about local, even though POSIX does not define its behaviour.
+# This is unwise but, as things stand, it is being used extensively by netifrc.
+# Also, SC2034 and SC2316 are muted because they produce false-positives.
+# shellcheck shell=sh disable=SC3043,SC2034,SC2316
 
 l2tp_depend()
 {
@@ -8,166 +13,224 @@ l2tp_depend()
 	before bridge interface macchanger
 }
 
-# Extract parameter list to shell vars
-#   1. variable prefix
-#   2. string to parse
-_l2tp_eval_props() {
-	local prop_pref=$1
-	local prop_list=$2
-	eval set -- "$3"
-	while [ -n "$1" ]; do
-		eval "case $1 in
-			$prop_list)
-				$prop_pref$1=\"$2\"
-				shift
-				shift
-				;;
-			*)
-				l2tp_err=\"invalid property $1\"
-				return 1
-				;;
-			
-		esac" || return 1
-	done
-	return 0
+_l2tp_parse_opts()
+{
+	# Parses lt2psession or l2tptunnel options using xargs(1), conveying
+	# them as arguments to awk(1). The awk program interprets the arguments
+	# as a series of key/value pairs and safely prints those specified as
+	# being required as variable declarations for evaluation by sh(1).
+	# Other keys are handled similarly, only in a way that renders them a
+	# no-op. For the program to exit successfully, all key names must be
+	# well-formed, all required keys must be seen, and all values must be
+	# non-blank. Note that assigning 1 to ARGC prevents awk from treating
+	# its arguments as the names of files to be opened.
+	printf %s "$1" \
+	| LC_CTYPE=C xargs -E '' awk -v q="'" -v required_keys="$2" -v other_keys="$3" '
+		function shquote(str) {
+			gsub(q, q "\\" q q, str)
+			return q str q
+		}
+		BEGIN {
+			argc = ARGC
+			ARGC = 1
+			gsub(" ", "|", required_keys)
+			gsub(" ", "|", other_keys)
+			re = "^(" required_keys "|" other_keys ")$"
+			sorter = "sort"
+			for (i = 1; i < argc; i += 2) {
+				key = ARGV[i]
+				val = ARGV[i + 1]
+				if (key !~ /^[[:alpha:]][_[:alnum:]]+$/) {
+					system("ewarn " shquote("Skipping malformed parameter: " key))
+				} else if (key ~ re) {
+					print key "=" shquote(val) | sorter
+					val_by[key] = val
+				} else {
+					print ": " key "=" shquote(val) | sorter
+				}
+			}
+			close(sorter)
+			split(required_keys, keys, "|")
+			missing = 0
+			for (i in keys) {
+				key = keys[i]
+				if (! (key in val_by)) {
+					system("eerror " shquote("The \"" key "\" parameter is missing"))
+					missing += 1
+				} else if (val_by[key] ~ /^[[:blank:]]*$/) {
+					system("eerror " shquote("The \"" key "\" parameter has a blank value"))
+					missing += 1
+				}
+			}
+			exit(!!missing)
+		}
+	'
 }
 
-_is_l2tp() {
-	# Check for L2TP support in kernel
-	ip l2tp show session 2>/dev/null 1>/dev/null || return 1
-
-	eval "$(ip l2tp show session | \
-		awk "match(\$0, /^Session ([0-9]+) in tunnel ([0-9]+)\$/, ret) {sid=ret[1]; tid=ret[2]} 
-		match(\$0, /^[ ]*interface name: ${IFACE}\$/) {print \"session_id=\"sid\";tunnel_id=\"tid; exit}")"
-	test -n "$session_id"
+_l2tp_parse_existing_session() {
+	ip l2tp show session \
+	| LC_CTYPE=C awk -v iface="${IFACE:?}" '
+		BEGIN { found = 0 }
+		/^Session [0-9]+ in tunnel [0-9]+$/ {
+			session_id = $2
+			tunnel_id = $5
+		}
+		/^[[:blank:]]*interface name:/ && "" $NF == "" iface {
+			print "session_id=" session_id
+			print "tunnel_id=" tunnel_id
+			found = 1
+			exit
+		}
+		END { exit(!found) }
+	'
 }
 
-# Get tunnel info
-#    1. Output variable prefix
-#    2. Tunnel ID to find
-_l2tp_get_tunnel_info() {
-	local found
-	eval "$(ip l2tp show tunnel | \
-		awk -v id=$2 -v prefix=$1 '
-		match($0, /^Tunnel ([0-9]+), encap (IP|UDP)$/, ret) {
-			if (found == "1") exit;
-			if (ret[1] == id) {
-				print "found=1;"
-				print prefix "tunnel_id=" ret[1] ";"
-				print prefix "encap=" ret[2] ";";
-				found="1"
-			}
-		} 
-		match($0, /^[ ]*From ([^ ]+) to ([^ ]+)$/, ret) {
-			if (found == "1") {
-				print prefix "local=" ret[1] ";"; 
-				print prefix "remote=" ret[2] ";"; 
-			}
+
+_l2tp_parse_existing_tunnel() {
+	ip l2tp show tunnel \
+	| LC_CTYPE=C awk -v q="'" -v id="$1" '
+		function shquote(str) {
+			gsub(q, q "\\" q q, str)
+			return q str q
 		}
-		match($0, /^[ ]*Peer tunnel ([0-9]+)$/, ret) {
-			if (found == "1") {
-				print prefix "peer_tunnel_id=" ret[1] ";"; 
-			}
+		BEGIN {
+			found = 0
+			sorter = "sort"
 		}
-		match($0, /^[ ]*UDP source \/ dest ports: ([0-9]+)\/([0-9]+)$/, ret) {
-			if (found == "1") {
-				print prefix "udp_sport=" ret[1] ";"; 
-				print prefix "udp_dport=" ret[2] ";"; 
+		/^Tunnel [0-9]+, encap (IP|UDP)$/ {
+			if (found) exit
+			tunnel_id = substr($2, 0, length($2) - 1)
+			if (tunnel_id == id) {
+				found = 1
+				print "tunnel_id=" shquote(tunnel_id) | sorter
+				print "encap=" shquote(tolower($4)) | sorter
 			}
-		}')"
-	test -n "$found"
+		}
+		found && /^[[:blank:]]*From [^[:blank:]]+ to [^[:blank:]]+$/ {
+			print "local=" shquote($2) | sorter
+			print "remote=" shquote($4) | sorter
+		}
+		found && /^[[:blank:]]*Peer tunnel [0-9]+$/ {
+			print "peer_tunnel_id=" shquote($NF) | sorter
+		}
+		found && /^[[:blank:]]*UDP source \/ dest ports: [0-9]+\/[0-9]+$/ {
+			split($NF, ports, "/")
+			print ": udp_sport=" shquote(ports[1]) | sorter
+			print ": udp_dport=" shquote(ports[2]) | sorter
+		}
+		END {
+			close(sorter)
+			exit(!found)
+		}
+	'
 }
 
-_ip_l2tp_add() {
-	local e
-	e="$(LC_ALL=C ip l2tp add "$@" 2>&1 1>/dev/null)"
-	case $e in
-		"")
-			return 0
-			;;
-		"RTNETLINK answers: No such process")
-			# seems to not be a fatal error but I don't know why I have this error... hmmm
-			ewarn "ip l2tp add $2 error: $e"
-			return 0
-			;;
-		*)
-			eend 1 "ip l2tp add $2 error: $e"
-			return 1
-			;;
-	esac
-	
+_l2tp_should_add_tunnel() {
+	local existing_tunnel
+
+	if ! existing_tunnel=$(_l2tp_parse_existing_tunnel "$1"); then
+		return 0
+	elif [ "$2" = "${existing_tunnel}" ]; then
+		return 1
+	else
+		return 2
+	fi
 }
 
+_l2tp_has_tunnel() {
+	_l2tp_parse_existing_tunnel "$1" >/dev/null
+}
+
+_l2tp_in_session() {
+	ip l2tp show session | {
+		LC_CTYPE=C
+		while read -r line; do
+			case ${line} in
+				"Session "*" in tunnel $1") return 0
+			esac
+		done
+	}
+	return 1
+}
+
+_is_blank() (
+	LC_CTYPE=C
+	case $1 in
+		*[![:blank:]]*) return 1
+	esac
+)
+
 l2tp_pre_start()
 {
-	local l2tpsession=
-	eval l2tpsession=\$l2tpsession_${IFVAR}
-	test -n "${l2tpsession}" || return 0
-	
-	ebegin "Creating L2TPv3 link ${IFVAR}"
-	local l2tp_err s_name s_tunnel_id s_session_id s_peer_session_id s_cookie s_peer_cookie s_offset s_peer_offset s_l2spec_type
-	if ! _l2tp_eval_props s_ "name|tunnel_id|session_id|peer_session_id|cookie|peer_cookie|offset|peer_offset|l2spec_type" "${l2tpsession}"; then
-		eend 1 "l2tpsession_${IFVAR} syntax error: $l2tp_err"
-		return 1
-	fi
-	if [ -n "$s_name" ]; then
-		eend 1 "l2tpsession_${IFVAR} error: please remove the \"name\" parameter (this parameter is managed by the system)"
-		return 1
-	fi
-	# Try to load mendatory l2tp_eth kernel module
-	if ! modprobe l2tp_eth; then
-		eend 1 "l2tp_eth module not present in your kernel (please enable CONFIG_L2TP_ETH option in your kernel config)"
-		return 1
-	fi
-	local l2tptunnel=
-	eval l2tptunnel=\$l2tptunnel_${IFVAR}
-	if [ -n "${l2tptunnel}" ]; then
-		local t_tunnel_id t_encap t_local t_remote t_peer_tunnel_id t_udp_sport t_udp_dport
-		_l2tp_eval_props t_ "remote|local|encap|tunnel_id|peer_tunnel_id|encap|udp_sport|udp_dport" "${l2tptunnel}"
-		# if encap=ip we need l2tp_ip kernel module
-		if [ "${t_encap^^}" = "IP" ] && ! modprobe l2tp_ip; then
-			eend 1 "l2tp_ip module not present in your kernel (please enable CONFIG_L2TP_IP option in your kernel config)"
-			return 1
-		fi
-		# Search for an existing tunnel with the same ID
-		local f_tunnel_id f_encap f_local f_remote f_peer_tunnel_id f_udp_sport f_udp_dport
-		if _l2tp_get_tunnel_info f_ $t_tunnel_id; then
-			# check if the existing tunnel has the same property than expected
-			if [ "tunnel_id:$f_tunnel_id;encap:$f_encap;local:$f_local;remote:$f_remote;
-			peer_tunnel_id:$f_peer_tunnel_id;udp_sport:$f_udp_sport;udp_dport:$f_udp_dport" \
-			!= "tunnel_id:$t_tunnel_id;encap:${t_encap^^};local:$t_local;remote:$t_remote;
-			peer_tunnel_id:$t_peer_tunnel_id;udp_sport:$t_udp_sport;udp_dport:$t_udp_dport" ]; then
-				eend 1 "There are an existing tunnel with id=$s_tunnel_id, but the properties mismatch with the one you want to create"
-				return 1
-			fi
+	local declared_session declared_tunnel l2tpsession l2tptunnel
+	local name peer_session_id session_id tunnel_id
+	local encap local peer_tunnel_id remote
+	local key
+
+	if key="l2tpsession_${IFVAR:?}"; ! eval "[ \${${key}+set} ]"; then
+		return
+	elif eval "l2tpsession=\$${key}"; _is_blank "${l2tpsession}"; then
+		eend 1 "${key} is defined but its value is blank"
+	elif ! declared_session=$(_l2tp_parse_opts "${l2tpsession}" "peer_session_id session_id tunnel_id" "name"); then
+		eend 1 "${key} is missing at least one required parameter"
+	elif eval "${declared_session}"; [ "${name+set}" ]; then
+		eend 1 "${key} defines a \"name\" parameter, which is forbidden by netifrc"
+	elif ! modprobe l2tp_eth; then
+		eend 1 "Couldn't load the l2tp_eth module (perhaps the CONFIG_L2TP_ETH kernel option is disabled)"
+	elif key="l2tptunnel_${IFVAR}"; eval "[ \${${key}+set} ]"; then
+		if eval "l2tptunnel=\$${key}"; _is_blank "${l2tptunnel}"; then
+			eend 1 "${key} is defined but its value is blank"
+		elif ! declared_tunnel=$(_l2tp_parse_opts "${l2tptunnel}" "local peer_tunnel_id remote tunnel_id" "encap"); then
+			eend 1 "${key} is missing at least one required parameter"
+		elif set -- "${tunnel_id}"; eval "${declared_tunnel}"; [ "$1" != "${tunnel_id}" ]; then
+			eend 1 "${key} defines a \"tunnel_id\" parameter that contradicts l2tpsession_${IFVAR}"
+		elif _l2tp_should_add_tunnel "${tunnel_id}" "${declared_tunnel}"; set -- $?; [ "$1" -eq 2 ]; then
+			eend 1 "Tunnel #${tunnel_id} exists but its properties mismatch those defined by ${key}"
+		elif [ "$1" -eq 1 ]; then
+			# The config matches an existing tunnel.
+			true
+		elif [ "${encap}" = ip ] && ! modprobe l2tp_ip; then
+			eend 1 "Couldn't load the l2tp_ip module (perhaps the CONFIG_L2TP_IP kernel option is disabled)"
 		else
-			veinfo ip l2tp add tunnel ${l2tptunnel}
-			_ip_l2tp_add tunnel ${l2tptunnel} || return 1
+			ebegin "Creating L2TPv3 tunnel (tunnel_id ${tunnel_id})"
+			printf %s "l2tp add tunnel ${l2tptunnel}" \
+			| xargs -E '' ip
+			eend $?
 		fi
-	elif ! ip l2tp show tunnel | grep -Eq "^Tunnel $s_tunnel_id,"; then
-		# no l2tptunnel_<INTF> declaration, assume that the tunnel is already present
-		# checking if tunnel_id exists otherwise raise an error
-		eend 1 "Tunnel id=$s_tunnel_id no found (you may have to set l2tptunnel_${IFVAR})"
-		return 1
-	fi
-	veinfo ip l2tp add session ${l2tpsession} name "${IFACE}"
-	_ip_l2tp_add session ${l2tpsession} name "${IFACE}" || return 1
-	_up
-}
+	elif ! _l2tp_has_tunnel "${tunnel_id}"; then
+		# A tunnel may incorporate more than one session (link). This
+		# module allows for the user not to define a tunnel for a given
+		# session. In that case, it will be expected that the required
+		# tunnel has already been created to satisfy some other session.
+		eend 1 "Tunnel #${tunnel_id} not found (defining ${key} may be required)"
+	fi || return
 
+	ebegin "Creating L2TPv3 session (session_id ${session_id} tunnel_id ${tunnel_id})"
+	printf %s "l2tp add session ${l2tpsession} name ${IFACE:?}" \
+	| xargs -E '' ip && _up
+	eend $?
+}
 
 l2tp_post_stop()
 {
-	local session_id tunnel_id
-	_is_l2tp || return 0
-	
-	ebegin "Destroying L2TPv3 link ${IFACE}"
-	veinfo ip l2tp del session tunnel_id $tunnel_id session_id $session_id
-	ip l2tp del session tunnel_id $tunnel_id session_id $session_id
-	if ! ip l2tp show session | grep -Eq "^Session [0-9]+ in tunnel $tunnel_id\$"; then
-		#tunnel $tunnel_id no longer used, destoying it...
-		veinfo ip l2tp del tunnel tunnel_id $tunnel_id
-		ip l2tp del tunnel tunnel_id $tunnel_id
+	local existing_session session_id tunnel_id
+
+	# This function may be invoked for every interface. If not a virtual
+	# interface, it can't possibly be one that's managed by this module, in
+	# which case running ip(8) and awk(1) would be a needless expense.
+	[ -e /sys/devices/virtual/net/"${IFACE:?}" ] \
+	&& existing_session=$(_l2tp_parse_existing_session 2>/dev/null) \
+	|| return 0
+
+	eval "${existing_session}"
+	set -- session_id "${session_id}" tunnel_id "${tunnel_id}"
+	ebegin "Destroying L2TPv3 session ($*)"
+	ip l2tp del session "$@"
+	eend $? &&
+	if ! _l2tp_in_session "${tunnel_id}"; then
+		shift 2
+		ebegin "Destroying L2TPv3 tunnel ($*)"
+		ip l2tp del tunnel "$@"
+		eend $?
 	fi
-	eend $?
 }


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2023-01-15  1:51 Sam James
  0 siblings, 0 replies; 109+ messages in thread
From: Sam James @ 2023-01-15  1:51 UTC (permalink / raw
  To: gentoo-commits

commit:     b6c67a56b566b0a178fc8eb7cac761e0f6521356
Author:     Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Sat Jan 14 23:04:46 2023 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sun Jan 15 01:51:26 2023 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=b6c67a56

net/l2tp.sh: Re-order function declarations and use a consistent brace style

This is how I would initially have submitted it, only I wanted for the initial
set of changes to be legible as a unified diff.

Signed-off-by: Kerin Millar <kfm <AT> plushkava.net>
Bug: https://bugs.gentoo.org/890238
Signed-off-by: Sam James <sam <AT> gentoo.org>

 net/l2tp.sh | 168 +++++++++++++++++++++++++++++-------------------------------
 1 file changed, 82 insertions(+), 86 deletions(-)

diff --git a/net/l2tp.sh b/net/l2tp.sh
index 51a2331..52b5733 100644
--- a/net/l2tp.sh
+++ b/net/l2tp.sh
@@ -7,14 +7,92 @@
 # Also, SC2034 and SC2316 are muted because they produce false-positives.
 # shellcheck shell=sh disable=SC3043,SC2034,SC2316
 
-l2tp_depend()
-{
+l2tp_depend() {
 	program ip
 	before bridge interface macchanger
 }
 
-_l2tp_parse_opts()
-{
+l2tp_pre_start() {
+	local declared_session declared_tunnel l2tpsession l2tptunnel
+	local name peer_session_id session_id tunnel_id
+	local encap local peer_tunnel_id remote
+	local key
+
+	if key="l2tpsession_${IFVAR:?}"; ! eval "[ \${${key}+set} ]"; then
+		return
+	elif eval "l2tpsession=\$${key}"; _is_blank "${l2tpsession}"; then
+		eend 1 "${key} is defined but its value is blank"
+	elif ! declared_session=$(_l2tp_parse_opts "${l2tpsession}" "peer_session_id session_id tunnel_id" "name"); then
+		eend 1 "${key} is missing at least one required parameter"
+	elif eval "${declared_session}"; [ "${name+set}" ]; then
+		eend 1 "${key} defines a \"name\" parameter, which is forbidden by netifrc"
+	elif ! modprobe l2tp_eth; then
+		eend 1 "Couldn't load the l2tp_eth module (perhaps the CONFIG_L2TP_ETH kernel option is disabled)"
+	elif key="l2tptunnel_${IFVAR}"; eval "[ \${${key}+set} ]"; then
+		if eval "l2tptunnel=\$${key}"; _is_blank "${l2tptunnel}"; then
+			eend 1 "${key} is defined but its value is blank"
+		elif ! declared_tunnel=$(_l2tp_parse_opts "${l2tptunnel}" "local peer_tunnel_id remote tunnel_id" "encap"); then
+			eend 1 "${key} is missing at least one required parameter"
+		elif set -- "${tunnel_id}"; eval "${declared_tunnel}"; [ "$1" != "${tunnel_id}" ]; then
+			eend 1 "${key} defines a \"tunnel_id\" parameter that contradicts l2tpsession_${IFVAR}"
+		elif _l2tp_should_add_tunnel "${tunnel_id}" "${declared_tunnel}"; set -- $?; [ "$1" -eq 2 ]; then
+			eend 1 "Tunnel #${tunnel_id} exists but its properties mismatch those defined by ${key}"
+		elif [ "$1" -eq 1 ]; then
+			# The config matches an existing tunnel.
+			true
+		elif [ "${encap}" = ip ] && ! modprobe l2tp_ip; then
+			eend 1 "Couldn't load the l2tp_ip module (perhaps the CONFIG_L2TP_IP kernel option is disabled)"
+		else
+			ebegin "Creating L2TPv3 tunnel (tunnel_id ${tunnel_id})"
+			printf %s "l2tp add tunnel ${l2tptunnel}" \
+			| xargs -E '' ip
+			eend $?
+		fi
+	elif ! _l2tp_has_tunnel "${tunnel_id}"; then
+		# A tunnel may incorporate more than one session (link). This
+		# module allows for the user not to define a tunnel for a given
+		# session. In that case, it will be expected that the required
+		# tunnel has already been created to satisfy some other session.
+		eend 1 "Tunnel #${tunnel_id} not found (defining ${key} may be required)"
+	fi || return
+
+	ebegin "Creating L2TPv3 session (session_id ${session_id} tunnel_id ${tunnel_id})"
+	printf %s "l2tp add session ${l2tpsession} name ${IFACE:?}" \
+	| xargs -E '' ip && _up
+	eend $?
+}
+
+l2tp_post_stop() {
+	local existing_session session_id tunnel_id
+
+	# This function may be invoked for every interface. If not a virtual
+	# interface, it can't possibly be one that's managed by this module, in
+	# which case running ip(8) and awk(1) would be a needless expense.
+	[ -e /sys/devices/virtual/net/"${IFACE:?}" ] \
+	&& existing_session=$(_l2tp_parse_existing_session 2>/dev/null) \
+	|| return 0
+
+	eval "${existing_session}"
+	set -- session_id "${session_id}" tunnel_id "${tunnel_id}"
+	ebegin "Destroying L2TPv3 session ($*)"
+	ip l2tp del session "$@"
+	eend $? &&
+	if ! _l2tp_in_session "${tunnel_id}"; then
+		shift 2
+		ebegin "Destroying L2TPv3 tunnel ($*)"
+		ip l2tp del tunnel "$@"
+		eend $?
+	fi
+}
+
+_is_blank() (
+	LC_CTYPE=C
+	case $1 in
+		*[![:blank:]]*) return 1
+	esac
+)
+
+_l2tp_parse_opts() {
 	# Parses lt2psession or l2tptunnel options using xargs(1), conveying
 	# them as arguments to awk(1). The awk program interprets the arguments
 	# as a series of key/value pairs and safely prints those specified as
@@ -152,85 +230,3 @@ _l2tp_in_session() {
 	}
 	return 1
 }
-
-_is_blank() (
-	LC_CTYPE=C
-	case $1 in
-		*[![:blank:]]*) return 1
-	esac
-)
-
-l2tp_pre_start()
-{
-	local declared_session declared_tunnel l2tpsession l2tptunnel
-	local name peer_session_id session_id tunnel_id
-	local encap local peer_tunnel_id remote
-	local key
-
-	if key="l2tpsession_${IFVAR:?}"; ! eval "[ \${${key}+set} ]"; then
-		return
-	elif eval "l2tpsession=\$${key}"; _is_blank "${l2tpsession}"; then
-		eend 1 "${key} is defined but its value is blank"
-	elif ! declared_session=$(_l2tp_parse_opts "${l2tpsession}" "peer_session_id session_id tunnel_id" "name"); then
-		eend 1 "${key} is missing at least one required parameter"
-	elif eval "${declared_session}"; [ "${name+set}" ]; then
-		eend 1 "${key} defines a \"name\" parameter, which is forbidden by netifrc"
-	elif ! modprobe l2tp_eth; then
-		eend 1 "Couldn't load the l2tp_eth module (perhaps the CONFIG_L2TP_ETH kernel option is disabled)"
-	elif key="l2tptunnel_${IFVAR}"; eval "[ \${${key}+set} ]"; then
-		if eval "l2tptunnel=\$${key}"; _is_blank "${l2tptunnel}"; then
-			eend 1 "${key} is defined but its value is blank"
-		elif ! declared_tunnel=$(_l2tp_parse_opts "${l2tptunnel}" "local peer_tunnel_id remote tunnel_id" "encap"); then
-			eend 1 "${key} is missing at least one required parameter"
-		elif set -- "${tunnel_id}"; eval "${declared_tunnel}"; [ "$1" != "${tunnel_id}" ]; then
-			eend 1 "${key} defines a \"tunnel_id\" parameter that contradicts l2tpsession_${IFVAR}"
-		elif _l2tp_should_add_tunnel "${tunnel_id}" "${declared_tunnel}"; set -- $?; [ "$1" -eq 2 ]; then
-			eend 1 "Tunnel #${tunnel_id} exists but its properties mismatch those defined by ${key}"
-		elif [ "$1" -eq 1 ]; then
-			# The config matches an existing tunnel.
-			true
-		elif [ "${encap}" = ip ] && ! modprobe l2tp_ip; then
-			eend 1 "Couldn't load the l2tp_ip module (perhaps the CONFIG_L2TP_IP kernel option is disabled)"
-		else
-			ebegin "Creating L2TPv3 tunnel (tunnel_id ${tunnel_id})"
-			printf %s "l2tp add tunnel ${l2tptunnel}" \
-			| xargs -E '' ip
-			eend $?
-		fi
-	elif ! _l2tp_has_tunnel "${tunnel_id}"; then
-		# A tunnel may incorporate more than one session (link). This
-		# module allows for the user not to define a tunnel for a given
-		# session. In that case, it will be expected that the required
-		# tunnel has already been created to satisfy some other session.
-		eend 1 "Tunnel #${tunnel_id} not found (defining ${key} may be required)"
-	fi || return
-
-	ebegin "Creating L2TPv3 session (session_id ${session_id} tunnel_id ${tunnel_id})"
-	printf %s "l2tp add session ${l2tpsession} name ${IFACE:?}" \
-	| xargs -E '' ip && _up
-	eend $?
-}
-
-l2tp_post_stop()
-{
-	local existing_session session_id tunnel_id
-
-	# This function may be invoked for every interface. If not a virtual
-	# interface, it can't possibly be one that's managed by this module, in
-	# which case running ip(8) and awk(1) would be a needless expense.
-	[ -e /sys/devices/virtual/net/"${IFACE:?}" ] \
-	&& existing_session=$(_l2tp_parse_existing_session 2>/dev/null) \
-	|| return 0
-
-	eval "${existing_session}"
-	set -- session_id "${session_id}" tunnel_id "${tunnel_id}"
-	ebegin "Destroying L2TPv3 session ($*)"
-	ip l2tp del session "$@"
-	eend $? &&
-	if ! _l2tp_in_session "${tunnel_id}"; then
-		shift 2
-		ebegin "Destroying L2TPv3 tunnel ($*)"
-		ip l2tp del tunnel "$@"
-		eend $?
-	fi
-}


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2022-12-25 19:14 Robin H. Johnson
  0 siblings, 0 replies; 109+ messages in thread
From: Robin H. Johnson @ 2022-12-25 19:14 UTC (permalink / raw
  To: gentoo-commits

commit:     d877a5aa5b105b17ced7be467fb4412a9ddd05aa
Author:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
AuthorDate: Sun Dec 25 19:14:04 2022 +0000
Commit:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
CommitDate: Sun Dec 25 19:14:04 2022 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=d877a5aa

net/hsr: add Parallel Redundancy Protocol (PRP) support

Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org>
Reference: https://github.com/gentoo/netifrc/pull/38

 net/hsr.sh | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/net/hsr.sh b/net/hsr.sh
index f5a427f..cbe35e9 100644
--- a/net/hsr.sh
+++ b/net/hsr.sh
@@ -21,6 +21,8 @@ hsr_pre_start()
 	eval hsr_slave1=\$hsr_slave1_${IFVAR}
 	eval hsr_slave2=\$hsr_slave2_${IFVAR}
 	eval hsr_supervision=\$hsr_supervision_${IFVAR}
+	eval hsr_version=\$hsr_version_${IFVAR}
+	eval hsr_proto=\$hsr_proto_${IFVAR}
 	if [ -z "${hsr_slave1}" ] || [ -z "${hsr_slave2}" ]; then
 		eerror "HSR interfaces require two slave interfaces to be set"
 		return 1
@@ -35,7 +37,10 @@ hsr_pre_start()
 	fi
 
 	ebegin "Creating HSR interface ${IFACE}"
-	cmd="ip link add name "${IFACE}" type hsr slave1 ${hsr_slave1} slave2 ${hsr_slave2} ${hsr_supervision:+supervision }${hsr_supervision}"
+	cmd="ip link add name "${IFACE}" type hsr slave1 ${hsr_slave1} slave2 ${hsr_slave2}"
+	test -n "${hsr_supervision}" && cmd="${cmd} supervision ${hsr_supervision}"
+	test -n "${hsr_version}" && cmd="${cmd} version ${hsr_version}"
+	test -n "${hsr_proto}" && cmd="${cmd} proto ${hsr_proto}"
 	veinfo $cmd
 	if $cmd ; then
 		eend 0 && _up && set_interface_type hsr


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2022-12-25 19:07 Robin H. Johnson
  0 siblings, 0 replies; 109+ messages in thread
From: Robin H. Johnson @ 2022-12-25 19:07 UTC (permalink / raw
  To: gentoo-commits

commit:     bd8ff4aa89e1d56e9886dad32bb2406c8f43c747
Author:     kmartin36 <Kevin.Martin <AT> gtri <DOT> gatech <DOT> edu>
AuthorDate: Sat Dec 17 08:26:21 2022 +0000
Commit:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
CommitDate: Sun Dec 25 19:06:36 2022 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=bd8ff4aa

Adding the saved args to the stop command

Closes: https://bugs.gentoo.org/881039
Signed-off-by: Kevin Martin <kevinmbecause <AT> gmail.com>
(cherry picked from commit 0e1c19959a6d82accdb57fa7a1f5b0036037a001)
Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org>
Closes: https://github.com/gentoo/netifrc/pull/41

 net/dhcpcd.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/dhcpcd.sh b/net/dhcpcd.sh
index 1e1bbe0..1380944 100644
--- a/net/dhcpcd.sh
+++ b/net/dhcpcd.sh
@@ -90,8 +90,8 @@ dhcpcd_stop()
 	eval opts=\$dhcp_${IFVAR}
 	[ -z "${opts}" ] && opts=${dhcp}
 	case " ${opts} " in
-		*" release "*) dhcpcd -k "${IFACE}" ;;
-		*) dhcpcd -x "${IFACE}" ;;
+		*" release "*) dhcpcd -k "${args}" "${IFACE}" ;;
+		*) dhcpcd -x "${args}" "${IFACE}" ;;
 	esac
 	[ -f "${argsfile}" ] && rm -f "${argsfile}"
 	eend $?


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2021-03-31  1:11 Patrick McLean
  0 siblings, 0 replies; 109+ messages in thread
From: Patrick McLean @ 2021-03-31  1:11 UTC (permalink / raw
  To: gentoo-commits

commit:     4143e26dd4a56c08fbb99e18913eaafaf2a04f32
Author:     Patrick McLean <chutzpah <AT> gentoo <DOT> org>
AuthorDate: Wed Mar 31 01:07:57 2021 +0000
Commit:     Patrick McLean <chutzpah <AT> gentoo <DOT> org>
CommitDate: Wed Mar 31 01:11:03 2021 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=4143e26d

net/iproute2.sh: in _get_mac_address, don't return multiple addresses

Currently if a device has virtual functions configured, ip will list the mac
addresses for the virtual functions on a device as well as the device itself.
This makes _get_mac_address return these addresses as well, causing functions
that consume this output to fail in "interesting" ways. This makes sure it only
returns 1 address.

Also don't set the mac variable to the address of the interface from sysfs, then
proceed to overwrite it with a call to "ip".

Signed-off-by: Patrick McLean <chutzpah <AT> gentoo.org>

 net/iproute2.sh | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/net/iproute2.sh b/net/iproute2.sh
index 46f0e48..bd7333e 100644
--- a/net/iproute2.sh
+++ b/net/iproute2.sh
@@ -91,10 +91,9 @@ _set_flag()
 _get_mac_address()
 {
 	local mac=
-	read -r mac < /sys/class/net/"${IFACE}"/address || return 1
-	local mac=$(LC_ALL=C _ip link show "${IFACE}" | sed -n \
+	mac=$(LC_ALL=C _ip link show "${IFACE}" | sed -n \
 		-e 'y/abcdef/ABCDEF/' \
-		-e '/link\// s/^.*\<\(..:..:..:..:..:..\)\>.*/\1/p')
+		-e '/link\// s/^.*\<\(..:..:..:..:..:..\)\>.*/\1/p' | head -n1)
 
 	case "${mac}" in
 		00:00:00:00:00:00) return 1 ;;


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2021-03-11 16:54 Lars Wendler
  0 siblings, 0 replies; 109+ messages in thread
From: Lars Wendler @ 2021-03-11 16:54 UTC (permalink / raw
  To: gentoo-commits

commit:     f56e5753063e4d461b3e140e50bcbd6a60b0c1eb
Author:     Patrick McLean <chutzpah <AT> gentoo <DOT> org>
AuthorDate: Sat Nov 21 06:53:54 2020 +0000
Commit:     Lars Wendler <polynomial-c <AT> gentoo <DOT> org>
CommitDate: Thu Mar 11 16:53:33 2021 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=f56e5753

net/dummy.sh: Add support for network namespaces

Closes: https://github.com/gentoo/netifrc/pull/35
Signed-off-by: Lars Wendler <polynomial-c <AT> gentoo.org>

 net/dummy.sh | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/net/dummy.sh b/net/dummy.sh
index 421d951..091e08c 100644
--- a/net/dummy.sh
+++ b/net/dummy.sh
@@ -13,16 +13,20 @@ _is_dummy() {
 	is_interface_type dummy
 }
 
+_ip()
+{
+	veinfo ip "${@}"
+	_netns ip "${@}"
+}
+
 dummy_pre_start()
 {
 	local dummy=
-	eval dummy=\$type_${IFVAR}
+	eval dummy="\$type_${IFVAR}"
 	[ "${dummy}" = "dummy" ] || return 0
 
 	ebegin "Creating dummy interface ${IFACE}"
-	cmd="ip link add name "${IFACE}" type dummy"
-	veinfo $cmd
-	if $cmd ; then
+	if _ip link add name "${IFACE}" type dummy ; then
 		eend 0 && _up && set_interface_type dummy
 	else
 		eend 1
@@ -35,8 +39,6 @@ dummy_post_stop()
 	_is_dummy || return 0
 
 	ebegin "Removing dummy ${IFACE}"
-	cmd="ip link delete "${IFACE}" type dummy"
-	veinfo "$cmd"
-	$cmd
+	_ip link delete "${IFACE}" type dummy
 	eend $?
 }


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2021-03-11 16:54 Lars Wendler
  0 siblings, 0 replies; 109+ messages in thread
From: Lars Wendler @ 2021-03-11 16:54 UTC (permalink / raw
  To: gentoo-commits

commit:     2eca000593194ef3bcf099b8bb1003bb5ea4292f
Author:     Patrick McLean <chutzpah <AT> gentoo <DOT> org>
AuthorDate: Sat Nov 21 06:52:48 2020 +0000
Commit:     Lars Wendler <polynomial-c <AT> gentoo <DOT> org>
CommitDate: Thu Mar 11 16:53:33 2021 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=2eca0005

net/bonding.sh: Add support for network namespaces

Signed-off-by: Lars Wendler <polynomial-c <AT> gentoo.org>

 net/bonding.sh | 57 +++++++++++++++++++++++++++++++--------------------------
 1 file changed, 31 insertions(+), 26 deletions(-)

diff --git a/net/bonding.sh b/net/bonding.sh
index 880f69b..1757a89 100644
--- a/net/bonding.sh
+++ b/net/bonding.sh
@@ -12,13 +12,18 @@ bonding_depend()
 	if [ ! -d /sys/class/net ]; then
 		program /sbin/ifenslave
 	fi
+
+	local netns
+	eval netns="\$netns_${IFVAR}"
+	[ -n "${netns}" ] && program ip
+	return 0
 }
 
 _config_vars="$_config_vars slaves"
 
 _is_bond()
 {
-	[ -f "/proc/net/bonding/${IFACE}" ]
+	_netns [ -f "/proc/net/bonding/${IFACE}" ]
 }
 
 bonding_pre_start()
@@ -52,7 +57,7 @@ bonding_pre_start()
 	# We can create the interface name we like now, but this
 	# requires sysfs
 	if ! _exists && [ -d /sys/class/net ]; then
-		echo "+${IFACE}" > /sys/class/net/bonding_masters
+		_netns echo "+${IFACE}" \> /sys/class/net/bonding_masters
 	fi
 	_exists true || return 1
 
@@ -68,13 +73,13 @@ bonding_pre_start()
 	# we configure all other options
 	# mode needs to be done before all other options.
 	# miimon needs to be done BEFORE downdelay
-	[ -d /sys/class/net ] && for n in mode miimon; do
+	_netns [ -d /sys/class/net ] && for n in mode miimon; do
 		x=/sys/class/net/"${IFACE}"/bonding/$n
-		[ -f "${x}" ] || continue
+		_netns [ -f "${x}" ] || continue
 		eval s=\$${n}_${IFVAR}
 		if [ -n "${s}" ]; then
 			einfo "Setting ${n}: ${s}"
-			echo "${s}" >"${x}" || \
+			_netns echo "${s}" \>"${x}" || \
 			eerror "Failed to configure $n (${n}_${IFVAR})"
 		fi
 	done
@@ -82,19 +87,19 @@ bonding_pre_start()
 	# With a leading '+' as a prefix.
 	n=arp_ip_target
 	x=/sys/class/net/"${IFACE}"/bonding/$n
-	[ -d /sys/class/net ] && if [ -f "$x" ]; then
+	_netns [ -d /sys/class/net ] && if _netns [ -f "$x" ]; then
 		eval s=\$${n}_${IFVAR}
 		if [ -n "${s}" ]; then
 			for i in $s; do
 				einfo "Adding ${n}: ${i}"
-				echo "+${i/+/}" >"${x}" || \
+				_netns echo "+${i/+/}" \>"${x}" || \
 				eerror "Failed to add $i (${n}_${IFVAR})"
 			done
 		fi
 	fi
 	# Nice and dynamic for remaining options:)
-	[ -d /sys/class/net ] && for x in /sys/class/net/"${IFACE}"/bonding/*; do
-		[ -f "${x}" ] || continue
+	_netns [ -d /sys/class/net ] && for x in $(_netns glob /sys/class/net/"${IFACE}"/bonding/\*); do
+		_netns [ -f "${x}" ] || continue
 		n=${x##*/}
 		# These entries are already handled above.
 		case "$n" in
@@ -106,7 +111,7 @@ bonding_pre_start()
 		eval s=\$${n}_${IFVAR}
 		if [ -n "${s}" ]; then
 			einfo "Setting ${n}: ${s}"
-			echo "${s}" >"${x}" || \
+			_netns echo "${s}" \>"${x}" || \
 			eerror "Failed to configure $n (${n}_${IFVAR})"
 		fi
 	done
@@ -145,9 +150,9 @@ bonding_pre_start()
 		unset oiface
 		eoutdent
 		# subsume (presumably kernel auto-)configured IP
-		if [ -x "$(command -v ip)" ]; then
-			ip link set ${IFACE} up
-			ip address add ${addr} dev ${IFACE}
+		if [ -x "$(command -v ip 2>/dev/null)" ]; then
+			_netns ip link set ${IFACE} up
+			_netns ip address add ${addr} dev ${IFACE}
 		else
 			ifconfig ${IFACE} ${addr} up
 		fi
@@ -171,7 +176,7 @@ bonding_pre_start()
 	# set mtu: ifenslave, kernel
 	# set slave MAC: ifenslave, kernel
 	eoutdent
-	if [ -d /sys/class/net ]; then
+	if _netns [ -d /sys/class/net ]; then
 		sys_bonding_path=/sys/class/net/"${IFACE}"/bonding
 		local oiface
 		oiface=$IFACE
@@ -179,20 +184,20 @@ bonding_pre_start()
 			IFACE=$primary
 			_down
 			IFACE=$oiface
-			echo "+${primary}" >$sys_bonding_path/slaves
-			echo "${primary}" >$sys_bonding_path/primary
+			_netns echo "+${primary}" \> $sys_bonding_path/slaves
+			_netns echo "${primary}" \> $sys_bonding_path/primary
 		fi
 		for s in ${slaves}; do
 			[ "${s}" = "${primary}" ] && continue
-			if ! grep -q ${s} $sys_bonding_path/slaves; then
+			if ! _netns grep -q ${s} $sys_bonding_path/slaves; then
 				IFACE=$s
 				_down
 				IFACE=$oiface
-				echo "+${s}" >$sys_bonding_path/slaves
+				_netns echo "+${s}" \> $sys_bonding_path/slaves
 			fi
 		done
 	else
-		ifenslave "${IFACE}" ${slaves} >/dev/null
+		_netns ifenslave "${IFACE}" ${slaves} >/dev/null
 	fi
 	eend $?
 
@@ -206,7 +211,7 @@ bonding_stop()
 	# Wipe subsumed interface
 	if [ -n "${subsume}" ]; then
 		if [ -x "$(command -v ip)" ]; then
-			ip address flush dev ${subsume}
+			_netns ip address flush dev ${subsume}
 		else
 			ifconfig ${subsume} 0.0.0.0
 		fi
@@ -214,7 +219,7 @@ bonding_stop()
 
 	local slaves= s=
 	slaves=$( \
-		sed -n -e 's/^Slave Interface: //p' "/proc/net/bonding/${IFACE}" \
+		_netns sed -n -e 's/^Slave Interface: //p' "/proc/net/bonding/${IFACE}" \
 		| tr '\n' ' ' \
 	)
 	[ -z "${slaves}" ] && return 0
@@ -224,12 +229,12 @@ bonding_stop()
 	eindent
 	einfo "${slaves}"
 	eoutdent
-	if [ -d /sys/class/net ]; then
+	if _netns [ -d /sys/class/net ]; then
 		for s in ${slaves}; do
-			echo -"${s}" > /sys/class/net/"${IFACE}"/bonding/slaves
+			_netns echo -"${s}" \> /sys/class/net/"${IFACE}"/bonding/slaves
 		done
 	else
-		ifenslave -d "${IFACE}" ${slaves}
+		_netns ifenslave -d "${IFACE}" ${slaves}
 	fi
 
 	# reset all slaves
@@ -244,8 +249,8 @@ bonding_stop()
 
 	_down
 
-	if [ -d /sys/class/net ]; then
-		echo "-${IFACE}" > /sys/class/net/bonding_masters
+	if _netns [ -d /sys/class/net ]; then
+		_netns echo "-${IFACE}" \> /sys/class/net/bonding_masters
 	fi
 
 	eend 0


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2021-03-11 16:54 Lars Wendler
  0 siblings, 0 replies; 109+ messages in thread
From: Lars Wendler @ 2021-03-11 16:54 UTC (permalink / raw
  To: gentoo-commits

commit:     b581c3f76b95bd2173a13d08054120f284ac06e7
Author:     Patrick McLean <chutzpah <AT> gentoo <DOT> org>
AuthorDate: Sat Nov 21 06:53:31 2020 +0000
Commit:     Lars Wendler <polynomial-c <AT> gentoo <DOT> org>
CommitDate: Thu Mar 11 16:53:33 2021 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=b581c3f7

net/bridge.sh: Add support for network namespaces when using iproute2

Signed-off-by: Lars Wendler <polynomial-c <AT> gentoo.org>

 net/bridge.sh | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/net/bridge.sh b/net/bridge.sh
index 4166215..a380f6a 100644
--- a/net/bridge.sh
+++ b/net/bridge.sh
@@ -12,19 +12,19 @@ _config_vars="$_config_vars bridge bridge_add brctl"
 
 _is_bridge()
 {
-	[ -d /sys/class/net/"${1:-${IFACE}}"/bridge ]
+	_netns [ -d /sys/class/net/"${1:-${IFACE}}"/bridge ]
 	return $?
 }
 
 _is_bridge_port()
 {
-	[ -d /sys/class/net/"${1:-${IFACE}}"/brport ]
+	_netns [ -d /sys/class/net/"${1:-${IFACE}}"/brport ]
 	return $?
 }
 
 _bridge_ports()
 {
-	for x in /sys/class/net/"${1:-${IFACE}}"/brif/*; do
+	for x in $(_netns glob /sys/class/net/"${1:-${IFACE}}"/brif/\*); do
 		n=${x##*/}
 		echo $n
 	done
@@ -82,7 +82,7 @@ bridge_pre_start()
 	if ! _is_bridge ; then
 		ebegin "Creating bridge ${IFACE}"
 		if ${do_iproute2}; then
-			ip link add "${IFACE}" type bridge
+			_netns ip link add "${IFACE}" type bridge
 			rc=$?
 		elif ${do_brctl}; then
 			brctl addbr "${IFACE}"
@@ -123,7 +123,7 @@ bridge_pre_start()
 	fi
 
 	# New configuration set mechanism, matches bonding
-	for x in /sys/class/net/"${IFACE}"/bridge/*; do
+	for x in $(_netns glob /sys/class/net/"${IFACE}"/bridge/\*); do
 		[ -f "${x}" ] || continue
 		n=${x##*/}
 		# keep no prefix for backward compatibility
@@ -132,7 +132,7 @@ bridge_pre_start()
 			if [ -n "${s}" ]; then
 				[ -z "${prefix}" ] && ewarn "sysfs key '${n}_${IFVAR}' should be prefixed, please add bridge_ prefix."
 				einfo "Setting ${n}: ${s}"
-				echo "${s}" >"${x}" || \
+				_netns echo "${s}" \>"${x}" || \
 				eerror "Failed to configure $n (${n}_${IFVAR})"
 			fi
 		done
@@ -154,7 +154,7 @@ bridge_pre_start()
 			# The interface is known to exist now
 			_up
 			if ${do_iproute2}; then
-				ip link set "${x}" master "${BR_IFACE}"
+				_netns ip link set "${x}" master "${BR_IFACE}"
 			elif ${do_brctl}; then
 				brctl addif "${BR_IFACE}" "${x}"
 			fi
@@ -163,7 +163,7 @@ bridge_pre_start()
 				return 1
 			fi
 			# Per-interface bridge settings
-			for x in /sys/class/net/"${IFACE}"/brport/*; do
+			for x in $(_netns glob /sys/class/net/"${IFACE}"/brport/\*); do
 				[ -f "${x}" ] || continue
 				n=${x##*/}
 				for prefix in "" brport_; do
@@ -171,7 +171,7 @@ bridge_pre_start()
 					if [ -n "${s}" ]; then
 						[ -z "${prefix}" ] && ewarn "sysfs key '${n}_${IFVAR}' should be prefixed, please add brport_ prefix."
 						einfo "Setting ${n}@${IFACE}: ${s}"
-						echo "${s}" >"${x}" || \
+						_netns echo "${s}" \>"${x}" || \
 						eerror "Failed to configure $n (${n}_${IFVAR})"
 					fi
 				done
@@ -194,7 +194,7 @@ bridge_post_stop()
 	if _is_bridge "${IFACE}"; then
 		ebegin "Destroying bridge ${IFACE}"
 		_down
-		for x in /sys/class/net/"${IFACE}"/brif/*; do
+		for x in $(_netns glob /sys/class/net/"${IFACE}"/brif/\*); do
 			[ -s $x ] || continue
 			n=${x##*/}
 			ports="${ports} ${n}"
@@ -206,8 +206,8 @@ bridge_post_stop()
 		# We are taking down an interface that is part of a bridge maybe
 		ports="${IFACE}"
 		local brport_dir="/sys/class/net/${IFACE}/brport"
-		[ -d ${brport_dir} ] || return 0
-		iface=$(readlink ${brport_dir}/bridge)
+		_netns [ -d ${brport_dir} ] || return 0
+		iface=$(_netns readlink ${brport_dir}/bridge)
 		iface=${iface##*/}
 		[ -z "${iface}" ] && return 0
 		extra=" from ${iface}"
@@ -218,7 +218,7 @@ bridge_post_stop()
 		local IFACE="${port}"
 		_set_flag -promisc
 		if type ip > /dev/null 2>&1; then
-			ip link set "${port}" nomaster
+			_netns ip link set "${port}" nomaster
 		else
 			brctl delif "${iface}" "${port}"
 		fi
@@ -228,7 +228,7 @@ bridge_post_stop()
 	if ${delete}; then
 		eoutdent
 		if type ip > /dev/null 2>&1; then
-			ip link del "${iface}"
+			_netns ip link del "${iface}"
 		else
 			brctl delbr "${iface}"
 		fi


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2021-02-02  8:28 Lars Wendler
  0 siblings, 0 replies; 109+ messages in thread
From: Lars Wendler @ 2021-02-02  8:28 UTC (permalink / raw
  To: gentoo-commits

commit:     b60fd3319a254dfacf0051dc0e5343a8fe6e87f1
Author:     Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Tue Feb  2 03:47:13 2021 +0000
Commit:     Lars Wendler <polynomial-c <AT> gentoo <DOT> org>
CommitDate: Tue Feb  2 08:27:02 2021 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=b60fd331

net/apipa.sh: Simplify and address the remaining portability issues

Re-factor the over-generalised seeding function into a _random_uint16
function. Have it use a simpler, faster method to collect entropy, with
the aid of od(1). Shorten the previously rambling comment.

Simplify the _random_apipa_octets function. Clamp the seed to the range
0-32767 for maximal portability. Convey the seed as a formal parameter,
rather then inject it. Use a simpler method to produce the octets, running
awk(1) only once. Format the random float, so that awk(1) is prevented
from using scientific notation to represent certain numbers.

Change a variable name in the subshell responsible for reading the list of
octet pairs, so as to be less confusing to future readers.

Note that the portability issue mentioned by commit 31a05f1 is addressed.
The code should now be fully POSIX-compliant, save for the continued use
of the local keyword, upon which it does not rely.

Signed-off-by: Kerin Millar <kfm <AT> plushkava.net>
Signed-off-by: Lars Wendler <polynomial-c <AT> gentoo.org>

 net/apipa.sh | 63 ++++++++++++++++++++++++++++--------------------------------
 1 file changed, 29 insertions(+), 34 deletions(-)

diff --git a/net/apipa.sh b/net/apipa.sh
index 41274fa..a124b84 100644
--- a/net/apipa.sh
+++ b/net/apipa.sh
@@ -6,47 +6,42 @@ apipa_depend()
 	program /sbin/arping /bin/arping
 }
 
-_random_bytes_as_int()
+_random_uint16()
 {
-	local hex num_bytes="$1"
-
-	# While POSIX does not require that /dev/urandom exist, it is a
-	# de-facto standard. Therefore, the following approach should be
-	# highly portable in practice. In the case of Linux, and unlike BSD
-	# this interface does not block in the event that the CSRNG has not
-	# yet been seeded. Still, this is acceptable because we do not
-	# require a guarantee that the entropy be cryptographically secure.
-	# It's also worth noting that Linux >=5.4 is faster at seeding in
-	# the absence of RDRAND/RDSEED than previous versions were.
+	# While POSIX does not require that /dev/urandom exist, it is a de-facto
+	# standard. In the case of Linux, and unlike BSD, this interface does
+	# not block in the event that the CSRNG has not yet been seeded.
+	# Still, this is acceptable because we do not require a guarantee that
+	# the entropy be cryptographically secure.
 	test -e /dev/urandom &&
-	hex=$(
-		LC_ALL=C tr -dc '[:xdigit:]' < /dev/urandom |
-		dd bs="$(( num_bytes * 2 ))" count=1 2>/dev/null) &&
-	test "${#hex}" = "$(( num_bytes * 2 ))" &&
-	printf '%d\n' "0x${hex}"
+	printf %d 0x"$(LC_ALL=C od -vAn -N2 -tx1 /dev/urandom | tr -d '[:space:]')"
 }
 
 _random_apipa_octets()
 {
 	local seed
 
-	# Obtain a highly random 16-bit seed for use by awk's RNG. In the
-	# unlikely event that the seed ends up being empty, awk will seed
-	# based on the time of day, with a granularity of one second.
-	seed=$(_random_bytes_as_int 2)
+	# Attempt to generate a random uint16 to seed awk's RNG. The maximum
+	# value of RAND_MAX known to be portable is 32767. Clamp accordingly by
+	# discarding one bit's worth of data. Should the seed turn out to be
+	# empty, we instruct awk to seed based on the time of day, in seconds.
+	seed=$(_random_uint16) && : $(( seed >>= 1 ))
 
 	# For APIPA (RFC 3927), the 169.254.0.0/16 address block is
 	# reserved. This provides 65024 addresses, having accounted for the
 	# fact that the first and last /24 are reserved for future use.
-	awk "BEGIN {
-		srand($seed)
-		for (i=256; i<65280; i++) print rand() \" \" i
-	}" |
-	sort -k 1,1 -n |
-	POSIXLY_CORRECT=1 awk '{
-		hex = sprintf("%04x",$2)
-		printf("%d %d\n", "0x" substr(hex,1,2), "0x" substr(hex,3,2))
-	}'
+	awk -v seed="$seed" 'BEGIN {
+		if (seed != "") {
+			srand(seed)
+		} else {
+			srand()
+		}
+		for (i = 1; i < 255; i++) {
+			for (j = 0; j < 256; j++) {
+				printf("%f %d %d\n", rand(), i, j)
+			}
+		}
+	}' | sort -k 1,1 -n
 }
 
 apipa_start()
@@ -62,11 +57,11 @@ apipa_start()
 	addr=$(
 		_random_apipa_octets |
 		{
-			while read -r i1 i2; do
-				addr="169.254.${i1}.${i2}"
-				vebegin "${addr}/16" >&3
-				if ! arping_address "${addr}" >&3; then
-					printf '%s\n' "${addr}"
+			while read -r f1 f2 f3; do
+				next_addr="169.254.$f2.$f3"
+				vebegin "$next_addr/16" >&3
+				if ! arping_address "$next_addr" >&3; then
+					printf %s "$next_addr"
 					exit 0
 				fi
 			done


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2021-01-27 16:55 Lars Wendler
  0 siblings, 0 replies; 109+ messages in thread
From: Lars Wendler @ 2021-01-27 16:55 UTC (permalink / raw
  To: gentoo-commits

commit:     e5c3bb95ed454a270cf1796bc123fb0c8f34ab5a
Author:     Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Wed Jan 27 16:25:05 2021 +0000
Commit:     Lars Wendler <polynomial-c <AT> gentoo <DOT> org>
CommitDate: Wed Jan 27 16:55:21 2021 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=e5c3bb95

net/apipa.sh: Account for the first and last /24 being reserved

While the 169.254/16 prefix is used to define IPv4 link-local addresses,
RFC 3927 states that the first 256 and last 256 addresses are reserved for
future use. Therefore, the number of available addresses amounts to neither
64516 nor 65534, but actually 65024.

Signed-off-by: Kerin Millar <kfm <AT> plushkava.net>
Signed-off-by: Lars Wendler <polynomial-c <AT> gentoo.org>

 net/apipa.sh | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/net/apipa.sh b/net/apipa.sh
index f3ec534..41274fa 100644
--- a/net/apipa.sh
+++ b/net/apipa.sh
@@ -36,11 +36,11 @@ _random_apipa_octets()
 	seed=$(_random_bytes_as_int 2)
 
 	# For APIPA (RFC 3927), the 169.254.0.0/16 address block is
-	# reserved. This provides 65534 addresses, having accounted for the
-	# network and broadcast address. Note that we must count from 1.
+	# reserved. This provides 65024 addresses, having accounted for the
+	# fact that the first and last /24 are reserved for future use.
 	awk "BEGIN {
 		srand($seed)
-		for (i=1; i<65535; i++) print rand() \" \" i
+		for (i=256; i<65280; i++) print rand() \" \" i
 	}" |
 	sort -k 1,1 -n |
 	POSIXLY_CORRECT=1 awk '{


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2021-01-27 14:19 Lars Wendler
  0 siblings, 0 replies; 109+ messages in thread
From: Lars Wendler @ 2021-01-27 14:19 UTC (permalink / raw
  To: gentoo-commits

commit:     b89e0687fb4facfc7f36fc137944856cf331271c
Author:     Lars Wendler <polynomial-c <AT> gentoo <DOT> org>
AuthorDate: Wed Jan 27 14:16:39 2021 +0000
Commit:     Lars Wendler <polynomial-c <AT> gentoo <DOT> org>
CommitDate: Wed Jan 27 14:16:39 2021 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=b89e0687

net/iwd.sh: Removed non-working "need dbus" call

This is a copy-paste remnant from net/wpa_supplicant.sh which never
worked with standalone netifrc.

Signed-off-by: Lars Wendler <polynomial-c <AT> gentoo.org>

 net/iwd.sh | 1 -
 1 file changed, 1 deletion(-)

diff --git a/net/iwd.sh b/net/iwd.sh
index e3f64b2..d8be2d5 100644
--- a/net/iwd.sh
+++ b/net/iwd.sh
@@ -3,7 +3,6 @@
 
 iwd_depend()
 {
-	need dbus
 	after macnet plug
 	before interface
 	provide wireless


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2021-01-27 14:06 Lars Wendler
  0 siblings, 0 replies; 109+ messages in thread
From: Lars Wendler @ 2021-01-27 14:06 UTC (permalink / raw
  To: gentoo-commits

commit:     31a05f1b3fb90a3b4e9c0e587bdd5a39e8236f6b
Author:     Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Mon Jan 25 02:40:29 2021 +0000
Commit:     Lars Wendler <polynomial-c <AT> gentoo <DOT> org>
CommitDate: Wed Jan 27 14:05:54 2021 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=31a05f1b

net/apipa.sh: fix broken implementation by way of a rewrite

Sadly, the present implementation has never functioned correctly. The
original author employed incorrect syntax for what was intended to be a
command substitution. As a result, the _random() function is never called.
What actually happens is that arping is needlessly executed exactly 64516
times, with no address ever being considered as a valid candidate.

Furthermore, this module has other bugs and is poorly designed. Here are the
reasons as to why:-

  • the 169.254.0.0/16 block offers 65534 addresses, not 64516
  • the main loop is horrendously slow at enumerating the address block
  • it counts to 64516 but doesn't ensure that each address is unique!
  • it prefers bash for generating entropy (fine, but non-standard)
  • it falls back to a non-standard utility for generating entropy

Therefore, I decided to re-write most of it. The fundamental difference is
that all 65534 octet pairs are generated up front before being processed by
the main loop. At most, every possible address will now be tested exactly
once.

In fact, this approach turns out to be faster by an order of magnitude. The
following synthetic tests - which calculate the time taken to enumerate the
entire address space - demonstrate the tremendous difference between the
existing code and mine. Of course, to ensure that the comparison was
meaningful, I rectified the command substitution bug in the existing code.

  # time bash apipa-old-test.sh
  real    2m34.367s
  user    1m9.959s
  sys     1m37.502s

  # time bash apipa-new-test.sh
  real    0m1.119s
  user    0m0.965s
  sys     0m0.182s

Note that the new _random_apipa_octets() function is responsible for
generating all 65534 combinations of octet pairs in a random order. It
mainly relies on awk(1) and sort(1). Where possible, a seed is obtained from
/dev/urandom for the benefit of awk's RNG, but this is not required.

I have isolated and tested the new functions on GNU/Linux, macOS, FreeBSD,
NetBSD, OpenBSD and MirBSD. I have individually tested gawk, mawk, nawk,
busybox awk and the awk implementations provided by the previously mentioned
operating systems in the case that they are distinct. The only
incompatiblity that I was personally able to find was with the awk
implementation of MirBSD, which affects the final invocation of awk in the
_random_apipa_octets function.  However, MirBSD was forked from an old
version of OpenBSD and seems sufficiently obscure so as not to be worth
worrying about. If someone should try to integrate netifrc into MirBSD one
day then the matter can be dealt with then.

Finally, I want to thank Steve Arnold for bringing the original bug to my
attention. Congratulations, Steve. You may be the only known user of
net/apipa.sh on the planet.

Signed-off-by: Kerin Millar <kfm <AT> plushkava.net>
Reported-by: Steve Arnold <nerdboy <AT> gentoo.org>
Closes: https://bugs.gentoo.org/766890
Signed-off-by: Lars Wendler <polynomial-c <AT> gentoo.org>

 net/apipa.sh | 94 +++++++++++++++++++++++++++++++++++++++++++-----------------
 1 file changed, 67 insertions(+), 27 deletions(-)

diff --git a/net/apipa.sh b/net/apipa.sh
index 849728b..f3ec534 100644
--- a/net/apipa.sh
+++ b/net/apipa.sh
@@ -1,49 +1,89 @@
 # Copyright (c) 2007-2008 Roy Marples <roy@marples.name>
 # Released under the 2-clause BSD license.
-# shellcheck shell=sh disable=SC1008
 
 apipa_depend()
 {
 	program /sbin/arping /bin/arping
 }
 
-_random()
+_random_bytes_as_int()
 {
-	local r=${RANDOM} # checkbashisms: false positive, we handle it AFTERWARDS
-	if [ -n "${r}" ]; then
-		echo "${r}"
-	else
-		uuidgen | sed -n -e 's/[^[:digit:]]//g' -e 's/\(^.\{1,7\}\).*/\1/p'
-	fi
+	local hex num_bytes="$1"
+
+	# While POSIX does not require that /dev/urandom exist, it is a
+	# de-facto standard. Therefore, the following approach should be
+	# highly portable in practice. In the case of Linux, and unlike BSD
+	# this interface does not block in the event that the CSRNG has not
+	# yet been seeded. Still, this is acceptable because we do not
+	# require a guarantee that the entropy be cryptographically secure.
+	# It's also worth noting that Linux >=5.4 is faster at seeding in
+	# the absence of RDRAND/RDSEED than previous versions were.
+	test -e /dev/urandom &&
+	hex=$(
+		LC_ALL=C tr -dc '[:xdigit:]' < /dev/urandom |
+		dd bs="$(( num_bytes * 2 ))" count=1 2>/dev/null) &&
+	test "${#hex}" = "$(( num_bytes * 2 ))" &&
+	printf '%d\n' "0x${hex}"
+}
+
+_random_apipa_octets()
+{
+	local seed
+
+	# Obtain a highly random 16-bit seed for use by awk's RNG. In the
+	# unlikely event that the seed ends up being empty, awk will seed
+	# based on the time of day, with a granularity of one second.
+	seed=$(_random_bytes_as_int 2)
+
+	# For APIPA (RFC 3927), the 169.254.0.0/16 address block is
+	# reserved. This provides 65534 addresses, having accounted for the
+	# network and broadcast address. Note that we must count from 1.
+	awk "BEGIN {
+		srand($seed)
+		for (i=1; i<65535; i++) print rand() \" \" i
+	}" |
+	sort -k 1,1 -n |
+	POSIXLY_CORRECT=1 awk '{
+		hex = sprintf("%04x",$2)
+		printf("%d %d\n", "0x" substr(hex,1,2), "0x" substr(hex,3,2))
+	}'
 }
 
 apipa_start()
 {
-	local iface="$1" i1= i2= addr= i=0
+	local addr rc
 
-	_exists true || return 1
+	_exists || return
 
 	einfo "Searching for free addresses in 169.254.0.0/16"
 	eindent
 
-	while [ ${i} -lt 64516 ]; do
-		: $(( i1 = (_random % 255) + 1 ))
-		: $(( i2 = (_random % 255) + 1 ))
-
-		addr="169.254.${i1}.${i2}"
-		vebegin "${addr}/16"
-		if ! arping_address "${addr}"; then
-			eval config_${config_index}="\"${addr}/16 broadcast 169.254.255.255\""
-			: $(( config_index -= 1 ))
-			veend 0
-			eoutdent
-			return 0
-		fi
+	exec 3>&1
+	addr=$(
+		_random_apipa_octets |
+		{
+			while read -r i1 i2; do
+				addr="169.254.${i1}.${i2}"
+				vebegin "${addr}/16" >&3
+				if ! arping_address "${addr}" >&3; then
+					printf '%s\n' "${addr}"
+					exit 0
+				fi
+			done
+			exit 1
+		}
+	)
+	rc=$?
+	exec 3>&-
 
-		: $(( i += 1 ))
-	done
+	if [ "$rc" = 0 ]; then
+		eval "config_${config_index}=\"\${addr}/16 broadcast 169.254.255.255\""
+		: $(( config_index -= 1 ))
+		veend 0
+	else
+		eerror "No free address found!"
+	fi
 
-	eerror "No free address found!"
 	eoutdent
-	return 1
+	return "$rc"
 }


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2021-01-24 10:37 Lars Wendler
  0 siblings, 0 replies; 109+ messages in thread
From: Lars Wendler @ 2021-01-24 10:37 UTC (permalink / raw
  To: gentoo-commits

commit:     6632c348cce8be19c7a960cabb2f6f41ec4c6d51
Author:     Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Sun Jan 24 02:49:43 2021 +0000
Commit:     Lars Wendler <polynomial-c <AT> gentoo <DOT> org>
CommitDate: Sun Jan 24 10:21:20 2021 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=6632c348

Use sysfs to obtain the MAC address in net/iproute2.sh

Dispense with the hideous ip-link(8) parser. Instead, collect the MAC
address by reading from the relevant sysfs file. While at it, tidy up
the remainder of the function so that the control flow is easier to
ascertain at a glance. Note that the address will be rendered in upper
case, just as it was before.

Signed-off-by: Kerin Millar <kfm <AT> plushkava.net>
Closes: https://bugs.gentoo.org/766758
Signed-off-by: Lars Wendler <polynomial-c <AT> gentoo.org>

 net/iproute2.sh | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/net/iproute2.sh b/net/iproute2.sh
index 4c32acc..2289587 100644
--- a/net/iproute2.sh
+++ b/net/iproute2.sh
@@ -70,19 +70,16 @@ _set_flag()
 
 _get_mac_address()
 {
-	local mac=$(LC_ALL=C ip link show "${IFACE}" | sed -n \
-		-e 'y/abcdef/ABCDEF/' \
-		-e '/link\// s/^.*\<\(..:..:..:..:..:..\)\>.*/\1/p')
+	local mac=
+	read -r mac < /sys/class/net/"${IFACE}"/address || return 1
 
 	case "${mac}" in
-		00:00:00:00:00:00);;
-		44:44:44:44:44:44);;
-		FF:FF:FF:FF:FF:FF);;
-		"");;
-		*) echo "${mac}"; return 0;;
+		00:00:00:00:00:00) return 1 ;;
+		44:44:44:44:44:44) return 1 ;;
+		ff:ff:ff:ff:ff:ff) return 1 ;;
 	esac
 
-	return 1
+	printf '%s\n' "${mac}" | LC_ALL=C tr '[:lower:]' '[:upper:]'
 }
 
 _set_mac_address()


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2021-01-18 14:40 Lars Wendler
  0 siblings, 0 replies; 109+ messages in thread
From: Lars Wendler @ 2021-01-18 14:40 UTC (permalink / raw
  To: gentoo-commits

commit:     60bd853443f8e01c4309aeb2f3198f959c62cfdf
Author:     Lars Wendler <polynomial-c <AT> gentoo <DOT> org>
AuthorDate: Mon Jan 18 14:21:31 2021 +0000
Commit:     Lars Wendler <polynomial-c <AT> gentoo <DOT> org>
CommitDate: Mon Jan 18 14:26:11 2021 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=60bd8534

net/wpa_supplicant.sh: Removed non-working "need dbus" call

This is a remnant from when netifrc was part of openrc.
After netifrc became it's own standalone project, the call "need dbus"
got caught by the need() function from openrc's sh/openrc-run.sh script
which does a simple echo on every input it receives.

Bug: https://bugs.gentoo.org/622730
Signed-off-by: Lars Wendler <polynomial-c <AT> gentoo.org>

 net/wpa_supplicant.sh | 8 --------
 1 file changed, 8 deletions(-)

diff --git a/net/wpa_supplicant.sh b/net/wpa_supplicant.sh
index d5e2013..3f8e1b1 100644
--- a/net/wpa_supplicant.sh
+++ b/net/wpa_supplicant.sh
@@ -4,14 +4,6 @@
 
 wpa_supplicant_depend()
 {
-	wpas=/usr/sbin/wpa_supplicant
-	[ -x ${wpas} ] || wpas=/sbin/wpa_supplicant
-	if [ -x ${wpas} ]; then
-		program start ${wpas}
-		# bug 345281: if wpa_supplicant is built w/ USE=dbus, we need to start
-		# dbus before we can start wpa_supplicant.
-		${wpas} -h | grep -Fsq DBus && need dbus
-	fi
 	after macnet plug
 	before interface
 	provide wireless


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2021-01-18 13:04 Lars Wendler
  0 siblings, 0 replies; 109+ messages in thread
From: Lars Wendler @ 2021-01-18 13:04 UTC (permalink / raw
  To: gentoo-commits

commit:     72b3a820214fc50d50b8ac0f031491106d8d8634
Author:     Lars Wendler <polynomial-c <AT> gentoo <DOT> org>
AuthorDate: Mon Jan 18 13:01:54 2021 +0000
Commit:     Lars Wendler <polynomial-c <AT> gentoo <DOT> org>
CommitDate: Mon Jan 18 13:01:54 2021 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=72b3a820

net/pppd.sh: Completely overhauled pppd version check

Thanks-to: Kerin Millar <kfm <AT> plushkava.net>
Bug: https://bugs.gentoo.org/729920

Signed-off-by: Lars Wendler <polynomial-c <AT> gentoo.org>

 net/pppd.sh | 24 +++---------------------
 1 file changed, 3 insertions(+), 21 deletions(-)

diff --git a/net/pppd.sh b/net/pppd.sh
index 2182497..22644f2 100644
--- a/net/pppd.sh
+++ b/net/pppd.sh
@@ -23,28 +23,10 @@ requote()
 
 pppd_is_ge_248()
 {
-	local ver_str="$(/usr/sbin/pppd --version 2>&1 | awk '/pppd version/ {print $3}')"
-	local maj_ver="$(echo ${ver_str} | cut -d . -f 1)"
-	local min_ver="$(echo ${ver_str} | cut -d . -f 2)"
-	local patch_ver="$(echo ${ver_str} | cut -d . -f 3)"
+	local ver_str="$(/usr/sbin/pppd --version 2>&1 | awk '/pppd version/ {print $3}' | tr '.' ' ')"
 
-	if [ "${maj_ver}" -gt 2 ] ; then
-		return 0
-	elif [ "${maj_ver}" -eq 2 ] ; then
-		if [ "${min_ver}" -gt 4 ] ; then
-			return 0
-		elif [ "${min_ver}" -eq 4 ] ; then
-			if [ "${patch_ver}" -ge 8 ] ; then
-				return 0
-			else
-				return 1
-			fi
-		else
-			return 1
-		fi
-	else
-		return 1
-	fi
+	# 002004008 is v2.4.8
+	[ "$(printf '%03d' ${ver_str})" -ge 002004008 ]
 }
 
 pppd_pre_start()


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2021-01-18 12:33 Lars Wendler
  0 siblings, 0 replies; 109+ messages in thread
From: Lars Wendler @ 2021-01-18 12:33 UTC (permalink / raw
  To: gentoo-commits

commit:     e08ad3fd1aa2fca27ddf0ad7dfeedb82db4a3666
Author:     Lars Wendler <polynomial-c <AT> gentoo <DOT> org>
AuthorDate: Mon Jan 18 11:44:10 2021 +0000
Commit:     Lars Wendler <polynomial-c <AT> gentoo <DOT> org>
CommitDate: Mon Jan 18 12:32:31 2021 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=e08ad3fd

net/pppd.sh: Improved pppd version check

Ed Wildgoose reported an issue with pppd version check if plugins are
also to be initialized. I this case "pppd --version" also reports the
plugins and that can confuse our original version check.

Bug: https://bugs.gentoo.org/729920
Thanks-to: Ed Wildgoose <ed+git <AT> wildgooses.com>
Closes: https://github.com/gentoo/netifrc/pull/33
Signed-off-by: Lars Wendler <polynomial-c <AT> gentoo.org>

 net/pppd.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/pppd.sh b/net/pppd.sh
index 42495a7..2182497 100644
--- a/net/pppd.sh
+++ b/net/pppd.sh
@@ -23,7 +23,7 @@ requote()
 
 pppd_is_ge_248()
 {
-	local ver_str="$(/usr/sbin/pppd --version 2>&1 | grep -o '[[:digit:]\.]\+')"
+	local ver_str="$(/usr/sbin/pppd --version 2>&1 | awk '/pppd version/ {print $3}')"
 	local maj_ver="$(echo ${ver_str} | cut -d . -f 1)"
 	local min_ver="$(echo ${ver_str} | cut -d . -f 2)"
 	local patch_ver="$(echo ${ver_str} | cut -d . -f 3)"


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2021-01-18 12:33 Lars Wendler
  0 siblings, 0 replies; 109+ messages in thread
From: Lars Wendler @ 2021-01-18 12:33 UTC (permalink / raw
  To: gentoo-commits

commit:     90482eddc3e792809bb220320672816000f727e3
Author:     Lars Wendler <polynomial-c <AT> gentoo <DOT> org>
AuthorDate: Mon Jan 18 11:23:12 2021 +0000
Commit:     Lars Wendler <polynomial-c <AT> gentoo <DOT> org>
CommitDate: Mon Jan 18 12:32:31 2021 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=90482edd

net/l2tp.sh: dash doesn't know "&>/dev/null" redirect

Signed-off-by: Lars Wendler <polynomial-c <AT> gentoo.org>

 net/l2tp.sh | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/net/l2tp.sh b/net/l2tp.sh
index 9644e32..82649b9 100644
--- a/net/l2tp.sh
+++ b/net/l2tp.sh
@@ -34,8 +34,7 @@ _l2tp_eval_props() {
 
 _is_l2tp() {
 	# Check for L2TP support in kernel
-	ip l2tp show session &>/dev/null
-	[ $? -ne 0 ] && return 1
+	ip l2tp show session 2>/dev/null 1>/dev/null || return 1
 
 	eval "$(ip l2tp show session | \
 		awk "match(\$0, /^Session ([0-9]+) in tunnel ([0-9]+)\$/, ret) {sid=ret[1]; tid=ret[2]} 


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2021-01-05 14:27 Lars Wendler
  0 siblings, 0 replies; 109+ messages in thread
From: Lars Wendler @ 2021-01-05 14:27 UTC (permalink / raw
  To: gentoo-commits

commit:     2658f44bb04e117043d1466fcd8e65c1e321db01
Author:     Lars Wendler <polynomial-c <AT> gentoo <DOT> org>
AuthorDate: Tue Jan  5 12:57:51 2021 +0000
Commit:     Lars Wendler <polynomial-c <AT> gentoo <DOT> org>
CommitDate: Tue Jan  5 14:26:56 2021 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=2658f44b

net/pppd.sh: prefer defaultroute-metric

Signed-off-by: Lars Wendler <polynomial-c <AT> gentoo.org>

 net/pppd.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/pppd.sh b/net/pppd.sh
index c6a6a8a..42495a7 100644
--- a/net/pppd.sh
+++ b/net/pppd.sh
@@ -65,10 +65,10 @@ pppd_pre_start()
 		return 0
 	fi
 
-	local link= i= unit="${IFACE#ppp}" opts= routemetric=defaultmetric
+	local link= i= unit="${IFACE#ppp}" opts= routemetric=defaultroute-metric
 
 	# https://github.com/paulusmack/ppp/commit/35e5a569c988b1ff865b02a24d9a727a00db4da9
-	pppd_is_ge_248 && routemetric=defaultroute-metric
+	pppd_is_ge_248 || routemetric=defaultmetric
 
 	# PPP requires a link to communicate over - normally a serial port
 	# PPPoE communicates over Ethernet


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2021-01-05 12:46 Lars Wendler
  0 siblings, 0 replies; 109+ messages in thread
From: Lars Wendler @ 2021-01-05 12:46 UTC (permalink / raw
  To: gentoo-commits

commit:     04e6565b185fd3066822333e1b1932284ec1f6b7
Author:     Lars Wendler <polynomial-c <AT> gentoo <DOT> org>
AuthorDate: Tue Dec 15 19:53:27 2020 +0000
Commit:     Lars Wendler <polynomial-c <AT> gentoo <DOT> org>
CommitDate: Tue Jan  5 12:44:05 2021 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=04e6565b

net/dhcpcd.sh: Remove support for ancient dhcpcd versions

Signed-off-by: Lars Wendler <polynomial-c <AT> gentoo.org>

 net/dhcpcd.sh | 27 +++++++++------------------
 1 file changed, 9 insertions(+), 18 deletions(-)

diff --git a/net/dhcpcd.sh b/net/dhcpcd.sh
index 548a503..e3410d8 100644
--- a/net/dhcpcd.sh
+++ b/net/dhcpcd.sh
@@ -20,7 +20,7 @@ dhcpcd_start()
 	# alter the pidfile's name (#718114)
 	# Save the args into a file so dhcpcd_stop can later re-use the very
 	# same args later.
-	local args= opt= pidfile= opts= new=true argsfile=/run/netifrc_dhcpcd_${IFACE}_args
+	local args= opt= pidfile= opts= argsfile=/run/netifrc_dhcpcd_${IFACE}_args
 	eval args=\$dhcpcd_${IFVAR}
 	[ -z "${args}" ] && args=${dhcpcd}
 	echo "${args}" > ${argsfile}
@@ -30,33 +30,24 @@ dhcpcd_start()
 	eval opts=\$dhcp_${IFVAR}
 	[ -z "${opts}" ] && opts=${dhcp}
 
-	case "$(dhcpcd --version)" in
-		"dhcpcd "[123]*) new=false;;
+	case "$(dhcpcd --version | head -n 1)" in
+		"dhcpcd "[123]*)
+			eerror 'The dhcpcd version is too old. Please upgrade.'
+			return 1
+			;;
 	esac
 
 	# Map some generic options to dhcpcd
 	for opt in ${opts}; do
 		case "${opt}" in
 			nodns)
-				if ${new}; then
-					args="${args} -C resolv.conf"
-				else
-					args="${args} -R"
-				fi
+				args="${args} -C resolv.conf"
 				;;
 			nontp)
-				if ${new}; then
-					args="${args} -C ntp.conf"
-				else
-					args="${args} -N"
-				fi
+				args="${args} -C ntp.conf"
 				;;
 			nonis)
-				if ${new}; then
-					args="${args} -C yp.conf"
-				else
-					args="${args} -Y"
-				fi
+				args="${args} -C yp.conf"
 				;;
 			nogateway) args="${args} -G";;
 			nosendhost) args="${args} -h ''";


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2021-01-05 12:46 Lars Wendler
  0 siblings, 0 replies; 109+ messages in thread
From: Lars Wendler @ 2021-01-05 12:46 UTC (permalink / raw
  To: gentoo-commits

commit:     86879b6bfd4f6d8ce26945a5570e579bf28249f5
Author:     Lars Wendler <polynomial-c <AT> gentoo <DOT> org>
AuthorDate: Tue Dec 15 20:47:15 2020 +0000
Commit:     Lars Wendler <polynomial-c <AT> gentoo <DOT> org>
CommitDate: Tue Jan  5 12:44:05 2021 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=86879b6b

Add code style fixes and missing copyright headers

Signed-off-by: Lars Wendler <polynomial-c <AT> gentoo.org>

 net/dhcpcd.sh | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/net/dhcpcd.sh b/net/dhcpcd.sh
index e3410d8..1e1bbe0 100644
--- a/net/dhcpcd.sh
+++ b/net/dhcpcd.sh
@@ -1,4 +1,5 @@
 # Copyright (c) 2007-2008 Roy Marples <roy@marples.name>
+# Copyright (c) 2020 Gentoo Authors
 # Released under the 2-clause BSD license.
 # shellcheck shell=sh disable=SC1008
 
@@ -55,9 +56,9 @@ dhcpcd_start()
 	done
 
 	# Add our route metric if not given
-	case " $args " in
+	case " ${args} " in
 	*" -m "*) ;;
-	*) [ "${metric:-0}" != 0 ] && args="$args -m $metric";;
+	*) [ "${metric:-0}" != 0 ] && args="${args} -m ${metric}";;
 	esac
 
 	# Bring up DHCP for this interface


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2020-12-15 20:11 Lars Wendler
  0 siblings, 0 replies; 109+ messages in thread
From: Lars Wendler @ 2020-12-15 20:11 UTC (permalink / raw
  To: gentoo-commits

commit:     ee7316e32ecd90384f05f77ddb29abbdf97fa6a2
Author:     Brian Evans <grknight <AT> gentoo <DOT> org>
AuthorDate: Tue Dec 15 19:39:21 2020 +0000
Commit:     Lars Wendler <polynomial-c <AT> gentoo <DOT> org>
CommitDate: Tue Dec 15 20:10:51 2020 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=ee7316e3

net/dhcpcd.sh: Don't run dhcpcd on stop if it's not installed

Bug: https://bugs.gentoo.org/760093
Signed-off-by: Lars Wendler <polynomial-c <AT> gentoo.org>

 net/dhcpcd.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/dhcpcd.sh b/net/dhcpcd.sh
index dcc6817..548a503 100644
--- a/net/dhcpcd.sh
+++ b/net/dhcpcd.sh
@@ -5,7 +5,7 @@
 dhcpcd_depend()
 {
 	after interface
-	program start dhcpcd
+	program dhcpcd
 	provide dhcp
 
 	# We prefer dhcpcd over these


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2020-06-02 21:54 Robin H. Johnson
  0 siblings, 0 replies; 109+ messages in thread
From: Robin H. Johnson @ 2020-06-02 21:54 UTC (permalink / raw
  To: gentoo-commits

commit:     1c846d9d8e23d94046df471c7ccbb88228537188
Author:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
AuthorDate: Tue Jun  2 21:44:26 2020 +0000
Commit:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
CommitDate: Tue Jun  2 21:44:57 2020 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=1c846d9d

net/iw: refactor iw mode setup

Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org>

 net/iw.sh | 37 ++++++++++++++++++++-----------------
 1 file changed, 20 insertions(+), 17 deletions(-)

diff --git a/net/iw.sh b/net/iw.sh
index 82b9ba9..dcdbb79 100644
--- a/net/iw.sh
+++ b/net/iw.sh
@@ -585,27 +585,30 @@ iw_configure()
 	[ -z "${SSID}" ] && eval SSID=\$essid_${IFVAR}
 
 	# Setup ad-hoc mode?
-	eval x=\$mode_${IFVAR}
-	x=${x:-managed}
+	eval _mode=\$mode_${IFVAR}
+	_mode=${_mode:-managed}
 
-	if [ "${x}" = "master" ]; then
-		eerror "Please use hostapd to make this interface an access point"
-		return 1
-	fi
-
-	if [ "${x}" = "ad-hoc" ]; then
-		iw_setup_adhoc
-		return $?
-	fi
-
-	if [ "${x}" != "managed" ]; then
-		eerror "Only managed and ad-hoc are supported"
-		return 1
-	fi
+	case "${_mode}" in
+		master)
+			eerror "Please use hostapd to make this interface an access point"
+			return 1
+			;;
+		ad-hoc|adhoc)
+			iw_setup_adhoc
+			return $?
+			;;
+		managed)
+			# Fall through
+			;;
+		*)
+			eerror "Only managed and ad-hoc are supported"
+			return 1
+			;;
+	esac
 
 	# Has an SSID been forced?
 	if [ -n "${SSID}" ]; then
-		iw_set_mode "${x}"
+		iw_set_mode "${_mode}"
 		iw_associate && return 0
 		[ "${SSID}" = "any" ] && iw_force_preferred && return 0
 


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2020-05-31  6:05 Robin H. Johnson
  0 siblings, 0 replies; 109+ messages in thread
From: Robin H. Johnson @ 2020-05-31  6:05 UTC (permalink / raw
  To: gentoo-commits

commit:     dea30db8062977dc9b8a2c8611f09cf8c891d36f
Author:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
AuthorDate: Sun May 31 05:52:43 2020 +0000
Commit:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
CommitDate: Sun May 31 05:52:47 2020 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=dea30db8

net/ip6to4: partial fix for bug #528314

netifrc has never clearly documented exactly what shell is targeted, and
this bug does not occur on any shell that supports the 'local' keyword.

Reference: https://bugs.gentoo.org/528314
Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org>

 net/ip6to4.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/ip6to4.sh b/net/ip6to4.sh
index 21acd71..6b573d1 100644
--- a/net/ip6to4.sh
+++ b/net/ip6to4.sh
@@ -103,8 +103,8 @@ ip6to4_pre_start()
 
 ip6to4_start()
 {
-	local config_ip6to4=$(service_get_value "config_ip6to4_$IFVAR")
-	local routes_ip6to4=$(service_get_value "routes_ip6to4_$IFVAR")
+	local config_ip6to4="$(service_get_value "config_ip6to4_$IFVAR")"
+	local routes_ip6to4="$(service_get_value "routes_ip6to4_$IFVAR")"
 
 	# Now apply our config
 	eval config_${config_index}=\'"${config_ip6to4}"\'


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2020-05-31  5:42 Robin H. Johnson
  0 siblings, 0 replies; 109+ messages in thread
From: Robin H. Johnson @ 2020-05-31  5:42 UTC (permalink / raw
  To: gentoo-commits

commit:     626cfdad15f9740208807bc436cb3915056c87b4
Author:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
AuthorDate: Sun May 31 05:42:22 2020 +0000
Commit:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
CommitDate: Sun May 31 05:42:22 2020 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=626cfdad

net/iproute2: support containers without /proc/sys/net/ipv4/route/flush

Bug: https://bugs.gentoo.org/648600
Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org>

 net/iproute2.sh | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/net/iproute2.sh b/net/iproute2.sh
index 5f65f1c..ca6c0f8 100644
--- a/net/iproute2.sh
+++ b/net/iproute2.sh
@@ -438,8 +438,18 @@ _iproute2_link_delete() {
 	eend $?
 }
 
+_iproute2_route_flush_supported() {
+	case $FAMILY in
+		-6) p='/proc/sys/net/ipv6/route/flush' ;;
+		-4|*) p='/proc/sys/net/ipv4/route/flush' ;;
+	esac
+	test -f $p
+}
+
 _iproute2_route_flush() {
-	_cmd ip $FAMILY route flush table cache dev "${IFACE}"
+	if _iproute2_route_flush_supported; then
+		_cmd ip $FAMILY route flush table cache dev "${IFACE}"
+	fi
 }
 
 _iproute2_ipv6_tentative_output() {


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2020-05-31  5:29 Robin H. Johnson
  0 siblings, 0 replies; 109+ messages in thread
From: Robin H. Johnson @ 2020-05-31  5:29 UTC (permalink / raw
  To: gentoo-commits

commit:     c0f36e9995b6e07b6691fa0c2d5c3a13223f9815
Author:     Hans Fernhout <hfern <AT> fernhout <DOT> info>
AuthorDate: Sun May 31 05:27:16 2020 +0000
Commit:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
CommitDate: Sun May 31 05:29:36 2020 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=c0f36e99

net/iwd: add iwd helper

Bug: https://bugs.gentoo.org/690808
Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org>

 net/iwd.sh | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 53 insertions(+)

diff --git a/net/iwd.sh b/net/iwd.sh
new file mode 100644
index 0000000..afb5b22
--- /dev/null
+++ b/net/iwd.sh
@@ -0,0 +1,53 @@
+# Original copyright (c) 2007-2009 Roy Marples <roy@marples.name>
+# Released under the 2-clause BSD license.
+
+iwd_depend()
+{
+	need dbus
+	after macnet plug
+	before interface
+	provide wireless
+	after iwconfig
+}
+
+_config_vars="$_config_vars iwd"
+
+iwd_pre_start()
+{
+	local iwds=/usr/libexec/iwd
+	local args= opt= opts=
+	eval opts=\$iwd_${IFVAR}
+
+	#set a "safe" default in case phy was not defined
+	PHY="phy0"
+
+	for opt in ${opts}; do
+		case "${opt}" in
+			phy* )	PHY="${opt}"
+				einfo "Assigned PHY to be ${PHY}"
+				;;
+			*    )	;;
+		esac
+	done
+	ebegin "Starting iwd on ${PHY} and ${IFVAR}"
+	pidfile="/run/iwd-${IFVAR}.pid"
+	start-stop-daemon --start --exec "${iwds}" --pidfile "${pidfile}" --background --verbose --make-pidfile -- -p ${PHY} -i "${IFVAR}"
+	return $?
+}
+
+
+iwd_post_stop()
+{
+	local iwds=/usr/libexec/iwd
+	pidfile="/run/iwd-${IFVAR}.pid"
+	if [ -f ${pidfile} ]; then
+		ebegin "Stopping iwd on ${IFACE}"
+		start-stop-daemon --stop --exec "${iwds}" --pidfile "${pidfile}"
+		eend $?
+	fi
+
+	# If iwd exits uncleanly, we need to remove the stale dir
+	[ -S "/run/iwd/${IFACE}" ] \
+		&& rm -f "/run/iwd/${IFACE}"
+}
+


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2020-05-31  5:29 Robin H. Johnson
  0 siblings, 0 replies; 109+ messages in thread
From: Robin H. Johnson @ 2020-05-31  5:29 UTC (permalink / raw
  To: gentoo-commits

commit:     8d16b31bfc457f03e0e761df19529749ffa1f0d8
Author:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
AuthorDate: Sun May 31 05:29:07 2020 +0000
Commit:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
CommitDate: Sun May 31 05:29:40 2020 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=8d16b31b

net/iwd: ensure program is present

Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org>

 net/iwd.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/iwd.sh b/net/iwd.sh
index afb5b22..e3f64b2 100644
--- a/net/iwd.sh
+++ b/net/iwd.sh
@@ -8,6 +8,7 @@ iwd_depend()
 	before interface
 	provide wireless
 	after iwconfig
+	program iwd
 }
 
 _config_vars="$_config_vars iwd"


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2020-05-31  5:13 Robin H. Johnson
  0 siblings, 0 replies; 109+ messages in thread
From: Robin H. Johnson @ 2020-05-31  5:13 UTC (permalink / raw
  To: gentoo-commits

commit:     dd5a41de524cfdebe47425e70513f95f9937e406
Author:     Lars Wendler <polynomial-c <AT> gentoo <DOT> org>
AuthorDate: Thu May 21 16:35:32 2020 +0000
Commit:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
CommitDate: Sun May 31 05:13:17 2020 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=dd5a41de

net/dhcpcd.sh: fetch pidfile location from dhcpcd

There's a -P switch for this but we also need to take into account the
-4 and -6 switches as they both alter the pidfile's name.

Bug: https://bugs.gentoo.org/718114
Signed-off-by: Lars Wendler <polynomial-c <AT> gentoo.org>
Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org>

 net/dhcpcd.sh | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/net/dhcpcd.sh b/net/dhcpcd.sh
index 0a306b8..c0639e0 100644
--- a/net/dhcpcd.sh
+++ b/net/dhcpcd.sh
@@ -16,9 +16,12 @@ _config_vars="$_config_vars dhcp dhcpcd"
 
 dhcpcd_start()
 {
-	local args= opt= opts= pidfile="/run/dhcpcd-${IFACE}.pid" new=true
+	# check for pidfile after we gathered the user's opts because they can
+	# alter the pidfile's name (#718114)
+	local args= opt= pidfile= opts= new=true
 	eval args=\$dhcpcd_${IFVAR}
 	[ -z "${args}" ] && args=${dhcpcd}
+	pidfile="$(dhcpcd -P ${args} ${IFACE})"
 
 	# Get our options
 	eval opts=\$dhcp_${IFVAR}
@@ -75,7 +78,13 @@ dhcpcd_start()
 
 dhcpcd_stop()
 {
-	local pidfile="/run/dhcpcd-${IFACE}.pid" opts= sig=SIGTERM
+	local args= pidfile= opts= sig=SIGTERM
+
+	# check for pidfile after we gathered the user's opts because they can
+	# alter the pidfile's name (#718114)
+	eval args=\$dhcpcd_${IFVAR}
+	[ -z "${args}" ] && args=${dhcpcd}
+	pidfile="$(dhcpcd -P ${args} ${IFACE})"
 	[ ! -f "${pidfile}" ] && return 0
 
 	ebegin "Stopping dhcpcd on ${IFACE}"


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2020-05-31  5:13 Robin H. Johnson
  0 siblings, 0 replies; 109+ messages in thread
From: Robin H. Johnson @ 2020-05-31  5:13 UTC (permalink / raw
  To: gentoo-commits

commit:     b3848b828d4f1cabe9bda54a0d9da473e5df3e9a
Author:     Lars Wendler <polynomial-c <AT> gentoo <DOT> org>
AuthorDate: Fri May 22 08:09:22 2020 +0000
Commit:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
CommitDate: Sun May 31 05:13:18 2020 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=b3848b82

net/dhcpcd.sh: Put user args into a temp file

So we still use the correct PID even if the user has changed his
configuration between start and stop.

Signed-off-by: Lars Wendler <polynomial-c <AT> gentoo.org>
Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org>

 net/dhcpcd.sh | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/net/dhcpcd.sh b/net/dhcpcd.sh
index c0639e0..dcc6817 100644
--- a/net/dhcpcd.sh
+++ b/net/dhcpcd.sh
@@ -16,11 +16,14 @@ _config_vars="$_config_vars dhcp dhcpcd"
 
 dhcpcd_start()
 {
-	# check for pidfile after we gathered the user's opts because they can
+	# check for pidfile after we gathered the user's args because they can
 	# alter the pidfile's name (#718114)
-	local args= opt= pidfile= opts= new=true
+	# Save the args into a file so dhcpcd_stop can later re-use the very
+	# same args later.
+	local args= opt= pidfile= opts= new=true argsfile=/run/netifrc_dhcpcd_${IFACE}_args
 	eval args=\$dhcpcd_${IFVAR}
 	[ -z "${args}" ] && args=${dhcpcd}
+	echo "${args}" > ${argsfile}
 	pidfile="$(dhcpcd -P ${args} ${IFACE})"
 
 	# Get our options
@@ -78,12 +81,16 @@ dhcpcd_start()
 
 dhcpcd_stop()
 {
-	local args= pidfile= opts= sig=SIGTERM
+	local args= pidfile= opts= sig=SIGTERM argsfile=/run/netifrc_dhcpcd_${IFACE}_args
 
-	# check for pidfile after we gathered the user's opts because they can
+	# check for pidfile after we gathered the user's args because they can
 	# alter the pidfile's name (#718114)
-	eval args=\$dhcpcd_${IFVAR}
-	[ -z "${args}" ] && args=${dhcpcd}
+	if [ -f "${argsfile}" ] ; then
+		args="$(cat ${argsfile})"
+	else
+		eval args=\$dhcpcd_${IFVAR}
+		[ -z "${args}" ] && args=${dhcpcd}
+	fi
 	pidfile="$(dhcpcd -P ${args} ${IFACE})"
 	[ ! -f "${pidfile}" ] && return 0
 
@@ -94,5 +101,6 @@ dhcpcd_stop()
 		*" release "*) dhcpcd -k "${IFACE}" ;;
 		*) dhcpcd -x "${IFACE}" ;;
 	esac
+	[ -f "${argsfile}" ] && rm -f "${argsfile}"
 	eend $?
 }


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2020-01-04  8:06 Robin H. Johnson
  0 siblings, 0 replies; 109+ messages in thread
From: Robin H. Johnson @ 2020-01-04  8:06 UTC (permalink / raw
  To: gentoo-commits

commit:     01704754311ada2c2154f501aebfda50710a185d
Author:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
AuthorDate: Sat Jan  4 08:02:40 2020 +0000
Commit:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
CommitDate: Sat Jan  4 08:02:40 2020 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=01704754

shellcheck: fix Double quote array expansions to avoid re-splitting elements. [SC2068]

Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org>

 net/l2tp.sh | 2 +-
 net/pppd.sh | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/l2tp.sh b/net/l2tp.sh
index 7c5b064..9644e32 100644
--- a/net/l2tp.sh
+++ b/net/l2tp.sh
@@ -81,7 +81,7 @@ _l2tp_get_tunnel_info() {
 
 _ip_l2tp_add() {
 	local e
-	e="$(LC_ALL=C ip l2tp add $@ 2>&1 1>/dev/null)"
+	e="$(LC_ALL=C ip l2tp add "$@" 2>&1 1>/dev/null)"
 	case $e in
 		"")
 			return 0

diff --git a/net/pppd.sh b/net/pppd.sh
index 796722e..e3c4d43 100644
--- a/net/pppd.sh
+++ b/net/pppd.sh
@@ -163,7 +163,7 @@ pppd_pre_start()
 	# We need to flatten the useless array
 	set -- $(_get_array "chat_${IFVAR}")
 	if [ $# != 0 ]; then
-		opts="${opts} connect '$(echo ${chatprog} $@ | sed -e "s:':'\\\\'':g")'"
+		opts="${opts} connect '$(echo ${chatprog} "$@" | sed -e "s:':'\\\\'':g")'"
 	fi
 
 	# Add plugins


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2020-01-04  7:59 Robin H. Johnson
  0 siblings, 0 replies; 109+ messages in thread
From: Robin H. Johnson @ 2020-01-04  7:59 UTC (permalink / raw
  To: gentoo-commits

commit:     9472b0e2fd402819963f492fe9ba37c82c0de277
Author:     Lars Wendler <polynomial-c <AT> gentoo <DOT> org>
AuthorDate: Fri Jan  3 20:30:28 2020 +0000
Commit:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
CommitDate: Sat Jan  4 07:58:21 2020 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=9472b0e2

pppd.sh: ppp-2.4.8 introduced "defaultroute-metric" option

That option name differs from the one we patched into previous pppd releases
so check if we are on >=2.4.8 version and use the correct option name
accordingly

Signed-off-by: Lars Wendler <polynomial-c <AT> gentoo.org>
Closes: https://bugs.gentoo.org/704722
Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org>

 net/pppd.sh | 34 ++++++++++++++++++++++++++++++++--
 1 file changed, 32 insertions(+), 2 deletions(-)

diff --git a/net/pppd.sh b/net/pppd.sh
index 6ca1396..796722e 100644
--- a/net/pppd.sh
+++ b/net/pppd.sh
@@ -21,6 +21,32 @@ requote()
 	printf "'%s' " "$@"
 }
 
+pppd_is_ge_248()
+{
+	local ver_str="$(/usr/sbin/pppd --version 2>&1 | grep -o '[[:digit:]\.]\+')"
+	local maj_ver="$(echo ${ver_str} | cut -d . -f 1)"
+	local min_ver="$(echo ${ver_str} | cut -d . -f 2)"
+	local patch_ver="$(echo ${ver_str} | cut -d . -f 3)"
+
+	if [ "${maj_ver}" -gt 2 ] ; then
+		return 0
+	elif [ "${maj_ver}" -eq 2 ] ; then
+		if [ "${min_ver}" -gt 4 ] ; then
+			return 0
+		elif [ "${min_ver}" -eq 4 ] ; then
+			if [ "${patch_ver}" -ge 8 ] ; then
+				return 0
+			else
+				return 1
+			fi
+		else
+			return 1
+		fi
+	else
+		return 1
+	fi
+}
+
 pppd_pre_start()
 {
 	# Interface has to be called ppp
@@ -39,7 +65,10 @@ pppd_pre_start()
 		return 0
 	fi
 
-	local link= i= unit="${IFACE#ppp}" opts=
+	local link= i= unit="${IFACE#ppp}" opts= routemetric=defaultmetric
+
+	# https://github.com/paulusmack/ppp/commit/35e5a569c988b1ff865b02a24d9a727a00db4da9
+	pppd_is_ge_248 && routemetric=defaultroute-metric
 
 	# PPP requires a link to communicate over - normally a serial port
 	# PPPoE communicates over Ethernet
@@ -76,6 +105,7 @@ pppd_pre_start()
 				return 1
 			;;
 			defaultmetric) hasdefaultmetric=true;;
+			defaultroute-metric) hasdefaultmetric=true;;
 			mtu) hasmtu=true;;
 			mru) hasmru=true;;
 			maxfail) hasmaxfail=true;;
@@ -98,7 +128,7 @@ pppd_pre_start()
 		local m=
 		eval m=\$metric_${IFVAR}
 		[ -z "${m}" ] && : $(( m = metric + $(_ifindex) ))
-		opts="${opts} defaultmetric ${m}"
+		opts="${opts} ${routemetric} ${m}"
 	fi
 	if [ -n "${mtu}" ]; then
 		${hasmtu} || opts="${opts} mtu ${mtu}"


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2019-07-09 19:59 Ben Kohler
  0 siblings, 0 replies; 109+ messages in thread
From: Ben Kohler @ 2019-07-09 19:59 UTC (permalink / raw
  To: gentoo-commits

commit:     43f0190924f8c721ebccd75a2d6b99671905bedf
Author:     Ben Kohler <bkohler <AT> gentoo <DOT> org>
AuthorDate: Tue Jul  9 19:42:16 2019 +0000
Commit:     Ben Kohler <bkohler <AT> gentoo <DOT> org>
CommitDate: Tue Jul  9 19:42:16 2019 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=43f01909

net/*: fix ordering of dhcp clients

We want to prefer dhclient over busybox udhcpc if it's available.  This
commit also adds deps to the other services which will guarantee the
priority dhcpcd > dhclient > pump > udhcpc.

Signed-off-by: Ben Kohler <bkohler <AT> gentoo.org>

 net/dhclient.sh | 3 +++
 net/dhcpcd.sh   | 4 ++--
 net/pump.sh     | 3 +++
 3 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/net/dhclient.sh b/net/dhclient.sh
index fd27308..24c3512 100644
--- a/net/dhclient.sh
+++ b/net/dhclient.sh
@@ -7,6 +7,9 @@ dhclient_depend()
 	after interface
 	program start /sbin/dhclient
 	provide dhcp
+
+	# We prefer dhclient over these
+	after udhcpc pump
 }
 
 _config_vars="$_config_vars dhcp dhcpcd"

diff --git a/net/dhcpcd.sh b/net/dhcpcd.sh
index 1812b45..0a306b8 100644
--- a/net/dhcpcd.sh
+++ b/net/dhcpcd.sh
@@ -8,8 +8,8 @@ dhcpcd_depend()
 	program start dhcpcd
 	provide dhcp
 
-	# We prefer dhcpcd over the others
-	after dhclient pump udhcpc
+	# We prefer dhcpcd over these
+	after udhcpc pump dhclient
 }
 
 _config_vars="$_config_vars dhcp dhcpcd"

diff --git a/net/pump.sh b/net/pump.sh
index 270b37d..864b6cf 100644
--- a/net/pump.sh
+++ b/net/pump.sh
@@ -7,6 +7,9 @@ pump_depend()
 	program /sbin/pump
 	after interface
 	provide dhcp
+
+	# We prefer pump over udhcpc
+	after udhcpc
 }
 
 _config_vars="$_config_vars dhcp pump"


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2019-07-09 19:59 Ben Kohler
  0 siblings, 0 replies; 109+ messages in thread
From: Ben Kohler @ 2019-07-09 19:59 UTC (permalink / raw
  To: gentoo-commits

commit:     3392e908a2e3afceb399a1eb56e05c479aad42da
Author:     Ben Kohler <bkohler <AT> gentoo <DOT> org>
AuthorDate: Tue Jul  9 19:59:09 2019 +0000
Commit:     Ben Kohler <bkohler <AT> gentoo <DOT> org>
CommitDate: Tue Jul  9 19:59:09 2019 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=3392e908

net/iw.sh: minor whitespace fix

Signed-off-by: Ben Kohler <bkohler <AT> gentoo.org>

 net/iw.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/iw.sh b/net/iw.sh
index 5462244..82b9ba9 100644
--- a/net/iw.sh
+++ b/net/iw.sh
@@ -12,8 +12,8 @@ iw_depend()
 	after plug
 	before interface
 	provide wireless
-        # Prefer us over iwconfig
-        after iwconfig
+	# Prefer us over iwconfig
+	after iwconfig
 }
 
 _get_ssid()


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2019-07-09 17:39 Ben Kohler
  0 siblings, 0 replies; 109+ messages in thread
From: Ben Kohler @ 2019-07-09 17:39 UTC (permalink / raw
  To: gentoo-commits

commit:     b8be61112499d3fc1681edb21f240bfeb9eeafe1
Author:     Ben Kohler <bkohler <AT> gentoo <DOT> org>
AuthorDate: Tue Jul  9 17:38:37 2019 +0000
Commit:     Ben Kohler <bkohler <AT> gentoo <DOT> org>
CommitDate: Tue Jul  9 17:38:37 2019 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=b8be6111

net/system.sh: change net-scripts to netifrc in output

Signed-off-by: Ben Kohler <bkohler <AT> gentoo.org>

 net/system.sh | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/net/system.sh b/net/system.sh
index 1f81493..0b65379 100644
--- a/net/system.sh
+++ b/net/system.sh
@@ -34,7 +34,7 @@ _system_dns()
 	[ -z "${servers}" -a -z "${domain}" -a -z "${search}" \
 	-a -z "${sortlist}" -a -z "${options}" ] && return 0
 
-	local buffer="# Generated by net-scripts for interface ${IFACE}\n"
+	local buffer="# Generated by netifrc for interface ${IFACE}\n"
 	[ -n "${domain}" ] && buffer="${buffer}domain ${domain}\n"
 	[ -n "${search}" ] && buffer="${buffer}search ${search}\n"
 
@@ -67,7 +67,7 @@ _system_ntp()
 	[ -z "${servers}" ] && servers=${ntp_servers}
 	[ -z "${servers}" ] && return 0
 
-	buffer="# Generated by net-scripts for interface ${IFACE}\n"
+	buffer="# Generated by netifrc for interface ${IFACE}\n"
 	buffer="${buffer}restrict default noquery notrust nomodify\n"
 	buffer="${buffer}restrict 127.0.0.1\n"
 
@@ -92,7 +92,7 @@ _system_nis()
 
 	[ -z "${servers}" -a -z "${domain}" ] && return 0
 
-	buffer="# Generated by net-scripts for interface ${iface}\n"
+	buffer="# Generated by netifrc for interface ${iface}\n"
 
 	if [ -n "${domain}" ]; then
 		hostname -y "${domain}"


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2019-04-21  4:11 Robin H. Johnson
  0 siblings, 0 replies; 109+ messages in thread
From: Robin H. Johnson @ 2019-04-21  4:11 UTC (permalink / raw
  To: gentoo-commits

commit:     963d378276193c9ae73b889da03960258773d259
Author:     Kirill Semenkov <semenkovk <AT> gmail <DOT> com>
AuthorDate: Mon Dec 17 09:07:18 2018 +0000
Commit:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
CommitDate: Sun Apr 21 04:10:41 2019 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=963d3782

Veth support added

Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org>

 net/veth.sh | 193 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 193 insertions(+)

diff --git a/net/veth.sh b/net/veth.sh
new file mode 100644
index 0000000..d969a14
--- /dev/null
+++ b/net/veth.sh
@@ -0,0 +1,193 @@
+# Copyright (c) 2018 
+# Released under the 2-clause BSD license.
+
+veth_depend()
+{
+	program ip awk
+}
+
+_config_vars="$_config_vars veth"
+
+
+# We need it because _exists() function seeks in /sys/class/net
+_netns_exists()
+{
+	[ -e "/var/run/netns/$1" ]
+}
+
+
+#Creates the network namespace if it doesn't exist. If called with no arguments, does nothing
+#Arguments:
+# $1 - name of the namespace
+_create_ns() {
+
+	vethrc=0
+	for _ns in "$@"; do
+		if [ -z "$_ns" ]; then
+			continue
+		fi
+		if ! _netns_exists "$_ns"; then
+			ip netns add "$_ns" > /dev/null 2>&1
+			vethrc=$(($?+ vethrc)) 
+		fi	
+	done
+	return $vethrc
+}
+
+#Brings a virtual interface up and takes network namespaces into account
+#Arguments: 
+# $1 - name of the interface, required!
+# $2 - namespace
+_bring_peer_up()
+{
+	if [ ! -z "$2" ]; then
+		ip link set "$1" netns "$2" > /dev/null 2>&1
+		vethrc=$?
+		ip netns exec "$2" ip link set dev "$1" up > /dev/null 2>&1
+		vethrc=$(($?+ vethrc)) 
+		return $vethrc
+	fi
+
+	ip link set dev "$1" up > /dev/null 2>&1
+	return $?
+} 
+
+#Brings a virtual interface down and takes network namespaces into account
+#Arguments: 
+# $1 - name of the interface, required!
+# $2 - namespace
+_bring_peer_down()
+{
+
+	if [ ! -z "$2" ]; then
+		ip netns exec "$2" ip link del dev "$1" > /dev/null 2>&1
+		return $? 
+	fi
+
+	ip link del dev "$1" > /dev/null 2>&1
+	return $?
+}
+
+
+#Create and bring the veth pair up
+_create_peers()
+{
+	local peers
+	peers="$(_get_array "veth_${IFVAR}")"
+
+	# veth has exactly two peers.
+	# For POSIX compatibility we evade bash arrays
+	local npeers
+	npeers=$(echo "$peers" | awk '{print NF}')
+	if [ "$npeers" != 2 ]; then
+		eerror "veth interface must have exactly two peers"
+		return 1
+	fi
+
+	for x in ${peers}; do
+		if _exists "$x" ; then
+			eerror "Interface $x already exists. Can't continue"
+			return 1
+		fi		
+	done
+
+	local netns1
+	netns1="$(_get_array "veth_${IFVAR}_ns1")"
+	local netns2
+	netns2="$(_get_array "veth_${IFVAR}_ns2")"
+
+	local vethrc
+
+	if ! _create_ns "$netns1" "$netns2"
+	then
+		eerror "Can't create namespaces: $netns1 $netns2"
+		return 1
+	fi
+
+	local peer1
+	peer1=$(echo "$peers" | awk '{print $1}')
+	local peer2
+	peer2=$(echo "$peers" | awk '{print $2}')
+
+	
+	ip link add "$peer1" type veth peer name "$peer2" > /dev/null 2>&1 || {
+		eerror "Can't create veth peer $peer1 or $peer2"
+		return 1
+	}
+
+
+	if ! _bring_peer_up "$peer1" "$netns1"
+	then
+		eerror "Can't bring the veth peer $peer1 up"
+		return 1
+
+	fi
+	if ! _bring_peer_up "$peer2" "$netns2"
+	then
+		eerror "Can't bring the veth peer $peer2 up"
+		return 1
+
+	fi
+
+	return 0
+}
+
+# Create peers and namespaces
+veth_pre_start()
+{
+	local itype
+	eval itype=\$type_${IFVAR}
+	if [ "$itype" != "veth" ]; then
+		return 0
+	fi
+
+	local createveth
+	eval createveth=\$veth_${IFVAR}_create
+	if [ "$createveth" == "no" ]; then
+		return 0
+	fi
+
+	type ip >/dev/null 2>&1 || {
+		eerror "iproute2 nor found, please install iproute2"
+		return 1
+	}
+
+	if ! _create_peers
+	then
+		return 1
+	fi
+
+
+	return 0
+}
+
+#Delete the veth pair
+#We don't delete namespaces because someone may use them for some purposes
+veth_post_stop()
+{
+	local itype
+	eval itype=\$type_${IFVAR}
+	if [ "$itype" != "veth" ]; then
+		return 0
+	fi
+
+	local createveth
+	eval createveth=\$veth_${IFVAR}_create
+	if [ "$createveth" == "no" ]; then
+		return 0
+	fi
+
+	local peers
+	peers="$(_get_array "veth_${IFVAR}")"
+	local first
+	first=$(echo "$peers" | awk '{print $1}')
+	local netns1
+	netns1="$(_get_array "veth_${IFVAR}_ns1")"
+
+	if ! _bring_peer_down "$first" "$netns1"
+	then
+		eerror "Can't delete the veth pair ${IFVAR}"
+		eend 1
+	fi
+	return 0
+}


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2018-07-12  6:25 Robin H. Johnson
  0 siblings, 0 replies; 109+ messages in thread
From: Robin H. Johnson @ 2018-07-12  6:25 UTC (permalink / raw
  To: gentoo-commits

commit:     86911bfd4ee00041273ee8439978e64a2163f3e2
Author:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
AuthorDate: Thu Jul 12 06:24:36 2018 +0000
Commit:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
CommitDate: Thu Jul 12 06:24:36 2018 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=86911bfd

net/wireguard: import from ebuild

This improves non-maintainer commit
66af4525ff3a4530a165443f459134f1f60283f8 to include correct author
attribution for net/wireguard.sh, as traced & discussed with the
upstream author.

Original-Author: Joakim Sindholt <opensource <AT> zhasha.com>
Signed-off-by: Jason A. Donenfeld <zx2c4 <AT> gentoo.org>
Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org>

 net/wireguard.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/wireguard.sh b/net/wireguard.sh
index efa45b0..8af76ca 100644
--- a/net/wireguard.sh
+++ b/net/wireguard.sh
@@ -1,4 +1,5 @@
-# Copyright (c) 2016 Gentoo Foundation
+# Copyright (c) 2016 Joakim Sindholt (zhasha)
+# Copyright (c) 2018 Jason A. Donenfeld,
 # Released under the 2-clause BSD license.
 
 wireguard_depend()


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2018-07-10 21:11 Jason Donenfeld
  0 siblings, 0 replies; 109+ messages in thread
From: Jason Donenfeld @ 2018-07-10 21:11 UTC (permalink / raw
  To: gentoo-commits

commit:     66af4525ff3a4530a165443f459134f1f60283f8
Author:     Jason A. Donenfeld <zx2c4 <AT> gentoo <DOT> org>
AuthorDate: Sun May 27 23:56:51 2018 +0000
Commit:     Jason Donenfeld <zx2c4 <AT> gentoo <DOT> org>
CommitDate: Tue Jul 10 21:10:22 2018 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=66af4525

net/wireguard: import from ebuild

Signed-off-by: Jason A. Donenfeld <zx2c4 <AT> gentoo.org>

 net/Makefile     |  2 +-
 net/wireguard.sh | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 54 insertions(+), 1 deletion(-)

diff --git a/net/Makefile b/net/Makefile
index 347e89c..390f8d8 100644
--- a/net/Makefile
+++ b/net/Makefile
@@ -14,7 +14,7 @@ INC-Linux=	adsl.sh apipa.sh arping.sh bonding.sh br2684ctl.sh bridge.sh \
 		ccwgroup.sh clip.sh ethtool.sh iproute2.sh ifplugd.sh ip6to4.sh \
 		ipppd.sh iwconfig.sh netplugd.sh pppd.sh pump.sh tuntap.sh udhcpc.sh \
 		vlan.sh macvlan.sh ip6rd.sh firewalld.sh dummy.sh hsr.sh l2tp.sh \
-		iw.sh
+		iw.sh wireguard.sh
 
 SRCS-NetBSD= ifwatchd.sh.in
 INC-NetBSD=	ifwatchd.sh

diff --git a/net/wireguard.sh b/net/wireguard.sh
new file mode 100644
index 0000000..efa45b0
--- /dev/null
+++ b/net/wireguard.sh
@@ -0,0 +1,53 @@
+# Copyright (c) 2016 Gentoo Foundation
+# Released under the 2-clause BSD license.
+
+wireguard_depend()
+{
+	program /usr/bin/wg
+	after interface
+}
+
+wireguard_pre_start()
+{
+	[ "${IFACE#wg}" != "$IFACE" ] || return 0
+
+	ip link delete dev "$IFACE" type wireguard 2>/dev/null
+	ebegin "Creating WireGuard interface $IFACE"
+	if ! ip link add dev "$IFACE" type wireguard; then
+		e=$?
+		eend $e
+		return $e
+	fi
+	eend 0
+
+	ebegin "Configuring WireGuard interface $IFACE"
+	set -- $(_get_array "wireguard_$IFVAR")
+	if [ $# -eq 1 ]; then
+		/usr/bin/wg setconf "$IFACE" "$1"
+	else
+		eval /usr/bin/wg set "$IFACE" "$@"
+	fi
+	e=$?
+	if [ $e -eq 0 ]; then
+		_up
+		e=$?
+		if [ $e -eq 0 ]; then
+			eend $e
+			return $e
+		fi
+	fi
+	ip link delete dev "$IFACE" type wireguard 2>/dev/null
+	eend $e
+	return $e
+}
+
+wireguard_post_stop()
+{
+	[ "${IFACE#wg}" != "$IFACE" ] || return 0
+
+	ebegin "Removing WireGuard interface $IFACE"
+	ip link delete dev "$IFACE" type wireguard
+	e=$?
+	eend $e
+	return $e
+}


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2018-01-21 21:59 Robin H. Johnson
  0 siblings, 0 replies; 109+ messages in thread
From: Robin H. Johnson @ 2018-01-21 21:59 UTC (permalink / raw
  To: gentoo-commits

commit:     1b52dd84770eab44b5590ecb5cd386eca36f9b34
Author:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
AuthorDate: Sun Jan 21 21:50:38 2018 +0000
Commit:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
CommitDate: Sun Jan 21 21:50:42 2018 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=1b52dd84

net/iproute2: improve DAD tentative wait/output.

If an interface had dad_timeout=0 set, then the wait loop output is
confusing. Skip it entirely, printing a useful message:
> Not waiting for DAD timeout on tentative IPv6 addresses (per conf.d/net dad_timeout)

Refactor the DAD tentantive conditionals for ease of debugging.

Bug 636846 suggests that some kernels are still showing tentative
addresses despite sysctls being set.

Bug: https://bugs.gentoo.org/636846
Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org>

 net/iproute2.sh | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/net/iproute2.sh b/net/iproute2.sh
index d33ee11..2d83534 100644
--- a/net/iproute2.sh
+++ b/net/iproute2.sh
@@ -441,9 +441,13 @@ _iproute2_route_flush() {
 	_cmd ip $FAMILY route flush table cache dev "${IFACE}"
 }
 
+_iproute2_ipv6_tentative_output() {
+	LC_ALL=C ip -family inet6 addr show dev ${IFACE} tentative
+}
+
 _iproute2_ipv6_tentative()
 {
-	[ -n "$(LC_ALL=C ip -family inet6 addr show dev ${IFACE} tentative)" ] && return 0
+	[ -n "$(_iproute2_ipv6_tentative_output)" ] && return 0
 
 	return 1
 }
@@ -462,11 +466,15 @@ iproute2_post_start()
 
 	# This block must be non-fatal, otherwise the interface will not be
 	# recorded as starting, and later services may be blocked.
-	if _iproute2_ipv6_tentative; then
-		if [ "$EINFO_VERBOSE" = "yes" ]; then
-			veinfo "Found tentative addresses:"
-			LC_ALL=C ip -family inet6 addr show dev ${IFACE} tentative
-		fi
+	_iproute2_ipv6_tentative ; ret_tentative=$?
+	if [ $ret_tentative -eq 0 -a "$EINFO_VERBOSE" = "yes" ]; then
+		veinfo "Found tentative addresses:"
+		_iproute2_ipv6_tentative_output
+	fi
+	# This could be nested, but the conditionals are very deep at that point.
+	if [ $ret_tentative -eq 0 -a $_dad_timeout -le 0 ]; then
+		einfo "Not waiting for DAD timeout on tentative IPv6 addresses (per conf.d/net dad_timeout)"
+	elif [ $ret_tentative -eq 0 ]; then
 		einfon "Waiting for tentative IPv6 addresses to complete DAD (${_dad_timeout} seconds) "
 		while [ $_dad_timeout -gt 0 ]; do
 			_iproute2_ipv6_tentative || break


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2017-11-27 20:22 Robin H. Johnson
  0 siblings, 0 replies; 109+ messages in thread
From: Robin H. Johnson @ 2017-11-27 20:22 UTC (permalink / raw
  To: gentoo-commits

commit:     986cf37b69299d2aa9d4eb678a2798b0bc021bc0
Author:     Henning Schild <henning <AT> hennsch <DOT> de>
AuthorDate: Fri Nov 24 13:02:58 2017 +0000
Commit:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
CommitDate: Mon Nov 27 20:22:06 2017 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=986cf37b

net/wpa_supplicant: change how we match wired connections

Before that patch you needed to write "-Dwired" in /etc/conf.d/net.
Where in fact "-D wired" or even a string with multiple spaces would be
ok for wpa_supplicant.

Signed-off-by: Henning Schild <henning <AT> hennsch.de>
Closes: https://github.com/gentoo/netifrc/pull/27
Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org>
(cherry picked from commit f5b82067ee5ce9badf328c92723e36a86588e74d)

 net/wpa_supplicant.sh | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/net/wpa_supplicant.sh b/net/wpa_supplicant.sh
index c487238..5df662a 100644
--- a/net/wpa_supplicant.sh
+++ b/net/wpa_supplicant.sh
@@ -63,10 +63,11 @@ wpa_supplicant_pre_start()
 	eval opts=\$wpa_supplicant_${IFVAR}
 	eval cliopts=\$wpa_cli_${IFVAR}
 	[ -z "${cliopts}" ] && cliopts=${wpa_cli}
-	case " ${opts} " in
-		*" -Dwired "*) wireless=false;;
-		*) _is_wireless || return 0;;
-	esac
+	if echo " $opts " | grep -q " \-D[[:space:]]wired "; then
+		wireless=false
+	else
+		_is_wireless || return 0
+	fi
 
 	# We don't configure wireless if we're being called from
 	# the background unless we're not currently running


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2017-11-27 20:22 Robin H. Johnson
  0 siblings, 0 replies; 109+ messages in thread
From: Robin H. Johnson @ 2017-11-27 20:22 UTC (permalink / raw
  To: gentoo-commits

commit:     7f6061ca070918204aad75330ea7c32aff3e2a9c
Author:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
AuthorDate: Mon Nov 27 20:19:02 2017 +0000
Commit:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
CommitDate: Mon Nov 27 20:22:29 2017 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=7f6061ca

net/wpa_supplicant: rewrite -D detection

Commit 38b9fac9 per Henning Schild's submission PR#27 improved
wpa_supplicant driver detection, but had room for improvements as
discussed in the comment thread. Includes detection of -N for future
multiple interface work.

Bug: https://github.com/gentoo/netifrc/pull/27
CC: Henning Schild <henning <AT> hennsch.de>
Thanks-To: Henning Schild <henning <AT> hennsch.de>
Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org>

 net/wpa_supplicant.sh | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/net/wpa_supplicant.sh b/net/wpa_supplicant.sh
index 5df662a..594a157 100644
--- a/net/wpa_supplicant.sh
+++ b/net/wpa_supplicant.sh
@@ -63,11 +63,21 @@ wpa_supplicant_pre_start()
 	eval opts=\$wpa_supplicant_${IFVAR}
 	eval cliopts=\$wpa_cli_${IFVAR}
 	[ -z "${cliopts}" ] && cliopts=${wpa_cli}
-	if echo " $opts " | grep -q " \-D[[:space:]]wired "; then
-		wireless=false
-	else
-		_is_wireless || return 0
-	fi
+	set -- $opts
+	local opt_D
+	while [ ${#*} -gt 0 ]; do
+		local opt=$1 ; shift
+		case "$opt" in
+			-D) opt_D=${1} ; shift ;;
+			-D*) opt_D=${opt#-D} ;;
+			-N) eerror "Cannot use -N to wpa_supplicant for \$wpa_supplicant_${IFVAR}!" && return 1 ;;
+		esac
+	done
+	case "$opt_D" in
+		roboswitch) wireless=false ;;
+		wired) wireless=false ;;
+		*) _is_wireless || return 0;;
+	esac
 
 	# We don't configure wireless if we're being called from
 	# the background unless we're not currently running


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2017-11-14 20:48 Robin H. Johnson
  0 siblings, 0 replies; 109+ messages in thread
From: Robin H. Johnson @ 2017-11-14 20:48 UTC (permalink / raw
  To: gentoo-commits

commit:     af56301d75988a12c5347b8e9db6812d36f157b4
Author:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
AuthorDate: Tue Nov 14 19:16:28 2017 +0000
Commit:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
CommitDate: Tue Nov 14 19:16:28 2017 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=af56301d

net/iproute2: refactor veinfo+CMD to _cmd helper.

Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org>

 net/iproute2.sh | 77 +++++++++++++++++++++++++--------------------------------
 1 file changed, 34 insertions(+), 43 deletions(-)

diff --git a/net/iproute2.sh b/net/iproute2.sh
index 7dea195..6d7a3b5 100644
--- a/net/iproute2.sh
+++ b/net/iproute2.sh
@@ -8,16 +8,21 @@ iproute2_depend()
 	after ifconfig
 }
 
+# This helper exists for the common pattern of 'veinfo $CMD ; $CMD'
+_cmd()
+{
+	veinfo "${@}"
+	"${@}"
+}
+
 _up()
 {
-	veinfo ip link set dev "${IFACE}" up
-	ip link set dev "${IFACE}" up
+	_cmd ip link set dev "${IFACE}" up
 }
 
 _down()
 {
-	veinfo ip link set dev "${IFACE}" down
-	ip link set dev "${IFACE}" down
+	_cmd ip link set dev "${IFACE}" down
 }
 
 _exists()
@@ -59,8 +64,7 @@ _set_flag()
 		flag=${flag#-}
 		opt="off"
 	fi
-	veinfo ip link set dev "${IFACE}" "${flag}" "${opt}"
-	ip link set dev "${IFACE}" "${flag}" "${opt}"
+	_cmd ip link set dev "${IFACE}" "${flag}" "${opt}"
 }
 
 _get_mac_address()
@@ -82,8 +86,7 @@ _get_mac_address()
 
 _set_mac_address()
 {
-	veinfo ip link set dev "${IFACE}" address "$1"
-	ip link set dev "${IFACE}" address "$1"
+	_cmd ip link set dev "${IFACE}" address "$1"
 }
 
 _get_inet_addresses()
@@ -102,8 +105,7 @@ _get_inet_address()
 _add_address()
 {
 	if [ "$1" = "127.0.0.1/8" -a "${IFACE}" = "lo" ]; then
-		veinfo ip addr add "$@" dev "${IFACE}" 2>/dev/null
-		ip addr add "$@" dev "${IFACE}" 2>/dev/null
+		_cmd ip addr add "$@" dev "${IFACE}" 2>/dev/null
 		return 0
 	fi
 	local x
@@ -179,8 +181,7 @@ _add_address()
 
 	# This must appear on a single line, continuations cannot be used
 	set -- "${address}${netmask:+/}${netmask}" ${peer:+peer} ${peer} ${broadcast:+broadcast} ${broadcast} ${anycast:+anycast} ${anycast} ${label:+label} ${label} ${scope:+scope} ${scope} dev "${IFACE}" ${valid_lft:+valid_lft} $valid_lft ${preferred_lft:+preferred_lft} $preferred_lft $confflaglist
-	veinfo ip addr add "$@"
-	ip addr add "$@"
+	_cmd ip addr add "$@"
 	rc=$?
 	# Check return code in some cases
 	if [ $rc -ne 0 ]; then
@@ -251,8 +252,7 @@ _add_route()
 		fgrep -sq "${cmd%% *}"
 	route_already_exists=$?
 
-	veinfo ip ${family} route append ${cmd} dev "${IFACE}"
-	ip ${family} route append ${cmd} dev "${IFACE}"
+	_cmd ip ${family} route append ${cmd} dev "${IFACE}"
 	rc=$?
 	# Check return code in some cases
 	if [ $rc -ne 0 ]; then
@@ -278,13 +278,10 @@ _add_route()
 
 _delete_addresses()
 {
-	veinfo ip addr flush dev "${IFACE}" scope global 2>/dev/null
-	ip addr flush dev "${IFACE}" scope global 2>/dev/null
-	veinfo ip addr flush dev "${IFACE}" scope site 2>/dev/null
-	ip addr flush dev "${IFACE}" scope site 2>/dev/null
+	_cmd ip addr flush dev "${IFACE}" scope global 2>/dev/null
+	_cmd ip addr flush dev "${IFACE}" scope site 2>/dev/null
 	if [ "${IFACE}" != "lo" ]; then
-		veinfo ip addr flush dev "${IFACE}" scope host 2>/dev/null
-		ip addr flush dev "${IFACE}" scope host 2>/dev/null
+		_cmd ip addr flush dev "${IFACE}" scope host 2>/dev/null
 	fi
 	return 0
 }
@@ -294,10 +291,10 @@ _has_carrier()
 	LC_ALL=C ip link show dev "${IFACE}" | grep -q "LOWER_UP"
 }
 
+# Used by iproute2, ip6rd & ip6to4
 _tunnel()
 {
-	veinfo ip tunnel "$@"
-	ip tunnel "$@"
+	_cmd ip $FAMILY tunnel "$@"
 	rc=$?
 	# TODO: check return code in some cases
 	return $rc
@@ -349,8 +346,7 @@ _iproute2_policy_routing()
 				_ip_rule_runner -4 add "${rules}"
 			fi
 		fi
-		veinfo ip -4 route flush table cache dev "${IFACE}"
-		ip -4 route flush table cache dev "${IFACE}"
+		FAMILY="-4" IFACE="${IFACE}" _iproute2_route_flush
 	fi
 
 	# Kernel may not have IPv6 built in
@@ -365,8 +361,7 @@ _iproute2_policy_routing()
 				_ip_rule_runner -6 add "${rules}"
 			fi
 		fi
-		veinfo ip -6 route flush table cache dev "${IFACE}"
-		ip -6 route flush table cache dev "${IFACE}"
+		FAMILY="-6" IFACE="${IFACE}" _iproute2_route_flush
 	fi
 }
 
@@ -388,8 +383,7 @@ iproute2_pre_start()
 		esac
 
 		ebegin "Creating tunnel ${IFVAR}"
-		veinfo ip ${ipproto} tunnel add ${tunnel} name "${IFACE}"
-		ip ${ipproto} tunnel add ${tunnel} name "${IFACE}"
+		_cmd ip ${ipproto} tunnel add ${tunnel} name "${IFACE}"
 		eend $? || return 1
 		_up
 	fi
@@ -404,8 +398,7 @@ iproute2_pre_start()
 		esac
 
 		ebegin "Creating interface ${IFVAR}"
-		veinfo ip ${ipproto} link add "${IFACE}" ${link}
-		ip ${ipproto} link add "${IFACE}" ${link}
+		_cmd ip ${ipproto} link add "${IFACE}" ${link}
 		eend $? || return 1
 		_up
 	fi
@@ -414,16 +407,14 @@ iproute2_pre_start()
 	local mtu=
 	eval mtu=\$mtu_${IFVAR}
 	if [ -n "${mtu}" ]; then
-		veinfo ip link set dev "${IFACE}" mtu "${mtu}"
-		ip link set dev "${IFACE}" mtu "${mtu}"
+		_cmd ip link set dev "${IFACE}" mtu "${mtu}"
 	fi
 
 	# TX Queue Length support
 	local len=
 	eval len=\$txqueuelen_${IFVAR}
 	if [ -n "${len}" ]; then
-		veinfo ip link set dev "${IFACE}" txqueuelen "${len}"
-		ip link set dev "${IFACE}" txqueuelen "${len}"
+		_cmd ip link set dev "${IFACE}" txqueuelen "${len}"
 	fi
 
 	local policyroute_order=
@@ -436,18 +427,20 @@ iproute2_pre_start()
 
 _iproute2_tunnel_delete() {
 	ebegin "Destroying tunnel $1"
-	veinfo ip $2 tunnel del "$1"
-	ip $2 tunnel del "$1"
+	_tunnel del "$1"
 	eend $?
 }
 
 _iproute2_link_delete() {
 	ebegin "Destroying interface $1"
-	veinfo ip link del dev "$1"
-	ip link del dev "$1"
+	_cmd ip $FAMILY link del dev "$1"
 	eend $?
 }
 
+_iproute2_route_flush() {
+	_cmd ip $FAMILY route flush table cache dev "${IFACE}"
+}
+
 _iproute2_ipv6_tentative()
 {
 	[ -n "$(LC_ALL=C ip -family inet6 addr show dev ${IFACE} tentative)" ] && return 0
@@ -502,8 +495,7 @@ iproute2_post_stop()
 
 		# Only do something if the interface actually exist
 		if _exists; then
-			veinfo ip -4 route flush table cache dev "${IFACE}"
-			ip -4 route flush table cache dev "${IFACE}"
+			FAMILY="-4" IFACE="${IFACE}" _iproute2_route_flush
 		fi
 	fi
 
@@ -517,8 +509,7 @@ iproute2_post_stop()
 
 		# Only do something if the interface actually exist
 		if _exists; then
-			veinfo ip -6 route flush table cache dev "${IFACE}"
-			ip -6 route flush table cache dev "${IFACE}"
+			FAMILY="-6" IFACE="${IFACE}" _iproute2_route_flush
 		fi
 	fi
 
@@ -527,7 +518,7 @@ iproute2_post_stop()
 		if [ -n "$(ip tunnel show "${IFACE}" 2>/dev/null)" ]; then
 			_iproute2_tunnel_delete "${IFACE}"
 		elif  [ -n "$(ip -6 tunnel show "${IFACE}" 2>/dev/null)" ]; then
-			_iproute2_tunnel_delete "${IFACE}" -6
+			FAMILY=-6 _iproute2_tunnel_delete "${IFACE}"
 		fi
 
 		[ -n "$(ip link show "${IFACE}" type gretap 2>/dev/null)" ] && _iproute2_link_delete "${IFACE}"


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2017-11-14 20:48 Robin H. Johnson
  0 siblings, 0 replies; 109+ messages in thread
From: Robin H. Johnson @ 2017-11-14 20:48 UTC (permalink / raw
  To: gentoo-commits

commit:     5496033be61f97755627ba1da45421a2a635c09e
Author:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
AuthorDate: Tue Nov 14 20:41:27 2017 +0000
Commit:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
CommitDate: Tue Nov 14 20:41:27 2017 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=5496033b

net/iproute2: clarify "waiting for IPv6 addresses"

Per bug 636846, a user thought that "waiting for IPv6 addresses" was
SLAAC (Stateless Autoconfiguration). In Linux, SLAAC is entirely
kernel-side, and the waiting is actually for DAD (duplicate address
detection) on link-local IPv6 addresses.

- Improve the message to include both DAD & tentative.
- If --verbose is used, print the tentative addresses.

If either of the accept_dad sysctls are set to zero, then the kernel
should NOT mark any addresses as tentative.
- net.ipv6.conf.all.accept_dad=0
- net.ipv6.conf.$IFACE.accept_dad=0

Bug: https://bugs.gentoo.org/636846
Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org>

 net/iproute2.sh | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/net/iproute2.sh b/net/iproute2.sh
index 6d7a3b5..d33ee11 100644
--- a/net/iproute2.sh
+++ b/net/iproute2.sh
@@ -463,7 +463,11 @@ iproute2_post_start()
 	# This block must be non-fatal, otherwise the interface will not be
 	# recorded as starting, and later services may be blocked.
 	if _iproute2_ipv6_tentative; then
-		einfon "Waiting for IPv6 addresses (${_dad_timeout} seconds) "
+		if [ "$EINFO_VERBOSE" = "yes" ]; then
+			veinfo "Found tentative addresses:"
+			LC_ALL=C ip -family inet6 addr show dev ${IFACE} tentative
+		fi
+		einfon "Waiting for tentative IPv6 addresses to complete DAD (${_dad_timeout} seconds) "
 		while [ $_dad_timeout -gt 0 ]; do
 			_iproute2_ipv6_tentative || break
 			sleep 1


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2017-10-21 20:56 Robin H. Johnson
  0 siblings, 0 replies; 109+ messages in thread
From: Robin H. Johnson @ 2017-10-21 20:56 UTC (permalink / raw
  To: gentoo-commits

commit:     552884f6eb4308109421cc7f90b6b675b82e48b7
Author:     stkchp <s <AT> tkch <DOT> net>
AuthorDate: Tue Oct 17 03:04:31 2017 +0000
Commit:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
CommitDate: Thu Oct 19 13:30:24 2017 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=552884f6

net/iproute2: delete IPv6 tunnel.

 net/iproute2.sh | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/net/iproute2.sh b/net/iproute2.sh
index d5612ab..7dea195 100644
--- a/net/iproute2.sh
+++ b/net/iproute2.sh
@@ -434,6 +434,13 @@ iproute2_pre_start()
 	return 0
 }
 
+_iproute2_tunnel_delete() {
+	ebegin "Destroying tunnel $1"
+	veinfo ip $2 tunnel del "$1"
+	ip $2 tunnel del "$1"
+	eend $?
+}
+
 _iproute2_link_delete() {
 	ebegin "Destroying interface $1"
 	veinfo ip link del dev "$1"
@@ -518,11 +525,11 @@ iproute2_post_stop()
 	# Don't delete sit0 as it's a special tunnel
 	if [ "${IFACE}" != "sit0" ]; then
 		if [ -n "$(ip tunnel show "${IFACE}" 2>/dev/null)" ]; then
-			ebegin "Destroying tunnel ${IFACE}"
-			veinfo ip tunnel del "${IFACE}"
-			ip tunnel del "${IFACE}"
-			eend $?
+			_iproute2_tunnel_delete "${IFACE}"
+		elif  [ -n "$(ip -6 tunnel show "${IFACE}" 2>/dev/null)" ]; then
+			_iproute2_tunnel_delete "${IFACE}" -6
 		fi
+
 		[ -n "$(ip link show "${IFACE}" type gretap 2>/dev/null)" ] && _iproute2_link_delete "${IFACE}"
 		[ -n "$(ip link show "${IFACE}" type vxlan 2>/dev/null)" ] && _iproute2_link_delete "${IFACE}"
 	fi


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2017-06-09 23:59 Robin H. Johnson
  0 siblings, 0 replies; 109+ messages in thread
From: Robin H. Johnson @ 2017-06-09 23:59 UTC (permalink / raw
  To: gentoo-commits

commit:     90f9fd0cee3284767d42d314683e22eb0613c55f
Author:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
AuthorDate: Fri Jun  9 23:58:49 2017 +0000
Commit:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
CommitDate: Fri Jun  9 23:58:49 2017 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=90f9fd0c

iproute2: apply ipproto=-6 cleanup.

Case statements for easier reading of ipproto='-6' choice.

Fixes: https://github.com/gentoo/netifrc/pull/24/files/60714158b4536d1e5694ec8a45e2cfac56202027#r98297184
Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org>

 net/iproute2.sh | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/net/iproute2.sh b/net/iproute2.sh
index 55c9592..d5612ab 100644
--- a/net/iproute2.sh
+++ b/net/iproute2.sh
@@ -381,10 +381,11 @@ iproute2_pre_start()
 		# be passed to iproute2 during tunnel creation.
 		# state 'any' does not exist for IPv4
 		local ipproto=''
-		[ "${tunnel##mode ipip6}" != "${tunnel}" ] && ipproto='-6'
-		[ "${tunnel##mode ip6ip6}" != "${tunnel}" ] && ipproto='-6'
-		[ "${tunnel##mode ip6gre}" != "${tunnel}" ] && ipproto='-6'
-		[ "${tunnel##mode any}" != "${tunnel}" ] && ipproto='-6'
+		case $tunnel in
+			*mode\ ipip6*) ipproto='-6' ;;
+			*mode\ ip6*) ipproto='-6' ;;
+			*mode\ any*) ipproto='-6' ;;
+		esac
 
 		ebegin "Creating tunnel ${IFVAR}"
 		veinfo ip ${ipproto} tunnel add ${tunnel} name "${IFACE}"
@@ -396,9 +397,11 @@ iproute2_pre_start()
 	eval link=\$iplink_${IFVAR}
 	if [ -n "${link}" ]; then
 		local ipproto=''
-		[ "${tunnel##mode ip6gre}" != "${tunnel}" ] && ipproto='-6'
-		[ "${tunnel##mode ip6gretap}" != "${tunnel}" ] && ipproto='-6'
-		[ "${tunnel##mode ip6tnl}" != "${tunnel}" ] && ipproto='-6'
+		case $tunnel in
+			*mode\ ipip6*) ipproto='-6' ;;
+			*mode\ ip6*) ipproto='-6' ;;
+			*mode\ any*) ipproto='-6' ;;
+		esac
 
 		ebegin "Creating interface ${IFVAR}"
 		veinfo ip ${ipproto} link add "${IFACE}" ${link}


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2017-06-09 23:55 Robin H. Johnson
  0 siblings, 0 replies; 109+ messages in thread
From: Robin H. Johnson @ 2017-06-09 23:55 UTC (permalink / raw
  To: gentoo-commits

commit:     1f76981467f9bbf1f2e22eb154fbb133ba333773
Author:     Sergey Popov <admin <AT> pinkbyte <DOT> ru>
AuthorDate: Tue Jan 24 09:18:21 2017 +0000
Commit:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
CommitDate: Tue Jan 24 13:45:52 2017 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=1f769814

Support for creating interfaces through iproute2 link command

Original idea and patch by Joseph Glanville <joseph.glanville <AT> orionvm.com.au>
https://gist.github.com/josephglanville/2757336

 net/iproute2.sh | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/net/iproute2.sh b/net/iproute2.sh
index 32ea5a4..55c9592 100644
--- a/net/iproute2.sh
+++ b/net/iproute2.sh
@@ -392,6 +392,20 @@ iproute2_pre_start()
 		eend $? || return 1
 		_up
 	fi
+	local link=
+	eval link=\$iplink_${IFVAR}
+	if [ -n "${link}" ]; then
+		local ipproto=''
+		[ "${tunnel##mode ip6gre}" != "${tunnel}" ] && ipproto='-6'
+		[ "${tunnel##mode ip6gretap}" != "${tunnel}" ] && ipproto='-6'
+		[ "${tunnel##mode ip6tnl}" != "${tunnel}" ] && ipproto='-6'
+
+		ebegin "Creating interface ${IFVAR}"
+		veinfo ip ${ipproto} link add "${IFACE}" ${link}
+		ip ${ipproto} link add "${IFACE}" ${link}
+		eend $? || return 1
+		_up
+	fi
 
 	# MTU support
 	local mtu=
@@ -417,6 +431,13 @@ iproute2_pre_start()
 	return 0
 }
 
+_iproute2_link_delete() {
+	ebegin "Destroying interface $1"
+	veinfo ip link del dev "$1"
+	ip link del dev "$1"
+	eend $?
+}
+
 _iproute2_ipv6_tentative()
 {
 	[ -n "$(LC_ALL=C ip -family inet6 addr show dev ${IFACE} tentative)" ] && return 0
@@ -499,6 +520,8 @@ iproute2_post_stop()
 			ip tunnel del "${IFACE}"
 			eend $?
 		fi
+		[ -n "$(ip link show "${IFACE}" type gretap 2>/dev/null)" ] && _iproute2_link_delete "${IFACE}"
+		[ -n "$(ip link show "${IFACE}" type vxlan 2>/dev/null)" ] && _iproute2_link_delete "${IFACE}"
 	fi
 }
 


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2017-06-09 23:52 Robin H. Johnson
  0 siblings, 0 replies; 109+ messages in thread
From: Robin H. Johnson @ 2017-06-09 23:52 UTC (permalink / raw
  To: gentoo-commits

commit:     18bceba0c3cd4a40937d158f8b59461d0eebee7f
Author:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
AuthorDate: Fri Jun  9 23:51:53 2017 +0000
Commit:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
CommitDate: Fri Jun  9 23:51:53 2017 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=18bceba0

bonding: make patching sysfs args easier in future.

Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org>

 net/bonding.sh | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/net/bonding.sh b/net/bonding.sh
index a25bf1f..6e5d810 100644
--- a/net/bonding.sh
+++ b/net/bonding.sh
@@ -78,6 +78,7 @@ bonding_pre_start()
 		fi
 	done
 	# Configure arp ip targets, they need to be added one after another
+	# With a leading '+' as a prefix.
 	n=arp_ip_target
 	x=/sys/class/net/"${IFACE}"/bonding/$n
 	[ -d /sys/class/net ] && if [ -f "$x" ]; then
@@ -94,9 +95,14 @@ bonding_pre_start()
 	[ -d /sys/class/net ] && for x in /sys/class/net/"${IFACE}"/bonding/*; do
 		[ -f "${x}" ] || continue
 		n=${x##*/}
+		# These entries are already handled above.
+		case "$n" in
+			mode) continue ;;
+			miimon) continue ;;
+			arp_ip_target) continue ;;
+		esac
+		# Check if anything to do.
 		eval s=\$${n}_${IFVAR}
-		# skip mode and miimon
-		[ "${n}" = "mode" -o "${n}" = "miimon" -o "${n}" = "arp_ip_target" ] && continue
 		if [ -n "${s}" ]; then
 			einfo "Setting ${n}: ${s}"
 			echo "${s}" >"${x}" || \
@@ -156,7 +162,7 @@ bonding_pre_start()
 		fi
 		# up the interface
 		_up
-    fi
+	fi
 
 	# finally add in slaves
 	# things needed in the process, and if they are done by ifenslave, openrc, and/or the kernel.


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2017-06-09 23:52 Robin H. Johnson
  0 siblings, 0 replies; 109+ messages in thread
From: Robin H. Johnson @ 2017-06-09 23:52 UTC (permalink / raw
  To: gentoo-commits

commit:     85f486367ab158b605d8817571028c90bccdc130
Author:     Marc Schiffbauer <mschiff <AT> gentoo <DOT> org>
AuthorDate: Mon Feb  6 18:23:41 2017 +0000
Commit:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
CommitDate: Fri Jun  9 23:48:18 2017 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=85f48636

bonding: add arp_ip_targets properly

netifrc handles bonding interfaces in /lib/netifrc/net/bonding.sh which
will apply all settings (*_bondX) like 'echo "${s}" >"${x}"' which will
not work for bonding arip ip targets: these have to be added by using
"echo +<ip> > arp_ip_target"

Please consider merging the attached patch which will fix that feature
and make netifrc work correctly with bonding interfaces when using
arp_ip_target instead of miimon.

Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org>

 net/bonding.sh | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/net/bonding.sh b/net/bonding.sh
index d0ed319..a25bf1f 100644
--- a/net/bonding.sh
+++ b/net/bonding.sh
@@ -1,4 +1,5 @@
 # Copyright (c) 2007-2008 Roy Marples <roy@marples.name>
+#               2017      Marc Schiffbauer <mschiff@gentoo.org>
 # Released under the 2-clause BSD license.
 
 bonding_depend()
@@ -21,7 +22,7 @@ _is_bond()
 
 bonding_pre_start()
 {
-	local x= s= n= slaves= primary=
+	local x= s= n= i= slaves= primary=
 
 	slaves="$(_get_array "slaves_${IFVAR}")"
 	unset slaves_${IFVAR}
@@ -76,13 +77,26 @@ bonding_pre_start()
 			eerror "Failed to configure $n (${n}_${IFVAR})"
 		fi
 	done
+	# Configure arp ip targets, they need to be added one after another
+	n=arp_ip_target
+	x=/sys/class/net/"${IFACE}"/bonding/$n
+	[ -d /sys/class/net ] && if [ -f "$x" ]; then
+		eval s=\$${n}_${IFVAR}
+		if [ -n "${s}" ]; then
+			for i in $s; do
+				einfo "Adding ${n}: ${i}"
+				echo "+${i/+/}" >"${x}" || \
+				eerror "Failed to add $i (${n}_${IFVAR})"
+			done
+		fi
+	fi
 	# Nice and dynamic for remaining options:)
 	[ -d /sys/class/net ] && for x in /sys/class/net/"${IFACE}"/bonding/*; do
 		[ -f "${x}" ] || continue
 		n=${x##*/}
 		eval s=\$${n}_${IFVAR}
 		# skip mode and miimon
-		[ "${n}" = "mode" -o "${n}" = "miimon" ] && continue
+		[ "${n}" = "mode" -o "${n}" = "miimon" -o "${n}" = "arp_ip_target" ] && continue
 		if [ -n "${s}" ]; then
 			einfo "Setting ${n}: ${s}"
 			echo "${s}" >"${x}" || \


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2017-01-27 21:54 Robin H. Johnson
  0 siblings, 0 replies; 109+ messages in thread
From: Robin H. Johnson @ 2017-01-27 21:54 UTC (permalink / raw
  To: gentoo-commits

commit:     1e14262524d65918ed6d1d13f2abd87b2f11425b
Author:     Sergey Popov <admin <AT> pinkbyte <DOT> ru>
AuthorDate: Tue Jan 24 14:10:36 2017 +0000
Commit:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
CommitDate: Tue Jan 24 14:10:36 2017 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=1e142625

Check for L2TP support in kernel

 net/l2tp.sh | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/net/l2tp.sh b/net/l2tp.sh
index 5efb535..dec1986 100644
--- a/net/l2tp.sh
+++ b/net/l2tp.sh
@@ -32,6 +32,10 @@ _l2tp_eval_props() {
 }
 
 _is_l2tp() {
+	# Check for L2TP support in kernel
+	ip l2tp show session &>/dev/null
+	[ $? -ne 0 ] && return 1
+
 	eval "$(ip l2tp show session | \
 		awk "match(\$0, /^Session ([0-9]+) in tunnel ([0-9]+)\$/, ret) {sid=ret[1]; tid=ret[2]} 
 		match(\$0, /^[ ]*interface name: ${IFACE}\$/) {print \"session_id=\"sid\";tunnel_id=\"tid; exit}")"


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2016-10-27  1:23 Robin H. Johnson
  0 siblings, 0 replies; 109+ messages in thread
From: Robin H. Johnson @ 2016-10-27  1:23 UTC (permalink / raw
  To: gentoo-commits

commit:     964a3a835eaa914422d5de55cd4151b4e56b544a
Author:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
AuthorDate: Wed Oct 26 20:12:16 2016 +0000
Commit:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
CommitDate: Wed Oct 26 20:12:16 2016 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=964a3a83

net/iproute2: fix netmask specifier.

X-Gentoo-Bug: 598078
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=598078
Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org>

 net/iproute2.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/iproute2.sh b/net/iproute2.sh
index 6efa2e7..32ea5a4 100644
--- a/net/iproute2.sh
+++ b/net/iproute2.sh
@@ -133,7 +133,7 @@ _add_address()
 					eerror "Too many netmasks: $raw_address netmask $1"
 					return 1
 				fi
-				netmask="/$(_netmask2cidr "$1")"
+				netmask="$(_netmask2cidr "$1")"
 				shift ;;
 			broadcast|brd|br*)
 				broadcast="$1" ; shift ;;


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2016-10-24 23:16 Robin H. Johnson
  0 siblings, 0 replies; 109+ messages in thread
From: Robin H. Johnson @ 2016-10-24 23:16 UTC (permalink / raw
  To: gentoo-commits

commit:     edd52106d7c868c86c396e0c2f486e58a6132d3c
Author:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
AuthorDate: Mon Oct 24 23:14:06 2016 +0000
Commit:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
CommitDate: Mon Oct 24 23:14:06 2016 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=edd52106

net/macchanger: support newer macchanger tool.

Newer versions of macchanger require -m to specify the MAC (it used to
be a non-option argument).

Also don't depend on the output format at all anymore, instead reading
the new MAC from sysfs on after macchanger reports success.

X-Gentoo-Bug: 540728
X-Gentoo-Bug: 547906
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=540728
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=547906
Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org>

 net/macchanger.sh | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/net/macchanger.sh b/net/macchanger.sh
index ff13770..ae9ff9b 100644
--- a/net/macchanger.sh
+++ b/net/macchanger.sh
@@ -14,7 +14,7 @@ macchanger_pre_start()
 	# We don't change MAC addresses from background
 	yesno ${IN_BACKGROUND} && return 0
 
-	local mac= opts=
+	local mac= opts= try= output= rc=
 
 	eval mac=\$mac_${IFVAR}
 	[ -z "${mac}" ] && return 0
@@ -60,7 +60,7 @@ macchanger_pre_start()
 		random-full|random) opts="${opts} -r";;
 
 		# default case is just to pass on all the options
-		*) opts="${opts} ${mac}";;
+		*) opts="${opts} -m ${mac}";;
 	esac
 
 	if [ ! -x /sbin/macchanger ]; then
@@ -68,24 +68,24 @@ macchanger_pre_start()
 		return 1
 	fi
 
-	mac=$(/sbin/macchanger ${opts} "${IFACE}" \
-		| sed -n -e 's/^\(Faked\|New\) MAC:.*\<\(..:..:..:..:..:..\)\>.*/\U\2/p' )
-	_up
+	for try in 1 2; do
+		# Sometimes the interface needs to be up
+		[ "${try}" -eq 2 ] && _up
+		output=$(/sbin/macchanger ${opts} "${IFACE}")
+		rc=$?
+		[ "${rc}" -eq 0 ] && break
+	done
 
-	# Sometimes the interface needs to be up ....
-	if [ -z "${mac}" ]; then
-		mac=$(/sbin/macchanger ${opts} "${IFACE}" \
-		| sed -n -e 's/^\(Faked\|New\) MAC:.*\<\(..:..:..:..:..:..\)\>.*/\U\2/p' )
-	fi
-
-	if [ -z "${mac}" ]; then
+	if [ "${rc}" -ne 0 ]; then
+		eerror "${output}"
 		eend 1 "Failed to set MAC address"
 		return 1
 	fi
 
 	eend 0
 	eindent
-	einfo "changed to" "${mac}"
+	newmac=$(_get_mac_address)
+	einfo "changed to ${newmac}"
 	eoutdent
 
 	return 0


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2016-10-24 20:58 Robin H. Johnson
  0 siblings, 0 replies; 109+ messages in thread
From: Robin H. Johnson @ 2016-10-24 20:58 UTC (permalink / raw
  To: gentoo-commits

commit:     699636d47ce69ad2ada2748e4522447dc57aadf9
Author:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
AuthorDate: Mon Oct 24 20:56:20 2016 +0000
Commit:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
CommitDate: Mon Oct 24 20:56:20 2016 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=699636d4

net/iproute2: no automatic scope=host on loopback.

Busybox 'ip address add' does not support the 'scope' argument.

It DOES support the scope argument for 'ip address show', as well as all
of 'ip route'. The kernel does get automatic scope correct now, so drop
any automatic setting of scope to host when it was not otherwise
specified, and let the kernel make it's own decision.

X-Gentoo-Bug: 487208
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=487208
Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org>

 net/iproute2.sh | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/net/iproute2.sh b/net/iproute2.sh
index 32d3c88..6efa2e7 100644
--- a/net/iproute2.sh
+++ b/net/iproute2.sh
@@ -162,11 +162,6 @@ _add_address()
 		esac
 	done
 
-	# Always scope lo addresses as host unless specified otherwise
-	if [ "${IFACE}" = "lo" ]; then
-		[ -z "$scope" ] && scope="host"
-	fi
-
 	# figure out the broadcast address if it is not specified
 	# This must NOT be set for IPv6 addresses
 	case $family in


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2016-10-24 16:49 Robin H. Johnson
  0 siblings, 0 replies; 109+ messages in thread
From: Robin H. Johnson @ 2016-10-24 16:49 UTC (permalink / raw
  To: gentoo-commits

commit:     7e3c6ff7af8c1559301bf1e28f1b9c8188c519ac
Author:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
AuthorDate: Mon Oct 24 16:44:45 2016 +0000
Commit:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
CommitDate: Mon Oct 24 16:44:50 2016 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=7e3c6ff7

net/iproute2: IPv6 DAD delay must be non-fatal.

Commit 50c9fd7827fa58d27a593c8c480068f85c047cec introduced a subtle
accidental change in the handling of IPv6 tentative addresses.

In an environment where the DAD completion time exceeds the configured
timeout (which was also reduced to 5 seconds, while the docs say 10
seconds), the interface was recorded as failing to start when the
timeout was hit without DAD completion. This means that the interface
was then marked as failed and later services did not start. No rollback
took place either.

Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org>

 net/iproute2.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/iproute2.sh b/net/iproute2.sh
index 9ef704d..32d3c88 100644
--- a/net/iproute2.sh
+++ b/net/iproute2.sh
@@ -441,6 +441,8 @@ iproute2_post_start()
 	[ -z "$policyroute_order" ] && policyroute_order=${policy_rules_before_routes:-no}
 	yesno "$policyroute_order" || _iproute2_policy_routing
 
+	# This block must be non-fatal, otherwise the interface will not be
+	# recorded as starting, and later services may be blocked.
 	if _iproute2_ipv6_tentative; then
 		einfon "Waiting for IPv6 addresses (${_dad_timeout} seconds) "
 		while [ $_dad_timeout -gt 0 ]; do
@@ -454,7 +456,6 @@ iproute2_post_start()
 
 		if [ $_dad_timeout -le 0 ]; then
 			eend 1
-			return 1
 		else
 			eend 0
 		fi


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2016-10-24  0:25 Robin H. Johnson
  0 siblings, 0 replies; 109+ messages in thread
From: Robin H. Johnson @ 2016-10-24  0:25 UTC (permalink / raw
  To: gentoo-commits

commit:     bf3ee524b605e6a78f5abeb0e6577ae8a9b16f0c
Author:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
AuthorDate: Mon Oct 24 00:25:41 2016 +0000
Commit:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
CommitDate: Mon Oct 24 00:25:41 2016 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=bf3ee524

iproute2/_get_route: better output on route check

Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org>

 net/iproute2.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/iproute2.sh b/net/iproute2.sh
index 1dff3fe..9ef704d 100644
--- a/net/iproute2.sh
+++ b/net/iproute2.sh
@@ -272,8 +272,8 @@ _add_route()
 				error|fatal) msgfunc=eerror rc=1;;
 				*) msgfunc=eerror rc=1 ; eerror "Unknown error behavior: $eh_behavior" ;;
 			esac
-			eval $msgfunc "Route '$cmd' already existed."
-			eval $msgfunc \"$(ip $family route show $cmd dev "${IFACE}" 2>&1)\"
+			eval $msgfunc "Route '$cmd_nometric' already existed:"
+			eval $msgfunc \"$(ip $family route show ${cmd_nometric} dev "${IFACE}" 2>&1)\"
 		else
 			: # TODO: Handle other errors
 		fi


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2016-10-24  0:23 Robin H. Johnson
  0 siblings, 0 replies; 109+ messages in thread
From: Robin H. Johnson @ 2016-10-24  0:23 UTC (permalink / raw
  To: gentoo-commits

commit:     0bd4f26da64fb30e0fba06e5866f0bdac132459b
Author:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
AuthorDate: Mon Oct 24 00:17:08 2016 +0000
Commit:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
CommitDate: Mon Oct 24 00:17:08 2016 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=0bd4f26d

iproute2/_add_route: ensure metric is set properly.

Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org>

 net/iproute2.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/iproute2.sh b/net/iproute2.sh
index 408e293..938a5fb 100644
--- a/net/iproute2.sh
+++ b/net/iproute2.sh
@@ -235,7 +235,7 @@ _add_route()
 	local cmd= have_metric=false
 	while [ -n "$1" ]; do
 		case "$1" in
-			metric) cmd="${cmd} $1"; have_metric=true;;
+			metric) cmd="${cmd} metric $2"; shift ; have_metric=true;;
 			netmask) cmd="${cmd}/$(_netmask2cidr "$2")"; shift;;
 			-host|-net);;
 			*) cmd="${cmd} $1";;


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2016-10-24  0:23 Robin H. Johnson
  0 siblings, 0 replies; 109+ messages in thread
From: Robin H. Johnson @ 2016-10-24  0:23 UTC (permalink / raw
  To: gentoo-commits

commit:     95105e7437c1680d564279f4dd7063d7241370ac
Author:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
AuthorDate: Mon Oct 24 00:23:06 2016 +0000
Commit:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
CommitDate: Mon Oct 24 00:23:06 2016 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=95105e74

iproute2/_get_route: do not include metric in test for existing route.

Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org>

 net/iproute2.sh | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/net/iproute2.sh b/net/iproute2.sh
index 938a5fb..1dff3fe 100644
--- a/net/iproute2.sh
+++ b/net/iproute2.sh
@@ -232,13 +232,13 @@ _add_route()
 		set -- "${one}" "${two}" via "$@"
 	fi
 
-	local cmd= have_metric=false
+	local cmd= cmd_nometric= have_metric=false
 	while [ -n "$1" ]; do
 		case "$1" in
-			metric) cmd="${cmd} metric $2"; shift ; have_metric=true;;
-			netmask) cmd="${cmd}/$(_netmask2cidr "$2")"; shift;;
+			metric) metric=$2 ; cmd="${cmd} metric $2" ; shift ; have_metric=true ;;
+			netmask) x="/$(_netmask2cidr "$2")" ; cmd="${cmd}${x}" ; cmd_nometric="${cmd}${x}" ; shift;;
 			-host|-net);;
-			*) cmd="${cmd} $1";;
+			*) cmd="${cmd} ${1}" ; cmd_nometric="${cmd_nometric} ${1}" ;;
 		esac
 		shift
 	done
@@ -252,7 +252,7 @@ _add_route()
 	fi
 
 	# Check for route already existing:
-	ip ${family} route show ${cmd} dev "${IFACE}" 2>/dev/null | \
+	ip ${family} route show ${cmd_nometric} dev "${IFACE}" 2>/dev/null | \
 		fgrep -sq "${cmd%% *}"
 	route_already_exists=$?
 


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2016-10-24  0:04 Robin H. Johnson
  0 siblings, 0 replies; 109+ messages in thread
From: Robin H. Johnson @ 2016-10-24  0:04 UTC (permalink / raw
  To: gentoo-commits

commit:     c9fcba63eba9760cdbd5effc9a63394a3fa9d3ae
Author:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
AuthorDate: Mon Oct 24 00:04:16 2016 +0000
Commit:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
CommitDate: Mon Oct 24 00:04:16 2016 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=c9fcba63

iproute2: error-check the error-behavior input.

Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org>

 net/iproute2.sh | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/net/iproute2.sh b/net/iproute2.sh
index b6fd847..408e293 100644
--- a/net/iproute2.sh
+++ b/net/iproute2.sh
@@ -198,6 +198,7 @@ _add_address()
 				info) msgfunc=einfo rc=0 ;;
 				warn) msgfunc=ewarn rc=0 ;;
 				error|fatal) msgfunc=eerror rc=1;;
+				*) msgfunc=eerror rc=1 ; eerror "Unknown error behavior: $eh_behavior" ;;
 			esac
 			eval $msgfunc "Address ${address}${netmask:+/}${netmask} already existed!"
 			eval $msgfunc \"$(ip addr show to "${address}/${family_maxnetmask}" dev "${IFACE}" 2>&1)\"
@@ -269,6 +270,7 @@ _add_route()
 				info) msgfunc=einfo rc=0 ;;
 				warn) msgfunc=ewarn rc=0 ;;
 				error|fatal) msgfunc=eerror rc=1;;
+				*) msgfunc=eerror rc=1 ; eerror "Unknown error behavior: $eh_behavior" ;;
 			esac
 			eval $msgfunc "Route '$cmd' already existed."
 			eval $msgfunc \"$(ip $family route show $cmd dev "${IFACE}" 2>&1)\"


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2016-10-24  0:04 Robin H. Johnson
  0 siblings, 0 replies; 109+ messages in thread
From: Robin H. Johnson @ 2016-10-24  0:04 UTC (permalink / raw
  To: gentoo-commits

commit:     7a057b6ab2dc644f7b292666f4363a72df47a03d
Author:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
AuthorDate: Sun Oct 23 23:52:01 2016 +0000
Commit:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
CommitDate: Sun Oct 23 23:52:01 2016 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=7a057b6a

iproute2: handle other error case better.

Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org>

 net/iproute2.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/iproute2.sh b/net/iproute2.sh
index 779d334..2c9f6bb 100644
--- a/net/iproute2.sh
+++ b/net/iproute2.sh
@@ -203,7 +203,7 @@ _add_address()
 			$msgfunc "Address ${address}${netmask:+/}${netmask} already existed: $(ip addr show to "${address}/${family_maxnetmask}" dev "${IFACE}" 2>&1)"
 			[ $abort -eq 1 ] && rc=1
 		else
-			# TODO: Handle other errors
+			: # TODO: Handle other errors
 		fi
 	fi
 	return $rc
@@ -275,7 +275,7 @@ _add_route()
 			$msgfunc "Route '$cmd' already existed: $(ip $family route show $cmd dev "${IFACE}" 2>&1)"
 			[ $abort -eq 1 ] && rc=1
 		else
-			# TODO: Handle other errors
+			: # TODO: Handle other errors
 		fi
 	fi
 	eend $rc


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2016-10-23 23:50 Robin H. Johnson
  0 siblings, 0 replies; 109+ messages in thread
From: Robin H. Johnson @ 2016-10-23 23:50 UTC (permalink / raw
  To: gentoo-commits

commit:     5be82041cf23b0359190c148e9d356d8aa85e18b
Author:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
AuthorDate: Sun Oct 23 23:43:35 2016 +0000
Commit:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
CommitDate: Sun Oct 23 23:43:35 2016 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=5be82041

iproute2: treat EEXIST error on addresses as non-fatal.

Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org>

 net/iproute2.sh | 25 ++++++++++++++++++++++++-
 1 file changed, 24 insertions(+), 1 deletion(-)

diff --git a/net/iproute2.sh b/net/iproute2.sh
index f15f3af..d03548e 100644
--- a/net/iproute2.sh
+++ b/net/iproute2.sh
@@ -177,12 +177,35 @@ _add_address()
 	# Always have a netmask
 	[ -z "$netmask" ] && netmask=$family_maxnetmask
 
+	# Check for address already existing:
+	ip addr show to "${address}/${family_maxnetmask}" dev "${IFACE}" 2>/dev/null | \
+		fgrep -sq "${address}"
+	address_already_exists=$?
+
 	# This must appear on a single line, continuations cannot be used
 	set -- "${address}${netmask:+/}${netmask}" ${peer:+peer} ${peer} ${broadcast:+broadcast} ${broadcast} ${anycast:+anycast} ${anycast} ${label:+label} ${label} ${scope:+scope} ${scope} dev "${IFACE}" ${valid_lft:+valid_lft} $valid_lft ${preferred_lft:+preferred_lft} $preferred_lft $confflaglist
 	veinfo ip addr add "$@"
 	ip addr add "$@"
 	rc=$?
-	# TODO: check return code in some cases
+	# Check return code in some cases
+	if [ $rc -ne 0 ]; then
+		# If the address already exists, our default behavior is to WARN but continue.
+		# You can completely silence this with: errh_IFVAR_address_EEXIST=continue
+		if [ $address_already_exists -eq 0 ]; then
+			eh_behavior=$(_get_errorhandler_behavior "$IFVAR" "address" "EEXIST" "warn")
+			abort=0
+			case $eh_behavior in
+				continue) msgfunc=true ;;
+				info) msgfunc=einfo ;;
+				warn) msgfunc=ewarn ;;
+				error|fatal) msgfunc=eerror abort=1;;
+			esac
+			$msgfunc "Address ${address}${netmask:+/}${netmask} already existed: $(ip addr show to "${address}/${family_maxnetmask}" dev "${IFACE}" 2>&1)"
+			[ $abort -eq 1 ] && rc=1
+		else
+			# TODO: Handle other errors
+		fi
+	fi
 	return $rc
 }
 


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2016-10-23 23:50 Robin H. Johnson
  0 siblings, 0 replies; 109+ messages in thread
From: Robin H. Johnson @ 2016-10-23 23:50 UTC (permalink / raw
  To: gentoo-commits

commit:     c0e9d13165c53ee934b25883b03ff39ef04e2904
Author:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
AuthorDate: Sun Oct 23 23:35:11 2016 +0000
Commit:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
CommitDate: Sun Oct 23 23:35:11 2016 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=c0e9d131

iproute2: capture the family and always set netmask explicitly.

Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org>

 net/iproute2.sh | 39 +++++++++++++++++++++++++++------------
 1 file changed, 27 insertions(+), 12 deletions(-)

diff --git a/net/iproute2.sh b/net/iproute2.sh
index 6cf9aef..f15f3af 100644
--- a/net/iproute2.sh
+++ b/net/iproute2.sh
@@ -109,17 +109,31 @@ _add_address()
 	local x
 	local address netmask broadcast peer anycast label scope
 	local valid_lft preferred_lft home nodad
-	local confflaglist
-	address="$1" ; shift
+	local confflaglist family raw_address family_maxnetmask
+	raw_address="$1" ; shift
+	# Extract the netmask on address if present.
+	if [ "${address%\/*}" != "${address}" ]; then
+		address="${raw_address%\/*}"
+		netmask="${raw_address#*\/}"
+	else
+		address="$raw_address"
+	fi
+
+	# Some options are not valid for one family or the other.
+	case ${address} in
+		*:*) family=6 family_maxnetmask=128 ;;
+		*) family=4 family_maxnetmask=32 ;;
+	esac
+
 	while [ -n "$*" ]; do
 		x=$1 ; shift
 		case "$x" in
 			netmask|ne*)
-				netmask="/$(_netmask2cidr "$1")"
-				if [ "${address/\/}" != "${address}" ]; then
-					eerror "Too many netmasks: $address netmask $1"
+				if [ -n "${netmask}" ]; then
+					eerror "Too many netmasks: $raw_address netmask $1"
 					return 1
 				fi
+				netmask="/$(_netmask2cidr "$1")"
 				shift ;;
 			broadcast|brd|br*)
 				broadcast="$1" ; shift ;;
@@ -155,15 +169,16 @@ _add_address()
 
 	# figure out the broadcast address if it is not specified
 	# This must NOT be set for IPv6 addresses
-	if [ "${address#*:}" = "${address}" ]; then
-		[ -z "$broadcast" ] && broadcast="+"
-	elif [ -n "$broadcast" ]; then
-		eerror "Broadcast keywords are not valid with IPv6 addresses"
-		return 1
-	fi
+	case $family in
+		4) [ -z "$broadcast" ] && broadcast="+" ;;
+		6) [ -n "$broadcast" ] && eerror "Broadcast keywords are not valid with IPv6 addresses" && return 1 ;;
+	esac
+
+	# Always have a netmask
+	[ -z "$netmask" ] && netmask=$family_maxnetmask
 
 	# This must appear on a single line, continuations cannot be used
-	set -- "${address}${netmask}" ${peer:+peer} ${peer} ${broadcast:+broadcast} ${broadcast} ${anycast:+anycast} ${anycast} ${label:+label} ${label} ${scope:+scope} ${scope} dev "${IFACE}" ${valid_lft:+valid_lft} $valid_lft ${preferred_lft:+preferred_lft} $preferred_lft $confflaglist
+	set -- "${address}${netmask:+/}${netmask}" ${peer:+peer} ${peer} ${broadcast:+broadcast} ${broadcast} ${anycast:+anycast} ${anycast} ${label:+label} ${label} ${scope:+scope} ${scope} dev "${IFACE}" ${valid_lft:+valid_lft} $valid_lft ${preferred_lft:+preferred_lft} $preferred_lft $confflaglist
 	veinfo ip addr add "$@"
 	ip addr add "$@"
 	rc=$?


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2016-10-23 23:50 Robin H. Johnson
  0 siblings, 0 replies; 109+ messages in thread
From: Robin H. Johnson @ 2016-10-23 23:50 UTC (permalink / raw
  To: gentoo-commits

commit:     f9793bb67a40dc58c97772a9731a2b6dfcb1422f
Author:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
AuthorDate: Sun Oct 23 23:50:08 2016 +0000
Commit:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
CommitDate: Sun Oct 23 23:50:08 2016 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=f9793bb6

iproute2: treat EEXIST error on routes as non-fatal.

Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org>

 net/iproute2.sh | 25 ++++++++++++++++++++++++-
 1 file changed, 24 insertions(+), 1 deletion(-)

diff --git a/net/iproute2.sh b/net/iproute2.sh
index d03548e..779d334 100644
--- a/net/iproute2.sh
+++ b/net/iproute2.sh
@@ -251,10 +251,33 @@ _add_route()
 		cmd="${cmd} metric ${metric}"
 	fi
 
+	# Check for route already existing:
+	ip ${family} route show ${cmd} dev "${IFACE}" 2>/dev/null | \
+		fgrep -sq "${cmd%% *}"
+	route_already_exists=$?
+
 	veinfo ip ${family} route append ${cmd} dev "${IFACE}"
 	ip ${family} route append ${cmd} dev "${IFACE}"
 	rc=$?
-	# TODO: check return code in some cases
+	# Check return code in some cases
+	if [ $rc -ne 0 ]; then
+		# If the route already exists, our default behavior is to WARN but continue.
+		# You can completely silence this with: errh_IFVAR_route_EEXIST=continue
+		if [ $route_already_exists -eq 0 ]; then
+			eh_behavior=$(_get_errorhandler_behavior "$IFVAR" "route" "EEXIST" "warn")
+			abort=0
+			case $eh_behavior in
+				continue) msgfunc=true ;;
+				info) msgfunc=einfo ;;
+				warn) msgfunc=ewarn ;;
+				error|fatal) msgfunc=eerror abort=1;;
+			esac
+			$msgfunc "Route '$cmd' already existed: $(ip $family route show $cmd dev "${IFACE}" 2>&1)"
+			[ $abort -eq 1 ] && rc=1
+		else
+			# TODO: Handle other errors
+		fi
+	fi
 	eend $rc
 }
 


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2016-10-23 22:39 Robin H. Johnson
  0 siblings, 0 replies; 109+ messages in thread
From: Robin H. Johnson @ 2016-10-23 22:39 UTC (permalink / raw
  To: gentoo-commits

commit:     486214bb2d772c9316d7a8e6917a70e4a7405381
Author:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
AuthorDate: Sun Oct 23 22:39:27 2016 +0000
Commit:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
CommitDate: Sun Oct 23 22:39:27 2016 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=486214bb

iproute2: errorcheck on netmasks.

Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org>

 net/iproute2.sh | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/net/iproute2.sh b/net/iproute2.sh
index d74bc29..682fdc6 100644
--- a/net/iproute2.sh
+++ b/net/iproute2.sh
@@ -115,7 +115,12 @@ _add_address()
 		x=$1 ; shift
 		case "$x" in
 			netmask|ne*)
-				netmask="/$(_netmask2cidr "$1")" ; shift ;;
+				netmask="/$(_netmask2cidr "$1")"
+				if [ "${address/\/}" != "${address}" ]; then
+					eerror "Too many netmasks: $address netmask $1"
+					return 1
+				fi
+				shift ;;
 			broadcast|brd|br*)
 				broadcast="$1" ; shift ;;
 			pointopoint|pointtopoint|peer|po*|pe*)


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2016-10-23 22:39 Robin H. Johnson
  0 siblings, 0 replies; 109+ messages in thread
From: Robin H. Johnson @ 2016-10-23 22:39 UTC (permalink / raw
  To: gentoo-commits

commit:     cec563da1dd8db44a2b9c9f4a0579c5a441e9528
Author:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
AuthorDate: Sun Oct 23 22:39:50 2016 +0000
Commit:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
CommitDate: Sun Oct 23 22:39:50 2016 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=cec563da

iproute2: prepare for error-checking on ip addr/route/tunnel.

Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org>

 net/iproute2.sh | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/net/iproute2.sh b/net/iproute2.sh
index 682fdc6..6cf9aef 100644
--- a/net/iproute2.sh
+++ b/net/iproute2.sh
@@ -166,6 +166,9 @@ _add_address()
 	set -- "${address}${netmask}" ${peer:+peer} ${peer} ${broadcast:+broadcast} ${broadcast} ${anycast:+anycast} ${anycast} ${label:+label} ${label} ${scope:+scope} ${scope} dev "${IFACE}" ${valid_lft:+valid_lft} $valid_lft ${preferred_lft:+preferred_lft} $preferred_lft $confflaglist
 	veinfo ip addr add "$@"
 	ip addr add "$@"
+	rc=$?
+	# TODO: check return code in some cases
+	return $rc
 }
 
 _add_route()
@@ -212,7 +215,9 @@ _add_route()
 
 	veinfo ip ${family} route append ${cmd} dev "${IFACE}"
 	ip ${family} route append ${cmd} dev "${IFACE}"
-	eend $?
+	rc=$?
+	# TODO: check return code in some cases
+	eend $rc
 }
 
 _delete_addresses()
@@ -237,6 +242,9 @@ _tunnel()
 {
 	veinfo ip tunnel "$@"
 	ip tunnel "$@"
+	rc=$?
+	# TODO: check return code in some cases
+	return $rc
 }
 
 # This is just to trim whitespace, do not add any quoting!


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2016-10-05 14:42 Robin H. Johnson
  0 siblings, 0 replies; 109+ messages in thread
From: Robin H. Johnson @ 2016-10-05 14:42 UTC (permalink / raw
  To: gentoo-commits

commit:     6072cfa443119fc89e997d9ff3a7eee5bb33ac36
Author:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
AuthorDate: Wed Oct  5 14:40:37 2016 +0000
Commit:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
CommitDate: Wed Oct  5 14:40:37 2016 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=6072cfa4

iproute2: add keywords: noprefixroute mngtmpaddr.

iproute2 gained new keywords noprefixroute & mngtmpaddr.
The prefix-match quick config wrongly expands noprefixroute to nodad, so
fix that.

Thanks-To: opensource <AT> zhasha.com
Gentoo-Bug: https://bugs.gentoo.org/show_bug.cgi?id=596234
Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org>

 net/iproute2.sh | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/net/iproute2.sh b/net/iproute2.sh
index 0b2a8d6..d74bc29 100644
--- a/net/iproute2.sh
+++ b/net/iproute2.sh
@@ -129,8 +129,13 @@ _add_address()
 					pr*) x=preferred_lft ;;
 				esac
 				eval "$x=$1" ; shift ;;
-			home|nodad|h*|no*)
-				case $x in h*) x=home ;; n*) x=nodad ;; esac
+			home|mngtmpaddr|nodad|noprefixroute|h*|mng*|no*)
+				case $x in
+					h*) x=home ;;
+					m*) x=mngtmpaddr ;;
+					nop*) x=noprefixroute ;;
+					n*) x=nodad ;;
+				esac
 				# FIXME: If we need to reorder these, this will take more code
 				confflaglist="${confflaglist} $x" ; ;;
 			*)


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2016-07-19 19:59 Robin H. Johnson
  0 siblings, 0 replies; 109+ messages in thread
From: Robin H. Johnson @ 2016-07-19 19:59 UTC (permalink / raw
  To: gentoo-commits

commit:     18dd0598b29d2158529466f1e7097bf894e584dc
Author:     Andrey Volkov <volkov.am <AT> ekb-info <DOT> ru>
AuthorDate: Fri Jul 15 08:23:56 2016 +0000
Commit:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
CommitDate: Tue Jul 19 19:59:32 2016 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=18dd0598

Fix missing interface types

(cherry picked from commit c8fe42141c95f5446dabf5c0b1f049151e51c2ad)

 net/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/Makefile b/net/Makefile
index a03c171..ce73c1e 100644
--- a/net/Makefile
+++ b/net/Makefile
@@ -13,7 +13,7 @@ SRCS-Linux=	iwconfig.sh.in udhcpc.sh.in
 INC-Linux=	adsl.sh apipa.sh arping.sh bonding.sh br2684ctl.sh bridge.sh \
 		ccwgroup.sh clip.sh ethtool.sh iproute2.sh ifplugd.sh ip6to4.sh \
 		ipppd.sh iwconfig.sh netplugd.sh pppd.sh pump.sh tuntap.sh udhcpc.sh \
-		vlan.sh macvlan.sh ip6rd.sh firewalld.sh
+		vlan.sh macvlan.sh ip6rd.sh firewalld.sh dummy.sh hsr.sh l2tp.sh
 
 SRCS-NetBSD= ifwatchd.sh.in
 INC-NetBSD=	ifwatchd.sh


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2016-07-05 18:14 Robin H. Johnson
  0 siblings, 0 replies; 109+ messages in thread
From: Robin H. Johnson @ 2016-07-05 18:14 UTC (permalink / raw
  To: gentoo-commits

commit:     e7a218ea4f3d85df05a8b2ca6c0fe71c0d15e44d
Author:     Mr-TI <emericv <AT> gmail <DOT> com>
AuthorDate: Sun May  1 09:36:55 2016 +0000
Commit:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
CommitDate: Sun May  1 09:36:55 2016 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=e7a218ea

Revert "Add L2TPv3 tunnel/session support to iproute2 module"
Moving the L2TP part to an separate file

This reverts commit 4a8358aaf9c0048930194e0bbe3d2509d9da4fd0.

 net/iproute2.sh | 45 ---------------------------------------------
 1 file changed, 45 deletions(-)

diff --git a/net/iproute2.sh b/net/iproute2.sh
index 825b9b1..0b2a8d6 100644
--- a/net/iproute2.sh
+++ b/net/iproute2.sh
@@ -318,32 +318,6 @@ iproute2_pre_start()
 		eend $? || return 1
 		_up
 	fi
-	
-	# L2TPv3
-	local l2tpsession=
-	eval l2tpsession=\$l2tpsession_${IFVAR}
-	if [ -n "${l2tpsession}" ]; then
-		ebegin "Creating L2TPv3 tunnel ${IFVAR}"
-		local l2tptunnel=
-		eval l2tptunnel=\$l2tptunnel_${IFVAR}
-		if [ -n "${l2tptunnel}" ]; then
-			local retcode
-			veinfo ip l2tp add tunnel ${l2tptunnel}
-			ip l2tp add tunnel ${l2tptunnel}
-			#a L2TPv3 tunnel can host several sessions (1 session <=> 1 interface)
-			#if $?=2 the tunnel id already exists, just ignore this error
-			#we assume that the existing one have the same property that we want to create...
-			if [ $? -ne 0 ] && [ $? -ne 2 ]; then
-				eend $? || return 1
-			fi
-		fi
-		veinfo ip l2tp add session ${l2tpsession} name "${IFACE}"
-		ip l2tp add session ${l2tpsession} name "${IFACE}"
-		if [ $? -ne 0 ] && [ $? -ne 2 ]; then
-			eend $? || return 1
-		fi
-		_up
-	fi
 
 	# MTU support
 	local mtu=
@@ -450,25 +424,6 @@ iproute2_post_stop()
 			ip tunnel del "${IFACE}"
 			eend $?
 		fi
-		local l2tptuple
-		# Searching for l2tp session associated to ${IFACE}
-		l2tptuple="$(ip l2tp show session | \
-			awk "match(\$0, /^Session ([0-9]+) in tunnel ([0-9]+)\$/, ret) {sid=ret[1]; tid=ret[2]} 
-				match(\$0, /^[ ]*interface name: ${IFACE}\$/) {print sid\":\"tid; exit}")"
-		if [ -n "$l2tptuple" ]; then
-			local l2tpsession_id l2tptunnel_id
-			l2tpsession_id=${l2tptuple%:*}
-			l2tptunnel_id=${l2tptuple#*:}
-			ebegin "Destroying L2TPv3 tunnel ${IFACE}"
-			veinfo ip l2tp del session tunnel_id $l2tptunnel_id session_id $l2tpsession_id
-			ip l2tp del session tunnel_id $l2tptunnel_id session_id $l2tpsession_id
-			if [ -z "$(ip l2tp show session | grep -E "^Session [0-9]+ in tunnel $l2tptunnel_id\$")" ]; then
-				#tunnel $l2tptunnel_id no longer used, destoying it...
-				veinfo ip l2tp del tunnel tunnel_id $l2tptunnel_id
-				ip l2tp del tunnel tunnel_id $l2tptunnel_id
-			fi
-			eend $?
-		fi
 	fi
 }
 


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2016-07-05 18:14 Robin H. Johnson
  0 siblings, 0 replies; 109+ messages in thread
From: Robin H. Johnson @ 2016-07-05 18:14 UTC (permalink / raw
  To: gentoo-commits

commit:     4a8358aaf9c0048930194e0bbe3d2509d9da4fd0
Author:     Emeric Verschuur <emeric <AT> mbedsys <DOT> org>
AuthorDate: Sat Apr 23 20:17:55 2016 +0000
Commit:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
CommitDate: Sat Apr 23 20:17:55 2016 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=4a8358aa

Add L2TPv3 tunnel/session support to iproute2 module

Add L2TPv3 tunnel/session support to iproute2 module:

Example of config to add two L2TPv3 session/two interfaces with a shared tunnel:

l2tptunnel_net1="remote 1.2.3.4 local 1.2.3.5tunnel_id 3 peer_tunnel_id 3 encap ip"
l2tpsession_net1="tunnel_id 3 session_id 3 peer_session_id 3"
config_net1="null"

l2tptunnel_net2="remote 1.2.3.4 local 1.2.3.5 tunnel_id 3 peer_tunnel_id 3 encap ip"
l2tpsession_net2="tunnel_id 3 session_id 4 peer_session_id 4"
config_net2="null"

 net/iproute2.sh | 45 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)

diff --git a/net/iproute2.sh b/net/iproute2.sh
index 0b2a8d6..825b9b1 100644
--- a/net/iproute2.sh
+++ b/net/iproute2.sh
@@ -318,6 +318,32 @@ iproute2_pre_start()
 		eend $? || return 1
 		_up
 	fi
+	
+	# L2TPv3
+	local l2tpsession=
+	eval l2tpsession=\$l2tpsession_${IFVAR}
+	if [ -n "${l2tpsession}" ]; then
+		ebegin "Creating L2TPv3 tunnel ${IFVAR}"
+		local l2tptunnel=
+		eval l2tptunnel=\$l2tptunnel_${IFVAR}
+		if [ -n "${l2tptunnel}" ]; then
+			local retcode
+			veinfo ip l2tp add tunnel ${l2tptunnel}
+			ip l2tp add tunnel ${l2tptunnel}
+			#a L2TPv3 tunnel can host several sessions (1 session <=> 1 interface)
+			#if $?=2 the tunnel id already exists, just ignore this error
+			#we assume that the existing one have the same property that we want to create...
+			if [ $? -ne 0 ] && [ $? -ne 2 ]; then
+				eend $? || return 1
+			fi
+		fi
+		veinfo ip l2tp add session ${l2tpsession} name "${IFACE}"
+		ip l2tp add session ${l2tpsession} name "${IFACE}"
+		if [ $? -ne 0 ] && [ $? -ne 2 ]; then
+			eend $? || return 1
+		fi
+		_up
+	fi
 
 	# MTU support
 	local mtu=
@@ -424,6 +450,25 @@ iproute2_post_stop()
 			ip tunnel del "${IFACE}"
 			eend $?
 		fi
+		local l2tptuple
+		# Searching for l2tp session associated to ${IFACE}
+		l2tptuple="$(ip l2tp show session | \
+			awk "match(\$0, /^Session ([0-9]+) in tunnel ([0-9]+)\$/, ret) {sid=ret[1]; tid=ret[2]} 
+				match(\$0, /^[ ]*interface name: ${IFACE}\$/) {print sid\":\"tid; exit}")"
+		if [ -n "$l2tptuple" ]; then
+			local l2tpsession_id l2tptunnel_id
+			l2tpsession_id=${l2tptuple%:*}
+			l2tptunnel_id=${l2tptuple#*:}
+			ebegin "Destroying L2TPv3 tunnel ${IFACE}"
+			veinfo ip l2tp del session tunnel_id $l2tptunnel_id session_id $l2tpsession_id
+			ip l2tp del session tunnel_id $l2tptunnel_id session_id $l2tpsession_id
+			if [ -z "$(ip l2tp show session | grep -E "^Session [0-9]+ in tunnel $l2tptunnel_id\$")" ]; then
+				#tunnel $l2tptunnel_id no longer used, destoying it...
+				veinfo ip l2tp del tunnel tunnel_id $l2tptunnel_id
+				ip l2tp del tunnel tunnel_id $l2tptunnel_id
+			fi
+			eend $?
+		fi
 	fi
 }
 


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2016-07-05 18:14 Robin H. Johnson
  0 siblings, 0 replies; 109+ messages in thread
From: Robin H. Johnson @ 2016-07-05 18:14 UTC (permalink / raw
  To: gentoo-commits

commit:     3bdc8488c51bfb1a84c27855f4dd83e814fa81e3
Author:     Emeric Verschuur <emeric <AT> mbedsys <DOT> org>
AuthorDate: Sun May  1 13:38:41 2016 +0000
Commit:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
CommitDate: Sun May  1 13:38:41 2016 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=3bdc8488

Start/stop message update

 net/l2tp.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/l2tp.sh b/net/l2tp.sh
index 24f5f8c..5efb535 100644
--- a/net/l2tp.sh
+++ b/net/l2tp.sh
@@ -100,7 +100,7 @@ l2tp_pre_start()
 	eval l2tpsession=\$l2tpsession_${IFVAR}
 	test -n "${l2tpsession}" || return 0
 	
-	ebegin "Creating L2TP tunnel ${IFVAR}"
+	ebegin "Creating L2TPv3 link ${IFVAR}"
 	local l2tp_err s_name s_tunnel_id s_session_id s_peer_session_id s_cookie s_peer_cookie s_offset s_peer_offset s_l2spec_type
 	if ! _l2tp_eval_props s_ "name|tunnel_id|session_id|peer_session_id|cookie|peer_cookie|offset|peer_offset|l2spec_type" "${l2tpsession}"; then
 		eend 1 "l2tpsession_${IFVAR} syntax error: $l2tp_err"
@@ -157,7 +157,7 @@ l2tp_post_stop()
 	local session_id tunnel_id
 	_is_l2tp || return 0
 	
-	ebegin "Destroying L2TP tunnel ${IFACE}"
+	ebegin "Destroying L2TPv3 link ${IFACE}"
 	veinfo ip l2tp del session tunnel_id $tunnel_id session_id $session_id
 	ip l2tp del session tunnel_id $tunnel_id session_id $session_id
 	if ! ip l2tp show session | grep -Eq "^Session [0-9]+ in tunnel $tunnel_id\$"; then


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2016-07-05 18:09 Robin H. Johnson
  0 siblings, 0 replies; 109+ messages in thread
From: Robin H. Johnson @ 2016-07-05 18:09 UTC (permalink / raw
  To: gentoo-commits

commit:     d72fb7cc7fe42a0c54ed37fc6b33c5522661af8a
Author:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
AuthorDate: Tue Jul  5 18:09:02 2016 +0000
Commit:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
CommitDate: Tue Jul  5 18:09:11 2016 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=d72fb7cc

arping: one more path per bug #566142.

Bug: https://bugs.gentoo.org/566142
Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org>

 net/arping.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/arping.sh b/net/arping.sh
index 65eb617..b03b8a9 100644
--- a/net/arping.sh
+++ b/net/arping.sh
@@ -3,7 +3,7 @@
 
 arping_depend()
 {
-	program /sbin/arping /bin/arping /usr/sbin/arping2
+	program /sbin/arping /bin/arping /usr/sbin/arping /usr/sbin/arping2
 	before interface
 }
 


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2015-11-08 14:33 Robin H. Johnson
  0 siblings, 0 replies; 109+ messages in thread
From: Robin H. Johnson @ 2015-11-08 14:33 UTC (permalink / raw
  To: gentoo-commits

commit:     a4fcc78c90893103d012ae1dc05a2a8f42d7cdaa
Author:     Alon Bar-Lev <alonbl <AT> gentoo <DOT> org>
AuthorDate: Sat Nov  7 20:02:59 2015 +0000
Commit:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
CommitDate: Sun Nov  8 07:13:36 2015 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=a4fcc78c

net: bridge: add warning when using sysfs variables without prefix

Signed-off-by: Alon Bar-Lev <alonbl <AT> gentoo.org>

 net/bridge.sh | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/net/bridge.sh b/net/bridge.sh
index 407b578..3dfd8b1 100644
--- a/net/bridge.sh
+++ b/net/bridge.sh
@@ -129,6 +129,7 @@ bridge_pre_start()
 		for prefix in "" bridge_; do
 			eval s=\$${prefix}${n}_${IFVAR}
 			if [ -n "${s}" ]; then
+				[ -z "${prefix}" ] && ewarn "sysfs key '${n}_${IFVAR}' should be prefixed, please add bridge_ prefix."
 				einfo "Setting ${n}: ${s}"
 				echo "${s}" >"${x}" || \
 				eerror "Failed to configure $n (${n}_${IFVAR})"
@@ -167,6 +168,7 @@ bridge_pre_start()
 				for prefix in "" brport_; do
 					eval s=\$${prefix}${n}_${IFVAR}
 					if [ -n "${s}" ]; then
+						[ -z "${prefix}" ] && ewarn "sysfs key '${n}_${IFVAR}' should be prefixed, please add brport_ prefix."
 						einfo "Setting ${n}@${IFACE}: ${s}"
 						echo "${s}" >"${x}" || \
 						eerror "Failed to configure $n (${n}_${IFVAR})"


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2015-05-25 10:04 Mike Frysinger
  0 siblings, 0 replies; 109+ messages in thread
From: Mike Frysinger @ 2015-05-25 10:04 UTC (permalink / raw
  To: gentoo-commits

commit:     50c9fd7827fa58d27a593c8c480068f85c047cec
Author:     Thomas D <whissi <AT> whissi <DOT> de>
AuthorDate: Wed Apr 16 09:51:56 2014 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Tue Mar 10 16:14:49 2015 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=50c9fd78

net/iproute2: Add timeout information and timeout progress indicator

With this patch we will show the currently set dad_timeout value to the
user. The timeout progress will be shown using dots.

The idea is stolen from _wait_for_carrier() in init.d/net.lo.in.

This patch will also undo commit

  732a9a4999f479ee97a404252f6a0eba4a86e338

X-Gentoo-Bug: 488250
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=488250

 net/iproute2.sh | 25 +++++++++++++++++--------
 1 file changed, 17 insertions(+), 8 deletions(-)

diff --git a/net/iproute2.sh b/net/iproute2.sh
index 7918941..8053b2f 100644
--- a/net/iproute2.sh
+++ b/net/iproute2.sh
@@ -351,9 +351,10 @@ _iproute2_ipv6_tentative()
 
 iproute2_post_start()
 {
-	local n=
-	eval n=\$dad_timeout_${IFVAR}
-	[ -z "$n" ] && n=${dad_timeout:-10}
+	local _dad_timeout=
+
+	eval _dad_timeout=\$dad_timeout_${IFVAR}
+	_dad_timeout=${_dad_timeout:-${dad_timeout:-5}}
 
 	local policyroute_order=
 	eval policyroute_order=\$policy_rules_before_routes_${IFVAR}
@@ -361,14 +362,22 @@ iproute2_post_start()
 	yesno "$policyroute_order" || _iproute2_policy_routing
 
 	if _iproute2_ipv6_tentative; then
-		ebegin "Waiting for IPv6 addresses"
-		while [ $n -ge 0 ]; do
+		einfon "Waiting for IPv6 addresses (${_dad_timeout} seconds) "
+		while [ $_dad_timeout -gt 0 ]; do
 			_iproute2_ipv6_tentative || break
 			sleep 1
-			: $(( n -= 1 ))
+			: $(( _dad_timeout -= 1 ))
+			printf "."
 		done
-		[ $n -ge 0 ]
-		eend $?
+
+		echo ""
+
+		if [ $_dad_timeout -le 0 ]; then
+			eend 1
+			return 1
+		else
+			eend 0
+		fi
 	fi
 
 	return 0


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2015-05-25 10:04 Mike Frysinger
  0 siblings, 0 replies; 109+ messages in thread
From: Mike Frysinger @ 2015-05-25 10:04 UTC (permalink / raw
  To: gentoo-commits

commit:     6befe06a7e72b5b7f17c7f1118fc16000a0cce13
Author:     Doug Freed <dwfreed <AT> mtu <DOT> edu>
AuthorDate: Sat Mar 14 23:55:06 2015 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Sat Mar 14 23:55:06 2015 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=6befe06a

bridge: use/prefer iproute2/sysfs where possible

Use and prefer iproute2 and sysfs over bridge-utils where possible.
Most users already have iproute2 installed, so this reduces the number
of external programs they need to use all of netifrc's functionality.

 net/bridge.sh | 89 +++++++++++++++++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 83 insertions(+), 6 deletions(-)

diff --git a/net/bridge.sh b/net/bridge.sh
index 60d3eeb..87e4055 100644
--- a/net/bridge.sh
+++ b/net/bridge.sh
@@ -4,7 +4,7 @@
 bridge_depend()
 {
 	before interface macnet
-	program brctl
+	program ip brctl
 }
 
 _config_vars="$_config_vars bridge bridge_add brctl"
@@ -29,6 +29,83 @@ _bridge_ports()
 	done
 }
 
+_brctl()
+{
+	if [ -z "${_bridge_use_ip}" ]; then
+	       if ip -V >/dev/null 2>&1 && [ "$(ip -V | cut -c 24-29)" -ge 130430 ]; then
+			_bridge_use_ip=1
+		else
+			_bridge_use_ip=0
+		fi
+	fi
+	if [ "${_bridge_use_ip}" -eq 1 ]; then
+		case "$1" in
+			addbr)
+				ip link add "$2" type bridge
+				;;
+			delbr)
+				ip link del "$2"
+				;;
+			addif)
+				ip link set "$3" master "$2"
+				;;
+			delif)
+				ip link set "$3" nomaster
+				;;
+			setageing)
+				echo "$3" > /sys/class/net/"$2"/bridge/ageing_time
+				;;
+			setgcint)
+				# appears to have been dropped in Debian, and I don't see a sysfs file for it
+				eerror "brctl setgcint is not supported!"
+				return 1
+				;;
+			stp)
+				if [ "$3" = "on" -o "$3" = "yes" -o "$3" = "1" ]; then
+					_stp_state=1
+				elif [ "$3" = "off" -o "$3" = "no" -o "$3" = "0" ]; then
+					_stp_state=0
+				else
+					eerror "Invalid STP state for brctl stp!"
+					return 1
+				fi
+				echo ${_stp_state} > /sys/class/net/"$2"/bridge/stp_state
+				;;
+			setbridgeprio)
+				echo "$3" > /sys/class/net/"$2"/bridge/priority
+				;;
+			setfd)
+				echo "$3" > /sys/class/net/"$2"/bridge/forward_delay
+				;;
+			sethello)
+				echo "$3" > /sys/class/net/"$2"/bridge/hello_time
+				;;
+			setmaxage)
+				echo "$3" > /sys/class/net/"$2"/bridge/max_age
+				;;
+			setpathcost)
+				echo "$4" > /sys/class/net/"$2"/brif/"$3"/path_cost
+				;;
+			setportprio)
+				echo "$4" > /sys/class/net/"$2"/brif/"$3"/priority
+				;;
+			hairpin)
+				if [ "$4" -eq "on" -o "$4" -eq "yes" -o "$4" -eq "1" ]; then
+					_hairpin_mode=1
+				elif [ "$4" -eq "off" -o "$4" -eq "no" -o "$4" -eq "0" ]; then
+					_hairpin_mode=0
+				else
+					eerror "Invalid hairpin mode for brctl hairpin!"
+					return 1
+				fi
+				echo ${_hairpin_mode} > /sys/class/net/"$2"/brif/"$3"/hairpin_mode
+				;;
+		esac
+	else
+		brctl "$@"
+	fi
+}
+
 bridge_pre_start()
 {
 	local brif= oiface="${IFACE}" e= x=
@@ -70,7 +147,7 @@ bridge_pre_start()
 
 	if ! _is_bridge ; then
 		ebegin "Creating bridge ${IFACE}"
-		if ! brctl addbr "${IFACE}"; then
+		if ! _brctl addbr "${IFACE}"; then
 			eend 1
 			return 1
 		fi
@@ -89,7 +166,7 @@ bridge_pre_start()
 		x=$1
 		shift
 		set -- "${x}" "${IFACE}" "$@"
-		brctl "$@"
+		_brctl "$@"
 	done
 	unset IFS
 
@@ -120,7 +197,7 @@ bridge_pre_start()
 			fi
 			# The interface is known to exist now
 			_up
-			if ! brctl addif "${BR_IFACE}" "${x}"; then
+			if ! _brctl addif "${BR_IFACE}" "${x}"; then
 				eend 1
 				return 1
 			fi
@@ -176,13 +253,13 @@ bridge_post_stop()
 		ebegin "Removing port ${port}${extra}"
 		local IFACE="${port}"
 		_set_flag -promisc
-		brctl delif "${iface}" "${port}"
+		_brctl delif "${iface}" "${port}"
 		eend $?
 	done
 
 	if ${delete}; then
 		eoutdent
-		brctl delbr "${iface}"
+		_brctl delbr "${iface}"
 		eend $?
 	fi
 


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2015-05-25 10:04 Mike Frysinger
  0 siblings, 0 replies; 109+ messages in thread
From: Mike Frysinger @ 2015-05-25 10:04 UTC (permalink / raw
  To: gentoo-commits

commit:     791f8201d0318fc9e41c27d698d558cac497e40e
Author:     Thomas D <whissi <AT> whissi <DOT> de>
AuthorDate: Wed Apr 16 09:52:26 2014 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Tue Mar 10 16:14:49 2015 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=791f8201

net/iproute2: No need to use 'grep' for checking tentative state

We don't need 'grep' to check the tentative state, because the 'ip' utility
has a builtin command for that.

X-Gentoo-Bug: 488260
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=488260

 net/iproute2.sh | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/net/iproute2.sh b/net/iproute2.sh
index 8053b2f..0b2a8d6 100644
--- a/net/iproute2.sh
+++ b/net/iproute2.sh
@@ -345,8 +345,9 @@ iproute2_pre_start()
 
 _iproute2_ipv6_tentative()
 {
-	LC_ALL=C ip addr show dev "${IFACE}" | \
-		grep -q "^[[:space:]]*inet6 .* tentative"
+	[ -n "$(LC_ALL=C ip -family inet6 addr show dev ${IFACE} tentative)" ] && return 0
+
+	return 1
 }
 
 iproute2_post_start()


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2015-05-25 10:01 Mike Frysinger
  0 siblings, 0 replies; 109+ messages in thread
From: Mike Frysinger @ 2015-05-25 10:01 UTC (permalink / raw
  To: gentoo-commits

commit:     64a72e65a43fccceab640a51cbabe2f3ffea22b6
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Tue Feb 24 19:40:10 2015 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Tue Feb 24 19:40:10 2015 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=64a72e65

do not use `echo -n`

The -n option is not portable.  Use printf instead.

 net/ifconfig.sh.Linux.in | 2 +-
 net/udhcpc.sh.Linux.in   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/ifconfig.sh.Linux.in b/net/ifconfig.sh.Linux.in
index b2203cb..3d91afa 100644
--- a/net/ifconfig.sh.Linux.in
+++ b/net/ifconfig.sh.Linux.in
@@ -81,7 +81,7 @@ _get_inet_address()
 	sed -n -e 's/.*\(inet addr:\|inet \)\([^ ]*\).*\(Mask:\|netmask \)\([^ ]*\).*/\2 \4/p')
 	[ -z "$1" ] && return 1
 
-	echo -n "$1"
+	printf '%s' "$1"
 	shift
 	echo "/$(_netmask2cidr "$1")"
 }

diff --git a/net/udhcpc.sh.Linux.in b/net/udhcpc.sh.Linux.in
index bb502e5..b6e0327 100644
--- a/net/udhcpc.sh.Linux.in
+++ b/net/udhcpc.sh.Linux.in
@@ -25,7 +25,7 @@ udhcpc_start()
 	# but it creates temporary files.
 	# We can move this stuff to udhcpc hook script to avoid that, should we do?
 	local conf="/var/run/udhcpc-${IFACE}.conf"
-	echo -n >"$conf"
+	>"$conf"
 	# Map some generic options to dhcpcd
 	for opt in ${opts}; do
 		case "${opt}" in


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2015-01-22 23:01 Robin H. Johnson
  0 siblings, 0 replies; 109+ messages in thread
From: Robin H. Johnson @ 2015-01-22 23:01 UTC (permalink / raw
  To: gentoo-commits

commit:     cc1d16c46c4ff0261f8be499769f49a3527a03c6
Author:     Doug Freed <dwfreed <AT> mtu <DOT> edu>
AuthorDate: Tue Jan 13 23:20:05 2015 +0000
Commit:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
CommitDate: Fri Jan 16 20:37:06 2015 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/netifrc.git;a=commit;h=cc1d16c4

firewalld: remove use of OpenRC need function

You can't use OpenRC's dependency functions in module depend functions,
because they aren't called in the OpenRC init script's depend function.
System administrators are responsible for ensuring that the dependencies
for their configuration are set correctly via (for OpenRC)
/etc/conf.d/net.

---
 net/firewalld.sh | 1 -
 1 file changed, 1 deletion(-)

diff --git a/net/firewalld.sh b/net/firewalld.sh
index ae83c57..b20f571 100644
--- a/net/firewalld.sh
+++ b/net/firewalld.sh
@@ -6,7 +6,6 @@ firewalld_depend()
 	after interface
 	before dhcp
 	program firewall-cmd
-	[ "$IFACE" != "lo" ] && need firewalld
 }
 
 _config_vars="$_config_vars firewalld_zone"


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2015-01-22 23:01 Robin H. Johnson
  0 siblings, 0 replies; 109+ messages in thread
From: Robin H. Johnson @ 2015-01-22 23:01 UTC (permalink / raw
  To: gentoo-commits

commit:     f86f4c03e6b403614e4613dff5805429740b076e
Author:     Mike Gilbert <floppym <AT> gentoo <DOT> org>
AuthorDate: Sun Jan 11 05:56:51 2015 +0000
Commit:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
CommitDate: Thu Jan 15 15:28:58 2015 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/netifrc.git;a=commit;h=f86f4c03

dhcpcd: Avoid calling start-stop-daemon

X-Gentoo-Bug: 536282
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=536282

---
 net/dhcpcd.sh | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/net/dhcpcd.sh b/net/dhcpcd.sh
index bdb60c6..c598083 100644
--- a/net/dhcpcd.sh
+++ b/net/dhcpcd.sh
@@ -82,10 +82,7 @@ dhcpcd_stop()
 	[ -z "${opts}" ] && opts=${dhcp}
 	case " ${opts} " in
 		*" release "*) dhcpcd -k "${IFACE}" ;;
-		*)
-			start-stop-daemon --stop --quiet \
-				 --signal ${sig} --pidfile "${pidfile}"
-			;;
+		*) dhcpcd -x "${IFACE}" ;;
 	esac
 	eend $?
 }


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2014-12-11 18:13 Robin H. Johnson
  0 siblings, 0 replies; 109+ messages in thread
From: Robin H. Johnson @ 2014-12-11 18:13 UTC (permalink / raw
  To: gentoo-commits

commit:     a93c80793276a026eef5be351cf33377945d8518
Author:     Patrick McLean <patrickm <AT> gaikai <DOT> com>
AuthorDate: Wed Dec 10 21:58:26 2014 +0000
Commit:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
CommitDate: Wed Dec 10 22:20:41 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/netifrc.git;a=commit;h=a93c8079

bonding: use iproute2 rather than ifconfig if it is installed

Currently the bonding contains 2 calls to ifconfig for a couple of operations,
this makes it use iproute2 instead if it is installed.

---
 net/bonding.sh | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/net/bonding.sh b/net/bonding.sh
index fb00825..ba75239 100644
--- a/net/bonding.sh
+++ b/net/bonding.sh
@@ -4,7 +4,7 @@
 bonding_depend()
 {
 	before interface macchanger
-	program /sbin/ifconfig /bin/ifconfig
+	program ip /sbin/ifconfig /bin/ifconfig
 	# If you do not have sysfs, you MUST have this binary instead for ioctl
 	# Also you will loose some functionality that cannot be done via sysfs:
 	if [ ! -d /sys/class/net ]; then
@@ -124,7 +124,12 @@ bonding_pre_start()
 		unset oiface
 		eoutdent
 		# subsume (presumably kernel auto-)configured IP
-		ifconfig ${IFACE} ${addr} up
+		if [ -x "$(command -v ip)" ]; then
+			ip link set ${IFACE} up
+			ip address add ${addr} dev ${IFACE}
+		else
+			ifconfig ${IFACE} ${addr} up
+		fi
 	else
 		# warn if root on nfs and no subsume interface supplied
 		local root_fs_type=$(mountinfo -s /)
@@ -179,7 +184,11 @@ bonding_stop()
 
 	# Wipe subsumed interface
 	if [ -n "${subsume}" ]; then
-		ifconfig ${subsume} 0.0.0.0
+		if [ -x "$(command -v ip)" ]; then
+			ip address flush dev ${subsume}
+		else
+			ifconfig ${subsume} 0.0.0.0
+		fi
 	fi
 
 	local slaves= s=


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2014-09-24  6:19 Robin H. Johnson
  0 siblings, 0 replies; 109+ messages in thread
From: Robin H. Johnson @ 2014-09-24  6:19 UTC (permalink / raw
  To: gentoo-commits

commit:     42aa70384a89346dd1733dfff4131f56178dc26a
Author:     Nuno Silva (njsg) <njsg <AT> iki <DOT> fi>
AuthorDate: Sat Sep 20 06:53:59 2014 +0000
Commit:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
CommitDate: Wed Sep 24 06:19:32 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/netifrc.git;a=commit;h=42aa7038

Use dhcpcd -k to force the release, instead of SIGHUP

Newer dhcpcd versions use a different signal internally (SIGALRM), but
dhcpcd -k interface_name will work with both newer and older versions
of dhcpcd.

Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org>

---
 net/dhcpcd.sh | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/net/dhcpcd.sh b/net/dhcpcd.sh
index 2c0f919..bdb60c6 100644
--- a/net/dhcpcd.sh
+++ b/net/dhcpcd.sh
@@ -81,8 +81,11 @@ dhcpcd_stop()
 	eval opts=\$dhcp_${IFVAR}
 	[ -z "${opts}" ] && opts=${dhcp}
 	case " ${opts} " in
-		*" release "*) sig=SIGHUP;;
+		*" release "*) dhcpcd -k "${IFACE}" ;;
+		*)
+			start-stop-daemon --stop --quiet \
+				 --signal ${sig} --pidfile "${pidfile}"
+			;;
 	esac
-	start-stop-daemon --stop --quiet --signal ${sig} --pidfile "${pidfile}"
 	eend $?
 }


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2014-07-17 17:56 Robin H. Johnson
  0 siblings, 0 replies; 109+ messages in thread
From: Robin H. Johnson @ 2014-07-17 17:56 UTC (permalink / raw
  To: gentoo-commits

commit:     201434997a89ced0f6a672101498f83d7ca6786a
Author:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
AuthorDate: Wed Jul 16 19:16:16 2014 +0000
Commit:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
CommitDate: Wed Jul 16 19:17:43 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/netifrc.git;a=commit;h=20143499

iproute2: more ip6 tunnel modes.

Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org>
X-Gentoo-Bug: 516920
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=516920

---
 net/iproute2.sh | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/net/iproute2.sh b/net/iproute2.sh
index 7f0eccb..7918941 100644
--- a/net/iproute2.sh
+++ b/net/iproute2.sh
@@ -303,11 +303,14 @@ iproute2_pre_start()
 	if [ -n "${tunnel}" ]; then
 		# Set our base metric to 1000
 		metric=1000
-		# Bug#347657: If the mode is 'ipip6' or 'ip6ip6', the -6 must be passed
-		# to iproute2 during tunnel creation.
+		# Bug#347657: If the mode is ipip6, ip6ip6, ip6gre or any, the -6 must
+		# be passed to iproute2 during tunnel creation.
+		# state 'any' does not exist for IPv4
 		local ipproto=''
 		[ "${tunnel##mode ipip6}" != "${tunnel}" ] && ipproto='-6'
 		[ "${tunnel##mode ip6ip6}" != "${tunnel}" ] && ipproto='-6'
+		[ "${tunnel##mode ip6gre}" != "${tunnel}" ] && ipproto='-6'
+		[ "${tunnel##mode any}" != "${tunnel}" ] && ipproto='-6'
 
 		ebegin "Creating tunnel ${IFVAR}"
 		veinfo ip ${ipproto} tunnel add ${tunnel} name "${IFACE}"


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2014-07-17 17:56 Robin H. Johnson
  0 siblings, 0 replies; 109+ messages in thread
From: Robin H. Johnson @ 2014-07-17 17:56 UTC (permalink / raw
  To: gentoo-commits

commit:     10c365a266c390d0d3e1c26fdb991022e0cd7235
Author:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
AuthorDate: Wed Jul 16 19:13:20 2014 +0000
Commit:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
CommitDate: Wed Jul 16 19:17:21 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/netifrc.git;a=commit;h=10c365a2

iproute2: verbose output

All ip commands that change state should have a ve* call before them to
enable verbose output of what is going on.

Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org>

---
 net/iproute2.sh | 25 +++++++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)

diff --git a/net/iproute2.sh b/net/iproute2.sh
index 096e724..7f0eccb 100644
--- a/net/iproute2.sh
+++ b/net/iproute2.sh
@@ -10,11 +10,13 @@ iproute2_depend()
 
 _up()
 {
+	veinfo ip link set dev "${IFACE}" up
 	ip link set dev "${IFACE}" up
 }
 
 _down()
 {
+	veinfo ip link set dev "${IFACE}" down
 	ip link set dev "${IFACE}" down
 }
 
@@ -57,6 +59,7 @@ _set_flag()
 		flag=${flag#-}
 		opt="off"
 	fi
+	veinfo ip link set dev "${IFACE}" "${flag}" "${opt}"
 	ip link set dev "${IFACE}" "${flag}" "${opt}"
 }
 
@@ -79,6 +82,7 @@ _get_mac_address()
 
 _set_mac_address()
 {
+	veinfo ip link set dev "${IFACE}" address "$1"
 	ip link set dev "${IFACE}" address "$1"
 }
 
@@ -98,6 +102,7 @@ _get_inet_address()
 _add_address()
 {
 	if [ "$1" = "127.0.0.1/8" -a "${IFACE}" = "lo" ]; then
+		veinfo ip addr add "$@" dev "${IFACE}" 2>/dev/null
 		ip addr add "$@" dev "${IFACE}" 2>/dev/null
 		return 0
 	fi
@@ -202,9 +207,12 @@ _add_route()
 
 _delete_addresses()
 {
+	veinfo ip addr flush dev "${IFACE}" scope global 2>/dev/null
 	ip addr flush dev "${IFACE}" scope global 2>/dev/null
+	veinfo ip addr flush dev "${IFACE}" scope site 2>/dev/null
 	ip addr flush dev "${IFACE}" scope site 2>/dev/null
 	if [ "${IFACE}" != "lo" ]; then
+		veinfo ip addr flush dev "${IFACE}" scope host 2>/dev/null
 		ip addr flush dev "${IFACE}" scope host 2>/dev/null
 	fi
 	return 0
@@ -217,6 +225,7 @@ _has_carrier()
 
 _tunnel()
 {
+	veinfo ip tunnel "$@"
 	ip tunnel "$@"
 }
 
@@ -266,6 +275,7 @@ _iproute2_policy_routing()
 				_ip_rule_runner -4 add "${rules}"
 			fi
 		fi
+		veinfo ip -4 route flush table cache dev "${IFACE}"
 		ip -4 route flush table cache dev "${IFACE}"
 	fi
 
@@ -281,6 +291,7 @@ _iproute2_policy_routing()
 				_ip_rule_runner -6 add "${rules}"
 			fi
 		fi
+		veinfo ip -6 route flush table cache dev "${IFACE}"
 		ip -6 route flush table cache dev "${IFACE}"
 	fi
 }
@@ -299,6 +310,7 @@ iproute2_pre_start()
 		[ "${tunnel##mode ip6ip6}" != "${tunnel}" ] && ipproto='-6'
 
 		ebegin "Creating tunnel ${IFVAR}"
+		veinfo ip ${ipproto} tunnel add ${tunnel} name "${IFACE}"
 		ip ${ipproto} tunnel add ${tunnel} name "${IFACE}"
 		eend $? || return 1
 		_up
@@ -307,12 +319,18 @@ iproute2_pre_start()
 	# MTU support
 	local mtu=
 	eval mtu=\$mtu_${IFVAR}
-	[ -n "${mtu}" ] && ip link set dev "${IFACE}" mtu "${mtu}"
+	if [ -n "${mtu}" ]; then
+		veinfo ip link set dev "${IFACE}" mtu "${mtu}"
+		ip link set dev "${IFACE}" mtu "${mtu}"
+	fi
 
 	# TX Queue Length support
 	local len=
 	eval len=\$txqueuelen_${IFVAR}
-	[ -n "${len}" ] && ip link set dev "${IFACE}" txqueuelen "${len}"
+	if [ -n "${len}" ]; then
+		veinfo ip link set dev "${IFACE}" txqueuelen "${len}"
+		ip link set dev "${IFACE}" txqueuelen "${len}"
+	fi
 
 	local policyroute_order=
 	eval policyroute_order=\$policy_rules_before_routes_${IFVAR}
@@ -365,6 +383,7 @@ iproute2_post_stop()
 
 		# Only do something if the interface actually exist
 		if _exists; then
+			veinfo ip -4 route flush table cache dev "${IFACE}"
 			ip -4 route flush table cache dev "${IFACE}"
 		fi
 	fi
@@ -379,6 +398,7 @@ iproute2_post_stop()
 
 		# Only do something if the interface actually exist
 		if _exists; then
+			veinfo ip -6 route flush table cache dev "${IFACE}"
 			ip -6 route flush table cache dev "${IFACE}"
 		fi
 	fi
@@ -387,6 +407,7 @@ iproute2_post_stop()
 	if [ "${IFACE}" != "sit0" ]; then
 		if [ -n "$(ip tunnel show "${IFACE}" 2>/dev/null)" ]; then
 			ebegin "Destroying tunnel ${IFACE}"
+			veinfo ip tunnel del "${IFACE}"
 			ip tunnel del "${IFACE}"
 			eend $?
 		fi


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2014-04-15 18:18 Robin H. Johnson
  0 siblings, 0 replies; 109+ messages in thread
From: Robin H. Johnson @ 2014-04-15 18:18 UTC (permalink / raw
  To: gentoo-commits

commit:     fc69aa3192ad56b4527248820e3a628da3a91809
Author:     Rick Farina (Zero_Chaos) <zerochaos <AT> gentoo <DOT> org>
AuthorDate: Tue Apr 15 18:11:05 2014 +0000
Commit:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
CommitDate: Tue Apr 15 18:18:34 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/netifrc.git;a=commit;h=fc69aa31

net/macchanger: fix for bug 503358

This adds support for macchanger 1.6 as well as keeping support
for macchanger <1.6.

Reported-By: teknocratdefunct <AT> riseup.net
X-Gentoo-Bug: 504458
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=504458
Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org>

---
 net/macchanger.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/macchanger.sh b/net/macchanger.sh
index 4e535ec..ff13770 100644
--- a/net/macchanger.sh
+++ b/net/macchanger.sh
@@ -69,13 +69,13 @@ macchanger_pre_start()
 	fi
 
 	mac=$(/sbin/macchanger ${opts} "${IFACE}" \
-		| sed -n -e 's/^Faked MAC:.*\<\(..:..:..:..:..:..\)\>.*/\U\1/p' )
+		| sed -n -e 's/^\(Faked\|New\) MAC:.*\<\(..:..:..:..:..:..\)\>.*/\U\2/p' )
 	_up
 
 	# Sometimes the interface needs to be up ....
 	if [ -z "${mac}" ]; then
 		mac=$(/sbin/macchanger ${opts} "${IFACE}" \
-		| sed -n -e 's/^Faked MAC:.*\<\(..:..:..:..:..:..\)\>.*/\U\1/p' )
+		| sed -n -e 's/^\(Faked\|New\) MAC:.*\<\(..:..:..:..:..:..\)\>.*/\U\2/p' )
 	fi
 
 	if [ -z "${mac}" ]; then


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2013-08-28 16:59 Robin H. Johnson
  0 siblings, 0 replies; 109+ messages in thread
From: Robin H. Johnson @ 2013-08-28 16:59 UTC (permalink / raw
  To: gentoo-commits

commit:     d0a28ef9f91d74678fb8c40e66a63bacc9f01bac
Author:     Alexander Tsoy <alexander <AT> tsoy <DOT> me>
AuthorDate: Wed Aug 28 16:50:13 2013 +0000
Commit:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
CommitDate: Wed Aug 28 16:50:13 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/netifrc.git;a=commit;h=d0a28ef9

ifconfig: support ipv6 routes without default prefix.

ifconfig module does not support IPv6 routes without
default prefix, eg "-net ::/0"

Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org>
X-Gentoo-Bug: 442594

---
 net/ifconfig.sh.Linux.in | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/net/ifconfig.sh.Linux.in b/net/ifconfig.sh.Linux.in
index 2afa66c..b2203cb 100644
--- a/net/ifconfig.sh.Linux.in
+++ b/net/ifconfig.sh.Linux.in
@@ -208,9 +208,11 @@ _add_route()
 		set -- "${one}" "${two}" gw "$@"
 	fi
 
-	case "$@" in
-		*:*|default*) [ "$1" = "-net" -o "$1" = "-host" ] && shift;;
-	esac
+	if [ "$1" = "-net" -o "$1" = "-host" ]; then
+		if [ "${2##*:}" != "$2" ]; then shift
+		elif [ "$2" = "default" ]; then shift
+		fi
+	fi
 
 	route ${family} add "$@" dev "${IFACE}"
 }


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2013-08-27 20:06 Ian Stakenvicius
  0 siblings, 0 replies; 109+ messages in thread
From: Ian Stakenvicius @ 2013-08-27 20:06 UTC (permalink / raw
  To: gentoo-commits

commit:     96eff38b65aba35943f2f3c22466eb7a5553c274
Author:     Ian Stakenvicius <axs <AT> gentoo <DOT> org>
AuthorDate: Tue Aug 27 20:06:39 2013 +0000
Commit:     Ian Stakenvicius <axs <AT> gentoo <DOT> org>
CommitDate: Tue Aug 27 20:06:39 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/netifrc.git;a=commit;h=96eff38b

fixed paths for arping tool due to ~arch iputils path migration, bug 458090

---
 net/apipa.sh  | 2 +-
 net/arping.sh | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/apipa.sh b/net/apipa.sh
index a4aee8a..6f3f910 100644
--- a/net/apipa.sh
+++ b/net/apipa.sh
@@ -3,7 +3,7 @@
 
 apipa_depend()
 {
-	program /sbin/arping
+	program /sbin/arping /bin/arping
 }
 
 _random()

diff --git a/net/arping.sh b/net/arping.sh
index 83360d7..65eb617 100644
--- a/net/arping.sh
+++ b/net/arping.sh
@@ -3,7 +3,7 @@
 
 arping_depend()
 {
-	program /sbin/arping /usr/sbin/arping2
+	program /sbin/arping /bin/arping /usr/sbin/arping2
 	before interface
 }
 


^ permalink raw reply related	[flat|nested] 109+ messages in thread
* [gentoo-commits] proj/netifrc:master commit in: net/
@ 2013-08-25  8:17 Robin H. Johnson
  0 siblings, 0 replies; 109+ messages in thread
From: Robin H. Johnson @ 2013-08-25  8:17 UTC (permalink / raw
  To: gentoo-commits

commit:     ea75a2a347a806a647a43a3d896d7815b0133434
Author:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
AuthorDate: Sun Aug 25 08:12:56 2013 +0000
Commit:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
CommitDate: Sun Aug 25 08:14:12 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/netifrc.git;a=commit;h=ea75a2a3

Bug #460756: Make clip module quiet.

This is a workaround as OpenRC is no longer silent on errors even with
--quiet. Bug #482396 tracks the OpenRC issue.

Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org>
X-Gentoo-Bug: 460756
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=460756

---
 net/clip.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/clip.sh b/net/clip.sh
index 2fc290f..ca98250 100644
--- a/net/clip.sh
+++ b/net/clip.sh
@@ -73,10 +73,11 @@ atmclip_svcs_stop()
 
 are_atmclip_svcs_running()
 {
-
+	[ -f /var/run/atmarpd.pid ] || return 1
 	start-stop-daemon --quiet --test --stop --pidfile /var/run/atmarpd.pid || return 1
 
 	if yesno ${clip_full:-yes}; then
+		[ -f /var/run/ilmid.pid -a -f /var/run/atmsigd.pid ] || return 1
 		start-stop-daemon --quiet --test --stop --pidfile /var/run/ilmid.pid || return 1
 		start-stop-daemon --quiet --test --stop --pidfile /var/run/atmsigd.pid || return 1
 	fi


^ permalink raw reply related	[flat|nested] 109+ messages in thread

end of thread, other threads:[~2024-09-29  0:29 UTC | newest]

Thread overview: 109+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-08 14:30 [gentoo-commits] proj/netifrc:master commit in: net/ Robin H. Johnson
  -- strict thread matches above, loose matches on Subject: below --
2024-09-29  0:28 Sam James
2024-09-23 12:02 Sam James
2024-09-09 22:43 Patrick McLean
2024-09-01  9:22 Sam James
2024-09-01  9:21 Sam James
2024-08-28 18:54 Patrick McLean
2024-06-11  0:39 Patrick McLean
2024-06-11  0:39 Patrick McLean
2024-05-23 18:12 Patrick McLean
2023-11-26  5:31 Robin H. Johnson
2023-11-25  4:52 Robin H. Johnson
2023-10-19 22:57 Sam James
2023-09-10 15:15 Sam James
2023-05-29  0:17 Mike Gilbert
2023-04-19 17:14 Robin H. Johnson
2023-04-17  4:35 Sam James
2023-02-12  6:54 Sam James
2023-01-19 18:50 Sam James
2023-01-19 18:50 Sam James
2023-01-17 15:06 Sam James
2023-01-17 15:06 Sam James
2023-01-17 15:06 Sam James
2023-01-15 20:37 Sam James
2023-01-15 14:03 Sam James
2023-01-15 14:03 Sam James
2023-01-15  1:53 Sam James
2023-01-15  1:51 Sam James
2023-01-15  1:51 Sam James
2022-12-25 19:14 Robin H. Johnson
2022-12-25 19:07 Robin H. Johnson
2021-03-31  1:11 Patrick McLean
2021-03-11 16:54 Lars Wendler
2021-03-11 16:54 Lars Wendler
2021-03-11 16:54 Lars Wendler
2021-02-02  8:28 Lars Wendler
2021-01-27 16:55 Lars Wendler
2021-01-27 14:19 Lars Wendler
2021-01-27 14:06 Lars Wendler
2021-01-24 10:37 Lars Wendler
2021-01-18 14:40 Lars Wendler
2021-01-18 13:04 Lars Wendler
2021-01-18 12:33 Lars Wendler
2021-01-18 12:33 Lars Wendler
2021-01-05 14:27 Lars Wendler
2021-01-05 12:46 Lars Wendler
2021-01-05 12:46 Lars Wendler
2020-12-15 20:11 Lars Wendler
2020-06-02 21:54 Robin H. Johnson
2020-05-31  6:05 Robin H. Johnson
2020-05-31  5:42 Robin H. Johnson
2020-05-31  5:29 Robin H. Johnson
2020-05-31  5:29 Robin H. Johnson
2020-05-31  5:13 Robin H. Johnson
2020-05-31  5:13 Robin H. Johnson
2020-01-04  8:06 Robin H. Johnson
2020-01-04  7:59 Robin H. Johnson
2019-07-09 19:59 Ben Kohler
2019-07-09 19:59 Ben Kohler
2019-07-09 17:39 Ben Kohler
2019-04-21  4:11 Robin H. Johnson
2018-07-12  6:25 Robin H. Johnson
2018-07-10 21:11 Jason Donenfeld
2018-01-21 21:59 Robin H. Johnson
2017-11-27 20:22 Robin H. Johnson
2017-11-27 20:22 Robin H. Johnson
2017-11-14 20:48 Robin H. Johnson
2017-11-14 20:48 Robin H. Johnson
2017-10-21 20:56 Robin H. Johnson
2017-06-09 23:59 Robin H. Johnson
2017-06-09 23:55 Robin H. Johnson
2017-06-09 23:52 Robin H. Johnson
2017-06-09 23:52 Robin H. Johnson
2017-01-27 21:54 Robin H. Johnson
2016-10-27  1:23 Robin H. Johnson
2016-10-24 23:16 Robin H. Johnson
2016-10-24 20:58 Robin H. Johnson
2016-10-24 16:49 Robin H. Johnson
2016-10-24  0:25 Robin H. Johnson
2016-10-24  0:23 Robin H. Johnson
2016-10-24  0:23 Robin H. Johnson
2016-10-24  0:04 Robin H. Johnson
2016-10-24  0:04 Robin H. Johnson
2016-10-23 23:50 Robin H. Johnson
2016-10-23 23:50 Robin H. Johnson
2016-10-23 23:50 Robin H. Johnson
2016-10-23 22:39 Robin H. Johnson
2016-10-23 22:39 Robin H. Johnson
2016-10-05 14:42 Robin H. Johnson
2016-07-19 19:59 Robin H. Johnson
2016-07-05 18:14 Robin H. Johnson
2016-07-05 18:14 Robin H. Johnson
2016-07-05 18:14 Robin H. Johnson
2016-07-05 18:09 Robin H. Johnson
2015-11-08 14:33 Robin H. Johnson
2015-05-25 10:04 Mike Frysinger
2015-05-25 10:04 Mike Frysinger
2015-05-25 10:04 Mike Frysinger
2015-05-25 10:01 Mike Frysinger
2015-01-22 23:01 Robin H. Johnson
2015-01-22 23:01 Robin H. Johnson
2014-12-11 18:13 Robin H. Johnson
2014-09-24  6:19 Robin H. Johnson
2014-07-17 17:56 Robin H. Johnson
2014-07-17 17:56 Robin H. Johnson
2014-04-15 18:18 Robin H. Johnson
2013-08-28 16:59 Robin H. Johnson
2013-08-27 20:06 Ian Stakenvicius
2013-08-25  8:17 Robin H. Johnson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox