Commit Graph

54 Commits

Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek e2054217d5 Move hostname setup logic to new shared/hostname-setup.[ch]
No functional change, just moving a bunch of things around. Before
we needed a rather complicated setup to test hostname_setup(), because
the code was in src/core/. When things are moved to src/shared/
we can just test it as any function.

The test is still "unsafe" because hostname_setup() may modify the
hostname.
2020-12-16 11:02:15 +01:00
Yu Watanabe 1d30fc5cb6 network: revert previous changes to address_compare_func()
This partially reverts fe841414ef and
2a236f9fc0.

For IPv4, kernel compares the local address, prefix, and prefixlen.
For IPv6, kernel compares only the local address.
Let's follow the kernel's comparison way.

Fixes #17831.
2020-12-08 12:41:07 +09:00
Yu Watanabe db9ecf0501 license: LGPL-2.1+ -> LGPL-2.1-or-later 2020-11-09 13:23:58 +09:00
Yu Watanabe fe841414ef network: read peer address, label, broadcast from rtnl message
Then, Address objects in Network and Link can be easily compared by
address_equal().
2020-10-13 20:30:35 +09:00
Yu Watanabe ee446d57b8 network: cleanup networkd-fdb.h 2020-10-07 02:44:42 +09:00
Yu Watanabe 446aaaf35f network: introduce helper function to enumerate information using netlink 2020-10-07 02:39:13 +09:00
Yu Watanabe c643bda5ec network: read driver name from ethtool
To make Driver= in [Match] section work in containers.

Note that ID_NET_DRIVER= property in udev database is set with the
result of the ethtool. So, this should not change anything for
non-container cases.

Closes #15678.
2020-06-03 18:25:37 +02:00
Benjamin Robin 243945e95e test: Add return 0 to main() function (even it is not strictly necessary) 2020-05-13 22:56:42 +02:00
Yu Watanabe ef62949a23 network: make Type=ether match based on iftype
This makes Type= can match the type shown in networkctl.

Closes #14952.
2020-03-02 08:52:18 +01:00
Zbigniew Jędrzejewski-Szmek e519e20ae1 test-network: do not fail if lo has a .network file
Fixes #9895.
2020-02-04 08:30:40 +01:00
Yu Watanabe 4bb7cc8287 network, udev: introduce PermanentMACAddress= setting in [Match] section
Closes #13983.
2020-01-08 17:54:54 +09:00
Yu Watanabe 572b21d96c network: make Name= in [Match] support alternative names of interfaces 2019-12-16 10:55:56 +09:00
Yu Watanabe 78404d22cc network: support matching based on wifi interfece type 2019-10-25 16:43:18 +09:00
Yu Watanabe 277ba8d1ab network: add support matching based on BSSID= 2019-10-15 01:59:56 +09:00
Yu Watanabe 8d968fdd99 network: support matching based on wifi SSID 2019-10-15 01:59:06 +09:00
Yu Watanabe d03f390ef2 network: drop arpa/inet.h from networkd-manager.h 2019-05-09 02:33:33 +02:00
Yu Watanabe 004aadcacd network: replace inet_pton() with in_addr_from_string() 2019-05-09 01:44:31 +02:00
Yu Watanabe 67a4683364 network: use IN_ADDR_NULL and ETHER_ADDR_NULL
The change in manager_rtnl_process_address() may not be necessary,
but for safety, let's initialize the value.
2019-05-07 16:55:19 +02:00
Zbigniew Jędrzejewski-Szmek 6d7c403324 tests: use a helper function to parse environment and open logging
The advantages are that we save a few lines, and that we can override
logging using environment variables in more test executables.
2018-09-14 09:29:57 +02:00
Zbigniew Jędrzejewski-Szmek 317bb217d3 tests: add helper to unify skipping a test and exiting 2018-09-14 09:29:57 +02:00
Yu Watanabe 964bc0ad60 test: log when skipping tests in more cases
Follow-up for the previous commit.
2018-09-13 12:07:34 +02:00
Yu Watanabe 51517f9e09 network: replace udev_device by sd_device 2018-08-23 04:57:39 +09:00
Yu Watanabe 3534a04300 network: move sd_event initialization to manager_new() 2018-07-18 12:37:50 +09:00
Zbigniew Jędrzejewski-Szmek d9b02e1697 tree-wide: drop copyright headers from frequent contributors
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
2018-06-20 11:58:53 +02:00
Lennart Poettering 96b2fb93c5 tree-wide: beautify remaining copyright statements
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.
2018-06-14 10:20:21 +02:00
Lennart Poettering 818bf54632 tree-wide: drop 'This file is part of systemd' blurb
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.
2018-06-14 10:20:20 +02:00
Lennart Poettering 8e766630f0 tree-wide: drop redundant _cleanup_ macros (#8810)
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.
2018-04-25 12:31:45 +02:00
Zbigniew Jędrzejewski-Szmek 11a1589223 tree-wide: drop license boilerplate
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.
2018-04-06 18:58:55 +02:00
Luca Bruno 2de2abad62 networkd/dhcp: shorten overlong hostname (#7616)
This commit updates networkd behavior to check if the hostname option
received via DHCP is too long for Linux limit, and in case shorten it.
An overlong hostname will be truncated to the first dot or to
`HOST_MAX_LEN`, whatever comes earlier.
2017-12-13 18:00:46 +01:00
Zbigniew Jędrzejewski-Szmek 6f349a4f9c test-network: use automatic cleanup 2017-11-28 09:25:38 +01:00
Zbigniew Jędrzejewski-Szmek 53e1b68390 Add SPDX license identifiers to source files under the LGPL
This follows what the kernel is doing, c.f.
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5fd54ace4721fc5ce2bb5aef6318fcf17f421460.
2017-11-19 19:08:15 +01:00
Tom Gundersen b76d99d9e6 networkd: move event loop handling out of the manager (#4723)
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.
2016-11-28 20:42:40 +01:00
Tom Gundersen 23f53b99b1 networkd: clean up main header file a bit
Rename networkd.h to networkd-manager.h, to more accurately describe what it
contains.
2016-11-14 01:05:06 +01:00
Daniel Mack b26fa1a2fb tree-wide: remove Emacs lines from all files
This should be handled fine now by .dir-locals.el, so need to carry that
stuff in every file.
2016-02-10 13:41:57 +01:00
Thomas Hindoe Paaboel Andersen cf0fbc49e6 tree-wide: sort includes
Sort the includes accoding to the new coding style.
2015-11-16 22:09:36 +01:00
Lennart Poettering b5efdb8af4 util-lib: split out allocation calls into alloc-util.[ch] 2015-10-27 13:45:53 +01:00
Tom Gundersen 3ac8e5433f networkd: address - add hash helpers for Address objects
Add compare_func and hash_func for the Address object. The notion of
address equality is the same as in the kernel, and hashing preserves
preserves equality.

Two addresses are considered equal if:
   - they have the same address family, and
     - they are neither IPv4 nor IPv6 addresses, or
     - the local addresses are identical, and
       - they are IPv6 addresses, or
         - they have the same prefixlength, and
         - their peer prefixes are identical

This fixes a bug in the old equality check, which got the local address
and the peer prefix mixed up.
2015-10-11 15:03:04 +02:00
Tom Gundersen f0213e3796 networkd: route/address - simplify and unify creators
Rename new_dynamic() to simply _new() and reuse that from new_static().
2015-10-11 14:21:41 +02:00
Tom Gundersen 5fae368bda networkd: refactor socket activation a bit 2015-02-03 22:20:38 +01:00
Zbigniew Jędrzejewski-Szmek 6cb8e687f0 network-address,test-network: avoid undefined behaviour 2015-02-02 21:34:35 -05:00
Tom Gundersen 5bb14c8651 test-network: fix off-by-one error in test 2014-08-31 19:22:33 +02:00
Lennart Poettering a2ba62c719 sd-network: remove redundant array size parameter from functions that return arrays
As long as the number of array entries is relatively small it's nicer to
simply return the number of entries directly, instead of using a size_t*
return parameter for it.
2014-07-17 01:42:26 +02:00
Tom Gundersen 5347925a59 test: network - skip if we don't have permissions to create netdevs 2014-07-14 16:49:41 +02:00
Eugene Yakubovich e1ea665eda Add support for DHCP static route options
This adds support for DHCP options 33 and 121: Static Route and
Classless Static Route. To enable this feature, set UseRoutes=true
in .network file. Returned routes are added to the routing table.
2014-06-29 15:18:21 +02:00
Tom Gundersen 09bee74d7a sd-dhcp-lease: move in_addr (de)serialization to shared network code 2014-05-19 18:14:56 +02:00
Tom Gundersen 9505d3c6de networkd: IP address equality 2014-05-17 20:46:11 +02:00
Tom Gundersen 505f8da732 networkd: tie links to rtnl rather than udev
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.
2014-04-19 18:41:58 +02:00
Tom Gundersen 0c2f9b8469 networkd: handle SIGINT and SIGTERM 2014-02-22 21:24:36 +01:00
Tom Gundersen 12e0f830f5 test: always use assert_se in tests 2014-02-22 21:24:36 +01:00
Tom Gundersen 02b59d57e0 networkd: add bridge support
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.
2013-11-26 01:32:25 +01:00