In the following case:
union ct_addr {
unsigned int ipv4;
struct in6_addr ipv6;
};
union ct_addr zero_ip = {0};
The ipv6 field might not be properly initialized.
For instance, clang 18.1.1 does not initialize the ipv6 field.
Reported-at: https://issues.redhat.com/browse/FDP-608
Signed-off-by: Xavier Simonart
---
v2: updated based on nit from Paolo.
---
lib/conntrack.c | 9 +++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/lib/conntrack.c b/lib/conntrack.c
index 16e1c8bb5..655b87ba9 100644
--- a/lib/conntrack.c
+++ b/lib/conntrack.c
@@ -2302,7 +2302,8 @@ find_addr(const struct conn_key *key, union ct_addr *min,
uint32_t hash, bool ipv4,
const struct nat_action_info_t *nat_info)
{
-const union ct_addr zero_ip = {0};
+union ct_addr zero_ip;
+memset(&zero_ip, 0, sizeof zero_ip);
/* All-zero case. */
if (!memcmp(min, &zero_ip, sizeof *min)) {
@@ -2394,14 +2395,18 @@ nat_get_unique_tuple(struct conntrack *ct, struct conn
*conn,
{
struct conn_key *fwd_key = &conn->key_node[CT_DIR_FWD].key;
struct conn_key *rev_key = &conn->key_node[CT_DIR_REV].key;
-union ct_addr min_addr = {0}, max_addr = {0}, addr = {0};
bool pat_proto = fwd_key->nw_proto == IPPROTO_TCP ||
fwd_key->nw_proto == IPPROTO_UDP ||
fwd_key->nw_proto == IPPROTO_SCTP;
uint16_t min_dport, max_dport, curr_dport;
uint16_t min_sport, max_sport, curr_sport;
+union ct_addr min_addr, max_addr, addr;
uint32_t hash, port_off, basis;
+memset(&min_addr, 0, sizeof min_addr);
+memset(&max_addr, 0, sizeof max_addr);
+memset(&addr, 0, sizeof addr);
+
basis = (nat_info->nat_flags & NAT_PERSISTENT) ? 0 : ct->hash_basis;
hash = nat_range_hash(fwd_key, basis, nat_info);
--
2.31.1
___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev