summaryrefslogtreecommitdiffhomepage
path: root/config/util.go
diff options
context:
space:
mode:
Diffstat (limited to 'config/util.go')
-rw-r--r--config/util.go23
1 files changed, 4 insertions, 19 deletions
diff --git a/config/util.go b/config/util.go
index 7cd8c01e..e857b98b 100644
--- a/config/util.go
+++ b/config/util.go
@@ -81,23 +81,6 @@ func getIPv6LinkLocalAddress(ifname string) (string, error) {
return "", fmt.Errorf("no ipv6 link local address for %s", ifname)
}
-func isLocalLinkLocalAddress(ifindex int, addr net.IP) (bool, error) {
- ifi, err := net.InterfaceByIndex(ifindex)
- if err != nil {
- return false, err
- }
- addrs, err := ifi.Addrs()
- if err != nil {
- return false, err
- }
- for _, a := range addrs {
- if ip, _, _ := net.ParseCIDR(a.String()); addr.Equal(ip) {
- return true, nil
- }
- }
- return false, nil
-}
-
func (b *BgpConfigSet) getPeerGroup(n string) (*PeerGroup, error) {
if n == "" {
return nil, nil
@@ -240,6 +223,9 @@ func (n *Neighbor) NeedsResendOpenMessage(new *Neighbor) bool {
isAfiSafiChanged(n.AfiSafis, new.AfiSafis)
}
+// TODO: these regexp are duplicated in api
+var _regexpPrefixMaskLengthRange = regexp.MustCompile(`(\d+)\.\.(\d+)`)
+
func ParseMaskLength(prefix, mask string) (int, int, error) {
_, ipNet, err := net.ParseCIDR(prefix)
if err != nil {
@@ -249,8 +235,7 @@ func ParseMaskLength(prefix, mask string) (int, int, error) {
l, _ := ipNet.Mask.Size()
return l, l, nil
}
- exp := regexp.MustCompile("(\\d+)\\.\\.(\\d+)")
- elems := exp.FindStringSubmatch(mask)
+ elems := _regexpPrefixMaskLengthRange.FindStringSubmatch(mask)
if len(elems) != 3 {
return 0, 0, fmt.Errorf("invalid mask length range: %s", mask)
}