Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.sbin/dhcp/common For BPF, we must loop on receive_packet...
details: https://anonhg.NetBSD.org/src/rev/5ca873887722
branches: trunk
changeset: 499721:5ca873887722
user: mycroft <mycroft%NetBSD.org@localhost>
date: Mon Nov 27 17:33:02 2000 +0000
description:
For BPF, we must loop on receive_packet(). BPF may return multiple packets at
once, and we obviously won't get a select() hit for each one in that case.
diffstat:
usr.sbin/dhcp/common/discover.c | 50 +++++++++++++++++++++++-----------------
1 files changed, 29 insertions(+), 21 deletions(-)
diffs (78 lines):
diff -r 3c61848efda7 -r 5ca873887722 usr.sbin/dhcp/common/discover.c
--- a/usr.sbin/dhcp/common/discover.c Mon Nov 27 17:25:24 2000 +0000
+++ b/usr.sbin/dhcp/common/discover.c Mon Nov 27 17:33:02 2000 +0000
@@ -43,7 +43,7 @@
#ifndef lint
static char copyright[] =
-"$Id: discover.c,v 1.8 2000/10/17 16:10:42 taca Exp $ Copyright (c) 1995-2000 The Internet Software Consortium. All rights reserved.\n";
+"$Id: discover.c,v 1.9 2000/11/27 17:33:02 mycroft Exp $ Copyright (c) 1995-2000 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
@@ -669,6 +669,7 @@
struct sockaddr_in from;
struct hardware hfrom;
struct iaddr ifrom;
+ isc_result_t status;
int result;
union {
unsigned char packbuf [4095]; /* Packet input buffer.
@@ -682,30 +683,37 @@
return ISC_R_INVALIDARG;
ip = (struct interface_info *)h;
- if ((result =
- receive_packet (ip, u.packbuf, sizeof u, &from, &hfrom)) < 0) {
- log_error ("receive_packet failed on %s: %m", ip -> name);
- return ISC_R_UNEXPECTED;
- }
- if (result == 0)
- return ISC_R_UNEXPECTED;
+ for (status = ISC_R_UNEXPECTED; ; status = ISC_R_SUCCESS) {
+ if ((result = receive_packet (ip, u.packbuf, sizeof u, &from,
+ &hfrom)) < 0) {
+ if (errno != EWOULDBLOCK) {
+ log_error ("receive_packet failed on %s: %m",
+ ip -> name);
+ return ISC_R_UNEXPECTED;
+ } else
+ return status;
+ }
+ if (result == 0)
+ return status;
- /* If we didn't at least get the fixed portion of the BOOTP
- packet, drop the packet. We're allowing packets with no
- sname or filename, because we're aware of at least one
- client that sends such packets, but this definitely falls
- into the category of being forgiving. */
- if (result < DHCP_FIXED_NON_UDP - DHCP_SNAME_LEN - DHCP_FILE_LEN)
- return ISC_R_UNEXPECTED;
+ /* If we didn't at least get the fixed portion of the BOOTP
+ packet, drop the packet. We're allowing packets with no
+ sname or filename, because we're aware of at least one
+ client that sends such packets, but this definitely falls
+ into the category of being forgiving. */
+ if (result <
+ DHCP_FIXED_NON_UDP - DHCP_SNAME_LEN - DHCP_FILE_LEN)
+ return ISC_R_UNEXPECTED;
- if (bootp_packet_handler) {
- ifrom.len = 4;
- memcpy (ifrom.iabuf, &from.sin_addr, ifrom.len);
+ if (bootp_packet_handler) {
+ ifrom.len = 4;
+ memcpy (ifrom.iabuf, &from.sin_addr, ifrom.len);
- (*bootp_packet_handler) (ip, &u.packet, (unsigned)result,
- from.sin_port, ifrom, &hfrom);
+ (*bootp_packet_handler) (ip, &u.packet,
+ (unsigned)result,
+ from.sin_port, ifrom, &hfrom);
+ }
}
- return ISC_R_SUCCESS;
}
isc_result_t interface_set_value (omapi_object_t *h,
Home |
Main Index |
Thread Index |
Old Index