Skip to content

Commit

Permalink
Correct checkpatch and compiler warnings
Browse files Browse the repository at this point in the history
Signed-off-by: Guvenc Gulce <[email protected]>
  • Loading branch information
guvenc committed Dec 20, 2023
1 parent b609889 commit 01da8d2
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
10 changes: 5 additions & 5 deletions src/dp_firewall.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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) ||
Expand Down
6 changes: 3 additions & 3 deletions src/dp_nat.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion src/grpc/dp_grpc_conv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/nodes/snat_node.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 01da8d2

Please sign in to comment.