Skip to content

Commit

Permalink
tc: remove duplicated functions
Browse files Browse the repository at this point in the history
  • Loading branch information
ywc689 committed Apr 13, 2021
1 parent a7eac97 commit 632ea8b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 16 deletions.
12 changes: 0 additions & 12 deletions include/linux_ipv6.h
Original file line number Diff line number Diff line change
Expand Up @@ -266,18 +266,6 @@ static inline int ipv6_addr_cmp(const struct in6_addr *a1, const struct in6_addr
return memcmp(a1, a2, sizeof(struct in6_addr));
}

static inline int ipv6_addr_cmp_u128(const struct in6_addr *a1, const struct in6_addr *a2)
{
uint8_t *p1, *p2;

for (p1 = (uint8_t *)a1, p2 = (uint8_t *)a2; p1 - (uint8_t *)a1 < 16; p1++, p2++) {
if (*p1 != *p2)
return *p1 > *p2 ? 1 : -1;
}

return 0;
}

static inline bool
ipv6_masked_addr_cmp(const struct in6_addr *a1, const struct in6_addr *m,
const struct in6_addr *a2)
Expand Down
8 changes: 4 additions & 4 deletions src/tc/cls_match.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,14 @@ static int match_classify(struct tc_cls *cls, struct rte_mbuf *mbuf,

ip6h = rte_pktmbuf_mtod_offset(mbuf, struct ip6_hdr *, offset);
if (!ipv6_addr_any(&m->srange.max_addr.in6)) {
if (ipv6_addr_cmp_u128(&ip6h->ip6_src, &m->srange.min_addr.in6) < 0 ||
ipv6_addr_cmp_u128(&ip6h->ip6_src, &m->srange.max_addr.in6) > 0)
if (ipv6_addr_cmp(&ip6h->ip6_src, &m->srange.min_addr.in6) < 0 ||
ipv6_addr_cmp(&ip6h->ip6_src, &m->srange.max_addr.in6) > 0)
goto done;
}

if (!ipv6_addr_any(&m->drange.max_addr.in6)) {
if (ipv6_addr_cmp_u128(&ip6h->ip6_dst, &m->drange.min_addr.in6) < 0 ||
ipv6_addr_cmp_u128(&ip6h->ip6_dst, &m->drange.max_addr.in6) > 0)
if (ipv6_addr_cmp(&ip6h->ip6_dst, &m->drange.min_addr.in6) < 0 ||
ipv6_addr_cmp(&ip6h->ip6_dst, &m->drange.max_addr.in6) > 0)
goto done;
}

Expand Down

0 comments on commit 632ea8b

Please sign in to comment.