Only query gateway hwaddr when binding a new lease. Don't bother when just

renewing or rebinding a lease.
This commit is contained in:
Nicholas J. Kain 2011-03-31 15:05:05 -04:00
parent a7db2c4bd2
commit 996983143e
3 changed files with 7 additions and 8 deletions

View File

@ -1,5 +1,5 @@
/* dhcpmsg.c - dhcp packet generation and sending functions /* dhcpmsg.c - dhcp packet generation and sending functions
* Time-stamp: <2011-03-30 23:53:52 nk> * Time-stamp: <2011-03-31 03:27:02 nk>
* *
* (c) 2004-2011 Nicholas J. Kain <njkain at gmail dot com> * (c) 2004-2011 Nicholas J. Kain <njkain at gmail dot com>
* (c) 2001 Russ Dill <Russ.Dill@asu.edu> * (c) 2001 Russ Dill <Russ.Dill@asu.edu>
@ -44,7 +44,6 @@ uint32_t random_xid(void);
int send_discover(uint32_t xid, uint32_t requested); int send_discover(uint32_t xid, uint32_t requested);
int send_selecting(uint32_t xid, uint32_t server, uint32_t requested); int send_selecting(uint32_t xid, uint32_t server, uint32_t requested);
int send_renew(uint32_t xid, uint32_t server, uint32_t ciaddr); int send_renew(uint32_t xid, uint32_t server, uint32_t ciaddr);
int send_renew(uint32_t xid, uint32_t server, uint32_t ciaddr);
int send_decline(uint32_t xid, uint32_t server, uint32_t requested); int send_decline(uint32_t xid, uint32_t server, uint32_t requested);
int send_release(uint32_t server, uint32_t ciaddr); int send_release(uint32_t server, uint32_t ciaddr);
int get_raw_packet(struct dhcpMessage *payload, int fd); int get_raw_packet(struct dhcpMessage *payload, int fd);

View File

@ -1,5 +1,5 @@
/* ifchange.c - functions to call the interface change daemon /* ifchange.c - functions to call the interface change daemon
* Time-stamp: <2011-03-31 01:57:46 nk> * Time-stamp: <2011-03-31 03:44:58 nk>
* *
* (c) 2004-2011 Nicholas J. Kain <njkain at gmail dot com> * (c) 2004-2011 Nicholas J. Kain <njkain at gmail dot com>
* *
@ -197,7 +197,7 @@ static void send_cmd(int sockfd, struct dhcpMessage *packet, uint8_t code)
sockwrite(sockfd, buf, strlen(buf)); sockwrite(sockfd, buf, strlen(buf));
} }
static void bound_if(struct dhcpMessage *packet) static void bound_if(struct dhcpMessage *packet, int mode)
{ {
int sockfd; int sockfd;
char buf[256]; char buf[256];
@ -226,7 +226,7 @@ static void bound_if(struct dhcpMessage *packet)
send_cmd(sockfd, packet, DHCP_WINS_SERVER); send_cmd(sockfd, packet, DHCP_WINS_SERVER);
close(sockfd); close(sockfd);
if (router_set == 1) { if (mode == IFCHANGE_BOUND && router_set == 1) {
if (arp_get_gw_hwaddr(&cs) == -1) { if (arp_get_gw_hwaddr(&cs) == -1) {
log_warning("arp_get_gw_hwaddr failed to make arp socket; setting gw mac=ff:ff:ff:ff:ff:ff"); log_warning("arp_get_gw_hwaddr failed to make arp socket; setting gw mac=ff:ff:ff:ff:ff:ff");
memset(&cs.routerAddr, 0xff, 4); memset(&cs.routerAddr, 0xff, 4);
@ -241,10 +241,10 @@ void ifchange(struct dhcpMessage *packet, int mode)
deconfig_if(); deconfig_if();
break; break;
case IFCHANGE_BOUND: case IFCHANGE_BOUND:
bound_if(packet); bound_if(packet, mode);
break; break;
case IFCHANGE_RENEW: case IFCHANGE_RENEW:
bound_if(packet); bound_if(packet, mode);
break; break;
case IFCHANGE_NAK: case IFCHANGE_NAK:
deconfig_if(); deconfig_if();

View File

@ -1,5 +1,5 @@
/* ifchange.h - functions to call the interface change daemon /* ifchange.h - functions to call the interface change daemon
* Time-stamp: <2011-03-30 16:38:19 nk> * Time-stamp: <2011-03-31 03:44:18 nk>
* *
* (c) 2004-2011 Nicholas J. Kain <njkain at gmail dot com> * (c) 2004-2011 Nicholas J. Kain <njkain at gmail dot com>
* *