diff options
author | 2017-02-13 19:13:14 +0000 | |
---|---|---|
committer | 2017-02-13 19:13:14 +0000 | |
commit | c525a1850093eeda7e2f4793bb28f06faaca922a (patch) | |
tree | bae08923087470164b0eddd80c96e3124bf720bf /usr.sbin/dhcpd/bpf.c | |
parent | Fix powerdown with vmmci(4) VMs using a shutdown and no reset. (diff) | |
download | wireguard-openbsd-c525a1850093eeda7e2f4793bb28f06faaca922a.tar.xz wireguard-openbsd-c525a1850093eeda7e2f4793bb28f06faaca922a.zip |
Switch from old errwarn.c logging to shiny new log.[ch].
ok benno@
Diffstat (limited to 'usr.sbin/dhcpd/bpf.c')
-rw-r--r-- | usr.sbin/dhcpd/bpf.c | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/usr.sbin/dhcpd/bpf.c b/usr.sbin/dhcpd/bpf.c index b84fb6d6c89..b862a44cd62 100644 --- a/usr.sbin/dhcpd/bpf.c +++ b/usr.sbin/dhcpd/bpf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bpf.c,v 1.14 2016/05/28 07:00:18 natano Exp $ */ +/* $OpenBSD: bpf.c,v 1.15 2017/02/13 19:13:14 krw Exp $ */ /* BPF socket interface code, originally contributed by Archie Cobbs. */ @@ -62,6 +62,7 @@ #include "dhcp.h" #include "tree.h" #include "dhcpd.h" +#include "log.h" ssize_t send_packet (struct interface_info *, struct dhcp_packet *, size_t, struct in_addr, struct sockaddr_in *, struct hardware *); @@ -77,11 +78,11 @@ if_register_bpf(struct interface_info *info) int sock; if ((sock = open("/dev/bpf0", O_RDWR)) == -1) - error("Can't open bpf device: %m"); + fatalx("Can't open bpf device: %m"); /* Set the BPF device to point at this interface. */ if (ioctl(sock, BIOCSETIF, info->ifp) == -1) - error("Can't attach interface %s to bpf device: %m", + fatalx("Can't attach interface %s to bpf device: %m", info->name); info->send_packet = send_packet; @@ -181,11 +182,11 @@ if_register_receive(struct interface_info *info) /* Make sure the BPF version is in range... */ if (ioctl(info->rfdesc, BIOCVERSION, &v) == -1) - error("Can't get BPF version: %m"); + fatalx("Can't get BPF version: %m"); if (v.bv_major != BPF_MAJOR_VERSION || v.bv_minor < BPF_MINOR_VERSION) - error("Kernel BPF version out of range - recompile dhcpd!"); + fatalx("Kernel BPF version out of range - recompile dhcpd!"); /* * Set immediate mode so that reads return as soon as a packet @@ -193,22 +194,22 @@ if_register_receive(struct interface_info *info) * with packets. */ if (ioctl(info->rfdesc, BIOCIMMEDIATE, &flag) == -1) - error("Can't set immediate mode on bpf device: %m"); + fatalx("Can't set immediate mode on bpf device: %m"); if (ioctl(info->rfdesc, BIOCSFILDROP, &flag) == -1) - error("Can't set filter-drop mode on bpf device: %m"); + fatalx("Can't set filter-drop mode on bpf device: %m"); /* make sure kernel fills in the source ethernet address */ if (ioctl(info->rfdesc, BIOCSHDRCMPLT, &cmplt) == -1) - error("Can't set header complete flag on bpf device: %m"); + fatalx("Can't set header complete flag on bpf device: %m"); /* Get the required BPF buffer length from the kernel. */ if (ioctl(info->rfdesc, BIOCGBLEN, &sz) == -1) - error("Can't get bpf buffer length: %m"); + fatalx("Can't get bpf buffer length: %m"); info->rbuf_max = sz; info->rbuf = malloc(info->rbuf_max); if (!info->rbuf) - error("Can't allocate %lu bytes for bpf input buffer.", + fatalx("Can't allocate %lu bytes for bpf input buffer.", (unsigned long)info->rbuf_max); info->rbuf_offset = 0; info->rbuf_len = 0; @@ -218,18 +219,18 @@ if_register_receive(struct interface_info *info) p.bf_insns = dhcp_bpf_filter; if (ioctl(info->rfdesc, BIOCSETF, &p) == -1) - error("Can't install packet filter program: %m"); + fatalx("Can't install packet filter program: %m"); /* Set up the bpf write filter program structure. */ p.bf_len = dhcp_bpf_wfilter_len; p.bf_insns = dhcp_bpf_wfilter; if (ioctl(info->rfdesc, BIOCSETWF, &p) == -1) - error("Can't install write filter program: %m"); + fatalx("Can't install write filter program: %m"); /* make sure these settings cannot be changed after dropping privs */ if (ioctl(info->rfdesc, BIOCLOCK) == -1) - error("Failed to lock bpf descriptor: %m"); + fatalx("Failed to lock bpf descriptor: %m"); } ssize_t @@ -255,7 +256,7 @@ send_packet(struct interface_info *interface, struct dhcp_packet *raw, result = writev(interface->wfdesc, iov, 2); if (result == -1) - warning("send_packet: %m"); + log_warnx("send_packet: %m"); return (result); } |