diff --git a/gobgp/cmd/global.go b/gobgp/cmd/global.go index 234d61972..4922875a9 100644 --- a/gobgp/cmd/global.go +++ b/gobgp/cmd/global.go @@ -42,6 +42,7 @@ const ( ACTION RT ENCAP + ESI_LABEL ROUTER_MAC VALID NOT_FOUND @@ -57,6 +58,7 @@ var ExtCommNameMap = map[ExtCommType]string{ ACTION: "action", RT: "rt", ENCAP: "encap", + ESI_LABEL: "esi-label", ROUTER_MAC: "router-mac", VALID: "valid", NOT_FOUND: "not-found", @@ -72,6 +74,7 @@ var ExtCommValueMap = map[string]ExtCommType{ ExtCommNameMap[ACTION]: ACTION, ExtCommNameMap[RT]: RT, ExtCommNameMap[ENCAP]: ENCAP, + ExtCommNameMap[ESI_LABEL]: ESI_LABEL, ExtCommNameMap[ROUTER_MAC]: ROUTER_MAC, ExtCommNameMap[VALID]: VALID, ExtCommNameMap[NOT_FOUND]: NOT_FOUND, @@ -205,6 +208,32 @@ func encapParser(args []string) ([]bgp.ExtendedCommunityInterface, error) { return []bgp.ExtendedCommunityInterface{o}, nil } +func esiLabelParser(args []string) ([]bgp.ExtendedCommunityInterface, error) { + if len(args) < 2 || args[0] != ExtCommNameMap[ESI_LABEL] { + return nil, fmt.Errorf("invalid esi-label") + } + label, err := strconv.Atoi(args[1]) + if err != nil { + return nil, err + } + isSingleActive := false + if len(args) > 2 { + switch args[2] { + case "single-active": + isSingleActive = true + case "all-active": + // isSingleActive = false + default: + return nil, fmt.Errorf("invalid esi-label") + } + } + o := &bgp.ESILabelExtended{ + Label: uint32(label), + IsSingleActive: isSingleActive, + } + return []bgp.ExtendedCommunityInterface{o}, nil +} + func routerMacParser(args []string) ([]bgp.ExtendedCommunityInterface, error) { if len(args) < 2 || args[0] != ExtCommNameMap[ROUTER_MAC] { return nil, fmt.Errorf("invalid router's mac") @@ -247,6 +276,7 @@ var ExtCommParserMap = map[ExtCommType]func([]string) ([]bgp.ExtendedCommunityIn ACTION: actionParser, RT: rtParser, ENCAP: encapParser, + ESI_LABEL: esiLabelParser, ROUTER_MAC: routerMacParser, VALID: validationParser, NOT_FOUND: validationParser, @@ -337,12 +367,12 @@ func ParseFlowSpecArgs(rf bgp.RouteFamily, args []string, rd bgp.RouteDistinguis func ParseEvpnEthernetAutoDiscoveryArgs(args []string) (bgp.AddrPrefixInterface, []string, error) { // Format: - // esi etag label