summaryrefslogtreecommitdiff
path: root/src/network
Commit message (Collapse)AuthorAgeFilesLines
* tree-wide: port over all code to the new CONFIG_PARSER_PROTOTYPE() macroLennart Poettering2018-05-2211-89/+81
| | | | | | | | | | | This makes most header files easier to look at. Also Emacs gets really slow when browsing through large sections of overly long prototypes, which is much improved by this macro. We should probably not do something similar with too many other cases, as macros like this might help readability for some, but make it worse for others. But I think given the complexity of this specific prototype and how often we use it, it's worth doing.
* Merge pull request #8962 from floppym/issue8905Zbigniew Jędrzejewski-Szmek2018-05-131-1/+1
|\ | | | | basic: timezone_is_valid: check for magic bytes "TZif"
| * basic: add log_level argument to timezone_is_validMike Gilbert2018-05-121-1/+1
| |
* | network: make route_update() accept NULLYu Watanabe2018-05-112-7/+7
| | | | | | | | | | | | This also fixes a wrong argument for route_configure(). Fixes #8960.
* | network: fix indentationYu Watanabe2018-05-111-104/+124
|/
* network,udev: sort included headersYu Watanabe2018-05-091-1/+1
|
* network,udev: make MACAddress= in [Match] section take multiple MAC addressesYu Watanabe2018-05-094-11/+13
|
* test: add tests for config_parse_hwaddrs()Yu Watanabe2018-05-091-2/+49
|
* ether-addr-util: make ether_addr_from_string() stricterYu Watanabe2018-05-091-4/+5
|
* networkd: add support to send DHCP user class option (#7499)Susant Sahani2018-05-074-1/+62
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch add support to enables to send User Class option code 77 RFC 3004. This option MAY carry multiple User Classes. The format of this option is as follows: Code Len Value +-----+-----+--------------------- . . . --+ | 77 | N | User Class Data ('Len' octets) | +-----+-----+--------------------- . . . --+ where Value consists of one or more instances of User Class Data. Each instance of User Class Data is formatted as follows: UC_Len_i User_Class_Data_i +--------+------------------------ . . . --+ | L_i | Opaque-Data ('UC_Len_i' octets) | +--------+------------------------ . . . --+ UserClass= A DHCPv4 client can use UserClass option to identify the type or category of user or applications it represents. The information contained in this option is an string that represents the user class of which the client is a member. Each class sets an identifying string of information to be used by the DHCP service to classify clients. Takes a whitespace-separated list. UserClass= hello world how are you Closes: RFC: #5134
* networkd: use ipv6_accept_ra_use_dns rather than dhcp_use_dns (#8836)Susant Sahani2018-05-021-1/+1
| | | | | | While Saving the DNS server use [IPv6AcceptRA] UseDNS= that is ipv6_accept_ra_use_dns. Closes #8420
* networkd: Bridge Property Use kernel defaults. (#8825)Susant Sahani2018-04-274-28/+42
| | | | | | | | | | Rather than choosing to set or unset any of these flag use kernel defaults. This patch makes following properties to unset. UseBPDU = unset HairPin = unset FastLeave = unset AllowPortToBeRoot = unset UnicastFlood = unset
* network: recreate link if its interface name is changed (#8795)Yu Watanabe2018-04-261-8/+11
| | | | | | | | If an interface name is changed, then the link state, especially managed or not, may need to be updated, as its corresponding .link or .network files may be different. So, let's once drop the link and recreate a new link object. Fixes #8794.
* networkd,udev: clean up MTU handlingLennart Poettering2018-04-2610-51/+14
| | | | | | | | | | | | | | | | This cleans up handling of MTU values across the codebase. Previously MTU values where stored sometimes in uint32_t, sometimes in uint16_t, sometimes unsigned and sometimes in size_t. This now unifies this to uint32_t across the codebase, as that's what netlink spits out, and what the majority was already using. Also, all MTU parameters are now parsed with config_parse_mtu() and config_parse_ipv6_mtu() is dropped as it is now unneeded. (Note there is one exception for the MTU typing: in the DCHPv4 code we continue to process the MTU as uint16_t value, as it is encoded like that in the protocol, and it's probably better stay close to the protocol there.)
* networkd: drop duplicate definition of IPV6_MIN_MTULennart Poettering2018-04-261-2/+0
| | | | We already have it in missing.h, and once suffices.
* tree-wide: drop redundant _cleanup_ macros (#8810)Lennart Poettering2018-04-2528-112/+101
| | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* networkd: more specific link down while enslaving (#8771)Tobias Jungel2018-04-201-1/+1
| | | | | | Issue #5853 introduced a link_down for every netdev enslaved. This behaviour is not required on other slave interfaces. fixes 14b6bb7
* networkd: add support to configure IPv6 MTU (#8664)Susant Sahani2018-04-204-1/+72
| | | | | This patch supports to configure IPv6 MTU. Closes #8632
* tree-wide: drop spurious newlines (#8764)Lennart Poettering2018-04-194-5/+0
| | | | | | | | Double newlines (i.e. one empty lines) are great to structure code. But let's avoid triple newlines (i.e. two empty lines), quadruple newlines, quintuple newlines, …, that's just spurious whitespace. It's an easy way to drop 121 lines of code, and keeps the coding style of our sources a bit tigther.
* Merge pull request #8739 from yuwata/add-descriptionLennart Poettering2018-04-171-1/+1
|\ | | | | bus-util: introduce bus_open_system_watch_bind_with_description()
| * network: set description to busYu Watanabe2018-04-171-1/+1
| |
* | networkd: fix dhcp4 link without routes not being considered ready (#8728)Anssi Hannula2018-04-171-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The dhcp4 code sets link->dhcp4_configured when dhcp4_route_handler() has processed the last message. However, in case UseRoutes=no has been set in the [DHCP] section, or in case the DHCP server simply sends no routes, link_set_dhcp_routes() will not send any netlink messages and dhcp4_route_handler() will therefore never be called. This causes the link to never reach LINK_STATE_CONFIGURED, and e.g. systemd-networkd-wait-online will not consider the link as ready. Fix that by setting link->dhcp4_configured = true and calling link_check_ready() in dhcp4_address_handler() in case link_set_dhcp_routes() sent no netlink messages (dhcp4_messages is zero).
* | networkd: fix crash if fails to get network file (#8714)Susant Sahani2018-04-171-1/+1
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In some situation if networkd fails to get the network file then networkd crashes becasse the link->network is not initalized; ``` veth99: Failed to get network dhcp-client-ipv4-only: No such file or directory Segmentation fault gdb) r The program being debugged has been started already. Start it from the beginning? (y or n) y Starting program: /home/sus/tt/systemd/build/systemd-networkd [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib64/libthread_db.so.1". warning: Loadable section ".note.gnu.property" outside of ELF segments warning: Loadable section ".note.gnu.property" outside of ELF segments warning: Loadable section ".note.gnu.property" outside of ELF segments Program received signal SIGSEGV, Segmentation fault. link_load (link=0x55555582ccd0) at ../src/network/networkd-link.c:2973 2973 r = sd_dhcp_client_new(&link->dhcp_client, link->network->dhcp_anonymize); (gdb) bt (gdb) p link->network $1 = (Network *) 0x0 (gdb) list 2968 if (r < 0) { 2969 log_link_debug_errno(link, r, "Failed to parse DHCPv4 address %s: %m", dhcp4_address); 2970 goto dhcp4_address_fail; 2971 } 2972 2973 r = sd_dhcp_client_new(&link->dhcp_client, link->network->dhcp_anonymize); 2974 if (r < 0) 2975 return log_link_error_errno(link, r, "Failed to create DHCPv4 client: %m"); 2976 2977 r = sd_dhcp_client_set_request_address(link->dhcp_client, &address.in); (gdb) r ```
* network,resolve: remove unused variables (#8738)Yu Watanabe2018-04-172-2/+0
| | | Follow-up for d7afd945b5aad5b262a3de97614f486d63d94612.
* src/network: add missing SPDX identifiersZbigniew Jędrzejewski-Szmek2018-04-062-0/+2
|
* tree-wide: drop license boilerplateZbigniew Jędrzejewski-Szmek2018-04-0681-1077/+24
| | | | | | | | | | 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: use TAKE_PTR() and TAKE_FD() macrosYu Watanabe2018-04-0512-63/+31
|
* network: fix typo in log messageYu Watanabe2018-04-051-1/+1
|
* Merge pull request #8552 from keszybz/test-improvementsLennart Poettering2018-03-231-4/+4
|\ | | | | Test and diagnostics improvements
| * 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...
* | macro: introduce TAKE_PTR() macroLennart Poettering2018-03-227-16/+8
|/ | | | | | | | | | | | | | | | This macro will read a pointer of any type, return it, and set the pointer to NULL. This is useful as an explicit concept of passing ownership of a memory area between pointers. This takes inspiration from Rust: https://doc.rust-lang.org/std/option/enum.Option.html#method.take and was suggested by Alan Jenkins (@sourcejedi). It drops ~160 lines of code from our codebase, which makes me like it. Also, I think it clarifies passing of ownership, and thus helps readability a bit (at least for the initiated who know the new macro)
* Merge pull request #8106 from dqminh/route-expires-kernelLennart Poettering2018-03-204-2/+32
|\ | | | | move route expiration to kernel
| * setup route expiration in kernel if supportedDaniel Dao2018-03-124-2/+32
| | | | | | | | | | | | | | | | | | kernel >= 4.5 (with commit https://github.com/torvalds/linux/commit/32bc201e1974976b7d3fea9a9b17bb7392ca6394) supports RTA_EXPIRES netlink attribute to set router lifetime. This simply detect the kernel version (>=4.5) and set the lifetime properly, fallback to expiring route in userspace for kernel that doesnt support it. Signed-off-by: Daniel Dao <dqminh89@gmail.com>
* | tree-wide: voidify pager_open()Yu Watanabe2018-03-191-3/+3
| | | | | | | | | | | | Even if pager_open() fails, in general, we should continue the operations. All erroneous cases in pager_open() show log message in the function. So, it is not necessary to check the returned value.
* | networkctl,hwdb: make verbs staticYu Watanabe2018-03-191-5/+5
| |
* | dhcp4: introduce new option 'duid-only' for ClientIdentifier= (#8350)Yu Watanabe2018-03-124-1/+30
| | | | | | | | | | | | | | This makes users can configure DHCPv4 client with ClientIdentifier=duid-only. If set so, then DHCP client sends only DUID as the client identifier. This may not be RFC compliant, but some setups require this. Closes #7828.
* | coccinelle: add reallocarray() coccinelle scriptLennart Poettering2018-03-021-4/+4
|/ | | | | Let's systematically make use of reallocarray() whereever we invoke realloc() with a product of two values.
* tree-wide: use "cannot" instead of "can not"Zbigniew Jędrzejewski-Szmek2018-02-084-8/+8
| | | | This is the usual spelling, and a bit shorter.
* networkd: vxlan require Remote= to be a non multicast address (#8117)Susant Sahani2018-02-081-2/+5
| | | | | | | | Remote= must be a non multicast address. ip-link(8) says: > remote IPADDR - specifies the unicast destination IP address to > use in outgoing packets when the destination link layer address > is not known in the VXLAN device forwarding database. Closes #8088.
* Merge pull request #8042 from zx2c4-forks/jd/networkctl-typeZbigniew Jędrzejewski-Szmek2018-02-081-32/+11
|\ | | | | networkd: fixup networkctl type display
| * networkd: clean up link_get_type_string returnsJason A. Donenfeld2018-01-291-19/+9
| | | | | | | | | | | | | | It's cleaner and more consistent to actually return what we were planning on returning. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
| * networkd: clean up link_get_type_stringJason A. Donenfeld2018-01-291-9/+7
| | | | | | | | | | | | The return value is always ignored, so get rid of it. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
| * networkd: simplify and display all devtypesJason A. Donenfeld2018-01-291-20/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Every place the kernel actually calls SET_NETDEV_DEVTYPE, it's adding a piece of information that looks useful and relevant for us to use. So let's use it when it's there. The previous matching based on the corresponding ARPHRD didn't really make much sense. The more sensible logic for getting a textual representation of the link type is to see if the kernel supplies a devtype. If it does, great. If not, then we can fall back on the ARPHRD, as before. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
| * networkd: display wireguard devtypeJason A. Donenfeld2018-01-291-7/+15
| | | | | | | | | | | | | | It's not useful to simply show "none", when we have more interesting information to display. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
* | networkd: fix dhcp6_prefixes_compare_func()Yu Watanabe2018-02-061-1/+1
|/ | | | | | | | | | Found by the following warning by gcc. ``` ../src/network/networkd-manager.c: In function 'dhcp6_prefixes_compare_func': ../src/network/networkd-manager.c:1383:16: warning: 'memcmp' reading 16 bytes from a region of size 8 [-Wstringop-overflow=] return memcmp(&a, &b, sizeof(*a)); ^ ```
* networkd: assume no link local addresses for where it isn't usedJason A. Donenfeld2018-01-261-0/+6
| | | | | | | | | | It turns out that link local doesn't make much sense in its context. Since link local is disabled by the kernel driver, it's important that networkd assumes it's off too, so that the link can reach the "configured" stage, without waiting indefinitely for link local addresses which will never come. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
* Merge pull request #7988 from ssahani/follow-7712Lennart Poettering2018-01-243-6/+5
|\ | | | | Networkd: cleanup code a bit
| * networkd: routing policy rules rename Manager object m to manager.Susant Sahani2018-01-242-5/+5
| |
| * networkd: remove unused variable manager -> mSusant Sahani2018-01-241-1/+0
| |