[os-upnp] miniupnpd is unnecessarily restarted on IPv6 WAN renewals

Open Beginner friendly
#6,000 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
85/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
php
Domain
backend

Research direction

Start by reading the newwanip hook in net/upnp and the miniupnpd_configure_do callback it invokes. Check how the hook passes WAN event arguments and how the callback handles inet versus inet6. Done means IPv4 renewals still restart miniupnpd while IPv6 renewals do not; the issue reports local validation for both families.

Written by the indexing model from the issue text.

Description

Important notices
Before you add a new report, we ask you kindly to acknowledge the following:

Bug description

The miniupnpd service is restarted on IPv6 WAN renewals, although its IPv4-facing UPnP configuration has not changed.

The newwanip hook in net/upnp currently invokes miniupnpd_configure_do for both IPv4 and IPv6 WAN address events. The callback does not inspect the address family, so an IPv6 renewal stops and starts miniupnpd unnecessarily.

On my OPNsense system this was reproducible with a PPPoE WAN. During a PPPoE reconnect, the IPv4 address change should trigger a miniupnpd restart; subsequent IPv6 address events should not trigger further restarts.

Environment

  • OPNsense 26.7.10p1
  • os-upnp 1.10_1
  • miniupnpd 2.3.11_2,1
  • FreeBSD 15 amd64
  • PPPoE WAN interface (pppoe0)

Steps to reproduce

  1. Enable UPnP and run miniupnpd with a PPPoE WAN.
  2. Trigger a WAN reconnect or another event that causes the IPv4 and IPv6 WAN address hooks to run.
  3. Observe miniupnpd process start/stop events.
  4. The IPv6 WAN renewal also invokes the miniupnpd restart callback.

Expected behaviour

Only IPv4 WAN address changes should trigger this newwanip restart. IPv6 WAN renewals should leave the miniupnpd process and its active state untouched.

Proposed change

Pass the hook arguments to the callback and ignore calls for address families other than inet:

'newwanip' => ['miniupnpd_configure_do:3'],

function miniupnpd_configure_do($verbose = false, $interfaces = [], $family = 'inet')
{
    global $config;

    if ($family !== 'inet') {
        return;
    }

    miniupnpd_stop();
    // existing configuration/start logic remains unchanged
}

The proposed change is intentionally limited to the newwanip hook and its callback. It does not alter miniupnpd startup behaviour or IPv6 UPnP functionality.

The default value inet preserves the existing boot-hook behaviour, where the callback is invoked without WAN-event arguments.

Validation

I applied this change locally and verified PHP syntax and the callback behaviour for both inet and inet6, including invocation through the plugin dispatcher.

During a real PPPoE reconnect, the IPv4 public address changed and miniupnpd restarted once for the IPv4 event. Subsequent IPv6 renewal events did not cause additional restarts. The UPnP lease remained present and the Xbox reported an Open NAT status.

A lease-file disappearance had also been observed during earlier testing, but its precise cause was not conclusively established; I am not attributing that behaviour to this callback issue.

The patch is intended as a minimal fix to avoid restarting miniupnpd on IPv6 WAN renewals.

Dominant language
PHP
Stars
1.2k
Forks
932
Avg merge
1d 11h
Merged PRs (30d)
22

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from opnsense/plugins

All issues in opnsense/plugins

Similar issues

More PHP issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.