Commit Graph

5458 Commits

Author SHA1 Message Date
Roy Marples
064767e361 Linux: Use netlink to workout address flags
There seems to be a race with netlink announcing the address vs
it's availability via /proc.
Fixes #76.
2022-04-20 17:51:53 +01:00
Wu Xiaotian
3fc025392d
add support for loongarch64 (#93) 2022-03-31 23:46:20 +01:00
Roy Marples
b09ed786b8 duid: Disable use of machine UUID by default.
Fixes #89.
2022-03-12 11:15:09 +00:00
Roy Marples
8b25cff6db hooks: Use command -v rather than type
command -v is now required by POSIX, type is technically an extension.
2022-02-24 12:53:02 +00:00
Roy Marples
5a4340c30c Bump dates for prior 2022-02-24 06:34:10 +00:00
Martin-Éric Racine
e774fb018e Fixes manual page typos found by Lintian 2022-02-24 06:28:21 +00:00
Roy Marples
50ca1766f5 dhcpcd.8: remove reference to 02-dump hook script
This hook script was removed a while ago.
Fixes #72.
2021-11-13 14:10:31 +00:00
Ben Woods
c932b296c7
Add epair(4) to the ignored interface types list (#73)
The FreeBSD epair(4) interface type can be thought of as a virtual patch cable.
The epair interfaces come in pairs, with network traffic being passed between the 2 pairs.
The basic intent is to provide connectivity between two virtual network stack instances.
This interface type does not typically require an IP address, as it is passing traffic
between other virtual networks/interfaces which obtain their own IP address.
Therefore, add this interface type to the list that will be ignored by dhcpcd.
2021-11-13 13:53:58 +00:00
Roy Marples
43de9416e6 privsep: Only set RLIMIT_NOFILES for supported platforms
Basically only for NetBSD, DragonFlyBSD, kqueue or epoll platforms.
All others will use poll(2) and return EINVAL if nfds > RLIMIT_NOFILES.

Trying to work out our nfs limit relies on already listening to
all FD's which may not be the case and was problematic.
Luckily all platforms aside from Solaris have new file creation
sandboxed away aside from accept(2) so this should still be safe.
2021-11-12 14:24:11 +00:00
Veronika Kremneva
4fa97ba4ae
src/privsep-linux.c: Add support of Synopsys ARC64 architecture (#66)
Signed-off-by: Veronika Kremneva <kremneva@synopsys.com>
2021-10-27 20:53:22 +01:00
Roy Marples
80dfabc522 privsep: and again on OpenBSD 2021-10-20 11:21:38 +01:00
Roy Marples
18e58b9767 privsep: Fix compile on Dragonfly BSD 2021-10-20 10:23:19 +01:00
Roy Marples
46879ef0c5 README.md: Remove non existant man page links.
They have not been online for sometime and are unlikely to return.
While here, correct the commit log location.

Fixes #39
2021-10-18 15:25:35 +01:00
Roy Marples
6e9535cc32 DHCP: Set INFORM state only when we are about to inform
As we may not find an address right away.
While here, tidy up and comment code about deriving the address
when none is specified for inform and static setups.
2021-10-14 06:31:11 +01:00
Kaelan Mikowicz
171524d225
DHCP: Fix infinite INFORM messages
When an address is configured on the interface, do not send an
INFORM message if the interface is already bound.

Fixes #48
2021-10-14 06:14:45 +01:00
Philip Paeps
fe668b5399
privsep: Fix getting interface VLANID on BSD (#58)
Include relevant headers for the definition of SIOCGETVLAN.  This fixes
DHCPv6 Prefix Delegation where a prefix is delegated to several VLAN
interfaces on the same physical interface.
2021-10-12 09:07:28 +01:00
Roy Marples
3b1f557d1c DHCP6: Don't spam the log when a RA repeatedly triggers an INFORM
This can occur if the RA reduces the prefix times in accordance
with it's own lifetimes for example.
dhcpcd only checks if the RA contents have changed to trigger a
new INFORM.

As such, only log about new INFORMs.

Fixes #46.
2021-10-01 16:25:53 +01:00
Marian Cingel
18da9b9155 privsep: Enforce proper alignment of serialized struct cmsghdr
Fixes #43.
2021-08-31 13:33:20 +01:00
Roy Marples
2fae4a113c DHCP6: Only send FQDN for SOLICIT, REQUEST, RENEW, or REBIND messages.
As per RFC 4704 section 5.
Fixes #44.
2021-08-31 10:57:44 +01:00
Stefan Sperling
3215c8f97b
Fix rt_cmp_dest() for equivalent network prefixes with different netmasks. (#52)
When rt_add() decides that it must delete+add a route in order to change
the routing table entry, a wrong RB tree lookup result can throw it off
the rails. In the case observed, a static /64 prefix was deleted from
vlan1 while dhcpcd intended to delete its reject route bound to lo0.

Given two routes in the table, the loopback reject route installed by
dhcpd for my /48 prefix, and a cloning route for a /64 prefix on vlan1:

2001:db8::/48 ::1         UGR        0        0 32768    56 lo0  
2001:db8::/64 2001:db8::1 UCn        1        2     -     4 vlan1

When searching the OS routing table dhcpcd attempts to tell routes apart
based only on the masked destination address. In the above case the masked
destinations look identical. The only difference is the length of the netmask.
The function rt_cmp_dest() didn't detect this and returned the /64 route
while dhcpcd was in fact searching for the /48 route.

This patch fixes the lookup by running rt_cmp_netmask() if the masked
destination comparison via sa_cmp() leaves us with a tie. With this change
dhcpcd deletes the /48 route as intended, and leaves the /64 route alone.

I had to move the rt_cmp_dest() function down since it needs to use the
static helper function rt_cmp_netmask(), which happened to be defined
just below rt_cmp_dest().

Why am I using an overlapping static prefix? The answer is that my ISP
assigns a static /48 prefix but won't route IPv6 unless my router sends
a DHCPv6 request when it connects via PPPoE. I configure static IPv6 subnets
on LAN interfaces and have configured dhcpcd to obtain a /48 prefix lease
without setting addresses on any internal interfaces.
My dhcpcd.conf contains:
  ipv6only
  noipv6rs
  duid
  persistent
  option rapid_commit
  require dhcp_server_identifier
  script ""
  allowinterfaces pppoe0
  interface pppoe0
    ia_pd 1 /2001:db8::/48

This problem was found on OpenBSD, in case that matters for reproduction
of the issue.
2021-08-31 10:31:15 +01:00
Peter Fabinski
0c34e10b13
Update man pages for default metric changes (#51)
* Update man pages for metric changes in 3547ed19

* Make metric man changes additive
2021-08-31 10:29:25 +01:00
Craig McQueen
24693f0190
Fix parsing of hex/octal escapes in strings (#42) 2021-08-20 08:57:18 +01:00
Roy Marples
3ca0e321bf
Merge pull request #38 from concatime/posix-shell
configure: test -a|o is not POSIX
2021-07-20 11:06:32 +01:00
Roy Marples
3c216f86f5 Build as dhcpcd-9.99 now we have a dhcpcd-9 branch. 2021-07-19 21:25:45 +01:00
Roy Marples
477cd9669c IPv4LL: Don't remove statically assigned addresses
Fixes #37.

While here, don't open a DHCP port for static addresses either
when not in manager mode.
2021-07-19 21:22:44 +01:00
Issam E. Maghni
6e1da480a1 configure: test -a|o is not POSIX 2021-05-04 12:34:01 -04:00
Roy Marples
01748b315d FreeBSD: Finish EVFILT_PROCDESC implementation. 2021-03-18 12:14:54 +00:00
Roy Marples
8a5846bda6 Fix more new eloop fallout. 2021-03-17 20:16:20 +00:00
Roy Marples
c691df1084 privsep: Implement pdfork(2) for capsicum(4)
Capsicum does not allow waitpid(2).
As such we need to use pdfork(2) and watch for the descriptor to
hangup.
2021-03-17 20:13:02 +00:00
Roy Marples
77ef5d931a privsep: Fix FreeBSD for prior 2021-03-17 15:19:27 +00:00
Roy Marples
7f6825d3db privsep: Fix Linux support for prior 2021-03-17 15:12:22 +00:00
Roy Marples
1cd224ca33 privsep: Remove debug from prior 2021-03-17 15:11:53 +00:00
Roy Marples
07a6574c2d privsep: Implement some process management
This also allows us to wait until all processes have exited to
avoid a fast restart which complains addresses are in use.
2021-03-17 15:03:52 +00:00
Roy Marples
7ade245567 privsep: Don't close control proxy on hangup
Instead wait for it to be closed by the master process for a
clean shtudown.
2021-03-17 14:23:55 +00:00
Roy Marples
88d1590824 control: Fix working with new eloop 2021-03-10 13:09:39 +00:00
Fabrice Fontaine
391e962e58
src/privsep-linux.c: add support for m68k (#29)
Fix the following build failure:

privsep-linux.c:206:4: error: #error "Platform does not support seccomp filter yet"
 #  error "Platform does not support seccomp filter yet"
    ^~~~~
In file included from privsep-linux.c:36:
privsep-linux.c:213:38: error: 'SECCOMP_AUDIT_ARCH' undeclared here (not in a function); did you mean 'SECCOMP_ALLOW_ARG'?
  BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, SECCOMP_AUDIT_ARCH, 1, 0),
                                      ^~~~~~~~~~~~~~~~~~

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
2021-03-08 10:05:16 +00:00
Roy Marples
8aa4950ac3 README.md: remove dead reference to phabricator 2021-03-08 09:43:50 +00:00
Roy Marples
a75ffaa08d control: Cannot write with hangup 2021-02-20 16:25:05 +00:00
Roy Marples
f322b5a1ae eloop: delete events from kqueue/epoll directly
Rather than relying on close(2) being called.
Whilst a bit less performant with many open/close, there is also
no guarantee that close(2) will actually be called as
shutdown(2) could be used instead.
2021-02-16 16:43:18 +00:00
Roy Marples
06d77c3f4f log a diagnostic here 2021-02-16 16:40:35 +00:00
Roy Marples
53d15176c1 control: Don't log error deleting fds from eloop.
They might not be added as they are inactive and its just noise
as no operation is done anymore even for kqueue or epoll.
2021-02-09 11:36:07 +00:00
Roy Marples
44eccd184f BSD: Find the correct interface for tunneled routes
Should disard a harmless diagnostic.
2021-02-09 10:11:54 +00:00
Roy Marples
e0651533ea control: GC control deletion
Just free it entirely.
2021-02-08 19:25:08 +00:00
Fabrice Fontaine
82386110e6
src/privsep-linux.c: add support for arc (#28)
Fix the following build failure:

privsep-linux.c:206:4: error: #error "Platform does not support seccomp filter yet"
 #  error "Platform does not support seccomp filter yet"
    ^~~~~
In file included from privsep-linux.c:36:
privsep-linux.c:213:38: error: 'SECCOMP_AUDIT_ARCH' undeclared here (not in a function); did you mean 'SECCOMP_ALLOW_ARG'?
  BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, SECCOMP_AUDIT_ARCH, 1, 0),
                                      ^~~~~~~~~~~~~~~~~~

It should be noted that AUDIT_ARCH_{ARCOMPACT,ARCV2} is only defined
since kernel 5.2 and
67f2a8a293

Detection of arc compact and arc v2 have been "copy/pasted" from
afab56958f

Fixes:
 - http://autobuild.buildroot.org/results/d29083700a80dd647621eed06faeeae03f0587d3

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
2021-02-08 06:23:54 +00:00
Fabrice Fontaine
f3f7332001
src/privsep-linux.c: add support for or1k (#27)
Fix the following build failure:

privsep-linux.c:206:4: error: #error "Platform does not support seccomp filter yet"
 #  error "Platform does not support seccomp filter yet"
    ^~~~~
In file included from privsep-linux.c:36:
privsep-linux.c:213:38: error: 'SECCOMP_AUDIT_ARCH' undeclared here (not in a function); did you mean 'SECCOMP_ALLOW_ARG'?
  BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, SECCOMP_AUDIT_ARCH, 1, 0),
                                      ^~~~~~~~~~~~~~~~~~

It should be noted that AUDIT_ARCH_OPENRISC is defined since kernel 3.7:
e2bebb4ae6

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
2021-02-07 08:43:14 +00:00
Roy Marples
e36d62c22c Force TOP as we know which directory we are in. 2021-02-05 22:41:16 +00:00
Roy Marples
7b2fb275ee control fd can be both read and write. 2021-02-05 21:56:40 +00:00
Fabrice Fontaine
dcfd7a23f0
src/privsep-linux: fix build on sparc (#26)
Fix the following build failure:

privsep-linux.c:203: warning: "AUDIT_ARCH_SPARC64" redefined
  203 | #    define AUDIT_ARCH_SPARC64
      |
In file included from privsep-linux.c:35:
/srv/storage/autobuild/run/instance-0/output-1/host/sparc64-buildroot-linux-gnu/sysroot/usr/include/linux/audit.h:392: note: this is the location of the previous definition
  392 | #define AUDIT_ARCH_SPARC64 (EM_SPARCV9|__AUDIT_ARCH_64BIT)
      |
In file included from privsep-linux.c:36:
privsep-linux.c:215:38: error: 'SECCOMP_AUDIT_ARCH' undeclared here (not in a function); did you mean 'SECCOMP_ALLOW_ARG'?
  215 |  BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, SECCOMP_AUDIT_ARCH, 1, 0),
      |                                      ^~~~~~~~~~~~~~~~~~

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
2021-02-05 08:25:12 +00:00
Fabrice Fontaine
166491c295 src/privsep-linux.c: add support for sh (#25)
Fix the following build failure:

privsep-linux.c:206:4: error: #error "Platform does not support seccomp filter yet"
 #  error "Platform does not support seccomp filter yet"
    ^~~~~
In file included from privsep-linux.c:36:
privsep-linux.c:213:38: error: 'SECCOMP_AUDIT_ARCH' undeclared here (not in a function); did you mean 'SECCOMP_ALLOW_ARG'?
  BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, SECCOMP_AUDIT_ARCH, 1, 0),
                                      ^~~~~~~~~~~~~~~~~~

It should be noted that AUDIT_ARCH_{SH,SHEL,SH64,SHEL64} are defined at
least since kernel 3.7 and
607ca46e97

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
2021-02-05 08:08:35 +00:00
Roy Marples
0025a1268a Fix tests 2021-02-03 20:52:01 +00:00