Commit graph

150 commits

Author SHA1 Message Date
Tom Gundersen d9876a527f networkd: add assert
It should not be possible to have a DHCP lease on a link without also having
an associated network. Add assert() to avoid compiler warnings.

Reported by Thomas H. P. Andersen
2014-06-14 15:06:17 +02:00
Thomas Hindoe Paaboel Andersen efdc73dae3 networkd: link - check returned value from set_lease_pool 2014-06-13 23:00:52 +02:00
Tom Gundersen 97578344f3 networkd: link - left-align debug messages
Still add some whitespace betwen ifname and the message to get the
messages aligned (as I find it easier to spot specific messages this way).
2014-06-13 18:34:34 +02:00
Tom Gundersen dd43110f78 networkd: add dhcp server support
When enabled in [Network] it will set up a dhcp server on the interface, listening
on one of its statically configured IPv4 addresses and with a fixed size pool of
leases determined from it.

Example:

[Match]
Name=ve-arch-tree

[Network]
Address=192.168.12.5/24
DHCPServer=yes

[Route]
Gateway=192.168.12.5
Destination=192.168.12.0/24

In this case we will configure ve-arch-tree with the address 192.168.12.5 and
hand out addresses in the range 192.168.12.6 - 192.168.12.38.

In the future, we should (as suggested by Lennart) introduce a syntax to pick the
server address automatically.
2014-06-13 17:07:20 +02:00
Tom Gundersen 512922f8b4 networkd: link - intialize mac address
Otherwise .netwrok matching on MAC address will not work.

Based on patch by Dave Reisner, and bug originally reported by Max Pray.
2014-06-04 21:29:25 +02:00
Tom Gundersen 85b5673b33 networkd: split runtime config dir from state dir
Configuration will be in

root:root /run/systemd/network

and state will be in

systemd-network:systemd-network /run/systemd/netif

This matches what we do for logind's seat/session state.
2014-06-03 18:58:00 +02:00
Tom Gundersen f5602be9da networkd: link - serialize link when addresses change
Thanks to Kay for tracking this down.
2014-05-21 11:32:03 +02:00
Tom Gundersen e375dcde72 networkd/sd-network: extend operational states
Expose states 'degraded' or 'routable' if a link has a site/link-local or a routable address, respectively.
2014-05-19 20:44:21 +02:00
Tom Gundersen bcb7a07e0a networkd/sd-network: expose statically configured NTP servers 2014-05-19 18:42:14 +02:00
Tom Gundersen d408b50681 networkd: fixup static DNS serialization 2014-05-19 18:14:56 +02:00
Tom Gundersen 091a364c80 resolved: add daemon to manage resolv.conf
Also remove the equivalent functionality from networkd.
2014-05-19 18:14:56 +02:00
Tom Gundersen 7374f9d87c networkd: link - serialize DNS information 2014-05-19 18:14:56 +02:00
Tom Gundersen 16cd414ba0 networkd: log - only log about udev initalization on debug level 2014-05-17 20:51:37 +02:00
Tom Gundersen 428fd0a758 networkd: keep list of active addresses 2014-05-17 20:51:37 +02:00
Tom Gundersen 3c4cb0645c networkd: log the initialization status of links 2014-05-16 14:52:02 +02:00
Tom Gundersen 3d3d425547 networkd: rename Address and Route list fields 2014-05-16 14:52:02 +02:00
Tom Gundersen 987efa17dd networkd: logging - align messages 2014-05-15 18:16:31 +02:00
Tom Gundersen 5261692fe5 networkd: log ifindices when links and netdevs are added 2014-05-15 18:16:31 +02:00
Tom Gundersen af4e9e2c56 networkd: rename NetDev variable for consistency with Link 2014-05-15 18:15:21 +02:00
Zbigniew Jędrzejewski-Szmek 5ea846cc51 networkd, build-sys: spelling fix 2014-05-15 15:29:59 +02:00
Lennart Poettering 19befb2d5f sd-bus: introduce sd_bus_slot objects encapsulating callbacks or vtables attached to a bus connection
This makes callback behaviour more like sd-event or sd-resolve, and
creates proper object for unregistering callbacks.

Taking the refernce to the slot is optional. If not taken life time of
the slot will be bound to the underlying bus object (or in the case of
an async call until the reply has been recieved).
2014-05-15 01:15:30 +02:00
Susant Sahani 7951dea209 networkd: introduce ipip tunnel
This patch enables basic ipip tunnel support.
It works with kernel module ipip

example conf:

file: ipip.netdev

[NetDev]
Name=ipip-tun
Kind=ipip
MTUBytes=1480

[Tunnel]
Local=192.168.223.238
Remote=192.169.224.239
TTL=64

file: ipip.network

[Match]
Name=em1

[Network]
Tunnel=ipip-tun

[tomegun:
         - drop unused variable
         - take ref when enslaving]
2014-05-12 17:37:12 +02:00
Tom Gundersen fbbeb65a93 networkd: get preexiting addresses when a link is added 2014-05-11 14:26:10 +02:00
Tom Gundersen 389cc5f743 networkd: link - redo flag change logging
Make the logging less verbose by only printing all the changed flags on one line,
at the same time make it more complete by supporting all flags currently supported
by the kernel.

We still fall back to printing the raw flags in case we get something we do not recognize
This may be useful when running on new kernels.
2014-05-10 20:56:37 +02:00
Tom Gundersen b90b025af1 networkd: link - don't log errors when missing routes/addresses are dropped
We were ignoring the wrong errno.
2014-05-09 14:41:27 +02:00
Tom Gundersen 7619683b46 networkd: link - handle links coming back to life
When enslaving devices, we may receieve DELLINK/NEWLINK for the same ifindex,
let's not be confused by this.
2014-05-09 14:41:27 +02:00
Tom Gundersen d9c67ea112 networkd: reorder bonding and bridging
A link should only ever be part of one, but if we accidentally do both, let's do it
in the right order so the failure is more obvious in the logs.
2014-05-09 14:41:27 +02:00
Tom Gundersen 370e9930c3 networkd: link - introduce LINGER state and link_drop()
We need the LINGER state in case we still have references to the link after it has been dropped.
2014-05-09 14:41:27 +02:00
Tom Gundersen b226d99b04 networkd: link - take refcounts on links
We need to take a refcount on the link whenever we expect a callback. The exceptions
are the ipv4ll/dhcp clients as their lifetimes are guaranteed to be shorter than that
of the link.
2014-05-09 14:41:27 +02:00
Tom Gundersen 14b746f721 networkd: introduce refcounting for Links and NetDevs 2014-05-09 14:41:27 +02:00
Tom Gundersen 68a8723c85 networkd: link - clean up state files
Also keep the path to the lease file around rather than regenarating it all the time.
2014-05-09 14:41:27 +02:00
Tom Gundersen bbf7c04821 sd-network: expose global operational state 2014-05-08 17:21:37 +02:00
Tom Gundersen 75adc2189b networkd: link - operstate is an enum, not a bitmask 2014-05-08 15:27:55 +02:00
Tom Gundersen 99b4cc3e75 networkd: link - always maintain link operstate regardless of admin state 2014-05-07 16:54:02 +02:00
Tom Gundersen deb2e5230b sd-network: expose both admin and operational state directly
Also add a call to check if a link is loopback, as this should commonly be ignored.
2014-05-07 16:54:02 +02:00
Umut Tezduyar Lindskog 8ddbeaa23c networkd: dont configure route if lease doesn't have one 2014-04-30 00:05:28 +02:00
Tom Gundersen 9b86b3930a networkd: link - don't fail a link if RF kill is active 2014-04-28 00:16:46 +02:00
Umut Tezduyar Lindskog d96e629fd7 networkd: do not complain about IFF_RUNNING
Otherwise:
eth0: unknown link flags gained: 0x00040 (ignoring)

[tomegun: hiding these messages is ok, as IFF_RUNNING is redundant
          and can be deduced from operstate and IFF_LOWER_UP]
2014-04-27 23:36:30 +02:00
Tom Gundersen 3a67e927e3 networkd-wait-online: improve interoptability and enable by default
To make sure we don't delay boot on systems where (some) network links are managed by someone else
we don't block if something else has successfully brought up a link.

We will still block until all links we are aware of that are  managed by networkd have been
configured, but if no such links exist, and someone else have configured a link sufficiently
that it has a carrier, it may be that the link is ready so we should no longer block.

Note that in all likelyhood the link is not ready (no addresses/routes configured),
so whatever network managment daemon configured it should provide a similar wait-online
service to block network-online.target until it is ready.

The aim is to block as long as we know networking is not fully configured, but no longer. This
will allow systemd-networkd-wait-online.service to be enabled on any system, even if we don't
know whether networkd is the main/only network manager.

Even in the case networking is fully configured by networkd, the default behavior may not be
sufficient: if two links need to be configured, but the first is fully configured before the
second one appears we will assume the network is up. To work around that, we allow specifying
specific devices to wait for before considering the network up.

This unit is enabled by default, just like systemd-networkd, but will only be pulled in if
anyone pulls in network-online.target.
2014-04-24 00:23:07 +02:00
Thomas Hindoe Paaboel Andersen cc544d5fb4 networkd: link - add missing curly brackets
introduced in 1e9be60bba
2014-04-22 21:45:17 +02:00
Tom Gundersen df9aa406e8 networkd: link - reduce default verbosity a bit 2014-04-22 21:06:00 +02:00
Tom Gundersen 1e9be60bba networkd: link - support IFLA_OPERSTATE
This properly detects the state of the link based on both the link flags and the
operstate.

Moreover, always log state-changes even if we are not yet managing the link.
2014-04-22 21:06:00 +02:00
Tom Gundersen 45ad2c1328 networkd: link - don't react to successfull link up
Avoid having two code-paths racing with eacother to do the same thing. The change
of flags will be detected in the normal way, so only use the link_up_handler
to detect if the 'up' failed and in that case fail the link.
2014-04-22 21:06:00 +02:00
Tom Gundersen 124fa2c601 networkd: link - log when starting clients fail 2014-04-22 21:06:00 +02:00
Tom Gundersen 2139694e82 networkd: link - avoid cycle when failing 2014-04-22 21:06:00 +02:00
Tom Gundersen 111bb8f93a networkd: link - stop clients when failing 2014-04-22 21:06:00 +02:00
Tom Gundersen 57bd6899b3 networkd: link - add explicit unmanaged state 2014-04-20 19:54:35 +02:00
Tom Gundersen 4bb40e8125 networkd: link - set mac addresses when starting clients
MAC addreses are also set when NEWLINK messages are receieved, but only if the clients have
already been initialized.
2014-04-20 19:34:53 +02:00
Tom Gundersen c6a1eb79a5 networkd: link - log changes in some common link flags 2014-04-20 19:20:26 +02:00
Tom Gundersen 75ee87c8c6 networkd: link - use IFF_DORMANT instead of IFF_RUNNING
Should be no functional change, but avoids spurious log
messages when in operstate UNKNOWN and !IFF_LOWER_UP.
2014-04-20 18:02:15 +02:00