Commit graph

307 commits

Author SHA1 Message Date
Harald Hoyer a7f7d1bde4 fix gcc warnings about uninitialized variables
like:

src/shared/install.c: In function ‘unit_file_lookup_state’:
src/shared/install.c:1861:16: warning: ‘r’ may be used uninitialized in
this function [-Wmaybe-uninitialized]
         return r < 0 ? r : state;
                ^
src/shared/install.c:1796:13: note: ‘r’ was declared here
         int r;
             ^
2015-03-27 14:57:38 +01:00
Shawn Landden 6ec8e7c763 sd-dhcp-client: fix strict aliasing issue 2015-03-14 14:50:45 +01:00
Zbigniew Jędrzejewski-Szmek 9116b40692 test-dhcp-option: conform to usual coding style 2015-03-13 23:42:17 -04:00
Zbigniew Jędrzejewski-Szmek 0915fda60a test-dhcp-option: add assert to check index is nonnegative
CID #1237623.
2015-03-13 23:42:17 -04:00
Zbigniew Jędrzejewski-Szmek dc75168823 Use space after a silencing (void)
We were using a space more often than not, and this way is
codified in CODING_STYLE.
2015-03-13 23:42:17 -04:00
David Herrmann 15411c0cb1 tree-wide: there is no ENOTSUP on linux
Replace ENOTSUP by EOPNOTSUPP as this is what linux actually uses.
2015-03-13 14:10:39 +01:00
Zbigniew Jędrzejewski-Szmek c066b4746b sd-pppoe: workaround for incomplete include in old kernels 2015-03-12 20:50:08 -04:00
Thomas Haller cc22955cfe sd-dhcp6-client: delay setting the DUID and don't fail constructor
sd_dhcp6_client_new() tried to set the DUID based on the machine id.
If the host has no /etc/machine-id, the constructor would fail
making it impossible to create an sd_dhcp6_client instance.

Relax this and create a DUID only later as needed. This way a caller
caller can workaround a missing machine-id file and set a DUID of his
choosing via sd_dhcp6_client_set_duid().
2015-03-04 11:01:39 +01: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
Zbigniew Jędrzejewski-Szmek 2404701e67 Transpose args in strv_fnmatch() to be more oo 2015-02-16 14:04:36 -05:00
Zbigniew Jędrzejewski-Szmek d49dc81276 test-network: fix segfault with NULL dev_path/driver/type/name 2015-02-16 13:58:26 -05:00
Zbigniew Jędrzejewski-Szmek ee5de57b9d network-internal: chain matches with AND in net_match_config()
The test would treat the first non-empty set of matches in
match_paths, match_drivers, match_types, match_names as definitive
(essentially chaining them with OR). Make those tests instead match
like other tests and require all to pass if the set of patterns is
nonempty.
2015-02-16 13:16:46 -05:00
Zbigniew Jędrzejewski-Szmek bceccd5ecc Add helper for fnmatch over strv 2015-02-16 13:16:45 -05:00
Thomas Hindoe Paaboel Andersen c1ff5570f4 Add missing includes in header files
This fixes various issues found by globally reordering the include
sections of all .c files.
2015-02-12 20:44:32 +01:00
Lennart Poettering a38d99451f Revert "tree-wide: Always use recvmsg with MSG_CMSG_CLOEXEC"
This reverts commit d6d810fbf8.

It's apparently not OK to pass MSG_CMSG_CLOEXEC to recvmsg() of raw
sockets.
2015-02-12 11:45:39 +01:00
Tom Gundersen 910889b617 network-internal: fix inverted matching
This fixes the test-suite again.
2015-02-11 13:13:50 +01:00
Tom Gundersen 5256e00e8b net: support globbing and disjunction in Match logic
Match{Name,OrginalName,Type,Driver,Path} can now take a space-separated glob of matches.
2015-02-10 22:30:35 +01:00
Cristian Rodríguez d6d810fbf8 tree-wide: Always use recvmsg with MSG_CMSG_CLOEXEC 2015-02-10 21:20:16 +01:00
Lennart Poettering 332560792c test-lldp: fix minor OOM 2015-02-10 21:17:26 +01:00
Lennart Poettering 804138a08c test-lldp: initialize structs when we define them 2015-02-10 21:15:47 +01:00
Lennart Poettering b762fbd128 test-lldp: use strndup() where possible 2015-02-10 21:15:21 +01:00
Philippe De Swert 2e1a569b77 libsystemd-network: Avoid potential NULL dereference in test-lldp
As a malloc0 could fail, doing a strncpy without checking could
cause issues. Adding an assert should be good enough and in line
with other similar routines in the code.

Found with Coverity Fixes: CID#1261402
2015-02-10 21:11:52 +01:00
Torstein Husebø e2acdb6b0f treewide: correct typos and use consistent "MAC" spelling 2015-02-09 14:32:49 +01:00
Zbigniew Jędrzejewski-Szmek 374c22b351 test-dhcp-client: add a kludge to make valgrind happy 2015-02-02 20:31:18 -05:00
Zbigniew Jędrzejewski-Szmek fe0885f8ce test-dhcp-client: open a real udp socket for test execution
./test-dhcp-client would attempt to operate fd 0, i.e. stdin.
For example, './test-dhcp-client </dev/null' would fail with EPERM
because /dev/null cannot be used with epoll.

https://bugzilla.redhat.com/show_bug.cgi?id=1076119
2015-02-02 20:31:18 -05:00
Zbigniew Jędrzejewski-Szmek afa3509a4f test-dhcp-client: remove linebreak 2015-01-31 12:25:12 -05: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
Patrik Flykt bd1957e906 sd-icmp6-nd: Add support for fetching the latest expired prefix
Keep the expired prefix for the duration of the prefix expiration event
and remove it afterwards.
2015-01-27 09:35:24 +02:00
Patrik Flykt 99af546d0e test-icmp6-nd: Add test cases for prefixes
Add test cases that feeds an Router Advertisement to the ICMPv6 code
and verify that the correct prefix lengths are returned given an IPv6
address.

Enhance the prefix verification test by adding a shorter prefix and
check that the intended prefix lengths are now updated.
2015-01-27 09:35:24 +02:00
Patrik Flykt d77bde34cf sd-icmp6-nd: Parse ICMPv6 prefix information
Save each new onlink IPv6 prefix and attach an expiry timer to it.
If the prefixes overlap, take the shorter prefix and write a debug
message about the event. Once the prefix is resent in a Router
Advertisement, update the timer. Add a new event for the expiring
prefix.

Add two helper functions, one for returning a prefix length given a
Router Advertisement and the other for generic prefix matching given
an IPv6 prefix and address.
2015-01-27 09:35:24 +02:00
Patrik Flykt 8d7f2c6a47 test-icmp6-rs: Add trivial test case for an MTU that is not present 2015-01-27 09:35:24 +02:00
Patrik Flykt d14b5bc621 sd-icmp6-nd: Add helper function to get the IPv6 link MTU
Update MTU according to the latest value received.
2015-01-27 09:35:24 +02:00
Patrik Flykt 5624c4801e sd-icmp6-nd: Add link and prefix structures for ICMPv6
Each ICMPv6 structure has an interface index and will therefore be
associated with an IPv6 link containing a list of of prefixes.
2015-01-27 09:35:24 +02:00
Patrik Flykt 09667885ba sd-icmp6-nd: Update Router Advertisement handling
As the IPv6 prefixes are needed, update the ICMPv6 Router Advertisement
code to dynamically allocate a suitably sized buffer. Iterate through
the ICMPv6 options one by one returning error if the option length is
too big to fit the buffer.
2015-01-27 09:35:24 +02:00
Patrik Flykt e7504d9547 sd-dhcp6-lease: Revise address iteration functions
Revise the address iteration functions so that one helper function
resets the iterator to the start of the address list while the
second one fetches addresses one by one.

The test case is also updated.
2015-01-27 09:35:24 +02:00
Zbigniew Jędrzejewski-Szmek c9403dced7 #pragma once here and there 2015-01-23 09:30:44 -05:00
Tom Gundersen 5bac523593 sd-dhcp-client: use RFC4361-complient ClientID by default
In addition to the benefits listed in the RFC, this allows DHCP to work also in
case several interfaces share the same MAC address on the same link (IPVLAN).

Note that this will make the ClientID (so probably the assigned IP address)
change on upgrades. If it is desired to avoid that we would have to remember and
write back the ID (which the library supports, but networkd currently does not).
2015-01-22 21:29:42 +01:00
Tom Gundersen 4086286641 dhcp-identifier: create IAID even if no udev device can be found
This is useful for testing.
2015-01-22 21:29:42 +01:00
Zbigniew Jędrzejewski-Szmek 1fa2f38f0f Assorted format fixes
Types used for pids and uids in various interfaces are unpredictable.
Too bad.
2015-01-22 01:14:52 -05:00
Tom Gundersen cfb5b38057 network: dhcp - split out dhcp_identifier_set_{iaid,duid_en} from dhcp6-client
This will also be used in dhcp4-client.
2015-01-21 22:57:55 +01:00
Tom Gundersen 764aad6258 network: dhcp - split out the duid structure into a new header file
We will use the same in both dhcp4 and dhcp6.
2015-01-21 22:57:55 +01:00
Patrik Flykt 950a1705dc sd-dhcp6-client: Remove unnecessary debug printout 2015-01-20 19:39:28 +02:00
Susant Sahani b3ff20978a LLDP: Support locally assigned port subtype
The Zyxel switch sends port subtype as Locally assigned (7).
Add LLDP_PORT_SUBTYPE_LOCALLY_ASSIGNED as supported type

reported by Mantas Mikulėnas <grawity@gmail.com>
2015-01-15 16:34:38 +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
Tom Gundersen 9c39eb5c88 network-intenal: user _cleanup_ macro in parse_ifname 2015-01-12 18:19:16 +01:00
Torstein Husebø 6b3fd9a14d libsystemd-network: fix typo in lldp 2015-01-05 12:34:11 +01:00
Zbigniew Jędrzejewski-Szmek ef75325319 network: fix scanf/printf format
usec_t is defined as 64 bit wide, but long is 32 bit on many archs.
2015-01-01 13:36:43 -05:00
David Herrmann ee14ebf211 lldp: fix sd_lldp_save()
Fix a bunch of needless memzero() calls, a bunch of use-after-free
regarding _cleanup_free_ and drop unused variables.

Hint: Do NOT use _cleanup_free_ for temporary strappend() helpers that are
freed multiple times. All you safe is the last free() call, which is
really not worth the trouble resetting it to NULL all the time.
2014-12-31 16:28:48 +01:00
David Herrmann 7d4866548d lldp: fix uninitialized cleanup var #2
Another uninitialized variable marked as _cleanup_. Set it to NULL to
avoid accessing uninitialized memory.
2014-12-31 16:07:17 +01:00
David Herrmann e7a2419a2a lldp: fix uninitialized cleanup var
Make sure to set _cleanup_ variables to NULL. Otherwise, we free
uninitialized objects.
2014-12-31 16:04:55 +01:00