summaryrefslogtreecommitdiffhomepage
path: root/internal
diff options
context:
space:
mode:
authoroc <oc@yunify.com>2018-11-05 21:10:25 +0800
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2018-11-07 15:29:59 +0900
commit5ab45752ce5a7dbbb16f357f8d405fb272eab512 (patch)
treeb28e1ea84f32593b67da825f44011f50d75d7eff /internal
parent60202fccc41ab35f616e050e13aeb20f82444533 (diff)
api: fix regression that match set option has no default value
The commit 000589f3c "api: Implement UpdatePolicy()" introduced a regression: if match-set-options is not defined in config file, gobgpd starts with error: failed to get policy info: not found... This fix set match-set-options to default when needed.
Diffstat (limited to 'internal')
-rw-r--r--internal/pkg/config/bgp_configs.go352
1 files changed, 176 insertions, 176 deletions
diff --git a/internal/pkg/config/bgp_configs.go b/internal/pkg/config/bgp_configs.go
index 5c3cff97..21e16fd8 100644
--- a/internal/pkg/config/bgp_configs.go
+++ b/internal/pkg/config/bgp_configs.go
@@ -55,14 +55,6 @@ var RemovePrivateAsOptionToIntMap = map[RemovePrivateAsOption]int{
REMOVE_PRIVATE_AS_OPTION_REPLACE: 1,
}
-func (v RemovePrivateAsOption) ToInt() int {
- i, ok := RemovePrivateAsOptionToIntMap[v]
- if !ok {
- return -1
- }
- return i
-}
-
var IntToRemovePrivateAsOptionMap = map[int]RemovePrivateAsOption{
0: REMOVE_PRIVATE_AS_OPTION_ALL,
1: REMOVE_PRIVATE_AS_OPTION_REPLACE,
@@ -75,6 +67,14 @@ func (v RemovePrivateAsOption) Validate() error {
return nil
}
+func (v RemovePrivateAsOption) ToInt() int {
+ i, ok := RemovePrivateAsOptionToIntMap[v]
+ if !ok {
+ return -1
+ }
+ return i
+}
+
// typedef for typedef bgp-types:bgp-community-regexp-type.
type BgpCommunityRegexpType StdRegexp
@@ -99,14 +99,6 @@ var CommunityTypeToIntMap = map[CommunityType]int{
COMMUNITY_TYPE_NONE: 3,
}
-func (v CommunityType) ToInt() int {
- i, ok := CommunityTypeToIntMap[v]
- if !ok {
- return -1
- }
- return i
-}
-
var IntToCommunityTypeMap = map[int]CommunityType{
0: COMMUNITY_TYPE_STANDARD,
1: COMMUNITY_TYPE_EXTENDED,
@@ -121,6 +113,14 @@ func (v CommunityType) Validate() error {
return nil
}
+func (v CommunityType) ToInt() int {
+ i, ok := CommunityTypeToIntMap[v]
+ if !ok {
+ return -1
+ }
+ return i
+}
+
// typedef for typedef bgp-types:bgp-ext-community-type.
type BgpExtCommunityType string
@@ -142,14 +142,6 @@ var PeerTypeToIntMap = map[PeerType]int{
PEER_TYPE_EXTERNAL: 1,
}
-func (v PeerType) ToInt() int {
- i, ok := PeerTypeToIntMap[v]
- if !ok {
- return -1
- }
- return i
-}
-
var IntToPeerTypeMap = map[int]PeerType{
0: PEER_TYPE_INTERNAL,
1: PEER_TYPE_EXTERNAL,
@@ -162,6 +154,14 @@ func (v PeerType) Validate() error {
return nil
}
+func (v PeerType) ToInt() int {
+ i, ok := PeerTypeToIntMap[v]
+ if !ok {
+ return -1
+ }
+ return i
+}
+
// typedef for identity bgp-types:bgp-session-direction.
// Type to describe the direction of NLRI transmission.
type BgpSessionDirection string
@@ -176,14 +176,6 @@ var BgpSessionDirectionToIntMap = map[BgpSessionDirection]int{
BGP_SESSION_DIRECTION_OUTBOUND: 1,
}
-func (v BgpSessionDirection) ToInt() int {
- i, ok := BgpSessionDirectionToIntMap[v]
- if !ok {
- return -1
- }
- return i
-}
-
var IntToBgpSessionDirectionMap = map[int]BgpSessionDirection{
0: BGP_SESSION_DIRECTION_INBOUND,
1: BGP_SESSION_DIRECTION_OUTBOUND,
@@ -196,6 +188,14 @@ func (v BgpSessionDirection) Validate() error {
return nil
}
+func (v BgpSessionDirection) ToInt() int {
+ i, ok := BgpSessionDirectionToIntMap[v]
+ if !ok {
+ return -1
+ }
+ return i
+}
+
// typedef for identity bgp-types:bgp-origin-attr-type.
// Type definition for standard BGP origin attribute.
type BgpOriginAttrType string
@@ -212,14 +212,6 @@ var BgpOriginAttrTypeToIntMap = map[BgpOriginAttrType]int{
BGP_ORIGIN_ATTR_TYPE_INCOMPLETE: 2,
}
-func (v BgpOriginAttrType) ToInt() int {
- i, ok := BgpOriginAttrTypeToIntMap[v]
- if !ok {
- return -1
- }
- return i
-}
-
var IntToBgpOriginAttrTypeMap = map[int]BgpOriginAttrType{
0: BGP_ORIGIN_ATTR_TYPE_IGP,
1: BGP_ORIGIN_ATTR_TYPE_EGP,
@@ -233,6 +225,14 @@ func (v BgpOriginAttrType) Validate() error {
return nil
}
+func (v BgpOriginAttrType) ToInt() int {
+ i, ok := BgpOriginAttrTypeToIntMap[v]
+ if !ok {
+ return -1
+ }
+ return i
+}
+
// typedef for identity bgp-types:afi-safi-type.
// Base identity type for AFI,SAFI tuples for BGP-4.
type AfiSafiType string
@@ -285,14 +285,6 @@ var AfiSafiTypeToIntMap = map[AfiSafiType]int{
AFI_SAFI_TYPE_OPAQUE: 20,
}
-func (v AfiSafiType) ToInt() int {
- i, ok := AfiSafiTypeToIntMap[v]
- if !ok {
- return -1
- }
- return i
-}
-
var IntToAfiSafiTypeMap = map[int]AfiSafiType{
0: AFI_SAFI_TYPE_IPV4_UNICAST,
1: AFI_SAFI_TYPE_IPV6_UNICAST,
@@ -324,6 +316,14 @@ func (v AfiSafiType) Validate() error {
return nil
}
+func (v AfiSafiType) ToInt() int {
+ i, ok := AfiSafiTypeToIntMap[v]
+ if !ok {
+ return -1
+ }
+ return i
+}
+
// typedef for identity bgp-types:bgp-capability.
// Base identity for a BGP capability.
type BgpCapability string
@@ -344,14 +344,6 @@ var BgpCapabilityToIntMap = map[BgpCapability]int{
BGP_CAPABILITY_ADD_PATHS: 4,
}
-func (v BgpCapability) ToInt() int {
- i, ok := BgpCapabilityToIntMap[v]
- if !ok {
- return -1
- }
- return i
-}
-
var IntToBgpCapabilityMap = map[int]BgpCapability{
0: BGP_CAPABILITY_MPBGP,
1: BGP_CAPABILITY_ROUTE_REFRESH,
@@ -367,6 +359,14 @@ func (v BgpCapability) Validate() error {
return nil
}
+func (v BgpCapability) ToInt() int {
+ i, ok := BgpCapabilityToIntMap[v]
+ if !ok {
+ return -1
+ }
+ return i
+}
+
// typedef for identity bgp-types:bgp-well-known-std-community.
// Reserved communities within the standard community space
// defined by RFC1997. These communities must fall within the
@@ -387,14 +387,6 @@ var BgpWellKnownStdCommunityToIntMap = map[BgpWellKnownStdCommunity]int{
BGP_WELL_KNOWN_STD_COMMUNITY_NOPEER: 3,
}
-func (v BgpWellKnownStdCommunity) ToInt() int {
- i, ok := BgpWellKnownStdCommunityToIntMap[v]
- if !ok {
- return -1
- }
- return i
-}
-
var IntToBgpWellKnownStdCommunityMap = map[int]BgpWellKnownStdCommunity{
0: BGP_WELL_KNOWN_STD_COMMUNITY_NO_EXPORT,
1: BGP_WELL_KNOWN_STD_COMMUNITY_NO_ADVERTISE,
@@ -409,6 +401,14 @@ func (v BgpWellKnownStdCommunity) Validate() error {
return nil
}
+func (v BgpWellKnownStdCommunity) ToInt() int {
+ i, ok := BgpWellKnownStdCommunityToIntMap[v]
+ if !ok {
+ return -1
+ }
+ return i
+}
+
// typedef for identity ptypes:match-set-options-restricted-type.
// Options that govern the behavior of a match statement. The
// default behavior is ANY, i.e., the given value matches any
@@ -426,14 +426,6 @@ var MatchSetOptionsRestrictedTypeToIntMap = map[MatchSetOptionsRestrictedType]in
MATCH_SET_OPTIONS_RESTRICTED_TYPE_INVERT: 1,
}
-func (v MatchSetOptionsRestrictedType) ToInt() int {
- i, ok := MatchSetOptionsRestrictedTypeToIntMap[v]
- if !ok {
- return -1
- }
- return i
-}
-
var IntToMatchSetOptionsRestrictedTypeMap = map[int]MatchSetOptionsRestrictedType{
0: MATCH_SET_OPTIONS_RESTRICTED_TYPE_ANY,
1: MATCH_SET_OPTIONS_RESTRICTED_TYPE_INVERT,
@@ -456,6 +448,14 @@ func (v MatchSetOptionsRestrictedType) DefaultAsNeeded() MatchSetOptionsRestrict
}
return v
}
+func (v MatchSetOptionsRestrictedType) ToInt() int {
+ _v := v.DefaultAsNeeded()
+ i, ok := MatchSetOptionsRestrictedTypeToIntMap[_v]
+ if !ok {
+ return -1
+ }
+ return i
+}
// typedef for identity ptypes:match-set-options-type.
// Options that govern the behavior of a match statement. The
@@ -475,14 +475,6 @@ var MatchSetOptionsTypeToIntMap = map[MatchSetOptionsType]int{
MATCH_SET_OPTIONS_TYPE_INVERT: 2,
}
-func (v MatchSetOptionsType) ToInt() int {
- i, ok := MatchSetOptionsTypeToIntMap[v]
- if !ok {
- return -1
- }
- return i
-}
-
var IntToMatchSetOptionsTypeMap = map[int]MatchSetOptionsType{
0: MATCH_SET_OPTIONS_TYPE_ANY,
1: MATCH_SET_OPTIONS_TYPE_ALL,
@@ -506,6 +498,14 @@ func (v MatchSetOptionsType) DefaultAsNeeded() MatchSetOptionsType {
}
return v
}
+func (v MatchSetOptionsType) ToInt() int {
+ _v := v.DefaultAsNeeded()
+ i, ok := MatchSetOptionsTypeToIntMap[_v]
+ if !ok {
+ return -1
+ }
+ return i
+}
// typedef for typedef ptypes:tag-type.
type TagType string
@@ -535,14 +535,6 @@ var InstallProtocolTypeToIntMap = map[InstallProtocolType]int{
INSTALL_PROTOCOL_TYPE_LOCAL_AGGREGATE: 6,
}
-func (v InstallProtocolType) ToInt() int {
- i, ok := InstallProtocolTypeToIntMap[v]
- if !ok {
- return -1
- }
- return i
-}
-
var IntToInstallProtocolTypeMap = map[int]InstallProtocolType{
0: INSTALL_PROTOCOL_TYPE_BGP,
1: INSTALL_PROTOCOL_TYPE_ISIS,
@@ -560,6 +552,14 @@ func (v InstallProtocolType) Validate() error {
return nil
}
+func (v InstallProtocolType) ToInt() int {
+ i, ok := InstallProtocolTypeToIntMap[v]
+ if !ok {
+ return -1
+ }
+ return i
+}
+
// typedef for identity ptypes:attribute-comparison.
// base type for supported comparison operators on route
// attributes.
@@ -583,14 +583,6 @@ var AttributeComparisonToIntMap = map[AttributeComparison]int{
ATTRIBUTE_COMPARISON_LE: 5,
}
-func (v AttributeComparison) ToInt() int {
- i, ok := AttributeComparisonToIntMap[v]
- if !ok {
- return -1
- }
- return i
-}
-
var IntToAttributeComparisonMap = map[int]AttributeComparison{
0: ATTRIBUTE_COMPARISON_ATTRIBUTE_EQ,
1: ATTRIBUTE_COMPARISON_ATTRIBUTE_GE,
@@ -607,6 +599,14 @@ func (v AttributeComparison) Validate() error {
return nil
}
+func (v AttributeComparison) ToInt() int {
+ i, ok := AttributeComparisonToIntMap[v]
+ if !ok {
+ return -1
+ }
+ return i
+}
+
// typedef for identity rpol:route-disposition.
// Select the final disposition for the route, either
// accept or reject.
@@ -624,14 +624,6 @@ var RouteDispositionToIntMap = map[RouteDisposition]int{
ROUTE_DISPOSITION_REJECT_ROUTE: 2,
}
-func (v RouteDisposition) ToInt() int {
- i, ok := RouteDispositionToIntMap[v]
- if !ok {
- return -1
- }
- return i
-}
-
var IntToRouteDispositionMap = map[int]RouteDisposition{
0: ROUTE_DISPOSITION_NONE,
1: ROUTE_DISPOSITION_ACCEPT_ROUTE,
@@ -645,6 +637,14 @@ func (v RouteDisposition) Validate() error {
return nil
}
+func (v RouteDisposition) ToInt() int {
+ i, ok := RouteDispositionToIntMap[v]
+ if !ok {
+ return -1
+ }
+ return i
+}
+
// typedef for identity rpol:route-type.
// Condition to check the route type in the route update.
type RouteType string
@@ -663,14 +663,6 @@ var RouteTypeToIntMap = map[RouteType]int{
ROUTE_TYPE_LOCAL: 3,
}
-func (v RouteType) ToInt() int {
- i, ok := RouteTypeToIntMap[v]
- if !ok {
- return -1
- }
- return i
-}
-
var IntToRouteTypeMap = map[int]RouteType{
0: ROUTE_TYPE_NONE,
1: ROUTE_TYPE_INTERNAL,
@@ -685,6 +677,14 @@ func (v RouteType) Validate() error {
return nil
}
+func (v RouteType) ToInt() int {
+ i, ok := RouteTypeToIntMap[v]
+ if !ok {
+ return -1
+ }
+ return i
+}
+
// typedef for identity rpol:default-policy-type.
// type used to specify default route disposition in
// a policy chain.
@@ -700,14 +700,6 @@ var DefaultPolicyTypeToIntMap = map[DefaultPolicyType]int{
DEFAULT_POLICY_TYPE_REJECT_ROUTE: 1,
}
-func (v DefaultPolicyType) ToInt() int {
- i, ok := DefaultPolicyTypeToIntMap[v]
- if !ok {
- return -1
- }
- return i
-}
-
var IntToDefaultPolicyTypeMap = map[int]DefaultPolicyType{
0: DEFAULT_POLICY_TYPE_ACCEPT_ROUTE,
1: DEFAULT_POLICY_TYPE_REJECT_ROUTE,
@@ -720,6 +712,14 @@ func (v DefaultPolicyType) Validate() error {
return nil
}
+func (v DefaultPolicyType) ToInt() int {
+ i, ok := DefaultPolicyTypeToIntMap[v]
+ if !ok {
+ return -1
+ }
+ return i
+}
+
// typedef for identity bgp:session-state.
// Operational state of the BGP peer.
type SessionState string
@@ -742,14 +742,6 @@ var SessionStateToIntMap = map[SessionState]int{
SESSION_STATE_ESTABLISHED: 5,
}
-func (v SessionState) ToInt() int {
- i, ok := SessionStateToIntMap[v]
- if !ok {
- return -1
- }
- return i
-}
-
var IntToSessionStateMap = map[int]SessionState{
0: SESSION_STATE_IDLE,
1: SESSION_STATE_CONNECT,
@@ -766,6 +758,14 @@ func (v SessionState) Validate() error {
return nil
}
+func (v SessionState) ToInt() int {
+ i, ok := SessionStateToIntMap[v]
+ if !ok {
+ return -1
+ }
+ return i
+}
+
// typedef for identity bgp:admin-state.
type AdminState string
@@ -781,14 +781,6 @@ var AdminStateToIntMap = map[AdminState]int{
ADMIN_STATE_PFX_CT: 2,
}
-func (v AdminState) ToInt() int {
- i, ok := AdminStateToIntMap[v]
- if !ok {
- return -1
- }
- return i
-}
-
var IntToAdminStateMap = map[int]AdminState{
0: ADMIN_STATE_UP,
1: ADMIN_STATE_DOWN,
@@ -802,6 +794,14 @@ func (v AdminState) Validate() error {
return nil
}
+func (v AdminState) ToInt() int {
+ i, ok := AdminStateToIntMap[v]
+ if !ok {
+ return -1
+ }
+ return i
+}
+
// typedef for identity bgp:mode.
// Ths leaf indicates the mode of operation of BGP graceful
// restart with the peer.
@@ -819,14 +819,6 @@ var ModeToIntMap = map[Mode]int{
MODE_REMOTE_HELPER: 2,
}
-func (v Mode) ToInt() int {
- i, ok := ModeToIntMap[v]
- if !ok {
- return -1
- }
- return i
-}
-
var IntToModeMap = map[int]Mode{
0: MODE_HELPER_ONLY,
1: MODE_BILATERAL,
@@ -840,6 +832,14 @@ func (v Mode) Validate() error {
return nil
}
+func (v Mode) ToInt() int {
+ i, ok := ModeToIntMap[v]
+ if !ok {
+ return -1
+ }
+ return i
+}
+
// typedef for typedef bgp-pol:bgp-next-hop-type.
type BgpNextHopType string
@@ -866,14 +866,6 @@ var BgpSetCommunityOptionTypeToIntMap = map[BgpSetCommunityOptionType]int{
BGP_SET_COMMUNITY_OPTION_TYPE_REPLACE: 2,
}
-func (v BgpSetCommunityOptionType) ToInt() int {
- i, ok := BgpSetCommunityOptionTypeToIntMap[v]
- if !ok {
- return -1
- }
- return i
-}
-
var IntToBgpSetCommunityOptionTypeMap = map[int]BgpSetCommunityOptionType{
0: BGP_SET_COMMUNITY_OPTION_TYPE_ADD,
1: BGP_SET_COMMUNITY_OPTION_TYPE_REMOVE,
@@ -887,6 +879,14 @@ func (v BgpSetCommunityOptionType) Validate() error {
return nil
}
+func (v BgpSetCommunityOptionType) ToInt() int {
+ i, ok := BgpSetCommunityOptionTypeToIntMap[v]
+ if !ok {
+ return -1
+ }
+ return i
+}
+
// typedef for identity gobgp:bmp-route-monitoring-policy-type.
type BmpRouteMonitoringPolicyType string
@@ -906,14 +906,6 @@ var BmpRouteMonitoringPolicyTypeToIntMap = map[BmpRouteMonitoringPolicyType]int{
BMP_ROUTE_MONITORING_POLICY_TYPE_ALL: 4,
}
-func (v BmpRouteMonitoringPolicyType) ToInt() int {
- i, ok := BmpRouteMonitoringPolicyTypeToIntMap[v]
- if !ok {
- return -1
- }
- return i
-}
-
var IntToBmpRouteMonitoringPolicyTypeMap = map[int]BmpRouteMonitoringPolicyType{
0: BMP_ROUTE_MONITORING_POLICY_TYPE_PRE_POLICY,
1: BMP_ROUTE_MONITORING_POLICY_TYPE_POST_POLICY,
@@ -929,6 +921,14 @@ func (v BmpRouteMonitoringPolicyType) Validate() error {
return nil
}
+func (v BmpRouteMonitoringPolicyType) ToInt() int {
+ i, ok := BmpRouteMonitoringPolicyTypeToIntMap[v]
+ if !ok {
+ return -1
+ }
+ return i
+}
+
// typedef for identity gobgp:mrt-type.
type MrtType string
@@ -942,14 +942,6 @@ var MrtTypeToIntMap = map[MrtType]int{
MRT_TYPE_TABLE: 1,
}
-func (v MrtType) ToInt() int {
- i, ok := MrtTypeToIntMap[v]
- if !ok {
- return -1
- }
- return i
-}
-
var IntToMrtTypeMap = map[int]MrtType{
0: MRT_TYPE_UPDATES,
1: MRT_TYPE_TABLE,
@@ -962,6 +954,14 @@ func (v MrtType) Validate() error {
return nil
}
+func (v MrtType) ToInt() int {
+ i, ok := MrtTypeToIntMap[v]
+ if !ok {
+ return -1
+ }
+ return i
+}
+
// typedef for identity gobgp:rpki-validation-result-type.
// indicate the validation result of RPKI based on ROA.
type RpkiValidationResultType string
@@ -980,14 +980,6 @@ var RpkiValidationResultTypeToIntMap = map[RpkiValidationResultType]int{
RPKI_VALIDATION_RESULT_TYPE_INVALID: 3,
}
-func (v RpkiValidationResultType) ToInt() int {
- i, ok := RpkiValidationResultTypeToIntMap[v]
- if !ok {
- return -1
- }
- return i
-}
-
var IntToRpkiValidationResultTypeMap = map[int]RpkiValidationResultType{
0: RPKI_VALIDATION_RESULT_TYPE_NONE,
1: RPKI_VALIDATION_RESULT_TYPE_NOT_FOUND,
@@ -1002,6 +994,14 @@ func (v RpkiValidationResultType) Validate() error {
return nil
}
+func (v RpkiValidationResultType) ToInt() int {
+ i, ok := RpkiValidationResultTypeToIntMap[v]
+ if !ok {
+ return -1
+ }
+ return i
+}
+
// struct for container gobgp:state.
type DynamicNeighborState struct {
// original -> gobgp:prefix