ppp icon indicating copy to clipboard operation
ppp copied to clipboard

Should this check ignore EINVAL?

Open ohmyitscasper opened this issue 4 years ago • 4 comments

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?

ohmyitscasper avatar Apr 06 '21 21:04 ohmyitscasper

@paulusmack: What do you think?

Neustradamus avatar Apr 09 '21 02:04 Neustradamus

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.

paulusmack avatar Apr 11 '21 23:04 paulusmack

@ohmyitscasper: Can you publish debug logs like @paulusmack has requested you more one year ago?

Neustradamus avatar Oct 25 '22 18:10 Neustradamus