-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dhclient: Set default ARP resolution wait to 250 ms, with an option to make it 0 ms #1368
Conversation
@ica574 Looks like the style checker wants "static const" rather than "const static". Can you change that? It's also complaining about the timespeccmp calls but that's a bug in the style checker; please leave those as they are. @bsdimp Do we ask for signed-off-by lines in github PRs? I'm sure Isaac can add them, I just hadn't noticed them before and wasn't sure if this was something you(?) put into the style checker deliberately. |
@cperciva Done! I've changed "const static" to "static const". |
sbin/dhclient/dhclient.c
Outdated
@@ -120,6 +121,8 @@ struct pidfh *pidfile; | |||
*/ | |||
#define TIME_MAX ((((time_t) 1 << (sizeof(time_t) * CHAR_BIT - 2)) - 1) * 2 + 1) | |||
|
|||
static struct timespec arp_timeout = { .tv_sec = 2, .tv_nsec = 0 }; | |||
const struct timespec zero_timespec = { .tv_sec = 0, .tv_nsec = 0 }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like this could be static?
sbin/dhclient/dhcpd.h
Outdated
extern time_t cur_time; | ||
extern int log_priority; | ||
extern int log_perror; | ||
|
||
extern const struct timespec zero_timespec; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why declare this when it's only used in dhclient.c?
Oops, I told @ica574 to make Isaac, please mark it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everyone doesn't always do it, but it'd be nice if the commit message explains why you want to do that for someone unfamiliar with the topic.
sbin/dhclient/dhclient.8
Outdated
@@ -95,6 +95,9 @@ Forces | |||
.Nm | |||
to reject leases with unknown options in them. | |||
The default behaviour is to accept such lease offers. | |||
.It Fl n | |||
Don't wait for ARP resolution within | |||
.Nm |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please keep the flags alphabetized by moving the added text to after line 84. Also the sentances explaining other flags are ending with a period. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My wheelhouse is only manuals, but manual LGTM! Congrats on your project, changing the world is so exciting!
libexec/rc/rc.conf
Outdated
@@ -138,6 +138,7 @@ dhclient_flags="" # Extra flags to pass to dhcp client. | |||
#dhclient_flags_em0="" # Extra dhclient flags for em0 only | |||
background_dhclient="NO" # Start dhcp client in the background. | |||
#background_dhclient_em0="YES" # Start dhcp client on em0 in the background. | |||
dhclient_noarpwait="NO" # Trust IP address from DHCP and don't ARP |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The double negative in dhclient_noarpwait="NO"
reads awkwardly. Reversing its logic, naming it dhclient_wait_for_arp
, and setting its default value to "YES"
might make it easier to understand.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. I suggested "noarpwait" since that's what the -n
flag means (and it needs to be that way around to keep the previous "no flags means wait for ARP" behaviour) but you're quite right that for a new rc.conf setting we can reverse that.
@ica574 How about dhclient_arpwait="YES" # ARP IP addresses before using them
and a corresponding change in the rc.d script?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good. I'll implement it!
libexec/rc/rc.conf
Outdated
@@ -138,6 +138,7 @@ dhclient_flags="" # Extra flags to pass to dhcp client. | |||
#dhclient_flags_em0="" # Extra dhclient flags for em0 only | |||
background_dhclient="NO" # Start dhcp client in the background. | |||
#background_dhclient_em0="YES" # Start dhcp client on em0 in the background. | |||
dhclient_arpwait="YES" # Trust IP address from DHCP and don't ARP |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You forgot to update the comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My bad, should be fixed now.
libexec/rc/rc.d/dhclient
Outdated
@@ -48,6 +48,10 @@ dhclient_prestart() | |||
rc_flags="${rc_flags} -b" | |||
fi | |||
|
|||
dhclient_arpwait=$(get_if_var $ifn dhclient_arpwait_IF $dhclient_arpwait) | |||
if checkyesno dhclient_arpwait; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and this is now backwards; we need to add -n
if dhclient_arpwait
is set to no.
Should we add an entry for |
libexec/rc/rc.conf
Outdated
@@ -138,6 +138,7 @@ dhclient_flags="" # Extra flags to pass to dhcp client. | |||
#dhclient_flags_em0="" # Extra dhclient flags for em0 only | |||
background_dhclient="NO" # Start dhcp client in the background. | |||
#background_dhclient_em0="YES" # Start dhcp client on em0 in the background. | |||
dhclient_arpwait="YES" # Wait for ARP resolution |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like we need an extra tab to line the comment up with the rest? Or is that just github being wonky?
Yes, that's probably a good idea. @ica574 Can you add this? Write something about not ARPing IP addresses before using them and this making the system boot faster on networks where the DHCP server is guaranteed to know whether an address is available. |
@ica574 Can you add Signed-off-by tags to all of the commits? I think |
94f1a9f
to
89b16d8
Compare
Introduce a new function, add_timeout_timespec(), to use timespec structs to handle timeouts. Make add_timeout() into a wrapper for the latter function to retain compatibility with the rest of the codebase. No functional change intended. Sponsored by: Google LLC (GSoC 2024) Signed-off-by: Isaac Cilia Attard <icattard@FreeBSD.org>
Use the new add_timeout_timespec() API to handle timeouts for state_selecting within dhclient.c. No functional change intended. Sponsored by: Google LLC (GSoC 2024) Signed-off-by: Isaac Cilia Attard <icattard@FreeBSD.org>
Change the use of time() to clock_gettime() to have millisecond-accurate rather than second-accurate timeouts. Sponsored by: Google LLC (GSoC 2024) Signed-off-by: Isaac Cilia Attard <icattard@FreeBSD.org>
Make arp_timeout available to dhclient.c, set the default timeout to 250 ms, and provide a new command-line argument, 'n' for setting the timeout to 0. Sponsored by: Google LLC (GSoC 2024) Signed-off-by: Isaac Cilia Attard <icattard@FreeBSD.org>
Document new n flag for disabling ARP resolution within dhclient. Sponsored by: Google LLC (GSoC 2024) Signed-off-by: Isaac Cilia Attard <icattard@FreeBSD.org>
Introduce a new rc.conf option to not wait for ARP resolution within dhclient. This is plausible on many modern networks where it is possible to trust the DHCP server to know whether an IP address is available. Sponsored by: Google LLC (GSoC 2024) Signed-off-by: Isaac Cilia Attard <icattard@FreeBSD.org>
share/man/man5/rc.conf.5
Outdated
.It Va dhclient_arpwait | ||
.Pq Vt bool | ||
Set to | ||
.Dq Li YES |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
YES is the default, so for rc.conf(5)
we should say what happens if we set it to NO.
Add new dhclient_arpwait option to rc.conf.5, with information about what it does, and cases in which it could be disabled. Sponsored by: Google LLC (GSoC 2024) Signed-off-by: Isaac Cilia Attard <icattard@FreeBSD.org>
Introduce a new rc.conf option to not wait for ARP resolution within dhclient. This is plausible on many modern networks where it is possible to trust the DHCP server to know whether an IP address is available. Sponsored by: Google LLC (GSoC 2024) Signed-off-by: Isaac Cilia Attard <icattard@FreeBSD.org> MFC after: 10 days Reviwed by: cperciva, brooks, Tom Hukins, Alexander Ziaee Pull Request: freebsd#1368
Add new dhclient_arpwait option to rc.conf.5, with information about what it does, and cases in which it could be disabled. Sponsored by: Google LLC (GSoC 2024) Signed-off-by: Isaac Cilia Attard <icattard@FreeBSD.org> MFC after: 10 days Reviwed by: cperciva, brooks, Tom Hukins, Alexander Ziaee Pull Request: freebsd#1368
Introduce a new function, add_timeout_timespec(), to use timespec structs to handle timeouts. Make add_timeout() into a wrapper for the latter function to retain compatibility with the rest of the codebase. No functional change intended. Sponsored by: Google LLC (GSoC 2024) Signed-off-by: Isaac Cilia Attard <icattard@FreeBSD.org> MFC after: 10 days Reviwed by: cperciva, brooks, Tom Hukins, Alexander Ziaee Pull Request: #1368 (cherry picked from commit 16a235f)
Use the new add_timeout_timespec() API to handle timeouts for state_selecting within dhclient.c. No functional change intended. Sponsored by: Google LLC (GSoC 2024) Signed-off-by: Isaac Cilia Attard <icattard@FreeBSD.org> MFC after: 10 days Reviwed by: cperciva, brooks, Tom Hukins, Alexander Ziaee Pull Request: #1368 (cherry picked from commit 76e0ffd)
Change the use of time() to clock_gettime() to have millisecond-accurate rather than second-accurate timeouts. Sponsored by: Google LLC (GSoC 2024) Signed-off-by: Isaac Cilia Attard <icattard@FreeBSD.org> MFC after: 10 days Reviwed by: cperciva, brooks, Tom Hukins, Alexander Ziaee Pull Request: #1368 (cherry picked from commit f0a3897)
Make arp_timeout available to dhclient.c, set the default timeout to 250 ms, and provide a new command-line argument, 'n' for setting the timeout to 0. Sponsored by: Google LLC (GSoC 2024) Signed-off-by: Isaac Cilia Attard <icattard@FreeBSD.org> MFC after: 10 days Reviwed by: cperciva, brooks, Tom Hukins, Alexander Ziaee Pull Request: #1368 (cherry picked from commit b51569a)
Introduce a new rc.conf option to not wait for ARP resolution within dhclient. This is plausible on many modern networks where it is possible to trust the DHCP server to know whether an IP address is available. Sponsored by: Google LLC (GSoC 2024) Signed-off-by: Isaac Cilia Attard <icattard@FreeBSD.org> MFC after: 10 days Reviwed by: cperciva, brooks, Tom Hukins, Alexander Ziaee Pull Request: #1368 (cherry picked from commit 503adcd)
Add new dhclient_arpwait option to rc.conf.5, with information about what it does, and cases in which it could be disabled. Sponsored by: Google LLC (GSoC 2024) Signed-off-by: Isaac Cilia Attard <icattard@FreeBSD.org> MFC after: 10 days Reviwed by: cperciva, brooks, Tom Hukins, Alexander Ziaee Pull Request: #1368 (cherry picked from commit e4482bf)
Introduce a new function, add_timeout_timespec(), to use timespec structs to handle timeouts. Make add_timeout() into a wrapper for the latter function to retain compatibility with the rest of the codebase. No functional change intended. Sponsored by: Google LLC (GSoC 2024) Signed-off-by: Isaac Cilia Attard <icattard@FreeBSD.org> MFC after: 10 days Reviwed by: cperciva, brooks, Tom Hukins, Alexander Ziaee Pull Request: #1368 (cherry picked from commit 16a235f)
Use the new add_timeout_timespec() API to handle timeouts for state_selecting within dhclient.c. No functional change intended. Sponsored by: Google LLC (GSoC 2024) Signed-off-by: Isaac Cilia Attard <icattard@FreeBSD.org> MFC after: 10 days Reviwed by: cperciva, brooks, Tom Hukins, Alexander Ziaee Pull Request: #1368 (cherry picked from commit 76e0ffd)
Change the use of time() to clock_gettime() to have millisecond-accurate rather than second-accurate timeouts. Sponsored by: Google LLC (GSoC 2024) Signed-off-by: Isaac Cilia Attard <icattard@FreeBSD.org> MFC after: 10 days Reviwed by: cperciva, brooks, Tom Hukins, Alexander Ziaee Pull Request: #1368 (cherry picked from commit f0a3897)
Make arp_timeout available to dhclient.c, set the default timeout to 250 ms, and provide a new command-line argument, 'n' for setting the timeout to 0. Sponsored by: Google LLC (GSoC 2024) Signed-off-by: Isaac Cilia Attard <icattard@FreeBSD.org> MFC after: 10 days Reviwed by: cperciva, brooks, Tom Hukins, Alexander Ziaee Pull Request: #1368 (cherry picked from commit b51569a)
Introduce a new rc.conf option to not wait for ARP resolution within dhclient. This is plausible on many modern networks where it is possible to trust the DHCP server to know whether an IP address is available. Sponsored by: Google LLC (GSoC 2024) Signed-off-by: Isaac Cilia Attard <icattard@FreeBSD.org> MFC after: 10 days Reviwed by: cperciva, brooks, Tom Hukins, Alexander Ziaee Pull Request: #1368 (cherry picked from commit 503adcd)
Add new dhclient_arpwait option to rc.conf.5, with information about what it does, and cases in which it could be disabled. Sponsored by: Google LLC (GSoC 2024) Signed-off-by: Isaac Cilia Attard <icattard@FreeBSD.org> MFC after: 10 days Reviwed by: cperciva, brooks, Tom Hukins, Alexander Ziaee Pull Request: #1368 (cherry picked from commit e4482bf)
Introduce a new function, add_timeout_timespec(), to use timespec structs to handle timeouts. Make add_timeout() into a wrapper for the latter function to retain compatibility with the rest of the codebase. No functional change intended. Sponsored by: Google LLC (GSoC 2024) Signed-off-by: Isaac Cilia Attard <icattard@FreeBSD.org> MFC after: 10 days Reviwed by: cperciva, brooks, Tom Hukins, Alexander Ziaee Pull Request: freebsd/freebsd-src#1368
Use the new add_timeout_timespec() API to handle timeouts for state_selecting within dhclient.c. No functional change intended. Sponsored by: Google LLC (GSoC 2024) Signed-off-by: Isaac Cilia Attard <icattard@FreeBSD.org> MFC after: 10 days Reviwed by: cperciva, brooks, Tom Hukins, Alexander Ziaee Pull Request: freebsd/freebsd-src#1368
Change the use of time() to clock_gettime() to have millisecond-accurate rather than second-accurate timeouts. Sponsored by: Google LLC (GSoC 2024) Signed-off-by: Isaac Cilia Attard <icattard@FreeBSD.org> MFC after: 10 days Reviwed by: cperciva, brooks, Tom Hukins, Alexander Ziaee Pull Request: freebsd/freebsd-src#1368
Make arp_timeout available to dhclient.c, set the default timeout to 250 ms, and provide a new command-line argument, 'n' for setting the timeout to 0. Sponsored by: Google LLC (GSoC 2024) Signed-off-by: Isaac Cilia Attard <icattard@FreeBSD.org> MFC after: 10 days Reviwed by: cperciva, brooks, Tom Hukins, Alexander Ziaee Pull Request: freebsd/freebsd-src#1368
Document new n flag for disabling ARP resolution within dhclient. Sponsored by: Google LLC (GSoC 2024) Signed-off-by: Isaac Cilia Attard <icattard@FreeBSD.org> MFC after: 10 days Reviwed by: cperciva, brooks, Tom Hukins, Alexander Ziaee Pull Request: freebsd/freebsd-src#1368
Introduce a new rc.conf option to not wait for ARP resolution within dhclient. This is plausible on many modern networks where it is possible to trust the DHCP server to know whether an IP address is available. Sponsored by: Google LLC (GSoC 2024) Signed-off-by: Isaac Cilia Attard <icattard@FreeBSD.org> MFC after: 10 days Reviwed by: cperciva, brooks, Tom Hukins, Alexander Ziaee Pull Request: freebsd/freebsd-src#1368
Add new dhclient_arpwait option to rc.conf.5, with information about what it does, and cases in which it could be disabled. Sponsored by: Google LLC (GSoC 2024) Signed-off-by: Isaac Cilia Attard <icattard@FreeBSD.org> MFC after: 10 days Reviwed by: cperciva, brooks, Tom Hukins, Alexander Ziaee Pull Request: freebsd/freebsd-src#1368
Introduce a new function, add_timeout_timespec(), to use timespec structs to handle timeouts. Make add_timeout() into a wrapper for the latter function to retain compatibility with the rest of the codebase. No functional change intended. Sponsored by: Google LLC (GSoC 2024) Signed-off-by: Isaac Cilia Attard <icattard@FreeBSD.org> MFC after: 10 days Reviwed by: cperciva, brooks, Tom Hukins, Alexander Ziaee Pull Request: freebsd/freebsd-src#1368
Use the new add_timeout_timespec() API to handle timeouts for state_selecting within dhclient.c. No functional change intended. Sponsored by: Google LLC (GSoC 2024) Signed-off-by: Isaac Cilia Attard <icattard@FreeBSD.org> MFC after: 10 days Reviwed by: cperciva, brooks, Tom Hukins, Alexander Ziaee Pull Request: freebsd/freebsd-src#1368
Change the use of time() to clock_gettime() to have millisecond-accurate rather than second-accurate timeouts. Sponsored by: Google LLC (GSoC 2024) Signed-off-by: Isaac Cilia Attard <icattard@FreeBSD.org> MFC after: 10 days Reviwed by: cperciva, brooks, Tom Hukins, Alexander Ziaee Pull Request: freebsd/freebsd-src#1368
Make arp_timeout available to dhclient.c, set the default timeout to 250 ms, and provide a new command-line argument, 'n' for setting the timeout to 0. Sponsored by: Google LLC (GSoC 2024) Signed-off-by: Isaac Cilia Attard <icattard@FreeBSD.org> MFC after: 10 days Reviwed by: cperciva, brooks, Tom Hukins, Alexander Ziaee Pull Request: freebsd/freebsd-src#1368
Document new n flag for disabling ARP resolution within dhclient. Sponsored by: Google LLC (GSoC 2024) Signed-off-by: Isaac Cilia Attard <icattard@FreeBSD.org> MFC after: 10 days Reviwed by: cperciva, brooks, Tom Hukins, Alexander Ziaee Pull Request: freebsd/freebsd-src#1368
Introduce a new rc.conf option to not wait for ARP resolution within dhclient. This is plausible on many modern networks where it is possible to trust the DHCP server to know whether an IP address is available. Sponsored by: Google LLC (GSoC 2024) Signed-off-by: Isaac Cilia Attard <icattard@FreeBSD.org> MFC after: 10 days Reviwed by: cperciva, brooks, Tom Hukins, Alexander Ziaee Pull Request: freebsd/freebsd-src#1368
Add new dhclient_arpwait option to rc.conf.5, with information about what it does, and cases in which it could be disabled. Sponsored by: Google LLC (GSoC 2024) Signed-off-by: Isaac Cilia Attard <icattard@FreeBSD.org> MFC after: 10 days Reviwed by: cperciva, brooks, Tom Hukins, Alexander Ziaee Pull Request: freebsd/freebsd-src#1368
Make the default ARP resolution wait time 250 ms, and add an option within dhclient to remove it altogether.