PPPoE WAN: MASTER restarts mpd5 while dialing; BACKUP reports result=partial #16

Closed
opened 2026-10-22 17:36:11 -07:00 by eric · 0 comments
Owner

Summary

The script and README describe PPPoE WANs as supported ("typically a WAN with a DHCP/PPPoE address"), but the runtime guards were only designed for and tested with DHCP. On a PPPoE WAN the MASTER branch probably keeps restarting mpd5, and the BACKUP branch probably reports result=partial on every transition. This comes from reading the code; it has not been reproduced on a PPPoE box.

Background

For a PPPoE interface, $config['interfaces']['wan']['if'] is the PPP device (e.g. pppoe0), so get_real_interface('wan') returns pppoe0, not the parent NIC. mpd5 creates pppoe0, and it is only UP and addressed once the session is established.

Problem A: MASTER keeps restarting the PPPoE session

iface_is_up() / iface_is_configured() (around lines 353–395) decide whether MASTER skips the interface. iface_is_configured() already has an exception for "DHCP still waiting on a lease" (live dhclient via /var/run/dhclient.<dev>.pid) so that duplicate events and reconciles don't restart it. PPPoE has no equivalent:

  • While mpd5 is dialing, or redialing during an ISP outage, pppoe0 is missing or not UP, so iface_is_up() returns false.
  • Every duplicate per-VHID CARP event and every once-a-minute --reconcile then runs legacy_interface_flags() + interface_configure() again, which restarts mpd5 mid-negotiation. A slow PPPoE server, or an outage longer than a minute, gives a restart loop, and each reconcile also logs the "drifted" error.

Fix: in the MASTER skip decision, also treat the interface as "configured/pending" when its PPP daemon is alive. OPNsense's mpd pidfile is /var/run/<type>_<ifkey>.pid (e.g. /var/run/pppoe_wan.pid). Verify the exact path in interfaces.inc (interface_ppps_configure / interface_ppps_reset) on current OPNsense core. Also check what iface_is_up() should mean when pppoe0 doesn't exist yet; probably check the daemon before the UP flag for PPP-type interfaces ($config['interfaces'][$ifkey]['ipaddr'] is pppoe/pptp/l2tp/ppp).

Problem B: BACKUP reports result=partial every time

BACKUP branch (around lines 789–796): interface_reset($ifkey) → interface_ppps_reset() kills mpd5, which most likely destroys pppoe0. The "belt-and-suspenders" ifconfig pppoe0 down then fails ("interface does not exist"), run_cmd() sets $failed, and the END banner says result=partial on every BACKUP transition.

Fix: skip the ifconfig down (or treat it as success) when the device no longer exists after interface_reset(). For PPP interfaces, consider downing the parent NIC instead. The parent comes from $config['ppps']['ppp'][]['ports'], or interface_ppps_hardware(), which interface_configure() uses to resolve $realhwif.

  • node_role()'s "VHID on a toggled interface" exclusion compares against pppoe0, not the parent NIC. That's harmless, but worth noting if the parent device ever needs to be included.
  • README "Tested on" should say PPPoE is untested until someone verifies it.

Acceptance

  • On a PPPoE WAN (or with stubs): repeated MASTER events/reconciles while mpd5 is dialing don't call interface_configure() again.
  • A BACKUP transition on a connected PPPoE WAN ends with result=ok.
  • CHANGELOG [Unreleased] entry.
## Summary The script and README describe PPPoE WANs as supported ("typically a WAN with a DHCP/PPPoE address"), but the runtime guards were only designed for and tested with DHCP. On a PPPoE WAN the MASTER branch probably keeps restarting `mpd5`, and the BACKUP branch probably reports `result=partial` on every transition. This comes from reading the code; it has not been reproduced on a PPPoE box. ## Background For a PPPoE interface, `$config['interfaces']['wan']['if']` is the PPP device (e.g. `pppoe0`), so `get_real_interface('wan')` returns `pppoe0`, not the parent NIC. `mpd5` creates `pppoe0`, and it is only UP and addressed once the session is established. ## Problem A: MASTER keeps restarting the PPPoE session `iface_is_up()` / `iface_is_configured()` (around lines 353–395) decide whether MASTER skips the interface. `iface_is_configured()` already has an exception for "DHCP still waiting on a lease" (live `dhclient` via `/var/run/dhclient.<dev>.pid`) so that duplicate events and reconciles don't restart it. PPPoE has no equivalent: - While `mpd5` is dialing, or redialing during an ISP outage, `pppoe0` is missing or not UP, so `iface_is_up()` returns false. - Every duplicate per-VHID CARP event and every once-a-minute `--reconcile` then runs `legacy_interface_flags()` + `interface_configure()` again, which restarts `mpd5` mid-negotiation. A slow PPPoE server, or an outage longer than a minute, gives a restart loop, and each reconcile also logs the "drifted" error. **Fix:** in the MASTER skip decision, also treat the interface as "configured/pending" when its PPP daemon is alive. OPNsense's mpd pidfile is `/var/run/<type>_<ifkey>.pid` (e.g. `/var/run/pppoe_wan.pid`). Verify the exact path in `interfaces.inc` (`interface_ppps_configure` / `interface_ppps_reset`) on current OPNsense core. Also check what `iface_is_up()` should mean when `pppoe0` doesn't exist yet; probably check the daemon before the UP flag for PPP-type interfaces (`$config['interfaces'][$ifkey]['ipaddr']` is `pppoe`/`pptp`/`l2tp`/`ppp`). ## Problem B: BACKUP reports `result=partial` every time BACKUP branch (around lines 789–796): `interface_reset($ifkey)` → `interface_ppps_reset()` kills `mpd5`, which most likely destroys `pppoe0`. The "belt-and-suspenders" `ifconfig pppoe0 down` then fails ("interface does not exist"), `run_cmd()` sets `$failed`, and the END banner says `result=partial` on every BACKUP transition. **Fix:** skip the `ifconfig down` (or treat it as success) when the device no longer exists after `interface_reset()`. For PPP interfaces, consider downing the parent NIC instead. The parent comes from `$config['ppps']['ppp'][]['ports']`, or `interface_ppps_hardware()`, which `interface_configure()` uses to resolve `$realhwif`. ## Related - `node_role()`'s "VHID on a toggled interface" exclusion compares against `pppoe0`, not the parent NIC. That's harmless, but worth noting if the parent device ever needs to be included. - README "Tested on" should say PPPoE is untested until someone verifies it. ## Acceptance - On a PPPoE WAN (or with stubs): repeated MASTER events/reconciles while `mpd5` is dialing don't call `interface_configure()` again. - A BACKUP transition on a connected PPPoE WAN ends with `result=ok`. - CHANGELOG `[Unreleased]` entry.
eric closed this issue 2026-10-23 15:39:27 -07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
eric/10-wancarp#16
No description provided.