Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 678184 - net-misc/netifrc-0.6.1: WireGuard interfaces do not set mtu
Summary: net-misc/netifrc-0.6.1: WireGuard interfaces do not set mtu
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Hosted Projects
Classification: Unclassified
Component: netifrc (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: netifrc Team
URL:
Whiteboard: netifrc:wg
Keywords:
: 677940 (view as bug list)
Depends on:
Blocks: 662808
  Show dependency tree
 
Reported: 2019-02-16 23:06 UTC by tastytea
Modified: 2024-05-23 18:12 UTC (History)
5 users (show)

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


Attachments
netifrc-wireguard-after-interface.patch (file_678184.txt,273 bytes, patch)
2024-05-13 12:21 UTC, Louis Sautier (sbraz)
Details | Diff
proposed patch (netifrc-wireguard-module-dep.patch,622 bytes, patch)
2024-05-20 13:49 UTC, Alexander Zubkov
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description tastytea 2019-02-16 23:06:56 UTC
I wanted to change the mtu on a WireGuard interface. The setting "mtu_wg0" had no effect.

Reproducible: Always

Steps to Reproduce:
1. Configure wg0 as WireGuard interface in /etc/conf.d/net
2. Set mtu_wg0="1400"
3. start net.wg0
Actual Results:  
mtu is 1420

Expected Results:  
mtu is 1400

My config:

config_wg0="fd23::10:1:3/64 10.23.10.13/16"
wireguard_wg0="/etc/wireguard/wg0.conf"
mtu_wg0="1400"
Comment 1 Ben Kohler gentoo-dev 2019-07-10 14:43:25 UTC
*** Bug 677940 has been marked as a duplicate of this bug. ***
Comment 2 Katherine Peeters 2021-07-19 22:03:13 UTC
I have the same issue on all of my Gentoo machines. Additionally, after a recent update (?) the MTU is no longer set correctly automatically, causing breakage. This means that every single time I boot any of my devices I have to log in as root and manually correct the MTU.

From what I can tell, netifrc is attempting to set the MTU before the interface has even been created, suggesting that this is not a Wireguard bug, but rather a netifrc bug. Either way, it's a problem...
Comment 3 tastytea 2021-07-20 09:28:17 UTC
Does the workaround from bug 677940 work for you? It works for me with netifrc 0.7.3.

postup() {
    case ${IFACE} in
        wg*)
            ip link set mtu 1400 dev ${IFACE}
        ;;
    esac
}
Comment 4 lmk 2022-11-22 22:43:52 UTC
Alternative solution that works for me is changing wireguard_depend() function in /lib/netifrc/net/wireguard to:

wireguard_depend()
{
    program /usr/bin/wg
    before interface
}
Comment 5 Louis Sautier (sbraz) gentoo-dev 2024-05-13 12:21:28 UTC
Created attachment 892862 [details, diff]
netifrc-wireguard-after-interface.patch

(In reply to lmk from comment #4)
> Alternative solution that works for me is changing wireguard_depend()
> function in /lib/netifrc/net/wireguard to:
> 
> wireguard_depend()
> {
>     program /usr/bin/wg
>     before interface
> }


Thanks, I can confirm that this works, I added the attached patch to /etc/portage/patches/net-misc/netifrc.
I would really like to know what the consequences of this change could be as I'm not familiar enough with netifrc's code.
Comment 6 Alexander Zubkov 2024-05-20 13:49:56 UTC
Created attachment 893576 [details, diff]
proposed patch

From my understanding, the patch is correct. "interface" dependency in netifrc - is where ip address, mtu, etc. is being set up. So "wireguard" module should be sorted before it.

Also it is unclear to me why interface is brought up in the module, instead of creating intface in wireguard_pre_up function, and it will be brought up later by init-script. I've added the modified patch, taking it into account.
Comment 7 Larry the Git Cow gentoo-dev 2024-05-23 18:12:22 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=8bb61b90c1d791bafd5cd0b6c54093cccee425f4

commit 8bb61b90c1d791bafd5cd0b6c54093cccee425f4
Author:     Alexander Zubkov <green@qrator.net>
AuthorDate: 2024-05-23 14:56:42 +0000
Commit:     Patrick McLean <chutzpah@gentoo.org>
CommitDate: 2024-05-23 18:12:13 +0000

    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@gmail.com> who proposed the solution and
    to Louis Sautier (sbraz) <sbraz@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@gentoo.org>
    Signed-off-by: Alexander Zubkov <green@qrator.net>
    Signed-off-by: Patrick McLean <chutzpah@gentoo.org>

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