diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2004-09-16 09:35:25 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2004-09-16 09:35:25 +0000 |
commit | 4e3a6692a9173e15874bf23d4a5af5c10724b36b (patch) | |
tree | 0c7c864ac7e2c71fe15795863e7bb870d33cabbb | |
parent | 3264005a9cbc0436cf558290c65e4b2103226f0f (diff) |
Remove the not initialized fallback_interface code and use the normal bpf
interface for that. Also store the hardware (ethernet) address in the state
so that relayed dhcp request are sent to the correct destination.
OK henning@ requested by deraadt@ tested otto@
-rw-r--r-- | usr.sbin/dhcpd/bootp.c | 11 | ||||
-rw-r--r-- | usr.sbin/dhcpd/dhcp.c | 35 | ||||
-rw-r--r-- | usr.sbin/dhcpd/dhcpd.h | 6 | ||||
-rw-r--r-- | usr.sbin/dhcpd/dispatch.c | 8 |
4 files changed, 21 insertions, 39 deletions
diff --git a/usr.sbin/dhcpd/bootp.c b/usr.sbin/dhcpd/bootp.c index 93f2a798cd3..03e970b1b0b 100644 --- a/usr.sbin/dhcpd/bootp.c +++ b/usr.sbin/dhcpd/bootp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bootp.c,v 1.9 2004/05/11 04:08:35 deraadt Exp $ */ +/* $OpenBSD: bootp.c,v 1.10 2004/09/16 09:35:24 claudio Exp $ */ /* * BOOTP Protocol support. @@ -332,12 +332,9 @@ lose: to.sin_addr = raw.giaddr; to.sin_port = server_port; - if (fallback_interface) { - result = send_packet(fallback_interface, &raw, - outgoing.packet_length, from, &to, &hto); - return; - } - + result = send_packet(packet->interface, &raw, + outgoing.packet_length, from, &to, packet->haddr); + return; } /* diff --git a/usr.sbin/dhcpd/dhcp.c b/usr.sbin/dhcpd/dhcp.c index b7e5cf5c0d6..98c0d3adff6 100644 --- a/usr.sbin/dhcpd/dhcp.c +++ b/usr.sbin/dhcpd/dhcp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dhcp.c,v 1.12 2004/05/24 06:22:45 henning Exp $ */ +/* $OpenBSD: dhcp.c,v 1.13 2004/09/16 09:35:24 claudio Exp $ */ /* * Copyright (c) 1995, 1996, 1997, 1998, 1999 @@ -560,13 +560,11 @@ nak_lease(struct packet *packet, struct iaddr *cip) to.sin_addr = raw.giaddr; to.sin_port = server_port; - if (fallback_interface) { - result = send_packet(fallback_interface, &raw, - outgoing.packet_length, from, &to, &hto); - if (result == -1) - warn("send_fallback: %m"); - return; - } + result = send_packet(packet->interface, &raw, + outgoing.packet_length, from, &to, packet->haddr); + if (result == -1) + warn("send_fallback: %m"); + return; } else { to.sin_addr.s_addr = htonl(INADDR_BROADCAST); to.sin_port = client_port; @@ -830,6 +828,7 @@ ack_lease(struct packet *packet, struct lease *lease, unsigned int offer, state->bootp_flags = packet->raw->flags; state->hops = packet->raw->hops; state->offer = offer; + memcpy(&state->haddr, packet->haddr, sizeof state->haddr); /* Figure out what options to send to the client: */ @@ -1216,14 +1215,12 @@ dhcp_reply(struct lease *lease) to.sin_addr = raw.giaddr; to.sin_port = server_port; - if (fallback_interface) { - result = send_packet(fallback_interface, &raw, - packet_length,raw.siaddr, &to, NULL); + result = send_packet(state->ip, &raw, + packet_length, raw.siaddr, &to, &state->haddr); - free_lease_state(state, "dhcp_reply fallback 1"); - lease->state = NULL; - return; - } + free_lease_state(state, "dhcp_reply gateway"); + lease->state = NULL; + return; /* If the client is RENEWING, unicast to the client using the regular IP stack. Some clients, particularly those that @@ -1245,14 +1242,6 @@ dhcp_reply(struct lease *lease) to.sin_addr = raw.ciaddr; to.sin_port = client_port; - if (fallback_interface) { - result = send_packet(fallback_interface, &raw, - packet_length, raw.siaddr, &to, NULL); - free_lease_state(state, "dhcp_reply fallback 2"); - lease->state = NULL; - return; - } - /* If it comes from a client that already knows its address and is not requesting a broadcast response, and we can unicast to a client without using the ARP protocol, sent it diff --git a/usr.sbin/dhcpd/dhcpd.h b/usr.sbin/dhcpd/dhcpd.h index b1cf14672c5..c2f1c732236 100644 --- a/usr.sbin/dhcpd/dhcpd.h +++ b/usr.sbin/dhcpd/dhcpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: dhcpd.h,v 1.13 2004/05/04 21:25:27 deraadt Exp $ */ +/* $OpenBSD: dhcpd.h,v 1.14 2004/09/16 09:35:24 claudio Exp $ */ /* * Copyright (c) 1995, 1996, 1997, 1998, 1999 @@ -232,6 +232,7 @@ struct lease_state { struct in_addr giaddr; u_int8_t hops; u_int8_t offer; + struct hardware haddr; }; #define ROOT_GROUP 0 @@ -717,8 +718,7 @@ int can_receive_unicast_unconfigured(struct interface_info *); void maybe_setup_fallback(void); /* dispatch.c */ -extern struct interface_info *interfaces, - *dummy_interfaces, *fallback_interface; +extern struct interface_info *interfaces; extern struct protocol *protocols; extern int quiet_interface_discovery; extern void (*bootp_packet_handler)(struct interface_info *, diff --git a/usr.sbin/dhcpd/dispatch.c b/usr.sbin/dhcpd/dispatch.c index 643cf5ca0b8..ef0a0107c8e 100644 --- a/usr.sbin/dhcpd/dispatch.c +++ b/usr.sbin/dhcpd/dispatch.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dispatch.c,v 1.11 2004/09/15 22:12:50 deraadt Exp $ */ +/* $OpenBSD: dispatch.c,v 1.12 2004/09/16 09:35:24 claudio Exp $ */ /* * Copyright (c) 1995, 1996, 1997, 1998, 1999 @@ -48,7 +48,7 @@ /* Most boxes has less than 16 interfaces, so this might be a good guess. */ #define INITIAL_IFREQ_COUNT 16 -struct interface_info *interfaces, *dummy_interfaces, *fallback_interface; +struct interface_info *interfaces; struct protocol *protocols; struct timeout *timeouts; static struct timeout *free_timeouts; @@ -229,10 +229,6 @@ discover_interfaces(int state) else last->next = tmp->next; - /* Remember the interface in case we need to know - about it later. */ - tmp->next = dummy_interfaces; - dummy_interfaces = tmp; continue; } last = tmp; |