Commit Graph

663 Commits

Author SHA1 Message Date
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