summaryrefslogtreecommitdiffhomepage
path: root/config
diff options
context:
space:
mode:
authorJeff Bean <bean@uber.com>2018-06-22 19:12:33 -0700
committerJeff Bean <bean@uber.com>2018-06-22 19:12:33 -0700
commit154650594c5b40b2905eb73b90f52de72f6ced16 (patch)
tree2ba6ffe099ff216a92df7fb3806eb9aeaa988208 /config
parent954562d65a90af4e8d2e9bf29e4c2bccc4420b38 (diff)
Fixing all megacheck errors.
Diffstat (limited to 'config')
-rw-r--r--config/default.go2
-rw-r--r--config/serve.go10
-rw-r--r--config/util.go23
3 files changed, 9 insertions, 26 deletions
diff --git a/config/default.go b/config/default.go
index 1576bb33..cbb11167 100644
--- a/config/default.go
+++ b/config/default.go
@@ -30,7 +30,7 @@ var configuredFields map[string]interface{}
func RegisterConfiguredFields(addr string, n interface{}) {
if configuredFields == nil {
- configuredFields = make(map[string]interface{}, 0)
+ configuredFields = make(map[string]interface{})
}
configuredFields[addr] = n
}
diff --git a/config/serve.go b/config/serve.go
index 8b2f1cfc..6b09af6e 100644
--- a/config/serve.go
+++ b/config/serve.go
@@ -68,12 +68,10 @@ func ReadConfigfileServe(path, format string, configCh chan *BgpConfigSet) {
}).Warningf("Can't read config file %s", path)
}
NEXT:
- select {
- case <-sigCh:
- log.WithFields(log.Fields{
- "Topic": "Config",
- }).Info("Reload the config file")
- }
+ <-sigCh
+ log.WithFields(log.Fields{
+ "Topic": "Config",
+ }).Info("Reload the config file")
}
}
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)
}