summaryrefslogtreecommitdiff
path: root/src/network/networkd.c
Commit message (Collapse)AuthorAgeFilesLines
* network: allocate FirewallContext lazilyYu Watanabe2021-03-231-4/+0
|
* tree-wide: enable colorized logging for daemons when run in consoleYu Watanabe2021-02-011-1/+1
| | | | It may be useful when debugging daemons.
* firewall-util: introduce context structureFlorian Westphal2020-12-161-0/+5
| | | | | | | | | | | | | | | for planned nft backend we have three choices: - open/close a new nfnetlink socket for every operation - keep a nfnetlink socket open internally - expose a opaque fw_ctx and stash all internal data here. Originally I opted for the 2nd option, but during review it was suggested to avoid static storage duration because of perceived problems with threaded applications. This adds fw_ctx and new/free functions, then converts the existing api and nspawn and networkd to use it.
* license: LGPL-2.1+ -> LGPL-2.1-or-laterYu Watanabe2020-11-091-1/+1
|
* network: introduce helper function to enumerate information using netlinkYu Watanabe2020-10-071-22/+2
|
* various daemons: emit Stopping... notification before destructing the ↵Zbigniew Jędrzejewski-Szmek2020-07-021-1/+1
| | | | | | | | manager object This is mostly cosmetic, but let's reorder the destructors so that we do the final sd_notify() call before we run the destructor for the manager object.
* resolved, networkd: don't resolve the user if not rootTopi Miettinen2019-12-071-18/+19
| | | | | | | | | | If a daemon is not started as root, most likely it also can't create its directory and let's not try to resolve the user in that case either. Create /run/systemd/netif/lldp with tmpfiles.d like other netif directories. This is also very helpful for preparing a RootImage for the daemons as NSS crud is not needed.
* network: introduce ip nexthop routingSusant Sahani2019-10-141-0/+4
| | | | | | | | | | Used to manipulate entries in the kernel's nexthop tables. Example: ``` [NextHop] Id=3 Gateway=192.168.5.1 ```
* networkd: Keep track of static neighborsWilliam A. Kennington III2019-08-121-0/+4
| | | | | We need to keep track of the static neighbors that are configured on the interface so that we can delete stale entries that were removed.
* network: include glibc headers before including kernel headersYu Watanabe2019-05-091-0/+1
|
* headers: remove unneeded includes from util.hZbigniew Jędrzejewski-Szmek2019-03-271-0/+3
| | | | | This means we need to include many more headers in various files that simply included util.h before, but it seems cleaner to do it this way.
* network: define main through macroYu Watanabe2018-12-081-55/+31
|
* log: introduce new helper call log_setup_service()Lennart Poettering2018-11-201-3/+1
| | | | | Let's reduce the common boilerplate and have a single setup function used by all service code to setup logging.
* network: replace udev_device by sd_deviceYu Watanabe2018-08-231-0/+1
|
* user-util: rework get_user_creds()Lennart Poettering2018-08-201-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | Let's fold get_user_creds_clean() into get_user_creds(), and introduce a flags argument for it to select "clean" behaviour. This flags parameter also learns to other new flags: - USER_CREDS_SYNTHESIZE_FALLBACK: in this mode the user records for root/nobody are only synthesized as fallback. Normally, the synthesized records take precedence over what is in the user database. With this flag set this is reversed, and the user database takes precedence, and the synthesized records are only used if they are missing there. This flag should be set in cases where doing NSS is deemed safe, and where there's interest in knowing the correct shell, for example if the admin changed root's shell to zsh or suchlike. - USER_CREDS_ALLOW_MISSING: if set, and a UID/GID is specified by numeric value, and there's no user/group record for it accept it anyway. This allows us to fix #9767 This then also ports all users to set the most appropriate flags. Fixes: #9767 [zj: remove one isempty() call]
* network: move sd_event initialization to manager_new()Yu Watanabe2018-07-181-13/+2
|
* tree-wide: drop copyright headers from frequent contributorsZbigniew Jędrzejewski-Szmek2018-06-201-3/+0
| | | | | | | | Fixes #9320. for p in Shapovalov Chevalier Rozhkov Sievers Mack Herrmann Schmidt Rudenberg Sahani Landden Andersen Watanabe; do git grep -e 'Copyright.*'$p -l|xargs perl -i -0pe 's|/([*][*])?[*]\s+([*#]\s+)?Copyright[^\n]*'$p'[^\n]*\s*[*]([*][*])?/\n*|\n|gms; s|\s+([*#]\s+)?Copyright[^\n]*'$p'[^\n]*\n*|\n|gms' done
* tree-wide: beautify remaining copyright statementsLennart Poettering2018-06-141-1/+1
| | | | | | Let's unify an beautify our remaining copyright statements, with a unicode ©. This means our copyright statements are now always formatted the same way. Yay.
* tree-wide: drop 'This file is part of systemd' blurbLennart Poettering2018-06-141-2/+0
| | | | | | | | | | | | | | | | This part of the copyright blurb stems from the GPL use recommendations: https://www.gnu.org/licenses/gpl-howto.en.html The concept appears to originate in times where version control was per file, instead of per tree, and was a way to glue the files together. Ultimately, we nowadays don't live in that world anymore, and this information is entirely useless anyway, as people are very welcome to copy these files into any projects they like, and they shouldn't have to change bits that are part of our copyright header for that. hence, let's just get rid of this old cruft, and shorten our codebase a bit.
* 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.