Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 803230

Summary: net-misc/netifrc-0.7.3:0 fails to create WireGuard interface not named wg*
Product: Gentoo Linux Reporter: Frank Mariën <gbu>
Component: Current packagesAssignee: netifrc Team <netifrc>
Status: UNCONFIRMED ---    
Severity: normal    
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
Package list:
Runtime testing required: ---
Attachments: emerge --info
remove the superfluous and problematic interface name check

Description Frank Mariën 2021-07-21 13:44:05 UTC
Created attachment 725482 [details]
emerge --info


netifrc fails to create WireGuard interface not named wg*


naming of interface accepted by iproute2 and the kernel to also function with netifrc.

ip link add [...] [ name ] NAME [...]


the functions




explicitly check for interface name wg* and return 0 early if it is named otherwise:

        [ "${IFACE#wg}" != "$IFACE" ] || return 0

        [ "${IFACE#wg}" != "$IFACE" ] || return 0

causing netifrc to fail in creating the interface if it does not already exist:



root@white:~  # rc-service net.grimmr start
 * Bringing up interface grimmr
 *   ERROR: interface grimmr does not exist
 *   Ensure that you have loaded the correct kernel module for your hardware
 * ERROR: net.grimmr failed to start
root@white:~  #

if I rename the interface to wg0, all is well..

Suggested fix:

Remove the name check. 

---	2021-07-21 15:28:34.596280276 +0200
+++	2021-07-21 15:29:06.346604760 +0200
@@ -11,7 +11,6 @@

-	[ "${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
@@ -44,7 +43,6 @@

-	[ "${IFACE#wg}" != "$IFACE" ] || return 0
 	ebegin "Removing WireGuard interface $IFACE"
 	ip link delete dev "$IFACE" type wireguard

Comment 1 Frank Mariën 2021-07-21 13:47:18 UTC
Created attachment 725485 [details, diff]
remove the superfluous and problematic interface name check
Comment 2 Frank Mariën 2021-07-21 15:52:03 UTC

.. now realise my solution can't work because the check is necessary to keep the script from acting on any interfaces. 

.. didn't know the scripts were called one by one until one accepted the interface)

.. don't immediately see a better way, since at this point the interface isn't created yet, and so we can't e.g. see if the wg commands accepts it.

I'll go without netifrc for now..