Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 803230 - net-misc/netifrc-0.7.3:0 fails to create WireGuard interface not named wg*
Summary: net-misc/netifrc-0.7.3:0 fails to create WireGuard interface not named wg*
Status: UNCONFIRMED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: netifrc Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-07-21 13:44 UTC by Frank Mariën
Modified: 2021-07-22 22:31 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
emerge --info (emerge_info,5.26 KB, text/plain)
2021-07-21 13:44 UTC, Frank Mariën
Details
remove the superfluous and problematic interface name check (file_803230.txt,596 bytes, patch)
2021-07-21 13:47 UTC, Frank Mariën
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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..