Commit graph

55 commits

Author SHA1 Message Date
Warner Losh b3e7694832 Remove $FreeBSD$: two-line .h pattern
Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/
2023-08-16 11:54:16 -06:00
Kristof Provost 476babaea7 rtsol: introduce an 'always' script
In addition to the 'M' and 'O' scripts (for when 'Managed' and 'Other'
flags are set) also introduce an 'always' script that is called for any
router advertisement (so even if M and O are not set).

This is primarly useful for systems like pfSense that wish to be
informed of routers for further system configuration.

See also https://redmine.pfsense.org/issues/14072

Reviewed by:	melifaro
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D39931
2023-05-02 18:07:36 +02:00
Colin Percival 231bac4ccc rtsol/rtsold: Add option to skip random delay
In accordance with a SHOULD in RFC 4861, rtsol and rtsold wait a
random time between zero and one (aka MAX_RTR_SOLICITATION_DELAY)
seconds before sending a Router Solicitation, in order to avoid
network congestion if many hosts come online at once.  (The
question of how many hosts would be required to cause congestion
by each sending a single packet on a Gbps+ network is left to the
reader.)

The new option -i disables this wait and instructs rtsol and rtsold
to send the Router Solicitation immediately.

Reviewed by:	bz, kp (earlier version)
MFC after:	1 week
Relnotes:	yes
Sponsored by:	https://www.patreon.com/cperciva
Differential Revision:	https://reviews.freebsd.org/D32956
2021-11-16 10:27:28 -08:00
Franco Fitchner bfa812f540 rtsold: auto-probe point to point interfaces
rtsold works fine for point to point interfaces in manual mode but will
not auto-probe them.

Reviewed by:	markj
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D31517
2021-08-14 11:14:24 -04:00
Hajimu UMEMOTO 006a01374f Simplify using nvlist_append_string_array().
Reported by:	hrs
MFC after:	1 week
2021-03-08 12:03:32 +09:00
Hajimu UMEMOTO 1def0a6257 fix casper initialization for setting scripts.
MFC after:	1 week
2020-11-27 18:40:51 +00:00
Bjoern A. Zeeb 60e7f66931 rtsol(d): add script for "M bit"
While we do support the "O bit" running a script (usually to start a
dhcpv6 client) we have no options for setups which set the "M bit" for,
e.g., static address assignment as in EC2.

Duplicate most of the "O bit" logic to also start a script for the
"M bit" with the one difference: if the "M bit" is set we will not
start the script for the "O bit" as well (per RFC 4861, Section 4.2).

Reviewed by:	hrs, markj
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D26099
2020-08-25 16:09:23 +00:00
Mark Johnston ee74c3327a rtsol: Use vwarnx(3) to log messages to standard error.
This ensures that the program name is included in the output, which
makes it easy to identify the source of error messages printed
during boot.

MFC after:	1 week
2019-02-27 18:13:41 +00:00
Mark Johnston 04e9edb544 Capsicumize rtsol(8) and rtsold(8).
These programs parse ND6 Router Advertisement messages; rtsold(8) has
required an SA, SA-14:20.rtsold, for a bug in this code.  Thus, they
are good candidates for sandboxing.

The approach taken is to run the main executable in capability mode
and use Casper services to provide functionality that cannot be
implemented within the sandbox.  In particular, several custom services
were required.

- A Casper service is used to send Router Solicitation messages on a
  raw ICMP6 socket.  Initially I took the approach of creating a
  socket for each interface upon startup, and connect(2)ing it to
  the all-routers multicast group for the interface.  This permits
  the use of sendmsg(2) in capability mode, but only works if the
  interface's link is up when rtsol(d) starts.  So, instead, the
  rtsold.sendmsg service is used to transmit RS messages on behalf
  of the main process.  One could alternately define a service
  which simply creates and connects a socket for each destination
  address, and returns the socket to the sandboxed process.  However,
  to implement rtsold's -m option we also need to read the ND6 default
  router list, and this cannot be done in capability mode.
- rtsold may execute resolvconf(8) in response to RDNSS and DNSSL
  options in received RA messages.  A Casper service is used to
  fork and exec resolvconf(8), and to reap the child process.
- A service is used to determine whether a given interface's
  link-local address is useable (i.e., not duplicated or undergoing
  DAD).  This information is supplied by getifaddrs(3), which reads
  a sysctl not available in capability mode.  The SIOCGIFCONF socket
  ioctl provides equivalent information and can be used in capability
  mode, but I decided against it for now because of some limitations
  of that interface.

In addition to these new services, cap_syslog(3) is used to send
messages to syslogd.

Reviewed by:	oshogbo
Tested by:	bz (previous versions)
MFC after:	2 months
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D17572
2019-01-05 16:05:39 +00:00
Mark Johnston 04c07c31eb Always free dynamically allocated memory before returning.
CID:		1007418
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
2018-10-24 16:46:26 +00:00
Mark Johnston d2f6957c1c Remove dead code.
No functional change intended.

MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
2018-10-20 17:44:23 +00:00
Mark Johnston 3d7dd2d69a Staticize a couple of functions.
No functional change intended.

MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
2018-10-20 17:43:27 +00:00
Mark Johnston 1a97dd3cc3 Remove some obsolete compatibility code.
No functional change intended.

MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
2018-10-20 17:40:30 +00:00
Pedro F. Giffuni 8a16b7a18f General further adoption of SPDX licensing ID tags.
Mainly focus on files that use BSD 3-Clause license.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

Special thanks to Wind River for providing access to "The Duke of
Highlander" tool: an older (2014) run over FreeBSD tree was useful as a
starting point.
2017-11-20 19:49:47 +00:00
Mark Johnston 0386a98bd0 Use the _SAFE loop variant, since the loop body may remove queue entries.
PR:		207146
MFC after:	3 days
2016-02-18 01:58:26 +00:00
Ulrich Spörlein c9e1c304c1 Fix type mismatches for malloc(3) and Co.
This is rather pedantic, as for most architectures it holds that
sizeof(type *) == sizeof(type **)

Found by:	clang static analyzer
Reviewed by:	ed
Differential Revision: https://reviews.freebsd.org/D4722
2015-12-29 11:24:41 +00:00
Enji Cooper 0ec7db6428 Fix rtsold's usage message
- Remove -a from the usage message example dealing with specific
  interfaces. -a only makes sense when not specifying an interface,
  such that it's to be run on all interfaces
- Fix the pidfile option (it's -p, not -P)
- Change `interfaces` to `interface` to match the manpage

MFC after: 3 days
PR: 173744
Sponsored by: EMC / Isilon Storage Division
2015-10-30 07:36:43 +00:00
Xin LI 56160b2e67 Now that we own the code, use arc4random(3) unconditionally
and remove the corresponding HAVE_ARC4RANDOM conditions.

MFC after:	2 weeks
2015-10-06 23:42:58 +00:00
Hiroki Sato f74237f5b6 - Remove #ifdef HAVE_POLL_H.
- Use nitems().

MFC after:	3 days
2015-09-10 06:40:28 +00:00
Gleb Smirnoff 56d5e0967c Stop including if_var.h from userland.
Sponsored by:	Nginx, Inc.
2015-04-06 09:42:23 +00:00
Hiroki Sato a678ca234f - Remove struct ifinfo *iflist. It is no longer used.
- Suppress warnings about increase of alignment requirement.
2013-08-17 19:23:35 +00:00
Hiroki Sato 3774384085 Fix build on arm and mips. 2013-08-06 15:49:18 +00:00
Hiroki Sato 7d26db1792 - Use time_uptime instead of time_second in data structures for
PF_INET6 in kernel.  This fixes various malfunction when the wall time
  clock is changed.  Bump __FreeBSD_version to 1000041.

- Use clock_gettime(CLOCK_MONOTONIC_FAST) in userland utilities.

MFC after:	1 month
2013-08-05 20:13:02 +00:00
Eitan Adler e0ef7724c3 Fix warning when compiling with gcc46:
error: variable 'target' set but not used

Approved by:	dim, cperciva (mentor, blanket for pre-mentorship already-approved commits)
MFC after:	3 days
2012-01-20 01:38:52 +00:00
Hiroki Sato 489e04d0da - Add ":origin" label to the interface id for resolvconf(8). (r223149)
- Add -u option to enable adding :[RA-source-address] to the interface id.
  (r223149)
- s/INET6_ADDRSTRLEN/sizeof(ntopbuf)/  (r223149)
- Fix a bug that can prevent -D from being overridden by -d. (r223149)
- /-P pidfile/-p pidfile/ for consistency with rtadvd(8). (r223149)
- Fix -F flag handling to support receiving RAs even when ip6.forwarding=1.
  (r225150)

Approved by:	re (kib)
2011-09-12 23:55:23 +00:00
Hiroki Sato 06056832ec - Accumulate RA options instead of replacing old ones when a new RA arrived.
RFC 4861 6.3.4 clearly defines handling multiple RAs in this way.

- RDNSS/DNSSL options from multiple RAs on a single link will be
  gathered and sent to resolvconf(8).

- Call "resolvconf -d" only after at least one RDNSS or DNSSL option is
  received and then all of them are expired.

- The rtsold.dump output now supports displaying a list of the RA options.

- Use more human-readable expression for logging values of struct timeval.

Discussed with:	ume
2011-06-08 16:03:29 +00:00
Hiroki Sato b4da9fbccd - Disable "resolvconf -d" temporarily to avoid extra invocations of the script
under a certain condition.
- Fix argv handling.

Spotted by:	ume
2011-06-08 04:06:56 +00:00
Hiroki Sato db82af41db - Implement RDNSS and DNSSL options (RFC 6106, IPv6 Router Advertisement
Options for DNS Configuration) into rtadvd(8) and rtsold(8).  DNS
  information received by rtsold(8) will go to resolv.conf(5) by
  resolvconf(8) script.  This is based on work by J.R. Oldroyd (kern/156259)
  but revised extensively[1].

- rtadvd(8) now supports "noifprefix" to disable gathering on-link prefixes
  from interfaces when no "addr" is specified[2].  An entry in rtadvd.conf
  with "noifprefix" + no "addr" generates an RA message with no prefix
  information option.

- rtadvd(8) now supports RTM_IFANNOUNCE message to fix crashes when an
  interface is added or removed.

- Correct bogus ND_OPT_ROUTE_INFO value to one in RFC 4191.

Reviewed by:	bz[1]
PR:		kern/156259 [1]
PR:		bin/152458 [2]
2011-06-06 03:06:43 +00:00
Ulrich Spörlein bd2c49af72 rtsol(8)/rtsold(8): make WARNS=3 clean
It is actually WARNS=6 clean for non-strict alignment archs.

Approved by:	ed (co-mentor)
2010-02-27 10:19:39 +00:00
Hajimu UMEMOTO 62fd5fd625 Exclude the interfaces which IPv6 and/or accepting RA is disabled
from the auto probed interface list.

MFC after:	1 week
2010-02-02 18:38:17 +00:00
Hajimu UMEMOTO 3ce74ea2c5 Make -a option actually work.
MFC after:	1 week
2010-02-02 16:02:09 +00:00
Hiroki Sato eb87e699b2 Add support for ND6_IFF_IFDISABLED and ND6_IFF_ACCEPT_RTADV to
the -F flag.

MFC after:	3 days
2009-09-12 22:14:58 +00:00
Andrey A. Chernov a08f0b20be Change arc4random to arc4random_uniform since modulo is not power of 2,
as OpenBSD does.

Obtained from:  OpenBSD
2008-07-26 15:46:39 +00:00
Kevin Lo 784bddbc5b Cleanup of userland __P use 2007-11-07 10:53:41 +00:00
SUZUKI Shinsuke 06755c2216 an English grammar fix
Reported by: ru
MFC after: 1 day
2005-06-09 09:28:35 +00:00
SUZUKI Shinsuke c27109e92b fixed typo
Obtained from: KAME
MFC after: 1 day
2005-06-08 23:51:42 +00:00
Hajimu UMEMOTO 5538fd1e35 -DSMALL will remove the need of dump.c (for rtsol)
Obtained from:	KAME
2004-01-14 17:59:38 +00:00
Hajimu UMEMOTO fcdaee3127 add -F flag, which configures sysctl(8) setting by rtsold
itself (rather than warn about the current setting).

Obtained from:	KAME
2004-01-14 17:42:03 +00:00
Hajimu UMEMOTO 8e7409eda3 ansify.
Obtained from:	KAME
2004-01-14 17:16:19 +00:00
Hajimu UMEMOTO d05ae8c388 use timeradd/sub/cmp.
Obtained from:	KAME
2004-01-14 16:55:08 +00:00
Hajimu UMEMOTO 9a364ca35a - improved the -a option. it can probe a interface automatically when
the interface wake up.  it can be started anytime even when there is
  no network interface on the list of intarfaces in the kernel.
- get a correct link ID for each interface at initialization
  (using scope libraries if HAVE_SCOPELIB is defined).
- fill in sin6_scope_id correctly before sendmsg().

Obtained from:	KAME
MFC after:	1 week
2003-08-17 11:11:32 +00:00
Hajimu UMEMOTO 5c706347d5 support poll(2).
Obtained from:	KAME
MFC after:	1 week
2003-08-14 18:43:57 +00:00
Hajimu UMEMOTO 92bdf888a6 daemon() has to be called prior to file descriptor setups
(otherwise file descriptors could be closed mistakenly)

Obtained from:	KAME
MFC after:	1 week
2003-08-14 18:13:34 +00:00
Hajimu UMEMOTO 653b3bd48b signal handler must take "int" arg.
Obtained from:	KAME
MFC after:	1 week
2003-08-14 15:57:52 +00:00
Hajimu UMEMOTO 8998f69b13 avoid fd_set overrun.
Obtained from:	KAME
MFC after:	1 week
2003-08-14 15:47:31 +00:00
Hajimu UMEMOTO bb58b617fb use strlcpy() and snprintf().
Obtained from:	KAME
MFC after:	1 week
2003-08-11 15:49:47 +00:00
Hajimu UMEMOTO fa19f9be04 KNF, correct typos and cleanup spaces.
Obtained from:	KAME
MFC after:	1 week
2003-08-08 16:56:01 +00:00
Hajimu UMEMOTO 5ed8c16b88 drop the code for the environment where getifaddrs(3) is not
supported.

Obtained from:	KAME
MFC after:	1 week
2003-08-08 16:52:31 +00:00
Hajimu UMEMOTO 86b032af6c Process the "O bit."
If the value of OtherConfigFlag changes from FALSE to TRUE, the
host should invoke the stateful autoconfiguration protocol,
requesting information.
[RFC 2462 Section 5.5.3]

Obtained from:	KAME
MFC after:	1 week
2003-08-08 16:42:37 +00:00
Hajimu UMEMOTO 1533bed05b __FUNCTION__ --> __func__
Obtained from:	KAME
MFC after:	1 week
2003-08-08 16:38:23 +00:00