ppp
ppp copied to clipboard
Should this check ignore EINVAL?
I'm getting ppp connection errors due to this check in sys-linux when trying to establish a ppp connection:
if (ioctl(fd, PPPIOCCONNECT, &ifunit) < 0) {
error("Couldn't attach to PPP unit %d: %m", ifunit);
goto err_close;
}
The kernel docs say this ioctl will return EINVAL if a connection already exists:
* PPPIOCCONNECT connects this channel to a PPP interface. The
argument should point to an int containing the interface unit
number. It will return an EINVAL error if the channel is already
connected to an interface, or ENXIO if the requested interface does
not exist.
With the following patch, my connection goes through fine:
- if (ioctl(fd, PPPIOCCONNECT, &ifunit) < 0) {
+ int ret = ioctl(fd, PPPIOCCONNECT, &ifunit);
+ if (ret < 0 && errno != EINVAL) {
error("Couldn't attach to PPP unit %d: %m", ifunit);
goto err_close;
}
So, should this check ignore EINVAL?
@paulusmack: What do you think?
Just ignoring EINVAL isn't the right thing to do; if the channel is already connected to an interface, how do we know that's the interface we want? And how did it get into that state anyway?
Without more details, such as debug logs from pppd, it's not possible to say what the correct fix would be.
@ohmyitscasper: Can you publish debug logs like @paulusmack has requested you more one year ago?