Commit graph

57 commits

Author SHA1 Message Date
Lennart Poettering e473522841 dhcp: generic data should be void*, not uint8_t*
If we handly arbitrary data we should use "void*" pointers, not
"uint8_t*", how go intended C to be used.
2015-08-26 23:05:34 +02:00
Lennart Poettering 3733eec3e2 dhcp: stop using refcnt.h
No need to invole atomic ops in single-threaded APIs, let's simplify
this.
2015-08-26 21:05:53 +02:00
Lennart Poettering bd91b83e57 dhcp: keep lease save/load functions private
When we make sd-dhcp public one day we really should not make
sd_dhcp_lease_save() and sd_dhcp_lease_load() public, since it's pretty
much only useful as internal utility for networkd itself.
2015-08-26 20:48:21 +02:00
Lennart Poettering 9098162579 dhcp: normalize DHCP host and domain names from leases
Previoulsy, we just checked whether the domain names specified in
incoming DHCP leases are valid. Given that validation code actually
internally normalizes anyway, it's a good idea to simply do the full
normalization and store that in the lease structure. This allows us to
remove the manual removal of a trailing dot, if there is one.
2015-08-26 20:45:29 +02:00
Lennart Poettering 2d03c0b803 dhcp: various simplifications 2015-08-26 20:45:29 +02:00
Lennart Poettering 8eb9058dc1 dhcp,network: implement RFC 4833 (DHCP Timezone option)
This one is simply to add: encode the tzdata timezone in the DHCP
options and optionally make use of it.
2015-08-26 20:44:20 +02:00
Lennart Poettering 43f447b121 dhcp: be more careful when parsing strings from DHCP packets
Let's make sure there's no embedded 0 byte. Also, let's reset the string
if the length is zero.
2015-08-26 20:41:42 +02:00
reverendhomer 626be147a6 libsystemd-network: fix memory leak 2015-08-08 14:24:11 +03:00
Daniel Mack 92d0218ed1 libsystemd-network: plug memory leak
Coverity #1315324
2015-08-06 08:54:29 +02:00
Zbigniew Jędrzejewski-Szmek 73974f6768 Merge branch 'hostnamectl-dot-v2'
Manual merge of https://github.com/systemd/systemd/pull/751.
2015-08-05 21:02:41 -04:00
Zbigniew Jędrzejewski-Szmek 8fb4944358 hostname-util: add relax parameter to hostname_is_valid
Tests are modified to check behaviour with relax and without relax.
New tests are added for hostname_cleanup().
Tests are moved a new file (test-hostname-util) because there's
now a bunch of them.

New parameter is not used anywhere, except in tests, so there should
be no observable change.
2015-08-05 20:49:20 -04:00
Lennart Poettering 30afef872e network: make enough space for string
Follow-up for PR #877.
2015-08-05 22:25:14 +03:00
Alex Crawford 9b57d9aee4 networkd: clean up duplicate code 2015-08-05 09:00:57 -07:00
Alex Crawford a073309fb7 networkd: serialize the private options
Save the private options along side the rest of the options in the lease
files.
2015-08-05 09:00:57 -07:00
Alex Crawford 7e753d9d28 networkd: add private options to lease struct
This stores private-zone DHCP options inside of their respective DHCP
lease. These options aren't used by networkd (what would it do with
them?), but saving them will allow other programs to query the values.
To improve performance, the options are stored in ascending order by
tag.
2015-08-05 09:00:57 -07:00
Lennart Poettering dacd6cee76 tree-wide: port everything over to fflush_and_check()
Some places invoked fflush() directly with their own manual error
checking, let's unify all that by using fflush_and_check().

This also unifies the general error paths of fflush()+rename() file
writers.
2015-07-29 20:31:07 +02:00
Tom Gundersen dad8f7f2b6 Merge pull request #538 from mischief/multiple-routers
sd-dhcp-lease: fix handling of multiple routers

We only support one router, but in case more than one is given, we now ignore subsequent ones, rather than fall over.
2015-07-14 20:17:11 +02:00
Beniamino Galvani e43a8393ea dhcp: add support for vendor specific DHCP option
This adds support for option 43 (Vendor Specific Information) to
libsystemd-network DHCP code. The option carries an opaque object of n
octets, interpreted by vendor-specific code on the clients and
servers.

[@zonque: adopted to new unhexmem() API]
2015-07-12 14:26:32 -04:00
Tom Gundersen 30494563f2 basic: util - fix errorhandling in unhexmem()
We were ignoring failures from unhexchar, which meant that invalid
hex characters were being turned into garbage rather than the string
rejected.

Fix this by making unhexmem return an error code, also change the API
slightly, to return the size of the returned memory, reflecting the
fact that the memory is a binary blob,and not a string.

For convenience, still append a trailing NULL byte to the returned
memory (not included in the returned size), allowing callers to
treat it as a string without doing a second copy.
2015-07-12 19:11:34 +02:00
Nick Owens a05185279b sd-dhcp-lease: fix handling of multiple routers
currently if a dhcp server sends more than one router, sd-dhcp-lease
does not copy the ip because it assumes it will only ever be 4 bytes. a
dhcp server could send more than one ip in the router list, so we should
copy the first one and ignore the rest of the bytes.
2015-07-11 15:37:01 -07:00
Nick Owens 37de250906 libsystemd-network: use domain validation instead of hostname validation for dhcp domain option
previously hostname_is_valid was used to validate domain names, which
would silently drop perfectly valid dns names that were longer than a
single dns label.
2015-06-10 11:15:46 -07:00
Lennart Poettering dde8bb32b1 json: minor style fixes 2015-05-21 23:30:37 +02:00
Lennart Poettering 958b66ea16 util: split all hostname related calls into hostname-util.c 2015-05-18 17:10:07 +02:00
Thomas Hindoe Paaboel Andersen 2eec67acbb remove unused includes
This patch removes includes that are not used. The removals were found with
include-what-you-use which checks if any of the symbols from a header is
in use.
2015-02-23 23:53:42 +01:00
Lennart Poettering f50f01f4b7 sd-dhcp: chop of trailing dot of DHCP supplied host and domain nams 2015-01-28 17:47:37 +01:00
Tom Gundersen f0c4b1c3fd refcnt: refcnt is unsigned, fix comparisons
This does not make a difference, but the code was confusing.
2015-01-13 23:03:11 +01:00
Michal Schmidt 23bbb0de4e treewide: more log_*_errno + return simplifications 2014-11-28 18:24:30 +01:00
Michal Schmidt da927ba997 treewide: no need to negate errno for log_*_errno()
It corrrectly handles both positive and negative errno values.
2014-11-28 13:29:21 +01:00
Michal Schmidt 0a1beeb642 treewide: auto-convert the simple cases to log_*_errno()
As a followup to 086891e5c1 "log: add an "error" parameter to all
low-level logging calls and intrdouce log_error_errno() as log calls
that take error numbers", use sed to convert the simple cases to use
the new macros:

find . -name '*.[ch]' | xargs sed -r -i -e \
's/log_(debug|info|notice|warning|error|emergency)\("(.*)%s"(.*), strerror\(-([a-zA-Z_]+)\)\);/log_\1_errno(-\4, "\2%m"\3);/'

Multi-line log_*() invocations are not covered.
And we also should add log_unit_*_errno().
2014-11-28 12:04:41 +01:00
Thomas Haller 1c6eb4e36b sd-dhcp-lease: fix copy-paste error asserting wrong function argument 2014-11-20 16:51:29 +01:00
Dan Williams e37f74a6d5 sd-dhcp-lease: load/save client ID
The lease is usually tied to the client ID, so users of the
lease may want to know what client ID it was acquired with.
2014-11-19 00:58:51 +01:00
Tom Gundersen 1dc24d5f48 sd-dhcp-lease: expose load/save functions
Based on patch by Dan Williams.
2014-11-18 19:10:37 +01:00
Tom Gundersen 1caa12d0a8 sd-dhcp-lease: use shared default prefixlen function
Also change the default prefixlen function to only access the first octet of the in_addr.
2014-11-01 19:02:44 +01:00
Tom Gundersen bab4792961 sd-dhcp-lease: use unaligned read helpers 2014-11-01 18:59:55 +01:00
Tom Gundersen df40eee8ed shared: in-addr-utils - add default_subnet_mask and default_prefixlen methods
These use the (deprecated) IPv4 address classes to deduce the corresponding subnet masks. This is useful when addresses
without subnet masks and prefix lengths are given.

Make use of these new functions from sd-dhcp-lease.
2014-10-27 17:40:24 +01:00
Lennart Poettering 708281b811 dhcp: the localhost isn't valid as hostname either 2014-08-15 03:10:20 +02:00
Tom Gundersen 784d9b9c09 sd-dhcp-lease: verify hostname and domainnames we receive 2014-08-15 01:04:53 +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
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
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
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 f5c0c00f40 dhcp-lease: add support for parsing a few more dhcp options 2014-05-20 23:31:22 +02:00
Tom Gundersen e140ae58f1 dhcp-lease: refactor lease parsing
Use helper functions, and add some more sanity checking/asserts.
2014-05-20 23:31:22 +02:00
Tom Gundersen 81d98a39eb sd-dhcp-lease/sd-network: modernization and fix leak 2014-05-19 18:14:56 +02:00
Tom Gundersen 09bee74d7a sd-dhcp-lease: move in_addr (de)serialization to shared network code 2014-05-19 18:14:56 +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 bc4155669a sd-dhcp-lease: fix double realloc 2014-04-29 21:57:59 +02:00
Tom Gundersen 109731eb25 sd-dhcp-lease: (de)serialize DNS and NTP servers
Also use inet_ntoa rather than inet_ntop.
2014-04-29 15:05:33 +02:00
Tom Gundersen 0b21bde96d sd-dhcp-leaes: use newdup() 2014-04-29 12:46:06 +02:00
Tom Gundersen 4684469639 sd-dhcp-lease: add NTP support
Export the NTP servers so timesyncd can use them.
2014-04-29 12:25:58 +02:00