openwrt / openwrt

This repository is a mirror of https://git.openwrt.org/openwrt/openwrt.git It is for reference only and is not active for check-ins. We will continue to accept Pull Requests here. They will be merged via staging trees then into openwrt.git.
Other
19.01k stars 10.04k forks source link

pppd: Couldn't rename interface ppp0 to l2tp-test: Resource busy #13011

Open ValdikSS opened 1 year ago

ValdikSS commented 1 year ago

Describe the bug

I have L2TP connection configured via UCI (/etc/config/network). I'm getting very frequent errors from pppd regarding interface renaming when trying to connect over L2TP (pppol2tp.so).

pppd: Couldn't rename interface ppp0 to l2tp-test: Resource busy

Since this error is fatal, I have to ifup the interface multiple times, up to 10-15. Only after several attempts, it finally manages to rename the interface and connect to L2TP.

There are several patches in master regarding interface creation for pppd. Should they be backported to 22.03.x?

OpenWrt version

22.03.5

OpenWrt target/subtarget

x86/legacy

Device

legacy

Image kind

Official downloaded image

Steps to reproduce

  1. Configure L2TP connection via UCI
  2. Try to connect to the server

Actual behaviour

Most of the time, the connection is not established with pppd: Couldn't rename interface ppp0 to l2tp-test: Resource busy error.

Expected behaviour

The connection is established successfully, without race conditions.

Additional info

daemon.notice xl2tpd[2515]: Connecting to host xxx, port 1701                                                 
daemon.notice xl2tpd[2515]: Connection established to xxx, 1701.  Local: 4612, Remote: 64 (ref=0/0).          
daemon.notice xl2tpd[2515]: Calling on tunnel 4612                                                                      
daemon.notice xl2tpd[2515]: Call established with xxx, Local: 60755, Remote: 62, Serial: 30 (ref=0/0)         
daemon.debug xl2tpd[2515]: start_pppd: I'm running:                                                                     
daemon.debug xl2tpd[2515]: "/usr/sbin/pppd"                                                                             
daemon.debug xl2tpd[2515]: "plugin"                                                                                     
daemon.debug xl2tpd[2515]: "pppol2tp.so"                                                                                
daemon.debug xl2tpd[2515]: "pppol2tp"                                                                                   
daemon.debug xl2tpd[2515]: "8"                                                                                          
daemon.debug xl2tpd[2515]: "passive"                                                                                    
daemon.debug xl2tpd[2515]: "nodetach"                                                                                   
daemon.debug xl2tpd[2515]: ":"                                                                                          
daemon.debug xl2tpd[2515]: "file"                                                                                       
daemon.debug xl2tpd[2515]: "/tmp/l2tp/options.l2tpo"                                                                    
daemon.info pppd[12774]: Plugin pppol2tp.so loaded.                                                                     
daemon.notice pppd[12774]: pppd 2.4.9 started by root, uid 0                                                            
daemon.notice netifd: Interface 'ppp0' is enabled                                                                       
daemon.info ipsec: 11[KNL] interface ppp0 activated                                                                     
daemon.notice netifd: Network device 'ppp0' link is up                                                                  
daemon.notice netifd: Interface 'ppp0' has link connectivity
daemon.notice netifd: Interface 'ppp0' is setting up now
daemon.notice netifd: Interface 'ppp0' is now up
**daemon.err pppd[12774]: Couldn't rename interface ppp0 to l2tp-l2tpo: Resource busy**
daemon.info pppd[12774]: Exit.
daemon.info ipsec: 13[KNL] interface ppp0 deactivated
daemon.notice netifd: Network device 'ppp0' link is down
daemon.info ipsec: 12[KNL] interface ppp0 deleted
daemon.notice netifd: Interface 'ppp0' has link connectivity loss
daemon.notice netifd: Interface 'ppp0' is now down
daemon.debug xl2tpd[2515]: child_handler : pppd exited for call 62 with code 1
daemon.info xl2tpd[2515]: call_close: Call 60755 to xxx disconnected
daemon.info xl2tpd[2515]: control_finish: Connection closed to xxx, port 1701 (), Local: 4612, Remote: 64
daemon.debug xl2tpd[2515]: Terminating pppd: sending TERM signal to pid 12774
daemon.notice netifd: Interface 'ppp0' is disabled

Diffconfig

No response

Terms

ValdikSS commented 1 year ago

@Ansuel

ValdikSS commented 1 year ago

Ok, I found the root of the issue.

I have ppp0 interface configured as proto none in /etc/config/network. When L2TP connection spawns pppd, the interface have ppp0 name, which gets renamed just a moment later by pppd.

However, since the interface is configured in UCI, it is set to up state by netifd as soon as the interface appears. Apparently, you can't rename up'ped interfaces, that's why pppd fails to do so.

From the patches I see in master, it should fix this issue: there's a patch to create the interface with proper name from the start.

Workaround:

ifdown ppp0
ifup l2tpwan
ifup ppp0