Browse Source

Merge pull request #14539 from PolynomialDivision/owipcalc-default-route

owipcalc: fix contains not respect default route
lilik-openwrt-22.03
Jo-Philipp Wich 4 years ago
committed by GitHub
parent
commit
82fdb0ed05
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 5 deletions
  1. +1
    -1
      net/owipcalc/Makefile
  2. +5
    -4
      net/owipcalc/src/owipcalc.c

+ 1
- 1
net/owipcalc/Makefile View File

@ -7,7 +7,7 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_NAME:=owipcalc PKG_NAME:=owipcalc
PKG_RELEASE:=5
PKG_RELEASE:=6
PKG_LICENSE:=Apache-2.0 PKG_LICENSE:=Apache-2.0
include $(INCLUDE_DIR)/package.mk include $(INCLUDE_DIR)/package.mk


+ 5
- 4
net/owipcalc/src/owipcalc.c View File

@ -227,7 +227,7 @@ static bool cidr_contains4(struct cidr *a, struct cidr *b)
if (printed) if (printed)
qprintf(" "); qprintf(" ");
if ((b->prefix >= a->prefix) && (net1 == net2))
if ((a->prefix == 0) || ((b->prefix >= a->prefix) && (net1 == net2)))
{ {
qprintf("1"); qprintf("1");
return true; return true;
@ -529,7 +529,7 @@ static bool cidr_contains6(struct cidr *a, struct cidr *b)
{ {
struct in6_addr *x = &a->addr.v6; struct in6_addr *x = &a->addr.v6;
struct in6_addr *y = &b->addr.v6; struct in6_addr *y = &b->addr.v6;
uint8_t i = (128 - a->prefix) / 8;
uint8_t i = ((128 - a->prefix) / 8) % 16;
uint8_t m = ~((1 << ((128 - a->prefix) % 8)) - 1); uint8_t m = ~((1 << ((128 - a->prefix) % 8)) - 1);
uint8_t net1 = x->s6_addr[15-i] & m; uint8_t net1 = x->s6_addr[15-i] & m;
uint8_t net2 = y->s6_addr[15-i] & m; uint8_t net2 = y->s6_addr[15-i] & m;
@ -537,8 +537,9 @@ static bool cidr_contains6(struct cidr *a, struct cidr *b)
if (printed) if (printed)
qprintf(" "); qprintf(" ");
if ((b->prefix >= a->prefix) && (net1 == net2) &&
((i == 15) || !memcmp(&x->s6_addr, &y->s6_addr, 15-i)))
if ((a->prefix == 0) ||
((b->prefix >= a->prefix) && (net1 == net2) &&
((i == 15) || !memcmp(&x->s6_addr, &y->s6_addr, 15-i))))
{ {
qprintf("1"); qprintf("1");
return true; return true;


Loading…
Cancel
Save