Skip to content

Commit

Permalink
fix: makes an AND relation between addr and label filters
Browse files Browse the repository at this point in the history
Signed-off-by: Shuoran Liu <[email protected]>
  • Loading branch information
Shuoran Liu committed May 24, 2023
1 parent 658a11d commit d797c91
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions src/addr/get.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,13 @@ impl AddressFilterBuilder {
}

if let Some(address) = self.address {
let mut is_match: bool = false;

for nla in msg.nlas.iter() {
if let Unspec(x) | Address(x) | Local(x) | Multicast(x)
| Anycast(x) = nla
{
let is_match = match address {
is_match = match address {
IpAddr::V4(address) => {
x[..] == address.octets()[..]
}
Expand All @@ -127,22 +129,31 @@ impl AddressFilterBuilder {
}
};
if is_match {
return true;
break;
}
}
}
return false;

if !is_match {
return false;
}
}

if let Some(ref label) = self.label {
let mut is_match: bool = false;

for nla in msg.nlas.iter() {
if let Label(l) = nla {
if label == l {
return true;
is_match = true;
break;
}
}
}
return false;

if !is_match {
return false;
}
}

true
Expand Down

0 comments on commit d797c91

Please sign in to comment.