core icon indicating copy to clipboard operation
core copied to clipboard

PPPOE reconnect loops due to buggy LCP packet bypass

Open somova opened this issue 8 years ago • 55 comments

I have an issue with a stable DSL connection using opnsense 18.1.x. After a reboot everything works fine. In case of reconnection (e.g. forced connection drop by my ISP after 24h, errors etc.) my system runs into a reconnection loop. Depending on the opnsense version (18.1.2 is the first release I ever used) the system behaviour looks differently:

  • v.18.1.2: the connection comes up again and runs fine for 90 seconds and drops again
  • v.18.1.4. the connection does not come up again

The problem is that after re-establishing the PPPoE connection PPP LCP packets sent out on netgraph hook mpd32168-lso:b0 (received on mpd32168-wan:bypass) are not (or only partly) forwarded via hook mpd32168-wan:link0 (see attached netgraph diagram).

In case of version 18.1.2 after re-establishing the PPPoE connection PPP LCP configuration packets are successfully exchanged, but responses to periodically incoming PPP LCP Echo requests (sent every 30 seconds by my ISP) are not forwarded. After 3 unanswered echo requests (3*30 = 90seconds) the ISP drops the connection. In case of version 18.1.4 even the exchange of PPP LCP configuration packets fails.

The bug report is related to the discussion in the opnsense forum: https://forum.opnsense.org/index.php?topic=7270.0

Neither manual reconnect nor restart of the mpd5 daemon works, the only solution is a reboot of the opnsense system.

netgraph_ix0

somova avatar Mar 18 '18 13:03 somova

I am also interested in the evolution of PPPoE with OPNsense, so signing up for this one.

Thank you for reporting the issue.

petererdos avatar Mar 19 '18 07:03 petererdos

Did you try https://github.com/opnsense/core/commit/64057c136f4d ?

fichtner avatar Mar 21 '18 18:03 fichtner

I haven't tried this patch. I think, the patch will not solve the provlem because the observed issues reside on PPP and LCP layer.

somova avatar Mar 28 '18 16:03 somova

Since it was mentioned that it is "stuck" and only reboot helps the following could help since it is related to the pppoe interface in the netgraph kernel module:

https://github.com/opnsense/core/commit/64057c136f4d#diff-c5f4a3581fb76adc9e03ceaee62ceb86R12

fichtner avatar Mar 28 '18 16:03 fichtner

Oh sorry, I have overlooked the details of your patch 😮 and its relation to netgraph. I will test it tomorrow.

somova avatar Mar 28 '18 17:03 somova

Much appreciated, thanks! :)

fichtner avatar Mar 28 '18 17:03 fichtner

I tested the patch, but my system shows the same behaviour like before.

I think the next step should be debugging the mpd5 daemon to see whether the corresponding socket of netgraph hook mpd32168-wan:bypass receive and process the LCP packets. Maybe, I can find some time the next weeks to check this.

somova avatar Mar 29 '18 08:03 somova

Sometimes this issue also occurs after rebooting the machine, not only after pppoe reconnect

somova avatar Apr 05 '18 16:04 somova

I'm experiencing the same issue. I have to reboot my OPNsense multiple times (2 - 3x) per day. mpd5 stops answering LCP Echo Requests and the connection is subsequently terminated: https://forum.opnsense.org/index.php?topic=7270.msg35642#msg35642

This is reliable reproduceable by forcing a PPPoE reconnect, by either side.

Can I do anything to help you fix this issue?

Edit: @fichtner 64057c1 did not fix this issue for me either. My initial installation (18.1.3) was running fine, I think the issue was introduced in either .4 or .5 and was not fixed with .6

Alphakilo avatar Apr 19 '18 11:04 Alphakilo

Your help is highly appreciated. The next steps I like to try when I have some free time:

  1. get more reference logs from working installations (for comparison)
  2. check whether LCP echo response packets sent out by mpd32168-lso:b0 are successfully received by hook mpd32168-wan:bypass (see netgraph above)
  3. check the obscure memory allocator within mpd5
  4. debug the mpd daemon (could be hard without test env and real debugger)

somova avatar Apr 24 '18 19:04 somova

Problem identified :-)

As already mentioned my ISP sends LCP echo request every 10 seconds and terminates the ppp/pppoe session after three unanswered packets. Since the ISP does not receive LCP echo replies my opnsense enters an infinite reconnection loop until I reboot the system. The cause is a timing issue in OpnSense (mpd daemon in conjunction with scripts) which affects all users applying to pppoe dialin in OpnSense.

After negotiating and establishing the ppp session the mpd daemon spawns a new child process for executing the ppp-linkup script by calling the blocking system() function call. This results in blocking the single-threaded mpd instance until the ppp-linkup script finishes. That time all incoming packets for managing the ppp session are queued and not processed.

On my system the ppp-linkup script consumes too much time, so that the mpd daemon is not able to reply the LCP echo request packets in time. This is also the cause why the system runs fine after reboot but not after reestablishing the pppoe session (after reboot the script consumes around 25 seconds to execute in other ways much more time).

In summary, it can be the stated that the problem results in a design flaw. It is not a good idea to process time critical actions within the mpd5 daemon while running a blocking system call without knowing how much time it consumes. To my mind in the long term the architecture of the mpd daemon needs a change by spawning the child process in a separate thread (or all time critical actions).

As a short term solution all actions which are not related to setting up the interface (all but ip addresses, dns servers and routes) should be sourced out to synchronized parallel processes.

somova avatar May 06 '18 11:05 somova

@somova thanks for this analysis, we can try a thing or two with this info :)

fichtner avatar May 06 '18 11:05 fichtner

@fichtner: thanks for the fast reply. Currently I am testing a dirty work around as short term solution (see here)

somova avatar May 06 '18 11:05 somova

@somova I was thinking something similar, but needed to check the code first to see if this was a very early regression when we removed pfSctl, but it does not seem so. How about a54cf79 (untested, extra branch for now).

fichtner avatar May 06 '18 11:05 fichtner

@fichtner: I applied the patch, the ppp-linkup works fine after reboot. But after initiating a reconnect I don't have internet access anymore. It seems that not all necessary services are restarted and the default routes are not setup properly.

Log after reboot (excerpt): May 6 15:28:46 opnsense: /usr/local/etc/rc.bootup: Dynamic DNS: (Success) IP Address Updated Successfully! May 6 15:28:46 opnsense: /usr/local/etc/rc.bootup: Dynamic DNS: updating cache file /var/cache/dyndns[...] May 6 15:28:45 opnsense: /usr/local/etc/rc.bootup: Dynamic DNS: (Success) IP Address Updated Successfully! May 6 15:28:45 opnsense: /usr/local/etc/rc.bootup: Dynamic DNS: updating cache file /var/cache/dyndns[...] [...] May 6 15:27:46 opnsense: /usr/local/etc/rc.bootup: ROUTING: setting IPv6 default route to fe80::9203:25ff:fe74:4dfe May 6 15:27:46 opnsense: /usr/local/etc/rc.bootup: ROUTING: setting IPv4 default route to 62.214.63.89 May 6 15:27:46 opnsense: /usr/local/etc/rc.bootup: ROUTING: no IPv6 default gateway set, trying wan on 'pppoe0' (fe80::9203:25ff:fe74:4dfe) May 6 15:27:46 opnsense: /usr/local/etc/rc.bootup: ROUTING: no IPv4 default gateway set, trying wan on 'pppoe0' (62.214.63.89)

Log after manually initiated reconnect (excerpt): May 6 15:33:24 kernel: ix0: promiscuous mode disabled May 6 15:32:37 kernel: ng_pppoe[10]: no matching session May 6 15:32:34 kernel: ng_pppoe[10]: no matching session May 6 15:32:34 kernel: ng_pppoe[10]: no matching session May 6 15:32:33 opnsense: /usr/local/etc/rc.newwanip: ROUTING: skipping IPv4 default route to wan May 6 15:32:33 opnsense: /usr/local/etc/rc.newwanip: ROUTING: skipping IPv4 default route to wan May 6 15:32:33 opnsense: /usr/local/etc/rc.newwanip: ROUTING: no IPv6 default gateway set, trying wan on 'pppoe0' () May 6 15:32:33 opnsense: /usr/local/etc/rc.newwanip: ROUTING: no IPv4 default gateway set, trying wan on 'pppoe0' () May 6 15:32:33 opnsense: /usr/local/etc/rc.newwanip: ROUTING: removing /tmp/pppoe0_defaultgwv6 May 6 15:32:33 opnsense: /usr/local/etc/rc.newwanip: ROUTING: removing /tmp/pppoe0_defaultgw May 6 15:32:33 opnsense: /usr/local/etc/rc.newwanip: ROUTING: entering configure using 'opt3' May 6 15:32:33 opnsense: /usr/local/etc/rc.newwanip: On (IP address: 192.168.100.2) (interface: WAN_GUESTNET[opt3]) (real interface: ix0). May 6 15:32:33 opnsense: /usr/local/etc/rc.newwanip: IP renewal is starting on 'ix0' May 6 15:32:33 opnsense: /usr/local/etc/rc.linkup: Hotplug event detected for WAN_GUESTNET(opt3) but ignoring since interface is configured with static IP (192.168.100.2 ::) May 6 15:32:33 kernel: ix0_vlan7: link state changed to UP May 6 15:32:33 kernel: ix0: link state changed to UP May 6 15:32:24 opnsense: /usr/local/etc/rc.linkup: Hotplug event detected for WAN_GUESTNET(opt3) but ignoring since interface is configured with static IP (192.168.100.2 ::) May 6 15:32:24 kernel: ng0: changing name to 'pppoe0' May 6 15:32:23 kernel: ix0_vlan7: link state changed to DOWN May 6 15:32:23 kernel: ix0: link state changed to DOWN May 6 15:32:23 opnsense: /status_interfaces.php: The command '/sbin/ifconfig 'pppoe0' inet6 -accept_rtadv' returned exit code '1', the output was 'ifconfig: interface pppoe0 does not exist' May 6 15:32:23 opnsense: /status_interfaces.php: The command `/sbin/ifconfig -m 'pppoe0'' failed to execute ifconfig: interface pppoe0 does not exist May 6 15:32:19 kernel: ix0: promiscuous mode enabled May 6 15:32:16 kernel: ix0: promiscuous mode disabled May 6 15:32:09 sshlockout[83567]: sshlockout/webConfigurator v3.0 starting up May 6 15:32:09 ppp-linkdown: Removing stale PPPoE gateway 62.214.63.89 on inet

somova avatar May 06 '18 13:05 somova

looks like ppp-linkup is started but pppoe0 is not configured? oO

fichtner avatar May 06 '18 13:05 fichtner

@somova could you also post the interfaces: ppp: log file output ?

fichtner avatar May 06 '18 21:05 fichtner

@somova and one more question... when the manual reconnect is done, will this fix it?

# configctl interface newip pppoe0

It looks like there is something wrong with the config.xml ... reading this pppoe0 is on top of ix0_vlan7 is on top of ix0 ? where would a static IP of 192.168.100.2 on ix0 come from if not from the config.xml ?!

fichtner avatar May 06 '18 21:05 fichtner

Due to problems with the patch I switched back to my work around. But this morning again no internet connection :cry:. The process list contained some hanging python processes which looked like remains from yesterday's tests.

root 47440 100.0 0.1 43644 10004 - Rs 15:32 860:46.39 /usr/local/bin/python2.7 /usr/local/opnsense/service/configd_ctl.py -m 'dns reload' 'interface newip pppoe0' root 40075 83.2 0.1 43644 9876 - Rs 15:27 829:08.92 /usr/local/bin/python2.7 /usr/local/opnsense/service/configd_ctl.py -m 'dns reload' 'interface newip pppoe0' root 36610 80.0 0.1 43644 9868 - Rs 15:27 827:26.13 /usr/local/bin/python2.7 /usr/local/opnsense/service/configd_ctl.py -m 'dns reload' 'interface newip pppoe0' root 44841 76.2 0.1 43644 10016 - Rs 15:32 801:07.49 /usr/local/bin/python2.7 /usr/local/opnsense/service/configd_ctl.py -m 'dns reload' 'interface newip pppoe0' root 20349 0.0 0.1 1110628 6468 - Ss 05:53 0:00.02 /usr/local/sbin/mpd5 -b -k -d /var/etc -f mpd_wan.conf -p /var/run/pppoe_wan.pid -s ppp pppoeclient

somova avatar May 07 '18 18:05 somova

@somova could you also post the interfaces: ppp: log file output ? @somova and one more question... when the manual reconnect is done, will this fix it?

Ok, I will test the patch again and post the results.

It looks like there is something wrong with the config.xml ... reading this pppoe0 is on top of ix0_vlan7 is on top of ix0 ? where would a static IP of 192.168.100.2 on ix0 come from if not from the config.xml ?!

  1. The pppoe0 is on top of ix0
  2. The ix0_vlan7 is on top of ix0 (This one was only for testing purposes with fritzbox but not in use anymore).

The static ip on ix0 is for the IP related communication with my fritzbox 7412 (192.168.100.1). This box is not configured as a real bridge modem but forwards incoming pppoe packets to the DSL interface and vice versa. In this configuration the box is still able to offer all its standard functionality to me (e.g. WLAN [as my guest WLAN] etc.)

somova avatar May 07 '18 19:05 somova