[gentoo-commits] proj/netifrc:master commit in: net/, doc/

2024-01-07 Thread Sam James
commit: 7b1c09f80b94f01f670c8d487df361b3ddfebe0c
Author: Matoro Mahri  matoro  tk>
AuthorDate: Sun Jan  7 07:16:30 2024 +
Commit: Sam James  gentoo  org>
CommitDate: Sun Jan  7 09:42:35 2024 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=7b1c09f8

Remove support for treecleaned net-misc/pump

Bug: https://bugs.gentoo.org/694314
Closes: https://bugs.gentoo.org/921538
Signed-off-by: Matoro Mahri  matoro.tk>
Closes: https://github.com/gentoo/netifrc/pull/51
Signed-off-by: Sam James  gentoo.org>

 doc/net.example.Linux.in |  7 ++
 net/Makefile |  2 +-
 net/dhclient.sh  |  2 +-
 net/dhcpcd.sh|  2 +-
 net/pump.sh  | 63 
 5 files changed, 5 insertions(+), 71 deletions(-)

diff --git a/doc/net.example.Linux.in b/doc/net.example.Linux.in
index cbd81e7..84e4b1c 100644
--- a/doc/net.example.Linux.in
+++ b/doc/net.example.Linux.in
@@ -493,11 +493,10 @@
 
 #-
 # DHCP
-# DHCP can be provided by dhclient, dhcpcd, pump or udhcpc.
+# DHCP can be provided by dhclient, dhcpcd, or udhcpc.
 #
 # dhclient: emerge net-misc/dhcp
 # dhcpcd:   emerge net-misc/dhcpcd
-# pump: emerge net-misc/pump
 # udhcpc:   emerge sys-apps/busybox
 
 # If you have more than one DHCP client installed, you need to specify which
@@ -508,7 +507,6 @@
 # - All clients send the current hostname to the DHCP server by default
 # - dhcpcd does not daemonize when the lease time is infinite
 # - udhcp-0.9.3-r3 and earlier do not support getting NTP servers
-# - pump does not support getting NIS servers
 # - DHCP tends to erase any existing device information - so add
 #   static addresses after dhcp if you need them
 # - dhclient and udhcpc can set other resolv.conf options such as "option"
@@ -524,11 +522,10 @@
 # default) to 10 seconds.
 #dhcpcd_eth0="-t 10"
 
-# dhclient, udhcpc and pump don't have many runtime options
+# dhclient and udhcpc don't have many runtime options
 # You can pass options to them in a similar manner to dhcpcd though
 #dhclient_eth0="..."
 #udhcpc_eth0="..."
-#pump_eth0="..."
 
 # GENERIC DHCP OPTIONS
 # Set generic DHCP options like so

diff --git a/net/Makefile b/net/Makefile
index f562d15..22bd8d1 100644
--- a/net/Makefile
+++ b/net/Makefile
@@ -12,7 +12,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 
\
-   ipppd.sh iwconfig.sh netplugd.sh pppd.sh pump.sh tuntap.sh 
udhcpc.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
 

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

diff --git a/net/dhcpcd.sh b/net/dhcpcd.sh
index 2493f27..e159f0a 100644
--- a/net/dhcpcd.sh
+++ b/net/dhcpcd.sh
@@ -10,7 +10,7 @@ dhcpcd_depend()
provide dhcp
 
# We prefer dhcpcd over these
-   after udhcpc pump dhclient
+   after udhcpc dhclient
 }
 
 _config_vars="$_config_vars dhcp dhcpcd"

diff --git a/net/pump.sh b/net/pump.sh
deleted file mode 100644
index 144316f..000
--- a/net/pump.sh
+++ /dev/null
@@ -1,63 +0,0 @@
-# Copyright (c) 2007-2008 Roy Marples 
-# Released under the 2-clause BSD license.
-# shellcheck shell=sh disable=SC1008
-
-pump_depend()
-{
-   program pump
-   after interface
-   provide dhcp
-
-   # We prefer pump over udhcpc
-   after udhcpc
-}
-
-_config_vars="$_config_vars dhcp pump"
-
-pump_start()
-{
-   local args= opt= opts=
-
-   # Get our options
-   eval opts=\$dhcp_${IFVAR}
-   [ -z "${opts}" ] && opts=${dhcp}
-
-   # Map some generic options to dhcpcd
-   for opt in ${opts}; do
-   case "${opt}" in
-   nodns) args="${args} --no-dns";;
-   nontp) args="${args} --no-ntp";;
-   nogateway) args="${args} --no-gateway";;
-   esac
-   done
-
-   # Add our route metric
-   [ "${metric:-0}" != "0" ] && args="${args} --route-metric ${metric}"
-
-   args="${args} --win-client-ident"
-   args="${args} --keep-up --interface ${IFACE}"
-
-   ebegin "Running pump"
-   eval pump "${args}"
-   eend $? || return 1
-
-   _show_address
-   return 0
-}
-
-pump_stop()
-{
-   # We check for a pump process first as querying for status
-   # causes pump to spawn a process
-   

[gentoo-commits] proj/netifrc:master commit in: net/, doc/

2023-11-24 Thread Robin H. Johnson
commit: a0b69349707b4aaaefc01fd37f1b386935d75c90
Author: Alon Bar-Lev  gmail  com>
AuthorDate: Sun May 14 21:38:28 2023 +
Commit: Robin H. Johnson  gentoo  org>
CommitDate: Sat Nov 25 04:54:01 2023 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=a0b69349

net: add qmi interface support

qmi is useful for cellular modem connection, the management interface is
implemented using libqmi's qmicli utility.

Signed-off-by: Alon Bar-Lev  gmail.com>
Signed-off-by: Robin H. Johnson  gentoo.org>
Closes: https://github.com/gentoo/netifrc/pull/44

 doc/net.example.Linux.in |  13 +
 net/Makefile |   2 +-
 net/qmi.sh   | 133 +++
 3 files changed, 147 insertions(+), 1 deletion(-)

diff --git a/doc/net.example.Linux.in b/doc/net.example.Linux.in
index 42b8071..cbd81e7 100644
--- a/doc/net.example.Linux.in
+++ b/doc/net.example.Linux.in
@@ -1132,6 +1132,19 @@
 #l2tpsession_l2tpeth2="tunnel_id 2 session_id 1 peer_session_id 1"
 #config_l2tpeth2="10.100.2.1/24"
 
+#-
+# QMI
+# For QMI support, emerge net-libs/libqmi
+# QMI is used for some cellular modems.
+#
+# Each QMI interface may have the following configuration:
+#qmi_apn_wwan0=# The name of the APN
+#qmi_auth_wwan0=   # none, pop, chap, both, Default: none
+#qmi_username_wwan0=   # Default: dummy
+#qmi_password_wwan0=   # Default dummy
+#qmi_cdc_wwan0=# Default: /dev/cdc-wmiX where 
X is taken from IFACE
+#-
+
 #-
 # Advanced Routing
 # WARNING: For advanced routing you MUST be using sys-apps/iproute2

diff --git a/net/Makefile b/net/Makefile
index 58483cd..f562d15 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 iwd.sh wireguard.sh veth.sh dhclientv6.sh
+   iw.sh iwd.sh wireguard.sh veth.sh dhclientv6.sh qmi.sh
 
 SRCS-NetBSD= ifwatchd.sh.in
 INC-NetBSD=ifwatchd.sh

diff --git a/net/qmi.sh b/net/qmi.sh
new file mode 100644
index 000..ac1b2dd
--- /dev/null
+++ b/net/qmi.sh
@@ -0,0 +1,133 @@
+# Copyright (c) 2011 by Gentoo Foundation
+# Released under the 2-clause BSD license.
+# shellcheck shell=sh disable=SC1008
+
+_is_qmi() {
+   [ -d "/sys/class/net/${IFACE}/qmi" ]
+}
+
+_get_state() {
+   echo "/run/net.${IFACE}.qmi.state"
+}
+
+_get_device() {
+   echo "/dev/cdc-$(echo "${IFACE}" | sed 's/wwan/wdm/')"
+}
+
+qmi_depend()
+{
+   program qmicli
+   program ip
+   before interface
+}
+
+qmi_pre_start() {
+
+   _is_qmi || return 0
+
+   local device
+   local apn
+   local auth
+   local username
+   local password
+   local out
+   local rc
+
+   eval device=\$qmi_cdc_${IFVAR}
+   eval apn=\$qmi_apn_${IFVAR}
+   eval auth=\$qmi_auth_${IFVAR}
+   eval username=\$qmi_username_${IFVAR}
+   eval password=\$qmi_password_${IFVAR}
+
+   [ -n "${apn}" ] || return 0
+
+   [ -n "${device}" ] || device="$(_get_device)"
+   [ -n "${auth}" ] || auth="none"
+   [ -n "${username}" ] || username="dummy"
+   [ -n "${password}" ] || password="dummy"
+
+   if ! [ -c "${device}" ]; then
+   ewarn "Cannot open device ${device} for ${IFACE}, aborting 
configuration"
+   return 1
+   fi
+
+   if ! cat "/sys/class/net/${IFACE}/qmi/raw_ip" | grep -q Y; then
+   ebegin "Configuring QMI raw IP"
+
+   ip link set "${IFACE}" down
+   if ! echo Y > "/sys/class/net/${IFACE}/qmi/raw_ip"; then
+   eend 1 "Cannot set raw IP mode for ${IFACE}, aborting 
configuration"
+   return 1
+   else
+   eend 0
+   fi
+   fi
+
+   local 
wwan_connection="apn='${apn}',auth='${auth}',username='${username}',password='${password}',autoconnect=yes,ip-type=4"
+   local n
+   for n in 1 2 3; do
+   ebegin "Connecting QMI APN '${apn}' using '${username}'"
+
+   if out="$( \
+   qmicli \
+   --device="${device}" \
+   --wds-start-network="${wwan_connection}" \
+   --device-open-proxy \
+   --client-no-release-cid \
+   )"; then
+   eend 0
+  

[gentoo-commits] proj/netifrc:master commit in: net/, doc/

2021-04-05 Thread Robin H. Johnson
commit: 4bd8be5f43d07a9e92b73174c7fbef8b989aaa55
Author: Robin H. Johnson  gentoo  org>
AuthorDate: Mon Apr  5 19:54:47 2021 +
Commit: Robin H. Johnson  gentoo  org>
CommitDate: Mon Apr  5 20:00:28 2021 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=4bd8be5f

net/ethtool: support more ethtool config knobs

Additional options now supported:
--set-channels
--set-dump
--set-fec
--set-phy-tunable
--set-priv-flags
--set-rxfh-indir
--per-queue
--features

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

 doc/net.example.Linux.in |  6 +++---
 net/ethtool.sh   | 15 +--
 2 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/doc/net.example.Linux.in b/doc/net.example.Linux.in
index b2c0f82..e59ce52 100644
--- a/doc/net.example.Linux.in
+++ b/doc/net.example.Linux.in
@@ -1318,10 +1318,10 @@
 # flash change-eeprom change pause eee coalesce ring offload tunable identify 
nfc rxfh-indir ntuple
 
 # Set global order to default
-#ethtool_order="flash change-eeprom change pause eee coalesce ring offload 
tunable identify nfc rxfh-indir ntuple"
+#ethtool_order="flash change-eeprom change priv-flags channels dump pause eee 
fec coalesce per-queue ring offload features phy-tunable tunable identify nfc 
rxfh-indir ntuple"
 
-# Hypothetical network card that requires a change-eeprom toggle to enable 
flashing
-#ethtool_order_eth0="change-eeprom flash change pause eee coalesce ring 
offload tunable nfc rxfh-indir ntuple"
+# Hypothetical network card that requires a change-eeprom or priv-flags toggle 
to enable flashing
+#ethtool_order_eth0="priv-flags change-eeprom flash channels dump pause eee 
fec coalesce per-queue ring offload features phy-tunable tunable identify nfc 
rxfh-indir ntuple"
 
 #-
 # Firewalld support

diff --git a/net/ethtool.sh b/net/ethtool.sh
index 0bcceff..ee595a2 100644
--- a/net/ethtool.sh
+++ b/net/ethtool.sh
@@ -17,7 +17,7 @@ ethtool_pre_start() {
local order opt OFS="${OIFS}"
eval order=\$ethtool_order_${IFVAR}
[ -z "${order}" ] && eval order=\$ethtool_order
-   [ -z "${order}" ] && order="flash change-eeprom change pause eee 
coalesce ring offload tunable identify nfc rxfh-indir ntuple"
+   [ -z "${order}" ] && order="flash change-eeprom change priv-flags 
channels dump pause eee fec coalesce per-queue ring offload features 
phy-tunable tunable identify nfc rxfh-indir ntuple"
# ethtool options not used: --driver, --register-dump, --eeprom-dump, 
--negotiate, --test, --statistics
eindent
for opt in ${order} ; do
@@ -36,7 +36,18 @@ ethtool_pre_start() {
local args_pretty="$(_trim "${p}")"
# Do nothing if empty
[ -z "${args_pretty}" ] && continue
-   [ "${opt}" = "eee" -o "${opt}" = "ring" -o "${opt}" = 
"tunable" ] && opt="set-${opt}"
+   case "$opt" in
+   # Cleaner to patch in future for new options
+   channels) opt="set-${opt}" ;;
+   dump) opt="set-${opt}" ;;
+   eee) opt="set-${opt}" ;;
+   fec) opt="set-${opt}" ;;
+   phy-tunable) opt="set-${opt}" ;;
+   priv-flags) opt="set-${opt}" ;;
+   ring) opt="set-${opt}" ;;
+   rxfh-indir) opt="set-${opt}" ;;
+   tunable) opt="set-${opt}" ;;
+   esac
args_pretty="--${opt} $IFACE ${args_pretty}"
args="--${opt} $IFACE ${args}"
ebegin "ethtool ${args_pretty}"



[gentoo-commits] proj/netifrc:master commit in: net/, doc/

2021-04-05 Thread Robin H. Johnson
commit: b8373edc844297fb54333ffab69d0cd0a7b5e0b8
Author: Maciej S. Szmigiero  maciej  szmigiero  name>
AuthorDate: Sat Mar 27 22:32:35 2021 +
Commit: Robin H. Johnson  gentoo  org>
CommitDate: Sat Mar 27 22:34:02 2021 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=b8373edc

net/ethtool.sh: add "eee" and "tunable" setting operations

This adds an ability to set "eee" and "tunable" ethtool parameters of a
network interface.

Signed-off-by: Maciej S. Szmigiero  maciej.szmigiero.name>

 doc/net.example.Linux.in | 12 +---
 net/ethtool.sh   |  4 ++--
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/doc/net.example.Linux.in b/doc/net.example.Linux.in
index 3bd2ee1..b2c0f82 100644
--- a/doc/net.example.Linux.in
+++ b/doc/net.example.Linux.in
@@ -1275,12 +1275,18 @@
 #ethtool_pause_eth0="autoneg off
 #rx on tx on"
 
+# Enable Energy-Efficient Ethernet
+#ethtool_eee_eth0="eee on"
+
 # Enable adaptive RX and TX coalescing
 #ethtool_coalesce_eth0="adaptive-rx on adaptive-tx on"
 
 # Change ring buffer settings
 #ethtool_ring_eth0=""
 
+# Set RX copy-break at 1500 bytes
+#ethtool_tunable_eth0="rx-copybreak 1500"
+
 # Enable all offload settings
 #ethtool_offload_eth0="rx on tx on sg on tso on ufo on gso on gro on lro on"
 
@@ -1309,13 +1315,13 @@
 
 # Additionally, there is a special control variable, if you need to change the
 # order of option processing. The default order is:
-# flash change-eeprom change pause coalesce ring offload identify nfc 
rxfh-indir ntuple
+# flash change-eeprom change pause eee coalesce ring offload tunable identify 
nfc rxfh-indir ntuple
 
 # Set global order to default
-#ethtool_order="flash change-eeprom change pause coalesce ring offload 
identify nfc rxfh-indir ntuple"
+#ethtool_order="flash change-eeprom change pause eee coalesce ring offload 
tunable identify nfc rxfh-indir ntuple"
 
 # Hypothetical network card that requires a change-eeprom toggle to enable 
flashing
-#ethtool_order_eth0="change-eeprom flash change pause coalesce ring offload 
nfc rxfh-indir ntuple"
+#ethtool_order_eth0="change-eeprom flash change pause eee coalesce ring 
offload tunable nfc rxfh-indir ntuple"
 
 #-
 # Firewalld support

diff --git a/net/ethtool.sh b/net/ethtool.sh
index 57c98f7..0bcceff 100644
--- a/net/ethtool.sh
+++ b/net/ethtool.sh
@@ -17,7 +17,7 @@ ethtool_pre_start() {
local order opt OFS="${OIFS}"
eval order=\$ethtool_order_${IFVAR}
[ -z "${order}" ] && eval order=\$ethtool_order
-   [ -z "${order}" ] && order="flash change-eeprom change pause coalesce 
ring offload identify nfc rxfh-indir ntuple"
+   [ -z "${order}" ] && order="flash change-eeprom change pause eee 
coalesce ring offload tunable identify nfc rxfh-indir ntuple"
# ethtool options not used: --driver, --register-dump, --eeprom-dump, 
--negotiate, --test, --statistics
eindent
for opt in ${order} ; do
@@ -36,7 +36,7 @@ ethtool_pre_start() {
local args_pretty="$(_trim "${p}")"
# Do nothing if empty
[ -z "${args_pretty}" ] && continue
-   [ "${opt}" = "ring" ] && opt="set-ring"
+   [ "${opt}" = "eee" -o "${opt}" = "ring" -o "${opt}" = 
"tunable" ] && opt="set-${opt}"
args_pretty="--${opt} $IFACE ${args_pretty}"
args="--${opt} $IFACE ${args}"
ebegin "ethtool ${args_pretty}"



[gentoo-commits] proj/netifrc:master commit in: net/, doc/

2021-01-18 Thread Lars Wendler
commit: f9951f7d42f1f5ad57e14a29a0be85a80d9a863a
Author: Lars Wendler  gentoo  org>
AuthorDate: Mon Jan 18 10:45:36 2021 +
Commit: Lars Wendler  gentoo  org>
CommitDate: Mon Jan 18 12:32:31 2021 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=f9951f7d

Convert many "grep" calls to "grep -F"

Signed-off-by: Lars Wendler  gentoo.org>

 doc/net.example.Linux.in | 6 +++---
 net/ifconfig.sh.Linux.in | 2 +-
 net/iproute2.sh  | 6 +++---
 net/iw.sh| 4 ++--
 net/iwconfig.sh.Linux.in | 5 ++---
 net/wpa_supplicant.sh| 3 +--
 6 files changed, 12 insertions(+), 14 deletions(-)

diff --git a/doc/net.example.Linux.in b/doc/net.example.Linux.in
index b404329..bafde42 100644
--- a/doc/net.example.Linux.in
+++ b/doc/net.example.Linux.in
@@ -1365,7 +1365,7 @@
 #  # Test for link on the interface prior to bringing it up.  This
 #  # only works on some network adapters and requires the
 #  # sys-apps/net-tools package to be installed.
-#  if mii-tool "${IFACE}" 2> /dev/null | grep -q 'no link'; then
+#  if mii-tool "${IFACE}" 2> /dev/null | grep -Fq 'no link'; then
 #  ewarn "No link on ${IFACE}, aborting configuration"
 #  return 1
 #  fi
@@ -1373,14 +1373,14 @@
 #  # Test for link on the interface prior to bringing it up.  This
 #  # only works on some network adapters and requires the ethtool
 #  # package to be installed.
-#  if ethtool "${IFACE}" | grep -q 'Link detected: no'; then
+#  if ethtool "${IFACE}" | grep -Fq 'Link detected: no'; then
 #  ewarn "No link on ${IFACE}, aborting configuration"
 #  return 1
 #  fi
 #
 #  # Test to see if we're docked or not and configure like so
 #  # config_docked="dhcp"
-#  if grep -q "1" /sys/devices/platform/dock.0/docked; then
+#  if grep -Fq "1" /sys/devices/platform/dock.0/docked; then
 #   einfo "${IFACE} is docked - configuring"
 #  _configure_variables "docked"
 #  fi

diff --git a/net/ifconfig.sh.Linux.in b/net/ifconfig.sh.Linux.in
index 960b239..b0a4551 100644
--- a/net/ifconfig.sh.Linux.in
+++ b/net/ifconfig.sh.Linux.in
@@ -47,7 +47,7 @@ _is_wireless()
-d /sys/class/net/"${IFACE}"/phy80211 ] && return 0
 
[ ! -e /proc/net/wireless ] && return 1
-   grep -Eq "^[[:space:]]*${IFACE}:" /proc/net/wireless
+   grep -q "^[[:space:]]*${IFACE}:" /proc/net/wireless
 }
 
 _set_flag()

diff --git a/net/iproute2.sh b/net/iproute2.sh
index d19f79d..4c32acc 100644
--- a/net/iproute2.sh
+++ b/net/iproute2.sh
@@ -192,7 +192,7 @@ _add_address()
 
# Check for address already existing:
ip addr show to "${address}/${family_maxnetmask}" dev "${IFACE}" 
2>/dev/null | \
-   fgrep -sq "${address}"
+   grep -Fsq "${address}"
address_already_exists=$?
 
# This must appear on a single line, continuations cannot be used
@@ -265,7 +265,7 @@ _add_route()
 
# Check for route already existing:
ip ${family} route show ${cmd_nometric} dev "${IFACE}" 2>/dev/null | \
-   fgrep -sq "${cmd%% *}"
+   grep -Fsq "${cmd%% *}"
route_already_exists=$?
 
_cmd ip ${family} route append ${cmd} dev "${IFACE}"
@@ -304,7 +304,7 @@ _delete_addresses()
 
 _has_carrier()
 {
-   LC_ALL=C ip link show dev "${IFACE}" | grep -q "LOWER_UP"
+   LC_ALL=C ip link show dev "${IFACE}" | grep -Fq "LOWER_UP"
 }
 
 # Used by iproute2, ip6rd & ip6to4

diff --git a/net/iw.sh b/net/iw.sh
index 029b9d6..1f8b068 100644
--- a/net/iw.sh
+++ b/net/iw.sh
@@ -212,7 +212,7 @@ iw_wait_for_association()
# carrier on or buggy madwifi drivers that
# sometimes have carrier on and ssid set
# without being associated.  :/
-   [ -n "$(iw dev "${IFACE}" info |grep ssid)" ] 
&& [ "${station_mac}" != "00:00:00:00:00:00" ] && return 0
+   [ -n "$(iw dev "${IFACE}" info | grep -F ssid)" 
] && [ "${station_mac}" != "00:00:00:00:00:00" ] && return 0
fi
else
local atest=
@@ -704,7 +704,7 @@ iw_pre_start()
 
# Store the fact that tx-power was off so we default to a longer
# wait if our scan returns nothing
-   LC_ALL=C iw dev "${IFACE}" info | sed -e '1d' | grep -q "txpower 0.00"
+   LC_ALL=C iw dev "${IFACE}" info | sed -e '1d' | grep -Fq "txpower 0.00"
local txpowerwasoff=$?
 
iw_defaults

diff --git a/net/iwconfig.sh.Linux.in b/net/iwconfig.sh.Linux.in
index 02f748d..98044a9 100644
--- a/net/iwconfig.sh.Linux.in
+++ b/net/iwconfig.sh.Linux.in
@@ -17,9 +17,8 @@ iwconfig_get_wep_status()
 {
local mode= status="disabled"
 
-   # No easy way of doing this grep in bash regex :/
if LC_ALL=C iwconfig "${IFACE}" | \
-   grep -qE "^ +Encryption 

[gentoo-commits] proj/netifrc:master commit in: net/, doc/

2021-01-05 Thread Lars Wendler
commit: 750d89eaf772551588c460a0c8425579e7d49677
Author: Lars Wendler  gentoo  org>
AuthorDate: Tue Jan  5 12:51:41 2021 +
Commit: Lars Wendler  gentoo  org>
CommitDate: Tue Jan  5 14:26:56 2021 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=750d89ea

net/pppd.sh: ppp-2.4.9 has renamed rp-pppoe.so to pppoe.so

Signed-off-by: Lars Wendler  gentoo.org>

 doc/net.example.Linux.in | 5 +++--
 net/pppd.sh  | 7 +++
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/doc/net.example.Linux.in b/doc/net.example.Linux.in
index d88302b..b404329 100644
--- a/doc/net.example.Linux.in
+++ b/doc/net.example.Linux.in
@@ -805,9 +805,10 @@
 #link_ppp0="pty 'your_link_command'"   # PPP links over ssh, rsh, etc
 #
 # Here you should specify what pppd plugins you want to use
-# Available plugins are: pppoe, pppoa, capi, dhcpc, minconn, radius,
+# Available plugins are: pppoe, rp-pppoe, pppoa, capi, dhcpc, minconn, radius,
 #   radattr, radrealms and winbind
-#plugins_ppp0="pppoe"  # Required plugin for PPPoE
+#plugins_ppp0="pppoe"  # Required plugin for PPPoE with 
>=ppp-2.4.9
+#plugins_ppp0="rp-pppoe"   # Required plugin for PPPoE with 


[gentoo-commits] proj/netifrc:master commit in: net/, doc/

2020-06-02 Thread Robin H. Johnson
commit: 589d7374dc5c023304f6226cb458d5346bdd3a0b
Author: Robin H. Johnson  gentoo  org>
AuthorDate: Tue Jun  2 21:51:00 2020 +
Commit: Robin H. Johnson  gentoo  org>
CommitDate: Tue Jun  2 21:53:50 2020 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=589d7374

net/iw: implement 802.11s mesh

Closes: https://bugs.gentoo.org/469296
Signed-off-by: Robin H. Johnson  gentoo.org>

 doc/net.example.Linux.in |  7 ++-
 net/iw.sh| 25 +
 2 files changed, 31 insertions(+), 1 deletion(-)

diff --git a/doc/net.example.Linux.in b/doc/net.example.Linux.in
index 4fc603b..d88302b 100644
--- a/doc/net.example.Linux.in
+++ b/doc/net.example.Linux.in
@@ -231,7 +231,7 @@
 # do require the SSID to be set - do this here
 #essid_eth0="any"
 
-# Set the mode of the interface (managed, ad-hoc, master or auto)
+# Set the mode of the interface (managed, ad-hoc, master, mesh or auto)
 # The default is auto
 # If it's ad-hoc or master you also may need to specify the channel below
 #mode_eth0="auto"
@@ -409,6 +409,11 @@
 # NOTE: preferred_aps  list ignores blacklisted_aps - so if you have
 # the same SSID in both, well, you're a bit silly :p
 
+# 802.11s mesh support
+# Requires CONFIG_MAC80211_MESH in kernel and hardware support
+#mode_wlan0="mesh"
+#mesh_wlan0="MyMeshNetworkID"
+
 
 
 # wpa_supplicant

diff --git a/net/iw.sh b/net/iw.sh
index dcdbb79..029b9d6 100644
--- a/net/iw.sh
+++ b/net/iw.sh
@@ -5,6 +5,7 @@
 
 _config_vars="$_config_vars ssid mode associate_timeout sleep_scan"
 _config_vars="$_config_vars preferred_aps blacklist_aps"
+_config_vars="$_config_vars mesh"
 
 iw_depend()
 {
@@ -170,6 +171,26 @@ iw_setup_adhoc()
return 0
 }
 
+iw_setup_mesh()
+{
+   if [ -z "${MESH}" ]; then
+   eerror "${IFACE} requires a MESH to be set to operate in mesh 
mode"
+   eerror "adjust the mesh_${IFVAR} setting in /etc/conf.d/net"
+   return 1
+   fi
+
+   iw_set_mode 'mesh'
+
+   veinfo "Joining mesh '$MESH' with $IFACE"
+   iw ${IFACE} mesh join "${MESH}" || return 1
+
+   # Finally apply the user Config
+   iw_user_config
+
+   iw_report
+   return 0
+}
+
 iw_wait_for_association()
 {
local timeout= i=0
@@ -600,6 +621,10 @@ iw_configure()
managed)
# Fall through
;;
+   mesh)
+   iw_setup_mesh
+   return $?
+   ;;
*)
eerror "Only managed and ad-hoc are supported"
return 1



[gentoo-commits] proj/netifrc:master commit in: net/, doc/

2020-05-31 Thread Robin H. Johnson
commit: ffa5a9e830c609fec987efac5723781e889ae67c
Author: Arseni Nimera  yandex  by>
AuthorDate: Sat May 30 22:20:25 2020 +
Commit: Robin H. Johnson  gentoo  org>
CommitDate: Sun May 31 23:15:20 2020 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=ffa5a9e8

Added macvtap support

Bug: https://bugs.gentoo.org/691372
Signed-off-by: Arseni Nimera  yandex.by>
(cherry picked from commit 0dc79645173fad82e0d437a6569b7ea7fa356197)
Signed-off-by: Robin H. Johnson  gentoo.org>

 doc/net.example.Linux.in | 3 +++
 net/macvlan.sh   | 8 ++--
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/doc/net.example.Linux.in b/doc/net.example.Linux.in
index c211ca7..a2993c0 100644
--- a/doc/net.example.Linux.in
+++ b/doc/net.example.Linux.in
@@ -664,6 +664,9 @@
 # MAC-VLAN mode (private, vepa, bridge, passtru)
 #mode_macvlan0="private"
 
+# MAC-VLAN type (macvlan, macvtap)
+#type_macvlan0="macvtap"
+
 # IP address, MAC address, ... are configured as a normal interface
 #config_macvlan0="192.168.20.20/24"
 #mac_macvlan0="00:50:06:20:20:20"

diff --git a/net/macvlan.sh b/net/macvlan.sh
index 8d55717..6243858 100644
--- a/net/macvlan.sh
+++ b/net/macvlan.sh
@@ -34,8 +34,12 @@ macvlan_pre_start()
eval mode=\$mode_${IFVAR}
[ -z "${mode}" ] && mode="private"
 
+   local type=
+   eval type=\$type_${IFVAR}
+   [ -z "${type}" ] && type="macvlan"
+
ebegin "Creating MAC-VLAN ${IFACE} to ${macvlan}"
-   e="$(ip link add link "${macvlan}" name "${IFACE}" type macvlan mode 
"${mode}" 2>&1 1>/dev/null)"
+   e="$(ip link add link "${macvlan}" name "${IFACE}" type "${type}" mode 
"${mode}" 2>&1 1>/dev/null)"
if [ -n "${e}" ]; then
eend 1 "${e}"
else
@@ -49,6 +53,6 @@ macvlan_post_stop()
_is_macvlan || return 0
 
ebegin "Removing MAC-VLAN ${IFACE}"
-   ip link delete "${IFACE}" type macvlan >/dev/null
+   ip link delete "${IFACE}" >/dev/null
eend $?
 }



[gentoo-commits] proj/netifrc:master commit in: net/, doc/

2019-04-20 Thread Robin H. Johnson
commit: b5bb3cdf925730a693eed9e2528b92c04975c7d0
Author: Kirill Semenkov  gmail  com>
AuthorDate: Mon Dec 17 09:10:50 2018 +
Commit: Robin H. Johnson  gentoo  org>
CommitDate: Sun Apr 21 04:10:41 2019 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=b5bb3cdf

Veth support added

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

 doc/net.example.Linux.in | 24 
 net/Makefile |  2 +-
 2 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/doc/net.example.Linux.in b/doc/net.example.Linux.in
index 3b414ba..6fc6094 100644
--- a/doc/net.example.Linux.in
+++ b/doc/net.example.Linux.in
@@ -914,6 +914,30 @@
 # of the node as well
 #openvpn_tun1="--user foo --group bar"
 
+#-
+# Virtual interface device (veth)
+# For veth support install iproute2 and awk
+#
+# The script uses "standard" ways of IP-address assignement in net.lo script. 
Network namespaces are not implemented here
+# because net.lo currently knows nothing about network namespaces.
+#
+#   You must specify veth interface type to avoid interference with "normal" 
interfaces startup
+#   The interface type must be set for both peers
+#type_veth0="veth"
+#   Here we declare peers for "ip link add" command
+#veth_veth0="veth0 veth1"
+#config_veth0="192.168.0.1/24"
+#
+#   Avoids race
+#rc_net_veth1_need="net.veth0"
+#type_veth1="veth"
+#   Both peers are created when the first one starts, we don't need to create 
the second peer
+#   explicitly, we just configure it
+#veth_veth1_create="no"
+#config_veth1="192.168.2.1/24"
+#
+
+
 #-
 # Bridging (802.1d)
 # Preferred: iproute2, emerge sys-apps/iproute2

diff --git a/net/Makefile b/net/Makefile
index 390f8d8..dab94f9 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
+   iw.sh wireguard.sh veth.sh
 
 SRCS-NetBSD= ifwatchd.sh.in
 INC-NetBSD=ifwatchd.sh



[gentoo-commits] proj/netifrc:master commit in: /, net/, doc/

2015-11-08 Thread Robin H. Johnson
commit: 2ce8b833812e5db9de7cf1543dd6499b4077db21
Author: Robin H. Johnson  gentoo  org>
AuthorDate: Sun Nov  8 14:29:50 2015 +
Commit: Robin H. Johnson  gentoo  org>
CommitDate: Sun Nov  8 14:29:50 2015 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=2ce8b833

New interace type: HSR.

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

 TODO |  1 -
 doc/net.example.Linux.in |  6 ++
 net/hsr.sh   | 56 
 3 files changed, 62 insertions(+), 1 deletion(-)

diff --git a/TODO b/TODO
index 64f62e2..023bbb4 100644
--- a/TODO
+++ b/TODO
@@ -12,7 +12,6 @@
- add vlan3 - _ifindex (eth0=0,vlan2=1,vlan3=2)
Now your routing table has entries for both vlan2 and vlan3 with a 
metric of 2.
 - Support many more device types easily:
-  - HSR: ip link add name hsr0 type hsr slave1 dummy3 slave2 dummy4
   - VXLAN: ip link add link dummy2 name vxlan199 type vxlan id 199 dev dummy2 
group 224.2.0.199 dstport 4789
   - IPVLAN: ...
   - IFB: ip link add ifb0 type ifb 

diff --git a/doc/net.example.Linux.in b/doc/net.example.Linux.in
index 1eaebac..6059301 100644
--- a/doc/net.example.Linux.in
+++ b/doc/net.example.Linux.in
@@ -159,6 +159,12 @@
 #
 # Dummy network interface:
 #type_dummy0=dummy
+#
+# HSR: High-availability Seamless Redundancy
+#type_hsr0=hsr
+#hsr_slave1=eth0
+#hsr_slave2=eth1
+#hsr_supervision=99 # Byte value
 
 #-
 # WIRELESS (802.11 support)

diff --git a/net/hsr.sh b/net/hsr.sh
new file mode 100644
index 000..94ecc01
--- /dev/null
+++ b/net/hsr.sh
@@ -0,0 +1,56 @@
+# Copyright (c) 2015 Gentoo Foundation
+# All rights reserved. Released under the 2-clause BSD license.
+
+hsr_depend()
+{
+   program ip
+   after interface
+   before dhcp macchanger
+}
+
+_is_hsr() {
+   is_interface_type hsr
+}
+
+hsr_pre_start()
+{
+   local hsr=
+   eval hsr=\$type_${IFVAR}
+   [ "${hsr}" = "hsr" ] || return 0
+   eval hsr_slave1=\$hsr_slave1_${IFVAR}
+   eval hsr_slave2=\$hsr_slave2_${IFVAR}
+   eval hsr_supervision=\$hsr_supervision_${IFVAR}
+   if [ -z "${hsr_slave1}" ] || [ -z "${hsr_slave2}" ]; then
+   eerror "HSR interfaces require two slave interfaces to be set"
+   return 1
+   fi
+   if ! ( IFACE=${hsr_slave1} _exists ); then
+   eerror "HSR slave1 ${hsr_slave1} does not exist"
+   return 1
+   fi
+   if ! ( IFACE=${hsr_slave2} _exists ); then
+   eerror "HSR slave2 ${hsr_slave2} does not exist"
+   return 1
+   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}"
+   veinfo $cmd
+   if $cmd ; then
+   eend 0 && _up && set_interface_type hsr
+   else
+   eend 1
+   fi
+}
+
+
+hsr_post_stop()
+{
+   _is_hsr || return 0
+
+   ebegin "Removing HSR ${IFACE}"
+   cmd="ip link delete "${IFACE}" type hsr"
+   veinfo "$cmd"
+   $cmd
+   eend $?
+}



[gentoo-commits] proj/netifrc:master commit in: net/, doc/

2015-11-08 Thread Robin H. Johnson
commit: 734e527dbe32fc3c0abdd326c485a6e69d8646f2
Author: Alon Bar-Lev  gentoo  org>
AuthorDate: Sat Nov  7 20:02:59 2015 +
Commit: Robin H. Johnson  gentoo  org>
CommitDate: Sat Nov  7 20:18:02 2015 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=734e527d

net: bridge: add bridge_ and brport_ prefixes to sysfs interface

keep the no prefix to be backward compatible.

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

 doc/net.example.Linux.in |  6 +++---
 net/bridge.sh| 29 +
 2 files changed, 20 insertions(+), 15 deletions(-)

diff --git a/doc/net.example.Linux.in b/doc/net.example.Linux.in
index bcf3311..f71385d 100644
--- a/doc/net.example.Linux.in
+++ b/doc/net.example.Linux.in
@@ -919,9 +919,9 @@
 # You can also configure the bridge or bridge members via sysfs on 2.6 kernels
 # or newer. See the kernel bridge documentation for a description of these
 # options.
-#stp_state_br0="0"
-#forward_delay_br0="10"
-#hairpin_mode_eth0="1"
+#bridge_stp_state_br0="0"
+#bridge_forward_delay_br0="10"
+#brport_hairpin_mode_eth0="1"
 
 #-
 # RFC 2684 Bridge Support

diff --git a/net/bridge.sh b/net/bridge.sh
index 82abb71..407b578 100644
--- a/net/bridge.sh
+++ b/net/bridge.sh
@@ -125,12 +125,15 @@ bridge_pre_start()
for x in /sys/class/net/"${IFACE}"/bridge/*; do
[ -f "${x}" ] || continue
n=${x##*/}
-   eval s=\$${n}_${IFVAR}
-   if [ -n "${s}" ]; then
-   einfo "Setting ${n}: ${s}"
-   echo "${s}" >"${x}" || \
-   eerror "Failed to configure $n (${n}_${IFVAR})"
-   fi
+   # keep no prefix for backward compatibility
+   for prefix in "" bridge_; do
+   eval s=\$${prefix}${n}_${IFVAR}
+   if [ -n "${s}" ]; then
+   einfo "Setting ${n}: ${s}"
+   echo "${s}" >"${x}" || \
+   eerror "Failed to configure $n (${n}_${IFVAR})"
+   fi
+   done
done
 
if [ -n "${ports}" ]; then
@@ -161,12 +164,14 @@ bridge_pre_start()
for x in /sys/class/net/"${IFACE}"/brport/*; do
[ -f "${x}" ] || continue
n=${x##*/}
-   eval s=\$${n}_${IFVAR}
-   if [ -n "${s}" ]; then
-   einfo "Setting ${n}@${IFACE}: ${s}"
-   echo "${s}" >"${x}" || \
-   eerror "Failed to configure $n 
(${n}_${IFVAR})"
-   fi
+   for prefix in "" brport_; do
+   eval s=\$${prefix}${n}_${IFVAR}
+   if [ -n "${s}" ]; then
+   einfo "Setting ${n}@${IFACE}: 
${s}"
+   echo "${s}" >"${x}" || \
+   eerror "Failed to configure $n 
(${n}_${IFVAR})"
+   fi
+   done
done
eend 0
done



[gentoo-commits] proj/netifrc:master commit in: net/, doc/

2015-11-08 Thread Robin H. Johnson
commit: 193803506202d0d37996ee81388215cfe3fc8cda
Author: Alon Bar-Lev  gentoo  org>
AuthorDate: Sat Nov  7 20:02:43 2015 +
Commit: Robin H. Johnson  gentoo  org>
CommitDate: Sat Nov  7 20:02:43 2015 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=19380350

net: bridge: support iproute2

add bridge_force_IFVAR to be interface independent.

mark the brctl_IFVAR as deprecated.

enable easy removal of brctl in future in favour of the iproute2 without
leaving legacy.

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

 doc/net.example.Linux.in |  1 +
 net/bridge.sh| 75 
 2 files changed, 57 insertions(+), 19 deletions(-)

diff --git a/doc/net.example.Linux.in b/doc/net.example.Linux.in
index b91bb50..bcf3311 100644
--- a/doc/net.example.Linux.in
+++ b/doc/net.example.Linux.in
@@ -893,6 +893,7 @@
 # ports to it you must set at least one of the following variables based on the
 # interface name, so that we can pick it up from your configuration. Even an
 # empty value variable is fine, but at least one of them must be set:
+# bridge_force_IFVAR
 # brctl_IFVAR
 
 # You need to configure the ports to null values so dhcp does not get started

diff --git a/net/bridge.sh b/net/bridge.sh
index 1d01be2..82abb71 100644
--- a/net/bridge.sh
+++ b/net/bridge.sh
@@ -4,7 +4,7 @@
 bridge_depend()
 {
before interface macnet
-   program brctl
+   program brctl ip
 }
 
 _config_vars="$_config_vars bridge bridge_add brctl"
@@ -35,17 +35,27 @@ bridge_pre_start()
# ports is for static add
local ports="$(_get_array "bridge_${IFVAR}")"
# old config options
-   local opts="$(_get_array "brctl_${IFVAR}")"
+   local brctl_opts="$(_get_array "brctl_${IFVAR}")"
# brif is used for dynamic add
eval brif=\$bridge_add_${IFVAR}
 
+   local do_iproute2=false do_brctl=false
+   if [ -n "${brctl_opts}" ] && type brctl >/dev/null 2>&1; then
+   do_brctl=true
+   elif type ip >/dev/null 2>&1; then
+   do_iproute2=true
+   elif type brctl >/dev/null 2>&1; then
+   do_brctl=true
+   fi
+
# we need a way to if the bridge exists in a variable name, not just the
# contents of a variable. Eg if somebody has only bridge_add_eth0='br0',
# with no other lines mentioning br0.
eval bridge_unset=\${bridge_${IFVAR}-y\}
eval brctl_unset=\${brctl_${IFVAR}-y\}
+   eval bridge_force_unset=\${bridge_force_${IFVAR}-y\}
 
-   if [ -z "${brif}" -a "${brctl_unset}" = 'y' ]; then
+   if [ -z "${brif}" -a "${brctl_unset}${bridge_force_unset}" = 'yy' ]; 
then
if [ -z "${ports}" -a "${bridge_unset}" = "y" ]; then
#eerror "Misconfigured static bridge detected (see 
net.example)"
return 0
@@ -70,7 +80,18 @@ bridge_pre_start()
 
if ! _is_bridge ; then
ebegin "Creating bridge ${IFACE}"
-   if ! brctl addbr "${IFACE}"; then
+   if ${do_iproute2}; then
+   ip link add "${IFACE}" type bridge
+   rc=$?
+   elif ${do_brctl}; then
+   brctl addbr "${IFACE}"
+   rc=$?
+   else
+   eerror "Neither iproute2 nor brctl has been found, 
please install"
+   eerror "either \"iproute2\" or \"brctl\"."
+   rc=1
+   fi
+   if [ ${rc} != 0 ]; then
eend 1
return 1
fi
@@ -82,19 +103,22 @@ bridge_pre_start()
# Old configuration set mechanism
# Only a very limited subset of the options are available in the old
# configuration method. The sysfs interface is in the next block 
instead.
-   if [ -n "${opts}" ]; then
-   ewarn "brctl options are deprecated please migrate to sysfs 
options"
-   ewarn "map of important options is available at 
https://wiki.gentoo.org/wiki/Netifrc/Brctl_Migration;
-   local IFS="$__IFS"
-   for x in ${opts}; do
+   if ${do_brctl}; then
+   if [ -n "${brctl_opts}" ]; then
+   ewarn "brctl options are deprecated please migrate to 
sysfs options"
+   ewarn "map of important options is available at 
https://wiki.gentoo.org/wiki/Netifrc/Brctl_Migration;
+
+   local IFS="$__IFS"
+   for x in ${brctl_opts}; do
+   unset IFS
+   set -- ${x}
+   x=$1
+   shift
+   set -- "${x}" "${IFACE}" "$@"
+   brctl "$@"
+   done
unset IFS
-   set -- ${x}
-   x=$1