Commit graph

54 commits

Author SHA1 Message Date
Lennart Poettering ae2a15bc14 macro: introduce TAKE_PTR() macro
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)
2018-03-22 20:21:42 +01:00
Zbigniew Jędrzejewski-Szmek 87ac8d998f tree-wide: use "cannot" instead of "can not"
This is the usual spelling, and a bit shorter.
2018-02-08 10:34:52 +01:00
Susant Sahani bf443be995 networkd: vxlan require Remote= to be a non multicast address (#8117)
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.
2018-02-08 10:22:46 +01:00
Susant Sahani 3e52ec4301 netword: tunnel remove unwanted space. 2018-01-22 15:50:07 +01:00
Yu Watanabe 1291a04298 ipvlan: fix wrong assignment in ipvlan_init() 2018-01-17 01:28:09 +09:00
Zbigniew Jędrzejewski-Szmek 67ddb52432
Merge pull request #7855 from poettering/log-h-includes
log.h #include cleanups
2018-01-15 13:43:09 +04:00
Lennart Poettering dccca82b1a log: minimize includes in log.h
log.h really should only include the bare minimum of other headers, as
it is really pulled into pretty much everything else and already in
itself one of the most basic pieces of code we have.

Let's hence drop inclusion of:

1. sd-id128.h because it's entirely unneeded in current log.h
2. errno.h, dito.
3. sys/signalfd.h which we can replace by a simple struct forward
   declaration
4. process-util.h which was needed for getpid_cached() which we now hide
   in a funciton log_emergency_level() instead, which nicely abstracts
   the details away.
5. sys/socket.h which was needed for struct iovec, but a simple struct
   forward declaration suffices for that too.

Ultimately this actually makes our source tree larger (since users of
the functionality above must now include it themselves, log.h won't do
that for them), but I think it helps to untangle our web of includes a
tiny bit.

(Background: I'd like to isolate the generic bits of src/basic/ enough
so that we can do a git submodule import into casync for it)
2018-01-11 14:44:31 +01:00
Zbigniew Jędrzejewski-Szmek 5360d77131 netdev: use "relaxed" parsing
We parse each netdev file twice: once to determine the type and match conditions,
and then the second time properly. In bcde742e78
the flags for the first parsing were (inadvertently I assume) were changed to
emit warnings. But this first pass is called with only [Match] and [NetDev] sections,
so we'd get warnings about all other section types. The obvious solution would be
to remove CONFIG_PARSE_WARN again, but I think it's better to keep the warnings
and set CONFIG_PARSE_RELAXED: we do want to get warnings about malformed lines and
such, and _RELAXED is enough to kill warnings about unknown sections.
2018-01-11 13:04:11 +01:00
Zbigniew Jędrzejewski-Szmek 2269954112 Merge pull request #7191 from Mic92/systemd
The change in netdev.c done in the merge is necessary to avoid crashing in
cleanup. This is a follow-up for f3c33b234d.
2018-01-09 14:35:54 +01:00
Jörg Thalheim e5719363f5 networkd: add support for wireguard interface type
More information may be found at wireguard.com.
2018-01-09 14:00:49 +01:00
Jörg Thalheim 05d0c2e3cf sd-netlink: add generic netlink support
This also adds the ability to incorporate arrays into netlink messages
and to determine when a netlink message is too big, used by some generic
netlink protocols.
2018-01-09 14:00:49 +01:00
Lennart Poettering f3c33b234d networkd: fix memory corruption
When loading .netdev files we parse them twice: first we do one parsing
iteration to figure out their "kind", and then we do it again to parse
out the kind's parameters. The first iteration is run with a "short"
NetDev structure, that only covers the generic NetDev properties. Which
should be enough, as we don't parse the per-kind properties. However,
before this patch we'd still try to destruct the per-kind properties
which resulted in memory corruption. With this change we distuingish the
two iterations by the state field, so that the destruction only happens
when the state signals we are running with a full NetDev structure.

Since this is not obvious, let's add a lot of comments.
2018-01-05 13:59:12 +01:00
Susant Sahani 3a4f3e423d networkd: Tunnel allows tunnel traffic on ip6tnl devices (#7756)
where the remote endpoint is a local host address.
2017-12-29 23:19:21 +09:00
Lennart Poettering 5022f08a23 core,udev,networkd: add ConditionKernelVersion=
This adds a simple condition/assert/match to the service manager, to
udev's .link handling and to networkd, for matching the kernel version
string.

In this version we only do fnmatch() based globbing, but we might want
to extend that to version comparisons later on, if we like, by slightly
extending the syntax with ">=", "<=", ">", "<" and "==" expressions.
2017-12-26 17:39:44 +01:00
Susant Sahani d384826f69 networkd: Add support for ipvlan L3s and flags (#7726)
This works supports to configure L3S mode and flags
such as bridge, private and vepa
2017-12-23 18:55:03 +01:00
Zbigniew Jędrzejewski-Szmek 281bb5c110 network: fix memory leak when an netdev was skipped
In general we'd leak anything that was allocated in the first parsing of
netdev, e.g. netdev name, host name, etc. Use normal netdev_unref to make sure
everything is freed.

--- command ---
/home/zbyszek/src/systemd/build2/test-network
--- stderr ---
/etc/systemd/network/wg0.netdev:3: Failed to parse netdev kind, ignoring: wireguard
/etc/systemd/network/wg0.netdev:5: Unknown section 'WireGuard'. Ignoring.
/etc/systemd/network/wg0.netdev:9: Unknown section 'WireGuardPeer'. Ignoring.
NetDev has no Kind configured in /etc/systemd/network/wg0.netdev. Ignoring
/etc/systemd/network/br0.network:13: Unknown lvalue 'NetDev' in section 'Network'
br0: netdev ready

=================================================================
==11666==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 4 byte(s) in 1 object(s) allocated from:
    #0 0x7f3a314cf238 in __interceptor_strdup (/lib64/libasan.so.4+0x77238)
    #1 0x7f3a30e71ad1 in free_and_strdup ../src/basic/string-util.c:870
    #2 0x7f3a30d34fba in config_parse_ifname ../src/shared/conf-parser.c:981
    #3 0x7f3a30d2f5b0 in next_assignment ../src/shared/conf-parser.c:155
    #4 0x7f3a30d30303 in parse_line ../src/shared/conf-parser.c:273
    #5 0x7f3a30d30dee in config_parse ../src/shared/conf-parser.c:390
    #6 0x7f3a30d310a5 in config_parse_many_files ../src/shared/conf-parser.c:428
    #7 0x7f3a30d3181c in config_parse_many ../src/shared/conf-parser.c:487
    #8 0x55b4200f9b00 in netdev_load_one ../src/network/netdev/netdev.c:634
    #9 0x55b4200fb562 in netdev_load ../src/network/netdev/netdev.c:778
    #10 0x55b4200c607a in manager_load_config ../src/network/networkd-manager.c:1299
    #11 0x55b4200818e0 in test_load_config ../src/network/test-network.c:128
    #12 0x55b42008343b in main ../src/network/test-network.c:254
    #13 0x7f3a305f8889 in __libc_start_main (/lib64/libc.so.6+0x20889)

SUMMARY: AddressSanitizer: 4 byte(s) leaked in 1 allocation(s).
-------
2017-12-20 16:17:29 +01:00
Susant Sahani d6df583c87 networkd: introduce vxcan netdev. (#7150)
Similar to the virtual ethernet driver veth, vxcan implements a
local CAN traffic tunnel between two virtual CAN network devices.
When creating a vxcan, two vxcan devices are created as pair
When one end receives the packet it appears on its pair and vice
versa. The vxcan can be used for cross namespace communication.
2017-11-22 08:23:22 +01:00
Shawn Landden 4831981d89 tree-wide: adjust fall through comments so that gcc is happy
Distcc removes comments, making the comment silencing
not work.

I know there was a decision against a macro in commit
ec251fe7d5
2017-11-20 13:06:25 -08: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
Lennart Poettering bcde742e78 conf-parser: turn three bool function params into a flags fields
This makes things more readable and fixes some issues with incorrect
flag propagation between the various flavours of config_parse().
2017-11-13 10:24:03 +01:00
Robin McCorkell 521cdf01e4 Fix creating independent VTI tunnel (#7303) 2017-11-13 10:14:36 +01:00
Susant Sahani 0da812036f networkd: bridge allow AgeingTimeSec to be set 0 (#7021)
Closes #7019.
2017-10-11 09:08:05 +02:00
Lennart Poettering b50846055e exec-util,conf-files: skip non-executable files in execute_directories()
Fixes: #6787
2017-09-13 11:42:31 +02:00
b1tninja c4819961b1 Allow configuration of a bridge netdev's group_fwd_mask. (#6759) 2017-09-08 12:36:06 +02:00
Susant Sahani 4d7fa6de3b networkd: Allow tunnels to be created without .network (#6701)
Now we don't support tunnels to be created without a .network file
that is we need a interface index.

This work allows tunnel to be created without a ifindex.

Closes #6695
2017-08-31 18:51:03 +02:00
Andreas Rammhold b13049c765 networkd: Added deprecation warning to VRF.TableId 2017-08-31 12:08:33 +02:00
Andreas Rammhold 62b83cf664 networkd: Renamed table_id field to table
Other parts of the code do just use `table` as identifier for the actual
routing table id. This change should make it easier to read through the
code since the meaning or rather the name stays the same.
2017-08-31 01:14:05 +02:00
Andreas Rammhold f98dd1e707 networkd: Add VRF.Table to support parsing of table names
Previously there was only `VRF.TableId` which only supported numeric
identifiers for routing table. With the additiona of
`config_parse_route_table` also names can be used as identifiers.
2017-08-31 01:11:16 +02:00
Zbigniew Jędrzejewski-Szmek e5f752082e build-sys: drop gitignore patterns for in-tree builds
... and other autotools-generated files.
2017-07-18 10:05:06 -04:00
Zbigniew Jędrzejewski-Szmek 72cdb3e783 build-sys: drop automake support
v2:
- also mention m4
2017-07-18 10:04:44 -04:00
Tobias Jungel 0d6c68eba3 network: bridge vlan without PVID (#5899)
this patch makes it possible to configure a vlan aware bridge without the
PVID. To configure no PVID set DefaultPVID=none in the [BridgeVLAN] section.

fixes #5716
2017-05-29 17:20:01 +02:00
Susant Sahani 6c1ff21b00 network: add support for vlan confs(MVRP, reorder header, loose binding) (#5834) 2017-05-09 20:25:11 +02:00
Zbigniew Jędrzejewski-Szmek ab8ee0f259 tree-wide: use SET_FLAG in more places (#5892) 2017-05-07 07:03:28 -04:00
Roelf Wichertjes 14b6bb7762 networkd: Add check to ensure link is down before attempting to enslave (#5853)
netdev to bond.

There are situations where a link can be in an "UP" state when
 systemd-networkd attempts to add the link to a bond device.
This is a problem because the bonding driver will refuse to
 enslave a link if it is in the "UP" state.
This check ensures systemd-networkd sets the link to "DOWN"
 before attempting to add the link to the bond.

Fixes #5838.
2017-04-30 13:12:32 +02:00
Susant Sahani 9cdf4e3d7d networkd: replace geneve/vxlan port parsing with generic config_parse_ip_port 2017-04-29 22:33:50 +05:30
Thomas Hindoe Paaboel Andersen 85df3c6037 networkd: remove duplicated include 2017-04-28 23:56:44 +02:00
Susant Sahani 3ded5bbfda networkd: replace geneve parsers with generic config_parse_uint8 2017-04-25 18:46:04 +05:30
Susant Sahani 6598e04641 networkd: Introduce GENEVE netdev
This work enables cration of geneve tunnel
2017-04-25 10:34:15 +05:30
Susant Sahani c8b2118405 networkd: vlan add GVRP support (#5761)
Add support to configure GVRP.

Closes #5760
2017-04-21 11:01:59 +02:00
Susant Sahani d8653945f7 networkd: vxlan support setting IPv6 flow labe
This work adds support for setting the IPv6 flow label for vxlan.

vxlan.netdev

NetDev]
Description=vxlan-test
Name=vxlan1
Kind=vxlan

[VXLAN]
Id=33
Local=2405:204:920b:29ac:7e7a:91ff:fe6d:ffe2
Remote=FF02:0:0:0:0:0:1:9
FlowLabel=104
ip -d link show vxlan1

8: vxlan1: <BROADCAST,MULTICAST> mtu 1430 qdisc noop state DOWN mode DEFAULT group default qlen 1000
    link/ether be:83:aa:db:6b:cb brd ff:ff:ff:ff:ff:ff promiscuity 0
    vxlan id 33 group ff02::1:9 local 2405:204:920b:29ac:7e7a:91ff:fe6d:ffe2 dev enp0s25 srcport 0 0 dstport 8472 flowlabel 0x68 ageing 300 noudpcsum noudp6zerocsumtx noudp6zerocsumrx addrgenmode eui64 numtxqueues 1 numrxqueues 1
2017-03-14 10:11:49 +05:30
Lennart Poettering c3988e728c Merge pull request #5438 from ssahani/vxlan-address
networkd: add symlinks for Makefile (netdev and wait-online) , vxlan enhancements.
2017-02-28 12:32:18 +01:00
Susant Sahani 8999954f44 networkd: fix assertion crash for tunnel, log error instead (#5465)
GRE6 and IP6TNL address should be a IPv6.

fix :

```
Assertion 't->family == AF_INET6' failed at src/network/netdev/tunnel.c:170,
function netdev_ip6gre_fill_message_create(). Aborting.
```
2017-02-28 10:32:22 +01:00
Susant Sahani d820ef04ab networkd: add symlinks to the Makefile for dir netdev and wait-online 2017-02-25 00:32:43 +05:30
Susant Sahani d35e5d3763 networkd: add support for vxlan Remote and Local.
This patch add supports to configure IFLA_VXLAN_LOCAL
and IFLA_VXLAN_GROUP.

The "Group" is renamed to "Remote" which is a multicast address.`

```
Description=vxlan-test
Name=vxlan1
Kind=vxlan

[VXLAN]
Id=33
Local=2001:db8:2f4:4bff:fa71:1a56
Remote=FF02:0:0:0:0:0:1:9
```

output
```
ip -d link show vxlan1
16: vxlan1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1430 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/ether fe:b4:97:03:f8:e5 brd ff:ff:ff:ff:ff:ff promiscuity 0
    vxlan id 33 group ff02::1:9 local 2001:db8:02f4:4bff:fa71:1a56 dev enp0s3 srcport 0 0 dstport 8472 ageing 300 noudpcsum noudp6zerocsumtx noudp6zerocsumrx addrgenmode none numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535

```
2017-02-25 00:31:47 +05:30
Mike Gilbert c9f7b4d356 build-sys: add check for gperf lookup function signature (#5055)
gperf-3.1 generates lookup functions that take a size_t length
parameter instead of unsigned int. Test for this at configure time.

Fixes: https://github.com/systemd/systemd/issues/5039
2017-01-10 08:39:05 +01:00
Susant Sahani 7dd6974c46 networkd: vxlan rename ARPProxy to ReduceARPProxy (#4891)
Fixes: #4768
2016-12-21 18:59:15 +01:00
Lennart Poettering 15ffcc3456 Merge pull request #4859 from keszybz/networkd
Networkd man page update and fixes for the fallout
2016-12-11 20:38:15 +01:00
Zbigniew Jędrzejewski-Szmek 6f3d4decf2 networkd: check that VTI/VTI6 tunnels have a local address
Otherwise we'd fail with an assertion:
Assertion 't->family == AF_INET' failed at ../src/network/netdev/tunnel.c:244, function netdev_vti_fill_message_create(). Aborting.
2016-12-09 13:55:14 -05:00
Zbigniew Jędrzejewski-Szmek 6e47dbbcb3 networkd: tighten parsing of Tunnel addresses
When assigning addresses, we'd set the family, and later
verify that the address on the other end has the same family.
But when the address was specified as "any", we'd simply unset
the family. Instead, only unset the family if both addresses
are wiped.

Also, don't bother setting family = AF_UNSPEC, since it's the default (0).
2016-12-09 13:55:14 -05:00
Zbigniew Jędrzejewski-Szmek 40a922d055 networkd: use log_netdev_error in a two more places 2016-12-09 13:55:14 -05:00