Commit Graph

533 Commits

Author SHA1 Message Date
Roy Marples
42c638c5d6 When running for a single interface, don't set WAITIP if we are
backgrounding immediatley.
2013-11-20 17:36:41 +00:00
Roy Marples
4873594f06 When releasing, we need to de-configure the interface as well. 2013-11-20 11:37:25 +00:00
Roy Marples
6f66c6c93f Change IAID to default from the last 4 bytes of the MAC address.
Rationale in the commit, but in a nutshell it allows for a stable
IAID between reboots without persistent storage and across
different OS's who name or number it differently to each other.
2013-11-15 16:44:46 +00:00
Roy Marples
ebc9d360fa Allow IAID to be configured in DHCPv4 clientid.
Use this as the default for DHCPv6 IA's as well.
Rename if_iaid to if_ia as it's really an IA containing an IAID.
2013-11-15 13:43:41 +00:00
Roy Marples
f796465a67 If we timeout, remove any waitip config so that we daemonise
correctly.
2013-10-05 16:28:33 +00:00
Roy Marples
7910de3282 We should abort if no specified interfaces are found. 2013-09-27 06:23:31 +00:00
Roy Marples
7e011222be Don't stop dev management on fork 2013-09-27 06:15:32 +00:00
Roy Marples
81ff1cbf91 Start dev after link for a more sane interface rename.
Only start dev in master mode.
2013-09-12 21:35:33 +00:00
Roy Marples
413652c1b3 Instead of linking directly to libudev, create a plugin system for /dev
management. This allows dhcpcd to work even if udev removed and adds the
ability to change from udev to something else in the future.
2013-09-12 15:43:20 +00:00
Roy Marples
7c3225083f Instead of just renaming the interface on Linux, take the FreeBSD
approach and remove the old and create a new one.
This simple change allows the the allow/deny rules to be followed.
2013-09-10 09:56:11 +00:00
Roy Marples
670118ad7f Fix compile warning on BSD 2013-09-09 23:09:29 +00:00
Roy Marples
1f88304a4e Fix interface renaming and carrier reporting when using udev 2013-09-09 20:22:12 +00:00
Roy Marples
50b52a2400 Fix initial carrier status 2013-09-05 13:27:52 +00:00
Roy Marples
7013b07382 Add 4 and 6 arguments to the waitip command so that you can specify
which protocols to wait for.
2013-08-31 16:48:39 +00:00
Roy Marples
15fc1181d5 Fix the persistent option. 2013-08-25 10:22:48 +00:00
Roy Marples
e82129a42c Reduce code size by merging IPv6 ND with RS. 2013-08-20 10:29:43 +00:00
Roy Marples
302025a6b9 Fix prior patch 2013-07-01 19:34:54 +00:00
Roy Marples
3566eb3cb5 Fix dhcpcd owning the RA if the kernel has disabled RA but there
is no directive in dhcpcd.conf
2013-07-01 19:23:19 +00:00
Roy Marples
ecf297d6c7 Detect link address changes on Linux.
Only NetBSD emits RTM_CHGADDR for link address changes.
Sadly no other BSD emits anything for link address changes so we have
to do a full discovery on carrier up.

When a link address does change, simply carry on as we are, no need
to drop any existing lease as the carrier change will do that for us.
2013-06-25 08:31:11 +00:00
Roy Marples
f164d58639 Arrived interfaces should share the same commandline options. 2013-06-19 10:06:54 +00:00
Roy Marples
a945c63ad9 Add a delay to initial Rebind IA_PD message.
Delay initial DHCPv6 messages a futher 2 seconds for POINTOPOINT links to
try and ensure dhcpcd receives a reply.
Process link events last so that dhcpcd can process any rejection messages.
When a delegating interface stops, the delegates addresses will be removed.
2013-06-18 09:17:28 +00:00
Roy Marples
6fb316a668 Fix a crash with departing interfaces.
Fix more needless spam when an interface departs.
2013-06-12 18:24:16 +00:00
Roy Marples
f127375eee Add a wpa_supplicant hook script.
This script starts wpa_supplicant on a wireless interface if not
already running and /etc/wpa_supplicant.conf exists, stops it
when the interface departs and sends wpa_supplicant a reconfigure
command.

If dhcpcd is running in master mode, you can use `dhcpcd -n eth0'
it instruct wpa_supplicant to reload its configuration file.
2013-06-07 20:03:28 +00:00
Roy Marples
336dd1b83b Move signal handling into dhcpcd.c
Log the PID of the signal caller
Move syslog functions out of the signal handler if we're not
exiting as it's not safe.
Close existing IPv4 sockets when restarting an interface.
Fix control handling keeping current flags and accepting new ones.
2013-06-07 12:44:19 +00:00
Roy Marples
f2e8e5175d Don't log carrier lost if carrier was UNKNOWN. 2013-06-06 18:39:12 +00:00
Roy Marples
ce289a66fa Add DEPARTED reason for when an interface is removed. 2013-06-06 12:38:15 +00:00
Roy Marples
2bf02a2b0b Don't assume the kernel will remove or mark tentative LL addresses.
This isn't a problem as we listen to IPv6 address changes.
2013-06-03 06:49:34 +00:00
Roy Marples
e74fdc60d4 In the event DHCPv6 is started without IPv6RS, we should wait for
a LL address to appear.
Also, use DH6S_INIT or DH6S_INFORM to dhcp6_start instead of 0 or
1 for clarity.
2013-05-30 22:39:17 +00:00
Roy Marples
fefc5353f3 Use LINK_UP/DOWN instead of magic numbers 2013-05-30 07:51:02 +00:00
Roy Marples
c5d2e393a5 Move SIOCGIFAFLAG_IN6 into if-bsd as in6_addr_flags
Add pfx_flush to flush ND6 entries when changing routes.
Both these functions only work for BSD, just stubs on Linux.

This tidies the code a little and fixes changing IPv6 routes on BSD,
although the kernel may complain network is down for a few moments.
2013-05-30 05:38:21 +00:00
Roy Marples
7afd1fdfb0 Comment on why we don't solicit dhcpv6 without an RA to instruct us. 2013-05-24 09:08:23 +00:00
Roy Marples
6e7265d527 Don't directly close stderr 2013-05-23 18:58:28 +00:00
Roy Marples
5331b839c9 Store IPv6 link local addresses per interface.
Listen to kernel messages to account them.
If we don't have a local link address, delay IPv6RS as it just
won#t work until we have a local link address.
2013-05-17 23:09:36 +00:00
Roy Marples
a8df1b28fb Use the kernel DAD for IPv6 addresses and finish the action once each
address DAD completes. BSD kernels will require a patch as noted within
the README. The linux netlink part still needs to be written.
2013-05-15 10:27:36 +00:00
Roy Marples
3491ea4d56 Change from _unused to __unused to match NetBSD cdefs and avoid
a compiler failure on linux-headers-3.7
2013-04-24 09:38:18 +00:00
Roy Marples
b3d908a6b0 Move dhcp_release into dhcp_drop 2013-04-04 23:57:12 +00:00
Roy Marples
66cf1d5db5 Don't crash when disabling IPv6 2013-04-04 23:25:31 +00:00
Roy Marples
8cc47ba26d White space police 2013-04-04 20:31:04 +00:00
Roy Marples
673e81e5b7 White space brigade 2013-04-02 07:01:11 +00:00
Roy Marples
00ababe4a0 Add DHCPv6 Prefix Delegation support, RFC3633.
Add DHCPv6 Temporary Address support, RFC3315.
2013-04-01 12:15:47 +00:00
Roy Marples
891ca6fad3 Fix rebooting. 2013-03-26 10:42:30 +00:00
Roy Marples
51a9a12419 Avoid a potential malloc when handling signals. 2013-03-26 08:51:34 +00:00
Roy Marples
92398db794 Move IPv6 RA checking and disabling kernel RA higher up the chain. 2013-02-19 16:05:12 +00:00
Roy Marples
53dae786ec Fix a crash. 2013-02-19 15:43:29 +00:00
Roy Marples
4c9c4b3ea0 Use TAILQ macros for IPv4 routes. 2013-02-19 15:23:53 +00:00
Roy Marples
4b0cbc8974 Use a TAILQ macro for our interface list. 2013-02-19 13:37:42 +00:00
Roy Marples
e6d2517562 Rework our signal setup and event loop around ppoll(2).
ppoll is mapped to pollts(2) for supporting systems.
If pselect(2) is available then we provide a compat shim for that, otherwise
we provide a non race free shim based on poll(2).
2013-02-18 20:56:55 +00:00
Roy Marples
cf6d21215b Restore our signal pipe so that we process signals in our event loop
as we use a lot of functions which are not safe according to signal(7).
2013-02-18 15:40:56 +00:00
Roy Marples
a54116c1c6 Move the signal reboot code into it's own function which is fired by
and eloop timeout of 0 seconds. We do this because we shouldn't modify
variables in a signal handler.
2013-02-18 10:35:47 +00:00
Roy Marples
28382337e1 Remove the xmalloc function.
Now we have removed all our xmalloc like functions dhcpcd can still
try to operate as best it can in low memory conditions.
2013-02-16 13:21:35 +00:00
Roy Marples
10e17e3f63 Remove xzalloc function 2013-02-15 21:45:08 +00:00
Roy Marples
fbbb0875dd Instead of opening link, ipv6, ipv6rs and ipv6ns sockets globally,
only open when the first link wanting this features needs it.
Hopefully fixes #263 and #264.
2013-02-15 20:33:13 +00:00
Roy Marples
68ceb7004a Fix compile on BSD 2013-02-04 14:12:48 +00:00
Roy Marples
aae24feb3d It's now possible to compile out IPv4 and IPv6 support by passing
--disable-ipv4 or --disable-ipv6 to configure.
2013-02-04 13:30:35 +00:00
Roy Marples
e88c525f50 Move ipv4 specific code out of net.c and into ipv4.c 2013-02-04 11:03:08 +00:00
Roy Marples
95fdd136ae Move if_state into interface->if_data as dhcp_state.
This should reduce memory usage for non IPv4 interfaces.
2013-02-03 22:55:45 +00:00
Roy Marples
5dc65f77b3 Move ipv4 specific infos from interface to if_state. 2013-02-03 14:52:24 +00:00
Roy Marples
875979f614 Move options away from ipv4 state to the interface. 2013-02-03 10:35:59 +00:00
Roy Marples
294eff4df4 Remove IPv4 and DHCP4 specific setup from dhcpcd.c and move into ipv4.c
and dhcp.c
Split configure.c into script.c and move the rest into dhcp.c

This starts the goal of making the base of dhcpcd protocol agnostic and
working towards building IPv4 and/or IPv6 code only to reduce size and
allow growing any future new protocol easier.
2013-02-02 14:05:55 +00:00
Roy Marples
3083087ccb Log error whe starting DHCPv6 without RA. 2012-12-07 09:46:49 +00:00
Roy Marples
dcec32683d If no IPv6 proc or sysctl entries exist for RA or forward, assume it's OK. 2012-12-07 09:43:56 +00:00
Roy Marples
4123fdf910 Normalise timing 2012-11-13 20:40:04 +00:00
Roy Marples
760780dd5c Use a proper namespace for IPv4LL 2012-11-13 11:44:20 +00:00
Roy Marples
9eb6e8dc94 Use a proper namespace for eloop 2012-11-13 11:25:51 +00:00
Roy Marples
e749a9ee95 Use a proper namespace for control 2012-11-13 10:17:19 +00:00
Roy Marples
94582a4d23 Expire the DHCPv6 lease when carrier drops. 2012-11-11 19:56:01 +00:00
Roy Marples
5c08c0c4ca Replace poll(2) with pselect(2) and vfork(2)+execve(2) with
posix_spawn(3).
Now we block all our signals at startup and allow pselect to
unblock them for the duration of the call. This allows us to
manage interrupts in a fashion to guarantee a consistent
internal state.

I have added a posix_spawn compat shim for systems that lack
that call. pselect(2) has been supported on target for some time
so there is no need for a compat shim there.
2012-11-10 16:38:52 +00:00
Roy Marples
599c9aeb6b Add a message to indicate dhcpcd exited cleanly. 2012-11-10 08:44:48 +00:00
Roy Marples
e54dee19ba Implement the core DHCPv6 client for SOLICIT, REQUEST, RENEW, CONFIRM. 2012-11-06 23:40:15 +00:00
root@uberpc.marples.name
930c51ad33 Fix some more potential leaks and allow full build with dmalloc. 2012-11-01 17:02:01 +00:00
Roy Marples
fccffbd9cf Plug some memory leaks. 2012-11-01 14:46:05 +00:00
Roy Marples
225624555b Improve reported timings. 2012-10-27 12:11:04 +00:00
Roy Marples
8c48758ad5 Show renew and rebind times when debugging is enabled.
Trying to help #259.
2012-10-27 11:38:17 +00:00
Roy Marples
652b80c8a9 Drop DHCPv6 on carrier down.
Send DHCPv6 interface information.
2012-10-12 19:10:04 +00:00
Roy Marples
f29cbe614f Fix code for -Wstrict-overflow 2012-10-12 11:26:20 +00:00
Roy Marples
d7555c1259 Add DHCPv6 INFORM support.
This is automatically started when RA flags O is set.
If no DHCPv6 request options are configured in dhcpcd.conf then we
request domain servers and search lists.
2012-10-12 10:31:51 +00:00
Roy Marples
27805e96f6 Move the default vendor string to a global variable.
When an interface starts, it assigns this by default instead of
generating it each time.
2012-10-09 13:20:50 +00:00
Roy Marples
56e106a774 Fix DUID support.
In the case where we cannot write a DUID file, then create a LL ID
instead of a LLT ID.
2012-10-09 13:14:56 +00:00
Roy Marples
f7d18e2ceb xid should be treated in network byte order 2012-10-08 16:13:47 +00:00
Roy Marples
0b0b417782 Restart the interface immediately after a NAK instead of
waiting one second.
2012-09-22 13:28:34 +00:00
Roy Marples
701b840fc4 Remove -v from --version in usage. 2012-08-18 13:58:53 +00:00
Roy Marples
8ce6389572 If we fail to open sockets, don't bother sending the request. 2012-08-06 10:24:13 +00:00
Roy Marples
bde566f574 Disable kernel interface RA as early as possible on Linux.
Don't add duplicate interfaces to the restore kernel RA on Linux.
2012-07-13 08:22:04 +00:00
Roy Marples
eebe9a1887 Improve IPv6 RA support by allowing dhcpcd to manage the address and routes
instead of the kernel. dhcpcd will only do this if RA is disabled in the kernel
or dhcpcd has been instructed to do this via dhcpcd.conf(5) ipv6ra_own and
ipv6ra_own_default directives.

Send and process IPv6 Neighbor Solicitions and Adverts to prove router
reachability. If a router cannot be reached in this way then it is expired.

When debugging, all ND messages are displayed which will create a lot of log
spam.

To ease packaging, ./configure now accepts LDFLAGS and --enable-static.
2012-07-05 16:37:41 +00:00
Roy Marples
248cf0d859 Remove unused variables 2012-04-01 07:38:52 +00:00
Roy Marples
2c77247bd0 Interface index should persist and be unique for the interface lifetime.
As such, store it at discover and stop using if_nametoindex(3).
2012-03-30 09:37:21 +00:00
roy@uberlaptop.marples.name
6b2a61c053 When sending signals, respect the interface it was started on. 2012-03-27 16:47:43 +00:00
Roy Marples
b5de3cec6a Fix Dd and Dt arguments.
New sentence, new line.
Sort options and option descriptions.
Sort SEE ALSO.
Use Fl Fl for long options.
Sync the usage output by the program with the one from the man page.
Thanks to Thomas Klausner.
2012-03-24 10:41:40 +00:00
Roy Marples
5e084fac90 If no ClientID or hardware address, don't report a blank hardware address. 2012-03-20 09:18:20 +00:00
Roy Marples
61dd6cf9ab Add an option to control dhcpcd forking or not if the RA does not contain
a RDNSS option.
This involves changing our options to an unsigned long long so we can use
more than 32 bits.
2012-03-07 10:06:45 +00:00
Roy Marples
d705c979f0 Respect an accept_ra setting of 2, fixes #240.
Detect IPv6 settings per interface if the platform allows, fixed #241.
2012-03-05 10:04:26 +00:00
Roy Marples
832efb4abf Stop checking for IFF_RUNNING in handle_carrier as it is invalid for BSD
and should already have been checked for Linux.
2012-02-05 19:32:17 +00:00
roy@uberlaptop.marples.name
441b06bc38 If the kernel is not configured to accept IPv6 or RA's then don't
needless attempt to solicit an IPv6 RA.
2012-02-04 15:15:25 +00:00
Roy Marples
449df9c859 Fix some more copyrights
RA expiry timers now trigger off options as well
Stop prefixing new_ for RA options
if_up and if_down are now set by dhcpcd itself
Correctly prefer a DHCP lease over an IPv4LL entry
2012-02-02 16:22:40 +00:00
Roy Marples
7ae411d942 Fix more copyright 2012-01-31 09:51:12 +00:00
Roy Marples
e0c4d1587d Allow dhcpcd to run on a read-only filesystem.
You'll get a lot of errors, but you will get a working address and routing.
2012-01-29 17:28:05 +00:00
Roy Marples
70b967d7d7 Remove the RA's before reporting no carrier. 2012-01-29 16:49:04 +00:00
Roy Marples
0c6ad78288 Don't start IPv6 if it's disabled globally. 2012-01-29 16:32:06 +00:00
Roy Marples
29fe5ed6a4 Just log the fact that the leased IP address was removed instead of
expiring the lease. This allows --reconfigure, -g to fully work as
intended.
2011-12-18 12:12:08 +00:00
Roy Marples
1c657b0883 Stop the --reconfigure, -g option from spinning needlessly.
Thanks to Mike Crowe.
2011-12-18 12:11:08 +00:00