rpms/dhcp/devel dhcp-3.0.2-mobile_duplicate_lease_detection.patch, NONE, 1.1
fedora-cvs-commits at redhat.com
fedora-cvs-commits at redhat.com
Fri Jun 17 18:32:20 UTC 2005
Author: jvdias
Update of /cvs/dist/rpms/dhcp/devel
In directory cvs.devel.redhat.com:/tmp/cvs-serv4052
Added Files:
dhcp-3.0.2-mobile_duplicate_lease_detection.patch
Log Message:
not currently used: patch to provide dhclient -m option and mobile-duplicate-lease-detection dhclient.conf option to DECLINE REQUESTed lease ACK-ed by server with different ethernet address to server that OFFERed lease
dhcp-3.0.2-mobile_duplicate_lease_detection.patch:
client/clparse.c | 28 ++++++++++++++++++++++++++--
client/dhclient.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++------
common/conflex.c | 4 ++++
includes/dhcpd.h | 7 +++++++
includes/dhctoken.h | 4 +++-
5 files changed, 86 insertions(+), 9 deletions(-)
--- NEW FILE dhcp-3.0.2-mobile_duplicate_lease_detection.patch ---
--- dhcp-3.0.2/common/conflex.c.dhclient_mobile_duplicate_lease 2004-11-24 12:39:15.000000000 -0500
+++ dhcp-3.0.2/common/conflex.c 2005-06-10 20:43:19.000000000 -0400
@@ -803,6 +803,8 @@
return MY;
if (!strcasecmp (atom + 1, "clt"))
return MCLT;
+ if (!strcasecmp (atom + 1, "obile-duplicate-lease-detection"))
+ return MOBILE_DUPLICATE_LEASE_DETECTION;
break;
case 'n':
if (!strcasecmp (atom + 1, "ormal"))
@@ -964,6 +966,8 @@
return SERVER_NAME;
if (!strcasecmp (atom + 1, "erver-identifier"))
return SERVER_IDENTIFIER;
+ if (!strcasecmp (atom + 1, "erver-hardware-address"))
+ return SERVER_HARDWARE_ADDRESS;
if (!strcasecmp (atom + 1, "erver"))
return SERVER;
if (!strcasecmp (atom + 1, "elect-timeout"))
--- dhcp-3.0.2/client/dhclient.c.dhclient_mobile_duplicate_lease 2005-06-10 20:43:19.000000000 -0400
+++ dhcp-3.0.2/client/dhclient.c 2005-06-10 20:53:23.000000000 -0400
@@ -77,6 +77,8 @@
#ifdef EXTENDED_NEW_OPTION_INFO
int extended_option_environment = 0;
#endif
+int mobile_duplicate_lease_detection = 0;
+
static void usage PROTO ((void));
void do_release(struct client_state *);
@@ -215,7 +217,9 @@
extended_option_environment = 1;
new_option_info_tree = GENERATE_NEW_OPTION_INFO;
#endif
- } else if (argv [i][0] == '-') {
+ } else if (!strcmp (argv[i], "-m")) {
+ mobile_duplicate_lease_detection = 1;
+ } else if (argv [i][0] == '-') {
usage ();
} else {
struct interface_info *tmp = (struct interface_info *)0;
@@ -593,9 +597,9 @@
log_info (url);
#ifdef EXTENDED_NEW_OPTION_INFO
- log_error ("Usage: dhclient [-1dqr] [-nwx] [-p <port>] %s",
+ log_error ("Usage: dhclient [-1dqr] [-nwmx] [-p <port>] %s",
#else
- log_error ("Usage: dhclient [-1dqr] [-nw] [-p <port>] %s",
+ log_error ("Usage: dhclient [-1dqr] [-nwm] [-p <port>] %s",
#endif
"[-s server]");
log_error (" [-cf config-file] [-lf lease-file]%s",
@@ -999,9 +1003,28 @@
script_write_params (client, "alias_", client -> alias);
/* If the BOUND/RENEW code detects another machine using the
- offered address, it exits nonzero. We need to send a
- DHCPDECLINE and toss the lease. */
- if (script_go (client)) {
+ offered address, it exits nonzero.
+
+ Or if we want to detect the same lease being offered by different
+ servers, eg. when moving a laptop to different networks which
+ use the same subnet, and we are rebooting with a currently
+ active lease, and a different server has OFFERed the same lease.
+
+ We need to send a DHCPDECLINE and toss the lease.
+ */
+ if ( ( (mobile_duplicate_lease_detection || client -> config -> mobile_duplicate_lease_detection)
+ &&( client->active && (client -> state == S_REBOOTING))
+ &&( client->active->hardware_addr != 0 )
+ &&( client->new->hardware_addr != 0 )
+ &&( client->active->hardware_addr->hlen == client->new->hardware_addr->hlen )
+ &&( memcmp(client->active->hardware_addr, client->new->hardware_addr,
+ client->new->hardware_addr->hlen + sizeof(client->new->hardware_addr->hlen)
+ ) != 0
+ )
+ )
+ || script_go (client)
+ )
+ {
make_decline (client, client -> new);
send_decline (client);
destroy_client_lease (client -> new);
@@ -1396,6 +1419,16 @@
}
}
+ /* If the server hardware address is available, copy it for mdld. */
+ if ( (mobile_duplicate_lease_detection || client -> config -> mobile_duplicate_lease_detection)
+ &&( packet->haddr != 0L ) && ( packet->haddr->hlen )
+ )
+ {
+ lease->hardware_addr = dmalloc( sizeof(struct hardware), MDL );
+ if( lease->hardware_addr )
+ memcpy( lease->hardware_addr, packet->haddr, sizeof(struct hardware) );
+ }
+
/* Ditto for the filename. */
if (!(i & 1) && packet -> raw -> file [0]) {
unsigned len;
@@ -2447,6 +2480,13 @@
} else
++errors;
}
+
+ if ( lease->hardware_addr ) {
+ fprintf ( leaseFile, " server-hardware-address %s;\n",
+ print_hw_addr(0, lease->hardware_addr->hlen, &(lease->hardware_addr->hbuf[0]))
+ );
+ }
+
if (lease -> medium) {
s = quotify_string (lease -> medium -> string, MDL);
if (s) {
--- dhcp-3.0.2/client/clparse.c.dhclient_mobile_duplicate_lease 2005-06-10 20:43:19.000000000 -0400
+++ dhcp-3.0.2/client/clparse.c 2005-06-10 20:49:03.000000000 -0400
@@ -87,6 +87,7 @@
top_level_config.requested_options = default_requested_options;
top_level_config.omapi_port = -1;
top_level_config.do_forward_update = 1;
+ top_level_config.mobile_duplicate_lease_detection = 0;
group_allocate (&top_level_config.on_receipt, MDL);
if (!top_level_config.on_receipt)
@@ -235,7 +236,9 @@
interface-declaration |
LEASE client-lease-statement |
ALIAS client-lease-statement |
- KEY key-definition */
+ KEY key-definition |
+ MOBILE_DUPLICATE_LEASE_DETECTION (implicit boolean)
+*/
void parse_client_statement (cfile, ip, config)
struct parse *cfile;
@@ -559,6 +562,12 @@
parse_reject_statement (cfile, config);
return;
+ case MOBILE_DUPLICATE_LEASE_DETECTION:
+ config -> mobile_duplicate_lease_detection = 1 ;
+ token = next_token (&val, (unsigned *)0, cfile); /* this token */
+ token = next_token (&val, (unsigned *)0, cfile); /* SEMI */
+ return;
+
default:
lose = 0;
stmt = (struct executable_statement *)0;
@@ -956,7 +965,8 @@
RENEW time-decl |
REBIND time-decl |
EXPIRE time-decl |
- KEY id */
+ KEY id |
+ SERVER_HARDWARE_ADDRESS hardware */
void parse_client_lease_declaration (cfile, lease, ipp, clientp)
struct parse *cfile;
@@ -971,6 +981,8 @@
struct option_cache *oc;
struct client_state *client = (struct client_state *)0;
struct data_string key_id;
+ unsigned char *sha;
+ unsigned shlen=0;
switch (next_token (&val, (unsigned *)0, cfile)) {
case KEY:
@@ -1033,6 +1045,18 @@
parse_string (cfile, &lease -> server_name, (unsigned *)0);
return;
+ case SERVER_HARDWARE_ADDRESS:
+ sha = parse_numeric_aggregate (cfile, (unsigned char *)0, &shlen,
+ COLON, 16, 8);
+ if( ( sha == 0L ) || (shlen > sizeof(lease -> hardware_addr -> hbuf) ) )
+ return;
+ lease -> hardware_addr = dmalloc( sizeof(struct hardware), MDL );
+ lease -> hardware_addr -> hlen = shlen;
+ memcpy( &(lease -> hardware_addr -> hbuf[0]), sha, shlen );
+ dfree(sha,MDL);
+ token = next_token (&val, (unsigned *)0, cfile); /* SEMI */
+ return;
+
case RENEW:
lease -> renewal = parse_date (cfile);
return;
--- dhcp-3.0.2/includes/dhctoken.h.dhclient_mobile_duplicate_lease 2004-09-21 15:25:38.000000000 -0400
+++ dhcp-3.0.2/includes/dhctoken.h 2005-06-10 20:43:19.000000000 -0400
@@ -308,7 +308,9 @@
REFRESH = 612,
DOMAIN_NAME = 613,
DO_FORWARD_UPDATE = 614,
- KNOWN_CLIENTS = 615
+ KNOWN_CLIENTS = 615,
+ SERVER_HARDWARE_ADDRESS=616,
+ MOBILE_DUPLICATE_LEASE_DETECTION=617
};
#define is_identifier(x) ((x) >= FIRST_TOKEN && \
--- dhcp-3.0.2/includes/dhcpd.h.dhclient_mobile_duplicate_lease 2005-06-10 20:43:19.000000000 -0400
+++ dhcp-3.0.2/includes/dhcpd.h 2005-06-10 20:43:19.000000000 -0400
@@ -647,6 +647,7 @@
unsigned int is_bootp: 1; /* If set, lease was acquired with BOOTP. */
struct option_state *options; /* Options supplied with lease. */
+ struct hardware *hardware_addr;
};
/* Possible states in which the client can be. */
@@ -722,6 +723,12 @@
int do_forward_update; /* If nonzero, and if we have the
information we need, update the
A record for the address we get. */
+ int mobile_duplicate_lease_detection;
+ /* If nonzero, detect and DECLINE duplicate
+ * leases ACKed by servers with different
+ * hardware addresses when REBOOTing with
+ * a REQUEST for an active lease.
+ */
};
/* Per-interface state used in the dhcp client... */
More information about the fedora-cvs-commits
mailing list