diff options
Diffstat (limited to 'internal')
-rw-r--r-- | internal/pkg/config/bgp_configs.go | 2 | ||||
-rw-r--r-- | internal/pkg/table/destination.go | 2 | ||||
-rw-r--r-- | internal/pkg/table/message.go | 15 | ||||
-rw-r--r-- | internal/pkg/table/message_test.go | 8 | ||||
-rw-r--r-- | internal/pkg/table/policy.go | 49 | ||||
-rw-r--r-- | internal/pkg/table/table.go | 8 | ||||
-rw-r--r-- | internal/pkg/zebra/zapi.go | 8 |
7 files changed, 41 insertions, 51 deletions
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 } |