Skip to content

Commit

Permalink
SQUASHME: Fix acl merging for masks which are multiples of 8
Browse files Browse the repository at this point in the history
Spotted by phk.
  • Loading branch information
nigoroll committed Sep 17, 2022
1 parent da349b8 commit cdb5ba5
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
21 changes: 21 additions & 0 deletions bin/varnishtest/tests/c00005.vtc
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,16 @@ varnish v1 -vcl {
# left,right adjacent
"2.3.4.0"/23;
"2.3.6.0"/23;

# phks test case
"10.0.0.0"/23;
"10.0.2.0"/23;

"10.1.0.0"/24;
"10.1.1.0"/24;

"10.2.0.0"/25;
"10.2.0.128"/25;
}

sub vcl_recv {
Expand Down Expand Up @@ -220,6 +230,10 @@ varnish v1 -vcl {

set req.http.ip = "2.2.255.255";call t;
set req.http.ip = "2.3.8.0"; call t;

set req.http.ip = "10.0.3.255"; call t;
set req.http.ip = "10.1.1.255"; call t;
set req.http.ip = "10.2.0.255"; call t;
}
}

Expand Down Expand Up @@ -259,6 +273,13 @@ logexpect l1 -v v1 -g raw {
expect 0 = VCL_acl {^\QNO_MATCH acl1\E$}
expect 1 = ReqHeader {^\Qip: 2.3.8.0\E$}
expect 0 = VCL_acl {^\QNO_MATCH acl1\E$}

expect 1 = ReqHeader {^\Qip: 10.0.3.255\E$}
expect 0 = VCL_acl {^\QMATCH acl1 "10.0.0.0"/22 fixed: merged\E}
expect 1 = ReqHeader {^\Qip: 10.1.1.255\E$}
expect 0 = VCL_acl {^\QMATCH acl1 "10.1.0.0"/23 fixed: merged\E}
expect 1 = ReqHeader {^\Qip: 10.2.0.255\E$}
expect 0 = VCL_acl {^\QMATCH acl1 "10.2.0.0"/24 fixed: merged\E}
} -start

client c1 {
Expand Down
2 changes: 2 additions & 0 deletions lib/libvcc/vcc_acl.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ vcl_acl_cmp(const struct acl_e *ae1, const struct acl_e *ae2)
p2 = ae2->data;
m = vmin_t(unsigned, ae1->mask, ae2->mask);
for (; m >= 8; m -= 8) {
if (m == 8 && ae1->mask == ae2->mask)
CMPA(*p1, *p2);
CMP(ACL_GT, *p1, *p2);
p1++;
p2++;
Expand Down

0 comments on commit cdb5ba5

Please sign in to comment.