diff --git a/src/dp_firewall.c b/src/dp_firewall.c index d61d9981f..d2f59075e 100644 --- a/src/dp_firewall.c +++ b/src/dp_firewall.c @@ -74,10 +74,10 @@ int dp_list_firewall_rules(const struct dp_port *port, struct dp_grpc_responder return DP_GRPC_OK; } -static __rte_always_inline void dp_apply_ipv6_mask(const uint8_t *addr, const uint8_t *mask, uint8_t *result) { - for (int i = 0; i < DP_IPV6_ADDR_SIZE; i++) { - result[i] = addr[i] & mask[i]; - } +static __rte_always_inline void dp_apply_ipv6_mask(const uint8_t *addr, const uint8_t *mask, uint8_t *result) +{ + for (int i = 0; i < DP_IPV6_ADDR_SIZE; i++) + result[i] = addr[i] & mask[i]; } static __rte_always_inline bool dp_is_rule_matching(const struct dp_fwall_rule *rule, @@ -144,7 +144,7 @@ static __rte_always_inline bool dp_is_rule_matching(const struct dp_fwall_rule * return false; } - return ( is_ip_match && + return (is_ip_match && ((src_port_lower == DP_FWALL_MATCH_ANY_PORT) || (src_port >= src_port_lower && src_port <= src_port_upper)) && ((dst_port_lower == DP_FWALL_MATCH_ANY_PORT) || diff --git a/src/dp_nat.c b/src/dp_nat.c index 0b9b91c94..d179f8485 100644 --- a/src/dp_nat.c +++ b/src/dp_nat.c @@ -300,18 +300,18 @@ void dp_nat_chg_ip(struct dp_flow *df, struct rte_ipv4_hdr *ipv4_hdr, static void dp_calculate_icmp_checksum(struct rte_icmp_hdr *icmp_hdr, size_t icmp_len) { uint32_t sum = 0; + uint16_t word; uint8_t *ptr = (uint8_t *)icmp_hdr; icmp_hdr->icmp_cksum = 0; for (size_t i = 0; i < icmp_len; i += 2) { - uint16_t word = (uint16_t)((uint16_t)ptr[i] | ((uint16_t)ptr[i + 1] << 8)); + word = (uint16_t)((uint16_t)ptr[i] | ((uint16_t)ptr[i + 1] << 8)); sum += word; } - while (sum >> 16) { + while (sum >> 16) sum = (sum & 0xFFFF) + (sum >> 16); - } icmp_hdr->icmp_cksum = ~((uint16_t)sum); } diff --git a/src/grpc/dp_grpc_conv.cpp b/src/grpc/dp_grpc_conv.cpp index 1dc51d8cc..9c8086f15 100644 --- a/src/grpc/dp_grpc_conv.cpp +++ b/src/grpc/dp_grpc_conv.cpp @@ -171,7 +171,7 @@ bool Ipv6PrefixLenToMask(uint32_t prefix_length, uint8_t *mask) { memset(mask, 0, DP_IPV6_ADDR_SIZE); // Initialize mask to all zeros for (uint32_t i = 0; i < prefix_length; i++) { - mask[i / 8] |= (1 << (7 - (i % 8))); + mask[i / 8] |= (uint8_t)(1 << (7 - (i % 8))); } return true; diff --git a/src/nodes/snat_node.c b/src/nodes/snat_node.c index 9d2120ab1..189276e39 100644 --- a/src/nodes/snat_node.c +++ b/src/nodes/snat_node.c @@ -129,6 +129,7 @@ static __rte_always_inline rte_edge_t get_next_index(__rte_unused struct rte_nod dp_change_l4_hdr_port(m, DP_L4_PORT_DIR_SRC, nat_port); } + ipv4_hdr = dp_get_ipv4_hdr(m); cntrack->nf_info.nat_type = DP_FLOW_NAT_TYPE_NETWORK_LOCAL; cntrack->nf_info.vni = vni; cntrack->nf_info.l4_type = df->l4_type;