aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNick Hainke <vincent@systemli.org>2021-01-16 13:48:50 +0100
committerAdrian Schmutzler <freifunk@adrianschmutzler.de>2021-01-19 15:39:36 +0100
commit0fda8049a7d1fb34074b7d5e8041312c1971f87d (patch)
treee058d57370f8bdf5e872206afe950d898fd99c99
parent38bdff29aa132a049228cbfc1d87064ceb6f824b (diff)
downloadupstream-0fda8049a7d1fb34074b7d5e8041312c1971f87d.tar.gz
upstream-0fda8049a7d1fb34074b7d5e8041312c1971f87d.tar.bz2
upstream-0fda8049a7d1fb34074b7d5e8041312c1971f87d.zip
owipcalc: remove clone in cidr_contains6
The "cidr_contains6" functions clones the given cidr. The contains4 does not clone the cidr. Both functions do not behave the same. I see no reason to push the cidr. I think that we get only a negligible performance gain, but it makes ipv4 and ipv6 equal again. Signed-off-by: Nick Hainke <vincent@systemli.org>
-rw-r--r--package/network/utils/owipcalc/Makefile2
-rw-r--r--package/network/utils/owipcalc/src/owipcalc.c9
2 files changed, 5 insertions, 6 deletions
diff --git a/package/network/utils/owipcalc/Makefile b/package/network/utils/owipcalc/Makefile
index 1f4c98bb48..dc68a0346b 100644
--- a/package/network/utils/owipcalc/Makefile
+++ b/package/network/utils/owipcalc/Makefile
@@ -7,7 +7,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=owipcalc
-PKG_RELEASE:=4
+PKG_RELEASE:=5
PKG_LICENSE:=Apache-2.0
include $(INCLUDE_DIR)/package.mk
diff --git a/package/network/utils/owipcalc/src/owipcalc.c b/package/network/utils/owipcalc/src/owipcalc.c
index c4df5c7450..5ed609f158 100644
--- a/package/network/utils/owipcalc/src/owipcalc.c
+++ b/package/network/utils/owipcalc/src/owipcalc.c
@@ -527,18 +527,17 @@ static bool cidr_network6(struct cidr *a)
static bool cidr_contains6(struct cidr *a, struct cidr *b)
{
- struct cidr *n = cidr_clone(a);
- struct in6_addr *x = &n->addr.v6;
+ struct in6_addr *x = &a->addr.v6;
struct in6_addr *y = &b->addr.v6;
- uint8_t i = (128 - n->prefix) / 8;
- uint8_t m = ~((1 << ((128 - n->prefix) % 8)) - 1);
+ uint8_t i = (128 - a->prefix) / 8;
+ uint8_t m = ~((1 << ((128 - a->prefix) % 8)) - 1);
uint8_t net1 = x->s6_addr[15-i] & m;
uint8_t net2 = y->s6_addr[15-i] & m;
if (printed)
qprintf(" ");
- if ((b->prefix >= n->prefix) && (net1 == net2) &&
+ if ((b->prefix >= a->prefix) && (net1 == net2) &&
((i == 15) || !memcmp(&x->s6_addr, &y->s6_addr, 15-i)))
{
qprintf("1");