diff options
author | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2016-01-10 17:45:34 +0900 |
---|---|---|
committer | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2016-01-10 20:03:27 +0900 |
commit | 427c665579e07edafc69351ffb4ab498a801d8b3 (patch) | |
tree | d512aaabe77f2becd562bb19ebfb935d4c7c216f /packet | |
parent | 749b47a1183e555cdedc216065f45326a3897c21 (diff) |
policy: support an action to add origin-validation ext-community
you can implement
https://tools.ietf.org/html/draft-kklf-sidr-route-server-rpki-light-00
by following commands
$ gobgp policy statement st0 add condition rpki valid
$ gobgp policy statement st0 add action ext-community add valid
$ gobgp policy statement st1 add condition rpki not-found
$ gobgp policy statement st1 add action ext-community add not-found
$ gobgp policy statement st2 add condition rpki invalid
$ gobgp policy statement st2 add action ext-community add invalid
$ gobgp policy p0 add st0 st1 st2
$ gobgp policy p0
Name p0:
StatementName st0:
Conditions:
RPKI result: valid
Actions:
ExtCommunity: COMMUNITY_ADD[valid]
NONE
StatementName st1:
Conditions:
RPKI result: not-found
Actions:
ExtCommunity: COMMUNITY_ADD[not-found]
NONE
StatementName st2:
Conditions:
RPKI result: invalid
Actions:
ExtCommunity: COMMUNITY_ADD[invalid]
NONE
Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Diffstat (limited to 'packet')
-rw-r--r-- | packet/bgp.go | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/packet/bgp.go b/packet/bgp.go index 1d7b65cc..d47e3b65 100644 --- a/packet/bgp.go +++ b/packet/bgp.go @@ -4559,6 +4559,25 @@ func NewFourOctetAsSpecificExtended(subtype ExtendedCommunityAttrSubType, as uin } func ParseExtendedCommunity(subtype ExtendedCommunityAttrSubType, com string) (ExtendedCommunityInterface, error) { + if subtype == EC_SUBTYPE_ORIGIN_VALIDATION { + var value ValidationState + switch com { + case VALIDATION_STATE_VALID.String(): + value = VALIDATION_STATE_VALID + case VALIDATION_STATE_NOT_FOUND.String(): + value = VALIDATION_STATE_NOT_FOUND + case VALIDATION_STATE_INVALID.String(): + value = VALIDATION_STATE_INVALID + default: + return nil, fmt.Errorf("invalid validation state") + } + return &OpaqueExtended{ + SubType: EC_SUBTYPE_ORIGIN_VALIDATION, + Value: &ValidationExtended{ + Value: value, + }, + }, nil + } elems, err := parseRdAndRt(com) if err != nil { return nil, err |