Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 187753 | Differences between
and this patch

Collapse All | Expand All

(-)arp.c (-13 / +36 lines)
Lines 105-110 Link Here
105
	int nprobes = 0;
105
	int nprobes = 0;
106
	int nclaims = 0;
106
	int nclaims = 0;
107
	struct in_addr null_address;
107
	struct in_addr null_address;
108
	struct timeval stopat;
109
	struct timeval now;
108
110
109
	if (! iface->arpable) {
111
	if (! iface->arpable) {
110
		logger (LOG_DEBUG, "interface `%s' is not ARPable", iface->name);
112
		logger (LOG_DEBUG, "interface `%s' is not ARPable", iface->name);
Lines 130-149 Link Here
130
		int buflen = sizeof (char *) * iface->buffer_length;
132
		int buflen = sizeof (char *) * iface->buffer_length;
131
		fd_set rset;
133
		fd_set rset;
132
		int bytes;
134
		int bytes;
133
		int s;
135
		int s = 0;
134
136
135
		tv.tv_sec = 0; 
137
		/* Only select if we have a timeout */
136
		tv.tv_usec = timeout;
138
		if (timeout > 0) {
139
			tv.tv_sec = 0; 
140
			tv.tv_usec = timeout;
137
141
138
		FD_ZERO (&rset);
142
			FD_ZERO (&rset);
139
		FD_SET (iface->fd, &rset);
143
			FD_SET (iface->fd, &rset);
140
		errno = 0;
144
141
		if ((s = select (FD_SETSIZE, &rset, NULL, NULL, &tv)) == -1) {
145
			errno = 0;
142
			if (errno != EINTR)
146
			if ((s = select (FD_SETSIZE, &rset, NULL, NULL, &tv)) == -1) {
143
				logger (LOG_ERR, "select: `%s'", strerror (errno));
147
				if (errno != EINTR)
144
			break;
148
					logger (LOG_ERR, "select: `%s'", strerror (errno));
145
		} else if (s == 0) {
149
				break;
146
			/* Timed out */
150
			}
151
		}
152
153
		/* Timed out */
154
		if (s == 0) {
147
			if (nprobes < NPROBES) {
155
			if (nprobes < NPROBES) {
148
				nprobes ++;
156
				nprobes ++;
149
				timeout = PROBE_INTERVAL;
157
				timeout = PROBE_INTERVAL;
Lines 159-166 Link Here
159
				retval = 0;
167
				retval = 0;
160
				break;
168
				break;
161
			}
169
			}
170
171
			/* Setup our stop time */
172
			if (get_time (&stopat) != 0)
173
				break;
174
			stopat.tv_usec += timeout;
175
176
			continue;
162
		}
177
		}
163
		
178
179
		/* We maybe ARP flooded, so check our time */
180
		if (get_time (&now) != 0)
181
			break;
182
		if (timercmp (&now, &stopat, >)) {
183
			timeout = 0;
184
			continue;
185
		}
186
164
		if (! FD_ISSET (iface->fd, &rset))
187
		if (! FD_ISSET (iface->fd, &rset))
165
			continue;
188
			continue;
166
189
(-)Makefile (-5 / +9 lines)
Lines 1-4 Link Here
1
VERSION = 3.1.3
1
VERSION = 3.1.4_pre2
2
CFLAGS ?= -O2 -pipe
2
CFLAGS ?= -O2 -pipe
3
3
4
# Should work for both GNU make and BSD make
4
# Should work for both GNU make and BSD make
Lines 49-60 Link Here
49
dhcpcd_OBJS = arp.o client.o common.o configure.o dhcp.o dhcpcd.o duid.o \
49
dhcpcd_OBJS = arp.o client.o common.o configure.o dhcp.o dhcpcd.o duid.o \
50
		info.o interface.o ipv4ll.o logger.o signals.o socket.o
50
		info.o interface.o ipv4ll.o logger.o signals.o socket.o
51
51
52
# By default we don't need to link to anything
52
# These are nasty hacks to work out what libs we need to link to
53
# Except on Darwin where we need -lresolv, so they need to uncomment this
53
# We require librt for glibc bases systems
54
#dhcpcd_LIBS = -lresolv
54
LIBRT != ldd /bin/date 2>/dev/null | grep -q /librt.so && echo "-lrt" || exit 0
55
LIBRT ?= $(shell ldd /bin/date 2>/dev/null | grep -q /librt.so && echo "-lrt")
55
56
57
# Darwin needs this, but we have no way of detecting this atm
58
#LIBRESOLV = -lresolv
59
56
dhcpcd: $(dhcpcd_H) $(dhcpcd_OBJS)
60
dhcpcd: $(dhcpcd_H) $(dhcpcd_OBJS)
57
	$(CC) $(LDFLAGS) $(dhcpcd_OBJS) $(dhcpcd_LIBS) -o dhcpcd
61
	$(CC) $(LDFLAGS) $(dhcpcd_OBJS) $(LIBRT) $(LIBRESOLV) -o dhcpcd
58
62
59
version.h:
63
version.h:
60
	echo '#define VERSION "$(VERSION)"' > version.h
64
	echo '#define VERSION "$(VERSION)"' > version.h
(-)common.c (-8 / +13 lines)
Lines 76-92 Link Here
76
#  endif
76
#  endif
77
#endif
77
#endif
78
78
79
/* This requires us to link to rt on glibc, so we use sysinfo instead */
79
/* Handy function to get the time. */
80
#ifdef __linux__
80
int get_time(struct timeval *tp)
81
#include <sys/sysinfo.h>
82
long uptime (void)
83
{
81
{
84
	struct sysinfo info;
82
	struct timespec ts;
85
83
86
	sysinfo (&info);
84
	if (clock_gettime (CLOCK_MONOTONIC, &ts) == -1) {
87
	return info.uptime;
85
		logger (LOG_ERR, "clock_gettime: %s", strerror (errno));
86
		return (-1);
87
	}
88
89
	tp->tv_sec = ts.tv_sec;
90
	tp->tv_usec = ts.tv_nsec / 1000;
91
	return (0);
88
}
92
}
89
#elif __APPLE__
93
94
#ifdef __APPLE__
90
/* Darwin doesn't appear to have an uptime, so try and make one ourselves */
95
/* Darwin doesn't appear to have an uptime, so try and make one ourselves */
91
long uptime (void)
96
long uptime (void)
92
{
97
{
(-)common.h (+2 lines)
Lines 23-28 Link Here
23
#define COMMON_H
23
#define COMMON_H
24
24
25
/* string.h pulls in features.h so the below define checks work */
25
/* string.h pulls in features.h so the below define checks work */
26
#include <sys/time.h>
26
#include <string.h>
27
#include <string.h>
27
28
28
/* Only GLIBC doesn't support strlcpy */
29
/* Only GLIBC doesn't support strlcpy */
Lines 36-41 Link Here
36
void srandomdev (void);
37
void srandomdev (void);
37
#endif
38
#endif
38
39
40
int get_time(struct timeval *tp);
39
long uptime (void);
41
long uptime (void);
40
void *xmalloc (size_t size);
42
void *xmalloc (size_t size);
41
char *xstrdup (const char *str);
43
char *xstrdup (const char *str);

Return to bug 187753