Re: bpf/pcap are weird

From: Guy Harris (guy_at_alum.mit.edu)
Date: 11/21/03

  • Next message: Poul-Henning Kamp: "Re: adding crypto support to GENERIC"
    Date: Fri, 21 Nov 2003 01:27:41 -0800
    To: Bruce Evans <bde@zeta.org.au>
    
    

    > > bpfpoll() is reported to be broken; see PR 36219.
    >
    > Yes, that's the PR that indicated that "select()"/"poll()" don't, in
    > fact, work correctly with timeouts.
    >
    > That was fixed in 4.5...
    >
    > > Rev.1.113 of bpf.c may have disturbed this.
    >
    > ...but might have been re-broken.
    >
    > > It removed the comment which said that
    > > bpf_ready() doesn't acually imitate resultof(FIONREAD) != 0.
    >
    > ...and it also removed the check for "d->bd_state == BPF_TIMED_OUT" that
    > made "select()"/"poll()" work with timeouts.

    I didn't read the code fully - no, it didn't. Revision 1.113 changed

            if (events & (POLLIN | POLLRDNORM)) {
                    /*
                     * An imitation of the FIONREAD ioctl code.
                     * XXX not quite. An exact imitation:
                     * if (d->b_slen != 0 ||
                     * (d->bd_hbuf != NULL && d->bd_hlen != 0)
                     */
                    if (d->bd_hlen != 0 ||
                        ((d->bd_immediate || d->bd_state == BPF_TIMED_OUT) &&
                        d->bd_slen != 0))
                            revents |= events & (POLLIN | POLLRDNORM);
                    else {
                            selrecord(td, &d->bd_sel);
                            /* Start the read timeout if necessary. */
                            if (d->bd_rtout > 0 && d->bd_state == BPF_IDLE) {
                                    callout_reset(&d->bd_callout, d->bd_rtout,
                                        bpf_timed_out, d);
                                    d->bd_state = BPF_WAITING;
                            }
                    }
            }

    to

            if (events & (POLLIN | POLLRDNORM)) {
                    if (bpf_ready(d))
                            revents |= events & (POLLIN | POLLRDNORM);
                    else {
                            selrecord(td, &d->bd_sel);
                            /* Start the read timeout if necessary. */
                            if (d->bd_rtout > 0 && d->bd_state == BPF_IDLE) {
                                    callout_reset(&d->bd_callout, d->bd_rtout,
                                        bpf_timed_out, d);
                                    d->bd_state = BPF_WAITING;
                            }
                    }
            }

    but revision 1.23 of "bpfdesc.h" introduce a macro "bpf_ready(bd)" that
    does

            #define bpf_ready(bd) \
                    ((bd)->bd_hlen != 0 || \
                     (((bd)->bd_immediate || (bd)->bd_state == BPF_TIMED_OUT) && \
                      (bd)->bd_slen != 0))

    so the actual "bpf_poll()" code doesn't change.

    Revision 1.23 was MFC'ed to the 4.x branch in revision 1.14.2.3, which
    is in 4.9.

    (Also, the problem I mentioned with FreeBSD 4.4 not supporting the
    workaround for "select()" not working is in FreeBSD 4.3 as well.)
    _______________________________________________
    freebsd-arch@freebsd.org mailing list
    http://lists.freebsd.org/mailman/listinfo/freebsd-arch
    To unsubscribe, send any mail to "freebsd-arch-unsubscribe@freebsd.org"


  • Next message: Poul-Henning Kamp: "Re: adding crypto support to GENERIC"

    Relevant Pages

    • Re: Seemingly odd disc i/o behaviour, need help to diagnose
      ... FreeBSD 4.4 is detecting a 'Generic PCI ATA Controller', ... > This manifests itself in timeouts on webpages that require DB data, ... > timeouts for other mail accounts, ...
      (freebsd-stable)
    • Problem with SCSI timeout
      ... Without medium, FreeBSD 5.4 takes 6 minutes to boot, because of ... When i saw that the time between these timeouts ...
      (comp.unix.bsd.freebsd.misc)
    • Problem with SCSI timeout
      ... Without medium, FreeBSD 5.4 takes 6 minutes to boot, because of ... When i saw that the time between these timeouts ...
      (comp.unix.bsd.freebsd.misc)
    • Problem with SCSI timeout
      ... Without medium, FreeBSD 5.4 takes 6 minutes to boot, because of ... When i saw that the time between these timeouts ...
      (comp.unix.bsd.freebsd.misc)
    • Re: optical mice
      ... :> Dear FreeBSD! ... I could live without a wheel, ... :> have experience with optical mice? ... To unsubscribe, ...
      (freebsd-stable)

  • Quantcast