summaryrefslogtreecommitdiffhomepage
path: root/internal
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@gmail.com>2020-10-20 14:49:08 +0900
committerFUJITA Tomonori <fujita.tomonori@gmail.com>2020-11-09 23:10:34 +0900
commit3df131c6ba76626ebd223f512e1308193ca5e37c (patch)
tree339b20948fe7f077b0aebbb9ca031ecbbf137a66 /internal
parent3d51923e3c33da286a4242627d00933aaad19eec (diff)
server: fix conversion from api.RouteAction to config.DefaultPolicyType
Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com>
Diffstat (limited to 'internal')
-rw-r--r--internal/pkg/config/util.go12
1 files changed, 10 insertions, 2 deletions
diff --git a/internal/pkg/config/util.go b/internal/pkg/config/util.go
index cc9ea059..d18deb50 100644
--- a/internal/pkg/config/util.go
+++ b/internal/pkg/config/util.go
@@ -299,14 +299,22 @@ func newAfiSafiConfigFromConfigStruct(c *AfiSafi) *api.AfiSafiConfig {
}
func newApplyPolicyFromConfigStruct(c *ApplyPolicy) *api.ApplyPolicy {
+ f := func(t DefaultPolicyType) api.RouteAction {
+ if t == DEFAULT_POLICY_TYPE_ACCEPT_ROUTE {
+ return api.RouteAction_ACCEPT
+ } else if t == DEFAULT_POLICY_TYPE_REJECT_ROUTE {
+ return api.RouteAction_REJECT
+ }
+ return api.RouteAction_NONE
+ }
applyPolicy := &api.ApplyPolicy{
ImportPolicy: &api.PolicyAssignment{
Direction: api.PolicyDirection_IMPORT,
- DefaultAction: api.RouteAction(c.Config.DefaultImportPolicy.ToInt()),
+ DefaultAction: f(c.Config.DefaultImportPolicy),
},
ExportPolicy: &api.PolicyAssignment{
Direction: api.PolicyDirection_EXPORT,
- DefaultAction: api.RouteAction(c.Config.DefaultExportPolicy.ToInt()),
+ DefaultAction: f(c.Config.DefaultExportPolicy),
},
}