3d0f46580aoptions.c: Add an add_option_clientid() variant for ndhs to use, and silence an unused function warning that triggers when compiling ndhs.
Nicholas J. Kain
2014-03-18 01:51:58 -04:00
742baf6d7bget_end_option_idx() has a useless conditional that always evaluates to the same value. Remove it, and introduce a slightly less useless conditional that prevents a possible one-byte-read past the end of packet.
Nicholas J. Kain
2014-03-18 01:38:58 -04:00
e8687ba29fMake validate_dhcp_packet()'s magic cookie length check clearer by using offsetof().
Nicholas J. Kain
2014-03-18 01:36:14 -04:00
0e12b4620bCosmetic cleanups.
Nicholas J. Kain
2014-03-17 22:58:55 -04:00
128dbfba21Remove ifch_proto.h.
Nicholas J. Kain
2014-03-17 22:20:32 -04:00
1e2c40eb81Functions don't need explicit extern linkage in headers in C99, as it is the default. Standardize on leaving out the extern keyword as it is less clutter.
Nicholas J. Kain
2014-03-17 22:10:58 -04:00
3f267576acUse RTA_DATA() instead of rtattr_get_data().
Nicholas J. Kain
2014-03-17 20:28:26 -04:00
f7de4a14fdUse NLMSG_DATA() instead of nlmsg_get_data().
Nicholas J. Kain
2014-03-17 20:26:37 -04:00
a052d069b7nlattr was being used where rtattr should have been used. Happily, the types are almost identical (same number of fields, each field has the same length), so the code worked anyway, but nlattr and rtattr are distinct.
Nicholas J. Kain
2014-03-17 20:22:20 -04:00
8416d5a633Make nl.c:nl_rtattr_parse() use the standard NLMSG_* and RTA_* macros. It's easier to verify correct behavior this way.
Nicholas J. Kain
2014-03-17 20:02:22 -04:00
268e88dc24Make nl_getifdata() use a netlink sequence number generated from the tv_nsec field from clock_gettime(CLOCK_REALTIME), and actually check that the sequence number matches that of the netlink replies.
Nicholas J. Kain
2014-03-17 06:15:59 -04:00
6460346bb6Fix the NLMSG_LENGTH() arguments in nl.c. Somehow it worked before by lucky coincidence, but the types provided to the sizeof were wrong.
Nicholas J. Kain
2014-03-17 06:14:14 -04:00
22fede861fNetlink is pickier than the ioctl interfaces and requires the link to manually be set to an 'up' state before much of anything can be changed. Ensure that this is done very early in ndhc's lifetime, and record the link status at startup time so that the hardware link status monitoring will not get confused. A perform_ifup() function is added to faciliate this need.
Nicholas J. Kain
2014-03-17 05:56:30 -04:00
13aa5e6403Remove some commented-out debugging code.
Nicholas J. Kain
2014-03-17 05:43:31 -04:00
3de2f42f4cIf we get a NLMSG_DONE in response to trying to delete the existing ip addresses associated with a link, then there are no existing ip addresses to delete; don't print an error in this case.
Nicholas J. Kain
2014-03-17 05:41:48 -04:00
83610972c3If link_(un|)set_flags() does not need to change the existing flags to satisfy the request, then return 1 rather than 0 and do not ask netlink to perform any changes.
Nicholas J. Kain
2014-03-17 05:35:34 -04:00
b0a5132d72Cosmetic cleanups to ifchd.c. No functional change.
Nicholas J. Kain
2014-03-17 05:33:00 -04:00
3e78ffd576We don't need to disable hardware link status while ifch is working; if the link status goes down, we will fail horribly anyway because ARP will fail, so we must keep track of the link status to be safe.
Nicholas J. Kain
2014-03-17 03:17:24 -04:00
03bd10ed88When setting the MTU via netlink, we must be careful to preserve the link flags or bad things will happen (such as the link being set down).
Nicholas J. Kain
2014-03-17 03:16:02 -04:00
6fcc43d169Hardware link status can 'bounce' erratically while link properties are being updated, so perform status debouncing.
Nicholas J. Kain
2014-03-17 02:55:47 -04:00
d8e3dc61eaMake the netlink link flags and router setting code work properly.
Nicholas J. Kain
2014-03-17 02:07:30 -04:00
d2f413d46eUpdate log prints in nl.c.
Nicholas J. Kain
2014-03-16 23:39:41 -04:00
3220cb90acUse recvmsg rather than recv in ifset.c.
Nicholas J. Kain
2014-03-16 23:39:24 -04:00
1ff3adef3aUpdate documentation and remove unused ioctl.h header.
Nicholas J. Kain
2014-03-16 21:16:06 -04:00
8a24f74a11Use netlink when setting the default ipv4 gateway.
Nicholas J. Kain
2014-03-16 21:05:50 -04:00
9de62e7b75Use netlink when setting the link MTU.
Nicholas J. Kain
2014-03-16 18:07:09 -04:00
987bffe157Clean up some error prints in ifset.c.
Nicholas J. Kain
2014-03-16 18:06:42 -04:00
50d6284feeUse netlink for setting link flags instead of ioctl.
Nicholas J. Kain
2014-03-16 05:10:21 -04:00
cce93139d0Delete old IP addresses associated with the interface when setting the DHCP-assigned IP, broadcast, and subnet.
Nicholas J. Kain
2014-03-15 04:43:29 -04:00
7bf1cc419enl_recv_buf() must be non-blocking; enforce it with the MSG_DONTWAIT flag. At the same time, properly handle EINTR.
Nicholas J. Kain
2014-03-15 04:35:07 -04:00
7627298c07The ip4 protocol change broke on the send side; fix it by explicitly zeroing the send buffer. It's less finicky than special-casing the ip4 command to use strnkcpy instead of strnkcat.
Nicholas J. Kain
2014-03-15 04:32:44 -04:00
19d009891aWhen updating the IP and broadcast addresses, clear out any old IP and broadcast addresses that may be still bound to the interface.
Nicholas J. Kain
2014-03-15 02:44:43 -04:00
4d1cfe8586Add a nl_sendgetaddr() function.
Nicholas J. Kain
2014-03-15 00:30:39 -04:00
e5d9f4acf2Move nl_sendgetlink() to nl.c.
Nicholas J. Kain
2014-03-14 23:54:21 -04:00
180ee36626Update plain Makefile and README.
Nicholas J. Kain
2014-03-14 23:51:11 -04:00
8faae4a0fdCheck that the return message type is not NLMSG_ERROR when setting the ip and broadcast addresses.
Nicholas J. Kain
2014-03-14 23:28:56 -04:00
6a9e8c5a57Disable seccomp-filter unless ENABLE_SECCOMP_FILTER is defined.
Nicholas J. Kain
2014-03-14 23:24:22 -04:00
3af0a7824dsubnet4_to_prefixlen() should use ntohl().
Nicholas J. Kain
2014-03-14 23:22:23 -04:00
b6444fa806Don't strip the generated executables by default.
Nicholas J. Kain
2014-03-14 20:49:03 -04:00
312884dfc5When execute_buffer() is passed an invalid command, print the bad command when logging the error.
Nicholas J. Kain
2014-03-14 20:48:33 -04:00
4afddd471aThe getopt_long shortarg string needed a ':' after 'C' as it has a mandatory argument.
Nicholas J. Kain
2014-03-14 20:47:57 -04:00
fbe6d36b6bFix the ip4 ragel parser.
Nicholas J. Kain
2014-03-14 20:46:40 -04:00
971c6085d8ifchd.c: If resolv_conf_fd < 0, it is invalid. -1 is the explicit uninitialized value, but there is no need to limit the guard to -1.
Nicholas J. Kain
2014-03-12 20:58:27 -04:00
f4a2a487d6Mark more function prototypes as extern.
Nicholas J. Kain
2014-03-12 20:55:35 -04:00
4feac2ea35Rename ifchd_cmd_str() to ifchd_cmd_bytes() as it can handle byte sequences without a terminating nul.
Nicholas J. Kain
2014-03-12 20:47:39 -04:00
73ad3b1419Mark external function prototypes in state.h as extern.
Nicholas J. Kain
2014-03-12 20:39:55 -04:00
c81e9f9a28Merge config.h into ndhc.h.
Nicholas J. Kain
2014-03-12 17:05:43 -04:00
84a68001d3Use a unified epoll_(add|del)().
Nicholas J. Kain
2014-03-12 16:51:10 -04:00
94a923b00aClean up and centralize stray external prototypes into headers.
Nicholas J. Kain
2014-03-12 16:24:02 -04:00
2afd963ad0ifchd.c: resolv_conf_fd can be static.
Nicholas J. Kain
2014-03-12 16:14:48 -04:00
b9a30f0653Move external definitions of functions in ifchd.c to ifchd.h instead of defining them manually in ndhc.c.
Nicholas J. Kain
2014-03-12 16:13:47 -04:00
9bf79b6034Update the nk_random calls to use the new re-entrant-safe API.
Nicholas J. Kain
2014-03-12 15:41:34 -04:00
54a7f54a4aMove add_rtattr() from ifset.c to nl.c as nl_add_rtatr().
Nicholas J. Kain
2014-03-12 15:25:07 -04:00
1222f4f22aHandle sendto() returning EINTR in nl_sendgetlink(), and print if an error is encountered while performing sendto().
Nicholas J. Kain
2014-03-12 15:14:40 -04:00
b7b353acdcStore the interface index in the client_config before forking off the subprocesses. ndhc-ifch can then use the stored interface index when setting the interface ip/subnet/broadcast via netlink instead of having to use ioctl to re-fetch the interface index.
Nicholas J. Kain
2014-03-12 15:07:37 -04:00
80f82c2451options.c: Don't trust the options length field in do_get_dhcp_opt() to not be longer than the total option length.
Nicholas J. Kain
2014-03-12 13:30:55 -04:00
765f3de274Use strncmp rather than strcmp in netlink.c when fetching the interface MAC address and index.
Nicholas J. Kain
2014-03-12 13:03:34 -04:00
fac6794b6cHandle SIGPIPE and SIGCHLD.
Nicholas J. Kain
2014-03-12 12:47:39 -04:00
be456ddeeeUse the ncmlib combined Tausworthe PRNG.
Nicholas J. Kain
2014-03-12 12:47:04 -04:00
c0fc3ed430Silence the last few new warnings.
Nicholas J. Kain
2014-03-10 23:00:57 -04:00
84b36f0e02Remove -Wcast-qual. The warnings are not useful on the ndhc code, and I would effectively end up silencing them via the (uintptr_t) casting hack.
Nicholas J. Kain
2014-03-10 22:56:01 -04:00
eaa8f2fcb2Fix warnings for state.c.
Nicholas J. Kain
2014-03-10 19:44:37 -04:00
151ed60de1Fix warnings in leasefile.c.
Nicholas J. Kain
2014-03-10 19:42:52 -04:00
d18aff8fb0Fix warnings in ifchd.c.
Nicholas J. Kain
2014-03-10 19:40:38 -04:00
8a3b875119Fix warnings in ifset.c.
Nicholas J. Kain
2014-03-10 19:31:46 -04:00
eec497adf5Fix warnings in ifchd-parse.rl. Just needed function prototypes.
Nicholas J. Kain
2014-03-10 19:29:19 -04:00
e5c7493bc8Fix warnings in arp.c.
Nicholas J. Kain
2014-03-10 19:25:06 -04:00
e7838d542bFix the remaining signed/unsigned comparison warnings. Nothing stands out as being dangerous or buggy.
Nicholas J. Kain
2014-03-10 19:00:08 -04:00
e50bd431d6dhcp.c: handle_packet() calls get_(raw|cooked)_packet(), which returns a signed value where values <0 are errors and >= 0 are lengths. Convert to an unsigned length value if the return is a length.
Nicholas J. Kain
2014-03-10 18:58:53 -04:00
85fcc1e8f0Use stricter gcc warning flags by default.
Nicholas J. Kain
2014-03-10 18:34:53 -04:00
df0898dfb6Change the thread name of the various ndhc processes so that they can be identified via ps/top.
Nicholas J. Kain
2014-03-10 14:44:12 -04:00
47dbf3e24dRename dhcp-hostname cmdarg to dhcp-set-hostname.
Nicholas J. Kain
2014-03-10 14:43:37 -04:00
94d6b1fb2eThe 'ip', 'snet', and 'bcast' commands have been replaced by 'ip4'. Remove them.
Nicholas J. Kain
2014-03-10 01:13:38 -04:00
a130448d46Update the README.
Nicholas J. Kain
2014-03-10 01:09:25 -04:00
1824802fb2Merge ifchd into ndhc. Rather than function as entirely separate daemons, ndhc will fork off an ifchd child that it will communicate with via pipes rather than by connecting to a SO_PEERCRED AF_UNIX socket.
Nicholas J. Kain
2014-03-10 00:52:56 -04:00
06ff60bb6bMake ndhc use the new 'ip4' ifchd command.
Nicholas J. Kain
2014-03-09 13:57:37 -04:00
c4f09b1a9aUse the standard defines for ipv4 printable address max string length.
Nicholas J. Kain
2014-03-09 13:51:49 -04:00
d7ea5d9b0dAdd the 'ip4' command to the ifchd wire protocol.
Nicholas J. Kain
2014-03-09 12:33:20 -04:00
520ba6fd31Mark function prototypes in ifchd/linux.h as extern. Update copyright dates and do some cosmetic changes, too.
Nicholas J. Kain
2014-03-09 12:32:30 -04:00
06b65de08cAdd a perform_ip_subnet_bcast() function that uses Linux netlink sockets to set the interface ip, subnet, and broadcast address simultaneously.
Nicholas J. Kain
2014-03-09 09:46:05 -04:00
81a9fe1c8einet_pton() can return 0 or -1 as errors. We wern't likely to see -1 in practice (it's documented to be only emitted when inet_pton is provided an unrecognized address family), but best to be completely correct.
Nicholas J. Kain
2014-03-09 09:42:49 -04:00
3ef87c1f26ifchd: Make the command parser much more strict. It now has a concept of argument types and command types.
Nicholas J. Kain
2013-05-11 10:59:04 -04:00
62d69e1909Lists of IPs should be comma-separated rather than semicolon or space-separated.
Nicholas J. Kain
2013-05-10 13:46:58 -04:00
1fc06c6e4fifchd: Print NYI messages to log if we received a command where the handler is not yet implemented.
Nicholas J. Kain
2013-05-10 13:45:09 -04:00
cb261be045ndhc: Subnet option is an ip, not an iplist.
Nicholas J. Kain
2013-05-10 13:44:31 -04:00
bf3de7f310Teach the Makefile how to handle Ragel, too.
Nicholas J. Kain
2013-05-08 09:08:47 -04:00
6654ad1300ncmlib should be tracked as an external repo.
Nicholas J. Kain
2013-05-08 08:14:23 -04:00
3d6e3a2610Update the log file printing.
Nicholas J. Kain
2013-05-08 08:11:15 -04:00
4c52accd62Fix the syscall whitelist to permit syscalls needed to properly log via glibc syslog.
Nicholas J. Kain
2013-05-08 08:10:57 -04:00
f8773742c9ncmlib: Cosmetic cleanups to chroot.c.
Nicholas J. Kain
2013-05-08 06:58:55 -04:00
f78ea70d71Ifchd: Convert some tabs to spaces.
Nicholas J. Kain
2013-05-08 06:37:33 -04:00
3640c5bbf0Ifchd: Print out log messages when commands are successfully dispatched.
Nicholas J. Kain
2013-05-08 06:36:20 -04:00
b7e6f59fc7Use a Ragel-generated DFA parser for ifchd command dispatch.
Nicholas J. Kain
2013-05-08 06:27:22 -04:00
930b92a268Remove strlc(at|py).
Nicholas J. Kain
2013-05-06 07:32:02 -04:00
958a57d819Convert to using strnkc(at|py).
Nicholas J. Kain
2013-05-06 07:07:54 -04:00
7ab11e8295Add strnkcpy() and strnkcat(). These are similar to strlcpy and strlcat, but simply return a bool indicating whether the destination received a truncated copy of the source (true if truncation occurs else false).
Nicholas J. Kain
2013-05-06 07:06:33 -04:00
f807e10e76Make the ARP-based lease address collision checks configurable in delay times and number of probes.
Nicholas J. Kain
2013-02-09 00:30:19 -05:00
b8c77a45e8Bump ndhc version to 1.1.
Nicholas J. Kain
2012-07-23 13:24:15 -04:00
22e5a60671Drop packet fragments in the BPF program. No compliant stack should fragment DHCP messages anyway, since the IPv4 min MTU is 576 bytes and the max DHCP message size + IP and UDP headers is less than that, but it is still worth checking.
Nicholas J. Kain
2012-07-23 13:18:23 -04:00
483ca6752dWhitelist syscalls provided by vDSO.
Nicholas J. Kain
2012-07-22 09:49:51 -04:00