Skip to content

Commit 04e3518

Browse files
committed
hotfix(pmtud,ipv6): detect IPv6 after tunnel is up
1 parent 4fd10ff commit 04e3518

2 files changed

Lines changed: 4 additions & 5 deletions

File tree

‎internal/vpn/run.go‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ func (l *Loop) Run(ctx context.Context, done chan<- struct{}) {
5959
enabled: settings.Type != vpn.Wireguard || *settings.Wireguard.MTU == 0,
6060
vpnType: settings.Type,
6161
network: connection.Protocol,
62-
ipv6: l.isIPv6Used(settings),
6362
icmpAddrs: settings.PMTUD.ICMPAddresses,
6463
tcpAddrs: settings.PMTUD.TCPAddresses,
6564
},

‎internal/vpn/tunnelup.go‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ type tunnelUpPMTUDData struct {
4141
// network is used to find the network level header overhead.
4242
// It can be [constants.UDP] or [constants.TCP].
4343
network string
44-
// ipv6 is true if the VPN connection supports IPv6.
45-
ipv6 bool
4644
// icmpAddrs is the list of addresses to use for ICMP path MTU discovery.
4745
// Each address should handle ICMP packets for PMTUD to work.
4846
icmpAddrs []netip.Addr
@@ -52,7 +50,8 @@ type tunnelUpPMTUDData struct {
5250
}
5351

5452
func (l *Loop) onTunnelUp(ctx, loopCtx context.Context, data tunnelUpData) {
55-
switch vpnType := l.GetSettings().Type; vpnType {
53+
vpnSettings := l.GetSettings()
54+
switch vpnType := vpnSettings.Type; vpnType {
5655
case vpn.Wireguard, vpn.AmneziaWg:
5756
l.logger.Infof("%s setup is complete. "+
5857
"Note %s is a silent protocol and it may or may not work, without giving any error message. "+
@@ -71,8 +70,9 @@ func (l *Loop) onTunnelUp(ctx, loopCtx context.Context, data tunnelUpData) {
7170

7271
if data.pmtud.enabled {
7372
mtuLogger := l.logger.New(log.SetComponent("MTU discovery"))
73+
ipv6 := l.isIPv6Used(vpnSettings)
7474
err := updateToMaxMTU(ctx, data.vpnIntf, data.pmtud.vpnType,
75-
data.pmtud.network, data.pmtud.ipv6, data.pmtud.icmpAddrs, data.pmtud.tcpAddrs,
75+
data.pmtud.network, ipv6, data.pmtud.icmpAddrs, data.pmtud.tcpAddrs,
7676
l.netLinker, l.routing, l.fw, mtuLogger)
7777
if err != nil {
7878
mtuLogger.Error(err.Error())

0 commit comments

Comments
 (0)