summaryrefslogtreecommitdiffhomepage
path: root/pkg
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@gmail.com>2019-01-09 09:07:06 +0900
committerFUJITA Tomonori <fujita.tomonori@gmail.com>2019-01-09 14:36:48 +0900
commit1d14b8ecfba61de524e0266e4a0fddb3b111f235 (patch)
tree8e66d6dada1377f85e58669c416f7f4cf993ee34 /pkg
parent0ae389ad1e7daeaeb354cd4be76b13ece9153e00 (diff)
silence staticcheck warnings
Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com>
Diffstat (limited to 'pkg')
-rw-r--r--pkg/packet/bgp/bgp.go16
-rw-r--r--pkg/packet/mrt/mrt.go20
-rw-r--r--pkg/packet/rtr/rtr.go4
-rw-r--r--pkg/server/fsm.go2
-rw-r--r--pkg/server/peer.go2
-rw-r--r--pkg/server/rpki.go2
-rw-r--r--pkg/server/server.go34
7 files changed, 38 insertions, 42 deletions
diff --git a/pkg/packet/bgp/bgp.go b/pkg/packet/bgp/bgp.go
index 941fe185..dfedba9b 100644
--- a/pkg/packet/bgp/bgp.go
+++ b/pkg/packet/bgp/bgp.go
@@ -2496,7 +2496,7 @@ func (er *EVPNMacIPAdvertisementRoute) Serialize() ([]byte, error) {
case 128:
buf = append(buf, []byte(er.IPAddress.To16())...)
default:
- return nil, fmt.Errorf("Invalid IP address length: %d", er.IPAddressLength)
+ return nil, fmt.Errorf("invalid IP address length: %d", er.IPAddressLength)
}
for _, l := range er.Labels {
@@ -2614,7 +2614,7 @@ func (er *EVPNMulticastEthernetTagRoute) Serialize() ([]byte, error) {
case 128:
buf = append(buf, []byte(er.IPAddress.To16())...)
default:
- return nil, fmt.Errorf("Invalid IP address length: %d", er.IPAddressLength)
+ return nil, fmt.Errorf("invalid IP address length: %d", er.IPAddressLength)
}
if err != nil {
return nil, err
@@ -2714,7 +2714,7 @@ func (er *EVPNEthernetSegmentRoute) Serialize() ([]byte, error) {
case 128:
buf = append(buf, []byte(er.IPAddress.To16())...)
default:
- return nil, fmt.Errorf("Invalid IP address length: %d", er.IPAddressLength)
+ return nil, fmt.Errorf("invalid IP address length: %d", er.IPAddressLength)
}
return buf, nil
}
@@ -3980,10 +3980,6 @@ func (v *FlowSpecComponentItem) Len() int {
}
func (v *FlowSpecComponentItem) Serialize() ([]byte, error) {
- if v.Op > math.MaxUint8 {
- return nil, fmt.Errorf("invalid op size: %d", v.Op)
- }
-
order := uint32(math.Log2(float64(v.Len())))
buf := make([]byte, 1+(1<<order))
buf[0] = byte(uint32(v.Op) | order<<4)
@@ -4358,7 +4354,7 @@ func (n *FlowSpecNLRI) Serialize(options ...*MarshallingOption) ([]byte, error)
}
length := n.Len(options...)
if length > 0xfff {
- return nil, fmt.Errorf("Too large: %d", length)
+ return nil, fmt.Errorf("too large: %d", length)
} else if length < 0xf0 {
length -= 1
buf = append([]byte{byte(length)}, buf...)
@@ -4666,7 +4662,7 @@ func (n *OpaqueNLRI) DecodeFromBytes(data []byte, options ...*MarshallingOption)
func (n *OpaqueNLRI) Serialize(options ...*MarshallingOption) ([]byte, error) {
if len(n.Key) > math.MaxUint16 {
- return nil, fmt.Errorf("Key length too big")
+ return nil, fmt.Errorf("key length too big")
}
buf := make([]byte, 2)
binary.BigEndian.PutUint16(buf, uint16(len(n.Key)))
@@ -9677,7 +9673,7 @@ func FlatUpdate(f1, f2 map[string]string) error {
}
}
if conflict {
- return fmt.Errorf("Keys conflict")
+ return fmt.Errorf("keys conflict")
} else {
return nil
}
diff --git a/pkg/packet/mrt/mrt.go b/pkg/packet/mrt/mrt.go
index dc07ba9b..adcdc649 100644
--- a/pkg/packet/mrt/mrt.go
+++ b/pkg/packet/mrt/mrt.go
@@ -461,7 +461,7 @@ type Rib struct {
func (u *Rib) DecodeFromBytes(data []byte) error {
if len(data) < 4 {
- return fmt.Errorf("Not all RibIpv4Unicast message bytes available")
+ return fmt.Errorf("not all RibIpv4Unicast message bytes available")
}
u.SequenceNumber = binary.BigEndian.Uint32(data[:4])
data = data[4:]
@@ -665,9 +665,9 @@ type BGP4MPHeader struct {
func (m *BGP4MPHeader) decodeFromBytes(data []byte) ([]byte, error) {
if m.isAS4 && len(data) < 8 {
- return nil, fmt.Errorf("Not all BGP4MPMessageAS4 bytes available")
+ return nil, fmt.Errorf("not all BGP4MPMessageAS4 bytes available")
} else if !m.isAS4 && len(data) < 4 {
- return nil, fmt.Errorf("Not all BGP4MPMessageAS bytes available")
+ return nil, fmt.Errorf("not all BGP4MPMessageAS bytes available")
}
if m.isAS4 {
@@ -735,7 +735,7 @@ func newBGP4MPHeader(peeras, localas uint32, intfindex uint16, peerip, localip s
if paddr != nil && laddr != nil {
af = bgp.AFI_IP6
} else {
- return nil, fmt.Errorf("Peer IP Address and Local IP Address must have the same address family")
+ return nil, fmt.Errorf("peer IP Address and Local IP Address must have the same address family")
}
}
return &BGP4MPHeader{
@@ -761,7 +761,7 @@ func (m *BGP4MPStateChange) DecodeFromBytes(data []byte) error {
return err
}
if len(rest) < 4 {
- return fmt.Errorf("Not all BGP4MPStateChange bytes available")
+ return fmt.Errorf("not all BGP4MPStateChange bytes available")
}
m.OldState = BGPState(binary.BigEndian.Uint16(rest[:2]))
m.NewState = BGPState(binary.BigEndian.Uint16(rest[2:4]))
@@ -804,7 +804,7 @@ func (m *BGP4MPMessage) DecodeFromBytes(data []byte) error {
}
if len(rest) < bgp.BGP_HEADER_LENGTH {
- return fmt.Errorf("Not all BGP4MPMessageAS4 bytes available")
+ return fmt.Errorf("not all BGP4MPMessageAS4 bytes available")
}
msg, err := bgp.ParseBGPMessage(rest)
@@ -903,7 +903,7 @@ func SplitMrt(data []byte, atEOF bool) (advance int, token []byte, err error) {
func ParseMRTBody(h *MRTHeader, data []byte) (*MRTMessage, error) {
if len(data) < int(h.Len) {
- return nil, fmt.Errorf("Not all MRT message bytes available. expected: %d, actual: %d", int(h.Len), len(data))
+ return nil, fmt.Errorf("not all MRT message bytes available. expected: %d, actual: %d", int(h.Len), len(data))
}
msg := &MRTMessage{Header: *h}
switch h.Type {
@@ -940,7 +940,7 @@ func ParseMRTBody(h *MRTHeader, data []byte) (*MRTMessage, error) {
case RIB_GENERIC_ADDPATH:
isAddPath = true
default:
- return nil, fmt.Errorf("unsupported table dumpv2 subtype: %v\n", subType)
+ return nil, fmt.Errorf("unsupported table dumpv2 subtype: %v", subType)
}
if msg.Body == nil {
@@ -993,10 +993,10 @@ func ParseMRTBody(h *MRTHeader, data []byte) (*MRTMessage, error) {
isAddPath: true,
}
default:
- return nil, fmt.Errorf("unsupported bgp4mp subtype: %v\n", subType)
+ return nil, fmt.Errorf("unsupported bgp4mp subtype: %v", subType)
}
default:
- return nil, fmt.Errorf("unsupported type: %v\n", h.Type)
+ return nil, fmt.Errorf("unsupported type: %v", h.Type)
}
err := msg.Body.DecodeFromBytes(data)
if err != nil {
diff --git a/pkg/packet/rtr/rtr.go b/pkg/packet/rtr/rtr.go
index 902f1e62..d332f84b 100644
--- a/pkg/packet/rtr/rtr.go
+++ b/pkg/packet/rtr/rtr.go
@@ -355,7 +355,7 @@ func SplitRTR(data []byte, atEOF bool) (advance int, token []byte, err error) {
totalLen := binary.BigEndian.Uint32(data[4:8])
if totalLen < RTR_MIN_LEN {
- return 0, nil, fmt.Errorf("Invalid length: %d", totalLen)
+ return 0, nil, fmt.Errorf("invalid length: %d", totalLen)
}
if uint32(len(data)) < totalLen {
return 0, nil, nil
@@ -385,7 +385,7 @@ func ParseRTR(data []byte) (RTRMessage, error) {
case RTR_ERROR_REPORT:
msg = &RTRErrorReport{}
default:
- return nil, fmt.Errorf("unknown RTR message type %d:", data[1])
+ return nil, fmt.Errorf("unknown RTR message type %d", data[1])
}
err := msg.DecodeFromBytes(data)
return msg, err
diff --git a/pkg/server/fsm.go b/pkg/server/fsm.go
index 2440f65a..67ab0cfc 100644
--- a/pkg/server/fsm.go
+++ b/pkg/server/fsm.go
@@ -1957,7 +1957,7 @@ func (h *fsmHandler) changeadminState(s adminState) error {
"State": fsm.state.String(),
}).Warn("cannot change to the same state")
- return fmt.Errorf("cannot change to the same state.")
+ return fmt.Errorf("cannot change to the same state")
}
return nil
}
diff --git a/pkg/server/peer.go b/pkg/server/peer.go
index 4e51137a..8d41428c 100644
--- a/pkg/server/peer.go
+++ b/pkg/server/peer.go
@@ -580,5 +580,5 @@ func (peer *peer) stopFSM() error {
}).Debug("freed fsm.h.t")
cleanInfiniteChannel(peer.outgoing)
}
- return fmt.Errorf("Failed to free FSM for %s", addr)
+ return fmt.Errorf("failed to free FSM for %s", addr)
}
diff --git a/pkg/server/rpki.go b/pkg/server/rpki.go
index c5c2f7c9..c46f8ffd 100644
--- a/pkg/server/rpki.go
+++ b/pkg/server/rpki.go
@@ -470,7 +470,7 @@ func (m *roaManager) GetServers() []*config.RpkiServer {
func (m *roaManager) GetRoa(family bgp.RouteFamily) ([]*table.ROA, error) {
if len(m.clientMap) == 0 {
- return []*table.ROA{}, fmt.Errorf("RPKI server isn't configured.")
+ return []*table.ROA{}, fmt.Errorf("RPKI server isn't configured")
}
var rfList []bgp.RouteFamily
switch family {
diff --git a/pkg/server/server.go b/pkg/server/server.go
index 85b13c23..941afdeb 100644
--- a/pkg/server/server.go
+++ b/pkg/server/server.go
@@ -1798,7 +1798,7 @@ func (s *BgpServer) fixupApiPath(vrfId string, pathList []*table.Path) error {
if pm == nil {
path.SetExtCommunities([]bgp.ExtendedCommunityInterface{m}, false)
} else if pm != nil && pm.Sequence < m.Sequence {
- return fmt.Errorf("Invalid MAC mobility sequence number")
+ return fmt.Errorf("invalid MAC mobility sequence number")
}
}
case *bgp.EVPNEthernetSegmentRoute:
@@ -1893,7 +1893,7 @@ func (s *BgpServer) DeletePath(ctx context.Context, r *api.DeletePathRequest) er
return nil
}()
if path == nil {
- return fmt.Errorf("Can't find a specified path")
+ return fmt.Errorf("can't find a specified path")
}
deletePathList = append(deletePathList, path.Clone(true))
} else if len(pathList) == 0 {
@@ -2238,10 +2238,10 @@ func (s *BgpServer) getRib(addr string, family bgp.RouteFamily, prefixes []*tabl
if len(addr) > 0 {
peer, ok := s.neighborMap[addr]
if !ok {
- return fmt.Errorf("Neighbor that has %v doesn't exist.", addr)
+ return fmt.Errorf("neighbor that has %v doesn't exist", addr)
}
if !peer.isRouteServerClient() {
- return fmt.Errorf("Neighbor %v doesn't have local rib", addr)
+ return fmt.Errorf("neighbor %v doesn't have local rib", addr)
}
id = peer.ID()
as = peer.AS()
@@ -2289,7 +2289,7 @@ func (s *BgpServer) getAdjRib(addr string, family bgp.RouteFamily, in bool, pref
err = s.mgmtOperation(func() error {
peer, ok := s.neighborMap[addr]
if !ok {
- return fmt.Errorf("Neighbor that has %v doesn't exist.", addr)
+ return fmt.Errorf("neighbor that has %v doesn't exist", addr)
}
id := peer.ID()
as := peer.AS()
@@ -2386,10 +2386,10 @@ func (s *BgpServer) getRibInfo(addr string, family bgp.RouteFamily) (info *table
if len(addr) > 0 {
peer, ok := s.neighborMap[addr]
if !ok {
- return fmt.Errorf("Neighbor that has %v doesn't exist.", addr)
+ return fmt.Errorf("neighbor that has %v doesn't exist", addr)
}
if !peer.isRouteServerClient() {
- return fmt.Errorf("Neighbor %v doesn't have local rib", addr)
+ return fmt.Errorf("neighbor %v doesn't have local rib", addr)
}
id = peer.ID()
as = peer.AS()
@@ -2405,7 +2405,7 @@ func (s *BgpServer) getAdjRibInfo(addr string, family bgp.RouteFamily, in bool)
err = s.mgmtOperation(func() error {
peer, ok := s.neighborMap[addr]
if !ok {
- return fmt.Errorf("Neighbor that has %v doesn't exist.", addr)
+ return fmt.Errorf("neighbor that has %v doesn't exist", addr)
}
var adjRib *table.AdjRib
@@ -2533,7 +2533,7 @@ func (s *BgpServer) ListPeer(ctx context.Context, r *api.ListPeerRequest, fn fun
func (s *BgpServer) addPeerGroup(c *config.PeerGroup) error {
name := c.Config.PeerGroupName
if _, y := s.peerGroupMap[name]; y {
- return fmt.Errorf("Can't overwrite the existing peer-group: %s", name)
+ return fmt.Errorf("can't overwrite the existing peer-group: %s", name)
}
log.WithFields(log.Fields{
@@ -2553,7 +2553,7 @@ func (s *BgpServer) addNeighbor(c *config.Neighbor) error {
}
if _, y := s.neighborMap[addr]; y {
- return fmt.Errorf("Can't overwrite the existing peer: %s", addr)
+ return fmt.Errorf("can't overwrite the existing peer: %s", addr)
}
var pgConf *config.PeerGroup
@@ -2653,7 +2653,7 @@ func (s *BgpServer) AddDynamicNeighbor(ctx context.Context, r *api.AddDynamicNei
func (s *BgpServer) deletePeerGroup(name string) error {
if _, y := s.peerGroupMap[name]; !y {
- return fmt.Errorf("Can't delete a peer-group %s which does not exist", name)
+ return fmt.Errorf("can't delete a peer-group %s which does not exist", name)
}
log.WithFields(log.Fields{
@@ -2687,7 +2687,7 @@ func (s *BgpServer) deleteNeighbor(c *config.Neighbor, code, subcode uint8) erro
}
n, y := s.neighborMap[addr]
if !y {
- return fmt.Errorf("Can't delete a peer configuration for %s", addr)
+ return fmt.Errorf("can't delete a peer configuration for %s", addr)
}
for _, l := range s.listListeners(addr) {
if err := setTCPMD5SigSockopt(l, addr, ""); err != nil {
@@ -2740,7 +2740,7 @@ func (s *BgpServer) updatePeerGroup(pg *config.PeerGroup) (needsSoftResetIn bool
_, ok := s.peerGroupMap[name]
if !ok {
- return false, fmt.Errorf("Peer-group %s doesn't exist.", name)
+ return false, fmt.Errorf("peer-group %s doesn't exist", name)
}
s.peerGroupMap[name].Conf = pg
@@ -2786,7 +2786,7 @@ func (s *BgpServer) updateNeighbor(c *config.Neighbor) (needsSoftResetIn bool, e
peer, ok := s.neighborMap[addr]
if !ok {
- return needsSoftResetIn, fmt.Errorf("Neighbor that has %v doesn't exist.", addr)
+ return needsSoftResetIn, fmt.Errorf("neighbor that has %v doesn't exist", addr)
}
if !peer.fsm.pConf.ApplyPolicy.Equal(&c.ApplyPolicy) {
@@ -2885,7 +2885,7 @@ func (s *BgpServer) addrToPeers(addr string) (l []*peer, err error) {
}
p, found := s.neighborMap[addr]
if !found {
- return l, fmt.Errorf("Neighbor that has %v doesn't exist.", addr)
+ return l, fmt.Errorf("neighbor that has %v doesn't exist", addr)
}
return []*peer{p}, nil
}
@@ -3748,10 +3748,10 @@ func (w *watcher) Generate(t watchEventType) error {
if len(w.opts.tableName) > 0 {
peer, ok := w.s.neighborMap[w.opts.tableName]
if !ok {
- return fmt.Errorf("Neighbor that has %v doesn't exist.", w.opts.tableName)
+ return fmt.Errorf("neighbor that has %v doesn't exist", w.opts.tableName)
}
if !peer.isRouteServerClient() {
- return fmt.Errorf("Neighbor %v doesn't have local rib", w.opts.tableName)
+ return fmt.Errorf("neighbor %v doesn't have local rib", w.opts.tableName)
}
id = peer.ID()
as = peer.AS()