Commit Graph

790 Commits

Author SHA1 Message Date
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
Mathieu Trudel-Lapierre c1a3890410 Add a "RequiredForOnline=" Link attribute for .network files (#7347)
RequiredForOnline= denotes a link/network that does/does not require being up
for systemd-networkd-wait-online to consider the system online; this makes it
possible to ignore devices without modifying parameters to wait-online.
2017-11-30 18:03:50 +01:00
Susant Sahani fbdb6605b5 networkd: Add comment for setting_mtu #7460 (#7489)
Follow up #7460
2017-11-28 17:24:52 +01:00
Susant Sahani 97e7fb39a8 networkd: DHCP client do not get into a loop while setting MTU (#7460)
Some devices get reset itself while setting the MTU. we get in to a LOOP .
Once the MTU changed then the DHCP client talking with DHCP server never stops.
networkd gets into a loop and generates endless DHCP requests.

fixes #6593
fixes #7380
2017-11-26 15:21:45 +01:00
Michael Vogt 64b21ece8c networkd: auto promote links if "promote_secondaries" is unset (#7167)
The DHCP code in systemd-networkd relies on the
`net.ipv4.conf.{default,all,<if>}.promote_secondaries` sysctl to be set
(the kernels default is that it is unset). If this sysctl is not set
DHCP will work most of the time, however when the IP address changes
between leases then the system will loose its IP.

Because some distributions decided to not ship these defaults (Debian
is an example and via downstream Ubuntu) networkd by default will now
enable this sysctl opton automatically.
2017-11-24 21:03:05 +01:00
Susant Sahani 8ad93cacf0 networkd: cleanup do not call link_enter_set_routes after label is set. (#6935)
Remove link_enter_set_routes after label is set.
2017-11-21 11:54:14 +01:00
Susant Sahani 762e2659b9 networkd: support incoming/outgoing device for rule matching (#7223)
Closes #7210
2017-11-21 11:51:50 +01:00
Lennart Poettering 4ff971ac08
Merge pull request #6918 from ssahani/issue-5625
networkd: ndisc - do not stop ndisc client incase of conf error.
2017-11-20 19:20:23 +01:00
Susant Sahani a63e5daaa3 networkd: Do not send requests to create netdevs if they exists. (#6973)
If the netdev already exists we should not send requests to
kernel to create them.

fixes #5448
2017-11-20 18:58:06 +01:00
Susant Sahani 8a9b3a23fd networkd: Set RoutingPolicyRule in link_configure (#7235)
The RoutingPolicyRules are not added when we are calling from set_address
the link->message++ and link->message-- never reaches to zero in the callback function
resulting routes are never gets added.

Closes #7200
2017-11-20 17:50:48 +01:00
Lennart Poettering 0b252fc0be
Merge pull request #7379 from yuwata/follow-up-7309
networkd: small fixes
2017-11-19 19:47:24 +01: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
Yu Watanabe 7b872092d9 networkd: fix indentation 2017-11-18 01:24:41 +09:00
Lennart Poettering aa2b10daec networkd: improve interface rename log message a bit (#7299)
Let's clarify that it's not networkd that renames interfaces, but
something else (for example, udev's link builtin based on .link files)

This doesn't change any logic, it just rewords the message a bit, to
clarify that we only log this for informational purposes, not because we
execute the rename operation ourselves.

Fixes: #7143
2017-11-12 16:26:58 +01:00
Zbigniew Jędrzejewski-Szmek ecc3f340ab networkd: fix two format string mismatches
../src/network/networkd-link.c:3577:84: warning: format specifies type 'unsigned char' but the argument has type 'uint32_t' (aka 'unsigned int') [-Wformat]
                                route->dst_prefixlen, route->tos, route->priority, route->table, route->lifetime);
                                                                                   ^~~~~~~~~~~~
../src/network/networkd-manager.c:1146:132: warning: format specifies type 'unsigned char' but the argument has type 'uint32_t' (aka 'unsigned int') [-Wformat]
                        rule->from_prefixlen, space ? " " : "", to_str, rule->to_prefixlen, rule->tos, rule->fwmark, rule->fwmask, rule->table);
                                                                                                                                   ^~~~~~~~~~~

Also add some line breaks to make it easier to see which argument is for which
part of the format string.
2017-11-01 23:10:21 +01:00
Susant Sahani 28464ae0e2 networkd: don't stop the dhcp server if it's not configured. (#7083)
we call sd_dhcp_server_stop even if it's not configured when link is
down resulting unwanted logs.
```
Oct 10 13:41:07 nena systemd-networkd[126]: eth0: Lost carrier
Oct 10 13:41:07 nena systemd-networkd[126]: DHCP CLIENT (0x560f2dc5): STOPPED
Oct 10 13:41:07 nena systemd-networkd[126]: eth0: DHCP lease lost
Oct 10 13:41:07 nena systemd-networkd[126]: NDISC: Stopping IPv6 Router Solicitation client
Oct 10 13:41:07 nena systemd-networkd[126]: Assertion 'server' failed at ../src/libsystemd-network/sd-dhcp-server.c:256, function sd_dhcp_server_stop(). Ignoring.
```

fixes #7047
2017-10-18 12:38:56 +02:00
Susant Sahani 702c979fef networkd: Consider linkLocalAddressing state while configuring ndisc. (#7012)
If linkLocalAddressing is disabled in for the interface still then
we look for ndisc configured or not in link_check_ready.

Link local is used automatic address configuration and neighbor discovery protocol.
If link local is disabled we should not configure ndisc.

Fixes #2713, #6441, #5841.
2017-10-18 11:12:59 +02:00
Susant Sahani 5971cb9de9 networkd: Bridge slave don't look for RA/dhcp(IPv4/IPv6)
Incase of bridge slaves we have disabled RA, DHCP(IPv4/IPv6). just skip the check in link_check_ready
for IPv6.
2017-09-28 00:45:15 +05:30
Susant Sahani bce67bbee3 networkd: add support to configure IP Rule (#5725)
Routing Policy rule manipulates rules in the routing policy database control the
route selection algorithm.

This work supports to configure Rule
```
[RoutingPolicyRule]
TypeOfService=0x08
Table=7
From= 192.168.100.18

```

```
ip rule show
0:	from all lookup local
0:	from 192.168.100.18 tos 0x08 lookup 7
```

V2 changes:

1. Added logic to handle duplicate rules.
2. If rules are changed or deleted and networkd restarted
   then those are deleted when networkd restarts next time

V3:

1. Add parse_fwmark_fwmask
2017-09-14 21:51:39 +02:00
juga0 db3d235820 networkd: set PRL default options depending on Anonymize.
Add also Client variable to know when Anonymize is true.
2017-09-06 19:03:25 +02:00
Susant Sahani dad2d78e1a networkd: Allow configure a specific link even if it has no carrier. (#6740)
This work allows to configure a specific link even if it has no carrier.

Closes #6645.
2017-09-06 16:57:04 +02:00
Jon Ringle e4f05508ad networkd: Honor configured DHCP ClientIdentifier on link_update (#6622)
We have an embedded board with a couple of ethernet ports. From the kernel
log, I can see that the ethernet drivers are obtaining their correct MAC
address, but for some reason, at first systemd-networkd doesn't see the
mac address for the ethernet port at the time that it looks at
dhcp_client_identifier configuration (it has 00:00:00:00:00:00 for mac).

Later on, systemd-networkd gets a link_update() call, and at this time, it
has the correct mac address for the ethernet port. However, in link_update()
the dhcp_client_identifier configuration is not being considered, and a call
to sd_dhcp_client_set_iaid_duid() is being done always
2017-08-30 11:38:00 +02:00
Lennart Poettering 4b61c87511 tree-wide: fput[cs]() → fput[cs]_unlocked() wherever that makes sense (#6396)
As a follow-up for db3f45e2d2 let's do the
same for all other cases where we create a FILE* with local scope and
know that no other threads hence can have access to it.

For most cases this shouldn't change much really, but this should speed
dbus introspection and calender time formatting up a bit.
2017-07-21 10:35:45 +02:00
Richard Maw 45a9eac9a0 networkd: Allow DHCP servers to be re-configured on carrier gain
In normal operation this would trigger an assertion
when a DHCP server is configured every time the link goes up.

This change makes sd_dhcp_server_configure_pool idempotent
and stops the DHCP server when the link loses carrier.

In addition to this stopping the assertion being triggered,
this has the useful side-effect of allowing the link to be taken down
and then brought back up as a way to have it use DNS from an "upstream"
interface that got its DNS configuration via DHCP
after the downstream link was configured.
2017-06-12 16:54:42 +01:00
Richard Maw c1835a427f networkd: Wait for link to get carrier before setting addresses
For containers the link is effectively always up,
but for virtual and physical machines networkd may have started
before the link has gained carrier.

Networkd will configure addresses when carrier is gained,
but should also configure addresses if the link is already up.
Without this patch the addresses are set unconditionally.

Normally this isn't a problem since addresses are either fixed,
set over DHCP, or is never without carrier.
But for machines that gain carrier and are configured to select
an address from the unallocated local address pool
this causes them to pick an address from the pool twice.

This change to skip address configuration when a link is added
before it has a carrier fixes having multiple addresses assigned
if the machine starts networkd before it has gained carrier
and is configured with an address from the pool.
2017-06-12 16:39:24 +01:00
Richard Maw 410a7f15f0 networkd: Clean up pool addresses on link down
When the link comes up it assigns addresses
by checking whether the address is 0.0.0.0,
and if so pulling a new address range out of the pool.

If the addresses aren't removed from the pool when the link goes down
then the set of addresses allocated will grow
until all the local address ranges are exhausted,
while it gets a different IP address every time.

This patch frees the addresses when link config is dropped
to fix the address leak,
and on systems which can expect all interfaces to be brought up or down
in a deterministic order this conveniently makes use the same address each time.
2017-06-12 16:20:49 +01:00
sjoerd-ccu 764febc23e networkd-link: Receive LLDP on Bridge slaves not master (#5995)
LLDP should be received on bridge slaves as they're the entities
directly connected to a peer. Receiving LLDP on the bridge device makes
little sense, Linux by default even filters out LLDP going onto the
bridge device.

Flip the current logic, receive LLDP on bridge slaves don't listen for
them on the bridge itself.
2017-05-23 09:10:59 +02:00
Patrik Flykt 7465dd22ad networkd-link.c: Add Router Advertisement starting and stopping
Start and stop Router Advertisement sending once the link has acquired
a link-local IPv6 address.
2017-05-15 14:49:50 +03:00
Daniel Wang b85bc551c3 network: Implement DHCP Option 119 (Domain Search List) (#5932)
This adds a modified version of dhcp6_option_parse_domainname() that is
able to parse compressed domain names, borrowing the idea from
dns_packet_read_name(). It also adds pieces in networkd-link and
networkd-manager to properly save/load the added option field.

Resolves #2710.
2017-05-13 10:19:32 -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 95b74ef6ea networkd: add support for address label
IPv6 address labels are used for address selection; they are described in RFC 3484.
Precedence is managed by userspace, and only the label itself is stored in the kernel.

enp0s25.network

[Match]
Name=enp0s25

[Network]
DHCP=yes
Address = 2001:db8:f00:baa::b

[AddressLabel]
Label=199
Prefix=2001:db8:41::/64

[AddressLabel]
Label=11
Prefix=2001:db8:31::/64

[AddressLabel]
Label=123
Prefix=2001:db8:21::/64

[AddressLabel]
Label=124
Prefix=2001:db8:11::/64
[sus@maximus label]$ ip addrlabel list

prefix ::1/128 label 0
prefix ::/96 label 3
prefix ::ffff:0.0.0.0/96 label 4
prefix 2001:db8:41::/64 dev enp0s25 label 199
prefix 2001:db8:31::/64 dev enp0s25 label 11
prefix 2001:db8:21::/64 dev enp0s25 label 123
prefix 2001:db8:11::/64 dev enp0s25 label 124
prefix 2001::/32 label 6
prefix 2001:10::/28 label 7
prefix 3ffe::/16 label 12
prefix 2002::/16 label 2
prefix fec0::/10 label 11
prefix fc00::/7 label 5
prefix ::/0 label 1
2017-04-26 16:00:44 +05:30
Dimitri John Ledkov b56be2966a networkd: Add bridge port priority setting (#5545)
Allow setting bridge port priority in the Bridge section of the network file,
similar to e.g. port path cost setting.

Set the default to an invalid value of 128, and only set the port priority when
it's not 128. Unlike e.g. path cost, zero is a valid priority value.

Add a networkd-test.py to check that bridge port priority is correctly set.

Incidently, fix bridge port cost type and document valid ranges.
2017-04-11 23:17:31 +02:00
Florian Klink a0e5c15d4f networkd: add IPv6ProxyNDPAddress support (#5174)
IPv6 Neighbor discovery proxy is the IPv6 equivalent to proxy ARP for IPv4.
It is required when ISPs do not unconditional route IPv6 subnets
to their designated target, but expect neighbor solicitation messages
for every address on a link.

A variable IPv6ProxyNDPAddress= is introduced to the [Network] section,
each representing a IPv6 neighbour proxy entry in the neighbour table.
2017-02-11 00:47:55 +01:00
Susant Sahani eb64b435eb networkd: bond support primary slave and active slave (#4873)
active_slave:

Specifies the new active slave for modes that support it
(active-backup, balance-alb and balance-tlb).

primary slave:
systemd-networks currently lacks the capability to set the primary slave
in an
active-backup bonding. This is necessary if you prefer one interface
over the
other. A common example is a eth0-wlan0 bonding on a laptop where you'd
want to
switch to the wired connection whenever it's available.

Fixes: #2837
2016-12-21 19:10:36 +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 b106c5867b networkd: do not print ": Success" in debug message
%m isn't useful in success path.
2016-12-09 13:55:14 -05:00
Susant Sahani e3a7b04848 networkd: link_enter_configured remove assert (#4800)
When we are in link_enter_configured we assume that the
link->state should be LINK_STATE_SETTING_ROUTES but in some
situation it's LINK_STATlE_SETTING_ADDRESSES.

Just ignore the wrong state.

Also since the return value not used any where
make link_enter_configured return type void.

Fixes: #4746
2016-12-05 09:31:48 -05:00
David Michael a09dc5467a networkd: support marking links unmanaged 2016-12-01 14:41:51 -08:00
Martin Pitt 59eb33e0fe networkd: move setting hostname and timezone to Manager
Hostname and time zone are global settings, not link specific.  Move these
methods from Link into Manager.
2016-11-23 16:32:06 +01:00
Lennart Poettering 49ad68298a networkd: do not automatically propagate bogus DNS/NTP servers
Never propagate DNS/NTP servers on the local link via the DHCP server. The
DNS/NTP servers 0.0.0.0 and 127.0.0.1 only make sense in the local context,
hence never propagate them automatically to other hosts.

Fixes: #4524
2016-11-21 22:58:26 +01:00
Lennart Poettering a380b2d4c6 networkd: rename link_push_dns_to_dhcp_server() → link_push_uplink_dns_to_dhcp_server()
Let's clarify that this is only relevant for pushing uplink DNS config data,
not in any other context.

(Same for NTP)
2016-11-21 22:58:26 +01:00
Lennart Poettering 5512a96316 networkd: store DNS servers configured per-network as parsed addresses
DNS servers must be specified as IP addresses, hence let's store them as that
internally, so that they are guaranteed to be fully normalized always, and
invalid data cannot be stored.
2016-11-21 22:58:26 +01:00
Tom Gundersen 23f53b99b1 networkd: clean up main header file a bit
Rename networkd.h to networkd-manager.h, to more accurately describe what it
contains.
2016-11-14 01:05:06 +01:00
Tom Gundersen 7d342c0332 networkd: network - apply() does not need to take the manager object 2016-11-13 01:02:46 +01:00
Lennart Poettering c69305ff4f networkd: flush DNSSL/RDNSS lists when we lose carrier
Fixes: #3870
2016-11-02 11:39:49 -06:00
Susant Sahani 197e280932 networkd: fix coding style (#4294) 2016-10-06 11:45:07 +02:00
Tobias Jungel f6bb7ac5c6 networkd: use BridgeFDB as well on bridge ports (#4253)
[BridgeFDB] did not apply to bridge ports so far. This patch adds the proper
handling. In case of a bridge interface the correct flag NTF_MASTER is now set
in the netlink call. FDB MAC addresses are now applied in
link_enter_set_addresses to make sure the link is setup.
2016-10-05 17:06:40 +02:00
Martin Pitt f258e94843 networkd: do not drop config for pending interfaces (#4187)
While an interface is still being processed by udev, it is in state "pending",
instead of "unmanaged". We must not flush device configuration then.

Further fixes commit 3104883ddc after commit c436d55397.

Fixes #4186
2016-09-24 10:07:45 -04:00
Susant Sahani 92c918b06d networkd: add support to configure virtual CAN device (#4139)
1. add support for kind vcan
2. fixup indention netlink-types.c, networkd-netdev.c
2016-09-14 18:15:16 +02:00
Mantas Mikulėnas c436d55397
networkd: do not drop config for unmanaged interfaces
Flushing foreign configuration for unmanaged interfaces is outright
evil, especially when it's a regular occurence with Wi-Fi.

Fixes: 3104883ddc "networkd: remove route if carrier is lost"
Ref: #3831
2016-08-25 13:25:08 +03:00
Zbigniew Jędrzejewski-Szmek b68d26b8cd networkd: fix typo (#4013) 2016-08-21 19:15:26 +02:00
Zbigniew Jędrzejewski-Szmek 1ed1f50f82 networkd: do not set NOARP unconditionally (#3891)
Fixes #3890.
2016-08-05 10:37:10 +02:00
Tobias Jungel ffff9abe1d networkd: apply bridge vlan configuration correct
bridge vlan configuration was applied even if it wasn't configured.

fixes #3876
2016-08-04 17:14:18 +02:00
Susant Sahani 99d2baa2ca networkd: add support to configure NOARP/ARP for interface (#3854)
https://lists.freedesktop.org/archives/systemd-devel/2016-August/037268.html
2016-08-04 10:00:58 -04:00
Susant Sahani 3104883ddc networkd: remove route if carrier is lost (#3831)
Fixes #3669.
2016-08-04 09:56:39 -04:00
Zbigniew Jędrzejewski-Szmek 2d37cd5356 Add enable_disable() helper
In this patch "enabled" and "disabled" is used exclusively, but "enable" and
"disable" forms are need for the following patch.
2016-07-31 22:48:22 -04:00
Michael Biebl 595bfe7df2 Various fixes for typos found by lintian (#3705) 2016-07-12 12:52:11 +02:00
Torstein Husebø 61233823aa treewide: fix typos and remove accidental repetition of words 2016-07-11 16:18:43 +02:00
Andreas Rammhold 6cb955c6a1 networkd: vrf: add support for enslaving devices to VRFs 2016-06-16 00:25:06 +02:00
Susant Sahani 357bb46af6 networkd: fix NULL pointer (#3523)
Not every link has kind associated with it.

(gdb) r
Starting program: /home/sus/tt/systemd/systemd-networkd
Missing separate debuginfos, use: dnf debuginfo-install
glibc-2.23.1-7.fc24.x86_64
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
vboxnet0: Gained IPv6LL
wlp3s0: Gained IPv6LL
enp0s25: Gained IPv6LL
Enumeration completed

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff6e27ade in __strcmp_sse2_unaligned () from /lib64/libc.so.6
(gdb) bt
src/network/networkd-link.c:2008
src/network/networkd-link.c:2059
src/network/networkd-link.c:2442
m=0x555555704a30, userdata=0x55555570bfe0) at src/network/networkd-link.c:2497
at src/libsystemd/sd-netlink/sd-netlink.c:347
src/libsystemd/sd-netlink/sd-netlink.c:402
src/libsystemd/sd-netlink/sd-netlink.c:432
userdata=0x5555556f7470) at src/libsystemd/sd-netlink/sd-netlink.c:739
src/libsystemd/sd-event/sd-event.c:2275
src/libsystemd/sd-event/sd-event.c:2626
timeout=18446744073709551615) at src/libsystemd/sd-event/sd-event.c:2685
bus=0x5555556f9af0, name=0x555555692315 "org.freedesktop.network1",
timeout=30000000,
    check_idle=0x55555556ac84 <manager_check_idle>, userdata=0x5555556f6b20) at
src/shared/bus-util.c:134
src/network/networkd-manager.c:1128
src/network/networkd.c:127
(gdb) f 1
src/network/networkd-link.c:2008
2008            if (link->network->bridge || streq("bridge", link->kind)) {
(gdb) p link->kind
$1 = 0x0
2016-06-13 15:57:38 +02:00
Tobias Jungel ceac40781b networkd: cleanup of bridge vlan code (#3505)
cleanup minor nitpicks mentioned in #3428
2016-06-12 19:59:21 +02:00
Tobias Jungel 13b498f967 networkd: add support to configure VLAN on bridge ports 2016-06-10 09:10:41 +02:00
Tobias Jungel 6cad256dbe networkd-link: parse linkinfo to get kind 2016-06-09 21:42:05 +02:00
Tom Gundersen d9c11f2b01 Merge pull request #3431 from poettering/network-fixes
put limits on addresses and routers per link and per network
2016-06-08 23:10:16 +02:00
Lennart Poettering 1e7a0e21c9 network: beef up ipv6 RA support considerably
This reworks sd-ndisc and networkd substantially to support IPv6 RA much more
comprehensively. Since the API is extended quite a bit networkd has been ported
over too, and the patch is not as straight-forward as one could wish. The
rework includes:

- Support for DNSSL, RDNSS and RA routing options in sd-ndisc and networkd. Two
  new configuration options have been added to networkd to make this
  configurable.

- sd-ndisc now exposes an sd_ndisc_router object that encapsulates a full RA
  message, and has direct, friendly acessor functions for the singleton RA
  properties, as well as an iterative interface to iterate through known and
  unsupported options. The router object may either be retrieved from the wire,
  or generated from raw data. In many ways the sd-ndisc API now matches the
  sd-lldp API, except that no implicit database of seen data is kept. (Note
  that sd-ndisc actually had a half-written, but unused implementaiton of such
  a store, which is removed now.)

- sd-ndisc will now collect the reception timestamps of RA, which is useful to
  make sd_ndisc_router fully descriptive of what it covers.

Fixes: #1079
2016-06-06 20:11:38 +02:00
Lennart Poettering fc6a313b5b lldp: add proper ref counting to sd_lldp object and a separate call for setting the ifindex
Let's make sd-lldp a bit more like sd-ndisc ant the other APIs, and add proper
ref counting and a separate call for setting the ifindex.

This also adds a new lldp_reset() call we can use at various places to close
all fds. This is also similar to how sd-ndisc already does it.
2016-06-06 19:59:07 +02:00
tomty89 3fb1ac5d57 networkd-link: fix handler typo for route_remove() (#3433)
Obviously we've been using the wrong handler here. Fixes #3352.
2016-06-04 12:31:07 +02:00
Lennart Poettering a60a720c7e networkd: drop weird "const" usage in function parameters
We generally only use "const" to constify the destination of pointers, but not
the pointers themselves, as they are copied anyway during C function
invocation. Hence, drop this usage of "const".
2016-06-03 19:20:46 +02:00
Tom Yan 720bec40e9 networkd-dhcp6: generalize DHCPv6 client (re)starting
dhcp6_request_address() was merely a function to switch the DHCPv6 client from "stateless" mode to "stateful" mode. It was also a one-way switch. Also, to (re)start the client, we would need to repeat separate function calls.

In this patch, dhcp6_request_address() is made a general starter/manager of the DHCPv6 client. It now takes an extra parameter so we will be specifying which mode the DHCPv6 client should be started in. Also it will keep track of the current mode and compare with the newly requested mode, and only restart the client in case there is a difference between them.

This also makes sure that the DHCPv6 client will be (re)started accordingly as per the Router Advertisement flags.
2016-06-01 14:54:46 +08:00
Lennart Poettering 8d76eea87b Merge pull request #3378 from keszybz/unit-write-drop-in-newline-removal
Remove newlines from drop in format strings + some formatting fixes
2016-05-29 18:42:40 +02:00
Zbigniew Jędrzejewski-Szmek 0053598f36 Typo fix: s/advertisment/advertisement/ 2016-05-28 11:50:37 -04:00
Tom Yan 2b00a4e03d networkd: disable IPv6 for bridge slave
If an interface is managed as a bridge slave, we don't want any IP configuration for it. Therefore, disable IPv6 in such case.
2016-05-28 13:35:01 +08:00
Tom Yan 2b2d8603ce networkd: unset master if not enslaved with networkd
When we manage an interface with networkd but not as a slave (i.e. no `Bridge=` or `Bond=` set in its .network), we do not want it to remain slaved.
2016-05-28 13:31:41 +08:00
Tom Yan 4cef7fe3d1 networkd: Disable IPv6 when DHCPv6 is only enabled
DHCPv6 requires an IPv6 link-local address to work. The client will not be started (even when enabled explicitly with `DHCP=`) if none is configured (either by autoconfiguration or manually). Therefore, disable IPv6 in such case.
2016-05-25 20:40:48 +08:00
Tom Yan fbc38f230b networkd: set IFLA_INET6_ADDR_GEN_MODE as per stable_secret
Although networkd has option (LinkLocalAddressing=) to toggle IPv6LL autoconfiguration, when it is enabled, the address is autoconfigured by the kernel, but not networkd.

Therefore, we do not statically set IFLA_INET6_ADDR_GEN_MODE to IN6_ADDR_GEN_MODE_EUI64, but dynamically depending on whether stable_secret is set, just as what the kernel does by default.

Note that this does NOT affect the global addresses configured by networkd.
2016-05-25 20:04:01 +08:00
Susant Sahani 7209086d8a networkd: do not update state or IPv6LL address if link is failed or lingering
This is partial fix for #2228 and #2977, #3204.

bridge-test: netdev ready
docker0: Gained IPv6LL
wlan0: Gained IPv6LL
eth0: Gained IPv6LL
Enumeration completed
bridge-test: netdev exists, using existing without changing its
parameters
vboxnet0: IPv6 enabled for interface: Success
lo: Configured
docker0: Could not drop address: No such process
vboxnet0: Gained carrier
wlan0: Could not drop address: No such process
eth0: Could not drop address: No such process
eth0: Could not drop address: No such process
eth0: Could not drop address: No such process
vboxnet0: Gained IPv6LL
vboxnet0: Could not set NDisc route or address: Invalid argument
vboxnet0: Failed
[New Thread 0x7ffff6505700 (LWP 1111)]
[Thread 0x7ffff6505700 (LWP 1111) exited]
Assertion 'link->state == LINK_STATE_SETTING_ROUTES' failed at
src/network/networkd-link.c:672, function link_enter_configured().
Aborting.

Program received signal SIGABRT, Aborted.
0x00007ffff6dc6a98 in raise () from /lib64/libc.so.6
Missing separate debuginfos, use: dnf debuginfo-install
iptables-1.4.21-15.fc23.x86_64 libattr-2.4.47-14.fc23.x86_64
libidn-1.32-1.fc23.x86_64 pcre-8.38-7.fc23.x86_64

Debugging

(gdb) bt
"link->state == LINK_STATE_SETTING_ROUTES", file=0x5555556a34c8
"src/network/networkd-link.c", line=672,
    func=0x5555556a56d0 <__PRETTY_FUNCTION__.14850>
"link_enter_configured") at src/basic/log.c:788
src/network/networkd-link.c:672
src/network/networkd-link.c:720
flags=0 '\000', scope=0 '\000', cinfo=0x7fffffffe020) at
src/network/networkd-address.c:344
(rtnl=0x5555556eded0, message=0x55555570ff20, userdata=0x5555556ec590)
at src/network/networkd-manager.c:604
m=0x55555570ff20) at src/libsystemd/sd-netlink/sd-netlink.c:365
at src/libsystemd/sd-netlink/sd-netlink.c:395
ret=0x0) at src/libsystemd/sd-netlink/sd-netlink.c:429
revents=1, userdata=0x5555556eded0) at
src/libsystemd/sd-netlink/sd-netlink.c:723
src/libsystemd/sd-event/sd-event.c:2268
src/libsystemd/sd-event/sd-event.c:2629
timeout=18446744073709551615) at src/libsystemd/sd-event/sd-event.c:2688
bus=0x5555556eeba0, name=0x55555568a2f5 "org.freedesktop.network1",
timeout=30000000,
    check_idle=0x55555556adb6 <manager_check_idle>,
userdata=0x5555556ec590) at src/shared/bus-util.c:134
src/network/networkd-manager.c:1130
src/network/networkd.c:127

(gdb) f 3
src/network/networkd-link.c:672
672         assert(link->state == LINK_STATE_SETTING_ROUTES);
(gdb) p link->state
$1 = LINK_STATE_FAILED

We should not be in this state .

even if vboxnet0 failed we went into this state.

vboxnet0: Could not set NDisc route or address: Invalid argument
vboxnet0: Failed
2016-05-17 22:59:56 -04:00
Clemens Gruber 77ff6022fa networkd: Add EmitRouter= option for DHCP Server (#3251)
Add an option to disable appending DHCP option 3 (Router) to the DHCP
OFFER and ACK packets.
This commit adds the boolean option EmitRouter= for the [DHCPServer]
section in .network files.

Rationale: On embedded devices, it is very useful to have a DHCP server
running on an USB OTG ethernet gadget interface to avoid manual setup on
the client PCs, but it should only serve IP addresses, no route(r)s.
Otherwise, Windows clients experience network connectivity issues, due
to them using the address set in DHCP option 3 as default gateway.

Signed-off-by: Clemens Gruber <clemens.gruber@pqgruber.com>
2016-05-17 19:34:25 -04:00
Zbigniew Jędrzejewski-Szmek 483d099e16 tree-wide: drop spurious "&"s when passing functions around
Also adjust indentation in various places.
2016-05-15 19:56:59 -04:00
Lennart Poettering 7272b25e16 networkd: reworkd LLDP emission to allow control of propagation level
This allows selecting the propagation level of emitted LLDP packets
(specifically: the destination MAC address of the packets). This is useful
because it allows generating LLDP packets that optionally cross certain types
of bridges.

See 802.11ab-2009, Table 7-1 for details.
2016-05-09 15:45:31 +02:00
Zbigniew Jędrzejewski-Szmek 8341a5c381 networkd: rework duid_{type,duid_type,duid,duid_len} setting
Separate fields are replaced  with a struct.

Second second duid type field is removed. The first field was used to carry
the result of DUIDType= configuration, and the second was either a copy of
this, or contained the type extracted from DuidRawData. The semantics are changed
so that the type specified in DUIDType is always used. DUIDRawData= no longer
overrides the type setting.

The networkd code is now more constrained than the sd-dhcp code:
DUIDRawData cannot have 0 length, length 0 is treated the same as unsetting.
Likewise, it is not possible to set a DUIDType=0. If it ever becomes necessary
to set type=0 or a zero-length duid, the code can be changed to support that.
Nevertheless, I think that's unlikely.

This addresses #3127 § 1 and 3.

v2:
- rename DUID.duid, DUID.duid_len to DUID.raw_data, DUID.raw_data_len
2016-05-03 12:23:01 -04:00
Zbigniew Jędrzejewski-Szmek 634f0f983c networkd: rework headers to avoid circular includes
Header files were organized in a way where the includer would add various
typedefs used by the includee before including it, resulting in a tangled
web of dependencies between files.

Replace this with the following logic:

          networkd.h
         /          \
networkd-link.h      \
networkd-ipv4ll.h--\__\
networkd-fdb.h         \
networkd-network.h    netword-netdev-*.h
networkd-route.h           \
                      networkd-netdev.h

If a pointer to a structure defined in a different header file is needed,
use a typedef line instead of including the whole header.
2016-04-29 19:01:28 -04:00
Lennart Poettering e0a24179c0 Merge pull request #3137 from keszybz/dirent-simplification
Various small cleanups in shared code
2016-04-29 10:40:15 +02:00
Susant Sahani 6fc2549711 networkd: reconfigure IPv6 and static address after link up event (#3105)
Now we are not setting static address, start dhcp6 client and
discovering IPv6 routers after link gained carrier.

This fixes #2912.
2016-04-28 19:03:29 -04:00
Zbigniew Jędrzejewski-Szmek b1e02ee7cf networkd: drop unnecessary stmt 2016-04-27 09:05:42 -04:00
Lennart Poettering fa7099927c networkd: consider various IPv6 features as disabled if IPv6 is not available in the kernel 2016-04-22 16:06:20 +02:00
Susant Sahani 0c241a378d networkd: When link gets dirty mark manager dirty too (#3080)
If we not marking manager dirty when link is dirty then
the state file is not updated. This is a side effect of
issue 2850
setting CriticalConnection=yes

timesyncd NTP servers given by DHCP server are ignored.
2016-04-21 16:08:07 +02:00
Susant Sahani 439689c6ec networkd: bump MTU to 1280 for interfaces which have IPv6 enabled (#3077)
IPv6 protocol requires a minimum MTU of 1280 bytes on the interface.
This fixes #3046.

Introduce helper link_ipv6_enabled() to figure out whether IPV6 is enabled.
Introduce network_has_static_ipv6_addresses() to find out if any static
ipv6 address configured.
If IPv6 is not configured on any interface that is SLAAC, DHCPv6 and static
IPv6 addresses not configured, then IPv6 will be automatically disabled for that
interface, that is we write "1" to /proc/sys/net/ipv6/conf//disable_ipv6.
2016-04-20 20:34:13 -04:00
Susant Sahani 23d8b221c0 networkd: Add support to configure proxy arp support to interfaces (#3020)
Fixes: #2889
2016-04-14 11:56:57 +02:00
Zbigniew Jędrzejewski-Szmek 1db30aeab1 Merge pull request #2915 from vinaykul/master 2016-03-31 00:52:23 -04:00
Vinay Kulkarni 413708d106 DHCP DUID, IAID configuration options 2016-03-30 16:33:55 -07:00
Beniamino Galvani 6afa676780 lldp: move public macros to sd-lldp.h and namespace them
lldp.h contains definitions of LLDP types, subtypes and capabilities which
should be exposed in public headers. Get rid of the file and move those
definitions to sd-lldp.h with the SD_ prefix.
2016-03-24 16:41:48 +01:00
Zbigniew Jędrzejewski-Szmek afec45395f Revert "DHCP DUID and IAID configurability" 2016-03-21 18:24:24 -04:00
Vinay Kulkarni c83321e6d4 DHCP DUID and IAID configurability 2016-03-09 21:58:44 -08:00
Vito Caputo 9ed794a32d tree-wide: minor formatting inconsistency cleanups 2016-02-23 14:20:34 -08:00
Vito Caputo 313cefa1d9 tree-wide: make ++/-- usage consistent WRT spacing
Throughout the tree there's spurious use of spaces separating ++ and --
operators from their respective operands.  Make ++ and -- operator
consistent with the majority of existing uses; discard the spaces.
2016-02-22 20:32:04 -08:00
Lennart Poettering 90dffb2241 sd-lldp: beef up callback logic
Instead of just notifying about the fact that something changed in the
database, actually inform the callback what precisely changed. This is useful,
so that the LLDP tx logic can be put into "fast" mode as soon as a previously
unknown peer appears, as suggested by the LLDP spec.
2016-02-21 20:58:59 +01:00
Lennart Poettering 8e1ad1eaf7 networkd: add basic LLDP transmission support
Let's add some minimalistic LLDP sender support. The idea is that this is
either on or off, and all fields determined automatically rather than
configured explicitly.
2016-02-21 20:58:59 +01:00
Lennart Poettering b553a6b13c sd-lldp: filter out LLDP messages coming from our own MAC address
Let's not get confused should we be connected to some bridge that mirrors back
our packets.
2016-02-21 20:40:58 +01:00
Lennart Poettering b9d74c40c6 networkd: make a couple of functions static
These functions are nowadays used only within networkd-link.c, hence ther's no
point in littering our public namespace with them.
2016-02-21 20:40:57 +01:00
Lennart Poettering 273eec24f5 networkd: rework when LLDP reception is enabled
Being on the link-layer LLDP is nothing we should turn on only when there's a
link beat. Instead, turn it on, whenever the iface is UP regardless if there's
a link beat or not. This closes the race between a link beat being available
and us subscribing to LLDP as a result.
2016-02-21 20:40:57 +01:00
Lennart Poettering b295beea88 networkd: rework how carrier bindings are serialized
Instead of serializing the interface name, expose the interface index, since
that's the only stable identifier.
2016-02-21 20:40:57 +01:00
Lennart Poettering 34437b4f9c sd-lldp: rework sd-lldp API
This reworks the sd-lldp substantially, simplifying things on one hand, and
extending the logic a bit on the other.

Specifically:

- Besides the sd_lldp object only one other object is maintained now,
  sd_lldp_neighbor. It's used both as storage for literal LLDP packets, and for
  maintainging info about peers in the database. Separation between packet, TLV
  and chassis data is not maintained anymore. This should be a major
  simplification.

- The sd-lldp API has been extended so that a couple of per-neighbor fields may
  be queried directly, without iterating through the object. Other fields that
  may appear multiple times, OTOH have to be iterated through.

- The maximum number of entries in the neighbor database is now configurable
  during runtime.

- The generation of callbacks from sd_lldp objects is more restricted:
  callbacks are only invoked when actual data changed.

- The TTL information is now hooked with a timer event, so that removals from
  the neighbor database due to TTLs now result in a callback event.

- Querying LLDP neighbor database will now return a strictly ordered array, to
  guarantee stability.

- A "capabilities" mask may now be configured, that selects what type of LLDP
  neighbor data is collected. This may be used to restrict collection of LLDP
  info about routers instead of all neighbors. This is now exposed via
  networkd's LLDP= setting.

- sd-lldp's API to serialize the collected data to text files has been removed.
  Instead, there's now an API to extract the raw binary data from LLDP neighbor
  objects, as well as one to convert this raw binary data back to an LLDP
  neighbor object. networkd will save this raw binary data to /run now, and the
  client side can simply parse the information.

- support for parsing the more exotic TLVs has been removed, since we are not
  using that. Instead there are now APIs to extract the raw data from TLVs.
  Given how easy it is to parse the TLVs clients should do so now directly
  instead of relying on our APIs for that.

- A lot of the APIs that parse out LLDP strings have been simplified so that
  they actually return strings, instead of char arrays with a length. To deal
  with possibly dangerous characters the strings are escaped if needed.

- APIs to extract and format the chassis and port IDs as strings has been
  added.

- lldp.h has been simplified a lot. The enums are anonymous now, since they
  were never used as enums, but simply as constants. Most definitions we don't
  actually use ourselves have eben removed.
2016-02-21 20:40:56 +01:00
Lennart Poettering 36c7d7097b networkd: fix logging of error codes 2016-02-20 22:42:29 +01:00
Lennart Poettering b710e6b68d networkd: enable LLDP only on ethernet 2016-02-20 22:42:29 +01:00
Lennart Poettering 032b27f534 sd-lldp: drop "port" object
Let's just keep the few parts we actually need of it in the main sd_lldp
object, so that we can simplify things quite a bit.

While we are at it, remove ifname and mac fields which we make no use of
whatsoever.
2016-02-20 22:42:29 +01:00
Daniel Mack b26fa1a2fb tree-wide: remove Emacs lines from all files
This should be handled fine now by .dir-locals.el, so need to carry that
stuff in every file.
2016-02-10 13:41:57 +01:00
Lennart Poettering d390f8ef2d util: introduce fputs_with_space() and make use of it at various places
The call combines outputing a string with prefixing it with a space, optionally. This is useful to shorten the logic
for outputing lists of strings, that are space separated.
2016-01-26 14:42:04 +01:00
Lennart Poettering b2a81c0b52 networkd: optinally use DHCP lease domain info for routing only
This changes the UseDomains= setting of .network files to take an optional third value "route", in addition to the
boolean values. If set, the passed domain information is used for routing rules only, but not for the search path
logic.
2016-01-26 14:42:04 +01:00
Lennart Poettering 27cb34f574 networkd: rename a few Network object properties to be more like the configuration settings
All booleans called dhcp_xyz are now called ".dhcp_use_xyz", to match their respective configuration file settings. This
should clarify things a bit, in particular as there is a DHCP hostname that was previously called just ".hostname"
because ".dhcp_hostname" was already existing as a bool. Since this confusion is removed now because the bool is called
".dhcp_use_hostname", the string field is now renamed to ".dhcp_hostname".
2016-01-26 14:42:04 +01:00
Lennart Poettering 3df9bec57c networkd: rework Domains= setting
Previously, .network files only knew a vaguely defined "Domains=" concept, for which the documentation declared it was
the "DNS domain" for the network connection, without specifying what that means.

With this the Domains setting is reworked, so that there are now "routing" domains and "search" domains. The former are
to be used by resolved to route DNS request to specific network interfaces, the latter is to be used for searching
single-label hostnames with (in addition to being used for routing). Both settings are configured in the "Domains="
setting. Normal domain names listed in it are now considered search domains (for compatibility with existing setups),
while those prefixed with "~" are considered routing domains only. To route all lookups to a specific interface the
routing domain "." may be used, referring to the root domain. An alternative syntax for this is the "*", as was already
implemented before using the "wildcard" domain concept.

This commit adds proper parsers for this new logic, and exposes this via the sd-network API. This information is not
used by resolved yet, this will be added in a later commit.
2016-01-26 14:42:03 +01:00
Tom Gundersen 4ddbb47472 Merge pull request #2267 from gdamjan/dont-drop-critical
networkd: link - do not drop config for critical interfaces
2016-01-20 17:33:59 +01:00
Daniel Mack 201f0c916d tree-wide: unify argument lists of IN_SET()
The new implementation will not allow passing the same values more than
once, so clean up first.
2016-01-10 18:10:08 +01:00
Lennart Poettering 8a516214c4 resolved: introduce support for per-interface negative trust anchors 2016-01-06 18:36:32 +01:00
Lennart Poettering ad6c047561 resolved,networkd: add a per-interface DNSSEC setting
This adds a DNSSEC= setting to .network files, and makes resolved honour
them.
2016-01-05 20:10:31 +01:00
Lennart Poettering aaa297d4e5 networkd,resolved: add a per-interface mdns configuration option 2016-01-05 17:41:41 +01:00
Damjan Georgievski 02e2862194 networkd: link - do not drop config for critical interfaces
the idea is that interfaces marked as critical are typically used
for NFS root. networkd shouldn't drop that config.

discussion at #780
2016-01-05 01:00:16 +01:00
Lennart Poettering 4afd3348c7 tree-wide: expose "p"-suffix unref calls in public APIs to make gcc cleanup easy
GLIB has recently started to officially support the gcc cleanup
attribute in its public API, hence let's do the same for our APIs.

With this patch we'll define an xyz_unrefp() call for each public
xyz_unref() call, to make it easy to use inside a
__attribute__((cleanup())) expression. Then, all code is ported over to
make use of this.

The new calls are also documented in the man pages, with examples how to
use them (well, I only added docs where the _unref() call itself already
had docs, and the examples, only cover sd_bus_unrefp() and
sd_event_unrefp()).

This also renames sd_lldp_free() to sd_lldp_unref(), since that's how we
tend to call our destructors these days.

Note that this defines no public macro that wraps gcc's attribute and
makes it easier to use. While I think it's our duty in the library to
make our stuff easy to use, I figure it's not our duty to make gcc's own
features easy to use on its own. Most likely, client code which wants to
make use of this should define its own:

       #define _cleanup_(function) __attribute__((cleanup(function)))

Or similar, to make the gcc feature easier to use.

Making this logic public has the benefit that we can remove three header
files whose only purpose was to define these functions internally.

See #2008.
2015-11-27 19:19:36 +01:00
Christian Hesse e5d44b34cc networkd: link - do not drop config for loopback device
Commit 5e5b137a (networkd: link - drop foreign config when configuring
link) introduced a regression where addresses (including 127.0.0.1) are
removed from loopback device.
Do not handle loopback device when removing foreign configs.

Signed-off-by: Christian Hesse <mail@eworm.de>
2015-11-25 20:02:53 +01:00
Thomas Hindoe Paaboel Andersen 74544b4ead networkd: link - fix reading routes
This regressed during the port to extract_first_word in c598ac76
(v228).

CID #1338083
2015-11-22 18:53:36 +01:00
Tom Gundersen fe30727643 Revert "networkd: ndisc - revert to letting the kernel handle NDisc"
This reverts commit 23f186494c.

The bug has now been fixed, so we can go back to managing this ourselves.
2015-11-19 01:25:40 +01:00
Thomas Hindoe Paaboel Andersen 928bc597b7 network: fix indentation 2015-11-18 19:08:44 +01:00
Tom Gundersen 23f186494c networkd: ndisc - revert to letting the kernel handle NDisc
There is still a bug in the userspace version, so temporarily revert this.

This is a work-around for issue #1866.
2015-11-18 14:26:36 +01:00
Tom Gundersen c601ebf79f sd-dhcp6-client: bind to link-local address
This ensures that several DHCPv6 clients can run on separate interfaces
simultaneously.
2015-11-17 14:17:41 +01:00
Tom Gundersen 62379e884e networkd: ndisc - always configure dhcp6 client
The ndisc client may trigger the dhcpv6 client to be started (this is the common case),
so we should allocate the dhcpv6 client whenever we allocate the ndisc one.
2015-11-17 13:26:46 +01:00
Tom Gundersen 63348d13fa networkd: ndisc/dhcpv6 - handle starting running clients
The clients may be triggered to be started repeatedly without being stopped first,
simply swallow the error rather than failing the link.
2015-11-16 19:14:22 +01:00
Tom Gundersen a56a2048f9 networkd: check explicit state rather than link->network
When deserializing we can now have an attached network without the various clients yet
having been configured. Hence, don't misused the link->network as a check to determine
if a link is ready to be used, but check the state explicitly.
2015-11-13 15:05:58 +01:00
Lennart Poettering 765afd5c4d networkd: stop managing per-interface IP forwarding settings
As it turns out the kernel does not support per-interface IPv6 packet
forwarding controls (unlike as it does for IPv4), but only supports a
global option (#1597). Also, the current per-interface management of the
setting isn't really useful, as you want it to propagate to at least one
more interface than the one you configure it on. This created much grief
(#1411, #1808).

Hence, let's roll this logic back and simplify this again, so that we
can expose the same behaviour on IPv4 and IPv6 and things start to work
automatically again for most folks: if a network with this setting set
is set up we propagate the setting into the global setting, but this is
strictly one-way: we never reset it again, and we do nothing for network
interfaces where this setting is not enabled.

Fixes: #1808, #1597.
2015-11-13 13:02:50 +01:00
Lennart Poettering d68e2e59b3 networkd: rearrange checks when to write something into sysctl a bit
Move check whether ipv6 is available into link_ipv6_privacy_extensions()
to keep it as internal and early as possible.

Always check if there's a network attached to a link before we apply
sysctls. We do this for most of the sysctl functions already, with this
change we do it for all.
2015-11-13 13:02:50 +01:00
Lennart Poettering 66a6bd6897 networkd: fix a couple of format string types
We really should use %i for ints, and %u for unsigneds, and be careful
what we pick depending on the type we want to print.
2015-11-13 13:02:49 +01:00
Lennart Poettering eb3da9012f util-lib: optionally, when writing a string to a file, verify string on failure
With this change, the idiom:

    r = write_string_file(p, buf, 0);
    if (r < 0) {
           if (verify_one_line_file(p, buf) > 0)
                   r = 0;
    }

gets reduced to:

    r = write_string_file(p, buf, WRITE_STRING_FILE_VERIFY_ON_FAILURE);

i.e. when writing the string fails and the new flag
WRITE_STRING_FILE_VERIFY_ON_FAILURE is specified we'll not return a
failure immediately, but check the contents of the file. If it matches
what we wanted to write we suppress the error and exit cleanly.
2015-11-13 13:02:49 +01:00
Tom Gundersen 5e5b137acc networkd: link - drop foreign config when configuring link
This is a change in behavior:

Before we would never remove any state, only add to it, we now drop unwanted
state from any link the moment we start managing it.

Note however, that we still will not remove any foreign state added at runtime,
to avoid any feedback loops. However, we make no guarantees about coexisting
with third-party tools that change the state of the links we manage.
2015-11-11 16:16:47 +01:00
Tom Gundersen 4058d339f5 networkd: improve logging 2015-11-11 15:42:38 +01:00
Tom Gundersen e7ab854c6c networkd: link - track state of IPv6LL address
This is managed by the kernel, but we should track whether or not we have
a configured IPv6LL address. This fixes two issues:
 - we now wait for IPv6LL before considering the link ready
 - we now wait for IPv6LL before attempting to do NDisc or DHCPv6
   these protocols relies on an LL address being available.
2015-11-11 15:42:38 +01:00
Tom Gundersen 3b015d40c1 networkd: ndisc - handle router advertisement in userspace
Router Discovery is a core part of IPv6, which by default is handled by the kernel.
However, the kernel implementation is meant as a fall-back, and to fully support
the protocol a userspace implementation is desired.

The protocol essentially listens for Router Advertisement packets from routers
on the local link and use these to configure the client automatically. The four
main pieces of information are: what kind (if any) of DHCPv6 configuration should
be performed; a default gateway; the prefixes that should be considered to be on
the local link; and the prefixes with which we can preform SLAAC in order to pick
a global IPv6 address.

A lot of additional information is also available, which we do not yet fully
support, but which will eventually allow us to avoid the need for DHCPv6 in the
common case.

Short-term, the reason for wanting this is in userspace was the desire to fully
track all the addresses on links we manage, and that is not possible for addresses
managed by the kernel (as the kernel does not expose to us the fact that it
manages these addresses). Moreover, we would like to support stable privacy
addresses, which will soon be mandated and the legacy MAC-based global addresses
deprecated, to do this well we need to handle the generation in userspace. Lastly,
more long-term we wish to support more RA options than what the kernel exposes.
2015-11-11 15:42:38 +01:00
Tom Gundersen f5a8c43f39 networkd: IPv6 router discovery - follow IPv6AcceptRouterAdvertisemnt=
The previous behavior:
When DHCPv6 was enabled, router discover was performed first, and then DHCPv6 was
enabled only if the relevant flags were passed in the Router Advertisement message.
Moreover, router discovery was performed even if AcceptRouterAdvertisements=false,
moreover, even if router advertisements were accepted (by the kernel) the flags
indicating that DHCPv6 should be performed were ignored.

New behavior:
If RouterAdvertisements are accepted, and either no routers are found, or an
advertisement is received indicating DHCPv6 should be performed, the DHCPv6
client is started. Moreover, the DHCP option now truly enables the DHCPv6
client regardless of router discovery (though it will probably not be
very useful to get a lease withotu any routes, this seems the more consistent
approach).

The recommended default setting should be to set DHCP=ipv4 and to leave
IPv6AcceptRouterAdvertisements unset.
2015-11-11 15:42:38 +01:00
Susant Sahani b69c318040 networkd: Add support to configure IPV6 hop limit
This patch adds support to configure IPV6 hop limit.

For example:
/proc/sys/net/ipv6/conf/wlp3s0/hop_limit
2015-11-10 09:26:38 +05:30
Daniel Mack 4084052911 Merge pull request #1726 from teg/networkd-2
networkd: (de)serialize more state and support expiring routes
2015-11-03 15:03:50 +01:00
Tom Gundersen c598ac7626 networkd: link - port to extract_first_word() 2015-10-30 12:32:49 +01:00
Tom Gundersen f833694d4f networkd: route - add expiration support
This should really live in the kernel, but the netlink API currently
does not support it. Until support has been added, expire the route
from userspace.
2015-10-30 12:32:49 +01:00
Tom Gundersen f703cc2c57 networkd: link - deserialize routes 2015-10-30 12:32:49 +01:00
Tom Gundersen 0bc70f1d9c networkd: link - (de)serialize IPv4LL and DHCPv4 addresses
This initializes the clients to try rebinding the preexisting
addresses before doing anything else.
2015-10-30 12:32:49 +01:00
Tom Gundersen c4a03a5669 networkd: link - deserialize
For now only deserialize some basic state and the applied addresses.

When a link is added, try to deserialize it's state from /run. This
is relevant only when networkd is restarted at runtime.
2015-10-30 12:32:49 +01:00
Tom Gundersen c1eb9872f6 networkd: link - serialize routes 2015-10-30 12:32:49 +01:00
Tom Gundersen 2ce4095690 networkd: route - rename fields in struct 2015-10-30 12:32:48 +01:00
Hristo Venev 4701725cd5 network: fix use-after-free in link_free
Freeing a link removes it both from addresses and addresses_foreign,
causing SIGSEGV if one of the sets is freed.
2015-10-29 12:18:02 +02:00
Lennart Poettering b5efdb8af4 util-lib: split out allocation calls into alloc-util.[ch] 2015-10-27 13:45:53 +01:00
Lennart Poettering 15a5e95075 util-lib: split out printf() helpers to stdio-util.h 2015-10-27 13:25:57 +01:00