1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-08 11:27:32 +03:00
Commit Graph

12645 Commits

Author SHA1 Message Date
Tom Gundersen
6af9144f5f sd-ipv4ll: simplify conflict handling
Use stop() and start() to drop some pulicate code.
2015-09-18 15:14:43 +02:00
Tom Gundersen
b45e4eb679 sd-ipv4ll: rework callbacks
Firstly, no longer distinguish between STOP and INIT states.

Secondly, do not trigger STOP events when calls to sd_ipv4ll_*() fail. The
caller is the one who would receive the event and will already know that the
call to sd_ipv4ll_*() has failed, so it is redundant.

STOP events will now only be triggered by calling sd_ipv4ll_stop() explicitly
or by some internal error in the library triggered by receiving a packet or
an expiring timeout (i.e., any error that would otherwise not be reported
back to the consumer of the library).

Lastly, follow CODING_STYLE and always return NULL on unref. Protect from
objects being destroyed in callbacks accordingly.
2015-09-18 15:14:43 +02:00
Tom Gundersen
5707940ed3 sd-ipv4ll: don't allow changing MAC address whilst running
This requires the caller to stop and restart the statemachine if they want to
change the MAC address.
2015-09-18 15:14:42 +02:00
Tom Gundersen
94a355a130 sd-ipv4ll: code cleanups
Simplify timeout handling.
2015-09-18 15:14:42 +02:00
Tom Gundersen
028e0b2056 sd-ipv4ll: remove duplicate packet verification
Most packets are filtered out by the BPF, so only check for the parts that may
actually differ.
2015-09-18 15:14:42 +02:00
Tom Gundersen
25d6213b43 sd-ipv4ll: minor cleanups 2015-09-18 15:14:42 +02:00
Tom Gundersen
b26f7e8ec9 sd-ipv4ll: split out on_conflict() from on_packet() 2015-09-18 15:14:42 +02:00
Tom Gundersen
8e5787b5e0 sd-ipv4ll: split run_state_machine() into on_packet() and on_timeout()
Simplify the code a bit, no functional change.
2015-09-18 15:14:42 +02:00
Tom Gundersen
996d16975b sd-ipv4ll: filter out unwanted ARP packets in the kernel
We currently process every ARP packet, but we should only care about the ones
relating to our IP address.

Also rename ipv4ll helpers to apr-utils.[ch], and rework the helpers a bit.
2015-09-18 15:14:42 +02:00
Lennart Poettering
16a012b1d0 Merge pull request #1241 from ssahani/net
networkd: add support for accept ra
2015-09-18 13:04:50 +02:00
Michal Schmidt
a0f5ab70f3 sd-bus: correct size calculation in DBus fd receive
The size of the allocated array for received file descriptors was
incorrectly calculated. This did not matter when a single file
descriptor was received, but for more descriptors the allocation was
insufficient.
2015-09-16 23:53:32 +02:00
Lennart Poettering
5ee50f525f Merge pull request #1269 from zonque/netcls
cgroup: add support for net_cls controllers
2015-09-16 20:59:31 +02:00
Tom Gundersen
5eefe544ef resolved: cache - cache what we can of negative redirect chains
When a NXDATA or a NODATA response is received for an alias it may
include CNAME records from the redirect chain. We should cache the
response for each of these names to avoid needless roundtrips in
the future.

It is not sufficient to do the negative caching only for the
canonical name, as the included redirection chain is not guaranteed
to be complete. In fact, only the final CNAME record from the chain
is guaranteed to be included.

We take care not to cache entries that redirects outside the current
zone, as the SOA will then not be valid.
2015-09-16 17:03:18 +02:00
Tom Gundersen
5643c00afe resolved: cache - handle CNAME redirection
CNAME records are special in the way they are treated by DNS servers,
and our cache should mimic that behavior: In case a domain name has an
alias, its CNAME record is returned in place of any other.

Our cache was not doing this despite caching the CNAME records, this
entailed needless lookups to re-resolve the CNAME.
2015-09-16 17:03:17 +02:00
Tom Gundersen
8e427d9be9 resolved: cache - only allow putting a single question key at a time
Only one key is allowed per transaction now, so let's simplify things and only allow putting
one question key into the cache at a time.
2015-09-16 17:03:17 +02:00
Tom Gundersen
36d9205d66 resolved: rr - introduce dns_resource_key_new_redirect()
Takes a key and CNAME RR and returns the canonical RR of the right
type. Make use of this in dns_question_redirect().
2015-09-16 17:03:17 +02:00
Tom Gundersen
7c1ff6ac3d resolved: rr - introduce dns_resource_key_new_cname()
Creates a new CNAME RR key with the same class and name as an existing key.
2015-09-16 17:03:17 +02:00
Tom Gundersen
04f9320120 resolved: cache - clarify logging 2015-09-16 17:03:17 +02:00
Michal Schmidt
a8b626100b basic: nicer xsprintf and xstrftime assert messages
It's nicer if the assertion failure message from a bad use of xsprintf
actually mentions xsprintf instead of the expression the macro is
implemented as.

The assert_message_se macro was added in the previous commit as an
internal helper, but it can also be used for customizing assertion
failure messages like in this case.

Example:
  char buf[10];
  xsprintf(buf, "This is a %s message.\n", "long");

Before:
  Assertion '(size_t) snprintf(buf, ELEMENTSOF(buf), "This is a %s
  message.\n", "long") < ELEMENTSOF(buf)' failed at foo.c:6, function
  main(). Aborting.

After:
  Assertion 'xsprintf: buf[] must be big enough' failed at foo.c:6,
  function main(). Aborting.
2015-09-16 15:48:00 +02:00
Michal Schmidt
34c38d2aaa basic: nicer assert messages
Make sure the assert expression is not macro-expanded before
stringification. This makes several assertion failure messages more
readable.

As an example:
  assert(streq("foo", "bar"));

I'd rather see this:

Assertion 'streq("foo", "bar")' failed at foo.c:5, function main(). Aborting.

...than this, though awesome, incomprehensible truncated mess:

Assertion '(__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p ((
"foo")) && __builtin_constant_p (("bar")) && (__s1_len = strlen (("foo")), __s2_
len = strlen (("bar")), (!((size_t)(const void *)((("foo")) + 1) - (size_t)(cons
t void *)(("foo")) == 1) || __s1_len >= 4) && (!((size_t)(const void *)((("bar")
) + 1) - (size_t)(const void *)(("bar")) == 1) || __s2_len >= 4)) ? __builtin_st
rcmp (("foo"), ("bar")) : (__builtin_constant_p (("foo")) && ((size_t)(const voi
d *)((("foo")) + 1) - (size_t)(const void *)(("foo")) == 1) && (__s1_len = strle
n (("foo")), __s1_len < 4) ? (__builtin_constant_p (("bar")) && ((size_t)(const
void *)((("bar")) + 1) - (size_t)(const void *)(("bar")) == 1) ? __builtin_strcm
p (("foo"), ("bar")) : (__extension__ ({ const unsigned char *__s2 = (const unsi
gned char *) (const char *) (("bar")); int __result = (((const unsigned char *)
(const char *) (("foo")))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __
result = (((const unsigned char *) (const char *) (("foo")))[1] - __s2[1]); if (
__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const cha
r *) (("foo")))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((
const unsigned char *) (const char *) (("foo")))[3] - __s2[3]); } } __result; })
)) : (__builtin_constant_p (("bar")) && ((size_t)(const void *)((("bar")) + 1) -
 (size_t)(const void *)(("bar")) == 1) && (__s2_len = strlen (("bar")), __s2_len
 < 4) ? (__builtin_constant_p (("foo")) && ((size_t)(const void *)((("foo")) + 1
) - (size_t)(const void *)(("foo")) == 1) ? __builtin_strcmp (("foo"), ("bar"))
: (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (cons
t char *) (("foo")); int __result = (((const unsigned char *) (const char *) (("
bar")))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const
unsigned char *) (const char *) (("bar")))[1] - __s2[1]); if (__s2_len > 1 && __
result == 0) { __result = (((const unsigned char *) (const char *) (("bar")))[2]
 - __s2[2]); if (__s2_len > 2 && __result == 0)
2015-09-16 15:48:00 +02:00
Michal Schmidt
7f39a21045 basic: make sure argument of ELEMENTSOF is an array
Using ELEMENTSOF on a pointer will result in a compilation error.
2015-09-16 15:32:25 +02:00
Daniel Mack
32ee7d3309 cgroup: add support for net_cls controllers
Add a new config directive called NetClass= to CGroup enabled units.
Allowed values are positive numbers for fix assignments and "auto" for
picking a free value automatically, for which we need to keep track of
dynamically assigned net class IDs of units. Introduce a hash table for
this, and also record the last ID that was given out, so the allocator
can start its search for the next 'hole' from there. This could
eventually be optimized with something like an irb.

The class IDs up to 65536 are considered reserved and won't be
assigned automatically by systemd. This barrier can be made a config
directive in the future.

Values set in unit files are stored in the CGroupContext of the
unit and considered read-only. The actually assigned number (which
may have been chosen dynamically) is stored in the unit itself and
is guaranteed to remain stable as long as the unit is active.

In the CGroup controller, set the configured CGroup net class to
net_cls.classid. Multiple unit may share the same net class ID,
and those which do are linked together.
2015-09-16 00:21:55 +02:00
Lennart Poettering
d801577473 Merge pull request #1250 from g2p/master
Hook more properties for transient units
2015-09-14 23:19:03 +02:00
Susant Sahani
4f2e437ad7 networkd:add support to configure ipv6 acceprt ra
This patch support to configure the ipv6 acceprt ra option.

for more information see
http://www.tldp.org/HOWTO/Linux+IPv6-HOWTO/proc-sys-net-ipv6..html
2015-09-12 08:18:06 +05:30
Lennart Poettering
e7ab4d1ac9 cgroup: unify how we invalidate cgroup controller settings
Let's make sure that we follow the same codepaths when adjusting a
cgroup property via the dbus SetProperty() call, and when we execute the
StartupCPUShares= effect.
2015-09-11 18:31:50 +02:00
Lennart Poettering
1afaa7e8d2 transaction: clarify via void-casting that we ignore the pipe2() return value for a reason 2015-09-11 18:31:50 +02:00
Lennart Poettering
cd72bd8a46 core: invalidate idle pipe event source in manager_close_idle_pipe()
In all occasions when this function is called we do so anyway, so let's
move this inside, to make things easier.
2015-09-11 18:31:50 +02:00
Lennart Poettering
c7cc737fce execute: fix return type from write() 2015-09-11 18:31:49 +02:00
Lennart Poettering
54eb2300ae execute: invalidate idle pipe after use
Not strictly necessary, but makes clear the fds are invalidated. Make
sure we do the same here as in most other cases.
2015-09-11 18:31:49 +02:00
Lennart Poettering
5269eb6b32 core: allocate sets of startup and failed units on-demand
There's a good chance we never needs these sets, hence allocate them
only when needed.
2015-09-11 18:31:49 +02:00
Lennart Poettering
aa36007ca1 timesyncd: fix how we print a PID 2015-09-11 18:31:49 +02:00
Lennart Poettering
d53d94743c core: refactor cpu shares/blockio weight cgroup logic
Let's stop using the "unsigned long" type for weights/shares, and let's
just use uint64_t for this, as that's what we expose on the bus.

Unify parsers, and always validate the range for these fields.

Correct the default blockio weight to 500, since that's what the kernel
actually uses.

When parsing the weight/shares settings from unit files accept the empty
string as a way to reset the weight/shares value. When getting it via
the bus, uniformly map (uint64_t) -1 to unset.

Open up StartupCPUShares= and StartupBlockIOWeight= to transient units.
2015-09-11 18:31:49 +02:00
Lennart Poettering
afc966e288 util: remove ring.[ch] + pty.[ch] and tests
This was used by consoled, which was removed, let's remove this too now.
2015-09-11 18:28:29 +02:00
Gabriel de Perthuis
b9c50073fc Hook more properties for transient units
systemd-run can now launch units with PrivateTmp, PrivateDevices,
PrivateNetwork, NoNewPrivileges set.
2015-09-11 18:25:41 +02:00
Lennart Poettering
85bc8c64e9 Merge pull request #1248 from lnykryn/loginctl-show-v2
loginctl: print nontrivial properties in logictl show-*
2015-09-11 16:28:36 +02:00
Lukas Nykryn
2a998c7402 loginctl: print nontrivial properties in logictl show-* 2015-09-11 16:04:32 +02:00
Evgeny Vereshchagin
478b619281 core: kill processes started due to the ExecReload= on timeout 2015-09-11 11:43:27 +03:00
Lennart Poettering
3227b2bced Merge pull request #1227 from intelfx/systemctl-legacy-tools-polkit
systemctl: fix various aspects of polkit authorization in legacy tools.
2015-09-10 19:53:31 +02:00
Daniel Mack
f70e152ec6 Merge pull request #1222 from poettering/image-ops-settings
machine: when removing, renaming, cloning images also care for .nspaw…
2015-09-10 19:18:18 +02:00
Daniel Mack
a18f3caa56 Merge pull request #1239 from poettering/cgroup-pids
core: add support for the "pids" cgroup controller
2015-09-10 19:11:29 +02:00
Daniel Mack
786c5bf957 Merge pull request #1242 from poettering/no-off_t
Drop usage of off_t
2015-09-10 19:01:25 +02:00
Lennart Poettering
03a7b521e3 core: add support for the "pids" cgroup controller
This adds support for the new "pids" cgroup controller of 4.3 kernels.
It allows accounting the number of tasks in a cgroup and enforcing
limits on it.

This adds two new setting TasksAccounting= and TasksMax= to each unit,
as well as a gloabl option DefaultTasksAccounting=.

This also updated "cgtop" to optionally make use of the new
kernel-provided accounting.

systemctl has been updated to show the number of tasks for each service
if it is available.

This patch also adds correct support for undoing memory limits for units
using a MemoryLimit=infinity syntax. We do the same for TasksMax= now
and hence keep things in sync here.
2015-09-10 18:41:06 +02:00
Lennart Poettering
59f448cf15 tree-wide: never use the off_t unless glibc makes us use it
off_t is a really weird type as it is usually 64bit these days (at least
in sane programs), but could theoretically be 32bit. We don't support
off_t as 32bit builds though, but still constantly deal with safely
converting from off_t to other types and back for no point.

Hence, never use the type anymore. Always use uint64_t instead. This has
various benefits, including that we can expose these values directly as
D-Bus properties, and also that the values parse the same in all cases.
2015-09-10 18:16:18 +02:00
Lennart Poettering
15af581253 Merge pull request #1236 from evverx/systemctl-requisite-of
systemctl: add RequisiteOf* as inverses of Requisite and RequisiteOverridable
2015-09-10 16:40:04 +02:00
Evgeny Vereshchagin
1143adf722 systemctl: add RequisiteOf* as inverses of Requisite and RequisiteOverridable 2015-09-10 14:49:29 +03:00
Daniel Mack
f33be31198 Merge pull request #1226 from poettering/coccinelle-fixes3
Third round of Coccinelle fixes
2015-09-10 13:46:14 +02:00
Ivan Shapovalov
58158dc765 systemctl: improve clarity of error messages in the logind path 2015-09-10 14:45:00 +03:00
Ivan Shapovalov
2ac3930f5b systemctl: relax permission checks in halt_main()
Thus we allow (non-interactive) polkit auth to kick in for legacy commands
(halt, poweroff, reboot, telinit) as well.

Fixes (another aspect of) issue #213.
2015-09-10 14:45:00 +03:00
Ivan Shapovalov
a9085ea356 systemctl: fix logind bus call error handling in halt_main()
Handle -EOPNOTSUPP and -EINPROGRESS like in start_special().
2015-09-10 14:44:59 +03:00
Ivan Shapovalov
4c315c2c7c systemctl: minor: use IN_SET() instead of repeated equality checks. 2015-09-10 14:39:46 +03:00