[PATCH 1/3] icmp6: Add l_icmp6_router_get_address
by Andrew Zaborowski
Add a getter for the router's address and make a small formatting change
while there.
---
ell/ell.sym | 1 +
ell/icmp6.c | 15 ++++++++++++++-
ell/icmp6.h | 1 +
3 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/ell/ell.sym b/ell/ell.sym
index 1fbd98c..d7027e3 100644
--- a/ell/ell.sym
+++ b/ell/ell.sym
@@ -657,6 +657,7 @@ global:
l_icmp6_client_set_nodelay;
l_icmp6_client_set_rtnl;
l_icmp6_client_set_route_priority;
+ l_icmp6_router_get_address;
l_icmp6_router_get_managed;
l_icmp6_router_get_other;
/* acd */
diff --git a/ell/icmp6.c b/ell/icmp6.c
index fe8a506..ebdcabd 100644
--- a/ell/icmp6.c
+++ b/ell/icmp6.c
@@ -728,12 +728,25 @@ struct l_icmp6_router *_icmp6_router_parse(const struct nd_router_advert *ra,
}
opts += l;
- opts_len -= l ;
+ opts_len -= l;
}
return r;
}
+LIB_EXPORT char *l_icmp6_router_get_address(const struct l_icmp6_router *r)
+{
+ char buf[INET6_ADDRSTRLEN];
+
+ if (unlikely(!r))
+ return NULL;
+
+ if (!inet_ntop(AF_INET6, r->address, buf, sizeof(buf)))
+ return NULL;
+
+ return l_strdup(buf);
+}
+
LIB_EXPORT bool l_icmp6_router_get_managed(const struct l_icmp6_router *r)
{
if (unlikely(!r))
diff --git a/ell/icmp6.h b/ell/icmp6.h
index a6b1265..b2231c9 100644
--- a/ell/icmp6.h
+++ b/ell/icmp6.h
@@ -66,6 +66,7 @@ bool l_icmp6_client_set_rtnl(struct l_icmp6_client *client,
bool l_icmp6_client_set_route_priority(struct l_icmp6_client *client,
uint32_t priority);
+char *l_icmp6_router_get_address(const struct l_icmp6_router *r);
bool l_icmp6_router_get_managed(const struct l_icmp6_router *r);
bool l_icmp6_router_get_other(const struct l_icmp6_router *r);
--
2.30.2
10 months, 2 weeks
[PATCH] Add logging if bind function fails
by Michael Johnson
The bind function returns any errors it encounters but they were
silently being discarded in this method. This at least logs this if
debug messages are enabled.
In the future it would be nice to have this log even if the debug output
isn't enabled as DHCP will not be working correctly.
---
ell/dhcp.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/ell/dhcp.c b/ell/dhcp.c
index bd346cc..115325e 100644
--- a/ell/dhcp.c
+++ b/ell/dhcp.c
@@ -782,7 +782,7 @@ static void dhcp_client_rx_message(const void *data, size_t len, void *userdata)
uint8_t msg_type = 0;
uint8_t t, l;
const void *v;
- int r;
+ int r, e;
struct in_addr ia;
CLIENT_DEBUG("");
@@ -855,9 +855,14 @@ static void dhcp_client_rx_message(const void *data, size_t len, void *userdata)
l_timeout_remove(client->timeout_resend);
client->timeout_resend = NULL;
- if (client->transport->bind)
- client->transport->bind(client->transport,
+ if (client->transport->bind) {
+ e = client->transport->bind(client->transport,
client->lease->address);
+ if (e < 0) {
+ CLIENT_DEBUG("Failed to bind dhcp socket. "
+ "Error %d: %s", e, strerror(-e));
+ }
+ }
dhcp_client_event_notify(client, r);
--
2.25.1
10 months, 2 weeks
Unchecked dependancy on openssl
by Gix, Brian
Hi Denis and all,
Bringing up a new dev environment I noticed that ELL has a dependancy on openssl, to create some required *.pem
files. The existance of openssl on the system is not checked by the bootstrap-configure setup, and it probably
should be.
--Brian
10 months, 2 weeks
[PATCH 3/3] util: Add l_streq0
by Andrew Zaborowski
Add a glib/nm-utils -style utility for comparing two strings that
handles NULL values (unlike strcmp). Two NULL strings are treated as
equal.
---
ell/ell.sym | 1 +
ell/util.c | 13 +++++++++++++
ell/util.h | 1 +
3 files changed, 15 insertions(+)
diff --git a/ell/ell.sym b/ell/ell.sym
index add7fef..4391051 100644
--- a/ell/ell.sym
+++ b/ell/ell.sym
@@ -12,6 +12,7 @@ global:
l_strlcpy;
l_str_has_prefix;
l_str_has_suffix;
+ l_streq0;
l_util_hexstring;
l_util_hexstring_upper;
l_util_from_hexstring;
diff --git a/ell/util.c b/ell/util.c
index 531b49e..5fb1a43 100644
--- a/ell/util.c
+++ b/ell/util.c
@@ -342,6 +342,19 @@ LIB_EXPORT bool l_str_has_suffix(const char *str, const char *suffix)
return !strcmp(&str[len_diff], suffix);
}
+/**
+ * l_streq0:
+ * @a: First operand
+ * @b: Second operand
+ *
+ * Returns: True if @a and @b are both NULL or both non-NULL and identical
+ * according to strcmp. False otherwise.
+ */
+LIB_EXPORT bool l_streq0(const char *a, const char *b)
+{
+ return a == b || (a && b && !strcmp(a, b));
+}
+
static char *hexstring_common(const unsigned char *buf, size_t len,
const char hexdigits[static 16])
{
diff --git a/ell/util.h b/ell/util.h
index bdf6935..d56c2a5 100644
--- a/ell/util.h
+++ b/ell/util.h
@@ -276,6 +276,7 @@ size_t l_strlcpy(char* dst, const char *src, size_t len);
bool l_str_has_prefix(const char *str, const char *prefix);
bool l_str_has_suffix(const char *str, const char *suffix);
+bool l_streq0(const char *a, const char *b);
char *l_util_hexstring(const unsigned char *buf, size_t len);
char *l_util_hexstring_upper(const unsigned char *buf, size_t len);
--
2.30.2
10 months, 2 weeks
[PATCH 1/2] ell: avoid using inet_ntoa()
by Davide Caratti
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
11 months
[PATCH] dhcp-server: Simplify timeout handling
by Andrew Zaborowski
Remove max timeout interval checks no longer useful after
the l_timeout_modify_ms() parameter type change.
---
ell/dhcp-server.c | 15 ++-------------
1 file changed, 2 insertions(+), 13 deletions(-)
diff --git a/ell/dhcp-server.c b/ell/dhcp-server.c
index b58b2f6..34512ae 100644
--- a/ell/dhcp-server.c
+++ b/ell/dhcp-server.c
@@ -225,15 +225,9 @@ static void set_next_expire_timer(struct l_dhcp_server *server,
uint64_t expiry = get_lease_expiry_time(next);
uint64_t now = l_time_now();
uint64_t next_timeout = l_time_after(expiry, now) ?
- expiry - now : 0;
- uint64_t next_timeout_ms = l_time_to_msecs(next_timeout) ?: 1;
+ l_time_to_msecs(expiry - now) : 0;
- if (L_WARN_ON(next_timeout_ms >
- server->lease_seconds * L_MSEC_PER_SEC))
- next_timeout_ms =
- server->lease_seconds * L_MSEC_PER_SEC;
-
- l_timeout_modify_ms(server->next_expire, next_timeout_ms);
+ l_timeout_modify_ms(server->next_expire, next_timeout ?: 1);
} else
server->next_expire = l_timeout_create(
server->lease_seconds,
@@ -246,11 +240,6 @@ static void lease_expired_cb(struct l_timeout *timeout, void *user_data)
struct l_dhcp_server *server = user_data;
struct l_dhcp_lease *lease = l_queue_peek_tail(server->lease_list);
- if (!is_expired_lease(lease)) {
- set_next_expire_timer(server, NULL);
- return;
- }
-
if (server->event_handler)
server->event_handler(server, L_DHCP_SERVER_EVENT_LEASE_EXPIRED,
server->user_data, lease);
--
2.30.2
11 months, 1 week
[PATCH 0/2] avoid using inet_ntoa() and inet_aton()
by Davide Caratti
some static checkers, like rpminspect, complain about use of "forbidden"
functions inet_aton() and inet_ntoa(). Use inet_pton() and inet_ntop()
instead.
Davide Caratti (2):
avoid using inet_ntoa()
avoid using inet_aton()
ell/acd.c | 5 +++--
ell/dhcp-lease.c | 3 ++-
ell/dhcp-server.c | 25 ++++++++++++++-----------
ell/dhcp.c | 17 +++++++++++++++--
ell/rtnl.c | 7 +++++--
examples/https-server-test.c | 4 +++-
6 files changed, 42 insertions(+), 19 deletions(-)
--
2.31.1
11 months, 1 week
[PATCH 1/2] dhcp-server: Fix lease expiry time calculation
by Andrew Zaborowski
We were comparing the l_time_now() (usecs) to lease->lifetime (secs)
and then converting the result from usecs to secs, so the "diff" and the
"to_secs" operations need to be switched around. While there, use the
opportunity to replace the "diff" operation so that if lease->lifetime is
already in the past (e.g. because processing took to long), we schedule
the timeout in 1 millisec instead of the absolute value of the difference.
---
ell/dhcp-server.c | 24 ++++++++++++++----------
1 file changed, 14 insertions(+), 10 deletions(-)
diff --git a/ell/dhcp-server.c b/ell/dhcp-server.c
index 50855fe..3d6a6a8 100644
--- a/ell/dhcp-server.c
+++ b/ell/dhcp-server.c
@@ -191,7 +191,6 @@ static void set_next_expire_timer(struct l_dhcp_server *server,
struct l_dhcp_lease *expired)
{
struct l_dhcp_lease *next;
- unsigned int next_timeout;
/*
* If this is an expiring lease put it into the expired queue, removing
@@ -214,15 +213,20 @@ static void set_next_expire_timer(struct l_dhcp_server *server,
return;
}
- next_timeout = l_time_to_secs(l_time_diff(l_time_now(),
- next->lifetime));
-
- if (server->next_expire)
- l_timeout_modify(server->next_expire, next_timeout);
- else
- server->next_expire = l_timeout_create(server->lease_seconds,
- lease_expired_cb,
- server, NULL);
+ if (server->next_expire) {
+ uint32_t now = l_time_to_secs(l_time_now());
+
+ if (l_time_after(next->lifetime, now)) {
+ unsigned int next_timeout = next->lifetime - now;
+
+ l_timeout_modify(server->next_expire, next_timeout);
+ } else
+ l_timeout_modify_ms(server->next_expire, 1);
+ } else
+ server->next_expire = l_timeout_create(
+ server->lease_seconds,
+ lease_expired_cb,
+ server, NULL);
}
static void lease_expired_cb(struct l_timeout *timeout, void *user_data)
--
2.30.2
11 months, 1 week
[PATCH] dhcp-server: Fix lease expiry time calculation
by Andrew Zaborowski
We were comparing the l_time_now() (usecs) to lease->lifetime (secs)
and then converting the result from usecs to secs, so the "diff" and the
"to_secs" operations need to be switched around. While there, use the
opportunity to replace the "diff" operation so that if lease->lifetime is
already in the past (e.g. because processing took to long), we schedule
the timeout in 1 millisec instead of the absolute value of the difference.
Since we're using uint32_t for the timestamps, use the overflow-safe(r)
comparisons in set_next_expire_timer and in is_expired_lease.
---
ell/dhcp-server.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/ell/dhcp-server.c b/ell/dhcp-server.c
index ebd4438..38193a2 100644
--- a/ell/dhcp-server.c
+++ b/ell/dhcp-server.c
@@ -104,7 +104,7 @@ struct l_dhcp_server {
static bool is_expired_lease(struct l_dhcp_lease *lease)
{
- if (lease->lifetime < l_time_to_secs(l_time_now()))
+ if ((int32_t) (lease->lifetime - l_time_to_secs(l_time_now())) < 0)
return true;
return false;
@@ -191,7 +191,8 @@ static void set_next_expire_timer(struct l_dhcp_server *server,
struct l_dhcp_lease *expired)
{
struct l_dhcp_lease *next;
- unsigned int next_timeout;
+ unsigned long next_timeout;
+ uint32_t now;
/*
* If this is an expiring lease put it into the expired queue, removing
@@ -214,11 +215,12 @@ static void set_next_expire_timer(struct l_dhcp_server *server,
return;
}
- next_timeout = l_time_to_secs(l_time_diff(l_time_now(),
- next->lifetime));
+ now = l_time_to_secs(l_time_now());
+ next_timeout = (int32_t) (next->lifetime - now) > 0 ?
+ (next->lifetime - now) * 1000L : 1;
if (server->next_expire)
- l_timeout_modify(server->next_expire, next_timeout);
+ l_timeout_modify_ms(server->next_expire, next_timeout);
else
server->next_expire = l_timeout_create(server->lease_seconds,
lease_expired_cb,
--
2.30.2
11 months, 2 weeks
[PATCH] dhcp: Fix address endianness in l2_send
by Andrew Zaborowski
dhcp_set_ip_udp_headers was unnecessarily trying to convert saddr and
daddr from host byte order to network order, the addresses are already
passsed in network byte order by the current 2 callers. This wasn't
breaking normal dhcp but could break P2P where the DHCP OFFER and ACK
source address is used by the client:
DHCPOFFER of 192.168.1.2 from 1.1.168.192
---
ell/dhcp-transport.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/ell/dhcp-transport.c b/ell/dhcp-transport.c
index c42bf45..68108e2 100644
--- a/ell/dhcp-transport.c
+++ b/ell/dhcp-transport.c
@@ -169,8 +169,8 @@ static void dhcp_set_ip_udp_headers(struct iphdr *ip, struct udphdr *udp,
ip->tot_len = L_CPU_TO_BE16(len + sizeof(*ip) + sizeof(*udp));
ip->protocol = IPPROTO_UDP;
- ip->saddr = L_CPU_TO_BE32(saddr);
- ip->daddr = L_CPU_TO_BE32(daddr);
+ ip->saddr = saddr;
+ ip->daddr = daddr;
udp->source = L_CPU_TO_BE16(sport);
udp->dest = L_CPU_TO_BE16(dport);
--
2.30.2
11 months, 2 weeks