-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Here we test leaking routes from / to VRFs with different types of allowed prefixes. Signed-off-by: Federico Paolinelli <[email protected]>
- Loading branch information
Showing
5 changed files
with
503 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// SPDX-License-Identifier:Apache-2.0 | ||
|
||
package address | ||
|
||
import ( | ||
"net" | ||
|
||
"go.universe.tf/e2etest/pkg/ipfamily" | ||
) | ||
|
||
func FilterForFamily(ips []string, family ipfamily.Family) []string { | ||
if family == ipfamily.DualStack { | ||
return ips | ||
} | ||
var res []string | ||
for _, ip := range ips { | ||
parsedIP, _, _ := net.ParseCIDR(ip) | ||
if parsedIP == nil { | ||
panic("invalid ip") // it's a test after all, should never happen | ||
} | ||
isV4 := (parsedIP.To4() != nil) | ||
if family == ipfamily.IPv4 && isV4 { | ||
res = append(res, ip) | ||
continue | ||
} | ||
if family == ipfamily.IPv6 && !isV4 { | ||
res = append(res, ip) | ||
continue | ||
} | ||
} | ||
return res | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.