diff options
author | David Hankins <dhankins@isc.org> | 2006-08-09 14:57:48 +0000 |
---|---|---|
committer | David Hankins <dhankins@isc.org> | 2006-08-09 14:57:48 +0000 |
commit | 78c553c4a00feae01947eaae167af79460e7c406 (patch) | |
tree | 0ec2ad6c34180f9af6d048050b513dd150804699 | |
parent | 51c4d3f56fcd33f7d4a4e3d5c06bc028cf5846b4 (diff) | |
download | isc-dhcp-78c553c4a00feae01947eaae167af79460e7c406.tar.gz |
Removing the new I/O changes from HEAD. [ISC-Bugs #16328]
-rw-r--r-- | RELNOTES | 5 | ||||
-rw-r--r-- | client/dhclient.c | 4 | ||||
-rw-r--r-- | common/ctrace.c | 18 | ||||
-rw-r--r-- | common/discover.c | 41 | ||||
-rw-r--r-- | common/packet.c | 36 | ||||
-rw-r--r-- | includes/dhcpd.h | 19 | ||||
-rw-r--r-- | relay/dhcrelay.8 | 12 | ||||
-rw-r--r-- | relay/dhcrelay.c | 142 | ||||
-rw-r--r-- | server/bootp.c | 15 | ||||
-rw-r--r-- | server/dhcp.c | 41 |
10 files changed, 83 insertions, 250 deletions
@@ -47,11 +47,6 @@ the README file. - RFC3942 compliance, site-local option spaces start at 224 now, not 128. -- The IO system now tracks all local IP addresses, so that the DHCP - applications (particularly the dhcrelay) can discern between what frames - were tranmsitted to it, and what frames are being carried through it which - it should not intercept. - - The Load Balance Algorithm was misimplemented. The current implementation matches RFC 3074. diff --git a/client/dhclient.c b/client/dhclient.c index 53ac8317..db60ca5b 100644 --- a/client/dhclient.c +++ b/client/dhclient.c @@ -32,7 +32,7 @@ #ifndef lint static char ocopyright[] = -"$Id: dhclient.c,v 1.142 2006/07/19 17:14:55 dhankins Exp $ Copyright (c) 2004-2006 Internet Systems Consortium. All rights reserved.\n"; +"$Id: dhclient.c,v 1.143 2006/08/09 14:57:47 dhankins Exp $ Copyright (c) 2004-2006 Internet Systems Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -231,8 +231,6 @@ int main (argc, argv, envp) } } - limited_broadcast.s_addr = INADDR_BROADCAST; - if (!no_dhclient_conf && (s = getenv ("PATH_DHCLIENT_CONF"))) { path_dhclient_conf = s; } diff --git a/common/ctrace.c b/common/ctrace.c index 5e8bcc09..8bcb9674 100644 --- a/common/ctrace.c +++ b/common/ctrace.c @@ -32,7 +32,7 @@ #ifndef lint static char copyright[] = -"$Id: ctrace.c,v 1.5 2006/02/27 23:56:13 dhankins Exp $ Copyright (c) 2004 Internet Systems Consortium. All rights reserved.\n"; +"$Id: ctrace.c,v 1.6 2006/08/09 14:57:47 dhankins Exp $ Copyright (c) 2004 Internet Systems Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -46,10 +46,8 @@ void trace_interface_register (trace_type_t *ttype, struct interface_info *ip) memset (&tipkt, 0, sizeof tipkt); memcpy (&tipkt.hw_address, &ip -> hw_address, sizeof ip -> hw_address); - if (ip -> address_count > 0) - memcpy (&tipkt.primary_address, - &ip -> addresses [0], - sizeof ip -> addresses [0]); + memcpy (&tipkt.primary_address, + &ip -> primary_address, sizeof ip -> primary_address); memcpy (tipkt.name, ip -> name, sizeof ip -> name); tipkt.index = htonl (ip -> index); @@ -89,12 +87,8 @@ void trace_interface_input (trace_type_t *ttype, unsigned len, char *buf) memcpy (&ip -> hw_address, &tipkt -> hw_address, sizeof ip -> hw_address); - ip -> address_count = ip -> address_max = 1; - ip -> addresses = dmalloc (sizeof (struct in_addr), MDL); - if (!ip -> addresses) - log_fatal ("Can't allocate address buffer for trace interface"); - memcpy (&ip -> addresses [0], &tipkt -> primary_address, - sizeof ip -> addresses [0]); + memcpy (&ip -> primary_address, &tipkt -> primary_address, + sizeof ip -> primary_address); memcpy (ip -> name, tipkt -> name, sizeof ip -> name); ip -> index = ntohl (tipkt -> index); @@ -108,7 +102,7 @@ void trace_interface_input (trace_type_t *ttype, unsigned len, char *buf) ip -> ifp -> ifr_addr.sa_len = sizeof (struct sockaddr_in); #endif sin = (struct sockaddr_in *)&ip -> ifp -> ifr_addr; - sin -> sin_addr = ip -> addresses [0]; + sin -> sin_addr = ip -> primary_address; addr.len = 4; memcpy (addr.iabuf, &sin -> sin_addr.s_addr, addr.len); diff --git a/common/discover.c b/common/discover.c index 4d22d149..c22a2a66 100644 --- a/common/discover.c +++ b/common/discover.c @@ -34,7 +34,7 @@ #ifndef lint static char copyright[] = -"$Id: discover.c,v 1.50 2006/02/27 23:56:13 dhankins Exp $ Copyright (c) 2004-2006 Internet Systems Consortium. All rights reserved.\n"; +"$Id: discover.c,v 1.51 2006/08/09 14:57:47 dhankins Exp $ Copyright (c) 2004-2006 Internet Systems Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -307,38 +307,8 @@ void discover_interfaces (state) if (foo.sin_addr.s_addr == htonl (INADDR_LOOPBACK) && ((tmp -> flags & INTERFACE_AUTOMATIC) && state == DISCOVER_SERVER)) - continue; + continue; - /* If the only address we have is 0.0.0.0, we - shouldn't consider the interface configured. */ - if (foo.sin_addr.s_addr != htonl(INADDR_ANY)) - tmp->configured = 1; - - if (!tmp -> addresses) { - tmp -> addresses = - dmalloc (10 * sizeof (struct in_addr), - MDL); - if (!tmp -> addresses) - log_fatal ("no memory for ifaddrlist"); - tmp -> address_count = 0; - tmp -> address_max = 10; - } else if (tmp -> address_count >= tmp -> address_max) { - struct in_addr *ta; - int newmax = tmp -> address_max * 2; - ta = dmalloc (newmax * - sizeof (struct in_addr), MDL); - if (!ta) - log_fatal ("no memory for new " - "ifaddrlist"); - memcpy (ta, tmp -> addresses, - tmp -> address_max * - sizeof (struct in_addr)); - dfree (tmp -> addresses, MDL); - tmp -> addresses = ta; - tmp -> address_max = newmax; - } - tmp -> addresses [tmp -> address_count++] = - foo.sin_addr; /* If this is the first real IP address we've found, keep a pointer to ifreq structure in @@ -355,6 +325,7 @@ void discover_interfaces (state) log_fatal ("no space for ifp."); memcpy (tif, ifp, len); tmp -> ifp = tif; + tmp -> primary_address = foo.sin_addr; } /* Grab the address... */ @@ -1167,12 +1138,6 @@ void interface_stash (struct interface_info *tptr) } interface_vector = vec; } - if (interface_vector [tptr -> index]) { - log_fatal("invalid tracefile - two interfaces with " - "same index - %s and %s", - interface_vector [tptr->index] -> name, - tptr -> name); - } interface_reference (&interface_vector [tptr -> index], tptr, MDL); if (tptr -> index >= interface_count) interface_count = tptr -> index + 1; diff --git a/common/packet.c b/common/packet.c index 7614f576..a6e8e567 100644 --- a/common/packet.c +++ b/common/packet.c @@ -33,7 +33,7 @@ #ifndef lint static char copyright[] = -"$Id: packet.c,v 1.44 2006/07/19 18:00:36 dhankins Exp $ Copyright (c) 2004-2005 Internet Systems Consortium. All rights reserved.\n"; +"$Id: packet.c,v 1.45 2006/08/09 14:57:47 dhankins Exp $ Copyright (c) 2004-2005 Internet Systems Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -231,8 +231,6 @@ ssize_t decode_udp_ip_header (interface, buf, bufix, from, buflen) unsigned len; unsigned ulen; int ignore = 0; - struct interface_info *ii; - int i; memcpy(&ip, buf + bufix, sizeof (struct ip)); udp = (struct udphdr *)(buf + bufix + ip_len); @@ -247,38 +245,6 @@ ssize_t decode_udp_ip_header (interface, buf, bufix, from, buflen) return -1; #endif /* USERLAND_FILTER */ - /* Eliminate packets that we might have accidentally intercepted because - we are doing routing. */ - - /* The DHCP client may not have an IP address; in that case, if we - got the packet, we need to look at it. So if address_count is - zero on the interface on which we received the packet, accept the - packet. */ - if (!interface -> configured) - goto good; - - /* XXX we should handle subnet broadcast addresses here. */ - /* XXX we should compare against 255.255.255.255, not limited_broadcast, - XXX because sometimes we tweak limited_broadcast for debugging. - XXX This is only currently a problem on the server. */ - if (ip.ip_dst.s_addr == limited_broadcast.s_addr) - goto good; - - /* Check IP addresses of _all_ interfaces - it's perfectly okay to send - a packet to an IP address on one interface that happens to arrive - through another interface. */ - /* XXX if the user excluded some interfaces, we will not accept packets - XXX for those interfaces. */ - for (ii = interfaces; ii; ii = ii -> next) { - for (i = 0; i < ii -> address_count; i++) { - if (ii -> addresses [i].s_addr == ip.ip_dst.s_addr) - goto good; - } - } - /* The IP destination address didn't match any of our addresses. */ - return -1; - - good: ulen = ntohs (udp -> uh_ulen); if (ulen < sizeof *udp || ((unsigned char *)udp) + ulen > buf + bufix + buflen) { diff --git a/includes/dhcpd.h b/includes/dhcpd.h index 5d1bdabe..49115e3c 100644 --- a/includes/dhcpd.h +++ b/includes/dhcpd.h @@ -870,12 +870,6 @@ struct client_state { struct option_state *sent_options; /* Options we sent. */ }; -/* Relay agent server list. */ -struct server_list { - struct server_list *next; - struct sockaddr_in to; -} *servers; - /* Information about each network interface. */ struct interface_info { @@ -884,12 +878,7 @@ struct interface_info { struct shared_network *shared_network; /* Networks connected to this interface. */ struct hardware hw_address; /* Its physical address. */ - struct in_addr *addresses; /* Addresses associated with - interface. */ - int address_count; /* Number of addresses associated with - interface. */ - int address_max; /* Max number of addresses we can - store in current buffer. */ + struct in_addr primary_address; /* Primary interface address. */ u_int8_t *circuit_id; /* Circuit ID associated with this interface. */ @@ -898,8 +887,6 @@ struct interface_info { u_int8_t *remote_id; /* Remote ID associated with this interface (if any). */ unsigned remote_id_len; /* Length of Remote ID. */ - struct server_list *servers; /* List of relay servers for this - interface. */ char name [IFNAMSIZ]; /* Its name... */ int index; /* Its index. */ @@ -912,9 +899,6 @@ struct interface_info { size_t rbuf_len; /* Length of data in buffer. */ struct ifreq *ifp; /* Pointer to ifreq struct. */ - int configured; /* If set to 1, interface has at - * least one valid IP address. - */ u_int32_t flags; /* Control flags... */ #define INTERFACE_REQUESTED 1 #define INTERFACE_AUTOMATIC 2 @@ -2162,7 +2146,6 @@ int parse_ip_addr_with_subnet(struct parse *, struct iaddrmatch *); void parse_reject_statement PROTO ((struct parse *, struct client_config *)); /* dhcrelay.c */ -void new_relay_server (char *, struct server_list **); void relay PROTO ((struct interface_info *, struct dhcp_packet *, unsigned, unsigned int, struct iaddr, struct hardware *)); int strip_relay_agent_options PROTO ((struct interface_info *, diff --git a/relay/dhcrelay.8 b/relay/dhcrelay.8 index 1e0a9a9c..238b16da 100644 --- a/relay/dhcrelay.8 +++ b/relay/dhcrelay.8 @@ -27,7 +27,7 @@ .\" see ``http://www.isc.org/isc''. To learn more about Vixie .\" Enterprises, see ``http://www.vix.com''. .\" -.\" $Id: dhcrelay.8,v 1.11 2006/02/27 23:56:13 dhankins Exp $ +.\" $Id: dhcrelay.8,v 1.12 2006/08/09 14:57:48 dhankins Exp $ .\" .TH dhcrelay 8 .SH NAME @@ -48,11 +48,6 @@ dhcrelay - Dynamic Host Configuration Protocol Relay Agent .B -i .I if0 [ -.B -is -.I server -... -] -[ .B ... .B -i .I ifN @@ -119,11 +114,6 @@ server) is attached. However, in some cases it may be necessary to exclude some networks; in this case, you must list all those network interfaces that should \fInot\fR be excluded using the \fB-i\fR flag. .PP -The -.B -is -flag can be used to indicate that for the previous interface specified with --i, packets should be forwarded to the specified server. -.PP In some cases it .I is helpful for the relay agent to forward requests from networks on which diff --git a/relay/dhcrelay.c b/relay/dhcrelay.c index 859fcf0f..8465b03b 100644 --- a/relay/dhcrelay.c +++ b/relay/dhcrelay.c @@ -34,7 +34,7 @@ #ifndef lint static char ocopyright[] = -"$Id: dhcrelay.c,v 1.58 2006/05/11 14:48:59 shane Exp $ Copyright (c) 2004-2006 Internet Systems Consortium. All rights reserved.\n"; +"$Id: dhcrelay.c,v 1.59 2006/08/09 14:57:48 dhankins Exp $ Copyright (c) 2004-2006 Internet Systems Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -92,6 +92,12 @@ enum { forward_and_append, /* Forward and append our own relay option. */ u_int16_t local_port; u_int16_t remote_port; +/* Relay agent server list. */ +struct server_list { + struct server_list *next; + struct sockaddr_in to; +} *servers; + static char copyright [] = "Copyright 2004-2006 Internet Systems Consortium."; static char arr [] = "All rights reserved."; static char message [] = "Internet Systems Consortium DHCP Relay Agent"; @@ -104,12 +110,11 @@ int main (argc, argv, envp) int fd; int i; struct servent *ent; - struct server_list *sp = (struct server_list *)0; + struct server_list *sp = NULL; int no_daemon = 0; int quiet = 0; isc_result_t status; char *s; - struct interface_info *tmp = (struct interface_info *)0; /* Make sure that file descriptors 0 (stdin), 1, (stdout), and 2 (stderr) are open. To do this, we assume that when we @@ -154,8 +159,8 @@ int main (argc, argv, envp) } else if (!strcmp (argv [i], "-d")) { no_daemon = 1; } else if (!strcmp (argv [i], "-i")) { - if (tmp) - interface_dereference (&tmp, MDL); + struct interface_info *tmp = + (struct interface_info *)0; status = interface_allocate (&tmp, MDL); if (status != ISC_R_SUCCESS) log_fatal ("%s: interface_allocate: %s", @@ -166,14 +171,7 @@ int main (argc, argv, envp) } strcpy (tmp -> name, argv [i]); interface_snorf (tmp, INTERFACE_REQUESTED); - } else if (!strcmp (argv [i], "-is")) { - if (++i == argc) - usage (); - if (!tmp) { - log_error ("-is must follow -i."); - usage (); - } - new_relay_server (argv [i], &tmp -> servers); + interface_dereference (&tmp, MDL); } else if (!strcmp (argv [i], "-q")) { quiet = 1; quiet_interface_discovery = 1; @@ -213,15 +211,33 @@ int main (argc, argv, envp) log_info ("isc-dhcrelay-%s", DHCP_VERSION); exit (0); } else { - new_relay_server (argv [i], &servers); + struct hostent *he; + struct in_addr ia, *iap = (struct in_addr *)0; + if (inet_aton (argv [i], &ia)) { + iap = &ia; + } else { + he = gethostbyname (argv [i]); + if (!he) { + log_error ("%s: host unknown", + argv [i]); + } else { + iap = ((struct in_addr *) + he -> h_addr_list [0]); + } + } + if (iap) { + sp = ((struct server_list *) + dmalloc (sizeof *sp, MDL)); + if (!sp) + log_fatal ("no memory for server.\n"); + sp -> next = servers; + servers = sp; + memcpy (&sp -> to.sin_addr, + iap, sizeof *iap); + } } } - limited_broadcast.s_addr = INADDR_BROADCAST; - - if (tmp) - interface_dereference (&tmp, MDL); - if ((s = getenv ("PATH_DHCRELAY_PID"))) { path_dhcrelay_pid = s; } @@ -248,7 +264,7 @@ int main (argc, argv, envp) remote_port = htons (ntohs (local_port) + 1); /* We need at least one server. */ - if (!servers) { + if (!sp) { usage (); } @@ -261,29 +277,6 @@ int main (argc, argv, envp) #endif } - if (interfaces) { - interface_reference (&tmp, interfaces, MDL); - do { - struct interface_info *next = NULL; - if (tmp -> next) - interface_reference (&next, tmp -> next, MDL); - - for (sp = tmp -> servers; sp; sp = sp -> next) { - sp -> to.sin_port = local_port; - sp -> to.sin_family = AF_INET; -#ifdef HAVE_SA_LEN - sp -> to.sin_len = sizeof sp -> to; -#endif - } - - interface_dereference (&tmp, MDL); - if (next) { - interface_reference (&tmp, next, MDL); - interface_dereference (&next, MDL); - } - } while (tmp); - } - /* Get the current time... */ GET_TIME (&cur_time); @@ -335,36 +328,6 @@ int main (argc, argv, envp) return 0; } -void new_relay_server (char *arg, struct server_list **servers) -{ - struct hostent *he; - struct in_addr ia, *iap = (struct in_addr *)0; - struct server_list *sp; - - if (inet_aton (arg, &ia)) { - iap = &ia; - } else { - he = gethostbyname (arg); - if (!he) { - log_error ("%s: host unknown", arg); - } else { - iap = ((struct in_addr *) - he -> h_addr_list [0]); - } - } - if (iap) { - sp = ((struct server_list *) - dmalloc (sizeof *sp, MDL)); - if (!sp) - log_fatal ("no memory for server.\n"); - memset(sp, 0, sizeof *sp); - sp -> next = *servers; - *servers = sp; - memcpy (&sp -> to.sin_addr, - iap, sizeof *iap); - } -} - void relay (ip, packet, length, from_port, from, hfrom) struct interface_info *ip; struct dhcp_packet *packet; @@ -377,7 +340,6 @@ void relay (ip, packet, length, from_port, from, hfrom) struct sockaddr_in to; struct interface_info *out; struct hardware hto, *htop; - int i; if (packet -> hlen > sizeof packet -> chaddr) { log_info ("Discarding packet with invalid hlen."); @@ -388,16 +350,14 @@ void relay (ip, packet, length, from_port, from, hfrom) in the packet. */ if (packet -> giaddr.s_addr) { for (out = interfaces; out; out = out -> next) { - for (i = 0; i < out -> address_count; i++) { - if (out -> addresses [i].s_addr == - packet -> giaddr.s_addr) - goto matched; - } + if (!memcmp (&out -> primary_address, + &packet -> giaddr, + sizeof packet -> giaddr)) + break; } } else { out = (struct interface_info *)0; } - matched: /* If it's a bootreply, forward it to the client. */ if (packet -> op == BOOTREPLY) { @@ -433,18 +393,15 @@ void relay (ip, packet, length, from_port, from, hfrom) return; if (!out) { - log_error ("packet to bogus giaddr %s.", + log_error ("packet to bogus giaddr %s.\n", inet_ntoa (packet -> giaddr)); ++bogus_giaddr_drops; return; } - if (out -> address_count < 1) - log_fatal ("no IP address on interface %s!", - out -> name); if (send_packet (out, (struct packet *)0, - packet, length, out -> addresses [0], + packet, length, out -> primary_address, &to, htop) < 0) { ++server_packet_errors; } else { @@ -463,13 +420,10 @@ void relay (ip, packet, length, from_port, from, hfrom) if (out) return; - if (ip -> address_count < 1) - log_fatal ("no IP address on interface %s", ip -> name); - /* Add relay agent options if indicated. If something goes wrong, drop the packet. */ if (!(length = add_relay_agent_options (ip, packet, length, - ip -> addresses [0]))) + ip -> primary_address))) return; /* If giaddr is not already set, Set it so the server can @@ -478,7 +432,7 @@ void relay (ip, packet, length, from_port, from, hfrom) set, the response will be sent directly to the relay agent that set giaddr, so we won't see it. */ if (!packet -> giaddr.s_addr) - packet -> giaddr = ip -> addresses [0]; + packet -> giaddr = ip -> primary_address; if (packet -> hops < max_hop_count) packet -> hops = packet -> hops + 1; else @@ -486,12 +440,11 @@ void relay (ip, packet, length, from_port, from, hfrom) /* Otherwise, it's a BOOTREQUEST, so forward it to all the servers. */ - for (sp = (ip -> servers - ? ip -> servers : servers); sp; sp = sp -> next) { + for (sp = servers; sp; sp = sp -> next) { if (send_packet ((fallback_interface ? fallback_interface : interfaces), (struct packet *)0, - packet, length, ip -> addresses [0], + packet, length, ip -> primary_address, &sp -> to, (struct hardware *)0) < 0) { ++client_packet_errors; } else { @@ -502,12 +455,13 @@ void relay (ip, packet, length, from_port, from, hfrom) ++client_packets_relayed; } } + } static void usage () { log_fatal ("Usage: dhcrelay [-p <port>] [-d] [-D] [-i %s%s%s%s", - "interface [-is server ... ]]\n ", + "interface] [-q] [-a]\n ", "[-c count] [-A length] ", "[-m append|replace|forward|discard]\n", " [server1 [... serverN]]"); diff --git a/server/bootp.c b/server/bootp.c index 7bf2afe3..6976f6d1 100644 --- a/server/bootp.c +++ b/server/bootp.c @@ -34,7 +34,7 @@ #ifndef lint static char copyright[] = -"$Id: bootp.c,v 1.75 2006/06/01 20:23:17 dhankins Exp $ Copyright (c) 2004-2005 Internet Systems Consortium. All rights reserved.\n"; +"$Id: bootp.c,v 1.76 2006/08/09 14:57:48 dhankins Exp $ Copyright (c) 2004-2005 Internet Systems Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -272,13 +272,11 @@ void bootp (packet) memcpy (&raw.siaddr, d1.data, 4); data_string_forget (&d1, MDL); } else { - if (lease -> subnet -> shared_network -> interface && - lease -> subnet -> - shared_network -> interface -> address_count) + if (lease -> subnet -> shared_network -> interface) raw.siaddr = (lease -> subnet -> shared_network -> - interface -> addresses [0]); - else if (packet -> interface -> address_count) - raw.siaddr = packet -> interface -> addresses [0]; + interface -> primary_address); + else + raw.siaddr = packet -> interface -> primary_address; } raw.giaddr = packet -> raw -> giaddr; @@ -328,8 +326,7 @@ void bootp (packet) hto.hlen = packet -> raw -> hlen + 1; memcpy (&hto.hbuf [1], packet -> raw -> chaddr, packet -> raw -> hlen); - if (packet -> interface -> address_count) - from = packet -> interface -> addresses [0]; + from = packet -> interface -> primary_address; /* Report what we're doing... */ log_info ("%s", msgbuf); diff --git a/server/dhcp.c b/server/dhcp.c index ddec7a53..59b97d9a 100644 --- a/server/dhcp.c +++ b/server/dhcp.c @@ -34,7 +34,7 @@ #ifndef lint static char copyright[] = -"$Id: dhcp.c,v 1.210 2006/07/31 23:17:24 dhankins Exp $ Copyright (c) 2004-2006 Internet Systems Consortium. All rights reserved.\n"; +"$Id: dhcp.c,v 1.211 2006/08/09 14:57:48 dhankins Exp $ Copyright (c) 2004-2006 Internet Systems Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -1361,8 +1361,7 @@ void nak_lease (packet, cip) option_state_dereference (&options, MDL); /* memset (&raw.ciaddr, 0, sizeof raw.ciaddr);*/ - if (packet -> interface -> address_count) - raw.siaddr = packet -> interface -> addresses [0]; + raw.siaddr = packet -> interface -> primary_address; raw.giaddr = packet -> raw -> giaddr; memcpy (raw.chaddr, packet -> raw -> chaddr, sizeof raw.chaddr); raw.hlen = packet -> raw -> hlen; @@ -2523,13 +2522,9 @@ void ack_lease (packet, lease, offer, when, msg, ms_nulltp, hp) } } else { /* XXXSK: should we use get_server_source_address() here? */ - if (state -> ip -> address_count) { - state -> from.len = - sizeof state -> ip -> addresses [0]; - memcpy (state -> from.iabuf, - &state -> ip -> addresses [0], - state -> from.len); - } + state -> from.len = sizeof state -> ip -> primary_address; + memcpy (state -> from.iabuf, &state -> ip -> primary_address, + state -> from.len); } /* Figure out the address of the boot file server. */ @@ -3944,22 +3939,18 @@ get_server_source_address(struct in_addr *from, data_string_forget(&d, MDL); } - if (packet->interface->address_count > 0) { - if (option_cache_allocate(&oc, MDL)) { - a = &packet->interface->addresses[0]; - if (make_const_data(&oc->expression, - (char *)a, sizeof(*a), - 0, 0, MDL)) { - option_code_hash_lookup(&oc->option, - dhcp_universe.code_hash, - &option_num, 0, MDL); - save_option(&dhcp_universe, options, oc); - } - option_cache_dereference(&oc, MDL); + if (option_cache_allocate(&oc, MDL)) { + a = &packet->interface->primary_address; + if (make_const_data(&oc->expression, + (char *)a, sizeof(*a), + 0, 0, MDL)) { + option_code_hash_lookup(&oc->option, + dhcp_universe.code_hash, + &option_num, 0, MDL); + save_option(&dhcp_universe, options, oc); } - *from = packet->interface->addresses[0]; - } else { - memset(from, 0, sizeof(*from)); + option_cache_dereference(&oc, MDL); } + *from = packet->interface->primary_address; } |