diff options
author | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2015-08-22 11:33:14 +0900 |
---|---|---|
committer | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2015-08-22 13:07:13 +0900 |
commit | da62a698664abaf0f8d321824b5ee69f2cf0fba4 (patch) | |
tree | 4a5d99f8f10b00f25db2e31534c055fb1a82e3ff | |
parent | 424ff51342c6691ee136c82b3199f2aeb2983f23 (diff) |
api/cli: support showing extended community action
Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
-rw-r--r-- | api/gobgp.pb.go | 16 | ||||
-rw-r--r-- | api/gobgp.proto | 1 | ||||
-rw-r--r-- | gobgp/policy.go | 14 | ||||
-rw-r--r-- | policy/policy.go | 13 |
4 files changed, 31 insertions, 13 deletions
diff --git a/api/gobgp.pb.go b/api/gobgp.pb.go index 9ef9cbef..dbcc63d5 100644 --- a/api/gobgp.pb.go +++ b/api/gobgp.pb.go @@ -601,10 +601,11 @@ func (m *AsPrependAction) String() string { return proto.CompactTextString(m) } func (*AsPrependAction) ProtoMessage() {} type Actions struct { - RouteAction string `protobuf:"bytes,1,opt,name=route_action" json:"route_action,omitempty"` - Community *CommunityAction `protobuf:"bytes,2,opt,name=community" json:"community,omitempty"` - Med string `protobuf:"bytes,3,opt,name=med" json:"med,omitempty"` - AsPrepend *AsPrependAction `protobuf:"bytes,4,opt,name=as_prepend" json:"as_prepend,omitempty"` + RouteAction string `protobuf:"bytes,1,opt,name=route_action" json:"route_action,omitempty"` + Community *CommunityAction `protobuf:"bytes,2,opt,name=community" json:"community,omitempty"` + Med string `protobuf:"bytes,3,opt,name=med" json:"med,omitempty"` + AsPrepend *AsPrependAction `protobuf:"bytes,4,opt,name=as_prepend" json:"as_prepend,omitempty"` + ExtCommunity *CommunityAction `protobuf:"bytes,5,opt,name=ext_community" json:"ext_community,omitempty"` } func (m *Actions) Reset() { *m = Actions{} } @@ -625,6 +626,13 @@ func (m *Actions) GetAsPrepend() *AsPrependAction { return nil } +func (m *Actions) GetExtCommunity() *CommunityAction { + if m != nil { + return m.ExtCommunity + } + return nil +} + type Statement struct { StatementNeme string `protobuf:"bytes,1,opt,name=statement_neme" json:"statement_neme,omitempty"` Conditions *Conditions `protobuf:"bytes,2,opt,name=conditions" json:"conditions,omitempty"` diff --git a/api/gobgp.proto b/api/gobgp.proto index 259bdfff..135fff8c 100644 --- a/api/gobgp.proto +++ b/api/gobgp.proto @@ -265,6 +265,7 @@ message Actions { CommunityAction community = 2; string med = 3; AsPrependAction as_prepend = 4; + CommunityAction ext_community = 5; } message Statement { diff --git a/gobgp/policy.go b/gobgp/policy.go index 3bcc7d34..7d88d723 100644 --- a/gobgp/policy.go +++ b/gobgp/policy.go @@ -1050,12 +1050,16 @@ func showPolicyStatement(indent int, pd *api.PolicyDefinition) { fmt.Printf("%sAsPathLength: %-6s %s\n", sIndent(indent+4), asPathLentgh.Operator, asPathLentgh.Value) fmt.Printf("%sActions:\n", sIndent(indent+2)) - communityAction := st.Actions.Community.Options - if len(st.Actions.Community.Communities) != 0 || st.Actions.Community.Options == "NULL" { - communities := strings.Join(st.Actions.Community.Communities, ",") - communityAction = fmt.Sprintf("%s[%s]", st.Actions.Community.Options, communities) + formatComAction := func(c *api.CommunityAction) string { + communityAction := c.Options + if len(c.Communities) != 0 || c.Options == "NULL" { + communities := strings.Join(c.Communities, ",") + communityAction = fmt.Sprintf("%s[%s]", c.Options, communities) + } + return communityAction } - fmt.Printf("%sCommunity: %s\n", sIndent(indent+4), communityAction) + fmt.Printf("%sCommunity: %s\n", sIndent(indent+4), formatComAction(st.Actions.Community)) + fmt.Printf("%sExtCommunity: %s\n", sIndent(indent+4), formatComAction(st.Actions.ExtCommunity)) fmt.Printf("%sMed: %s\n", sIndent(indent+4), st.Actions.Med) asn := "" diff --git a/policy/policy.go b/policy/policy.go index a07dbc4a..5d0c3b9a 100644 --- a/policy/policy.go +++ b/policy/policy.go @@ -1877,12 +1877,17 @@ func ActionsToApiStruct(conActions config.Actions) *api.Actions { conActions.BgpActions.SetAsPathPrepend.As, uint32(conActions.BgpActions.SetAsPathPrepend.RepeatN), } + extCommunityAction := &api.CommunityAction{ + Communities: conActions.BgpActions.SetExtCommunity.SetExtCommunityMethod.Communities, + Options: conActions.BgpActions.SetExtCommunity.Options, + } resActions := &api.Actions{ - RouteAction: action, - Community: communityAction, - Med: medAction, - AsPrepend: asprependAction, + RouteAction: action, + Community: communityAction, + Med: medAction, + AsPrepend: asprependAction, + ExtCommunity: extCommunityAction, } return resActions } |