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   
Whiteboard:
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

Summary:
--------

netifrc fails to create WireGuard interface not named wg*


Expect:
-------

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

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

   
Issue:  
------   

the functions

wireguard_pre_start()
wireguard_post_stop()

in

/lib/netifrc/net/wireguard.sh

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

wireguard_pre_start()
{
        [ "${IFACE#wg}" != "$IFACE" ] || return 0
[...]


wireguard_post_stop()
{
        [ "${IFACE#wg}" != "$IFACE" ] || return 0
[...]

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

/etc/init.d/net:

config_grimmr="xx.xx.0.2/24"
wireguard_grimmr="/etc/wireguard/grimmr.conf"


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. 

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

 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
@@ -44,7 +43,6 @@

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

WKR,
-f
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
I 

.. 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..