libpcap.patch 728 B

123456789101112131415161718192021
  1. libpcap opens /dev/bpfX as O_RDONLY rather than O_RDWR. This
  2. affects applications which open BPF using pcap_open_live(),
  3. then get the fileno and try to use it to send packets. An
  4. example application having this problem with BGP is UCARP
  5. (http://www.ucarp.org/), which silently fails to send packets.
  6. See also: http://www.freebsd.org/cgi/query-pr.cgi?pr=72814
  7. Index: pcap-bpf.c
  8. --- pcap-bpf.c.orig 2003-11-22 01:06:28 +0100
  9. +++ pcap-bpf.c 2004-12-09 22:57:15 +0100
  10. @@ -468,6 +468,8 @@
  11. do {
  12. (void)snprintf(device, sizeof(device), "/dev/bpf%d", n++);
  13. - fd = open(device, O_RDONLY);
  14. + fd = open(device, O_RDWR);
  15. + if (fd < 0 && errno == EACCES)
  16. + fd = open(device, O_RDONLY);
  17. } while (fd < 0 && errno == EBUSY);
  18. /*