Commit Graph

170 Commits

Author SHA1 Message Date
Tom Gundersen 1a941ac4b6 networkd: link - ignore missing MAC address
Currently DHCP/IPv4LL only works on ethernet devices, but no reason not to otherwise
manage them.
2014-07-01 12:55:05 +02:00
Tom Gundersen 28aeb07f55 networkd: link - drop assert from _free()
_free() should always succeed, even if object is not fully allocated.
2014-07-01 10:30:37 +02:00
Tom Gundersen 5da8149fd3 networkd: link - improve refcounting
We failed to take a ref when waiting for udev synchronization. Fix that and also
make unreffing in callbacks simpler throughout by using _cleanup_ macros.

Fixes <https://bugs.freedesktop.org/show_bug.cgi?id=80556>.
2014-07-01 10:21:18 +02:00
Tom Gundersen 3e53303ea6 networkd: dhcp - use same metric for all DHCP-related routes 2014-06-30 13:06:33 +02:00
Tom Gundersen 46ba9fbae2 networkd: dhcp - update the lifetime of an existing address
The logic otherwise is that we leave anything preconfigured alone, but in the case of DHCP
we actually need to update it whenever the lease is renewed.
2014-06-29 17:01:23 +02:00
Tom Gundersen b16665806a networkd: improve DHCP error logging 2014-06-29 16:34:43 +02:00
Tom Gundersen fb6730c498 networkd: set static addresses immediately
Don't wait for IPv4LL nor DHCP to finish before setting statically configured addresses.
2014-06-29 15:18:21 +02:00
Eugene Yakubovich e1ea665eda Add support for DHCP static route options
This adds support for DHCP options 33 and 121: Static Route and
Classless Static Route. To enable this feature, set UseRoutes=true
in .network file. Returned routes are added to the routing table.
2014-06-29 15:18:21 +02:00
Tom Gundersen ed942a9eb2 networkd: merge DHCPv4 and DHCPv6 config
If there are v4 or v6 specific options we can keep those in separate sections,
but for the common options, we will use only one.

Moreovere only use DHCP=[yes/both|no/none|v4|v6] to enable or disable the clients.
2014-06-29 15:18:21 +02:00
Patrik Flykt 68ceb9df6a sd-dhcp-client/networkd: set lifetimes for IPv4 addresses
Note that /proc/sys/net/ipv4/ip_dynaddr needs to be non-zero.

[tomegun: hook up DHCP renew events to increase the lifetime when necessary]
2014-06-29 15:18:21 +02:00
Tom Gundersen 7c16313f11 networkd/sd-dhcp-server: only start dhcp server when necessary 2014-06-29 15:18:21 +02:00
Patrik Flykt 1873a3d344 networkd: Properly stop router solicitation and DHCPv6 client
When a link fails or looses carrier, always stop ongoing router
solicitation and any DHCPv6 client that may be running.
2014-06-26 16:09:50 +03:00
Tom Gundersen 6b66097b95 networkd: link - fix memleak of icmp6 struct 2014-06-20 13:04:02 +02:00
Steven Noonan ae94176262 networkd: fix refcounting with UseMTU=yes
The link was unintentionally being unreferenced instead of referenced for the
MTU setup.
2014-06-19 20:40:20 +02:00
Patrik Flykt 4138fb2c79 networkd: Add initial DHCPv6 support
Enable DHCPv6 support by creating a DHCPv6 boolean in the Network
section. Add necessary DHCPv6 structures and initial function calls.
2014-06-19 15:44:44 +03:00
Lennart Poettering 4f43493897 networkd: configure dhcp server range only after successfully setting an IP address on the interface
This way we can make use of the addresses of the IP pool.
2014-06-18 18:28:29 +02:00
Lennart Poettering 11bf3cced1 networkd: add address pool support
When an address is configured to be all zeroes, networkd will now
automatically find a locally unused network of the right size from a
list of pre-configured pools. Currently those pools are 10.0.0.0/8,
172.16.0.0/12, 192.168.0.0/16 and fc00::/7, i.e. the network ranges for
private networks. They are compiled in, but should be configurable
eventually.

This allows applying the same configuration to a large number of
interfaces with each time a different IP range block, and management of
these IP ranges is fully automatic.

When allocating an address range from the pool it is made sure the range
is not used otherwise.
2014-06-18 18:28:29 +02:00
Tom Gundersen bf0308cbd5 networkd: link - fix carrier check on new link
We were comparing against our own internal enum rather than the kernel exposed one.

Found by Thomas Ritter.
2014-06-17 09:17:07 +02:00
Susant Sahani 326cb4061a networkd: introduce vxlan
This patch enables netwokd to create vxlan

Changes:
Added:
	1. File networkd networkd-vxlan.c
	2. to netdev
	    bool learning
	    struct in_addr group
	    uint64_t vxlanid;
	3. VXLAN subsection and config
	   parameters
2014-06-16 20:38:22 +02:00
Tom Gundersen 4f561e8e43 networkd: link - flush all pending NEWLINK events before trying to match
We could still have an old interface name and/or mac address when libudev
tells us that the device is initialized, as the up-to-date info could still
be on its way from the kernel.
2014-06-14 19:01:46 +02:00
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