Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/external/bsd/dhcpcd/dist Import dhcpcd-5.2.0 with the follow...
details: https://anonhg.NetBSD.org/src/rev/bb991f321cfc
branches: trunk
changeset: 752482:bb991f321cfc
user: roy <roy%NetBSD.org@localhost>
date: Sat Feb 27 15:52:20 2010 +0000
description:
Import dhcpcd-5.2.0 with the following changes from dhcpcd-5.1.5:
* VendorID is now dhcpcd-$version:$OS-$version:$machine:$platform
* IPv4LL address range can now be used in DHCP requests
* sysctl net.ipv4.conf.$iface.promote_secondaries enabled on Linux
This resolves a long standing issue of changing ip on the same subnet.
* IPv4LL correctly resets the DHCP timer.
diffstat:
external/bsd/dhcpcd/dist/arp.c | 4 +-
external/bsd/dhcpcd/dist/bind.c | 2 +-
external/bsd/dhcpcd/dist/defs.h | 2 +-
external/bsd/dhcpcd/dist/dhcp.c | 18 +++++------
external/bsd/dhcpcd/dist/dhcp.h | 1 +
external/bsd/dhcpcd/dist/dhcpcd.c | 48 +++++++++++++++++---------------
external/bsd/dhcpcd/dist/if-bsd.c | 7 ++++
external/bsd/dhcpcd/dist/if-options.c | 19 ++++++++++--
external/bsd/dhcpcd/dist/if-options.h | 2 +-
external/bsd/dhcpcd/dist/if-pref.c | 6 ++--
external/bsd/dhcpcd/dist/ipv4ll.c | 43 ++++++++++++++++++++--------
external/bsd/dhcpcd/dist/net.c | 8 +++++
external/bsd/dhcpcd/dist/net.h | 2 +
external/bsd/dhcpcd/dist/platform-bsd.c | 44 ++++++++++++++++++++++++++++++
external/bsd/dhcpcd/dist/platform.h | 33 ++++++++++++++++++++++
15 files changed, 182 insertions(+), 57 deletions(-)
diffs (truncated from 521 to 300 lines):
diff -r 8cedbcc778c3 -r bb991f321cfc external/bsd/dhcpcd/dist/arp.c
--- a/external/bsd/dhcpcd/dist/arp.c Sat Feb 27 12:16:50 2010 +0000
+++ b/external/bsd/dhcpcd/dist/arp.c Sat Feb 27 15:52:20 2010 +0000
@@ -78,7 +78,7 @@
static void
handle_arp_failure(struct interface *iface)
{
- if (IN_LINKLOCAL(htonl(iface->state->fail.s_addr))) {
+ if (iface->state->offer->cookie != htonl(MAGIC_COOKIE)) {
handle_ipv4ll_failure(iface);
return;
}
@@ -216,7 +216,7 @@
add_timeout_sec(ANNOUNCE_WAIT, send_arp_announce, iface);
return;
}
- if (IN_LINKLOCAL(htonl(state->new->yiaddr))) {
+ if (state->new->cookie != htonl(MAGIC_COOKIE)) {
/* We should pretend to be at the end
* of the DHCP negotation cycle unless we rebooted */
if (state->interval != 0)
diff -r 8cedbcc778c3 -r bb991f321cfc external/bsd/dhcpcd/dist/bind.c
--- a/external/bsd/dhcpcd/dist/bind.c Sat Feb 27 12:16:50 2010 +0000
+++ b/external/bsd/dhcpcd/dist/bind.c Sat Feb 27 15:52:20 2010 +0000
@@ -143,7 +143,7 @@
lease->leasetime = ~0U;
lease->net.s_addr = ifo->req_mask.s_addr;
state->reason = "STATIC";
- } else if (IN_LINKLOCAL(htonl(state->new->yiaddr))) {
+ } else if (state->new->cookie != htonl(MAGIC_COOKIE)) {
syslog(LOG_INFO, "%s: using IPv4LL address %s",
iface->name, inet_ntoa(lease->addr));
lease->leasetime = ~0U;
diff -r 8cedbcc778c3 -r bb991f321cfc external/bsd/dhcpcd/dist/defs.h
--- a/external/bsd/dhcpcd/dist/defs.h Sat Feb 27 12:16:50 2010 +0000
+++ b/external/bsd/dhcpcd/dist/defs.h Sat Feb 27 15:52:20 2010 +0000
@@ -28,7 +28,7 @@
#define CONFIG_H
#define PACKAGE "dhcpcd"
-#define VERSION "5.1.5"
+#define VERSION "5.2.0"
#ifndef CONFIG
# define CONFIG SYSCONFDIR "/" PACKAGE ".conf"
diff -r 8cedbcc778c3 -r bb991f321cfc external/bsd/dhcpcd/dist/dhcp.c
--- a/external/bsd/dhcpcd/dist/dhcp.c Sat Feb 27 12:16:50 2010 +0000
+++ b/external/bsd/dhcpcd/dist/dhcp.c Sat Feb 27 15:52:20 2010 +0000
@@ -362,7 +362,7 @@
*len = bl;
if (bp) {
memcpy(bp, op, ol);
- return (const uint8_t *)&opt_buffer;
+ return (const uint8_t *)opt_buffer;
}
if (op)
return op;
@@ -843,19 +843,16 @@
m = (uint8_t *)dhcp;
p = dhcp->options;
- if ((type == DHCP_INFORM ||
- type == DHCP_RELEASE ||
- type == DHCP_REQUEST) &&
- !IN_LINKLOCAL(ntohl(iface->addr.s_addr)))
+ if ((type == DHCP_INFORM || type == DHCP_RELEASE ||
+ (type == DHCP_REQUEST &&
+ iface->net.s_addr == lease->net.s_addr &&
+ (iface->state->new == NULL ||
+ iface->state->new->cookie == htonl(MAGIC_COOKIE)))))
{
dhcp->ciaddr = iface->addr.s_addr;
/* In-case we haven't actually configured the address yet */
if (type == DHCP_INFORM && iface->addr.s_addr == 0)
dhcp->ciaddr = lease->addr.s_addr;
- /* Zero the address if we're currently on a different subnet */
- if (type == DHCP_REQUEST &&
- iface->net.s_addr != lease->net.s_addr)
- dhcp->ciaddr = 0;
}
dhcp->op = DHCP_BOOTREQUEST;
@@ -893,7 +890,7 @@
p += iface->clientid[0] + 1;
}
- if (lease->addr.s_addr && !IN_LINKLOCAL(htonl(lease->addr.s_addr))) {
+ if (lease->addr.s_addr && lease->cookie == htonl(MAGIC_COOKIE)) {
if (type == DHCP_DECLINE ||
type == DHCP_DISCOVER ||
(type == DHCP_REQUEST &&
@@ -1374,6 +1371,7 @@
{
struct timeval now;
+ lease->cookie = dhcp->cookie;
/* BOOTP does not set yiaddr for replies when ciaddr is set. */
if (dhcp->yiaddr)
lease->addr.s_addr = dhcp->yiaddr;
diff -r 8cedbcc778c3 -r bb991f321cfc external/bsd/dhcpcd/dist/dhcp.h
--- a/external/bsd/dhcpcd/dist/dhcp.h Sat Feb 27 12:16:50 2010 +0000
+++ b/external/bsd/dhcpcd/dist/dhcp.h Sat Feb 27 15:52:20 2010 +0000
@@ -165,6 +165,7 @@
time_t leasedfrom;
struct timeval boundtime;
uint8_t frominfo;
+ uint32_t cookie;
};
#include "dhcpcd.h"
diff -r 8cedbcc778c3 -r bb991f321cfc external/bsd/dhcpcd/dist/dhcpcd.c
--- a/external/bsd/dhcpcd/dist/dhcpcd.c Sat Feb 27 12:16:50 2010 +0000
+++ b/external/bsd/dhcpcd/dist/dhcpcd.c Sat Feb 27 15:52:20 2010 +0000
@@ -231,6 +231,7 @@
iface->raw_fd = -1;
}
if (iface->udp_fd != -1) {
+ /* we don't listen to events on the udp */
close(iface->udp_fd);
iface->udp_fd = -1;
}
@@ -540,6 +541,7 @@
{
lease->frominfo = 0;
lease->addr.s_addr = dhcp->yiaddr;
+ lease->cookie = dhcp->cookie;
if (type == 0 ||
get_option_addr(&lease->server, dhcp, DHO_SERVERID) != 0)
lease->server.s_addr = INADDR_ANY;
@@ -710,17 +712,20 @@
static void
open_sockets(struct interface *iface)
{
- if (iface->udp_fd != -1)
- close(iface->udp_fd);
- if (open_udp_socket(iface) == -1 &&
- (errno != EADDRINUSE || iface->addr.s_addr != 0))
- syslog(LOG_ERR, "%s: open_udp_socket: %m", iface->name);
- if (iface->raw_fd != -1)
- delete_event(iface->raw_fd);
- if (open_socket(iface, ETHERTYPE_IP) == -1)
- syslog(LOG_ERR, "%s: open_socket: %m", iface->name);
- if (iface->raw_fd != -1)
- add_event(iface->raw_fd, handle_dhcp_packet, iface);
+ if (iface->raw_fd == -1) {
+ if (open_socket(iface, ETHERTYPE_IP) == -1)
+ syslog(LOG_ERR, "%s: open_socket: %m", iface->name);
+ else
+ add_event(iface->raw_fd, handle_dhcp_packet, iface);
+ }
+ if (iface->udp_fd == -1 &&
+ iface->addr.s_addr != 0 &&
+ iface->state->new != NULL &&
+ iface->state->new->cookie == htonl(MAGIC_COOKIE))
+ {
+ if (open_udp_socket(iface) == -1 && errno != EADDRINUSE)
+ syslog(LOG_ERR, "%s: open_udp_socket: %m", iface->name);
+ }
}
static void
@@ -728,8 +733,8 @@
{
struct timespec ts;
- if (iface->state->lease.addr.s_addr &&
- !IN_LINKLOCAL(htonl(iface->state->lease.addr.s_addr)))
+ if (iface->state->new != NULL &&
+ iface->state->new->cookie == htonl(MAGIC_COOKIE))
{
syslog(LOG_INFO, "%s: releasing lease of %s",
iface->name, inet_ntoa(iface->state->lease.addr));
@@ -1064,21 +1069,20 @@
start_static(iface);
return;
}
- if (ifo->reboot == 0) {
+ if (ifo->reboot == 0 || iface->state->offer == NULL) {
start_discover(iface);
return;
}
- if (IN_LINKLOCAL(htonl(iface->state->lease.addr.s_addr))) {
+ if (ifo->options & DHCPCD_INFORM) {
+ syslog(LOG_INFO, "%s: informing address of %s",
+ iface->name, inet_ntoa(iface->state->lease.addr));
+ } else if (iface->state->offer->cookie == 0) {
if (ifo->options & DHCPCD_IPV4LL) {
iface->state->claims = 0;
send_arp_announce(iface);
} else
start_discover(iface);
return;
- }
- if (ifo->options & DHCPCD_INFORM) {
- syslog(LOG_INFO, "%s: informing address of %s",
- iface->name, inet_ntoa(iface->state->lease.addr));
} else {
syslog(LOG_INFO, "%s: rebinding lease of %s",
iface->name, inet_ntoa(iface->state->lease.addr));
@@ -1161,7 +1165,7 @@
if (iface->state->offer) {
get_lease(&iface->state->lease, iface->state->offer);
iface->state->lease.frominfo = 1;
- if (IN_LINKLOCAL(htonl(iface->state->offer->yiaddr))) {
+ if (iface->state->offer->cookie == 0) {
if (iface->state->offer->yiaddr ==
iface->addr.s_addr)
{
@@ -1189,9 +1193,9 @@
}
}
}
- if (!iface->state->offer)
+ if (iface->state->offer == NULL)
start_discover(iface);
- else if (IN_LINKLOCAL(htonl(iface->state->lease.addr.s_addr)) &&
+ else if (iface->state->offer->cookie == 0 &&
iface->state->options->options & DHCPCD_IPV4LL)
start_ipv4ll(iface);
else
diff -r 8cedbcc778c3 -r bb991f321cfc external/bsd/dhcpcd/dist/if-bsd.c
--- a/external/bsd/dhcpcd/dist/if-bsd.c Sat Feb 27 12:16:50 2010 +0000
+++ b/external/bsd/dhcpcd/dist/if-bsd.c Sat Feb 27 15:52:20 2010 +0000
@@ -73,6 +73,13 @@
static int r_fd = -1;
int
+if_init(_unused struct interface *iface)
+{
+ /* BSD promotes secondary address by default */
+ return 0;
+}
+
+int
init_sockets(void)
{
if ((socket_afnet = socket(AF_INET, SOCK_DGRAM, 0)) == -1)
diff -r 8cedbcc778c3 -r bb991f321cfc external/bsd/dhcpcd/dist/if-options.c
--- a/external/bsd/dhcpcd/dist/if-options.c Sat Feb 27 12:16:50 2010 +0000
+++ b/external/bsd/dhcpcd/dist/if-options.c Sat Feb 27 15:52:20 2010 +0000
@@ -26,6 +26,7 @@
*/
#include <sys/types.h>
+#include <sys/utsname.h>
#include <arpa/inet.h>
@@ -44,6 +45,7 @@
#include "common.h"
#include "if-options.h"
#include "net.h"
+#include "platform.h"
/* These options only make sense in the config file, so don't use any
valid short options for them */
@@ -771,8 +773,9 @@
{
struct if_options *ifo;
FILE *f;
- char *line, *option, *p;
+ char *line, *option, *p, *platform;
int skip = 0, have_profile = 0;
+ struct utsname utn;
/* Seed our default options */
ifo = xzalloc(sizeof(*ifo));
@@ -788,9 +791,17 @@
if (strcmp(ifo->hostname, "(none)") == 0 ||
strcmp(ifo->hostname, "localhost") == 0)
ifo->hostname[0] = '\0';
- ifo->vendorclassid[0] = snprintf((char *)ifo->vendorclassid + 1,
- VENDORCLASSID_MAX_LEN,
- "%s %s", PACKAGE, VERSION);
+
+ platform = hardware_platform();
+ if (uname(&utn) == 0)
+ ifo->vendorclassid[0] = snprintf((char *)ifo->vendorclassid + 1,
+ VENDORCLASSID_MAX_LEN,
+ "%s-%s:%s-%s:%s%s%s", PACKAGE, VERSION,
+ utn.sysname, utn.release, utn.machine,
+ platform ? ":" : "", platform);
+ else
+ ifo->vendorclassid[0] = snprintf((char *)ifo->vendorclassid + 1,
+ VENDORCLASSID_MAX_LEN, "%s-%s", PACKAGE, VERSION);
/* Parse our options file */
f = fopen(file ? file : CONFIG, "r");
diff -r 8cedbcc778c3 -r bb991f321cfc external/bsd/dhcpcd/dist/if-options.h
--- a/external/bsd/dhcpcd/dist/if-options.h Sat Feb 27 12:16:50 2010 +0000
+++ b/external/bsd/dhcpcd/dist/if-options.h Sat Feb 27 15:52:20 2010 +0000
@@ -43,7 +43,7 @@
#define DEFAULT_REBOOT 10
#define HOSTNAME_MAX_LEN 250 /* 255 - 3 (FQDN) - 2 (DNS enc) */
-#define VENDORCLASSID_MAX_LEN 48
+#define VENDORCLASSID_MAX_LEN 255
#define CLIENTID_MAX_LEN 48
#define USERCLASS_MAX_LEN 255
#define VENDOR_MAX_LEN 255
Home |
Main Index |
Thread Index |
Old Index