summaryrefslogtreecommitdiff
path: root/src/network/networkd.c
Commit message (Collapse)AuthorAgeFilesLines
* tree-wide: drop redundant _cleanup_ macros (#8810)Lennart Poettering2018-04-251-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | This drops a good number of type-specific _cleanup_ macros, and patches all users to just use the generic ones. In most recent code we abstained from defining type-specific macros, and this basically removes all those added already, with the exception of the really low-level ones. Having explicit macros for this is not too useful, as the expression without the extra macro is generally just 2ch wider. We should generally emphesize generic code, unless there are really good reasons for specific code, hence let's follow this in this case too. Note that _cleanup_free_ and similar really low-level, libc'ish, Linux API'ish macros continue to be defined, only the really high-level OO ones are dropped. From now on this should really be the rule: for really low-level stuff, such as memory allocation, fd handling and so one, go ahead and define explicit per-type macros, but for high-level, specific program code, just use the generic _cleanup_() macro directly, in order to keep things simple and as readable as possible for the uninitiated. Note that before this patch some of the APIs (notable libudev ones) were already used with the high-level macros at some places and with the generic _cleanup_ macro at others. With this patch we hence unify on the latter.
* tree-wide: drop license boilerplateZbigniew Jędrzejewski-Szmek2018-04-061-13/+0
| | | | | | | | | | Files which are installed as-is (any .service and other unit files, .conf files, .policy files, etc), are left as is. My assumption is that SPDX identifiers are not yet that well known, so it's better to retain the extended header to avoid any doubt. I also kept any copyright lines. We can probably remove them, but it'd nice to obtain explicit acks from all involved authors before doing that.
* tree-wide: warn when a directory path already exists but has bad mode/owner/typeZbigniew Jędrzejewski-Szmek2018-03-231-4/+4
| | | | | | | | | | | | | | | | | | | | | When we are attempting to create directory somewhere in the bowels of /var/lib and get an error that it already exists, it can be quite hard to diagnose what is wrong (especially for a user who is not aware that the directory must have the specified owner, and permissions not looser than what was requested). Let's print a warning in most cases. A warning is appropriate, because such state is usually a sign of borked installation and needs to be resolved by the adminstrator. $ build/test-fs-util Path "/tmp/test-readlink_and_make_absolute" already exists and is not a directory, refusing. (or) Directory "/tmp/test-readlink_and_make_absolute" already exists, but has mode 0775 that is too permissive (0755 was requested), refusing. (or) Directory "/tmp/test-readlink_and_make_absolute" already exists, but is owned by 1001:1000 (1000:1000 was requested), refusing. Assertion 'mkdir_safe(tempdir, 0755, getuid(), getgid(), MKDIR_WARN_MODE) >= 0' failed at ../src/test/test-fs-util.c:320, function test_readlink_and_make_absolute(). Aborting. No functional change except for the new log lines.
* basic/mkdir: convert bool flag to enumZbigniew Jędrzejewski-Szmek2018-03-221-4/+4
| | | | In preparation for subsequent changes...
* network: create runtime sub-directories after drop_privileges()Yu Watanabe2018-01-171-14/+18
| | | | | | | | | | | For old kernels not supporting AmbientCapabilities=, networkd is started as root with limited capabilities. Then, networkd cannot chown the directories under runtime directory as CapabilityBoundingSet= does not contains enough capabilities. This makes these directories are created after dropping privileges. Thus, networkd does not need to chown them anymore. Fixes #7863.
* Add SPDX license identifiers to source files under the LGPLZbigniew Jędrzejewski-Szmek2017-11-191-0/+1
| | | | | This follows what the kernel is doing, c.f. https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5fd54ace4721fc5ce2bb5aef6318fcf17f421460.
* mkdir: introduce follow_symlink flag to mkdir_safe{,_label}()Yu Watanabe2017-10-061-4/+4
|
* networkd: add support to configure IP Rule (#5725)Susant Sahani2017-09-141-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Routing Policy rule manipulates rules in the routing policy database control the route selection algorithm. This work supports to configure Rule ``` [RoutingPolicyRule] TypeOfService=0x08 Table=7 From= 192.168.100.18 ``` ``` ip rule show 0: from all lookup local 0: from 192.168.100.18 tos 0x08 lookup 7 ``` V2 changes: 1. Added logic to handle duplicate rules. 2. If rules are changed or deleted and networkd restarted then those are deleted when networkd restarts next time V3: 1. Add parse_fwmark_fwmask
* units: make use of !! ExecStart= prefix in systemd-networkd.serviceYu Watanabe2017-08-271-7/+11
| | | | | Let's make use of !! to run networkd with ambient capabilities on systems supporting them.
* networkd: move event loop handling out of the manager (#4723)Tom Gundersen2016-11-281-3/+20
| | | | | | | | | | | This will allow us to have several managers sharing an event loop and running in parallel, as if they were running in separate processes. The long term-aim is to allow networkd to be split into separate processes, so restructure the code to make this simpler. For now we drop the exit-on-idle logic, as this was anyway severely restricted at the moment. Once split, we will revisit this as it may then make more sense again.
* networkd: clean up main header file a bitTom Gundersen2016-11-141-1/+1
| | | | | Rename networkd.h to networkd-manager.h, to more accurately describe what it contains.
* DHCP DUID, IAID configuration optionsVinay Kulkarni2016-03-301-0/+5
|
* Revert "DHCP DUID and IAID configurability"revert-2818-masterZbigniew Jędrzejewski-Szmek2016-03-211-5/+0
|
* DHCP DUID and IAID configurabilityVinay Kulkarni2016-03-091-0/+5
|
* tree-wide: remove Emacs lines from all filesDaniel Mack2016-02-101-2/+0
| | | | | This should be handled fine now by .dir-locals.el, so need to carry that stuff in every file.
* networkd: route - track routesTom Gundersen2015-10-301-0/+6
|
* src/basic: rename audit.[ch] → audit-util.[ch] and capability.[ch] → ↵Lennart Poettering2015-10-271-1/+1
| | | | | | | | | capability-util.[ch] The files are named too generically, so that they might conflict with the upstream project headers. Hence, let's add a "-util" suffix, to clarify that this are just our utility headers and not any official upstream headers.
* util-lib: split out user/group/uid/gid calls into user-util.[ch]Lennart Poettering2015-10-261-1/+3
|
* Fix error message for enumerate addressesrinrinne2015-07-031-1/+1
| | | | | Error message for enumerating addresses was not 'addresses' but 'links'. This patch fixes it.
* everywhere: port everything to sigprocmask_many() and friendsLennart Poettering2015-06-151-1/+1
| | | | | | | | | | | This ports a lot of manual code over to sigprocmask_many() and friends. Also, we now consistly check for sigprocmask() failures with assert_se(), since the call cannot realistically fail unless there's a programming error. Also encloses a few sd_event_add_signal() calls with (void) when we ignore the return values for it knowingly.
* util: split out signal-util.[ch] from util.[ch]Lennart Poettering2015-05-291-2/+2
| | | | No functional changes.
* networkd: use LOG_WARN not LOG_ERR for non-fatal errorsZbigniew Jędrzejewski-Szmek2015-03-211-6/+4
|
* remove unused includesThomas Hindoe Paaboel Andersen2015-02-231-1/+0
| | | | | | This patch removes includes that are not used. The removals were found with include-what-you-use which checks if any of the symbols from a header is in use.
* networkd: move the connection to the bus out of manager_new (again)Tom Gundersen2015-02-051-0/+6
| | | | This would otherwise make the tests fail as we cannot grab the bus name.
* networkd: exit on idleTom Gundersen2015-02-051-1/+1
| | | | | | We will be woken up on rtnl or dbus activity, so let's just quit if some time has passed and that is the only thing that can happen. Note that we will always stay around if we expect network activity (e.g. DHCP is enabled), as we are not restarted on that.
* networkd: log when finished enumerating links and addressesTom Gundersen2015-02-051-0/+2
|
* networkd: refactor socket activation a bitTom Gundersen2015-02-031-18/+0
|
* LLDP: Add support for networkctlSusant Sahani2014-12-191-0/+6
|
* networkd: manager - enumerate addresses globally, rather than per-linkTom Gundersen2014-12-081-0/+6
| | | | The kernel always returns all addresses, rather than only for the given link, so let's only enumerate once.
* treewide: more log_*_errno() conversions, multiline callsMichal Schmidt2014-11-281-6/+3
| | | | | | | | | | | | Basically: find . -name '*.[ch]' | while read f; do perl -i.mmm -e \ 'local $/; local $_=<>; s/log_(debug|info|notice|warning|error|emergency)\("([^"]*)%s"([^;]*),\s*strerror\(-?([->a-zA-Z_]+)\)\);/log_\1_errno(\4, "\2%m"\3);/gms;print;' \ $f; done Plus manual indentation fixups.
* treewide: no need to negate errno for log_*_errno()Michal Schmidt2014-11-281-8/+8
| | | | It corrrectly handles both positive and negative errno values.
* treewide: auto-convert the simple cases to log_*_errno()Michal Schmidt2014-11-281-8/+8
| | | | | | | | | | | | | As a followup to 086891e5c1 "log: add an "error" parameter to all low-level logging calls and intrdouce log_error_errno() as log calls that take error numbers", use sed to convert the simple cases to use the new macros: find . -name '*.[ch]' | xargs sed -r -i -e \ 's/log_(debug|info|notice|warning|error|emergency)\("(.*)%s"(.*), strerror\(-([a-zA-Z_]+)\)\);/log_\1_errno(-\4, "\2%m"\3);/' Multi-line log_*() invocations are not covered. And we also should add log_unit_*_errno().
* notify: send STOPPING=1 from our daemonsLennart Poettering2014-08-211-0/+1
|
* networkd: simplify signal handling of SIGTERM/SIGINTLennart Poettering2014-07-071-0/+2
| | | | | sd-event makes handling SIGTERM/SIGINT a lot easier than it used to, let's make use of this
* networkd: split runtime config dir from state dirTom Gundersen2014-06-031-3/+3
| | | | | | | | | | | | Configuration will be in root:root /run/systemd/network and state will be in systemd-network:systemd-network /run/systemd/netif This matches what we do for logind's seat/session state.
* networkd: drop CAP_SYS_MODULETom Gundersen2014-06-031-2/+1
| | | | | | | | | | | | | | | | | | | Rely on modules being built-in or autoloaded on-demand. As networkd is a network facing service, we want to limits its capabilities, as much as possible. Also, we may not have CAP_SYS_MODULE in a container, and we want networkd to work the same there. Module autoloading does not always work, but should be fixed by the kernel patch f98f89a0104454f35a: 'net: tunnels - enable module autoloading', which is currently in net-next and which people may consider backporting if they want tunneling support without compiling in the modules. Early adopters may also use a module-load.d snippet and order systemd-modules-load.service before networkd to force the module loading of tunneling modules. This sholud fix the various build issues people have reported.
* networkd: run as unpriviliged "systemd-network" userLennart Poettering2014-06-011-3/+22
| | | | | | This allows us to run networkd mostly unpriviliged with the exception of CAP_NET_* and CAP_SYS_MODULE. I'd really like to get rid of the latter though...
* resolved: add daemon to manage resolv.confTom Gundersen2014-05-191-8/+0
| | | | Also remove the equivalent functionality from networkd.
* networkd: manager - don't leak kmod contextTom Gundersen2014-05-121-6/+0
| | | | Also, keep the kmod_new internal to networkd-manager.c
* networkd: introduce ipip tunnelSusant Sahani2014-05-121-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch enables basic ipip tunnel support. It works with kernel module ipip example conf: file: ipip.netdev [NetDev] Name=ipip-tun Kind=ipip MTUBytes=1480 [Tunnel] Local=192.168.223.238 Remote=192.169.224.239 TTL=64 file: ipip.network [Match] Name=em1 [Network] Tunnel=ipip-tun [tomegun: - drop unused variable - take ref when enslaving]
* networkd: tie links to rtnl rather than udevTom Gundersen2014-04-191-1/+1
| | | | | | | | | | This essentially swaps the roles of rtnl and udev in networkd. After this change libudev is only used for waiting for udev to initialize devices and to get udev-specific information needed for some [Match] attributes. This in particular simplifies the code in containers where udev is not really useful, but also simplifies things and reduces round-trips in the non-container case.
* networkd: fix creation of runtime dirs at startupTom Gundersen2014-03-141-2/+14
| | | | This allows us to drop the repeated attempted creations of the runtime dirs during runtime.
* networkd: rework startupTom Gundersen2014-03-111-10/+10
| | | | Open all listenerns before loading configuration.
* sd-network: add new libraryTom Gundersen2014-02-281-0/+5
| | | | | | This is similar to sd-login, but exposes the state of networkd rather than logind. Include it in libsystemd-dhcp and rename it to libsystemd-network.
* sd-dhcp-client/networkd: add transient hostname supportTom Gundersen2014-01-161-0/+6
|
* networkd: improve loggingTom Gundersen2014-01-161-9/+22
|
* networkd: generate resolv.confTom Gundersen2014-01-121-0/+7
| | | | | | | | | | | | | This adds support to generate a basic resolv.conf in /run/systemd/network. This file will not take any effect unless a symlink is created from /etc/resolv.conf. Nameservers received over DHCP takes precedence over statically configured ones. Note: /etc/resolv.conf is severely limited, so in the future we will likely rather provide a much more powerfull nss plugin (or something to that effect), but this should allow current users to function without any loss of functionality.
* networkd: Initialize variable to NULLPatrik Flykt2013-11-271-1/+1
| | | | | If any number of arguments are given, _cleanup_manager_free_ is used with unitialized memory causing a crash.
* networkd: add bridge supportTom Gundersen2013-11-261-0/+4
| | | | | | | | | | | A bridge is specified in a .netdev file with a section [Bridge] and at least the entry Name=. A link may be joined to a bridge if the .network applied to it has a Bridge= entry giving the name of the bridge in its [Network] section. We eagerly create all bridges on startup, and links are added to bridges as soon as they both appear.
* networkd: fix buildTom Gundersen2013-11-231-0/+1
| | | | Forgot to 'git add'...