Compare commits

...

No commits in common. "c9-beta" and "c10s" have entirely different histories.

10 changed files with 177 additions and 336 deletions

2
.gitignore vendored
View File

@ -1 +1 @@
SOURCES/ell-0.41.tar.xz
/ell-*.tar.xz

View File

@ -1 +0,0 @@
e551e9576123b2519b547ad31e305c710ab2fa63 SOURCES/ell-0.41.tar.xz

View File

@ -1,33 +0,0 @@
From 4097c1b862eb59f7110d097df7f719d00869191d Mon Sep 17 00:00:00 2001
Message-Id: <4097c1b862eb59f7110d097df7f719d00869191d.1624267112.git.davide.caratti@gmail.com>
From: Davide Caratti <davide.caratti@gmail.com>
Date: Wed, 16 Jun 2021 21:22:15 +0200
Subject: [PATCH 1/2] examples: avoid using inet_ntoa()
---
examples/https-server-test.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/examples/https-server-test.c b/examples/https-server-test.c
index 6362722..b626fd2 100644
--- a/examples/https-server-test.c
+++ b/examples/https-server-test.c
@@ -199,12 +199,13 @@ int main(int argc, char *argv[])
https_tls_ready, https_tls_disconnected, NULL);
if (getenv("TLS_DEBUG")) {
+ char buf[INET_ADDRSTRLEN];
char *str;
l_tls_set_debug(tls, https_tls_debug_cb, NULL, NULL);
- str = l_strdup_printf("/tmp/ell-certchain-%s.pem",
- inet_ntoa(client_addr.sin_addr));
+ inet_ntop(AF_INET,&client_addr.sin_addr, buf, INET_ADDRSTRLEN);
+ str = l_strdup_printf("/tmp/ell-certchain-%s.pem", buf);
l_tls_set_cert_dump_path(tls, str);
l_free(str);
}
--
2.31.1

View File

@ -1,269 +0,0 @@
From e2fa5ae4d6eec61d7ca80e07269f86235cef8d60 Mon Sep 17 00:00:00 2001
Message-Id: <e2fa5ae4d6eec61d7ca80e07269f86235cef8d60.1624267112.git.davide.caratti@gmail.com>
In-Reply-To: <4097c1b862eb59f7110d097df7f719d00869191d.1624267112.git.davide.caratti@gmail.com>
References: <4097c1b862eb59f7110d097df7f719d00869191d.1624267112.git.davide.caratti@gmail.com>
From: Davide Caratti <davide.caratti@gmail.com>
Date: Wed, 16 Jun 2021 21:22:14 +0200
Subject: [PATCH 2/2] ell: avoid using inet_ntoa()
static checkers (like rpminspect) complain about use of inet_ntoa(), as
it relies on a static buffer. Fix this as follows:
- use inet_ntop() with a buffer of size INET_ADDRSTRLEN allocated in
the stack, similarly to what it is already done for IPv6 addresses
- convert IP_STR() to use NIPQUAD() / NIPQUAD_FMT, similarly to what
is done with MAC addresses
---
ell/acd.c | 28 +++++++++++++---------------
ell/dhcp-lease.c | 3 ++-
ell/dhcp-server.c | 37 ++++++++++++++++++-------------------
ell/dhcp.c | 6 ++++--
ell/rtnl.c | 7 +++++--
5 files changed, 42 insertions(+), 39 deletions(-)
diff --git a/ell/acd.c b/ell/acd.c
index 6989f82..4216898 100644
--- a/ell/acd.c
+++ b/ell/acd.c
@@ -55,14 +55,11 @@
#define MAC "%02x:%02x:%02x:%02x:%02x:%02x"
#define MAC_STR(a) a[0], a[1], a[2], a[3], a[4], a[5]
-#define IP_STR(uint_ip) \
-({ \
- struct in_addr _in; \
- char *_out; \
- _in.s_addr = uint_ip; \
- _out = inet_ntoa(_in); \
- _out; \
-})
+#define NIPQUAD_FMT "%u.%u.%u.%u"
+#define NIPQUAD(u32_ip) ((unsigned char *) &u32_ip)[0], \
+ ((unsigned char *) &u32_ip)[1], \
+ ((unsigned char *) &u32_ip)[2], \
+ ((unsigned char *) &u32_ip)[3]
#define ACD_DEBUG(fmt, args...) \
l_util_debug(acd->debug_handler, acd->debug_data, \
@@ -146,7 +143,8 @@ static int acd_send_packet(struct l_acd *acd, uint32_t source_ip)
p.arp_pln = 4;
p.arp_op = htons(ARPOP_REQUEST);
- ACD_DEBUG("sending packet with target IP %s", IP_STR(acd->ip));
+ ACD_DEBUG("sending packet with target IP "NIPQUAD_FMT,
+ NIPQUAD(acd->ip));
memcpy(&p.arp_sha, acd->mac, ETH_ALEN);
memcpy(&p.arp_spa, &source_ip, sizeof(p.arp_spa));
@@ -165,8 +163,8 @@ static void announce_wait_timeout(struct l_timeout *timeout, void *user_data)
struct l_acd *acd = user_data;
if (acd->state == ACD_STATE_PROBE) {
- ACD_DEBUG("No conflicts found for %s, announcing address",
- IP_STR(acd->ip));
+ ACD_DEBUG("No conflicts found for "NIPQUAD_FMT ", announcing address",
+ NIPQUAD(acd->ip));
acd->state = ACD_STATE_ANNOUNCED;
@@ -284,17 +282,17 @@ static bool acd_read_handler(struct l_io *io, void *user_data)
!memcmp(arp.arp_tpa, &acd->ip, sizeof(uint32_t));
if (!source_conflict && !target_conflict) {
- ACD_DEBUG("No target or source conflict detected for %s",
- IP_STR(acd->ip));
+ ACD_DEBUG("No target or source conflict detected for "NIPQUAD_FMT,
+ NIPQUAD(acd->ip));
return true;
}
switch (acd->state) {
case ACD_STATE_PROBE:
/* No reason to continue probing */
- ACD_DEBUG("%s conflict detected for %s",
+ ACD_DEBUG("%s conflict detected for "NIPQUAD_FMT,
target_conflict ? "Target" : "Source",
- IP_STR(acd->ip));
+ NIPQUAD(acd->ip));
if (acd->event_func)
acd->event_func(L_ACD_EVENT_CONFLICT, acd->user_data);
diff --git a/ell/dhcp-lease.c b/ell/dhcp-lease.c
index 44c815f..94b67b4 100644
--- a/ell/dhcp-lease.c
+++ b/ell/dhcp-lease.c
@@ -178,12 +178,13 @@ error:
static inline char *get_ip(uint32_t ip)
{
struct in_addr addr;
+ char buf[INET_ADDRSTRLEN];
if (ip == 0)
return NULL;
addr.s_addr = ip;
- return l_strdup(inet_ntoa(addr));
+ return l_strdup(inet_ntop(AF_INET, &addr, buf, INET_ADDRSTRLEN));
}
LIB_EXPORT char *l_dhcp_lease_get_address(const struct l_dhcp_lease *lease)
diff --git a/ell/dhcp-server.c b/ell/dhcp-server.c
index 34512ae..4a6b3f6 100644
--- a/ell/dhcp-server.c
+++ b/ell/dhcp-server.c
@@ -92,14 +92,11 @@ struct l_dhcp_server {
#define MAC "%02x:%02x:%02x:%02x:%02x:%02x"
#define MAC_STR(a) a[0], a[1], a[2], a[3], a[4], a[5]
-#define IP_STR(uint_ip) \
-({ \
- struct in_addr _in; \
- char *_out; \
- _in.s_addr = uint_ip; \
- _out = inet_ntoa(_in); \
- _out; \
-})
+#define NIPQUAD_FMT "%u.%u.%u.%u"
+#define NIPQUAD(u32_ip) ((unsigned char *) &u32_ip)[0], \
+ ((unsigned char *) &u32_ip)[1], \
+ ((unsigned char *) &u32_ip)[2], \
+ ((unsigned char *) &u32_ip)[3]
#define SERVER_DEBUG(fmt, args...) \
l_util_debug(server->debug_handler, server->debug_data, \
@@ -286,8 +283,8 @@ static struct l_dhcp_lease *add_lease(struct l_dhcp_server *server,
l_queue_push_head(server->lease_list, lease);
}
- SERVER_DEBUG("added lease IP %s for "MAC " lifetime=%u",
- IP_STR(yiaddr), MAC_STR(chaddr),
+ SERVER_DEBUG("added lease IP "NIPQUAD_FMT " for "MAC " lifetime=%u",
+ NIPQUAD(yiaddr), MAC_STR(chaddr),
server->lease_seconds);
return lease;
@@ -477,8 +474,8 @@ static void send_offer(struct l_dhcp_server *server,
_dhcp_message_builder_finalize(&builder, &len);
- SERVER_DEBUG("Sending OFFER of %s to "MAC, IP_STR(reply->yiaddr),
- MAC_STR(reply->chaddr));
+ SERVER_DEBUG("Sending OFFER of "NIPQUAD_FMT " to "MAC,
+ NIPQUAD(reply->yiaddr), MAC_STR(reply->chaddr));
if (server->transport->l2_send(server->transport, server->address,
DHCP_PORT_SERVER,
@@ -561,7 +558,7 @@ static void send_ack(struct l_dhcp_server *server,
_dhcp_message_builder_finalize(&builder, &len);
- SERVER_DEBUG("Sending ACK to %s", IP_STR(reply->yiaddr));
+ SERVER_DEBUG("Sending ACK to "NIPQUAD_FMT, NIPQUAD(reply->yiaddr));
if (server->transport->l2_send(server->transport, server->address,
DHCP_PORT_SERVER, reply->ciaddr,
@@ -628,15 +625,15 @@ static void listener_event(const void *data, size_t len, void *user_data)
switch (type) {
case DHCP_MESSAGE_TYPE_DISCOVER:
- SERVER_DEBUG("Received DISCOVER, requested IP %s",
- IP_STR(requested_ip_opt));
+ SERVER_DEBUG("Received DISCOVER, requested IP "NIPQUAD_FMT,
+ NIPQUAD(requested_ip_opt));
send_offer(server, message, lease, requested_ip_opt);
break;
case DHCP_MESSAGE_TYPE_REQUEST:
- SERVER_DEBUG("Received REQUEST, requested IP %s",
- IP_STR(requested_ip_opt));
+ SERVER_DEBUG("Received REQUEST, requested IP "NIPQUAD_FMT,
+ NIPQUAD(requested_ip_opt));
if (requested_ip_opt == 0) {
requested_ip_opt = message->ciaddr;
@@ -760,6 +757,7 @@ LIB_EXPORT void l_dhcp_server_destroy(struct l_dhcp_server *server)
LIB_EXPORT bool l_dhcp_server_start(struct l_dhcp_server *server)
{
+ char buf[INET_ADDRSTRLEN];
struct in_addr ia;
if (unlikely(!server))
@@ -846,11 +844,12 @@ LIB_EXPORT bool l_dhcp_server_start(struct l_dhcp_server *server)
l_acd_set_defend_policy(server->acd, L_ACD_DEFEND_POLICY_INFINITE);
ia.s_addr = server->address;
+ inet_ntop(AF_INET, &ia, buf, INET_ADDRSTRLEN);
/* In case of unit testing we don't want this to be a fatal error */
- if (!l_acd_start(server->acd, inet_ntoa(ia))) {
+ if (!l_acd_start(server->acd, buf)) {
SERVER_DEBUG("Failed to start ACD on %s, continuing without",
- IP_STR(server->address));
+ buf);
l_acd_destroy(server->acd);
server->acd = NULL;
diff --git a/ell/dhcp.c b/ell/dhcp.c
index fff1645..bd346cc 100644
--- a/ell/dhcp.c
+++ b/ell/dhcp.c
@@ -778,6 +778,7 @@ static void dhcp_client_rx_message(const void *data, size_t len, void *userdata)
struct l_dhcp_client *client = userdata;
const struct dhcp_message *message = data;
struct dhcp_message_iter iter;
+ char buf[INET_ADDRSTRLEN];
uint8_t msg_type = 0;
uint8_t t, l;
const void *v;
@@ -911,11 +912,12 @@ static void dhcp_client_rx_message(const void *data, size_t len, void *userdata)
l_acd_set_skip_probes(client->acd, true);
ia.s_addr = client->lease->address;
+ inet_ntop(AF_INET, &ia, buf, INET_ADDRSTRLEN);
/* For unit testing we don't want this to be a fatal error */
- if (!l_acd_start(client->acd, inet_ntoa(ia))) {
+ if (!l_acd_start(client->acd, buf)) {
CLIENT_DEBUG("Failed to start ACD on %s, continuing",
- inet_ntoa(ia));
+ buf);
l_acd_destroy(client->acd);
client->acd = NULL;
}
diff --git a/ell/rtnl.c b/ell/rtnl.c
index 957e749..2983013 100644
--- a/ell/rtnl.c
+++ b/ell/rtnl.c
@@ -752,6 +752,7 @@ LIB_EXPORT uint32_t l_rtnl_set_powered(struct l_netlink *rtnl, int ifindex,
LIB_EXPORT void l_rtnl_ifaddr4_extract(const struct ifaddrmsg *ifa, int bytes,
char **label, char **ip, char **broadcast)
{
+ char buf[INET_ADDRSTRLEN];
struct in_addr in_addr;
struct rtattr *attr;
@@ -763,7 +764,8 @@ LIB_EXPORT void l_rtnl_ifaddr4_extract(const struct ifaddrmsg *ifa, int bytes,
break;
in_addr = *((struct in_addr *) RTA_DATA(attr));
- *ip = l_strdup(inet_ntoa(in_addr));
+ *ip = l_strdup(inet_ntop(AF_INET, &in_addr, buf,
+ INET_ADDRSTRLEN));
break;
case IFA_BROADCAST:
@@ -771,7 +773,8 @@ LIB_EXPORT void l_rtnl_ifaddr4_extract(const struct ifaddrmsg *ifa, int bytes,
break;
in_addr = *((struct in_addr *) RTA_DATA(attr));
- *broadcast = l_strdup(inet_ntoa(in_addr));
+ *broadcast = l_strdup(inet_ntop(AF_INET, &in_addr, buf,
+ INET_ADDRSTRLEN));
break;
case IFA_LABEL:
--
2.31.1

View File

@ -1,12 +0,0 @@
diff --git a/examples/acd-client.c b/examples/acd-client.c
index e737288..71e14ef 100644
--- a/examples/acd-client.c
+++ b/examples/acd-client.c
@@ -107,7 +107,6 @@ int main(int argc, char *argv[])
bool no_probe = false;
l_log_set_stderr();
- l_debug_enable("*");
if (argc < 3) {
usage();

6
gating.yaml Normal file
View File

@ -0,0 +1,6 @@
--- !Policy
product_versions:
- rhel-10
decision_context: osci_compose_gate
rules:
- !PassingTestCaseRule {test_case_name: osci.brew-build.tier0.functional}

View File

@ -1,15 +1,11 @@
Name: libell
Version: 0.41
Release: 4%{?dist}
Version: 0.62
Release: 2%{?dist}
Summary: Embedded Linux library
License: LGPLv2+
License: LGPL-2.0-or-later
URL: https://01.org/ell
Source0: https://www.kernel.org/pub/linux/libs/ell/ell-%{version}.tar.xz
Patch0: acd-client-nodebug.patch
Patch1: 0001-examples-avoid-using-inet_ntoa.patch
Patch2: 0002-ell-avoid-using-inet_ntoa.patch
BuildRequires: gcc
BuildRequires: make
@ -60,23 +56,95 @@ find %{buildroot} -type f -name "*.la" -delete
%changelog
* Mon Aug 09 2021 Mohan Boddu <mboddu@redhat.com> - 0.41-4
- Rebuilt for IMA sigs, glibc 2.34, aarch64 flags
Related: rhbz#1991688
* Mon Jun 24 2024 Troy Dawson <tdawson@redhat.com> - 0.62-2
- Bump release for June 2024 mass rebuild
* Thu Jun 24 2021 Davide Caratti <dcaratti@redhat.com> - 0.41-3
- bump NVR to trigger CI
* Sat Feb 10 2024 Peter Robinson <pbrobinson@fedoraproject.org> - 0.62-1
- Update to 0.62
* Thu Jun 24 2021 Davide Caratti <dcaratti@redhat.com> - 0.41-2
- add gating test that uses acd-client.c. Related: rhbz#1973511
- drop tests dependency on libell-devel. Related: rhbz#1973511
* Thu Jan 25 2024 Fedora Release Engineering <releng@fedoraproject.org> - 0.61-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild
* Mon Jun 21 2021 Davide Caratti <dcaratti@redhat.com> - 0.41-1
- Avoid use of inet_ntoa(). Related: rhbz#1967524
- Update to 0.41. Related: rhbz#1967524
* Sun Jan 21 2024 Fedora Release Engineering <releng@fedoraproject.org> - 0.61-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild
* Fri Apr 16 2021 Mohan Boddu <mboddu@redhat.com> - 0.39-2
- Rebuilt for RHEL 9 BETA on Apr 15th 2021. Related: rhbz#1947937
* Mon Jan 8 2024 Davide Caratti <dcaratti@redhat.com> - 0.61-2
- Change specfile to use SPDX identifier
* Sat Dec 16 2023 Peter Robinson <pbrobinson@fedoraproject.org> - 0.61-1
- Update to 0.61
* Mon Nov 20 2023 Peter Robinson <pbrobinson@fedoraproject.org> - 0.60-1
- Update to 0.60
* Fri Sep 29 2023 Peter Robinson <pbrobinson@fedoraproject.org> - 0.59-1
- Update to 0.59
* Fri Aug 25 2023 Peter Robinson <pbrobinson@fedoraproject.org> - 0.58-1
- Update to 0.58
* Thu Jul 20 2023 Fedora Release Engineering <releng@fedoraproject.org> - 0.57-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild
* Sun May 28 2023 Peter Robinson <pbrobinson@fedoraproject.org> - 0.57-1
- Update to 0.57
* Tue Jan 24 2023 Peter Robinson <pbrobinson@fedoraproject.org> - 0.56-1
- Update to 0.56
* Thu Jan 19 2023 Fedora Release Engineering <releng@fedoraproject.org> - 0.55-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild
* Mon Dec 19 2022 Peter Robinson <pbrobinson@fedoraproject.org> - 0.55-1
- Update to 0.55
* Sat Nov 19 2022 Peter Robinson <pbrobinson@fedoraproject.org> - 0.54-1
- Update to 0.54
* Thu Jul 28 2022 Peter Robinson <pbrobinson@fedoraproject.org> - 0.52-1
- Update to 0.52
* Thu Jul 21 2022 Fedora Release Engineering <releng@fedoraproject.org> - 0.50-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild
* Sun May 15 2022 Peter Robinson <pbrobinson@fedoraproject.org> - 0.50-1
- Update to 0.50
* Sat Mar 26 2022 Peter Robinson <pbrobinson@fedoraproject.org> - 0.49-2
- Update to 0.49
* Sat Feb 12 2022 Peter Robinson <pbrobinson@fedoraproject.org> - 0.48-1
- Update to 0.48
* Thu Jan 20 2022 Fedora Release Engineering <releng@fedoraproject.org> - 0.47-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild
* Wed Jan 05 2022 Peter Robinson <pbrobinson@fedoraproject.org> - 0.47-1
- Update to 0.47
* Sat Dec 11 2021 Peter Robinson <pbrobinson@fedoraproject.org> - 0.46-1
- Update to 0.46
* Sun Nov 07 2021 Peter Robinson <pbrobinson@fedoraproject.org> - 0.45-1
- Update to 0.45
* Sun Sep 19 2021 Peter Robinson <pbrobinson@fedoraproject.org> - 0.44-1
- Update to 0.44
* Sun Aug 22 2021 Peter Robinson <pbrobinson@fedoraproject.org> - 0.43-1
- Update to 0.43
* Sat Aug 07 2021 Peter Robinson <pbrobinson@fedoraproject.org> - 0.42-1
- Update to 0.42
* Thu Jul 22 2021 Fedora Release Engineering <releng@fedoraproject.org> - 0.41-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild
* Tue Jun 15 2021 Peter Robinson <pbrobinson@fedoraproject.org> - 0.41-1
- Update to 0.41
* Sat May 15 2021 Peter Robinson <pbrobinson@fedoraproject.org> - 0.40-1
- Update to 0.40
* Tue Mar 30 2021 Peter Robinson <pbrobinson@fedoraproject.org> - 0.39-1
- Update to 0.39

1
sources Normal file
View File

@ -0,0 +1 @@
SHA512 (ell-0.62.tar.xz) = f0019cddba737879f2567b0295ec4cdf8589b989fdaba70a885253140f742e67e33abfe25fabbf8ecfd5c61336ec9cfe359193e0579b9120a66b13e9593beabf

64
tests/sanity/acd-test.sh Executable file
View File

@ -0,0 +1,64 @@
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
#
# Copyright (C) 2015-2019 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved.
# ┌─────────────────────┐ ┌─────────────────────┐
# │ $netns0 │ │ $netns1 │
# │ │ │ │
# │┌────────┐ │ │ ┌────────┐│
# ││ eth0 │───────────┼────┼───────────│ eth0 ││
# │├────────┴──────────┐│ │┌──────────┴────────┤│
# ││192.0.2.1/24 ││ ││192.0.2.1/24 ││
# ││ping ││ ││ACD daemon ││
# │└───────────────────┘│ │└───────────────────┘│
# └─────────────────────┘ └─────────────────────┘
set -e
exec 3>&1
export LANG=C
netns0="ell-test-$$-0"
netns1="ell-test-$$-1"
pretty() { echo -e "\x1b[32m\x1b[1m[+] ${1:+NS$1: }${2}\x1b[0m" >&3; }
pp() { pretty "" "$*"; "$@"; }
maybe_exec() { if [[ $BASHPID -eq $$ ]]; then "$@"; else exec "$@"; fi; }
n0() { pretty 0 "$*"; maybe_exec ip netns exec $netns0 "$@"; }
n1() { pretty 1 "$*"; maybe_exec ip netns exec $netns1 "$@"; }
ip0() { pretty 0 "ip $*"; ip -n $netns0 "$@"; }
ip1() { pretty 1 "ip $*"; ip -n $netns1 "$@"; }
slp() { read -t "$1" -N 1 || true; }
do_cleanup() {
set +e
exec 2>/dev/null
pp pkill ell-acd-client
pp ip netns del $netns1
pp ip netns del $netns0
pp rm /tmp/tmp/acd-$$.log
}
trap do_cleanup EXIT
pkill ell-acd-client || true
ip netns del $netns0 2>/dev/null || true
ip netns del $netns1 2>/dev/null || true
pp ip netns add $netns0
pp ip netns add $netns1
ip0 link set dev lo up
ip0 link add name eth0 type veth peer name eth0 netns $netns1
ip0 link set dev eth0 up
ip1 link set dev lo up
ip1 link set dev eth0 up
idx="$(ip1 -j link show dev eth0 | jq '.[0].ifindex')"
n1 ./ell-acd-client $idx 192.0.2.1 -d -D defend -n 1>/tmp/acd-$$.log 2>&1 &
slp 5
ip0 address add dev eth0 192.0.2.1/24
n0 ping 192.0.2.2 -I eth0 -c5 -w5 -q || true
slp 5
pp cat /tmp/acd-$$.log
pp grep 'IP 192.0.2.1 has been lost' /tmp/acd-$$.log

17
tests/tests.yml Normal file
View File

@ -0,0 +1,17 @@
- hosts: localhost
tags:
- classic
roles:
- role: standard-test-source
- role: standard-test-basic
required_packages:
- gcc
- jq
- iproute
tests:
- build-tests:
dir: ./source/examples
run: gcc acd-client.c -I.. -lell -o ell-acd-client && cp ../../sanity/acd-test.sh .
- sanity-tests:
dir: ./source/examples
run: ./acd-test.sh