Commit Graph

131 Commits

Author SHA1 Message Date
Yu Watanabe 0c816fcc7b network: make link_request_set_nexthop() called from link_request_set_routes() or route_handler()
Then we can drop static_routes_ready() flag.
2020-07-15 17:15:25 +09:00
Yu Watanabe feb596b5c3 network: include error code in the log message 2020-07-15 17:14:30 +09:00
Yu Watanabe 2a877f4560 network: set dhcp6_xxx_configured flag after routes/addresses are assigned 2020-07-15 17:14:30 +09:00
Yu Watanabe a211ff4b84 network: introduce own address handler for dhcp6 delegated prefix
Fixes #16365.
2020-07-07 19:48:26 +02:00
Zbigniew Jędrzejewski-Szmek 77ecc1aaa5
Merge pull request #16380 from yuwata/network-dhcp6-update-prefix-route
Network: update acquired dhcp6 prefix routes
2020-07-07 09:05:08 +02:00
Yu Watanabe 1d596fdec2 network: do not restart radv engine when adding prefix
Replaces d469cea3bd.
2020-07-07 11:20:35 +09:00
Yu Watanabe 8fc2a5dff4 network: fix indentation 2020-07-07 11:18:28 +09:00
Yu Watanabe 290696e512 Revert "network: Don't send RA with zero router lifetime when restarting radv"
This reverts commit d469cea3bd.
2020-07-07 11:06:08 +09:00
Michael Marley d469cea3bd network: Don't send RA with zero router lifetime when restarting radv
While investigating https://github.com/systemd/systemd/issues/16356, I
discovered that networkd stops the radv service before adding or updating
prefixes and then starts it again.  This causes networkd to send an RA with
a router lifetime of zero, causing the routes to flap on systems receiving
the RA for a fraction of a second before radv is started again and proper
RAs are sent.  That has the potential to cause issues with latency-sensitive
traffic like gaming or VoIP.  This patch adds a boolean argument to the
sd_radv_stop() function to control this behavior.  The zero lifetime RA is
still sent whenever radv is actually being stopped, but when it is being
restarted for a prefix update (from networkd-dhcp6.c), the final RA is no
longer sent to avoid the route flapping.
2020-07-07 10:49:25 +09:00
Yu Watanabe f050c94df0 network: always update acquired prefix route
Otherwise, routes become lifetime 0.

Fixes #16356.
2020-07-07 09:20:44 +09:00
Yu Watanabe 1419ff0401 network: decrease indentation level 2020-07-07 09:14:21 +09:00
Yu Watanabe cecd68c70f network: fix indentation 2020-07-07 08:47:38 +09:00
Susant Sahani 838d39af93 network: Allow DHCPv6 client to start solicit mode
Now DHCPv6 client start only DHCPv6 INFORMATION-REQUEST mode.
Let's enable Solicit mode too.
2020-07-02 16:18:48 +09:00
Yu Watanabe 8d9982e30d network: drop unnecessary "&"
This confuses gcc-10 with -O3 -flto.

Closes #16224.
2020-06-22 12:13:24 +09:00
Susant Sahani 120b5c0bbe network: DHCPv6 - Add support to set token on the LAN interface
This patch adds support to set a token on the LAN interface for
the acquired delegated prefixes for the DHCPv6 to generate address.
2020-06-17 14:20:48 +09:00
Yu Watanabe c24dd73952 network: move DHCPv6 related conf parsers to networkd-dhcp6.c 2020-06-02 17:06:00 +09:00
Yu Watanabe f3e4b1e07c
Merge pull request #15884 from ssahani/dhcpv6-vendor
DHCPv6: Introduce vendor specific
2020-06-01 12:25:54 +09:00
Evgeny Vereshchagin ceae629564 README: add a Fossies codespell badge
I keep forgetting where the report is. Hopefully the badge will
make it easier to find it. I also fixed several typos codespell
found along the way.
2020-05-29 15:06:16 +02:00
Susant Sahani b4ccc5de7d network: Inroduce DHCP6- send vendor options
network: Inroduce DHCP6- send vendor options

```
 0                   1                   2                   3
       0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
      |      OPTION_VENDOR_OPTS       |           option-len          |
      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
      |                       enterprise-number                       |
      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
      .                                                               .
      .                       vendor-option-data                      .
      .                                                               .
      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
```

```
  0                   1                   2                   3
       0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
      |          sub-opt-code         |         sub-option-len        |
      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
      .                                                               .
      .                        sub-option-data                        .
      .                                                               .
      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                 Figure 31: Vendor-specific Options Format

      sub-opt-code         The code for the sub-option.  A 2-octet
                           field.

      sub-option-len       An unsigned integer giving the length of the
                           sub-option-data field in this sub-option in
                           octets.  A 2-octet field.

      sub-option-data      The data area for the sub-option.  The
                           length, in octets, is specified by
                           sub-option-len.

```
2020-05-29 13:37:57 +02:00
Susant Sahani 9efa8a3cff network: DHCPv6 Assign delegated prefix to LAN interface
In DHCPv6-PD environment, where WAN interface requests IPv6 via DHCPv6,
receives the address as well as delegated prefixes, with LAN interfaces
serving those delegated prefixes in their router advertisement messages.
The LAN interfaces on the router themselves do not have
the IPv6 addresses assigned by networkd from the prefix it
serves on that interface. Now this patch enables it.
2020-05-29 16:20:37 +09:00
Lennart Poettering bb2294e454
Merge pull request #15669 from andir/systemd-ipv6-pd-subnet-id
networkd: subnet id support for ipv6 prefix delegation
2020-05-27 18:47:26 +02:00
Andreas Rammhold 02e9e34bd9
networkd: Add support for setting a preferred subnet id for IPv6 PD leases
This allows users to configure a subnet id that should be used instead
of automatically (sequentially) assigned subnets. The previous attempt
had the downside that the subnet id would not be the same between
networkd restarts. In some setups it is desirable to have predictable
subnet ids across restarts of services and systems.

The code for the assignment had to be broken up into two pieces. One of
them is the old (sequential) assignment of prefixes and the other is the
new assignment based on configured subnet ids. The new assignment code
has to be executed first and has to be taken into account when (later
on) allocating the "old" subnets from the same pool.

Instead of having one iteration through the links we are now trying to
allocate a prefix for every link on every delegated prefix, unless they
received an assignment in a previous iteration.
2020-05-26 12:41:22 +02:00
Susant Sahani ed0d1b2e99 network: DHCPv6 - Add support to send vendor class information
Frame 1: 177 bytes on wire (1416 bits), 177 bytes captured (1416 bits) on interface veth-peer, id 0
Ethernet II, Src: 1e:04:f8:b8:2f:d4 (1e:04:f8:b8:2f:d4), Dst: IPv6mcast_01:00:02 (33:33:00:01:00:02)
Internet Protocol Version 6, Src: fe80::1c04:f8ff:feb8:2fd4, Dst: ff02::1:2
User Datagram Protocol, Src Port: 546, Dst Port: 547
DHCPv6
    Message type: Solicit (1)
    Transaction ID: 0x5ca46b
    Rapid Commit
    Identity Association for Non-temporary Address
    Fully Qualified Domain Name
    Vendor Class
        Option: Vendor Class (16)
        Length: 23
        Value: 0000ab11000048656c6c6f3a686f773a6172653a796f75
        Enterprise ID: Tom Gundersen (systemd) (43793)
        vendor-class-data: Hello:how:are:you
    Identity Association for Prefix Delegation
    Option Request
    Client Identifier
    Elapsed time
2020-05-20 07:58:03 +02:00
Susant Sahani f37f2a6b8a network: DHCPv6 - Add support to send user class
Frame 115: 171 bytes on wire (1368 bits), 171 bytes captured (1368 bits) on interface veth-peer, id 0
Ethernet II, Src: 1e:04:f8:b8:2f:d4 (1e:04:f8:b8:2f:d4), Dst: IPv6mcast_01:00:02 (33:33:00:01:00:02)
Internet Protocol Version 6, Src: fe80::1c04:f8ff:feb8:2fd4, Dst: ff02::1:2
User Datagram Protocol, Src Port: 546, Dst Port: 547
DHCPv6
    Message type: Solicit (1)
    Transaction ID: 0x673257
    Rapid Commit
        Option: Rapid Commit (14)
        Length: 0
    Identity Association for Non-temporary Address
        Option: Identity Association for Non-temporary Address (3)
        Length: 12
        Value: d0cc94090000000000000000
        IAID: d0cc9409
        T1: 0
        T2: 0
    Fully Qualified Domain Name
        Option: Fully Qualified Domain Name (39)
        Length: 6
        Value: 01045a657573
        0000 0... = Reserved: 0x00
        .... .0.. = N bit: Server should perform DNS updates
        .... ..0. = O bit: Server has not overridden client's S bit preference
        .... ...1 = S bit: Server should perform forward DNS updates
        Client FQDN: Zeus
    User Class
        Option: User Class (15)
        Length: 17
        Value: 000f68656c6c6f30313233343031323334
    Identity Association for Prefix Delegation
        Option: Identity Association for Prefix Delegation (25)
        Length: 12
        Value: d0cc94090000000000000000
        IAID: d0cc9409
        T1: 0
        T2: 0
    Option Request
        Option: Option Request (6)
        Length: 10
        Value: 001700180038001f000e
        Requested Option code: DNS recursive name server (23)
        Requested Option code: Domain Search List (24)
        Requested Option code: NTP Server (56)
        Requested Option code: Simple Network Time Protocol Server (31)
        Requested Option code: Rapid Commit (14)
    Client Identifier
        Option: Client Identifier (1)
        Length: 14
        Value: 00020000ab11d258482fc7eee651
        DUID: 00020000ab11d258482fc7eee651
        DUID Type: assigned by vendor based on Enterprise number (2)
        Enterprise ID: Tom Gundersen (systemd) (43793)
        Identifier: d258482fc7eee651
    Elapsed time
        Option: Elapsed time (8)
        Length: 2
        Value: 0bd0
        Elapsed time: 30240ms
2020-05-19 11:48:30 +02:00
Susant Sahani 35f6a5cb44 network: DHCPv6 - Add support set arbitary request options 2020-05-17 11:18:29 +02:00
Andrew Doran e7d5fe17db DHCP client: make SendOption work for DHCPv6 too. 2020-05-11 16:31:08 +02:00
Susant Sahani 3175a8c21b network: DHCPv6 Add support to send MUD URL 2020-04-01 17:01:12 +02:00
Yu Watanabe 5ecb131d94 network: include NLMSGERR_ATTR_MSG attribute in error message 2019-11-30 16:14:02 +09:00
Susant Sahani 2805536bff network: DHCPv6 client add support for prefix delegation hint
Add support for prefix hint lenth and prefix hint address
```
Frame 43: 177 bytes on wire (1416 bits), 177 bytes captured (1416 bits) on interface 0
Ethernet II, Src: f6:c1:08:4d:45:f1 (f6:c1:08:4d:45:f1), Dst: IPv6mcast_01:00:02 (33:33:00:01:00:02)
Internet Protocol Version 6, Src: fe80::d250:c82:7f6e:28d6, Dst: ff02::1:2
User Datagram Protocol, Src Port: 546, Dst Port: 547
DHCPv6
    Message type: Solicit (1)
    Transaction ID: 0x5c7902
    Rapid Commit
    Identity Association for Non-temporary Address
    Fully Qualified Domain Name
    Identity Association for Prefix Delegation
        Option: Identity Association for Prefix Delegation (25)
        Length: 41
        Value: 1b97b1690000000000000000001a0019ffffffffffffffff…
        IAID: 1b97b169
        T1: 0
        T2: 0
        IA Prefix
            Option: IA Prefix (26)
            Length: 25
            Value: ffffffffffffffff3c000000000000000000000000000000…
            Preferred lifetime: infinity
            Valid lifetime: infinity
            Prefix length: 60
            Prefix address: ::
    Option Request
    Client Identifier
    Elapsed time
```
2019-10-01 23:52:40 +09:00
Yu Watanabe f136875549 network: make route_get() or friends take Route object 2019-09-17 21:53:42 +09:00
Yu Watanabe 5e8712404e network: drop redundant "else" 2019-08-26 15:40:30 +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 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 6787917dfa network: update state file after dhcp6 events
E.g. DNS servers may be received from DHCPv6 server. If the link is
already in configured state, the DNS servers are not written in the
state file.
2019-07-17 23:15:15 +09:00
Yu Watanabe 2eff7cc59c network: drop unnecessary line breaks 2019-07-17 23:13:40 +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 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 6545067aa9 network: re-assign static routes when dynamic address is updated
Follow-up for b5799eeb07.

Closes #7354.
2019-07-11 22:37:00 +09:00
Yu Watanabe 73854ba1a0 network: process address reply message 2019-07-11 22:37:00 +09:00
Yu Watanabe 04ed994937 network: move DHCP6 related code from networkd-manager.c to networkd-dhcp6.c 2019-06-30 04:46:04 +09:00
Yu Watanabe ca5ad760a5 network: move conf parsers and function prototypes 2019-06-30 04:45:56 +09:00
Yu Watanabe 9aa5d8ba84 network: include glibc headers before including kernel headers 2019-05-09 03:21:31 +02:00
Yu Watanabe 57e447078d network: replace inet_ntop() with in_addr_to_string() 2019-05-09 01:44:31 +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 ca7c792b83 network: fix memleak and double free
Fixes the third issue in #12452.
2019-05-07 16:55:19 +02:00
Frantisek Sumsal 4e361acc06 tree-wide: replace explicit NULL checks with their shorter variants
Done by coccinelle/equals-null.cocci
2019-04-28 14:28:49 +02:00
Yu Watanabe 57445b53fb network: add missing error check 2019-02-16 06:34:22 +09:00
Yu Watanabe 966ab36b10 network: use _cleanup_ attribute at one more place 2019-02-15 11:45:44 +09:00
Yu Watanabe bdb9f58086 network: honor VRF table or explicitly specified route table 2019-02-15 11:45:39 +09:00
Fabrice Fontaine aeed8332af networkd-dhcp6.c: fix build without IFA_F_NOPREFIXROUTE
systemd fails to build on kernel without IFA_F_NOPREFIXROUTE
since 9714c02

So put include missing_network.h

Fixes:
 - http://autobuild.buildroot.org/results/970b09e1d49b53dff12a07ca4ad424ef9dd29a69

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
2019-02-03 18:38:47 +01:00