Commit graph

192 commits

Author SHA1 Message Date
Tom Gundersen ae06ab1014 networkd: store ifindex as int 2014-07-28 11:46:57 +02:00
Tom Gundersen 2d2349cc3e sd-dhcp-client: drop event DHCP_EVENT_NO_LEASE
Keep this internal to the client and simply restart it when NAK is receieved, as
per the RFC.
2014-07-28 10:44:51 +02:00
Tom Gundersen 3c072310d5 networkd: ipv4ll - drop unnecessary get_address() 2014-07-25 02:12:00 +02:00
Tom Gundersen b0e39c8284 networkd: merge DNS and NTP entries when exporting
In the state files, do not distinguish where the various entries came from
(static or DHCP), but include them all in the same list.
2014-07-23 23:54:51 +02:00
Dan Williams 28cc555d85 networkd: set route protocol
All routes added by networkd are currently set RTPROT_BOOT, which according
to the kernel means "Route installed during boot" (rtnetlink.h).  But this
is not always the case as networkd changes routing after boot too.  Since
the kernel gives more detailed protocols, use them.

With this patch, user-configured static routes now use RTPROT_STATIC (which
they are) and DHCP routes use RTPROT_DHCP.  There is no define for IPv4LL
yet, so those are installed as RTPROT_STATIC (though perhaps RTPROT_RA is
better?).

[tomegun: fixup
src/network/networkd-link.c:972:33: error: too few arguments to function 'route_new_dynamic']
2014-07-23 09:19:32 +02:00
Tom Gundersen aa9f114058 networkd: netdev - split NetDev struct into per-kind structs
Similarly to how unit types work.
2014-07-21 13:32:27 +02:00
Lennart Poettering ca4e095ab9 sd-rtnl: make string returned by sd_rtnl_message_read_string() const 2014-07-18 12:38:32 +02:00
Tom Gundersen 6dcaa6f59a sd-network: fixup api
Do not expose link_is_loopback, people should just get this from rtnl directly.
Do not expose NTP servers as IP addresses, these must be strings.
Expose ifindex as int, not unsigned. This is what the kernel (mostly) and glibc uses.
2014-07-17 22:53:35 +02:00
Lennart Poettering a2ba62c719 sd-network: remove redundant array size parameter from functions that return arrays
As long as the number of array entries is relatively small it's nicer to
simply return the number of entries directly, instead of using a size_t*
return parameter for it.
2014-07-17 01:42:26 +02:00
Tom Gundersen f5de5b0020 sd-dhcp-client: make request broadcasts opt-in
It appears there is no good way to decide whether or not broadcasts should be enabled,
there is hardware that must have broadcast, and there are networks that only allow
unicast. So we give up and make this configurable.

By default, unicast is used, but if the kernel were to inform us abotu certain
interfaces requiring broadcast, we could change this to opt-in by default in
those cases.
2014-07-15 18:55:31 +02:00
Tom Gundersen 679b3605f0 networkd: link - fix memory leak
Make link_initialized() idempotent to avoid taking refs on several udev_device
objects.
2014-07-14 16:50:01 +02:00
Tom Gundersen 3be1d7e0c5 networkd: netdev - introduce vtable for netdev kinds
Split each netdev kind into its own .h/.c.
2014-07-14 16:49:41 +02:00
Tom Gundersen 3f26503776 networkd: netdev - rename 'enslave' to 'join'
Enslave only really makes sense when referring to bridges and bonds, so try to be
a bit more neutral.
2014-07-14 16:47:04 +02:00
Susant Sahani edb85f0d8d networkd: dhcp add vendor class indentifier option 60
Vendor Class Identifier be used by DHCP clients to identify
their vendor type and configuration. When using this option,
vendors can define their own specific identifier values, such
as to convey a particular hardware or operating system
configuration or other identifying information.

Vendor-specified DHCP options—features that let administrators assign
separate options to clients with similar configuration requirements.
For example, if DHCP-aware clients for example we want to separate
different gateway and option for different set of people
(dev/test/hr/finance) in a org or devices for example web/database
servers or let's say in a embedded device etc and require a different
default gateway or DNS server than the rest of clients.
2014-07-14 11:39:20 +02:00
Tom Gundersen 5bdd314cd9 networkd: return 1 from successful event handlers 2014-07-14 11:04:13 +02:00
Lennart Poettering 4faefc7ff8 networkd: always prefer dhcp routes over ipv4ll routes 2014-07-10 21:32:44 +02:00
Tom Gundersen 4958aee497 networkd: properly track addresses when first added
When doing a NEWADDR, the reply we get back is the NEWADDR itself, rather
than just an empty ack (unlike how NEWLINK works). For this reason, the
process that did the NEWADDR does not get the broadcast message.

We were only listening for broadcast messages, and hence not tracking the
addresses we added ourselves. This went unnoticed as the kernel will usually
send NEWADDR messages from time to time anyway, so things would mostly work,
but in the worst case we would not notice that a routable address was available
and consider ourselves offline.
2014-07-03 22:55:05 +02:00
Tom Gundersen 393c0c5e64 networkd: link - improve link tracking logging 2014-07-03 22:55:05 +02:00
Tom Gundersen 563c69c6b2 networkd: netdev - take ref immediately after calling out
Keeping the refcounting next to the sd_bus_call_async() makes it easier to check.
2014-07-03 11:00:01 +02:00
Lennart Poettering fecc80c1ba util: generalize is_localhost() and use it everywhere where applicable 2014-07-02 13:41:31 +02:00
Eugene Yakubovich 4cc7a82c94 networkd: send hostname to dhcp server
Send hostname (option 12) in DISCOVER and REQUEST messages so the
DHCP server could use it to register with dynamic DNS and such.

To opt-out of this behaviour set SendHostname to false in [DHCP]
section of .network file

[tomegun: rebased, made sure a failing set_hostname is a noop and moved
          config from DHCPv4 to DHCP]
2014-07-01 22:02:25 +02:00
Tom Gundersen 856f962c7a networkd: link - don't fail if master netdev already exists
This allows restarts to work gracefully.
2014-07-01 13:30:23 +02:00
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