Remove legacy support for exiting after obtaining a DHCP lease.

This commit is contained in:
Nicholas J. Kain 2020-10-20 06:54:17 -04:00
parent ade4e988af
commit 4575f74164
5 changed files with 2 additions and 35 deletions

View File

@ -500,24 +500,6 @@ int arp_gw_query_timeout(struct client_state_t cs[static 1], long long nowts)
return ARPR_OK; return ARPR_OK;
} }
// Failure here is difficult to handle gracefully, as we do have a valid
// IP but have not yet announced it to other hosts on our ethernet
// segment. We try to do so for one minute. We must measure the time
// directly so that carrier loss or suspend are handled properly.
__attribute__((noreturn))
static void quit_after_lease_handler(struct client_state_t cs[static 1])
{
long long init_ts = curms();
for (;;) {
if (arp_announcement(cs) >= 0)
exit(EXIT_SUCCESS);
log_warning("%s: (%s) Failed to send ARP announcement: %s",
client_config.interface, __func__, strerror(errno));
if (curms() - init_ts > (60LL * 1000LL)) break;
}
exit(EXIT_FAILURE);
}
int arp_collision_timeout(struct client_state_t cs[static 1], long long nowts) int arp_collision_timeout(struct client_state_t cs[static 1], long long nowts)
{ {
if (nowts >= garp.arp_check_start_ts + ANNOUNCE_WAIT || if (nowts >= garp.arp_check_start_ts + ANNOUNCE_WAIT ||
@ -539,8 +521,6 @@ int arp_collision_timeout(struct client_state_t cs[static 1], long long nowts)
cs->routerAddr = get_option_router(&garp.dhcp_packet); cs->routerAddr = get_option_router(&garp.dhcp_packet);
stop_dhcp_listen(cs); stop_dhcp_listen(cs);
write_leasefile(temp_addr); write_leasefile(temp_addr);
if (client_config.quit_after_lease)
quit_after_lease_handler(cs);
return ARPR_FREE; return ARPR_FREE;
} }
long long rtts = garp.send_stats[ASEND_COLLISION_CHECK].ts + long long rtts = garp.send_stats[ASEND_COLLISION_CHECK].ts +

View File

@ -60,12 +60,6 @@ struct cfgparse {
case -1: client_config.abort_if_no_lease = false; default: break; case -1: client_config.abort_if_no_lease = false; default: break;
} }
} }
action quit {
switch (ccfg.ternary) {
case 1: client_config.quit_after_lease = true; break;
case -1: client_config.quit_after_lease = false; default: break;
}
}
action request { set_client_addr(ccfg.buf); } action request { set_client_addr(ccfg.buf); }
action vendorid { action vendorid {
copy_cmdarg(client_config.vendor, ccfg.buf, copy_cmdarg(client_config.vendor, ccfg.buf,
@ -177,7 +171,6 @@ struct cfgparse {
hostname = 'hostname' value @hostname; hostname = 'hostname' value @hostname;
interface = 'interface' value @interface; interface = 'interface' value @interface;
now = 'now' boolval @now; now = 'now' boolval @now;
quit = 'quit' boolval @quit;
request = 'request' value @request; request = 'request' value @request;
vendorid = 'vendorid' value @vendorid; vendorid = 'vendorid' value @vendorid;
user = 'user' value @user; user = 'user' value @user;
@ -197,7 +190,7 @@ struct cfgparse {
rfkill_idx = 'rfkill-idx' value @rfkill_idx; rfkill_idx = 'rfkill-idx' value @rfkill_idx;
main := blankline | main := blankline |
clientid | hostname | interface | now | quit | clientid | hostname | interface | now |
request | vendorid | user | ifch_user | sockd_user | chroot | request | vendorid | user | ifch_user | sockd_user | chroot |
state_dir | seccomp_enforce | relentless_defense | arp_probe_wait | state_dir | seccomp_enforce | relentless_defense | arp_probe_wait |
arp_probe_num | arp_probe_min | arp_probe_max | gw_metric | arp_probe_num | arp_probe_min | arp_probe_max | gw_metric |
@ -280,7 +273,6 @@ static void parse_cfgfile(const char fname[static 1])
hostname = ('-h'|'--hostname') argval @hostname; hostname = ('-h'|'--hostname') argval @hostname;
interface = ('-i'|'--interface') argval @interface; interface = ('-i'|'--interface') argval @interface;
now = ('-n'|'--now') tbv @now; now = ('-n'|'--now') tbv @now;
quit = ('-q'|'--quit') tbv @quit;
request = ('-r'|'--request') argval @request; request = ('-r'|'--request') argval @request;
vendorid = ('-V'|'--vendorid') argval @vendorid; vendorid = ('-V'|'--vendorid') argval @vendorid;
user = ('-u'|'--user') argval @user; user = ('-u'|'--user') argval @user;
@ -303,7 +295,7 @@ static void parse_cfgfile(const char fname[static 1])
main := ( main := (
cfgfile | clientid | hostname | interface | cfgfile | clientid | hostname | interface |
now | quit | request | vendorid | user | ifch_user | sockd_user | now | request | vendorid | user | ifch_user | sockd_user |
chroot | state_dir | seccomp_enforce | relentless_defense | chroot | state_dir | seccomp_enforce | relentless_defense |
arp_probe_wait | arp_probe_num | arp_probe_min | arp_probe_max | arp_probe_wait | arp_probe_num | arp_probe_min | arp_probe_max |
gw_metric | resolv_conf | dhcp_set_hostname | rfkill_idx | gw_metric | resolv_conf | dhcp_set_hostname | rfkill_idx |

View File

@ -52,9 +52,6 @@ should use by name. The default is to listen on 'eth0'.
.BI \-n ,\ \-\-now .BI \-n ,\ \-\-now
Exit with failure if a lease cannot be obtained. Useful for some init scripts. Exit with failure if a lease cannot be obtained. Useful for some init scripts.
.TP .TP
.BI \-q ,\ \-\-quit
Exit after obtaining a lease. Useful for some init scripts.
.TP
.BI \-r\ IP ,\ \-\-request= IP .BI \-r\ IP ,\ \-\-request= IP
Request the specified IP address from the remote DHCP server. The DHCP server Request the specified IP address from the remote DHCP server. The DHCP server
has no obligation to provide us with this IP, but it may acquiesce to the has no obligation to provide us with this IP, but it may acquiesce to the

View File

@ -152,7 +152,6 @@ void show_usage(void)
" -i, --interface=INTERFACE Interface to use (default: eth0)\n" " -i, --interface=INTERFACE Interface to use (default: eth0)\n"
" -n, --now Exit with failure if lease cannot be\n" " -n, --now Exit with failure if lease cannot be\n"
" immediately negotiated.\n" " immediately negotiated.\n"
" -q, --quit Quit after obtaining lease\n"
" -r, --request=IP IP address to request (default: none)\n" " -r, --request=IP IP address to request (default: none)\n"
" -u, --user=USER Change ndhc privileges to this user\n" " -u, --user=USER Change ndhc privileges to this user\n"
" -U, --ifch-user=USER Change ndhc-ifch privileges to this user\n" " -U, --ifch-user=USER Change ndhc-ifch privileges to this user\n"

View File

@ -69,7 +69,6 @@ struct client_config_t {
int metric; // Metric for the default route int metric; // Metric for the default route
int ifindex; // Index number of the interface to use int ifindex; // Index number of the interface to use
uint8_t clientid_len; // Length of the clientid uint8_t clientid_len; // Length of the clientid
bool quit_after_lease; // Quit after obtaining lease
bool abort_if_no_lease; // Abort if no lease bool abort_if_no_lease; // Abort if no lease
bool enable_rfkill; // Listen for rfkill events bool enable_rfkill; // Listen for rfkill events
}; };