fix for dhclient+aliases
Brooks Davis
brooks at one-eyed-alien.net
Wed Nov 2 16:12:42 PST 2005
I've got a proposed fix for dhclient interactions with IPv4 aliases. It
turns out that my speculation that it was driver issues was wrong and
that dhclient with reacting to the aliases themselves. I suspect there
may be issues with some drivers, but that's not the main problem.
This patch adds a flag which causes dhclient to ignore address changes
that it didn't cause. Does this seem like an acceptable solution? I'd
probably add an rc.conf variable similar to background_dhclient.
-- Brooks
----- Forwarded message from Brooks Davis <brooks at freebsd.org> -----
From: Brooks Davis <brooks at freebsd.org>
Date: Wed, 2 Nov 2005 23:54:08 GMT
To: Perforce Change Reviews <perforce at freebsd.org>
Subject: PERFORCE change 86258 for review
http://perforce.freebsd.org/chv.cgi?CH=86258
Change 86258 by brooks at brooks_pagefault on 2005/11/02 23:53:14
Add a -a option to allow IPv4 aliases to be set on an interface.
Affected files ...
.. //depot/user/brooks/cleanup/sbin/dhclient/dhclient.8#6 edit
.. //depot/user/brooks/cleanup/sbin/dhclient/dhclient.c#8 edit
Differences ...
==== //depot/user/brooks/cleanup/sbin/dhclient/dhclient.8#6 (text+ko) ====
@@ -46,7 +46,7 @@
.Nd "Dynamic Host Configuration Protocol (DHCP) client"
.Sh SYNOPSIS
.Nm
-.Op Fl dqu
+.Op Fl abdqu
.Op Fl c Ar file
.Op Fl l Ar file
.Ar interface
@@ -63,6 +63,11 @@
.Pp
The options are as follows:
.Bl -tag -width ".Fl c Ar file"
+.It Fl a
+Allows IPv4 aliases to be added to the interface.
+Normally,
+.Nm
+exits if IPv4 addresses are added to or deleted from the interface.
.It Fl b
Forces
.Nm
==== //depot/user/brooks/cleanup/sbin/dhclient/dhclient.c#8 (text+ko) ====
@@ -103,6 +103,7 @@
#define TIME_MAX 2147483647
+int allow_aliases;
int log_priority;
int no_daemon;
int unknown_ok = 1;
@@ -203,6 +204,8 @@
ifam = (struct ifa_msghdr *)rtm;
if (ifam->ifam_index != ifi->index)
break;
+ if (allow_aliases)
+ break;
if (findproto((char *)(ifam + 1), ifam->ifam_addrs) != AF_INET)
break;
if (ifi == NULL)
@@ -227,12 +230,30 @@
goto die;
case RTM_DELADDR:
ifam = (struct ifa_msghdr *)rtm;
+
if (ifam->ifam_index != ifi->index)
break;
if (findproto((char *)(ifam + 1), ifam->ifam_addrs) != AF_INET)
break;
if (scripttime == 0 || t < scripttime + 10)
break;
+
+ sa = get_ifa((char *)(ifam + 1), ifam->ifam_addrs);
+ if (sa == NULL)
+ goto die;
+
+ if ((a.len = sizeof(struct in_addr)) > sizeof(a.iabuf))
+ error("king bula sez: len mismatch");
+ memcpy(a.iabuf, &((struct sockaddr_in *)sa)->sin_addr, a.len);
+ if (addr_eq(a, defaddr))
+ break;
+
+ for (l = ifi->client->active; l != NULL; l = l->next)
+ if (addr_eq(a, l->address))
+ break;
+
+ if (l == NULL) /* deleted addr is not the one we set */
+ break;
goto die;
case RTM_IFINFO:
ifm = (struct if_msghdr *)rtm;
@@ -301,8 +322,11 @@
openlog(__progname, LOG_PID | LOG_NDELAY, DHCPD_LOG_FACILITY);
setlogmask(LOG_UPTO(LOG_INFO));
- while ((ch = getopt(argc, argv, "bc:dl:nqu")) != -1)
+ while ((ch = getopt(argc, argv, "abc:dl:nqu")) != -1)
switch (ch) {
+ case 'a':
+ allow_aliases = 1;
+ break;
case 'b':
immediate_daemon = 1;
break;
----- End forwarded message -----
--
Any statement of the form "X is the one, true Y" is FALSE.
PGP fingerprint 655D 519C 26A7 82E7 2529 9BF0 5D8E 8BE9 F238 1AD4
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-hackers/attachments/20051102/1a929429/attachment.bin
More information about the freebsd-hackers
mailing list