Commit Graph

5458 Commits

Author SHA1 Message Date
Roy Marples
def6e99252 Rename Privileged Actioneer to Privileged Proxy
Sadly actioneer is not a real word.
2021-02-02 17:09:25 +00:00
Roy Marples
f6082bca98 Rename Master to Manager 2021-02-02 16:54:09 +00:00
Roy Marples
3c26587f67 Fix prior for epoll. 2021-02-02 15:10:20 +00:00
Roy Marples
5d619328bf eloop: Make the API more like native poll/kqueue/epoll
Just have the one callback, but return an abstracted event mask
to work out if we can read/write have something else.
Log diagnostics if the event mask is unexpected.

While here add more logging if we fail to register an event to
monitor.
2021-02-02 14:41:54 +00:00
Roy Marples
b042338612 Add __NR_pselect6_time64 to priory 2021-01-31 21:12:26 +00:00
Roy Marples
1c6c0860c5 Linux: allow pselect(2) to work in SECCOMP
The default is ppoll(2), but we still allow epoll(7) so
allowing pselect(2) makes perfect sense and allows the user
to pick the polling mechanism they want.
2021-01-31 21:07:43 +00:00
Fabrice Fontaine
e3a40586db
src/privsep-linux.c: add support for microblaze (#24)
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_MICROBLAZE is only defined since
kernel 3.18 and
ce5d112827

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
2021-01-31 20:57:40 +00:00
Roy Marples
f3d2ff551b A belated welcome to 2021 2021-01-31 10:33:21 +00:00
Fabrice Fontaine
d670866ce0
src/privsep-linux.c: add support for nios2 (#23)
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_NIOS2 is only defined since kernel
5.2 and
1660aac45e

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
2021-01-31 10:12:21 +00:00
Roy Marples
d8d7f68001 Typo with prior 2021-01-31 10:08:11 +00:00
Roy Marples
8253ef16e1 Linux: Add support for NDS32BE SECCOMP 2021-01-31 07:37:03 +00:00
Fabrice Fontaine
19c3d9209a
src/privsep-linux.c: add support for xtensa (#22)
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_XTENSA is only defined since kernel
5.0 and
98c3115a4e

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
2021-01-31 02:35:10 +00:00
Roy Marples
55df1b68f6 import-src: Improve target so we don't create empty files 2021-01-30 12:21:15 +00:00
Roy Marples
b29f653581 import-src: adjust build target so all .in files are pre-built
While here, if we cannot find ypbind to work out how the hook script
should be configured, guess according to OS.
2021-01-30 11:46:06 +00:00
Fabrice Fontaine
3848e7204f
src/privsep-linux.c: add support for nds32 (#21)
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_NDS32 is only defined since kernel
5.2 and
fa562447e1

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

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
2021-01-30 11:10:08 +00:00
Roy Marples
01fabe6f5e eloop: optimise the pselect code so it's not a wrapper for ppoll
This makes the code smaller yet and also use less memory then ppoll!
Still, the API blows chunks and we still have arbitary fd limits
which we'll realistically never hit.
Also, some BSD's note potential issues with select on the same fd
across processes so ppoll is still the winner.
2021-01-30 11:04:53 +00:00
Roy Marples
d747ef075c eloop: Default to using ppoll(2) again.
Even though we now have fully working kqueue(2) and epoll(7)
with our privsep code, ppoll(2) is faster and smaller for our
workload.

This time though, we will keep the code here as it's fully working
and while fixing kqueue we also fixed other bugs in dhcpcd as a result
so it's not time wasted at all.
2021-01-30 01:37:15 +00:00
Roy Marples
e11849f8e2 eloop: Fix logic error with epoll reading test 2021-01-30 01:10:21 +03:00
Roy Marples
a9cb061e38 eloop: Always free the pollfd buffer when clearing events
And set the flag to re-create it before the next run.
This allows us to always ensure it's small if the prior run
used more signals and fds.
2021-01-29 11:13:43 +00:00
Roy Marples
14d3b511ee eloop: fix a memory leak when clearing events 2021-01-29 06:53:12 +00:00
Roy Marples
410ea0e8c6 Whitespace 2021-01-29 06:46:39 +00:00
Roy Marples
5456a4a3b0 eloop: fixup a compile warning 2021-01-28 23:25:26 +00:00
Roy Marples
e5f451918c BSD: Plug a memory leak 2021-01-28 23:24:49 +00:00
Roy Marples
701a9d031e Linux: Implement epoll(7) for eloop (again)
eloop allows for O(1) processing of active fd's.
The problems with the prior implementation have now been fixed.
2021-01-28 17:26:20 +00:00
Roy Marples
07af15970a control: Don't log the write db didn't exist when freeing it. 2021-01-28 17:26:08 +00:00
Roy Marples
55c9cda13b privsep: Restore the poll maxfd + 1 for state engine
It wasn't fixed, it was using kqueue so avoided!
2021-01-28 13:17:57 +00:00
Roy Marples
b62b3780ac DragonFly: cast away more kqueue compile warnings 2021-01-28 12:51:47 +00:00
Roy Marples
76b466bb62 FreeBSD: cast away some kqueue warnings
NetBSD uses size_t, FreeBSD uses int for changelist length.
2021-01-28 12:39:07 +00:00
Roy Marples
62cb1ffc50 privsep: Don't add 1 to max fd open when limiting resources
It shoud no longer be needed for OpenBSD, Linux and Solaris.
2021-01-28 12:13:45 +00:00
Roy Marples
44bbb1a68b OpenBSD: Fix kqueue detection and one error. 2021-01-28 12:13:24 +00:00
Roy Marples
11baa2a1f5 BSD: Implement kqueue(2) for eloop (again)
kqueue allows for O(1) processing of active fd's an a more
robust signal handling method without the need to use global
variables to avoid calling functions during signal delivery.

The problems with the prior implemenation have now been fixed.
2021-01-28 11:54:05 +00:00
Roy Marples
3ffb1dd5ee privsep: move setting signals to after clearing eloop 2021-01-27 14:11:52 +00:00
Roy Marples
534eb959e8 Whitespace 2021-01-27 13:45:34 +00:00
Roy Marples
ca1a5ca0ea privsep: Ensure BPF listener pid is logged in debug
This mirrors the inet listener.
2021-01-27 13:37:31 +00:00
Roy Marples
9e27c9216d control: log an error if we fail to remove the write callback 2021-01-27 13:33:52 +00:00
Roy Marples
de92f37d68 Whitespace 2021-01-27 13:31:51 +00:00
Roy Marples
d55f8e4403 control: unlink privileged socket when shutting down without privsep
Otherwise we have a connection refused when dhcpcd starts again
as it sees the stale socket file.
2021-01-26 17:37:29 +00:00
Roy Marples
ba9f3823ae Linux: fix a memory leak when dhcpcd exits or the log is reopened 2021-01-24 22:53:20 +00:00
Roy Marples
fe2b82eec2 eloop: Allow eloop to process all fds returned from poll(2)
We do this by ensuring the events list or pollfd struct storage
is not modified during the revent processing.
An event with a fd of -1 means it's been deleted and one without
a pollfd struct reference has been newly added.
This also allows us to count down the number of fd's that
returned a revent so we can break the loop early if possible.

This is a really minor optimisation that at best only applies if
more than one revent is returned via poll(2).
In the case on dhcpcd on NetBSD with privsep, the number of
fd's is really low. And on other platforms or without privsep it's
low also (just not as low).
It's only when you run dhcpcd per interface that the number
of fd's starts to creep upwards as you then need one per address
dhcpcd is monitoring (as well as the ARP listener per IPv4 address
for non NetBSD).

However, I use eloop in other code where this could be a good saving
and dhcpcd is where the master version of this lives!
2021-01-24 22:22:25 +00:00
Roy Marples
39b397dddd script: Use rt_proto_add to ensure no duplicate interfaces on OpenBSD
OpenBSD allows matching priorities, so we need to take the interfaces
in the order given to ensure uniqueness.
2021-01-18 11:31:05 +00:00
Roy Marples
dbb8e334c9 Release dhcpcd-9.4.0 2020-12-28 12:59:20 +00:00
Roy Marples
dec1f731d6 script: ignore inactive interfaces for ordering 2020-12-28 01:59:57 +00:00
Roy Marples
2bd74fa2ac DHCP: Split hardware address randomisation out of anonymous option
A 3rd party might want to control the randomisation.
2020-12-28 00:02:26 +00:00
Roy Marples
486ad9aaf6 DHCP: For anonymous, just use a generic clientid 2020-12-27 23:52:44 +00:00
Roy Marples
6468e7f2c0 20-resolv.conf: Don't call resolvconf -c if we didn't call -C
This solves the warnings on all OS other than Linux who don't have
a supporting resolvconf for deprecating DNS because they never
emit the NOCARRIER_ROAMING reason.
2020-12-27 22:33:11 +00:00
Roy Marples
4b2668b9e2 Check for NetBSD in prior, as we did before 2020-12-27 22:04:45 +00:00
Roy Marples
bb5de1714e dhcpcd: Don't roam when anonymous is set
We can now remove the NOCARRIER_PRESERVE_IP define.
2020-12-27 21:59:32 +00:00
Roy Marples
440081797a NetBSD: Map IP Persistance to roaming
We can use IN_IFF_TENTATIVE for this.
2020-12-27 20:39:38 +00:00
Roy Marples
d93d9b90e2 Adjust prior to build routes and run script after aborting protocols for roaming 2020-12-27 20:39:31 +00:00
Roy Marples
3547ed19f0 hooks: add NOCARRIER_ROAMING reason
This is given when the OS supports the concept of wireless roaming
or the IP setup can be persisted when the carrier drops.

When this happens, routes are moved to a higher metric (if supported)
to support non preferred but non roaming routes.
The `interface_order` hook variable will now order the interfaces
according to priority and move roaming interfaces to the back of the
list.
If resolvconf is present then it is called with the -C option
to deprecate DNS and if carrier comes back it is called again with the
-c option to activate it once more.

As part of this change, default route metrics have been changed to
support a larger number of interfaces.
base metric		1000		(was 200)
wireless offset		2000		(was 100)
IPv4LL offset		1000000		(was 10000)
roaming offset		2000000
2020-12-27 19:53:31 +00:00