Commit Graph

936 Commits

Author SHA1 Message Date
Susant Sahani c16c780804 network: introduce ip nexthop routing
Used to manipulate entries in the kernel's nexthop tables.
Example:
```
[NextHop]
Id=3
Gateway=192.168.5.1
```
2019-10-14 21:32:48 +09:00
Zbigniew Jędrzejewski-Szmek 800603524a networkd: drop DHCPv4 config on stop, keep on restart, by default
This partially reverts 95355a281c.

It seems that other parts of link_stop_clients() should be skipped
when restarting, but I don't know enough about those other clients to have
an opinion if it is better to stop&start them on restart or not.
Anyway, that can be done in later patches now that the support for restarts
is there.

Fixes #13625.
2019-10-02 14:01:42 +02:00
Yu Watanabe 55a1729fd0 network: drop noisy log message
Closes #13595.
2019-09-26 11:37:50 +09:00
Frantisek Sumsal 38288f0bb8 tree-wide: various code-formatting improvements
Reported/found by Coccinelle
2019-09-22 07:17:27 +02:00
Susant Sahani 299d578f7f network: DHCP server Add support to transmit SIP server
1. DHCP server trasmit
2. Client parses and saves in leases
Implements http://www.rfc-editor.org/rfc/rfc3361.txt

```
Frame 134: 348 bytes on wire (2784 bits), 348 bytes captured (2784 bits) on interface 0
Ethernet II, Src: 42:65:85:d6:4e:32 (42:65:85:d6:4e:32), Dst: 1e:04:f8:b8:2f:d4 (1e:04:f8:b8:2f:d4)
Internet Protocol Version 4, Src: 192.168.5.1, Dst: 192.168.5.11
User Datagram Protocol, Src Port: 67, Dst Port: 68
Dynamic Host Configuration Protocol (ACK)
    Message type: Boot Reply (2)
    Hardware type: Ethernet (0x01)
    Hardware address length: 6
    Hops: 0
    Transaction ID: 0x7cc87cb4
    Seconds elapsed: 0
    Bootp flags: 0x0000 (Unicast)
    Client IP address: 0.0.0.0
    Your (client) IP address: 192.168.5.11
    Next server IP address: 0.0.0.0
    Relay agent IP address: 0.0.0.0
    Client MAC address: 1e:04:f8:b8:2f:d4 (1e:04:f8:b8:2f:d4)
    Client hardware address padding: 00000000000000000000
    Server host name not given
    Boot file name not given
    Magic cookie: DHCP
    Option: (53) DHCP Message Type (ACK)
        Length: 1
        DHCP: ACK (5)
    Option: (51) IP Address Lease Time
        Length: 4
        IP Address Lease Time: (3600s) 1 hour
    Option: (1) Subnet Mask (255.255.255.0)
        Length: 4
        Subnet Mask: 255.255.255.0
    Option: (3) Router
        Length: 4
        Router: 192.168.5.1
    Option: (6) Domain Name Server
        Length: 4
        Domain Name Server: 192.168.5.1
    Option: (42) Network Time Protocol Servers
        Length: 4
        Network Time Protocol Server: 192.168.1.1
    Option: (120) SIP Servers <=====here
        Length: 9
        SIP Server Encoding: IPv4 Address (1)
        SIP Server Address: 192.168.1.1
        SIP Server Address: 192.168.5.2
    Option: (101) TCode
        Length: 13
        TZ TCode: Europe/Berlin
    Option: (54) DHCP Server Identifier (192.168.5.1)
        Length: 4
        DHCP Server Identifier: 192.168.5.1
    Option: (255) End
        Option End: 255
```

```
cat /run/systemd/netif/state                                                                                                   ✔    3148  16:40:51
OPER_STATE=routable
CARRIER_STATE=carrier
ADDRESS_STATE=routable
DNS=192.168.94.2 192.168.5.1
NTP=192.168.5.1
SIP=192.168.1.1 192.168.5.2

```

aa
2019-09-20 21:22:23 +09:00
Frantisek Sumsal 59a224d728
Merge pull request #13577 from yuwata/network-fix-ci-failure
network: fix CI failure
2019-09-17 17:42:26 +00:00
Yu Watanabe f136875549 network: make route_get() or friends take Route object 2019-09-17 21:53:42 +09:00
Yu Watanabe 4d59e14f32 network: do not enter failed state if device's sysfs entry does not exist yet 2019-09-17 21:34:06 +09:00
Yu Watanabe b1b0b42e48 network: add missing link->network checks
When the function is called, no network file may be assigned to the
link.
2019-09-17 21:29:35 +09:00
Yu Watanabe 5539fc0f73 network: drop IPv6LL address when LinkLocalAddressing=no|ipv4
C.f. disscussion in #13533.

Hopefully fixes #12886.
2019-09-17 09:45:22 +09:00
Yu Watanabe 2aa7d367ec network: do not create default route for ipv4 link local addressing
When nspawn container with private network starts, networkd creates
the default route for the interface. The route may cause problem on
the host side, and it can be created with DefaultRouteOnDevice= now.
Hence, this makes networkd not create the route implicitly any more.

Closes #13418.
2019-09-15 22:33:11 +09:00
Yu Watanabe b977347498
Merge pull request #13412 from yuwata/network-check-and-warn-more
network: check more static IPv6 configurations and add more warnings
2019-08-28 15:23:01 +09:00
Yu Watanabe adfeee49c5 network: enable ipv6 when the network has static ipv6 configurations 2019-08-27 23:53:46 +09:00
Zbigniew Jędrzejewski-Szmek 57ad760746 network: drop all checks of ipv6_disabled sysctl
*We* control the sysctl setting. If the user configured IPv6, then we apply the
settings, and just make sure that at some point during the configuration the
sysctl is disabled (i.e. ipv6 enabled) if we have IPv6 configured.

Replaces #13283.
2019-08-27 15:31:48 +02:00
Susant Sahani 482efedc08 network: Do not disable IPv6 by writing to sysctl
Only enable is and do not disable IPv6
2019-08-22 13:21:57 +02:00
Yu Watanabe 2d79289525 network: rename AddressFamilyBoolean -> AddressFamily
We usually do not call an extended boolean as XxxBoolean.
2019-08-16 22:02:17 +09:00
Lennart Poettering 24f36fb180
Merge pull request #13302 from yuwata/network-set-put-fixes
network: fixes related to set_put()
2019-08-14 16:18:06 +02:00
William A. Kennington III d1bdafd214 networkd: Keep track of static neighbors
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.
2019-08-12 20:28:19 +09:00
Yu Watanabe 3dc2e7af5f network: add missing link_ref() 2019-08-11 09:11:25 +09:00
Yu Watanabe 75a302b561 network: fix potential memleaks related to set_put() 2019-08-11 08:57:01 +09:00
William A. Kennington III 0b1cd3e25a networkd: Routes should take the gateway into account
Otherwise, changing the default gateway doesn't purge old gateway routes
left on the system during daemon restart. This also fixes removing other
foreign gateway routes that don't match the expected configuration.

Tested:
    Changed gateway addresses prior to the patch and they lingered on
    the system during each reconfiguration. Applied this patch and
    reconfigured gateways and other routes multiple times and it removed
    the foreign routes that had gateways that didn't match.

Signed-off-by: William A. Kennington III <william@wkennington.com>
2019-08-07 20:32:36 +09:00
Yu Watanabe 500b96eb34 network: drop redundant Link::kind check
All CAN devices' iftype are ARPHRD_CAN. So, checking Link::kind is
redundant.

Follow-up for c6ac3729c9.
2019-07-25 16:47:16 +09:00
Yu Watanabe c6ac3729c9 network: support slcan
The device driver does not have IFLA_INFO_KIND attribute. So, we need to
check iftype.

Closes #13150.
2019-07-24 23:13:22 +09:00
Yu Watanabe 8f815e8b03 tree-wide: drop netinet/ether.h from socket-util.h and sd-netlink.h 2019-07-24 18:23:08 +09:00
Yu Watanabe bd7d6cec33 network: do not touch kernel-created multicast route
Fixes #6088.
2019-07-23 22:08:49 +09:00
Yu Watanabe d4c52ee5b5 network: store routes provided by DHCPv4 in Set
This re-writes d03073ddcd.
2019-07-19 01:44:44 +09:00
Yu Watanabe 8107f4731e network: drop fallback mechanism to assign DHCPv6 addresses with IFA_F_NOPREFIXROUTE
The flag IFA_F_NOPREFIXROUTE was introduced in kernel-3.14. But even if
the kernel does not support the flag, it should be just ignored. So, it
is not necessary to do the fallback logic. Moreover, the current logic
is not a fallback mechanism but just retrying. So, it should not work.
Let's drop that.
2019-07-17 23:13:40 +09:00
Yu Watanabe 1576154957 network: implement DBus methods to set DNS related properties 2019-07-17 06:59:12 +09:00
Yu Watanabe 4e2ef9d9d1 network: do not configure routes when dropping addresses
Follow-up for 4ff296b024.
2019-07-17 00:51:46 +09:00
Yu Watanabe 4ff296b024 network: make link enter failed state when a configuration fails
Some path of configuring address, route or etc., go to failed state, but
some do not. E.g., failure in address configuration which is provided by
DHCPv4 goes to failed state, but static address does not.

This is just for consistency. This should not change anything if
everything is fine.

This also voidify manager_rtnl_process_address().
2019-07-15 21:52:06 +09:00
Yu Watanabe a0cd6da5bb network: honor IPv6AcceptRA.UseDomains= setting 2019-07-14 22:08:29 +09:00
Yu Watanabe b425c3ae02 network: do not change to configuring state needlessly
When DHCP or any other dynamic addresses are changed, then
link_request_set_routes() is invoked, and even if no static routes
are configured, the operational state is needlessly changed to
configuring state.
This makes the state is changed only when static routes are configured.
2019-07-14 07:37:12 +02:00
Lennart Poettering 7e82b4059b
Merge pull request #13006 from yuwata/network-split-dhcp-12917
networkd: DHCPv6 - separate DHCPv6 options from DHCPv4 options
2019-07-11 10:28:03 +02:00
Lennart Poettering a082157282
Merge pull request #13005 from keszybz/fix-gcc-warning
Fix two gcc warnings
2019-07-10 16:20:31 +02:00
1848 b7700511ef Fixed condition checked twice 2019-07-10 23:02:24 +09:00
1848 98d20a17a9 Added support for xfrm interfaces 2019-07-10 23:02:19 +09:00
Zbigniew Jędrzejewski-Szmek 573e9a3310 networkd: silence bogus gcc warning about %s
Fixes #12931.

In file included from ../src/basic/macro.h:558,
                 from ../src/basic/alloc-util.h:9,
                 from ../src/network/networkd-link.c:7:
../src/network/networkd-link.c: In function ‘link_sysctl_ipv6_enabled’:
../src/basic/log.h:107:9: error: ‘%s’ directive argument is null [-Werror=format-overflow=]
  107 |         log_internal_realm(LOG_REALM_PLUS_LEVEL(LOG_REALM, (level)), __VA_ARGS__)
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/shared/log-link.h:21:25: note: in expansion of macro ‘log_internal’
   21 |                         log_internal(level, error, _FILE_, __LINE__, __func__, ##__VA_ARGS__); \
      |                         ^~~~~~~~~~~~
../src/shared/log-link.h:33:50: note: in expansion of macro ‘log_link_full’
   33 | #define log_link_warning_errno(link, error, ...) log_link_full(link, LOG_WARNING, error, ##__VA_ARGS__)
      |                                                  ^~~~~~~~~~~~~
../src/network/networkd-link.c:83:24: note: in expansion of macro ‘log_link_warning_errno’
   83 |                 return log_link_warning_errno(link, r,
      |                        ^~~~~~~~~~~~~~~~~~~~~~
../src/network/networkd-link.c:84:77: note: format string is defined here
   84 |                                               "Failed to read net.ipv6.conf.%s.disable_ipv6 sysctl property: %m",
      |                                                                             ^~
cc1: some warnings being treated as errors
2019-07-10 10:32:39 +02:00
Susant Sahani caa8ca4286 networkd: DHCPv6 - separate DHCPv6 options from DHCPv4 options
Closes https://github.com/systemd/systemd/issues/12917
2019-07-10 16:59:29 +09:00
Yu Watanabe 593aee8f3c network: read sysctl value only once (#12990)
Follow-up for bafa964144.

When the value is changed, networkd needs to be restarted.
2019-07-09 09:56:50 +02:00
Yu Watanabe 8fcf1d6180 network: move DHCP server related functions to networkd-dhcp-server.c 2019-06-30 04:46:27 +09:00
Yu Watanabe ca5ad760a5 network: move conf parsers and function prototypes 2019-06-30 04:45:56 +09:00
Lennart Poettering 762267cdc1
Merge pull request #12762 from yuwata/network-introduce-carrier-and-network-state-12752
network: introduce carrier and address state to fix network_is_online()
2019-06-20 13:36:30 +02:00
Yu Watanabe b80a511b1b network: add missing entries in routing_policy_rule_{hash,compare}_func()
This also makes routing_policy_rule_get() or friends take
a RoutingPolicyRule object as an input.
2019-06-19 21:10:07 +09:00
Yu Watanabe ff14e2ebcb network: do not configure routing policy rule if it is already configured 2019-06-18 13:10:23 +09:00
Yu Watanabe ac999bf07d sd-network: introduce functions for new link and manager states 2019-06-16 23:17:28 +09:00
Yu Watanabe 35c5a9cae4 network: expose carrier and address states over dbus
Previously, when a bridge or bonding interface is in degraded-carrier
state, then we cannot judge the interface has addresses or not.
By using the new states, dbus clients can distinguish such situation.
2019-06-16 23:17:28 +09:00
Yu Watanabe 1678fbb3c5 network: split operational states into carrier and address states
This should not change any behavior. The new states will be exposed by
later commits.
2019-06-16 23:17:23 +09:00
Yu Watanabe 6a1af3d4ca network: split out DBus related prototypes to networkd-link-bus.h 2019-06-16 09:13:12 +09:00
Yu Watanabe bafa964144 network: read link specific sysctl value
This introduce link_sysctl_ipv6_enabled() and replaces
manager_sysctl_ipv6_enabled() with it.
2019-06-15 14:56:42 +02:00
Yu Watanabe 463797c104 network: skip to check dynamic addresses when ConfigureWithoutCarrier=yes
Otherwise, the interface cannot be in "configured" state, as ipv6 link local
addressing is enabled by default. Note that even if ConfigureWithoutCarrier=
is set, all dynamic configurations are checked when the interface has
carrier.
2019-06-14 05:25:35 +09:00
Yu Watanabe 7ef7e5509b network: ignore requested ipv6 routing policy rule when ipv6 is disabled by sysctl 2019-06-12 11:03:37 +09:00
Yu Watanabe c442331750 network: ignore requested ipv6 route when ipv6 is disabled by sysctl 2019-06-12 11:03:08 +09:00
Yu Watanabe 54a1a535bd network: ignore requested ipv6 addresses when ipv6 is disabled by sysctl 2019-06-12 11:02:33 +09:00
Yu Watanabe d03073ddcd network: assign new DHCP address before removing old lease address
Closes #12676.
2019-06-07 16:22:00 +09:00
Zbigniew Jędrzejewski-Szmek 2db18cdd46
Merge pull request #12738 from yuwata/network-routing-policy-cleanup
network: several cleanups for routing policy rule
2019-06-06 18:53:20 +02:00
Yu Watanabe db51778f85 network: make KeepConfiguration=static drop DHCP addresses and routes
Also, KeepConfiguration=dhcp drops static foreign addresses and routes.
2019-06-06 22:50:29 +09:00
Yu Watanabe 95355a281c network: add KeepConfiguration=dhcp-on-stop
The option prevents to drop lease address on stop.
By setting this, we can safely restart networkd.
2019-06-06 22:50:29 +09:00
Susant Sahani 7da377ef16 networkd: add support to keep configuration 2019-06-06 22:50:29 +09:00
Yu Watanabe 9f08a578a8 network: remove unused argument in routing_policy_rule_configure() 2019-06-04 16:23:18 +09:00
Zbigniew Jędrzejewski-Szmek c2babfc2f5 networkd: rewrite condition to make it easier to understand 2019-05-30 15:31:44 +02:00
Yu Watanabe d61e4c5b6e network: add nlmon support
nlmon is a Netlink monitor device.
2019-05-28 22:47:15 +09:00
Yu Watanabe cab042b843 network: make VXCAN devices go through LINK_STATE_CONFIGURING 2019-05-24 10:55:33 +09:00
Yu Watanabe 910feb787f network: unify link_ipv4ll_enabled() and link_ipv4ll_fallback_enabled() 2019-05-22 17:59:39 +09:00
Yu Watanabe a0ae96149a network: drop unused variable 2019-05-22 17:59:39 +09:00
Yu Watanabe bb262ef02b network: update master's ifindex in link_update()
And use it in link_is_enslaved().
2019-05-22 17:59:39 +09:00
Yu Watanabe 2292a4c6db network: drop duplicated logs
link_set_state() already logs about state change.
2019-05-22 17:58:46 +09:00
Yu Watanabe af9ba57aa2 network: make CAN devices go through LINK_STATE_CONFIGURING 2019-05-22 17:58:46 +09:00
Yu Watanabe f410d46358 network: disable IPv4LL for ipvlan with L3 or L3S mode
As L3 or L3S mode do not support ARP.
2019-05-22 17:58:46 +09:00
Yu Watanabe b26ea30801 network: tighten the condition whether link has carrier
ip command requires that IFF_RUNNING is set for that the link has
carrier.
2019-05-19 05:39:45 +09:00
Yu Watanabe a32a00831c
Merge pull request #12574 from yuwata/network-mtu-issue-12552
network: do not always bump MTU with additional 4bytes
2019-05-16 08:25:48 +02:00
Yu Watanabe fe0e16db09 network: do not use ordered_set_printf() for DOMAINS= or ROUTE_DOMAINS=
This partially reverts 5e2a51d588.

Fixes #12531.
2019-05-16 05:17:26 +02:00
Yu Watanabe f6fcc1c2a4 network: bump MTU bytes only when MTUByte= is not set 2019-05-16 11:51:03 +09:00
Yu Watanabe 933c70a0a4 network: honor MTUBytes= setting
Closes #12552.
2019-05-16 11:47:41 +09:00
Yu Watanabe af2fa2c116 network: disable link local addressing on ipip, gre, sit, and vti netdevs
Closes #12547.
2019-05-16 05:53:41 +09:00
Yu Watanabe 710ce9e537 network: link_check_ready() returns earlier if routes are not configured yet
link_request_set_routes() calls link_check_ready(), so it is not
necessary to continue that here.
2019-05-16 05:53:41 +09:00
Yu Watanabe d8f31d7d32
Merge pull request #12537 from yuwata/network-link-local-follow-ups
network: do not send ipv6 token to kernel
2019-05-14 02:22:18 +02:00
Yu Watanabe 9f6e82e6eb network: do not send ipv6 token to kernel
We disabled kernel RA support. Then, we should not send
IFLA_INET6_TOKEN.
Thus, we do not need to send IFLA_INET6_ADDR_GEN_MODE twice.

Follow-up for 0e2fdb83bb and
4eb086a387.
2019-05-12 07:32:00 +09:00
Yu Watanabe 86e2be7bc3 network: drop unnecessary initializations 2019-05-11 06:24:04 +09:00
Yu Watanabe 4799f19e30 network: move link_set_bond() to netdev/bond.c 2019-05-11 06:24:04 +09:00
Yu Watanabe 9a81f11956 network: move link_set_bridge to netdev/bridge.c 2019-05-11 06:24:04 +09:00
Yu Watanabe 3ddcbeea45 network: move CAN link related functions to networkd-can.c 2019-05-11 06:24:00 +09:00
Yu Watanabe 06d7cee589 network: make BindCarrier= work with CAN devices
If CAN device is set `BindCarrier=` then the interface could not be
down. This fixes the issue.
2019-05-11 06:21:43 +09:00
Yu Watanabe 8e54db83e2 network: make link_drop() can take custom handler
It will be used in the later commit.
2019-05-11 06:15:35 +09:00
Yu Watanabe 7f8539504c network: move sd_lldp related functions to networkd-lldp-rx.c 2019-05-11 06:14:39 +09:00
Susant Sahani be7468f07a LLDP: Fix logs for LLDP
```
May 10 11:08:54 test systemd-networkd[447]: wwan0: Failed to stop LLDP: Success
May 10 11:08:54 test systemd-networkd[447]: wwan0: Gained carrier
May 10 11:08:54 test systemd-networkd[447]: wwan0: Failed to start LLDP: Success
```
2019-05-11 06:14:39 +09:00
Yu Watanabe 0b20047244 network: move link_lldp_emit_enabled() to networkd-lldp-tx.c 2019-05-11 06:14:39 +09:00
Yu Watanabe 5af7bc6f4c
Merge pull request #12480 from ssahani/proxy-arp
network: bridge add support to configure proxy ARP/WIFI
2019-05-10 15:30:41 +02:00
Susant Sahani 8185ca6c0a networkd: Log error if LLDP fails to start/stop
Now LLDP does not log anything why it failed which
is hard to debug. Let's just add some logs.

https://github.com/systemd/systemd/issues/10881
2019-05-10 00:01:01 +02:00
Susant Sahani 0fadb2a46f network: add support to configure proxy ARP/WIFI 2019-05-09 15:03:04 +09:00
Susant Sahani 4eb086a387 networkd: fix link_up() (#12505)
Fillup IFLA_INET6_ADDR_GEN_MODE while we do link_up.

Fixes the following error:
```
dummy-test: Could not bring up interface: Invalid argument
```

After reading the kernel code when we do a link up
```
net/core/rtnetlink.c
IFLA_AF_SPEC
 af_ops->set_link_af(dev, af);
  inet6_set_link_af
   if (tb[IFLA_INET6_ADDR_GEN_MODE])
             Here it looks for IFLA_INET6_ADDR_GEN_MODE
```
Since link up we didn't filling up that it's failing.

Closes #12504.
2019-05-09 04:05:35 +02:00
Yu Watanabe 9aa5d8ba84 network: include glibc headers before including kernel headers 2019-05-09 03:21:31 +02:00
Yu Watanabe 004aadcacd network: replace inet_pton() with in_addr_from_string() 2019-05-09 01:44:31 +02:00
Susant Sahani 1087623bac networkd: Add support to configure proxy ARP and proxy ARP Wifi 2019-05-09 01:44:26 +02:00
Lennart Poettering b2adc2ae3a
Merge pull request #12501 from keszybz/silence-strncpy-warnings
Silence strncpy warnings
2019-05-08 01:39:32 +02:00
Yu Watanabe 2c448c8a17 network: fix use-after-free
The function sd_radv_add_prefix() in dhcp6_pd_prefix_assign() may
return -EEXIST, and in that case the sd_radv_prefix object allocated
in dhcp6_pd_prefix_assign() will be freed when the function returns.
Hence, the key value in Manager::dhcp6_prefixes hashmap is lost.
2019-05-07 16:55:19 +02:00
Yu Watanabe f535e35417 network: simplify link_free() 2019-05-07 16:55:19 +02:00
Yu Watanabe c9c908a60d network: make Link objects take references of Network objects 2019-05-07 16:55:19 +02:00
Zbigniew Jędrzejewski-Szmek c98b354500 network: remove redunant link name in message
Fixes #12454.

gcc was complaining that the link->ifname argument is NULL. Adding
assert(link->ifname) right before the call has no effect. It seems that
gcc is confused by the fact that log_link_warning_errno() internally
calls log_object(), with link->ifname passed as the object. log_object()
is also a macro and is does a check whether the passed object is NULL.
So we have a check if something is NULL right next an unconditional use
of it where it cannot be NULL. I think it's a bug in gcc.

Anyway, we don't need to use link->ifname here. log_object() already prepends
the object name to the message.
2019-05-07 13:46:55 +02:00
Susant Sahani 946f8e14d5 networkd: stop clients when networkd shuts down (#12463)
We not stopping the clients when networkd stops. They
should shut down cleanly and then we need to clean the DS.

One of requirements to implement
https://github.com/systemd/systemd/issues/10820.

```
^CBus bus-api-network: changing state RUNNING → CLOSED
DHCP SERVER: UNREF
DHCP SERVER: STOPPED
DHCP CLIENT (0x60943df0): STOPPED
veth-test: DHCP lease lost
veth-test: Removing address 192.168.5.31
NDISC: Stopping IPv6 Router Solicitation client
DHCP CLIENT (0x0): FREE
==24308==
==24308== HEAP SUMMARY:
==24308==     in use at exit: 8,192 bytes in 2 blocks
==24308==   total heap usage: 4,230 allocs, 4,228 frees, 1,209,732 bytes allocated
==24308==
==24308== LEAK SUMMARY:
==24308==    definitely lost: 0 bytes in 0 blocks
==24308==    indirectly lost: 0 bytes in 0 blocks
==24308==      possibly lost: 0 bytes in 0 blocks
==24308==    still reachable: 8,192 bytes in 2 blocks
==24308==         suppressed: 0 bytes in 0 blocks
==24308== Rerun with --leak-check=full to see details of leaked memory
==24308==
==24308== For lists of detected and suppressed errors, rerun with: -s
==24308== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
==24308== could not unlink /tmp/vgdb-pipe-from-vgdb-to-24308-by-sus-on-Zeus
==24308== could not unlink /tmp/vgdb-pipe-to-vgdb-from-24308-by-sus-on-Zeus
==24308== could not unlink /tmp/vgdb-pipe-shared-mem-vgdb-24308-by-sus-on-Zeus

```
2019-05-06 16:06:50 +02:00
Yu Watanabe 6c0c041a8e network: make link_check_ready() handle LinkLocalAddressing=fallback 2019-05-04 16:46:02 +02:00
Yu Watanabe 552081a499 network: rewrite condition about DHCP in link_check_ready() 2019-05-04 16:46:02 +02:00
Susant Sahani 8bc17bb3f7 networkd: Option to use LinkLocalAddressing only when DHCP fails
When LinkLocalAddressing=fallback or LinkLocalAddressing=ipv4-fallback
then IPv4LL will be started only when DHCP fails.

Closes #9648.
2019-05-04 16:45:57 +02:00
Yu Watanabe b9ea3d2e47 network: fix assertion when link get carrier
This fixes a bug introduced by bd08ce5615.
When link is in LINK_STATE_INITIALIZED, `Link::network` may not be
set yet.

Fixes #12452.
2019-05-03 01:14:36 +02:00
Susant Sahani b5799eeb07 networkd: Add back static routes after DHCPv4 lease expires.
1. When the DHCPv4 lease expires kernel removes the route. So add it back
when we gain lease again.

Closes https://github.com/systemd/systemd/issues/12426

2. When UseRoutes=false do not remove router
2019-04-29 18:13:31 +02:00
Ben Boeckel 5238e95759 codespell: fix spelling errors 2019-04-29 16:47:18 +02:00
Yu Watanabe 51aba17b88 network: drop invalid assertion
The link may not have corresponding .network file.
Note that in that case, link_ipv4ll_enabled() and link_dhcp4_enabled()
returns false. So, it is safe to drop the assertion.

Fixes #12422.
2019-04-28 19:54:50 +02:00
Zbigniew Jędrzejewski-Szmek 4232cf049f network: drop "return 1" when the return value is ignored by all callers
The reader is tricked into thinking that this has some meaning...
2019-04-25 11:13:39 +02:00
Yu Watanabe 5f707e1280 network: fix ref/unref logic for Link object
- bridge or bonding master takes a reference of slave links.
- drop link from bridge or bonding master's slave list when slave link
  is removed.
- change type of Link::slaves to Set*,

Fixes #12315.
2019-04-25 10:47:17 +02:00
Yu Watanabe bd08ce5615 network: prevent interfaces to be initialized multiple times
When a uevent is received during the relevant interface is in
LINK_STATE_PENDING, then the interface may be initialized twice.
To prevent that, this introduces LINK_STATE_INITIALIZED.
2019-04-25 10:44:46 +02:00
Yu Watanabe 0beb9542e9 network: logs link state change 2019-04-17 19:41:50 +09:00
Zbigniew Jędrzejewski-Szmek 41f6e627d7 Make fopen_temporary and fopen_temporary_label unlocked
This is partially a refactoring, but also makes many more places use
unlocked operations implicitly, i.e. all users of fopen_temporary().
AFAICT, the uses are always for short-lived files which are not shared
externally, and are just used within the same context. Locking is not
necessary.
2019-04-12 11:44:56 +02:00
Lennart Poettering 6990fb6bc6 tree-wide: (void)ify a few unlink() and rmdir()
Let's be helpful to static analyzers which care about whether we
knowingly ignore return values. We do in these cases, since they are
usually part of error paths.
2019-03-27 18:09:56 +01:00
Yu Watanabe 7033af49df network: introduce new netdev create type NETDEV_CREATE_AFTER_CONFIGURED
It will be used to support L2TP tunnel in later commits.
2019-03-14 10:57:41 +09:00
Yu Watanabe 2b6db913e2 network: do not call link_joined() when not all netdevs are configured
If some of stacked netdevs are already configured, then link_joined()
is called before netdevs are fully configured.
2019-03-14 10:57:41 +09:00
Tobias Jungel 7f15b71460 networkd: Add bridge port capabilities
This PR adds the configuration switches for multicast flooding, neighbor
suppression and learning of a bridge port.
2019-03-13 16:27:22 +01:00
Yu Watanabe 4ac77d63e9 network: make RequiredForOnline= also take operational state
This will be used by systemd-networkd-wait-online.
2019-03-13 14:29:03 +09:00
Yu Watanabe c9cc038343 network: introduce 'degraded-carrier' operstate to order all states
Previously, 'degraded' state is ambiguous for bonding or bridge master:
1. one or more slave interfaces does not have carrier,
2. no link local address is assigned to the master,
3. combination of the above two.

This makes the above case 1 and 3 are in the new 'degraded-carrier'
state, and makes 'degraded' state as all slaves are active but no
link local address on master.
2019-03-13 14:29:00 +09:00
Yu Watanabe 2cd6b9326c network: move LinkOperationalState and relevant functions to network-util.[ch] 2019-03-13 14:28:38 +09:00
Clemens Gruber c423be28a0 network: introduce TripleSampling= option in CAN section
When enabled, three samples are used to determine the value of a
received bit by majority rule.

This patch adds support for the TripleSampling= option in the [CAN]
section of .network files.
2019-03-11 17:15:47 +01:00
Yu Watanabe 299ad32d48 network: do not configure interfaces under renaming 2019-03-05 10:33:42 +09:00
Yu Watanabe 30de2b89d1 network: always drop configs when interface is renamed
Before the renaming, wrong .network file may be assigned to the link.
So, let's always drop link configuration.
2019-03-05 10:33:27 +09:00
Yu Watanabe 40288ecea1 network: bump mtu if stacked vlan or macvlan requests larger size
Closes #5972.
2019-02-27 10:04:56 +09:00
Yu Watanabe 45e11abfff network: make bridge master also follow operstates of slave interfaces
If one of bridge slaves is in off, no-carrier, or dormant, then
operstate of the bridge master is set to degraded.
2019-02-25 09:34:14 +09:00
Yu Watanabe 34bf3c0051 network: extend 'enslaved' state to bridge slave interfaces
Currently, the interface's operstate is set to 'enslaved' only when
it is managed by networkd.
2019-02-25 09:34:14 +09:00
Yu Watanabe b102cdca6b network: do not disable dynamic addressing for bridge slaves
This effectively reverts 5971cb9de9 and
2b00a4e03d.

Usually, it is not necessary to assign addresses to bridge slaves,
but such functionality is supported by kernel. If users explicitly
request such configuration, networkd should support that.
2019-02-25 09:34:14 +09:00
Yu Watanabe 033295c188 network: fix invalid memory access
This fixes a bug introduced by 959f65d32e.
2019-02-25 09:34:14 +09:00
Lennart Poettering 953a1af082
Merge pull request #11776 from keszybz/networkd-ordered-sets
Store domains lists in OrderedSets in networkd
2019-02-21 15:15:11 +01:00
Zbigniew Jędrzejewski-Szmek 5e2a51d588 networkd: use OrderedSets instead of strvs to store lists of domains
We were already using OrderedSets in the manager object, but strvs in the
configuration parsing code. Using sets gives us better scaling when many
domains are used.

In oss-fuzz #13059 the attached reproducer takes approximately 30.5 s to be
parsed. Converting to sets makes this go down to 10s. This is not _vastly_
faster, but using sets seems like a nicer approach anyway. In particular, we
avoid the quadratic de-unification operation after each addition.
2019-02-21 12:04:27 +01:00
Yu Watanabe 4b600505dd network: check whether ipv6 is enabled in sysctl
Currently, the value is read only once.

Fixes #11711.
2019-02-21 10:55:13 +09:00
Yu Watanabe 826a3602d8 network: use sysctl_read_ip_property() 2019-02-21 10:38:10 +09:00
Yu Watanabe 62e021a95d network: use sysctl_write_ip_property() and friends 2019-02-21 10:38:10 +09:00
Thomas Haller 072320eab0 dhcp: move filtering of bogus DNS/NTP addresses out of DHCP client
The DHCP client should not pre-filter addresses beyond what RFC
requires. If a client's user (like networkd) wishes to skip/filter
certain addresses, it's their responsibility.

The point of this is that the DHCP library does not hide/abstract
information that might be relevant for certain users. For example,
NetworkManager exposes DHCP options in its API. When doing that, the
options should be close to the actual lease.

This is related to commit d9ec2e632d
(dhcp4: filter bogus DNS/NTP server addresses silently).
2019-02-18 13:34:22 +01:00
Lennart Poettering 1cfece4a45
Merge pull request #11681 from yuwata/network-link-enslaved-operstate
network: introduce new 'enslaved' operstate
2019-02-18 13:00:13 +01:00
Lennart Poettering 702451b038
Merge pull request #11698 from yuwata/fix-network-route-table
network: honor specified route table
2019-02-18 12:58:32 +01:00
Yu Watanabe 959f65d32e network: make bond master follow operstates of slaves
If one of bond slaves is in off, no-carrier, or dormant, then
bond master is set to degraded.
2019-02-18 18:04:11 +09:00
Yu Watanabe 25e992ba23 network: always drop configs when corresponding network file does not exist
Follow-up for 93b4dab57e.

Fixes #11724.
2019-02-18 06:11:50 +09:00
Yu Watanabe 89b9a97573 network: disable link local addressing on vrf
See the commment in vrf_link_scope_lookup() in drivers/net/vrf.c of
Linux kernel.
2019-02-17 01:15:23 +09:00
Yu Watanabe 14153d1b6e network: introduce new operational state 'enslaved'
If an interface has IFF_SLAVE flag, then its operational state becomes
not in 'degraded' or 'carrier', but the new 'enslaved' state.
2019-02-16 07:15:49 +09:00
Yu Watanabe 7fcee28417 network: introduce specific netlink async handler for link_set_bond()
This also rename link_bond_set() to link_set_bond().
2019-02-16 07:15:49 +09:00
Yu Watanabe f2bfcdb94a network: disable addressing on bond slave interface 2019-02-16 07:15:49 +09:00
Lennart Poettering 8e6b3f49fe
Merge pull request #11636 from yuwata/network-in-addr-is-null
network, sd-netlink: unify several functions and fixes coding style
2019-02-15 11:40:34 +01:00
Lennart Poettering 19df3047f3
Merge pull request #9262 from ssahani/ignore-carrier-9111
networkd: allow to retain configs even if carrier is lost
2019-02-15 11:35:43 +01:00
Yu Watanabe bdb9f58086 network: honor VRF table or explicitly specified route table 2019-02-15 11:45:39 +09:00
Susant Sahani 0e2fdb83bb networkd: honour LinkLocalAddressing
Closes #9890
2019-02-13 02:36:15 +09:00
Yu Watanabe 3f7cc0809d network: coding style fixes 2019-02-11 01:28:09 +09:00
Susant Sahani 93b4dab57e networkd: Allow to retain configs even if carrier is lost
When there is bad link in the network the carrier goes up/down.
This makes networkd stops all the clients and drop config.
But if the remote router/dhcpserver running a prevention
of DHCP Starvation attack or DHCP Flood attack it does not allow
networkd to take a DHCP lease resulting failure in configuration.
This patch allows to keep the client running and keep the conf
also for this scenario.

Closes #9111
2019-02-06 13:35:11 +01:00
Lennart Poettering 7c45deb20d
Merge pull request #11460 from yuwata/fix-11458
network: update address when static address was already configured by DHCP
2019-01-26 15:41:06 +01:00
Yu Watanabe 1cc84f3bb9 network: make link_up() static 2019-01-24 12:07:41 +09:00
Lennart Poettering a8ea2833cf
Merge pull request #11375 from daxtens/issue5882
network: Fix IPv6 PreferredSource routes
2019-01-17 18:08:01 +01:00
Yu Watanabe a47a6daebe network: update address when static address was already configured by DHCP
Fixes #11458.
2019-01-17 14:16:21 +09:00
Daniel Axtens 6aa5773bff Install routes after addresses are ready
If an IPv6 route is added with a source address that is still
tentative, the kernel will refuse to install it.

Previously, once we sent the messages to the kernel to add the
addresses, we would immediately proceed to add the routes. The
addresses would usually still be tentative at this point, so
adding static IPv6 routes was broken - see issue #5882.

Now, only begin to configure routes once the addresses are ready,
by restructuring the state machine, and tracking when addresses are
ready, not just added.

Fixes: #5882
Signed-off-by: Daniel Axtens <dja@axtens.net>
2019-01-16 12:54:06 +11:00
Yu Watanabe 9e2bbf9915 network: make Link and NetDev always have the valid poiter to Manager
c4397d94c3 introduces
link_detach_from_manager() and netdev_detach_from_manager(), and they
set Link::manager or NetDev::manager NULL.
But, at the time e.g. link is removed, hence link_drop() is called,
there may be still some asynchronous netlink call is waiting, and
their callbacks hit assertion.

This make {link,netdev}_detach_from_manager() just drop all references
from manager, but keep the pointer to manager.

Fixes #11411.
2019-01-15 14:48:53 +01:00
Daniel Axtens 6accfd3139 Move link_check_ready() to later in the file
We're about to need it to be later in the file for the next commit.
Moving it now means that when we change it in the next commit, it's
not intermingled with the move.

No functional change intended.

Signed-off-by: Daniel Axtens <dja@axtens.net>
2019-01-10 11:01:57 +11:00
Yu Watanabe 2428613f85 network: set *_configured flags to false before requesting addresses or freinds
Fixes #11272.
2019-01-02 18:37:10 +09:00
Yu Watanabe 47079967e6 network: rename link_set_routing_policy_rule() to link_request_set_routing_policy_rule()
For consistency to other functions.
2019-01-02 18:37:10 +09:00
Yu Watanabe f3ef324dfa network: do not ignore errors on link_request_set_neighbors() and link_set_routing_policy() 2019-01-02 18:37:10 +09:00
rogerjames99 7da7340afd Do not start server if it is already runnning (#11245) 2018-12-28 15:34:43 +09:00
Lennart Poettering 7ece6f5897 networkd: permit DNS "DefaultRoute" configuration in .network files 2018-12-21 12:10:07 +01:00
Thomas Haller 8217ed5ec3 network: fix handling of uninitialized and zero IAID setting
An earlier commit 0e408b82b (dhcp6-client: handle IAID with value zero)
introduced a flag to sd_dhcp6_client to distinguish between an unset
IAID and a value set to zero.

However, that was not sufficient and broke leaving the setting
uninitialized in networkd configuration. The configuration parsing
also must distinguish between the default, unset value and an
explict zero configuration.

Fixes: 0e408b82b8
2018-12-10 14:25:28 +01:00
William A. Kennington III e4a71bf36f networkd: Static neighbor support
When using networkd we currently have no way of ensuring that static
neighbor entries are set when our link comes up. This change adds a new
section to the network definition that allows multiple static neighbors
to be set on a link.
2018-12-09 16:56:37 -08:00
William A. Kennington III 289e6774d0 networkd: Use only a generic CONFIGURING state
This allows us to convey that we are performing multiple link
configuration changes in parallel. This is needed to support configuring
neighbors while simultaneously configuring addresses and routes.
2018-12-09 16:56:00 -08:00
William A. Kennington III c42ff3a1a7 networkd: Track address configuration
This will be useful to assert that our static route configuration always
happens after address configuration once our individual configure state
goes away.
2018-12-09 16:54:37 -08:00
Yu Watanabe f0a43eb821
Merge pull request #11063 from yuwata/update-missing-v3
missing: split missing.h into small pieces
2018-12-06 16:54:27 +01:00
Yu Watanabe ef118d00eb util: drop missing.h from socket-util.h 2018-12-06 13:31:16 +01:00
Susant Sahani d3aa8b49e5 networkd: bridge add support to configure multicast_to_unicast
closes #10649
2018-12-03 23:49:46 +05:30
Lennart Poettering a20f73221a
Merge pull request #10976 from yuwata/typesafe-netlink-call
netlink: introduce typesafe netlink functions
2018-12-03 17:55:00 +01:00
Lennart Poettering 686d13b9f2 util-lib: split out env file parsing code into env-file.c
It's quite complex, let's split this out.

No code changes, just some file rearranging.
2018-12-02 13:22:29 +01:00
Lennart Poettering e4de72876e util-lib: split out all temporary file related calls into tmpfiles-util.c
This splits out a bunch of functions from fileio.c that have to do with
temporary files. Simply to make the header files a bit shorter, and to
group things more nicely.

No code changes, just some rearranging of source files.
2018-12-02 13:22:29 +01:00
Yu Watanabe 302a796f5a network: use typesafe netlink_call_async() macro where applicable 2018-12-02 06:29:32 +01:00
Yu Watanabe 4645ad47ac network: use route_remove_handler() as the default callback of route_remove() 2018-12-02 06:23:45 +01:00
Yu Watanabe 63ae056909 network: use address_remove_handler() as the default callback of address_remove() 2018-12-02 06:23:45 +01:00
Yu Watanabe 29889b4d24 network: set default callbacks for routing_policy_rule_configure() and routing_policy_rule_remove() 2018-12-02 06:23:45 +01:00
Yu Watanabe cccf9517f1 network: move address_label_handler() to networkd-address-label.c
And use it as the default callback function of address_label_configure().
2018-12-02 06:23:45 +01:00
Lennart Poettering bf61b05a06 networkd: slightly rework route establishment logic
Use a for() loop to merge the two very similar loops into one, and add
more comments explaining the logic behing this.

Follow-up for 0d34228fc0
2018-11-29 13:38:54 +09:00
Yu Watanabe fab57f7f13
Merge pull request #10948 from ssahani/iprule-port-proto
networkd: add support to configure ip rule port range and protocol.
2018-11-29 03:17:36 +09:00
Susant Sahani 926062f083 networkd: add support to configure ip rule port range and protocol.
Please see:

iprule: support for ip_proto, sport and dport match options
https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/commit/?id=f686f764682745daf6a93b0a6330ba42a961f858

Closes 10622
2018-11-28 20:06:28 +05:30
Susant Sahani 0d34228fc0 fix: systemd-networkd reverse route ordering
We missing a default route. Add gateway first.

This fixes https://github.com/systemd/systemd/issues/5430
2018-11-28 23:19:00 +09:00
Lennart Poettering 13df9c398d fileio: automatically add NULL sentinel to parse_env_file()
Let's modernize things a bit.
2018-11-14 17:01:55 +01:00
Lennart Poettering aa8fbc74e3 fileio: drop "newline" parameter for env file parsers
Now that we don't (mis-)use the env file parser to parse kernel command
lines there's no need anymore to override the used newline character
set. Let's hence drop the argument and just "\n\r" always. This nicely
simplifies our code.
2018-11-14 17:01:54 +01:00
Yu Watanabe 17f9c355d5 network: use structured initializers 2018-11-12 16:32:10 +09:00
Lennart Poettering b992109b3e
Merge pull request #10633 from yuwata/sd-resolve-destroy
Another solution to fix wireguard issues
2018-11-06 19:30:59 +03:00
Lennart Poettering a0ca258adf
Merge pull request #10597 from toanju/fix-networkd-l3-loss
networkd: don't remove ip address or route
2018-11-06 17:44:24 +03:00
Tobias Jungel 7ecf0c3e17 networkd: don't remove route
In case networkd is restarted this prevents a removal of an already existing
route that would be configured using networkd. With the proposed changes the
route will be kept on the interface without removing. This happens only on
physical hosts or VMs since networkd handles interface configuration slightly
different in containers.
2018-11-06 13:28:12 +01:00
Tobias Jungel 30226d2718 networkd: don't remove ip address
In case networkd is restarted this prevents a removal of an already existing IP
address that would be configured using networkd. With the proposed changes the
IP address will be kept on the interface without removing. This happens only on
physical hosts or VMs since networkd handles interface configuration slightly
different in containers.
2018-11-06 13:26:37 +01:00
Yu Watanabe 57512c893e tree-wide: set WRITE_STRING_FILE_DISABLE_BUFFER flag when we write files under /proc or /sys 2018-11-06 21:24:03 +09:00
Yu Watanabe c4397d94c3 network: link_drop() and netdev_drop() remove reference from manager 2018-11-05 13:19:02 +09:00
Yu Watanabe e6b65ab760 network: fix return value of routing_policy_rule_get()
To distinguish source of rule.
2018-11-01 23:38:11 +09:00
Yu Watanabe 5a937ea2f6 sd-device: make sd_device_get_is_initialized() returns is_initialized by return value 2018-10-29 17:33:33 +09:00
Tobias Jungel cbff717048 networkd: keep bond slave up if already attached
There is no need to disable an already correct enslaved interface.

relates to #10118
2018-10-19 23:00:52 +02:00
Yu Watanabe 8190a388a6 sd-netlink: make sd_netlink_slot take its description 2018-10-16 18:42:23 +09:00
Yu Watanabe ee38400bba sd-netlink: introduce sd_netlink_slot 2018-10-15 18:10:04 +09:00
Yu Watanabe 0ae286e697 network: make netlink callbacks return 1
This is not necessary. But most of netlink callbacks in networkd
return 1.
2018-10-10 14:43:05 +09:00
Yu Watanabe 26d6b2147e network: drop break line in comment 2018-10-10 14:43:05 +09:00
Yu Watanabe e6bf77744a network: make netlink callback not return negative value
Fixes #10320.
2018-10-10 14:43:05 +09:00
Yu Watanabe 1046bf9b1a network: add destroy callbacks for asynchronous netlink calls 2018-10-10 14:43:05 +09:00
Yu Watanabe 545bab1f0a sd-netlink: add destroy_callback argument to sd_netlink_call_async() 2018-10-10 14:43:05 +09:00
Patrik Flykt aabcb75409 networkd-link: Don't start a DHCPv6 informational exchange automatically
When a link is configured, wait until there is a Router Advertisement before
attempting to start DHCPv6. The intended DHCPv6 mode will be evaluated in
ndisc_router_handler() in networkd-ndisc.c.
2018-10-05 16:58:06 +02:00
Patrik Flykt 107523437c networkd-dhcp6: Request prefix delegation for a new link
Request prefix delegation for a new downstream link that is enabled
after any number of upstream DHCPv6 links. Submit the request after
the link has been configured with a link-local address.

If the upstream DHCPv6 client has already been configured to request
prefixes, attempt to re-assign any possible prefixes between the
already existing links and the new one. If no prefixes are yet
acquired, nothing will happen right away and any prefixes will be
distributed after a reply from the DHCPv6 server.

If none of the already existing downstream links have requested
DHCPv6 prefixes to be assigned, enable prefix delegation for each
client and restart them one by one if they are already running. This
causes the DHCPv6 clients to re-acquire addresses and prefixes and
to re-distribute them to all links when receiving an updated
response from their respective DHCPv6 servers. If the DHCPv6 client
in question was not already running, it is set to request prefixes
but not restarted.

When an error occurs while setting or restarting the DHCPv6 client,
log the incident and move over to the next link.

Fixes #9758.
2018-10-02 12:32:46 -06:00
Zbigniew Jędrzejewski-Szmek 9d0798a2ed
Merge pull request #9832 from yuwata/fix-9831
network: fixes related to setting MTU
2018-09-08 17:17:07 +02:00
Yu Watanabe 8301aa0bf1 tree-wide: use DEFINE_TRIVIAL_REF_UNREF_FUNC() macro or friends where applicable 2018-08-27 14:01:46 +09:00
Zbigniew Jędrzejewski-Szmek ab4dd98476 network: reword some error messages
Use "falling back" instead of "fallback".

Also, it's not an application-specific machine ID, but rather an
application-and-machine-specific ID.  Let's call it "app-machine-speicific" for
short.
2018-08-23 11:32:55 +02:00
Zbigniew Jędrzejewski-Szmek c07fe6d0df Merge pull request #9406 from yuwata/rfe-9228
Trivial conflict solved in merge and include net/if_arp.h added.
2018-08-23 11:11:13 +02:00
Susant Sahani 708c425d0a Networkd: Start DHCP server when link is up.
Closes #9479
2018-08-23 10:03:30 +02:00
Yu Watanabe 51517f9e09 network: replace udev_device by sd_device 2018-08-23 04:57:39 +09:00
Yu Watanabe 55dc8c4a82 network: call link_acquire_conf() and link_enter_join_netdev() after MTU is set
Fixes #9831.
2018-08-13 16:12:08 +09:00
Yu Watanabe ee4931068e network: do not re-set MTU when current and requested MTU are same 2018-08-13 15:23:31 +09:00
Yu Watanabe 72c2500b2a network: drop redundant lines
Follow-up for 44b598a1c9.
2018-08-13 15:23:31 +09:00
Yu Watanabe 27dfc98275 network: request product UUID when DUIDType=uuid but DUIDRawData= is not set
Closes #9228.
2018-08-08 10:15:00 +09:00
Yu Watanabe fff1f40c9b network: introduce dhcp4_set_client_identifier() to unify duplicated codes 2018-08-08 10:15:00 +09:00
Yu Watanabe f24648a66c network: move and rename link_duid() 2018-08-08 10:15:00 +09:00
Yu Watanabe fc95c359f6 tree-wide: use returned value from log_*_errno() 2018-08-07 15:48:37 +09:00
Yu Watanabe ddfc4f6e34 network: free routes assigned to link 2018-07-18 13:07:27 +09:00
Yu Watanabe 0ade014c8b network: simplify link_free() 2018-07-18 13:06:34 +09:00
Yu Watanabe db2f8a2e8a tree-wide: add a space after (void) 2018-07-03 10:44:28 +02:00
Lennart Poettering 6dd9477dde
Merge pull request #9348 from keszybz/copyright-removal
Copyright removal
2018-06-20 12:27:56 +02: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
Susant Sahani 44b598a1c9 networkd: Unify set MTU
Now the setting MTU is embedded into the link_up message which makes it
incapable of setting MTU if link is up. MTU can be set while Link is up.

Closes #9254
2018-06-20 08:09:30 +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
Iwan Timmer c9299be2f5 resolve: rename PrivateDNS to DNSOverTLS
PrivateDNS is not considered a good name for this option, so rename it to DNSOverTLS
2018-06-14 09:57:56 +02:00
Iwan Timmer d050561ac3 resolve: make PrivateDNS configurable per link
Like with DNSSec, make PrivateDNS configurable per link, so you can have trusted and untrusted links.
2018-06-11 21:35:58 +02:00
Hiram van Paassen 06828bb617 networkd-link: add support to configure CAN interfaces
This patch adds support for kind "can". Fixes: #4042.
2018-06-09 15:12:31 +02:00
Marc Kleine-Budde bd5038f8b7 networkd-link: link_up_can(): move function upwards
This patch is a preparation patch, to avoid forward declarations in the
next patch.
2018-06-09 15:12:31 +02:00
Marc Kleine-Budde 93ea77505e networkd-link: link_configure(); factor out link_configure_can() into separate function 2018-06-09 15:12:31 +02:00
Zbigniew Jędrzejewski-Szmek a1230ff972 basic/log: add the log_struct terminator to macro
This way all callers do not need to specify it.
Exhaustively tested by running test-log under valgrind ;)
2018-06-04 13:46:03 +02:00
Susant Sahani 866e6b7a12 networkd: enable to set IFF_ALLMULTI to network device (#9146)
networkd: allow setting set IFF_ALLMULTI flag on network devices
2018-06-01 16:22:12 +02:00
Susant Sahani e6ebebbe6a networkd: Add ability to set MULTICAST flag on interface
Closes #9113

fix ARP toggling flag
2018-05-30 12:59:24 +02:00
Lennart Poettering 1a5a177eaf fileio: accept FILE* in addition to path in parse_env_file()
Most our other parsing functions do this, let's do this here too,
internally we accept that anyway. Also, the closely related
load_env_file() and load_env_file_pairs() also do this, so let's be
systematic.
2018-05-24 17:01:57 +02:00
Susant Sahani b296797f1c networkd: use ipv6_accept_ra_use_dns rather than dhcp_use_dns (#8836)
While Saving the DNS server use [IPv6AcceptRA] UseDNS= that is
ipv6_accept_ra_use_dns.

Closes #8420
2018-05-02 20:16:10 +02:00
Susant Sahani 7f9915f0de networkd: Bridge Property Use kernel defaults. (#8825)
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
2018-04-27 10:32:28 +02:00
Yu Watanabe 587c458665 network: recreate link if its interface name is changed (#8795)
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.
2018-04-26 21:05:32 +02:00
Lennart Poettering 4e964aa05c networkd,udev: clean up MTU handling
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.)
2018-04-26 13:51:44 +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
Susant Sahani 11102cba69 networkd: add support to configure IPv6 MTU (#8664)
This patch supports to configure IPv6 MTU.

Closes #8632
2018-04-20 11:38:39 +02:00
Lennart Poettering 5d13a15b1d tree-wide: drop spurious newlines (#8764)
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.
2018-04-19 12:13:23 +02:00
Susant Sahani b1c626f67f networkd: fix crash if fails to get network file (#8714)
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
```
2018-04-17 16:55:04 +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
Yu Watanabe 1cc6c93a95 tree-wide: use TAKE_PTR() and TAKE_FD() macros 2018-04-05 14:26:26 +09:00
Lennart Poettering 5c24d63675
Merge pull request #8106 from dqminh/route-expires-kernel
move route expiration to kernel
2018-03-20 17:38:30 +01:00
Yu Watanabe dace710c4a dhcp4: introduce new option 'duid-only' for ClientIdentifier= (#8350)
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.
2018-03-12 17:18:07 +01:00
Daniel Dao f02ba16389 setup route expiration in kernel if supported
kernel >= 4.5 (with commit 32bc201e19) 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>
2018-03-12 11:36:25 +00:00
Jason A. Donenfeld a8f5bba6a0 networkd: assume no link local addresses for where it isn't used
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>
2018-01-26 15:41:17 +01:00
Susant Sahani 420d205867 networkd: sd_ndisc reset mac address when MAC address change detected.
When there is a change in mac address we are not currently not changing
the MAC address and resulting  v6 connectivity is gone.

When kernel reports a change in mac address change the MAC of ndisc
client too.

Closes # 7806
2018-01-24 12:05:38 +01:00
Yu Watanabe 55a7c78b9d networkd: remove unnecessary parentheses
Follow-up for 56a23cb40a.
2018-01-15 23:48:00 +09:00
Lennart Poettering 38edb7674b
Merge pull request #7582 from pfl/dhcp6_prefix_delegation
DHCPv6 prefix delegation
2018-01-15 12:02:37 +01:00
Susant Sahani 27c34f732e networkd: call link_set_routing_policy_rule before setting routes (#7815)
commit 7715629 (networkd: Fix race condition in [RoutingPolicyRule] handling (#7615)).
Does not fix race. Still there is a race in case of bride because the
bride goes down and up .

calling route_configure then link_set_routing_policy_rule and the
link_check_ready makes a race between routing_policy_rule_messages and route_messages.
While bride comes up and we call the call again route_configure if finds
it self in the callback function LINK_STATE_CONFIGURED networkd dies.
Let's handle first routing policy rules then route_configure. This fixes
the crash.
Closes #7797
2018-01-09 09:13:06 +01:00
Patrik Flykt 56a23cb40a networkd: Add DHCPv6 as a configuration option to radv prefixes
The Network section IPv6PrefixDelegation= option takes two new
configuration values, namely "static" and "dhcpv6" in addition
to boolean yes and no values. Static prefixes in IPv6Prefix
sections are used when IPv6PrefixDelegation= option contains
"static", and DHCPv6 is queried for prefixes when the option
contains "dhcpv6". Both DHCPv6 and static prefixes are used when
the option contains a boolean true value. The default value is
false as before, meaning no prefixes are delegated.
2018-01-04 15:22:43 +02:00
Lennart Poettering 0d53667334 tree-wide: use __fsetlocking() instead of fxyz_unlocked()
Let's replace usage of fputc_unlocked() and friends by __fsetlocking(f,
FSETLOCKING_BYCALLER). This turns off locking for the entire FILE*,
instead of doing individual per-call decision whether to use normal
calls or _unlocked() calls.

This has various benefits:

1. It's easier to read and easier not to forget

2. It's more comprehensive, as fprintf() and friends are covered too
   (as these functions have no _unlocked() counterpart)

3. Philosophically, it's a bit more correct, because it's more a
   property of the file handle really whether we ever pass it on to another
   thread, not of the operations we then apply to it.

This patch reworks all pieces of codes that so far used fxyz_unlocked()
calls to use __fsetlocking() instead. It also reworks all places that
use open_memstream(), i.e. use stdio FILE* for string manipulations.

Note that this in some way a revert of 4b61c87511.
2017-12-14 10:42:25 +01:00
Saran Tunyasuvunakool 7715629e9a networkd: Fix race condition in [RoutingPolicyRule] handling (#7615)
The routing policy rule setup logic is moved to the routes setup phase (rather than the addresses setup phase as it is now). Additionally, a call to `link_check_ready` is added to the routing policy rules setup handler. This prevents a race condition with the routes setup handler.

Also give each async handler its own message counter to prevent race conditions when logging successes.

Fixes: #7614
2017-12-12 16:25:36 +01:00
Vito Caputo 508f63b411 *: fix some inconsistent control statement style 2017-12-01 16:49:52 -08:00