X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=pppd%2Fsys-linux.c;h=448d426dfdf04249fa086dec1b6496702bb60dfe;hb=26703b215b0b68d7005e6b5e41d744101471a743;hp=f25e6c3c393dc70dac0300b8ac1f270dd1273fe3;hpb=52a17b6d41d64d0502a73e5b4224546360581b49;p=ppp.git diff --git a/pppd/sys-linux.c b/pppd/sys-linux.c index f25e6c3..448d426 100644 --- a/pppd/sys-linux.c +++ b/pppd/sys-linux.c @@ -85,6 +85,11 @@ #endif #endif /* IPX_CHANGE */ +#ifdef PPP_FILTER +#include +#include +#endif /* PPP_FILTER */ + #ifdef LOCKLIB #include #endif @@ -442,8 +447,9 @@ int establish_ppp (int tty_fd) */ set_ppp_fd (tty_fd); if (ioctl(tty_fd, PPPIOCGUNIT, &x) < 0) { - if ( ! ok_error (errno)) - fatal("ioctl(PPPIOCGUNIT): %m(%d)", errno); + if (ok_error (errno)) + goto err; + fatal("ioctl(PPPIOCGUNIT): %m(%d)", errno); } /* Check that we got the same unit again. */ if (looped && x != ifunit) @@ -988,13 +994,13 @@ int read_packet (unsigned char *buf) nr = -1; if (ppp_fd >= 0) { nr = read(ppp_fd, buf, len); - if (nr < 0 && errno != EWOULDBLOCK && errno != EIO) + if (nr < 0 && errno != EWOULDBLOCK && errno != EIO && errno != EINTR) error("read: %m"); } if (nr < 0 && new_style_driver && ifunit >= 0) { /* N.B. we read ppp_fd first since LCP packets come in there. */ nr = read(ppp_dev_fd, buf, len); - if (nr < 0 && errno != EWOULDBLOCK && errno != EIO) + if (nr < 0 && errno != EWOULDBLOCK && errno != EIO && errno != EINTR) error("read /dev/ppp: %m"); } return (new_style_driver && nr > 0)? nr+2: nr; @@ -1158,6 +1164,33 @@ void ccp_flags_set (int unit, int isopen, int isup) } } +#ifdef PPP_FILTER +/* + * set_filters - set the active and pass filters in the kernel driver. + */ +int set_filters(struct bpf_program *pass, struct bpf_program *active) +{ + struct sock_fprog fp; + + fp.len = pass->bf_len; + fp.filter = (struct sock_filter *) pass->bf_insns; + if (ioctl(ppp_dev_fd, PPPIOCSPASS, &fp) < 0) { + if (errno == ENOTTY) + warn("kernel does not support PPP filtering"); + else + error("Couldn't set pass-filter in kernel: %m"); + return 0; + } + fp.len = active->bf_len; + fp.filter = (struct sock_filter *) active->bf_insns; + if (ioctl(ppp_dev_fd, PPPIOCSACTIVE, &fp) < 0) { + error("Couldn't set active-filter in kernel: %m"); + return 0; + } + return 1; +} +#endif /* PPP_FILTER */ + /******************************************************************** * * get_idle_time - return how long the link has been idle.