Skip to content

Commit

Permalink
dhclient always uses bpf on openbsd no matter what, it works, and we …
Browse files Browse the repository at this point in the history
…don't

need to fallback to their raw socket code
suddenly dhclient is so fast...
pb tested and sez ok
  • Loading branch information
henning committed Feb 23, 2004
1 parent e032411 commit 306326d
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 298 deletions.
4 changes: 2 additions & 2 deletions sbin/dhclient/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# $OpenBSD: Makefile,v 1.3 2004/02/04 12:16:56 henning Exp $
# $OpenBSD: Makefile,v 1.4 2004/02/23 18:21:15 henning Exp $
#
# Copyright (c) 1996, 1997 The Internet Software Consortium.
# All rights reserved.
Expand Down Expand Up @@ -34,7 +34,7 @@

SRCS= dhclient.c clparse.c \
alloc.c dispatch.c hash.c memory.c print.c bpf.c icmp.c options.c \
tree.c conflex.c errwarn.c inet.c packet.c socket.c convert.c \
tree.c conflex.c errwarn.c inet.c packet.c convert.c \
ethernet.c tables.c parse.c

PROG= dhclient
Expand Down
19 changes: 1 addition & 18 deletions sbin/dhclient/bpf.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $OpenBSD: bpf.c,v 1.5 2004/02/07 17:59:22 henning Exp $ */
/* $OpenBSD: bpf.c,v 1.6 2004/02/23 18:21:15 henning Exp $ */

/* BPF socket interface code, originally contributed by Archie Cobbs. */

Expand Down Expand Up @@ -223,10 +223,6 @@ send_packet(struct interface_info *interface, struct packet *packet,
struct iovec iov[2];
int result;

if (!strcmp(interface->name, "fallback"))
return (send_fallback(interface, packet, raw,
len, from, to, hto));

/* Assemble the headers... */
assemble_hw_header(interface, buf, &bufp, hto);
assemble_udp_ip_header(interface, buf, &bufp, from.s_addr,
Expand Down Expand Up @@ -369,16 +365,3 @@ can_receive_unicast_unconfigured(struct interface_info *ip)
{
return (1);
}

void
maybe_setup_fallback(void)
{
struct interface_info *fbi;

fbi = setup_fallback();
if (fbi) {
if_register_fallback(fbi);
add_protocol("fallback", fallback_interface->wfdesc,
fallback_discard, fallback_interface);
}
}
58 changes: 1 addition & 57 deletions sbin/dhclient/dhcpd.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $OpenBSD: dhcpd.h,v 1.5 2004/02/10 13:12:48 henning Exp $ */
/* $OpenBSD: dhcpd.h,v 1.6 2004/02/23 18:21:15 henning Exp $ */

/* Definitions for dhcpd... */

Expand Down Expand Up @@ -612,76 +612,20 @@ void dump_raw(unsigned char *, int);
void dump_packet(struct packet *);
void hash_dump(struct hash_table *);

/* socket.c */
#if defined(USE_SOCKET_SEND) || defined(USE_SOCKET_RECEIVE) \
|| defined(USE_SOCKET_FALLBACK)
int if_register_socket(struct interface_info *);
#endif

#if defined(USE_SOCKET_FALLBACK) && !defined(USE_SOCKET_SEND)
void if_reinitialize_fallback(struct interface_info *);
void if_register_fallback(struct interface_info *);
ssize_t send_fallback(struct interface_info *,
struct packet *, struct dhcp_packet *, size_t, struct in_addr,
struct sockaddr_in *, struct hardware *);
#endif

#ifdef USE_SOCKET_SEND
void if_reinitialize_send(struct interface_info *);
void if_register_send(struct interface_info *);
ssize_t send_packet(struct interface_info *,
struct packet *, struct dhcp_packet *, size_t, struct in_addr,
struct sockaddr_in *, struct hardware *);
#endif
#ifdef USE_SOCKET_FALLBACK
void fallback_discard(struct protocol *);
#endif
#ifdef USE_SOCKET_RECEIVE
void if_reinitialize_receive(struct interface_info *);
void if_register_receive(struct interface_info *);
ssize_t receive_packet(struct interface_info *, unsigned char *, size_t,
struct sockaddr_in *, struct hardware *);
#endif
#ifdef USE_SOCKET_SEND
int can_unicast_without_arp(void);
int can_receive_unicast_unconfigured(struct interface_info *);
void maybe_setup_fallback(void);
#endif

/* bpf.c */
#if defined(USE_BPF_SEND) || defined(USE_BPF_RECEIVE)
int if_register_bpf(struct interface_info *);
#endif
#ifdef USE_BPF_SEND
void if_reinitialize_send(struct interface_info *);
void if_register_send(struct interface_info *);
ssize_t send_packet(struct interface_info *,
struct packet *, struct dhcp_packet *, size_t, struct in_addr,
struct sockaddr_in *, struct hardware *);
#endif
#ifdef USE_BPF_RECEIVE
void if_reinitialize_receive(struct interface_info *);
void if_register_receive(struct interface_info *);
ssize_t receive_packet(struct interface_info *, unsigned char *, size_t,
struct sockaddr_in *, struct hardware *);
#endif
#ifdef USE_BPF_SEND
int can_unicast_without_arp(void);
int can_receive_unicast_unconfigured(struct interface_info *);
void maybe_setup_fallback(void);
#endif

/* raw.c */
#ifdef USE_RAW_SEND
void if_reinitialize_send(struct interface_info *);
void if_register_send(struct interface_info *);
ssize_t send_packet(struct interface_info *,
struct packet *, struct dhcp_packet *, size_t, struct in_addr,
struct sockaddr_in *, struct hardware *);
int can_unicast_without_arp(void);
int can_receive_unicast_unconfigured(struct interface_info *);
void maybe_setup_fallback(void);
#endif

/* dispatch.c */
extern struct interface_info *interfaces,
Expand Down
4 changes: 1 addition & 3 deletions sbin/dhclient/dispatch.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $OpenBSD: dispatch.c,v 1.7 2004/02/10 13:12:48 henning Exp $ */
/* $OpenBSD: dispatch.c,v 1.8 2004/02/23 18:21:15 henning Exp $ */

/* Network input dispatcher... */

Expand Down Expand Up @@ -288,8 +288,6 @@ discover_interfaces(int state)
add_protocol(tmp->name, tmp->rfdesc, got_one, tmp);

freeifaddrs(ifap);

maybe_setup_fallback();
}

struct interface_info *
Expand Down
77 changes: 3 additions & 74 deletions sbin/dhclient/osdep.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $OpenBSD: osdep.h,v 1.6 2004/02/08 22:34:19 naddy Exp $ */
/* $OpenBSD: osdep.h,v 1.7 2004/02/23 18:21:15 henning Exp $ */

/* Operating system dependencies... */

Expand Down Expand Up @@ -36,18 +36,6 @@
* under a contract with Vixie Laboratories.
*/

#if !defined (USE_SOCKETS) && \
!defined (USE_SOCKET_SEND) && \
!defined (USE_SOCKET_RECEIVE) && \
!defined (USE_RAW_SOCKETS) && \
!defined (USE_RAW_SEND) && \
!defined (USE_SOCKET_RECEIVE) && \
!defined (USE_BPF) && \
!defined (USE_BPF_SEND) && \
!defined (USE_BPF_RECEIVE)
# define USE_DEFAULT_NETWORK
#endif

#include <syslog.h>
#include <sys/types.h>
#include <string.h>
Expand Down Expand Up @@ -84,8 +72,6 @@ extern int h_errno;
#define HAVE_SA_LEN
#define HAVE_MKSTEMP

#define USE_BPF

#if defined(__alpha__) || (defined(__sparc64__) && defined(__arch64__))
#define PTRSIZE_64BIT
#endif
Expand All @@ -94,65 +80,8 @@ extern int h_errno;
# define TIME_MAX 2147483647
#endif

/* Porting::
If you add a new network API, and have it set up so that it can be
used for sending or receiving, but doesn't have to be used for both,
then set up an ifdef like the ones below: */

#ifdef USE_SOCKETS
# define USE_SOCKET_SEND
# define USE_SOCKET_RECEIVE
#endif

#ifdef USE_RAW_SOCKETS
# define USE_RAW_SEND
# define USE_SOCKET_RECEIVE
#endif

#ifdef USE_BPF
# define USE_BPF_SEND
# define USE_BPF_RECEIVE
#endif

/* Porting::
If you add support for sending packets directly out an interface,
and your support does not do ARP or routing, you must use a fallback
mechanism to deal with packets that need to be sent to routers.
Currently, all low-level packet interfaces use BSD sockets as a
fallback. */

#if defined(USE_BPF_SEND) || defined(USE_NIT_SEND) || \
defined(USE_DLPI_SEND) || defined(USE_UPF_SEND) || defined(USE_LPF_SEND)
# define USE_SOCKET_FALLBACK
# define USE_FALLBACK
#endif

/* Porting::
If you add support for sending packets directly out an interface
and need to be able to assemble packets, add the USE_XXX_SEND
definition for your interface to the list tested below. */

#if defined(USE_RAW_SEND) || defined(USE_BPF_SEND) || \
defined(USE_NIT_SEND) || defined(USE_UPF_SEND) || \
defined(USE_DLPI_SEND) || defined(USE_LPF_SEND)
# define PACKET_ASSEMBLY
#endif

/* Porting::
If you add support for receiving packets directly from an interface
and need to be able to decode raw packets, add the USE_XXX_RECEIVE
definition for your interface to the list tested below. */

#if defined(USE_RAW_RECEIVE) || defined(USE_BPF_SEND) || \
defined(USE_NIT_RECEIVE) || defined(USE_UPF_RECEIVE) || \
defined(USE_DLPI_RECEIVE) || defined(USE_LPF_SEND) || \
(defined(USE_SOCKET_SEND) && defined(SO_BINDTODEVICE))
# define PACKET_DECODING
#endif
#define PACKET_ASSEMBLY
#define PACKET_DECODING

/* jmp_buf is assumed to be a struct unless otherwise defined in the
system header. */
Expand Down
144 changes: 0 additions & 144 deletions sbin/dhclient/socket.c

This file was deleted.

0 comments on commit 306326d

Please sign in to comment.