Date: Wed, 2 Nov 2005 16:12:39 -0800 From: Brooks Davis <brooks@one-eyed-alien.net> To: hackers@freebsd.org Subject: fix for dhclient+aliases Message-ID: <20051103001239.GA19590@odin.ac.hmc.edu>
next in thread | raw e-mail | index | archive | help
--KsGdsel6WgEHnImy Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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@freebsd.org> ----- From: Brooks Davis <brooks@freebsd.org> Date: Wed, 2 Nov 2005 23:54:08 GMT To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 86258 for review http://perforce.freebsd.org/chv.cgi?CH=3D86258 Change 86258 by brooks@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 ... =2E. //depot/user/brooks/cleanup/sbin/dhclient/dhclient.8#6 edit =2E. //depot/user/brooks/cleanup/sbin/dhclient/dhclient.c#8 edit Differences ... =3D=3D=3D=3D //depot/user/brooks/cleanup/sbin/dhclient/dhclient.8#6 (text+k= o) =3D=3D=3D=3D @@ -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 =3D=3D=3D=3D //depot/user/brooks/cleanup/sbin/dhclient/dhclient.c#8 (text+k= o) =3D=3D=3D=3D @@ -103,6 +103,7 @@ =20 #define TIME_MAX 2147483647 =20 +int allow_aliases; int log_priority; int no_daemon; int unknown_ok =3D 1; @@ -203,6 +204,8 @@ ifam =3D (struct ifa_msghdr *)rtm; if (ifam->ifam_index !=3D ifi->index) break; + if (allow_aliases) + break; if (findproto((char *)(ifam + 1), ifam->ifam_addrs) !=3D AF_INET) break; if (ifi =3D=3D NULL) @@ -227,12 +230,30 @@ goto die; case RTM_DELADDR: ifam =3D (struct ifa_msghdr *)rtm; + if (ifam->ifam_index !=3D ifi->index) break; if (findproto((char *)(ifam + 1), ifam->ifam_addrs) !=3D AF_INET) break; if (scripttime =3D=3D 0 || t < scripttime + 10) break; + + sa =3D get_ifa((char *)(ifam + 1), ifam->ifam_addrs); + if (sa =3D=3D NULL) + goto die; + + if ((a.len =3D 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 =3D ifi->client->active; l !=3D NULL; l =3D l->next) + if (addr_eq(a, l->address)) + break; + + if (l =3D=3D NULL) /* deleted addr is not the one we set */ + break; goto die; case RTM_IFINFO: ifm =3D (struct if_msghdr *)rtm; @@ -301,8 +322,11 @@ openlog(__progname, LOG_PID | LOG_NDELAY, DHCPD_LOG_FACILITY); setlogmask(LOG_UPTO(LOG_INFO)); =20 - while ((ch =3D getopt(argc, argv, "bc:dl:nqu")) !=3D -1) + while ((ch =3D getopt(argc, argv, "abc:dl:nqu")) !=3D -1) switch (ch) { + case 'a': + allow_aliases =3D 1; + break; case 'b': immediate_daemon =3D 1; break; ----- End forwarded message ----- --=20 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 --KsGdsel6WgEHnImy Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (GNU/Linux) iD8DBQFDaVX2XY6L6fI4GtQRAmwqAKCIvL4e6emYzb04RyoapnRa7Y3eHwCgvGVu EpcR+dglWQMBvYE2QFBF3D4= =yzbw -----END PGP SIGNATURE----- --KsGdsel6WgEHnImy--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20051103001239.GA19590>