summaryrefslogtreecommitdiff
path: root/sbin/slaacd/slaacd.c
AgeCommit message (Collapse)Author
2023-02-15Use correct order of arguments for shutdown(2).Florian Obser
Luckily routesock would never be <= 2 so shutdown would always failing with EINVAL and not shutting down random other sockets. The kernel was just uselessly piling up route messages that we were never reading. This mistake first showed up in slaacd(8) and then was copied to the other daemons. Reported & fixed by Josiah Frentsos (jfrent at tilde.team), thanks! OK kn
2022-11-27Provide more accurate lock error messageKlemens Nanni
When started manuall from single-user mode (/ still read-only), the current error is misleading: # slaacd -dv slaacd: already running The lock was specifically added to prevent multiple instances in the installer, which discards the error message entirely anyway. Retain the useful EAGAIN/"already running" message, but otherwise print the real error reason: # slaacd -dv slaacd: /dev/slaacd.lock: Read-only file system Feedback OK deraadt millert
2022-09-15Ignore error when we try to delete an address that's already gone.Florian Obser
This will happen when an address expires because the vltime drops to zero. The kernel then deletes the address and slaacd tries to do so, too. The correct fix is to track in slaacd that the kernel already deleted the address for us, but that's too much work shortly before a release so just hide the ugly warning for now, it's harmless. Problem reported by semarie some time ago. OK deraadt, benno
2022-07-12Rewrite state machine in the style of dhcpleased(8).Florian Obser
It is less cluttered, easier to reason about and fixes some bugs in passing that would have been difficult in the old state machine. Stale IPv6 addresses, default routes and nameservers are now correctly removed when moving from one IPv6 enabled network to another IPv6 enabled network. Default routes and nameservers correctly expire when they are not refreshed and nameservers are updated when router advertisements change the nameserver option. Testing & input caspar@ Putting it in now to get wider testing and shake out bugs, discussed with deraadt@ at r2k22.
2021-08-24When an interface disappears, e.g. when a usb dongle gets unplugged,Florian Obser
we get a RTM_IFANNOUNCE message not a RTM_IFINFO message. Handle this message to not accumulate "unknown" interfaces. While here fix a bug where we would remove an interface only in the engine process but not in the frontend when an interfaces gets unplugged while we process a RTM_IFINFO message for it. OK benno
2021-07-27The SIOCAIFADDR_IN6 ioctl could lose a race against another processFlorian Obser
configuring the same IP. I forgot to fix slaacd after fixing the same problem in dhcpleased. Pointed out by afresh1
2021-07-22Send rDNS proposals on ramdiskskn
Otherwise resolvd(8) will never learn nameservers and update /etc/resolv.conf with IPv6 resolvers. At the moment IPv6 only installations always prompt for nameservers anyway, but that is its own bug and will be fixed soon. This enables the upcoming fix to detect learned nameservers in the first place. Feedback OK florian
2021-07-21Use exclusive lock under /dev/, silence expected errors in installerkn
resolvd(8), slaacd(8) and dhcpleased(8) are different from other daemons in that there must only be a single instance. resolvd already does this, adjust slaacd and dhcpleased accordingly while moving the lockfile paths under /dev/ such that they work early on boot and don't run into races should /var be (un)mounted between daemon starts. Locking is especially required in the installer where all three daemons are started every time the "(I)nstall, (U)pgrade, (A)utoinstall or (S)hell? " prompt is entered, i.e. restarting installation or dropping into a shell and back into the prompt again would start multiple instances. To avoid expected lockfile error messages in between installer prompts, discard standard error when starting the autoconf daemons; none of them has other potential failure cases in installer mode before daemon(3)izing. Input sthen deraadt OK deraadt
2021-05-01In singel user mode / is mounted ro. Just warn if we can't createFlorian Obser
the control socket instead of fatal(). OK deraadt
2021-03-21Use new terminology of RFC 8981 and (mechanically) replace "privacy"Florian Obser
with "temporary".
2021-03-07Fold get_lladdr into update_iface, now the only caller.Florian Obser
This allows us to pass the link state over to engine here instead of in update_addr which is not available in small. This gets us more in line dhcpleased.
2021-02-27Path #defines are traditionally prefixed with _PATH.Florian Obser
pointed out by deraadt
2021-01-19Make imsg event structs static to fix -fno-common.Florian Obser
Follows claudio's lead in ospfd et al. Problem reported by mortimer.
2021-01-19No need for a global slaacd_process; unbreaks -fno-common.Florian Obser
Problem reported by mortimer
2021-01-17Mark up locations of KAME hack with #ifdef __KAME__ so that we canFlorian Obser
find it again if and when we no longer need it. No object change.
2020-12-01Sync get_ifrdomain() to rad(8) version by removing a useles (void)Florian Obser
cast in front of a strlcpy(3). tb@ had pointed out that the use in rad(8) was not consistent. I consider the void cast a useless annotation, either the strl* functions must have the canonical trucation check or it must be obvious that truncation cannot happen or is not a problem. While at it remove a bunch more casts that snuck in over time.
2020-09-14We might race against removal of an rdomain we just want to handle.Florian Obser
Make setsockopt non-fatal in this case and just ignore the request. Spotted in a diff by reyk for rad(8); discussed with claudio
2020-09-14Let slaacd handle all rdomains in a single daemon.Florian Obser
Suggested by claudio and matthieu Testing matthieu Putting it in now to get enough testing before release so that there is enough time to back it out, suggested by deraadt
2020-07-03Rename IN6_IFF_PRIVACY to IN6_IFF_TEMPORARY.Florian Obser
This is the name the other BSDs use for this, there is no reason to be different, the IPv6 RFCs call these addresses temporary, and some software in ports wants to use this as well. Most recently pointed out for firefox by landry. OK claudio, sthen
2020-05-25Do not log "startup" to syslog.Florian Obser
slaacd and unwind start very early in the boot process and syslog is not fully available yet so these messages tend to get lost. But they are also not particularly useful. Prompted by a report by Jason Mader on bugs@ OK deraadt, claudio, bluhm Note that this code has been copied around to all our privsep daemons and also lives in usr.sbin. Leave it alone there because multiple people said they find it useful for those daemons.
2020-04-16Make the control socket name depend on the routing domain we are in.Florian Obser
That way, when slaacd gets started in a different rdomain with route exec things just work, no need to provide an alternative control socket. Pointed out by claudio Original diff by benno, but I like my bikeshed purple. OK benno, claudio
2020-04-14When slaacd is run in a routing domain (rdomain) other than the default (0) itFlorian Obser
sends router solicitations and receives router advertisements only from interfaces that are in its own rdomain. It also only sees interfaces arriving, or departing in its own rdomain. However, for the default route there is rdomain cross-talk because slaacd configures the default route in the default rdomain (and fails). Make slaacd honour the rdomain it's running in as well. OK denis, phessler, benno
2019-12-15semarie diagnosed a what appeared to be a 'large backwards memcpy' of anTheo de Raadt
ipv6 address, but was actually oversize (a large union). correct access to the right subfield. ok florian semarie
2019-11-23 On startup withdraw all proposals for all interfaces by sending anFlorian Obser
empty proposal with if_index 0. It is possible that the set of autoconf interfaces changed between a stop -> start transition and slaacd would never withdraw nameservers for interfaces that had the autoconf flag previously but no longer after the restart.
2019-11-22 Merge DNS proposals coming from the same interface.Florian Obser
That way we no longer need to handle withdraws in unwind. A new proposal from a daemon on an interface is always a replacement. If nameservers expire or an interface goes away we sent an empty list of nameservers. pestering^Wprodding deraadt
2019-11-21Configure the default route with RTP_NONE so that the kernel assignsFlorian Obser
different priorities for wired vs. wireless interfaces for us. Gleaned from dhclient.
2019-11-11 Send DNS proposals on route socket when new nameservers are learnedFlorian Obser
from router advertisements. unwind(8) can solicit DNS proposals by sending an empty RTM_PROPOSAL message with priority RTP_PROPOSAL_SOLICIT.
2019-11-07 Remove half way implemented address and default route proposals.Florian Obser
This never worked out and is getting in the way of DNS proposals which are coming next. No (intended) functional change. Input & OK tohe
2019-11-05trailing whitespaceFlorian Obser
2019-08-30Remove configured IPv6 addresses remaining when slaacd(8) detects apamela
link-state change and no new router advertisement is obtained (in accordance with RFC 6059). This should improve IPv6 -> legacy-IP-only transitions, preventing applications from believing IPv6 connectivity is available when it is not, potentially resulting in long timeouts. suggestion, input and OK florian@ phessler@
2019-06-28When system calls indicate an error they return -1, not some arbitraryTheo de Raadt
value < 0. errno is only updated in this case. Change all (most?) callers of syscalls to follow this better, and let's see if this strictness helps us in the future.
2019-03-31Avoid calling dup2(oldd, newd) when oldd == newd. In that case theYASUOKA Masahiko
descriptor keeps CLOEXEC flag then it will be closed unexpectedly by exec(). ok tedu florian
2019-03-11Make slaacd(8) imsg processing more paranoid. Unexpected size mismatchespamela
mean we should no longer trust processes, so we call fatal(x). The control socket is the exception, where we ignore rather than allow crashes due to data from the outside. suggestion/input and OK florian@
2019-03-11Change fatal() to fatalx() where errno is not set.pamela
input and OK florian@
2019-03-05slaacd doesn't have a config file to reload on hangup. We can ignorepamela
those signals, so remove unnecessary signal handling code. pointed at and OK florian@
2019-03-02Introduce the IMSG_DATA_SIZE() macro to replace recurring math onpamela
imsg.hdr.len to shorten and simplify code. correction and OK florian@
2019-01-22PF_ROUTE -> AF_ROUTE in the scattered sock()/setsockopt() callsKenneth R Westerback
where the "wrong" #define was used. ok dlg@
2018-08-19Call daemon with 0 as first argument so that it changes the cwd to /Florian Obser
otherwise the main process will keep sitting in the directory from where slaacd was started which might for example prevent an unmount. Problem first observed by dlg in ntpd(8). Discussed with deraadt@
2018-08-05Since -s argument is no longer checked, during reexec, the argv size then mustRicardo Mestre
be shortened by 1. OK florian@
2018-08-04Leave the control socket behind on shutdown. It doesn't hurt anyone.Florian Obser
On the other hand it is much more powerful to get rid of cpath; slaacd has no filesystem access whatsoever. Triggered by mestre@'s work to fix unlinking in other daemons and a question from deraadt@ OK mestre
2018-07-27Enable slaacd(8) to set MTU on an interface.bket
If a router advertisement message with the MTU option is received on an interface slaacd will set the specified MTU on that interface. Lots of help from florian@. Thank you! OK florian@
2018-07-23When moving between networks slaacd configures new addresses butFlorian Obser
leaves old ones behind. The IPv6 RFCs don't seem to offer guidance on what to do in this case. (RFC 5220 discusses related issues, but not exactly this.) It seems a bit harsh to just delete old addresses - a naive implementation can easily lead to flip-flopping between two prefixes. Instead set the preferred lifetime to 0 for all addresses on an interface when the link goes down, thus marking addresses as deprecated but still usable. When the link comes back send a router solicitation. If we are still on the old network and receive a router advertisement the preferred lifetime will increase and the addresses will no longer be deprecated. If we moved to a new network we will get new router advertisements and form new addresses. The old ones will stay deprecated and the address selection algorithm will prefer new addresses. Problem reported by many. testing & OK phessler
2018-07-23Handle duplicate address detection failures.Florian Obser
We get notified when duplication is detected on the route socket. For privacy addresses simply generate a new random address. If we have soii enabled increase the dad counter on the prefix and generate a new address. For eui64 addresses nothing can be done.
2018-07-09Remove array of IMSG type names.Florian Obser
It was helpfull in the beginning to know which IMSG are flying around but unusable (and unsused) since slaacd(8) is on the ramdisk.
2018-07-07slaacd is not interested in v4-related route messages so set the addressStuart Henderson
family on the two socket() calls to open the routing socket, so that only v6-related and af-unspecific messages are seen. One of the sockets is only used for sending not receiving messages; shutdown the receive side to avoid receiving messages as suggested by claudio@. slaacd is run by default (watching for interface changes to add the "autoconf" flag), so has to process route messages even where IPv6 autoconf isn't used - these changes reduce CPU use on machines processing large numbers of route updates (in particular full-table BGP routers). ok florian@ claudio@ benno@
2018-06-18Pledge main process now that we have wroute.Florian Obser
2018-05-17Handle RTM_DELETE of slaacd managed default route by re-inserting it.Florian Obser
Problem pointed out & OK phessler
2018-05-17Fully align this with route(8); no need to be different here and mightFlorian Obser
help us if we ever get rid of KAME hack.
2018-05-17Introduce SLAACD_RTA_LABEL define to not use a string constant allFlorian Obser
over the place.
2018-05-16Create all sockets with SOCK_CLOEXEC, we never want to hold on to themFlorian Obser
over execve(2).