Commit graph

70 commits

Author SHA1 Message Date
Tom Gundersen fe8db0c5ee sd-network: add new library
This is similar to sd-login, but exposes the state of networkd rather than logind.

Include it in libsystemd-dhcp and rename it to libsystemd-network.
2014-02-28 01:01:13 +01:00
Tom Gundersen fe6b2d55bc networkd: add basic support for MACVLANs 2014-02-25 21:19:08 +01:00
Tom Gundersen 0c2f9b8469 networkd: handle SIGINT and SIGTERM 2014-02-22 21:24:36 +01:00
Lennart Poettering 151b9b9662 api: in constructor function calls, always put the returned object pointer first (or second)
Previously the returned object of constructor functions where sometimes
returned as last, sometimes as first and sometimes as second parameter.
Let's clean this up a bit. Here are the new rules:

1. The object the new object is derived from is put first, if there is any

2. The object we are creating will be returned in the next arguments

3. This is followed by any additional arguments

Rationale:

For functions that operate on an object we always put that object first.
Constructors should probably not be too different in this regard. Also,
if the additional parameters might want to use varargs which suggests to
put them last.

Note that this new scheme only applies to constructor functions, not to
all other functions. We do give a lot of freedom for those.

Note that this commit only changes the order of the new functions we
added, for old ones we accept the wrong order and leave it like that.
2014-02-20 00:03:10 +01:00
Lennart Poettering 39883f622f make gcc shut up
If -flto is used then gcc will generate a lot more warnings than before,
among them a number of use-without-initialization warnings. Most of them
without are false positives, but let's make them go away, because it
doesn't really matter.
2014-02-19 17:53:50 +01:00
Tom Gundersen 14efd7617b networkd: dhcp - log when lease is lost 2014-02-19 16:46:58 +01:00
Tom Gundersen 216816c6bc networkd: link - only reset transient hostname if it was set by us 2014-02-19 16:46:58 +01:00
Tom Gundersen 11a7f22939 networkd: refactor link_add() :(
Don't set set **ret when returning r < 0, as matching on the errno may easily
give false positives in the future leading to null pointer dereference.

Reported-by: David Herrmann <dh.herrmann@gmail.com>
2014-02-18 22:34:26 +01:00
Tom Gundersen 4fb7242cbb sd-rtnl-message: store reference to the bus in the message
This mimics the sd-bus api, as we may need it in the future.
2014-02-18 11:21:22 +01:00
Umut Tezduyar Lindskog 17256461f5 networkd: act on lease only if there is one
Interface could go down before acquiring a dhcp lease
2014-02-17 23:30:08 +01:00
Lennart Poettering d595c5cc9e rtnl: rename constructors from the form sd_rtnl_xxx_yyy_new() to sd_rtnl_xxx_new_yyy()
So far we followed the rule to always indicate the "flavour" of
constructors after the "_new_" or "_open_" in the function name, so
let's keep things in sync here for rtnl and do the same.
2014-02-13 13:53:25 +01:00
Lennart Poettering cf6a891173 rtnl: drop "sd_" prefix from cleanup macros
The "sd_" prefix is supposed to be used on exported symbols only, and
not in the middle of names. Let's drop it from the cleanup macros hence,
to make things simpler.

The bus cleanup macros don't carry the "sd_" either, so this brings the
APIs a bit nearer.
2014-02-13 03:44:14 +01:00
Tom Gundersen 63ffa72022 networkd: link - correctly skip state ENSLAVING when no vlans configured
This fixes a regression introduced in 672682a6b
2014-02-10 23:01:47 +01:00
Tom Gundersen 672682a6b9 networkd: VLAN - allow multiple vlans to be created on a link
Also limit the range of vlan ids. Other implementations and
documentation use the ranges {0,1}-{4094,4095}, but we use
the one accepted by the kernel: 0-4094.

Reported-by: Oleksii Shevchuk <alxchk@gmail.com>
2014-02-10 19:00:17 +01:00
Tom Gundersen d50cf59b94 networkd: fix setting dns from dhcp 2014-02-10 11:53:20 +01:00
Thomas Hindoe Paaboel Andersen ecd2f2c594 remove unused variables 2014-02-07 23:09:40 +01:00
Tom Gundersen a6cc569e33 sd-dhcp-client: split sd_dhcp_lease from sd_dhcp_client
This allows us users of the library to keep copies of old leases. This is
used by networkd to know what addresses to drop (if any) when the lease
expires.

In the future this may be used by DNAv4 and sd-dhcp-server.
2014-02-07 15:48:35 +01:00
Tom Gundersen 71acb5e7dc networkd: don't fail on DHCP errors 2014-02-01 16:51:35 +01:00
Tom Gundersen c07aeadfea networkd: dhcp - refactor handler 2014-01-31 12:20:34 +01:00
Tom Gundersen 50add2909c networkd: netdev - reduce chance of race when receiving netdev's ifindex
When creating a new link, the kernel will not inform us about the new ifindex
in its ack. We have to listen for newly created devices and deduce the new
ifindex by matching on the ifname.

We used to do this by waiting for a new device from libudev, but that is asking
for trouble, as udev will happily rename the device before handing it to us.
Listen on rtnl instead, the chance of the name being changed before reaching us
is much smaller (if not nil).

Kernel patch in the works to make this unneccessary.
2014-01-30 14:30:39 +01:00
Tom Gundersen 377a218f87 sd-dhcp-client/net-util: make netmask_to_prefixlen generic
This was originally included in the dhcp-client at my request, but it is not
really dhcp-specific and useful outside of it, so let's pull it out.
2014-01-30 14:30:39 +01:00
Tom Gundersen eb0ea358b6 networkd: address - add support for broadcast 2014-01-30 14:30:39 +01:00
Tom Gundersen eb27aeca24 networkd: dhcpv4 - add notion of 'CriticalConnection'
These connections are never torn down, even when the DHCP specifications say that
they should be. This is useful/necessary when the rootfs (or another critical fs)
is mounted over this network connection, and dataloss would result if the connection
is lost.

This option defaults to off, but our initrd generator (TBD) will enable it when
applicable.
2014-01-30 14:30:39 +01:00
Tom Gundersen c9ccc19f9e networkd: improve logging a bit
Fix/add some structured logging messages, and be uniform about when we WARN and ERR.
2014-01-25 11:39:22 +01:00
Tom Gundersen 54abf461d6 networkd: add basic VLAN support 2014-01-25 11:25:17 +01:00
Tom Gundersen 52433f6b65 networkd: add basic bonding support
Refactor bridging support to be generic netdev support and extend it to
cover bonding as well.
2014-01-22 17:56:49 +01:00
Tom Gundersen 5d4795f372 sd-rtnl: link - allow setting the change mask 2014-01-22 17:56:49 +01:00
Tom Gundersen e6674986de networkd: use 'up'/'down' rather than 'on'/'off' 2014-01-19 15:43:33 +01:00
Tom Gundersen b25ef18b33 sd-dhcp-client: refactor client_{free,new}
Make them more simiar to sd_bus and friends. Also factor out the event attachment. In the future,
we will likely want to support external main-loops, so this is a first step. For the time being,
we are still requiring an sd_event to be attached though.
2014-01-18 19:32:45 +01:00
Tom Gundersen bcbca8291f networkd: don't hard depend on system bus
We may not have a dbus daemon in the initrd (until we can rely on kdbus). In
this case, simply ignore any attempts at using the bus. There is only one user
for now, but surely more to come.

In order to work reliably in the real root without kdbus, but at the same time
don't delay boot when kdbus is in use, order ourselves after dbus.service.
2014-01-18 01:56:41 +01:00
Tom Gundersen 7ae4ef6d23 sd-dhcp-client: refactor DNS support
Rather than keeping an array of pointers to addresses, just keep an array of addresses.
2014-01-16 20:32:08 +01:00
Tom Gundersen 1346b1f038 sd-dhcp-client/networkd: add transient hostname support 2014-01-16 20:32:08 +01:00
Tom Gundersen 6fc7349894 networkd: dhcp - only set the MTU option once
Only set MTU request when creating the dhcp client, not every time it is restarted.
2014-01-16 20:32:08 +01:00
Tom Gundersen 396945dc1f networkd: link - only save original MTU when necessary 2014-01-16 20:32:08 +01:00
Tom Gundersen 1f6d9bc9ee networkd: improve logging 2014-01-16 20:32:08 +01:00
Tom Gundersen 4f882b2a50 sd-dhcp-client/networkd: add interface MTU support 2014-01-16 01:44:19 +01:00
Tom Gundersen 5be4d38e31 networkd: DHCPv4 - allow opting out of using DNS servers
Setting UseDNS=no will ignore any received DNS servers.
2014-01-13 21:54:57 +01:00
Tom Gundersen 3bef724f7e networkd: generate resolv.conf
This adds support to generate a basic resolv.conf in /run/systemd/network.
This file will not take any effect unless a symlink is created from
/etc/resolv.conf.

Nameservers received over DHCP takes precedence over statically configured ones.

Note: /etc/resolv.conf is severely limited, so in the future we will likely
rather provide a much more powerfull nss plugin (or something to that effect),
but this should allow current users to function without any loss of
functionality.
2014-01-12 15:37:21 +01:00
Tom Gundersen ab47d620b4 networkd: improve logging a bit 2014-01-12 15:37:21 +01:00
Zbigniew Jędrzejewski-Szmek 39032b8777 network: use GNU-ism to simplify macros
Thanks David!
2014-01-11 10:07:22 -05:00
Zbigniew Jędrzejewski-Szmek 628706137e networkd: print the received DHCPv4 address and gateway
It seems that networkd stores in_addr.s_addr contents in reverse
order (little-endian, not network order). This is a bit confusing,
but sd_rtnl evidently likes this order.
2014-01-08 22:15:27 -05:00
Zbigniew Jędrzejewski-Szmek 3333d748fa networkd: use structured logging for links and bridges 2014-01-08 22:15:27 -05:00
Tom Gundersen aa3437a573 networkd: print the ifindex of added links
This debug information may be useful when comapring to dropped rtnetlink messages.
2014-01-03 18:20:11 +01:00
Tom Gundersen 2672953bde networkd: improve logging
This gives a bit better messages when a link is added twice.
2014-01-03 16:56:09 +01:00
Tom Gundersen efbc88b8ed networkd: improve link state change logging 2014-01-03 16:20:10 +01:00
Tom Gundersen ff25413852 networkd: link - explicitly set the link to be up if the call to IFF_UP succeeds
No need to wait for the NEWLINK message to arrive.
2014-01-03 02:18:55 +01:00
Tom Gundersen b1b532f58c networkd: dhcp - avoid null pointer dereference 2014-01-03 01:42:26 +01:00
Tom Gundersen 1746cf2ad7 networkd: add more asserts and ignore all events when link has failed 2014-01-03 01:42:26 +01:00
Tom Gundersen 06a6e59301 networkd: only track state of links we are managing
If a network is not (yet) set for a link, we do not care about its state (as we
anyway don't know what to do with it).
2014-01-02 15:56:10 +01:00
Tom Gundersen 449f755492 networkd: improve logging
Remove redundant messages, add some debugging ones and make wording more uniform.
2014-01-02 15:49:23 +01:00