ppp-project / ppp

Paul's PPP Package: PPP daemon and associated utilities | Official GitHub repo: https://github.com/ppp-project/ppp
https://github.com/ppp-project/ppp
Other
384 stars 231 forks source link

Should this check ignore EINVAL? #271

Open ohmyitscasper opened 3 years ago

ohmyitscasper commented 3 years ago

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?

Neustradamus commented 3 years ago

@paulusmack: What do you think?

paulusmack commented 3 years ago

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.

Neustradamus commented 2 years ago

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

Neustradamus commented 2 months ago

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