diff --git a/config/default.go b/config/default.go index 94f5dc9d..d3160989 100644 --- a/config/default.go +++ b/config/default.go @@ -39,7 +39,9 @@ func SetDefaultConfigValues(md toml.MetaData, bt *Bgp) error { AfiSafi{AfiSafiName: "encap"}, AfiSafi{AfiSafiName: "rtc"}, AfiSafi{AfiSafiName: "ipv4-flowspec"}, - AfiSafi{AfiSafiName: "l3vpn-ipnv4-flowspec"}, + AfiSafi{AfiSafiName: "l3vpn-ipv4-flowspec"}, + AfiSafi{AfiSafiName: "ipv6-flowspec"}, + AfiSafi{AfiSafiName: "l3vpn-ipv6-flowspec"}, } } diff --git a/gobgp/cmd/common.go b/gobgp/cmd/common.go index 4d828366..bd971fea 100644 --- a/gobgp/cmd/common.go +++ b/gobgp/cmd/common.go @@ -458,6 +458,8 @@ func checkAddressFamily(ip net.IP) (bgp.RouteFamily, error) { rf = bgp.RF_RTC_UC case "ipv4-flowspec", "ipv4-flow", "flow4": rf = bgp.RF_FS_IPv4_UC + case "ipv6-flowspec", "ipv6-flow", "flow6": + rf = bgp.RF_FS_IPv6_UC case "": if len(ip) == 0 || ip.To4() != nil { rf = bgp.RF_IPv4_UC diff --git a/gobgp/cmd/global.go b/gobgp/cmd/global.go index 40c2c9da..5951fe25 100644 --- a/gobgp/cmd/global.go +++ b/gobgp/cmd/global.go @@ -235,7 +235,7 @@ func ParseExtendedCommunities(input string) ([]bgp.ExtendedCommunityInterface, e return exts, nil } -func ParseFlowSpecArgs(args []string) (bgp.AddrPrefixInterface, []string, error) { +func ParseFlowSpecArgs(rf bgp.RouteFamily, args []string) (bgp.AddrPrefixInterface, []string, error) { thenPos := len(args) for idx, v := range args { if v == "then" { @@ -246,13 +246,20 @@ func ParseFlowSpecArgs(args []string) (bgp.AddrPrefixInterface, []string, error) return nil, nil, fmt.Errorf("invalid format") } matchArgs := args[1:thenPos] - cmp, err := bgp.ParseFlowSpecComponents(strings.Join(matchArgs, " ")) + cmp, err := bgp.ParseFlowSpecComponents(rf, strings.Join(matchArgs, " ")) if err != nil { return nil, nil, err } - nlri := bgp.NewFlowSpecIPv4Unicast(cmp) - extcomms := args[thenPos:] - return nlri, extcomms, nil + var nlri bgp.AddrPrefixInterface + switch rf { + case bgp.RF_FS_IPv4_UC: + nlri = bgp.NewFlowSpecIPv4Unicast(cmp) + case bgp.RF_FS_IPv6_UC: + nlri = bgp.NewFlowSpecIPv6Unicast(cmp) + default: + return nil, nil, fmt.Errorf("invalid route family") + } + return nlri, args[thenPos:], nil } func ParseEvpnMacAdvArgs(args []string) (bgp.AddrPrefixInterface, []string, error) { @@ -449,8 +456,8 @@ func ParsePath(rf bgp.RouteFamily, args []string) (*api.Path, error) { } case bgp.RF_EVPN: nlri, extcomms, err = ParseEvpnArgs(args) - case bgp.RF_FS_IPv4_UC: - nlri, extcomms, err = ParseFlowSpecArgs(args) + case bgp.RF_FS_IPv4_UC, bgp.RF_FS_IPv6_UC: + nlri, extcomms, err = ParseFlowSpecArgs(rf, args) default: return nil, fmt.Errorf("Unsupported route family: %s", rf) } @@ -520,16 +527,17 @@ func modPath(resource api.Resource, name, modtype string, args []string) error { helpErrMap := map[bgp.RouteFamily]error{} helpErrMap[bgp.RF_IPv4_UC] = fmt.Errorf("usage: %s rib %s [nexthop
] -a ipv4", cmdstr, modtype) helpErrMap[bgp.RF_IPv6_UC] = fmt.Errorf("usage: %s rib %s [nexthop
] -a ipv6", cmdstr, modtype) - helpErrMap[bgp.RF_FS_IPv4_UC] = fmt.Errorf(`usage: %s rib %s match then [nexthop
] -a ipv4-flowspec - : { %s | %s | + fsHelpMsgFmt := fmt.Sprintf(`err: %s +usage: %s rib %s match then -a %%s + : { %s [] | %s [] | %s ... | %s | %s ... | - { %s | %s | %s | %s | %s | %s | %s } ... }... + { %s | %s | %s | %s | %s | %s | %s | %s } ... }... : %s : not-a-fragment, is-a-fragment, first-fragment, last-fragment : %s : &?{<|>|=} : { %s | %s | %s | %s | %s | %s { sample | terminal | sample-terminal } | %s ... }... - : xxx:yyy, xx.xx.xx.xx:yyy, xxx.xxx:yyy`, cmdstr, modtype, + : xxx:yyy, xx.xx.xx.xx:yyy, xxx.xxx:yyy`, err, cmdstr, modtype, bgp.FlowSpecNameMap[bgp.FLOW_SPEC_TYPE_DST_PREFIX], bgp.FlowSpecNameMap[bgp.FLOW_SPEC_TYPE_SRC_PREFIX], bgp.FlowSpecNameMap[bgp.FLOW_SPEC_TYPE_IP_PROTO], @@ -542,11 +550,14 @@ func modPath(resource api.Resource, name, modtype string, args []string) error { bgp.FlowSpecNameMap[bgp.FLOW_SPEC_TYPE_ICMP_CODE], bgp.FlowSpecNameMap[bgp.FLOW_SPEC_TYPE_PKT_LEN], bgp.FlowSpecNameMap[bgp.FLOW_SPEC_TYPE_DSCP], + bgp.FlowSpecNameMap[bgp.FLOW_SPEC_TYPE_LABEL], protos, flags, ExtCommNameMap[ACCEPT], ExtCommNameMap[DISCARD], ExtCommNameMap[RATE], ExtCommNameMap[REDIRECT], ExtCommNameMap[MARK], ExtCommNameMap[ACTION], ExtCommNameMap[RT]) - helpErrMap[bgp.RF_EVPN] = fmt.Errorf(`usage: %s rib %s { macadv | multicast } [nexthop
] -a evpn + helpErrMap[bgp.RF_FS_IPv4_UC] = fmt.Errorf(fsHelpMsgFmt, "ipv4-flowspec") + helpErrMap[bgp.RF_FS_IPv6_UC] = fmt.Errorf(fsHelpMsgFmt, "ipv6-flowspec") + helpErrMap[bgp.RF_EVPN] = fmt.Errorf(`usage: %s rib %s { macadv | multicast } -a evpn :