summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--cmd/gobgp/bmp.go2
-rw-r--r--cmd/gobgp/global.go8
-rw-r--r--cmd/gobgp/mrt.go4
-rw-r--r--cmd/gobgp/neighbor.go12
-rw-r--r--cmd/gobgp/policy.go13
-rw-r--r--cmd/gobgp/vrf.go8
-rw-r--r--internal/pkg/config/bgp_configs.go2
-rw-r--r--internal/pkg/table/destination.go2
-rw-r--r--internal/pkg/table/message.go15
-rw-r--r--internal/pkg/table/message_test.go8
-rw-r--r--internal/pkg/table/policy.go49
-rw-r--r--internal/pkg/table/table.go8
-rw-r--r--internal/pkg/zebra/zapi.go8
-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
-rw-r--r--tools/pyang_plugins/bgpyang2golang.py1
21 files changed, 103 insertions, 117 deletions
diff --git a/cmd/gobgp/bmp.go b/cmd/gobgp/bmp.go
index 7e9754d9..8fd61ff9 100644
--- a/cmd/gobgp/bmp.go
+++ b/cmd/gobgp/bmp.go
@@ -53,7 +53,7 @@ func modBmpServer(cmdType string, args []string) error {
if bmpOpts.StatisticsTimeout >= 0 && bmpOpts.StatisticsTimeout <= 65535 {
statisticsTimeout = bmpOpts.StatisticsTimeout
} else {
- return fmt.Errorf("invalid statistics-timeout value. it must be in the range 0-65535. default value is 0 and means disabled.")
+ return fmt.Errorf("invalid statistics-timeout value. it must be in the range 0-65535. default value is 0 and means disabled")
}
policyType := api.AddBmpRequest_PRE
diff --git a/cmd/gobgp/global.go b/cmd/gobgp/global.go
index 467824a0..fe53242f 100644
--- a/cmd/gobgp/global.go
+++ b/cmd/gobgp/global.go
@@ -123,18 +123,14 @@ func redirectParser(args []string) ([]bgp.ExtendedCommunityInterface, error) {
if err != nil {
return nil, err
}
- switch rt.(type) {
+ switch r := rt.(type) {
case *bgp.TwoOctetAsSpecificExtended:
- r := rt.(*bgp.TwoOctetAsSpecificExtended)
return []bgp.ExtendedCommunityInterface{bgp.NewRedirectTwoOctetAsSpecificExtended(r.AS, r.LocalAdmin)}, nil
case *bgp.IPv4AddressSpecificExtended:
- r := rt.(*bgp.IPv4AddressSpecificExtended)
return []bgp.ExtendedCommunityInterface{bgp.NewRedirectIPv4AddressSpecificExtended(r.IPv4.String(), r.LocalAdmin)}, nil
case *bgp.FourOctetAsSpecificExtended:
- r := rt.(*bgp.FourOctetAsSpecificExtended)
return []bgp.ExtendedCommunityInterface{bgp.NewRedirectFourOctetAsSpecificExtended(r.AS, r.LocalAdmin)}, nil
case *bgp.IPv6AddressSpecificExtended:
- r := rt.(*bgp.IPv6AddressSpecificExtended)
return []bgp.ExtendedCommunityInterface{bgp.NewRedirectIPv6AddressSpecificExtended(r.IPv6.String(), r.LocalAdmin)}, nil
}
return nil, fmt.Errorf("invalid redirect")
@@ -1241,7 +1237,7 @@ func parsePath(rf bgp.RouteFamily, args []string) (*api.Path, error) {
nlri = bgp.NewOpaqueNLRI([]byte(m["key"][0]), nil)
}
default:
- return nil, fmt.Errorf("Unsupported route family: %s", rf)
+ return nil, fmt.Errorf("unsupported route family: %s", rf)
}
if err != nil {
return nil, err
diff --git a/cmd/gobgp/mrt.go b/cmd/gobgp/mrt.go
index f03dd41e..61ce0a59 100644
--- a/cmd/gobgp/mrt.go
+++ b/cmd/gobgp/mrt.go
@@ -43,7 +43,7 @@ func injectMrt() error {
var idx int64
if mrtOpts.QueueSize < 1 {
- return fmt.Errorf("Specified queue size is smaller than 1, refusing to run with unbounded memory usage")
+ return fmt.Errorf("specified queue size is smaller than 1, refusing to run with unbounded memory usage")
}
ch := make(chan []*api.Path, mrtOpts.QueueSize)
@@ -112,7 +112,7 @@ func injectMrt() error {
for _, e := range rib.Entries {
if len(peers) < int(e.PeerIndex) {
- exitWithError(fmt.Errorf("invalid peer index: %d (PEER_INDEX_TABLE has only %d peers)\n", e.PeerIndex, len(peers)))
+ exitWithError(fmt.Errorf("invalid peer index: %d (PEER_INDEX_TABLE has only %d peers)", e.PeerIndex, len(peers)))
}
//t := time.Unix(int64(e.OriginatedTime), 0)
diff --git a/cmd/gobgp/neighbor.go b/cmd/gobgp/neighbor.go
index 31e01b4c..90d9e4f8 100644
--- a/cmd/gobgp/neighbor.go
+++ b/cmd/gobgp/neighbor.go
@@ -668,7 +668,7 @@ func showValidationInfo(p *api.Path, shownAs map[uint32]struct{}) error {
nlri, _ := apiutil.GetNativeNlri(p)
if len(asPath) == 0 {
- return fmt.Errorf("The path to %s was locally generated.\n", nlri.String())
+ return fmt.Errorf("the path to %s was locally generated", nlri.String())
} else if !checkOriginAsWasNotShown(p, asPath, shownAs) {
return nil
}
@@ -827,7 +827,7 @@ func showNeighborRib(r string, name string, args []string) error {
option = api.TableLookupOption_LOOKUP_SHORTER
} else if args[0] == "validation" {
if r != cmdAdjIn {
- return fmt.Errorf("RPKI information is supported for only adj-in.")
+ return fmt.Errorf("RPKI information is supported for only adj-in")
}
validationTarget = target
} else {
@@ -894,10 +894,10 @@ func showNeighborRib(r string, name string, args []string) error {
return err
}
if r == nil {
- return fmt.Errorf("Neighbor %v is not found", name)
+ return fmt.Errorf("neighbor %v is not found", name)
}
if r.Peer.State.SessionState != api.PeerState_ESTABLISHED {
- return fmt.Errorf("Neighbor %v's BGP session is not established", name)
+ return fmt.Errorf("neighbor %v's BGP session is not established", name)
}
}
}
@@ -986,7 +986,7 @@ func showNeighborRib(r string, name string, args []string) error {
func resetNeighbor(cmd string, remoteIP string, args []string) error {
if reasonLen := len(neighborsOpts.Reason); reasonLen > bgp.BGP_ERROR_ADMINISTRATIVE_COMMUNICATION_MAX {
- return fmt.Errorf("Too long reason for shutdown communication (max %d bytes)", bgp.BGP_ERROR_ADMINISTRATIVE_COMMUNICATION_MAX)
+ return fmt.Errorf("too long reason for shutdown communication (max %d bytes)", bgp.BGP_ERROR_ADMINISTRATIVE_COMMUNICATION_MAX)
}
var comm string
soft := true
@@ -1012,7 +1012,7 @@ func resetNeighbor(cmd string, remoteIP string, args []string) error {
func stateChangeNeighbor(cmd string, remoteIP string, args []string) error {
if reasonLen := len(neighborsOpts.Reason); reasonLen > bgp.BGP_ERROR_ADMINISTRATIVE_COMMUNICATION_MAX {
- return fmt.Errorf("Too long reason for shutdown communication (max %d bytes)", bgp.BGP_ERROR_ADMINISTRATIVE_COMMUNICATION_MAX)
+ return fmt.Errorf("too long reason for shutdown communication (max %d bytes)", bgp.BGP_ERROR_ADMINISTRATIVE_COMMUNICATION_MAX)
}
switch cmd {
case cmdShutdown:
diff --git a/cmd/gobgp/policy.go b/cmd/gobgp/policy.go
index d5fb80d3..8c720578 100644
--- a/cmd/gobgp/policy.go
+++ b/cmd/gobgp/policy.go
@@ -869,6 +869,7 @@ func modAction(name, op string, args []string) error {
}
typ := args[0]
args = args[1:]
+ cmd := "{ add | remove | replace } <value>..."
switch typ {
case "reject":
stmt.Actions.RouteAction = api.RouteAction_REJECT
@@ -877,7 +878,7 @@ func modAction(name, op string, args []string) error {
case "community":
stmt.Actions.Community = &api.CommunityAction{}
if len(args) < 1 {
- return fmt.Errorf("%s community { add | remove | replace } <value>...", usage)
+ return fmt.Errorf("%s community %s", usage, cmd)
}
stmt.Actions.Community.Communities = args[1:]
switch strings.ToLower(args[0]) {
@@ -888,12 +889,12 @@ func modAction(name, op string, args []string) error {
case "replace":
stmt.Actions.Community.ActionType = api.CommunityActionType_COMMUNITY_REPLACE
default:
- return fmt.Errorf("%s community { add | remove | replace } <value>...", usage)
+ return fmt.Errorf("%s community %s", usage, cmd)
}
case "ext-community":
stmt.Actions.ExtCommunity = &api.CommunityAction{}
if len(args) < 1 {
- return fmt.Errorf("%s ext-community { add | remove | replace } <value>...", usage)
+ return fmt.Errorf("%s ext-community %s", usage, cmd)
}
stmt.Actions.ExtCommunity.Communities = args[1:]
switch strings.ToLower(args[0]) {
@@ -904,12 +905,12 @@ func modAction(name, op string, args []string) error {
case "replace":
stmt.Actions.ExtCommunity.ActionType = api.CommunityActionType_COMMUNITY_REPLACE
default:
- return fmt.Errorf("%s ext-community { add | remove | replace } <value>...", usage)
+ return fmt.Errorf("%s ext-community %s", usage, cmd)
}
case "large-community":
stmt.Actions.LargeCommunity = &api.CommunityAction{}
if len(args) < 1 {
- return fmt.Errorf("%s large-community { add | remove | replace } <value>...", usage)
+ return fmt.Errorf("%s large-community %s", usage, cmd)
}
stmt.Actions.LargeCommunity.Communities = args[1:]
switch strings.ToLower(args[0]) {
@@ -920,7 +921,7 @@ func modAction(name, op string, args []string) error {
case "replace":
stmt.Actions.LargeCommunity.ActionType = api.CommunityActionType_COMMUNITY_REPLACE
default:
- return fmt.Errorf("%s large-community { add | remove | replace } <value>...", usage)
+ return fmt.Errorf("%s large-community %s", usage, cmd)
}
case "med":
stmt.Actions.Med = &api.MedAction{}
diff --git a/cmd/gobgp/vrf.go b/cmd/gobgp/vrf.go
index 69ec571e..73162519 100644
--- a/cmd/gobgp/vrf.go
+++ b/cmd/gobgp/vrf.go
@@ -127,7 +127,8 @@ func modVrf(typ string, args []string) error {
"rt": paramList,
"id": paramSingle})
if err != nil || len(a[""]) != 1 || len(a["rd"]) != 1 || len(a["rt"]) < 2 {
- return fmt.Errorf("Usage: gobgp vrf add <vrf name> [ id <id> ] rd <rd> rt { import | export | both } <rt>...")
+ //lint:ignore ST1005 cli example
+ return fmt.Errorf("usage: gobgp vrf add <vrf name> [ id <id> ] rd <rd> rt { import | export | both } <rt>...")
}
name := a[""][0]
var rd bgp.RouteDistinguisherInterface
@@ -156,7 +157,8 @@ func modVrf(typ string, args []string) error {
importRt = append(importRt, rt)
exportRt = append(exportRt, rt)
default:
- return fmt.Errorf("Usage: gobgp vrf add <vrf name> rd <rd> rt { import | export | both } <rt>...")
+ //lint:ignore ST1005 cli example
+ return fmt.Errorf("usage: gobgp vrf add <vrf name> [ id <id> ] rd <rd> rt { import | export | both } <rt>...")
}
}
var id uint64
@@ -178,7 +180,7 @@ func modVrf(typ string, args []string) error {
return err
case cmdDel:
if len(args) != 1 {
- return fmt.Errorf("Usage: gobgp vrf del <vrf name>")
+ return fmt.Errorf("usage: gobgp vrf del <vrf name>")
}
_, err := client.DeleteVrf(ctx, &api.DeleteVrfRequest{
Name: args[0],
diff --git a/internal/pkg/config/bgp_configs.go b/internal/pkg/config/bgp_configs.go
index 21e16fd8..0833e240 100644
--- a/internal/pkg/config/bgp_configs.go
+++ b/internal/pkg/config/bgp_configs.go
@@ -16,6 +16,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
+//lint:file-ignore S1008 generated code.
+
package config
import (
diff --git a/internal/pkg/table/destination.go b/internal/pkg/table/destination.go
index b843f8f4..44686abe 100644
--- a/internal/pkg/table/destination.go
+++ b/internal/pkg/table/destination.go
@@ -933,7 +933,7 @@ func compareByRouterID(path1, path2 *Path) (*Path, error) {
}
if !SelectionOptions.ExternalCompareRouterId && path1.IsIBGP() != path2.IsIBGP() {
- return nil, fmt.Errorf("This method does not support comparing ebgp with ibgp path")
+ return nil, fmt.Errorf("this method does not support comparing ebgp with ibgp path")
}
// At least one path is not coming from NC, so we get local bgp id.
diff --git a/internal/pkg/table/message.go b/internal/pkg/table/message.go
index 31b90596..32069484 100644
--- a/internal/pkg/table/message.go
+++ b/internal/pkg/table/message.go
@@ -85,9 +85,9 @@ func UpdatePathAttrs4ByteAs(msg *bgp.BGPUpdate) error {
asAttrPos := 0
as4AttrPos := 0
for i, attr := range msg.PathAttributes {
- switch attr.(type) {
+ switch a := attr.(type) {
case *bgp.PathAttributeAsPath:
- asAttr = attr.(*bgp.PathAttributeAsPath)
+ asAttr = a
for j, param := range asAttr.Value {
as2Param, ok := param.(*bgp.AsPathParam)
if ok {
@@ -103,7 +103,7 @@ func UpdatePathAttrs4ByteAs(msg *bgp.BGPUpdate) error {
msg.PathAttributes[i] = asAttr
case *bgp.PathAttributeAs4Path:
as4AttrPos = i
- as4Attr = attr.(*bgp.PathAttributeAs4Path)
+ as4Attr = a
}
}
@@ -211,9 +211,8 @@ func UpdatePathAggregator2ByteAs(msg *bgp.BGPUpdate) {
as := uint32(0)
var addr string
for i, attr := range msg.PathAttributes {
- switch attr.(type) {
+ switch agg := attr.(type) {
case *bgp.PathAttributeAggregator:
- agg := attr.(*bgp.PathAttributeAggregator)
addr = agg.Value.Address.String()
if agg.Value.AS > (1<<16)-1 {
as = agg.Value.AS
@@ -233,15 +232,15 @@ func UpdatePathAggregator4ByteAs(msg *bgp.BGPUpdate) error {
var agg4Attr *bgp.PathAttributeAs4Aggregator
agg4AttrPos := 0
for i, attr := range msg.PathAttributes {
- switch attr.(type) {
+ switch agg := attr.(type) {
case *bgp.PathAttributeAggregator:
- attr := attr.(*bgp.PathAttributeAggregator)
+ attr := agg
if attr.Value.Askind == reflect.Uint16 {
aggAttr = attr
aggAttr.Value.Askind = reflect.Uint32
}
case *bgp.PathAttributeAs4Aggregator:
- agg4Attr = attr.(*bgp.PathAttributeAs4Aggregator)
+ agg4Attr = agg
agg4AttrPos = i
}
}
diff --git a/internal/pkg/table/message_test.go b/internal/pkg/table/message_test.go
index 8b3287d3..8d2431e8 100644
--- a/internal/pkg/table/message_test.go
+++ b/internal/pkg/table/message_test.go
@@ -374,9 +374,9 @@ func TestASPathAs4TransMultipleLargeParams(t *testing.T) {
func TestAggregator4BytesASes(t *testing.T) {
getAggr := func(msg *bgp.BGPUpdate) *bgp.PathAttributeAggregator {
for _, attr := range msg.PathAttributes {
- switch attr.(type) {
+ switch a := attr.(type) {
case *bgp.PathAttributeAggregator:
- return attr.(*bgp.PathAttributeAggregator)
+ return a
}
}
return nil
@@ -384,9 +384,9 @@ func TestAggregator4BytesASes(t *testing.T) {
getAggr4 := func(msg *bgp.BGPUpdate) *bgp.PathAttributeAs4Aggregator {
for _, attr := range msg.PathAttributes {
- switch attr.(type) {
+ switch a := attr.(type) {
case *bgp.PathAttributeAs4Aggregator:
- return attr.(*bgp.PathAttributeAs4Aggregator)
+ return a
}
}
return nil
diff --git a/internal/pkg/table/policy.go b/internal/pkg/table/policy.go
index af07b784..bffc01c0 100644
--- a/internal/pkg/table/policy.go
+++ b/internal/pkg/table/policy.go
@@ -2586,7 +2586,7 @@ func NewAsPathPrependAction(action config.SetAsPathPrepend) (*AsPathPrependActio
default:
asn, err := strconv.ParseUint(action.As, 10, 32)
if err != nil {
- return nil, fmt.Errorf("As number string invalid")
+ return nil, fmt.Errorf("AS number string invalid")
}
a.asn = uint32(asn)
}
@@ -2692,39 +2692,28 @@ func (s *Statement) ToConfig() *config.Statement {
Conditions: func() config.Conditions {
cond := config.Conditions{}
for _, c := range s.Conditions {
- switch c.(type) {
+ switch v := c.(type) {
case *PrefixCondition:
- v := c.(*PrefixCondition)
cond.MatchPrefixSet = config.MatchPrefixSet{PrefixSet: v.set.Name(), MatchSetOptions: v.option.ConvertToMatchSetOptionsRestrictedType()}
case *NeighborCondition:
- v := c.(*NeighborCondition)
cond.MatchNeighborSet = config.MatchNeighborSet{NeighborSet: v.set.Name(), MatchSetOptions: v.option.ConvertToMatchSetOptionsRestrictedType()}
case *AsPathLengthCondition:
- v := c.(*AsPathLengthCondition)
cond.BgpConditions.AsPathLength = config.AsPathLength{Operator: config.IntToAttributeComparisonMap[int(v.operator)], Value: v.length}
case *AsPathCondition:
- v := c.(*AsPathCondition)
cond.BgpConditions.MatchAsPathSet = config.MatchAsPathSet{AsPathSet: v.set.Name(), MatchSetOptions: config.IntToMatchSetOptionsTypeMap[int(v.option)]}
case *CommunityCondition:
- v := c.(*CommunityCondition)
cond.BgpConditions.MatchCommunitySet = config.MatchCommunitySet{CommunitySet: v.set.Name(), MatchSetOptions: config.IntToMatchSetOptionsTypeMap[int(v.option)]}
case *ExtCommunityCondition:
- v := c.(*ExtCommunityCondition)
cond.BgpConditions.MatchExtCommunitySet = config.MatchExtCommunitySet{ExtCommunitySet: v.set.Name(), MatchSetOptions: config.IntToMatchSetOptionsTypeMap[int(v.option)]}
case *LargeCommunityCondition:
- v := c.(*LargeCommunityCondition)
cond.BgpConditions.MatchLargeCommunitySet = config.MatchLargeCommunitySet{LargeCommunitySet: v.set.Name(), MatchSetOptions: config.IntToMatchSetOptionsTypeMap[int(v.option)]}
case *NextHopCondition:
- v := c.(*NextHopCondition)
cond.BgpConditions.NextHopInList = v.set.List()
case *RpkiValidationCondition:
- v := c.(*RpkiValidationCondition)
cond.BgpConditions.RpkiValidationResult = v.result
case *RouteTypeCondition:
- v := c.(*RouteTypeCondition)
cond.BgpConditions.RouteType = v.typ
case *AfiSafiInCondition:
- v := c.(*AfiSafiInCondition)
res := make([]config.AfiSafiType, 0, len(v.routeFamilies))
for _, rf := range v.routeFamilies {
res = append(res, config.AfiSafiType(rf.String()))
@@ -2747,21 +2736,21 @@ func (s *Statement) ToConfig() *config.Statement {
act.RouteDisposition = config.ROUTE_DISPOSITION_NONE
}
for _, a := range s.ModActions {
- switch a.(type) {
+ switch v := a.(type) {
case *AsPathPrependAction:
- act.BgpActions.SetAsPathPrepend = *a.(*AsPathPrependAction).ToConfig()
+ act.BgpActions.SetAsPathPrepend = *v.ToConfig()
case *CommunityAction:
- act.BgpActions.SetCommunity = *a.(*CommunityAction).ToConfig()
+ act.BgpActions.SetCommunity = *v.ToConfig()
case *ExtCommunityAction:
- act.BgpActions.SetExtCommunity = *a.(*ExtCommunityAction).ToConfig()
+ act.BgpActions.SetExtCommunity = *v.ToConfig()
case *LargeCommunityAction:
- act.BgpActions.SetLargeCommunity = *a.(*LargeCommunityAction).ToConfig()
+ act.BgpActions.SetLargeCommunity = *v.ToConfig()
case *MedAction:
- act.BgpActions.SetMed = a.(*MedAction).ToConfig()
+ act.BgpActions.SetMed = v.ToConfig()
case *LocalPrefAction:
- act.BgpActions.SetLocalPref = a.(*LocalPrefAction).ToConfig()
+ act.BgpActions.SetLocalPref = v.ToConfig()
case *NexthopAction:
- act.BgpActions.SetNextHop = a.(*NexthopAction).ToConfig()
+ act.BgpActions.SetNextHop = v.ToConfig()
}
}
return act
@@ -3414,13 +3403,13 @@ func (r *RoutingPolicy) reload(c config.RoutingPolicy) error {
return err
}
if _, ok := pmap[y.Name]; ok {
- return fmt.Errorf("duplicated policy name. policy name must be unique.")
+ return fmt.Errorf("duplicated policy name. policy name must be unique")
}
pmap[y.Name] = y
for _, s := range y.Statements {
_, ok := smap[s.Name]
if ok {
- return fmt.Errorf("duplicated statement name. statement name must be unique.")
+ return fmt.Errorf("duplicated statement name. statement name must be unique")
}
smap[s.Name] = s
}
@@ -3480,19 +3469,19 @@ func (r *RoutingPolicy) GetDefinedSet(typ DefinedType, name string) (*config.Def
if name != "" && s.Name() != name {
continue
}
- switch s.(type) {
+ switch v := s.(type) {
case *PrefixSet:
- sets.PrefixSets = append(sets.PrefixSets, *s.(*PrefixSet).ToConfig())
+ sets.PrefixSets = append(sets.PrefixSets, *v.ToConfig())
case *NeighborSet:
- sets.NeighborSets = append(sets.NeighborSets, *s.(*NeighborSet).ToConfig())
+ sets.NeighborSets = append(sets.NeighborSets, *v.ToConfig())
case *CommunitySet:
- sets.BgpDefinedSets.CommunitySets = append(sets.BgpDefinedSets.CommunitySets, *s.(*CommunitySet).ToConfig())
+ sets.BgpDefinedSets.CommunitySets = append(sets.BgpDefinedSets.CommunitySets, *v.ToConfig())
case *ExtCommunitySet:
- sets.BgpDefinedSets.ExtCommunitySets = append(sets.BgpDefinedSets.ExtCommunitySets, *s.(*ExtCommunitySet).ToConfig())
+ sets.BgpDefinedSets.ExtCommunitySets = append(sets.BgpDefinedSets.ExtCommunitySets, *v.ToConfig())
case *LargeCommunitySet:
- sets.BgpDefinedSets.LargeCommunitySets = append(sets.BgpDefinedSets.LargeCommunitySets, *s.(*LargeCommunitySet).ToConfig())
+ sets.BgpDefinedSets.LargeCommunitySets = append(sets.BgpDefinedSets.LargeCommunitySets, *v.ToConfig())
case *AsPathSet:
- sets.BgpDefinedSets.AsPathSets = append(sets.BgpDefinedSets.AsPathSets, *s.(*AsPathSet).ToConfig())
+ sets.BgpDefinedSets.AsPathSets = append(sets.BgpDefinedSets.AsPathSets, *v.ToConfig())
}
}
return sets, nil
diff --git a/internal/pkg/table/table.go b/internal/pkg/table/table.go
index bcde936b..a2002b41 100644
--- a/internal/pkg/table/table.go
+++ b/internal/pkg/table/table.go
@@ -75,13 +75,13 @@ func (t *Table) deletePathsByVrf(vrf *Vrf) []*Path {
for _, p := range dest.knownPathList {
var rd bgp.RouteDistinguisherInterface
nlri := p.GetNlri()
- switch nlri.(type) {
+ switch v := nlri.(type) {
case *bgp.LabeledVPNIPAddrPrefix:
- rd = nlri.(*bgp.LabeledVPNIPAddrPrefix).RD
+ rd = v.RD
case *bgp.LabeledVPNIPv6AddrPrefix:
- rd = nlri.(*bgp.LabeledVPNIPv6AddrPrefix).RD
+ rd = v.RD
case *bgp.EVPNNLRI:
- rd = nlri.(*bgp.EVPNNLRI).RD()
+ rd = v.RD()
default:
return pathList
}
diff --git a/internal/pkg/zebra/zapi.go b/internal/pkg/zebra/zapi.go
index e4391ca6..7a069530 100644
--- a/internal/pkg/zebra/zapi.go
+++ b/internal/pkg/zebra/zapi.go
@@ -1352,20 +1352,20 @@ func (h *Header) Serialize() ([]byte, error) {
binary.BigEndian.PutUint32(buf[4:8], uint32(h.VrfId))
binary.BigEndian.PutUint16(buf[8:10], uint16(h.Command))
default:
- return nil, fmt.Errorf("Unsupported ZAPI version: %d", h.Version)
+ return nil, fmt.Errorf("unsupported ZAPI version: %d", h.Version)
}
return buf, nil
}
func (h *Header) DecodeFromBytes(data []byte) error {
if uint16(len(data)) < 4 {
- return fmt.Errorf("Not all ZAPI message header")
+ return fmt.Errorf("not all ZAPI message header")
}
h.Len = binary.BigEndian.Uint16(data[0:2])
h.Marker = data[2]
h.Version = data[3]
if uint16(len(data)) < HeaderSize(h.Version) {
- return fmt.Errorf("Not all ZAPI message header")
+ return fmt.Errorf("not all ZAPI message header")
}
switch h.Version {
case 2:
@@ -1377,7 +1377,7 @@ func (h *Header) DecodeFromBytes(data []byte) error {
h.VrfId = binary.BigEndian.Uint32(data[4:8])
h.Command = API_TYPE(binary.BigEndian.Uint16(data[8:10]))
default:
- return fmt.Errorf("Unsupported ZAPI version: %d", h.Version)
+ return fmt.Errorf("unsupported ZAPI version: %d", h.Version)
}
return nil
}
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()
diff --git a/tools/pyang_plugins/bgpyang2golang.py b/tools/pyang_plugins/bgpyang2golang.py
index 01ee9c3b..e2545135 100644
--- a/tools/pyang_plugins/bgpyang2golang.py
+++ b/tools/pyang_plugins/bgpyang2golang.py
@@ -39,6 +39,7 @@ _COPYRIGHT_NOTICE = """
// See the License for the specific language governing permissions and
// limitations under the License.
+//lint:file-ignore S1008 generated code.
"""
EQUAL_TYPE_LEAF = 0