Commit Graph

  • 3d0f46580a options.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 -0400
  • 742baf6d7b get_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 -0400
  • e8687ba29f Make validate_dhcp_packet()'s magic cookie length check clearer by using offsetof(). Nicholas J. Kain 2014-03-18 01:36:14 -0400
  • 0e12b4620b Cosmetic cleanups. Nicholas J. Kain 2014-03-17 22:58:55 -0400
  • 128dbfba21 Remove ifch_proto.h. Nicholas J. Kain 2014-03-17 22:20:32 -0400
  • 1e2c40eb81 Functions 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 -0400
  • 3f267576ac Use RTA_DATA() instead of rtattr_get_data(). Nicholas J. Kain 2014-03-17 20:28:26 -0400
  • f7de4a14fd Use NLMSG_DATA() instead of nlmsg_get_data(). Nicholas J. Kain 2014-03-17 20:26:37 -0400
  • a052d069b7 nlattr 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 -0400
  • 8416d5a633 Make 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 -0400
  • 268e88dc24 Make 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 -0400
  • 6460346bb6 Fix 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 -0400
  • 22fede861f Netlink 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 -0400
  • 13aa5e6403 Remove some commented-out debugging code. Nicholas J. Kain 2014-03-17 05:43:31 -0400
  • 3de2f42f4c If 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 -0400
  • 83610972c3 If 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 -0400
  • b0a5132d72 Cosmetic cleanups to ifchd.c. No functional change. Nicholas J. Kain 2014-03-17 05:33:00 -0400
  • 3e78ffd576 We 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 -0400
  • 03bd10ed88 When 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 -0400
  • 6fcc43d169 Hardware link status can 'bounce' erratically while link properties are being updated, so perform status debouncing. Nicholas J. Kain 2014-03-17 02:55:47 -0400
  • d8e3dc61ea Make the netlink link flags and router setting code work properly. Nicholas J. Kain 2014-03-17 02:07:30 -0400
  • d2f413d46e Update log prints in nl.c. Nicholas J. Kain 2014-03-16 23:39:41 -0400
  • 3220cb90ac Use recvmsg rather than recv in ifset.c. Nicholas J. Kain 2014-03-16 23:39:24 -0400
  • 1ff3adef3a Update documentation and remove unused ioctl.h header. Nicholas J. Kain 2014-03-16 21:16:06 -0400
  • 8a24f74a11 Use netlink when setting the default ipv4 gateway. Nicholas J. Kain 2014-03-16 21:05:50 -0400
  • 9de62e7b75 Use netlink when setting the link MTU. Nicholas J. Kain 2014-03-16 18:07:09 -0400
  • 987bffe157 Clean up some error prints in ifset.c. Nicholas J. Kain 2014-03-16 18:06:42 -0400
  • 50d6284fee Use netlink for setting link flags instead of ioctl. Nicholas J. Kain 2014-03-16 05:10:21 -0400
  • cce93139d0 Delete 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 -0400
  • 7bf1cc419e nl_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 -0400
  • 7627298c07 The 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 -0400
  • 19d009891a When 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 -0400
  • 4d1cfe8586 Add a nl_sendgetaddr() function. Nicholas J. Kain 2014-03-15 00:30:39 -0400
  • e5d9f4acf2 Move nl_sendgetlink() to nl.c. Nicholas J. Kain 2014-03-14 23:54:21 -0400
  • 180ee36626 Update plain Makefile and README. Nicholas J. Kain 2014-03-14 23:51:11 -0400
  • 8faae4a0fd Check 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 -0400
  • 6a9e8c5a57 Disable seccomp-filter unless ENABLE_SECCOMP_FILTER is defined. Nicholas J. Kain 2014-03-14 23:24:22 -0400
  • 3af0a7824d subnet4_to_prefixlen() should use ntohl(). Nicholas J. Kain 2014-03-14 23:22:23 -0400
  • b6444fa806 Don't strip the generated executables by default. Nicholas J. Kain 2014-03-14 20:49:03 -0400
  • 312884dfc5 When execute_buffer() is passed an invalid command, print the bad command when logging the error. Nicholas J. Kain 2014-03-14 20:48:33 -0400
  • 4afddd471a The getopt_long shortarg string needed a ':' after 'C' as it has a mandatory argument. Nicholas J. Kain 2014-03-14 20:47:57 -0400
  • fbe6d36b6b Fix the ip4 ragel parser. Nicholas J. Kain 2014-03-14 20:46:40 -0400
  • 971c6085d8 ifchd.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 -0400
  • f4a2a487d6 Mark more function prototypes as extern. Nicholas J. Kain 2014-03-12 20:55:35 -0400
  • 4feac2ea35 Rename 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 -0400
  • 73ad3b1419 Mark external function prototypes in state.h as extern. Nicholas J. Kain 2014-03-12 20:39:55 -0400
  • c81e9f9a28 Merge config.h into ndhc.h. Nicholas J. Kain 2014-03-12 17:05:43 -0400
  • 84a68001d3 Use a unified epoll_(add|del)(). Nicholas J. Kain 2014-03-12 16:51:10 -0400
  • 94a923b00a Clean up and centralize stray external prototypes into headers. Nicholas J. Kain 2014-03-12 16:24:02 -0400
  • 2afd963ad0 ifchd.c: resolv_conf_fd can be static. Nicholas J. Kain 2014-03-12 16:14:48 -0400
  • b9a30f0653 Move 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 -0400
  • 9bf79b6034 Update the nk_random calls to use the new re-entrant-safe API. Nicholas J. Kain 2014-03-12 15:41:34 -0400
  • 54a7f54a4a Move add_rtattr() from ifset.c to nl.c as nl_add_rtatr(). Nicholas J. Kain 2014-03-12 15:25:07 -0400
  • 1222f4f22a Handle 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 -0400
  • b7b353acdc Store 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 -0400
  • 80f82c2451 options.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 -0400
  • 765f3de274 Use strncmp rather than strcmp in netlink.c when fetching the interface MAC address and index. Nicholas J. Kain 2014-03-12 13:03:34 -0400
  • fac6794b6c Handle SIGPIPE and SIGCHLD. Nicholas J. Kain 2014-03-12 12:47:39 -0400
  • be456ddeee Use the ncmlib combined Tausworthe PRNG. Nicholas J. Kain 2014-03-12 12:47:04 -0400
  • c0fc3ed430 Silence the last few new warnings. Nicholas J. Kain 2014-03-10 23:00:57 -0400
  • 84b36f0e02 Remove -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 -0400
  • eaa8f2fcb2 Fix warnings for state.c. Nicholas J. Kain 2014-03-10 19:44:37 -0400
  • 151ed60de1 Fix warnings in leasefile.c. Nicholas J. Kain 2014-03-10 19:42:52 -0400
  • d18aff8fb0 Fix warnings in ifchd.c. Nicholas J. Kain 2014-03-10 19:40:38 -0400
  • 8a3b875119 Fix warnings in ifset.c. Nicholas J. Kain 2014-03-10 19:31:46 -0400
  • eec497adf5 Fix warnings in ifchd-parse.rl. Just needed function prototypes. Nicholas J. Kain 2014-03-10 19:29:19 -0400
  • e5c7493bc8 Fix warnings in arp.c. Nicholas J. Kain 2014-03-10 19:25:06 -0400
  • e7838d542b Fix the remaining signed/unsigned comparison warnings. Nothing stands out as being dangerous or buggy. Nicholas J. Kain 2014-03-10 19:00:08 -0400
  • e50bd431d6 dhcp.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 -0400
  • 85fcc1e8f0 Use stricter gcc warning flags by default. Nicholas J. Kain 2014-03-10 18:34:53 -0400
  • df0898dfb6 Change 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 -0400
  • 47dbf3e24d Rename dhcp-hostname cmdarg to dhcp-set-hostname. Nicholas J. Kain 2014-03-10 14:43:37 -0400
  • 94d6b1fb2e The 'ip', 'snet', and 'bcast' commands have been replaced by 'ip4'. Remove them. Nicholas J. Kain 2014-03-10 01:13:38 -0400
  • a130448d46 Update the README. Nicholas J. Kain 2014-03-10 01:09:25 -0400
  • 1824802fb2 Merge 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 -0400
  • 06ff60bb6b Make ndhc use the new 'ip4' ifchd command. Nicholas J. Kain 2014-03-09 13:57:37 -0400
  • c4f09b1a9a Use the standard defines for ipv4 printable address max string length. Nicholas J. Kain 2014-03-09 13:51:49 -0400
  • d7ea5d9b0d Add the 'ip4' command to the ifchd wire protocol. Nicholas J. Kain 2014-03-09 12:33:20 -0400
  • 520ba6fd31 Mark 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 -0400
  • 06b65de08c Add 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 -0400
  • 81a9fe1c8e inet_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 -0400
  • 3ef87c1f26 ifchd: 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 -0400
  • 62d69e1909 Lists of IPs should be comma-separated rather than semicolon or space-separated. Nicholas J. Kain 2013-05-10 13:46:58 -0400
  • 1fc06c6e4f ifchd: 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 -0400
  • cb261be045 ndhc: Subnet option is an ip, not an iplist. Nicholas J. Kain 2013-05-10 13:44:31 -0400
  • bf3de7f310 Teach the Makefile how to handle Ragel, too. Nicholas J. Kain 2013-05-08 09:08:47 -0400
  • 6654ad1300 ncmlib should be tracked as an external repo. Nicholas J. Kain 2013-05-08 08:14:23 -0400
  • 3d6e3a2610 Update the log file printing. Nicholas J. Kain 2013-05-08 08:11:15 -0400
  • 4c52accd62 Fix the syscall whitelist to permit syscalls needed to properly log via glibc syslog. Nicholas J. Kain 2013-05-08 08:10:57 -0400
  • f8773742c9 ncmlib: Cosmetic cleanups to chroot.c. Nicholas J. Kain 2013-05-08 06:58:55 -0400
  • f78ea70d71 Ifchd: Convert some tabs to spaces. Nicholas J. Kain 2013-05-08 06:37:33 -0400
  • 3640c5bbf0 Ifchd: Print out log messages when commands are successfully dispatched. Nicholas J. Kain 2013-05-08 06:36:20 -0400
  • b7e6f59fc7 Use a Ragel-generated DFA parser for ifchd command dispatch. Nicholas J. Kain 2013-05-08 06:27:22 -0400
  • 930b92a268 Remove strlc(at|py). Nicholas J. Kain 2013-05-06 07:32:02 -0400
  • 958a57d819 Convert to using strnkc(at|py). Nicholas J. Kain 2013-05-06 07:07:54 -0400
  • 7ab11e8295 Add 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 -0400
  • f807e10e76 Make the ARP-based lease address collision checks configurable in delay times and number of probes. Nicholas J. Kain 2013-02-09 00:30:19 -0500
  • b8c77a45e8 Bump ndhc version to 1.1. Nicholas J. Kain 2012-07-23 13:24:15 -0400
  • 22e5a60671 Drop 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 -0400
  • 483ca6752d Whitelist syscalls provided by vDSO. Nicholas J. Kain 2012-07-22 09:49:51 -0400