[PATCH] ell/ecc.h: fix build with uclibc
by Fabrice Fontaine
ssize_t is defined in sys/types.h
Fixes:
- http://autobuild.buildroot.org/results/444c9deb728fb041e560d940145f96cc4f...
Signed-off-by: Fabrice Fontaine <fontaine.fabrice(a)gmail.com>
---
ell/ecc.h | 2 ++
1 file changed, 2 insertions(+)
diff --git a/ell/ecc.h b/ell/ecc.h
index 26a5889..65c49e8 100644
--- a/ell/ecc.h
+++ b/ell/ecc.h
@@ -27,6 +27,8 @@
extern "C" {
#endif
+#include <sys/types.h> // for ssize_t
+
#define L_ECC_MAX_DIGITS 6
#define L_ECC_SCALAR_MAX_BYTES L_ECC_MAX_DIGITS * 8
#define L_ECC_POINT_MAX_BYTES L_ECC_SCALAR_MAX_BYTES * 2
--
2.20.1
2 years, 1 month
[PATCH] settings: Parse non-base-10 integer settings
by Andrew Zaborowski
Change the stro{,u}{l,ll} base parameter to 0 to not disallow hex or
octal numbers, useful for bitmasks.
---
ell/settings.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/ell/settings.c b/ell/settings.c
index c5e1184..f4326d6 100644
--- a/ell/settings.c
+++ b/ell/settings.c
@@ -998,7 +998,7 @@ LIB_EXPORT bool l_settings_get_int(const struct l_settings *settings,
errno = 0;
- t = r = strtol(value, &endp, 10);
+ t = r = strtol(value, &endp, 0);
if (*endp != '\0')
goto error;
@@ -1045,7 +1045,7 @@ LIB_EXPORT bool l_settings_get_uint(const struct l_settings *settings,
errno = 0;
- t = r = strtoul(value, &endp, 10);
+ t = r = strtoul(value, &endp, 0);
if (*endp != '\0')
goto error;
@@ -1091,7 +1091,7 @@ LIB_EXPORT bool l_settings_get_int64(const struct l_settings *settings,
errno = 0;
- r = strtoll(value, &endp, 10);
+ r = strtoll(value, &endp, 0);
if (*endp != '\0')
goto error;
@@ -1137,7 +1137,7 @@ LIB_EXPORT bool l_settings_get_uint64(const struct l_settings *settings,
errno = 0;
- r = strtoull(value, &endp, 10);
+ r = strtoull(value, &endp, 0);
if (*endp != '\0')
goto error;
--
2.20.1
2 years, 1 month
[PATCH] rtnl: Export l_rtnl_*() functions
by Daniel Wagner
---
ell/ell.sym | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/ell/ell.sym b/ell/ell.sym
index 0c83b874706f..f4b30dd9366f 100644
--- a/ell/ell.sym
+++ b/ell/ell.sym
@@ -543,6 +543,26 @@ ELL_0.10 {
l_gpio_reader_new;
l_gpio_reader_free;
l_gpio_reader_get;
+ /* rtnl */
+ l_rtnl_set_linkmode_and_operstate;
+ l_rtnl_set_mac;
+ l_rtnl_set_powered;
+ l_rtnl_ifaddr4_extract;
+ l_rtnl_ifaddr4_dump;
+ l_rtnl_ifaddr4_add;
+ l_rtnl_ifaddr4_delete;
+ l_rtnl_route4_extract;
+ l_rtnl_route4_dump;
+ l_rtnl_route4_add_connected;
+ l_rtnl_route4_add_gateway;
+ l_rtnl_ifaddr6_extract;
+ l_rtnl_ifaddr6_dump;
+ l_rtnl_ifaddr6_add;
+ l_rtnl_ifaddr6_delete;
+ l_rtnl_route6_extract;
+ l_rtnl_route6_dump;
+ l_rtnl_route6_add_gateway;
+ l_rtnl_route6_delete_gateway;
local:
*;
};
--
2.25.1
2 years, 1 month
[PATCH] rtnl: Annotate global functions with LIB_EXPORT
by Daniel Wagner
---
ell/rtnl.c | 47 ++++++++++++++++++++++++++++-------------------
1 file changed, 28 insertions(+), 19 deletions(-)
diff --git a/ell/rtnl.c b/ell/rtnl.c
index 7611e82f9843..dc83937b99d1 100644
--- a/ell/rtnl.c
+++ b/ell/rtnl.c
@@ -33,6 +33,7 @@
#include "netlink.h"
#include "log.h"
#include "rtnl.h"
+#include "private.h"
static size_t rta_add_u8(void *rta_buf, unsigned short type, uint8_t value)
{
@@ -132,7 +133,8 @@ static void l_rtnl_route_extract(const struct rtmsg *rtmsg, uint32_t len,
}
}
-uint32_t l_rtnl_set_linkmode_and_operstate(struct l_netlink *rtnl, int ifindex,
+LIB_EXPORT uint32_t l_rtnl_set_linkmode_and_operstate(struct l_netlink *rtnl,
+ int ifindex,
uint8_t linkmode, uint8_t operstate,
l_netlink_command_func_t cb,
void *user_data,
@@ -165,7 +167,7 @@ uint32_t l_rtnl_set_linkmode_and_operstate(struct l_netlink *rtnl, int ifindex,
return id;
}
-uint32_t l_rtnl_set_mac(struct l_netlink *rtnl, int ifindex,
+LIB_EXPORT uint32_t l_rtnl_set_mac(struct l_netlink *rtnl, int ifindex,
const uint8_t addr[static 6],
bool power_up,
l_netlink_command_func_t cb,
@@ -202,7 +204,8 @@ uint32_t l_rtnl_set_mac(struct l_netlink *rtnl, int ifindex,
return id;
}
-uint32_t l_rtnl_set_powered(struct l_netlink *rtnl, int ifindex, bool powered,
+LIB_EXPORT uint32_t l_rtnl_set_powered(struct l_netlink *rtnl, int ifindex,
+ bool powered,
l_netlink_command_func_t cb, void *user_data,
l_netlink_destroy_func_t destroy)
{
@@ -227,7 +230,7 @@ uint32_t l_rtnl_set_powered(struct l_netlink *rtnl, int ifindex, bool powered,
return id;
}
-void l_rtnl_ifaddr4_extract(const struct ifaddrmsg *ifa, int bytes,
+LIB_EXPORT void l_rtnl_ifaddr4_extract(const struct ifaddrmsg *ifa, int bytes,
char **label, char **ip, char **broadcast)
{
struct in_addr in_addr;
@@ -262,7 +265,8 @@ void l_rtnl_ifaddr4_extract(const struct ifaddrmsg *ifa, int bytes,
}
}
-uint32_t l_rtnl_ifaddr4_dump(struct l_netlink *rtnl, l_netlink_command_func_t cb,
+LIB_EXPORT uint32_t l_rtnl_ifaddr4_dump(struct l_netlink *rtnl,
+ l_netlink_command_func_t cb,
void *user_data,
l_netlink_destroy_func_t destroy)
{
@@ -340,7 +344,7 @@ static uint32_t l_rtnl_ifaddr4_change(struct l_netlink *rtnl, uint16_t nlmsg_typ
return id;
}
-uint32_t l_rtnl_ifaddr4_add(struct l_netlink *rtnl, int ifindex,
+LIB_EXPORT uint32_t l_rtnl_ifaddr4_add(struct l_netlink *rtnl, int ifindex,
uint8_t prefix_len, const char *ip,
const char *broadcast,
l_netlink_command_func_t cb, void *user_data,
@@ -350,7 +354,7 @@ uint32_t l_rtnl_ifaddr4_add(struct l_netlink *rtnl, int ifindex,
broadcast, cb, user_data, destroy);
}
-uint32_t l_rtnl_ifaddr4_delete(struct l_netlink *rtnl, int ifindex,
+LIB_EXPORT uint32_t l_rtnl_ifaddr4_delete(struct l_netlink *rtnl, int ifindex,
uint8_t prefix_len, const char *ip,
const char *broadcast,
l_netlink_command_func_t cb, void *user_data,
@@ -360,7 +364,7 @@ uint32_t l_rtnl_ifaddr4_delete(struct l_netlink *rtnl, int ifindex,
broadcast, cb, user_data, destroy);
}
-void l_rtnl_route4_extract(const struct rtmsg *rtmsg, uint32_t len,
+LIB_EXPORT void l_rtnl_route4_extract(const struct rtmsg *rtmsg, uint32_t len,
uint32_t *table, uint32_t *ifindex,
char **dst, char **gateway, char **src)
{
@@ -368,7 +372,7 @@ void l_rtnl_route4_extract(const struct rtmsg *rtmsg, uint32_t len,
NULL, NULL, dst, gateway, src);
}
-uint32_t l_rtnl_route4_dump(struct l_netlink *rtnl,
+LIB_EXPORT uint32_t l_rtnl_route4_dump(struct l_netlink *rtnl,
l_netlink_command_func_t cb, void *user_data,
l_netlink_destroy_func_t destroy)
{
@@ -456,7 +460,8 @@ static uint32_t l_rtnl_route4_add(struct l_netlink *rtnl, int ifindex,
destroy);
}
-uint32_t l_rtnl_route4_add_connected(struct l_netlink *rtnl, int ifindex,
+LIB_EXPORT uint32_t l_rtnl_route4_add_connected(struct l_netlink *rtnl,
+ int ifindex,
uint8_t dst_len, const char *dst,
const char *src, uint8_t proto,
l_netlink_command_func_t cb,
@@ -467,7 +472,8 @@ uint32_t l_rtnl_route4_add_connected(struct l_netlink *rtnl, int ifindex,
src, 0, proto, cb, user_data, destroy);
}
-uint32_t l_rtnl_route4_add_gateway(struct l_netlink *rtnl, int ifindex,
+LIB_EXPORT uint32_t l_rtnl_route4_add_gateway(struct l_netlink *rtnl,
+ int ifindex,
const char *gateway, const char *src,
uint32_t priority_offset,
uint8_t proto,
@@ -480,7 +486,8 @@ uint32_t l_rtnl_route4_add_gateway(struct l_netlink *rtnl, int ifindex,
user_data, destroy);
}
-void l_rtnl_ifaddr6_extract(const struct ifaddrmsg *ifa, int len, char **ip)
+LIB_EXPORT void l_rtnl_ifaddr6_extract(const struct ifaddrmsg *ifa, int len,
+ char **ip)
{
struct in6_addr in6_addr;
struct rtattr *attr;
@@ -510,7 +517,7 @@ void l_rtnl_ifaddr6_extract(const struct ifaddrmsg *ifa, int len, char **ip)
}
}
-uint32_t l_rtnl_ifaddr6_dump(struct l_netlink *rtnl,
+LIB_EXPORT uint32_t l_rtnl_ifaddr6_dump(struct l_netlink *rtnl,
l_netlink_command_func_t cb, void *user_data,
l_netlink_destroy_func_t destroy)
{
@@ -575,7 +582,7 @@ static uint32_t l_rtnl_ifaddr6_change(struct l_netlink *rtnl,
return id;
}
-uint32_t l_rtnl_ifaddr6_add(struct l_netlink *rtnl, int ifindex,
+LIB_EXPORT uint32_t l_rtnl_ifaddr6_add(struct l_netlink *rtnl, int ifindex,
uint8_t prefix_len, const char *ip,
l_netlink_command_func_t cb, void *user_data,
l_netlink_destroy_func_t destroy)
@@ -584,7 +591,7 @@ uint32_t l_rtnl_ifaddr6_add(struct l_netlink *rtnl, int ifindex,
ip, cb, user_data, destroy);
}
-uint32_t l_rtnl_ifaddr6_delete(struct l_netlink *rtnl, int ifindex,
+LIB_EXPORT uint32_t l_rtnl_ifaddr6_delete(struct l_netlink *rtnl, int ifindex,
uint8_t prefix_len, const char *ip,
l_netlink_command_func_t cb,
void *user_data,
@@ -594,7 +601,7 @@ uint32_t l_rtnl_ifaddr6_delete(struct l_netlink *rtnl, int ifindex,
ip, cb, user_data, destroy);
}
-void l_rtnl_route6_extract(const struct rtmsg *rtmsg, uint32_t len,
+LIB_EXPORT void l_rtnl_route6_extract(const struct rtmsg *rtmsg, uint32_t len,
uint32_t *table, uint32_t *ifindex,
char **dst, char **gateway, char **src)
{
@@ -602,7 +609,7 @@ void l_rtnl_route6_extract(const struct rtmsg *rtmsg, uint32_t len,
NULL, NULL, dst, gateway, src);
}
-uint32_t l_rtnl_route6_dump(struct l_netlink *rtnl,
+LIB_EXPORT uint32_t l_rtnl_route6_dump(struct l_netlink *rtnl,
l_netlink_command_func_t cb, void *user_data,
l_netlink_destroy_func_t destroy)
{
@@ -670,7 +677,8 @@ static uint32_t l_rtnl_route6_change(struct l_netlink *rtnl,
destroy);
}
-uint32_t l_rtnl_route6_add_gateway(struct l_netlink *rtnl, int ifindex,
+LIB_EXPORT uint32_t l_rtnl_route6_add_gateway(struct l_netlink *rtnl,
+ int ifindex,
const char *gateway,
uint32_t priority_offset,
uint8_t proto,
@@ -683,7 +691,8 @@ uint32_t l_rtnl_route6_add_gateway(struct l_netlink *rtnl, int ifindex,
user_data, destroy);
}
-uint32_t l_rtnl_route6_delete_gateway(struct l_netlink *rtnl, int ifindex,
+LIB_EXPORT uint32_t l_rtnl_route6_delete_gateway(struct l_netlink *rtnl,
+ int ifindex,
const char *gateway,
uint32_t priority_offset,
uint8_t proto,
--
2.25.1
2 years, 1 month
[PATCH] unit: Add graceful fail of pem, tls and key tests
by Brian Gix
Unit tests for PEM, TLS and KEY require the pkcs8_key_parser module
to be running in the kernel, however not all kernels have this
running by default. This checks for this possibility and aborts
these tests with exit(1) rather than an assert, and includes instruction
to correct the issue.
---
unit/test-key.c | 9 +++++++++
unit/test-pem.c | 9 +++++++++
unit/test-tls.c | 12 +++++++++++-
3 files changed, 29 insertions(+), 1 deletion(-)
diff --git a/unit/test-key.c b/unit/test-key.c
index 697ff47..240a02c 100644
--- a/unit/test-key.c
+++ b/unit/test-key.c
@@ -569,6 +569,15 @@ static void test_key_crypto(const void *data)
privkey = l_pem_load_private_key(CERTDIR "cert-client-key-pkcs8.pem",
NULL, NULL);
+ if (!privkey) {
+ l_info("* Some kernel versions do not automatically load\n"
+ "* the pkcs8_key_parser module. If the system running\n"
+ "* test has not loaded this module, a failure here is\n"
+ "* likely. Running \"modprobe pkcs8_key_parser\" may\n"
+ "* correct this issue.\n");
+ exit(1);
+ }
+
assert(privkey);
success = l_key_get_info(privkey, rsa, hash, &keybits, &is_public);
assert(success);
diff --git a/unit/test-pem.c b/unit/test-pem.c
index d39003e..a1e8110 100644
--- a/unit/test-pem.c
+++ b/unit/test-pem.c
@@ -216,6 +216,15 @@ static void test_priv_key_from_data(const void *data)
key = l_pem_load_private_key_from_data(raw_private_key,
strlen(raw_private_key),
"abc", &is_encrypted);
+ if (!key) {
+ l_info("* Some kernel versions do not automatically load\n"
+ "* the pkcs8_key_parser module. If the system running\n"
+ "* test has not loaded this module, a failure here is\n"
+ "* likely. Running \"modprobe pkcs8_key_parser\" may\n"
+ "* correct this issue.\n");
+ exit(1);
+ }
+
assert(key);
assert(is_encrypted);
diff --git a/unit/test-tls.c b/unit/test-tls.c
index 1d47787..3519376 100644
--- a/unit/test-tls.c
+++ b/unit/test-tls.c
@@ -562,8 +562,18 @@ static void test_tls_with_ver(const struct tls_conn_test *test,
l_pem_load_private_key(test->server_key_path,
test->server_key_passphrase,
NULL);
- assert(server_cert);
+ if (!server_key) {
+ l_info("* Some kernel versions do not automatically\n"
+ "* load the pkcs8_key_parser module. If the\n"
+ "* system running test has not loaded this\n"
+ "* module, a failure here is likely. Running\n"
+ "* \"modprobe pkcs8_key_parser\" may correct\n"
+ "* this issue.\n");
+ exit(1);
+ }
+
assert(server_key);
+ assert(server_cert);
assert(l_tls_set_auth_data(s[0].tls, server_cert, server_key));
}
--
2.21.1
2 years, 2 months
[PATCH] rtnl: add 'power_up' flag to l_rtnl_set_mac
by James Prestwood
The use of l_rtnl_set_mac in IWD is always followed by powering up the
device. Bringing the device back up requires calling l_rtnl_set_powered
which makes another async call into the kernel. In order to reduce
complexity we can include the IFF_UP flag to the MAC change message which
will both change the MAC and bring the interface up all in one go.
The existing behavior is maintained by passing false to 'power_up'.
---
ell/rtnl.c | 5 +++++
ell/rtnl.h | 1 +
2 files changed, 6 insertions(+)
diff --git a/ell/rtnl.c b/ell/rtnl.c
index 4600a7e..bf84cbd 100644
--- a/ell/rtnl.c
+++ b/ell/rtnl.c
@@ -167,6 +167,7 @@ uint32_t l_rtnl_set_linkmode_and_operstate(struct l_netlink *rtnl, int ifindex,
uint32_t l_rtnl_set_mac(struct l_netlink *rtnl, int ifindex,
const uint8_t addr[static 6],
+ bool power_up,
l_netlink_command_func_t cb,
void *user_data,
l_netlink_destroy_func_t destroy)
@@ -183,6 +184,10 @@ uint32_t l_rtnl_set_mac(struct l_netlink *rtnl, int ifindex,
rtmmsg->ifi_family = AF_UNSPEC;
rtmmsg->ifi_index = ifindex;
+ if (power_up) {
+ rtmmsg->ifi_change = IFF_UP;
+ rtmmsg->ifi_flags = IFF_UP;
+ }
rta_buf = (void *) rtmmsg + NLMSG_ALIGN(sizeof(struct ifinfomsg));
diff --git a/ell/rtnl.h b/ell/rtnl.h
index ea283c1..60b8db4 100644
--- a/ell/rtnl.h
+++ b/ell/rtnl.h
@@ -38,6 +38,7 @@ uint32_t l_rtnl_set_linkmode_and_operstate(struct l_netlink *rtnl, int ifindex,
uint32_t l_rtnl_set_mac(struct l_netlink *rtnl, int ifindex,
const uint8_t addr[static 6],
+ bool power_up,
l_netlink_command_func_t cb,
void *user_data,
l_netlink_destroy_func_t destroy);
--
2.24.1
2 years, 2 months
[PATCH 0/4] Refactor timespec to microsecond conversion
by Ossama Othman
An integer overflow fix for a timespec to microsecond conversion in
l_path_get_mtime() was previously committed but two overflows could
still occur: (1) the multiplication in the seconds (tv_sec) to
microsecond conversion could still exceed UINT64_MAX, and (2) addition
of the microseconds obtained from the nanoseconds (tv_nsec) member
could also result in a sum that exceeds UINT64_MAX.
This set of patches refactors the timespec to microsecond to a new
l_timespec_to_usecs() function that checks for overflow in both of the
cases mentioned above. The l_path_get_mtime() function now uses
l_timespec_to_usecs() to address the remaining potential integer
overflows. A potential integer overflow in the l_time_now() function
was corrected in a similar manner.
Ossama Othman (4):
time: Add timespec to microseconds converter
unit: Add l_timespec_to_usecs() unit test.
time: Use l_timespec_to_usecs() to avoid overflow.
path: Use l_timespec_to_usecs() to avoid overflow.
ell/ell.sym | 1 +
ell/path.c | 3 +--
ell/time.c | 26 +++++++++++++++++++++++++-
ell/time.h | 3 +++
unit/test-time.c | 34 ++++++++++++++++++++++++++++++++++
5 files changed, 64 insertions(+), 3 deletions(-)
--
2.20.1
2 years, 2 months
[PATCH] path: Fix an integer overflow in l_path_get_mtime
by Andrew Zaborowski
time_t may be 32 bits wide (also signed) so we need to cast
timespec.tv_sec to uint64_t before multiplying by 1000000.
---
ell/path.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/ell/path.c b/ell/path.c
index dfede14..df5a703 100644
--- a/ell/path.c
+++ b/ell/path.c
@@ -162,7 +162,8 @@ LIB_EXPORT uint64_t l_path_get_mtime(const char *path)
if (ret < 0)
return L_TIME_INVALID;
- return sb.st_mtim.tv_sec * 1000000 + sb.st_mtim.tv_nsec / 1000;
+ return (uint64_t) sb.st_mtim.tv_sec * 1000000 +
+ sb.st_mtim.tv_nsec / 1000;
}
/**
--
2.20.1
2 years, 2 months