Commit graph

232 commits

Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek b1d6dcf5a5 Do not format USEC_INFINITY as NULL
systemctl would print 'CPUQuotaPerSecUSec=(null)' for no limit. This
does not look right.

Since USEC_INFINITY is one of the valid values, format_timespan()
could return NULL, and we should wrap every use of it in strna() or
similar. But most callers didn't do that, and it seems more robust to
return a string ("infinity") that makes sense most of the time, even
if in some places the result will not be grammatically correct.
2014-09-29 11:09:39 -04:00
Thomas Hindoe Paaboel Andersen b49ffb29ed sd-bus: sd_bus_message_get_errno should only return positive errno
sd_bus_message_get_errno can currently return either a number of
different poitive errno values (from bus-error-mapping), or a negative
EINVAL if passed null as parameter.

The check for null parameter was introduced in 40ca29a137
at the same as the function was renamed from bus_message_to_errno and
made public API. Before becoming public the function used to return
only negative values.

It is weird to have a function return both positive and negative errno
and it generally looks like a mistake. The function is guarded by the
--enable-kdbus flags so I wonder if we still have time to fix it up?
It does not have any documentation yet. However, except for a few details
it is just a convenient way to call sd_bus_error_get_errno which is documented
to return only positive errno.

This patch makes it return only positive errno and fixes up the two
calls to the function that tried to cope with both positive and negative
values.
2014-09-16 21:31:15 +02:00
Michal Schmidt d5099efc47 hashmap: introduce hash_ops to make struct Hashmap smaller
It is redundant to store 'hash' and 'compare' function pointers in
struct Hashmap separately. The functions always comprise a pair.
Store a single pointer to struct hash_ops instead.

systemd keeps hundreds of hashmaps, so this saves a little bit of
memory.
2014-09-15 16:08:50 +02:00
Tom Gundersen adc5b2e2eb sd-network: add _get_network_file api 2014-09-08 15:09:07 +02:00
Tom Gundersen 78c958f82e networkd: link - allow loopback links to be manage, but ignore DHCP/IPv4LL 2014-09-04 20:55:26 +02:00
Tom Gundersen a821cbb00c networkd: link - clarify log message when receiving address for unknown link 2014-09-04 14:16:56 +02:00
Tom Gundersen bd2efe9219 networkd: link - do not manage loopback links
Fixes https://bugs.freedesktop.org/show_bug.cgi?id=83134.
2014-09-04 14:16:25 +02:00
Tom Gundersen 51d1817152 networkd: link - save link flags when the link is added
Don't wait for the link to be fully synchronised.
2014-09-04 14:10:57 +02:00
Tom Gundersen a61bb41c29 networkd: move carrier gained/lost handling from link_update_flags() to link_update()
This allows us also to simplify link_has_carrier() a bit.
2014-09-04 14:10:57 +02:00
Tom Gundersen 81163121e6 networkd: don't consider deprecated or tentative addresses when determining operstate
https://bugs.freedesktop.org/show_bug.cgi?id=81287
2014-08-19 19:01:38 +02:00
Tom Gundersen 2a5948f715 networkd: link - don't enforce ENSLAVING state
We are only guaranteed to stay in ENSLAVING state whilst enslaving by bridges/bonds, not
when adding stacked devices (as then the underlying device can be IFF_UP'ed and configured
in parallel), so drop these asserts.
2014-08-19 17:55:34 +02:00
Lennart Poettering ea352b409e networkd: fix how we generate lists in link_save()
https://bugs.freedesktop.org/show_bug.cgi?id=82721
2014-08-18 18:59:48 +02:00
Lennart Poettering d5314fff96 networkd: always write out locally configured settings first, dhcp-acquired ones later
This is primarily important for the domains list, as we really should
prefer the locally configured domain over the dhcp supplied ones when we
use it as a search list.
2014-08-15 15:42:56 +02:00
Tom Gundersen 67272d157a sd-network: add support for wildcard domains 2014-08-15 15:15:24 +02:00
Tom Gundersen 6192b846ca networkd: add support for Domains= to .network files
This allows the search/routing domanis to be specified per link/network and be passed
on to resolved.
2014-08-15 15:15:24 +02:00
Tom Gundersen ad0734e890 networkd: rename UseDomainName to UseDomains
This option will also apply to the search domains, so make it plural.
2014-08-15 12:53:34 +02:00
Tom Gundersen 9b4d1882ca sd-network: add sd_network_linkg_get_domains()
For now this only exposes the domain name (DHCP Option 15), and not
the search string (DHCP Option 119), which will be implemented in
a follow-up patch.
2014-08-14 23:13:14 +02:00
Tom Gundersen 9fdaa9925e networkd: link - don't enter LINK_CONFIGURED more than once 2014-08-14 14:13:36 +02:00
Tom Gundersen c6d3b3034a networkd: link - print address lifetime for tracked addresses
This should help in debugging issues with DHCP lease renewal.
2014-08-14 14:07:45 +02:00
Tom Gundersen d3df0e3982 sd-network: rename operstates 'down' -> 'off' and 'up' -> 'no-carrier'
Suggested by Lennart and Kay.
2014-08-13 22:44:41 +02:00
Tom Gundersen 8434fd5cf2 sd-network: rename state INITALIZING to PENDING and expose as any other state
This is the state when we are waiting for udev to initialize the device, and waiting for
libudev and rtnl to be in sync. In the future we probably will also be waiting for nl80211.
At this point we do not yet have enough information to know whether or not networkd should
be handling the device.
2014-08-13 15:39:57 +02:00
Tom Gundersen 54cba0b16c sd-network: split the operstate 'unknown' into 'down' and 'up' 2014-08-12 20:42:59 +02:00
Tom Gundersen 3c9b886068 networkd: link - split out dhcp4 handling 2014-08-12 20:42:59 +02:00
Tom Gundersen 77a008c090 networkd: link - fix IN_SET usage 2014-08-12 20:42:59 +02:00
Tom Gundersen b22d8a00f4 networkd: link - split out ipv4ll handling 2014-08-12 20:42:59 +02:00
Tom Gundersen 431ca2cebb networkd: link - make check for whether addresses/routes are being configured implicit 2014-08-12 20:42:59 +02:00
Tom Gundersen 0b1831c20c networkd: split out networkd-link.h 2014-08-12 20:42:59 +02:00
Lennart Poettering c2d6bd61ee networkd: update manager_save() to use fflush_and_check() to simplify things a bit 2014-08-12 13:02:27 +02:00
Lennart Poettering 91d3efeddd networkd: fix build 2014-08-12 02:33:37 +02:00
Lennart Poettering 44e7b94926 networkd: monopolize in_addr utility functions in shared/in-addr-util.h
Primarily, this means we get rid of net_parse_inaddr(), and replace it
everywhere with in_addr_from_string() and in_addr_from_string_auto().
These functions do not clobber the callers arguments on failure, which
is more close to our usual coding style.
2014-08-11 22:46:42 +02:00
Tom Gundersen 59b8f6b628 sd-dhcp-server: always send out ROUTER and SUBNET_MASK
For now we simply take these values from the server's address.
2014-08-04 20:58:15 +02:00
Tom Gundersen bd8f653876 networkd: add and expose per-link LLMNR config option 2014-08-04 16:56:34 +02:00
Tom Gundersen afe7fd56f5 networkd: track the MTU of each link
And inform the DHCPv4 clients about it.
2014-08-01 16:34:50 +02:00
Tom Gundersen 9fecce8041 Revert "networkd: don't assume udev_device_new_from_device_id sets errno"
libudev now does set errno correctly, so we can indeed rely on this.

This reverts commit 2b49732c3d.
2014-08-01 11:56:13 +02:00
Tom Gundersen 2b49732c3d networkd: don't assume udev_device_new_from_device_id sets errno
This reverts 6f4d55a8ae, as we cannot rely on errno here.

Reported by David Herrmann.
2014-07-30 21:53:38 +02:00
Tom Gundersen 6f4d55a8ae networkd: improve error message when udev device can not be found
Reported by Raimonds Cicans <ray@apollo.lv>
2014-07-30 18:35:53 +02:00
Tom Gundersen ba17915457 networkd: ipv4ll - configure link-local address independently of DHCPv4
This changes the behavior when both DHCPv4 and IPv4LL are enabled. Before,
we would disable IPv4LL when we got a DHCPv4 lease and enable it if the
lease was lost.

Now we just always set up both, if both are enabled, but the DHCPv4
addresses and routes will always take precedence due to their metric
and scope.
2014-07-30 17:45:47 +02:00
Lennart Poettering af93291cc4 resolved: when answer A or AAAA questions, order responses by whether addresses are link-local or not 2014-07-30 00:48:59 +02:00
Michael Marineau 70b34f5de8 networkd: fix reporting errors from hostnamed
The return value may be -EINVAL or a positive errno from the dbus
message. Check both ranges, otherwise most errors are silently ignored.
2014-07-29 22:24:58 +02:00
Tom Gundersen 6a0a2f860f networkd: unify handling of stacked netdevs 2014-07-28 12:16:40 +02:00
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