diff options
-rw-r--r-- | gobgp/cmd/common.go | 4 | ||||
-rw-r--r-- | gobgp/cmd/global.go | 16 | ||||
-rw-r--r-- | packet/bgp/bgp.go | 12 |
3 files changed, 22 insertions, 10 deletions
diff --git a/gobgp/cmd/common.go b/gobgp/cmd/common.go index 14e61737..5aaadaf8 100644 --- a/gobgp/cmd/common.go +++ b/gobgp/cmd/common.go @@ -461,6 +461,10 @@ func checkAddressFamily(def bgp.RouteFamily) (bgp.RouteFamily, error) { rf = bgp.RF_FS_IPv4_UC case "ipv6-flowspec", "ipv6-flow", "flow6": rf = bgp.RF_FS_IPv6_UC + case "ipv4-l3vpn-flowspec", "ipv4vpn-flowspec", "flowvpn4": + rf = bgp.RF_FS_IPv4_VPN + case "ipv6-l3vpn-flowspec", "ipv6vpn-flowspec", "flowvpn6": + rf = bgp.RF_FS_IPv6_VPN case "l2vpn-flowspec": rf = bgp.RF_FS_L2_VPN case "opaque": diff --git a/gobgp/cmd/global.go b/gobgp/cmd/global.go index 1563c847..9aa7549d 100644 --- a/gobgp/cmd/global.go +++ b/gobgp/cmd/global.go @@ -301,6 +301,12 @@ func ParseFlowSpecArgs(rf bgp.RouteFamily, args []string, rd bgp.RouteDistinguis case bgp.RF_FS_IPv6_UC: nlri = bgp.NewFlowSpecIPv6Unicast(cmp) fnlri = &nlri.(*bgp.FlowSpecIPv6Unicast).FlowSpecNLRI + case bgp.RF_FS_IPv4_VPN: + nlri = bgp.NewFlowSpecIPv4VPN(rd, cmp) + fnlri = &nlri.(*bgp.FlowSpecIPv4VPN).FlowSpecNLRI + case bgp.RF_FS_IPv6_VPN: + nlri = bgp.NewFlowSpecIPv6VPN(rd, cmp) + fnlri = &nlri.(*bgp.FlowSpecIPv6VPN).FlowSpecNLRI case bgp.RF_FS_L2_VPN: nlri = bgp.NewFlowSpecL2VPN(rd, cmp) fnlri = &nlri.(*bgp.FlowSpecL2VPN).FlowSpecNLRI @@ -688,7 +694,7 @@ func ParsePath(rf bgp.RouteFamily, args []string) (*api.Path, error) { } case bgp.RF_EVPN: nlri, extcomms, err = ParseEvpnArgs(args) - case bgp.RF_FS_L2_VPN: + case bgp.RF_FS_IPv4_VPN, bgp.RF_FS_IPv6_VPN, bgp.RF_FS_L2_VPN: args, rd, err = extractRouteDistinguisher(args) if err != nil { return nil, err @@ -776,7 +782,7 @@ func modPath(resource api.Resource, name, modtype string, args []string) error { helpErrMap[bgp.RF_IPv4_UC] = fmt.Errorf("usage: %s rib %s <PREFIX> [origin { igp | egp | incomplete }] [nexthop <ADDRESS>] [med <VALUE>] [local-pref <VALUE>] [community <VALUE>] [aigp metric <METRIC>] -a ipv4", cmdstr, modtype) helpErrMap[bgp.RF_IPv6_UC] = fmt.Errorf("usage: %s rib %s <PREFIX> [origin { igp | egp | incomplete }] [nexthop <ADDRESS>] [med <VALUE>] [local-pref <VALUE>] [community <VALUE>] [aigp metric <METRIC>] -a ipv6", cmdstr, modtype) fsHelpMsgFmt := fmt.Sprintf(`err: %s -usage: %s rib %s match <MATCH_EXPR> then <THEN_EXPR> -a %%s +usage: %s rib %s%%smatch <MATCH_EXPR> then <THEN_EXPR> -a %%s %%s <THEN_EXPR> : { %s | %s | %s <value> | %s <RT> | %s <value> | %s { sample | terminal | sample-terminal } | %s <RT>... }... <RT> : xxx:yyy, xx.xx.xx.xx:yyy, xxx.xxx:yyy`, err, cmdstr, modtype, @@ -806,8 +812,10 @@ usage: %s rib %s match <MATCH_EXPR> then <THEN_EXPR> -a %%s protos, flags, ) - helpErrMap[bgp.RF_FS_IPv4_UC] = fmt.Errorf(fsHelpMsgFmt, "ipv4-flowspec", ipFsMatchExpr) - helpErrMap[bgp.RF_FS_IPv6_UC] = fmt.Errorf(fsHelpMsgFmt, "ipv6-flowspec", ipFsMatchExpr) + helpErrMap[bgp.RF_FS_IPv4_UC] = fmt.Errorf(fsHelpMsgFmt, " ", "ipv4-flowspec", ipFsMatchExpr) + helpErrMap[bgp.RF_FS_IPv6_UC] = fmt.Errorf(fsHelpMsgFmt, " ", "ipv6-flowspec", ipFsMatchExpr) + helpErrMap[bgp.RF_FS_IPv4_VPN] = fmt.Errorf(fsHelpMsgFmt, " rd <RD> ", "ipv4-l3vpn-flowspec", ipFsMatchExpr) + helpErrMap[bgp.RF_FS_IPv6_VPN] = fmt.Errorf(fsHelpMsgFmt, " rd <RD> ", "ipv6-l3vpn-flowspec", ipFsMatchExpr) macFsMatchExpr := fmt.Sprintf(` <MATCH_EXPR> : { { %s | %s } <MAC> | %s <ETHER_TYPE> | { %s | %s | %s | %s | %s | %s | %s | %s } <ITEM>... }... <ETHER_TYPE> : %s <ITEM> : &?{<|>|=}<value>`, diff --git a/packet/bgp/bgp.go b/packet/bgp/bgp.go index 597307d8..2e4e7c4e 100644 --- a/packet/bgp/bgp.go +++ b/packet/bgp/bgp.go @@ -2190,21 +2190,21 @@ func flowSpecPrefixParser(rf RouteFamily, args []string) (FlowSpecComponentInter switch typ { case FlowSpecNameMap[FLOW_SPEC_TYPE_DST_PREFIX]: switch rf { - case RF_FS_IPv4_UC: + case RF_FS_IPv4_UC, RF_FS_IPv4_VPN: return NewFlowSpecDestinationPrefix(NewIPAddrPrefix(uint8(ones), ip.String())), nil - case RF_FS_IPv6_UC: + case RF_FS_IPv6_UC, RF_FS_IPv6_VPN: return NewFlowSpecDestinationPrefix6(NewIPv6AddrPrefix(uint8(ones), ip.String()), offset), nil default: - return nil, fmt.Errorf("invalid type. only RF_FS_IPv4_UC or RF_FS_IPv6_UC is allowed") + return nil, fmt.Errorf("invalid type") } case FlowSpecNameMap[FLOW_SPEC_TYPE_SRC_PREFIX]: switch rf { - case RF_FS_IPv4_UC: + case RF_FS_IPv4_UC, RF_FS_IPv4_VPN: return NewFlowSpecSourcePrefix(NewIPAddrPrefix(uint8(ones), ip.String())), nil - case RF_FS_IPv6_UC: + case RF_FS_IPv6_UC, RF_FS_IPv6_VPN: return NewFlowSpecSourcePrefix6(NewIPv6AddrPrefix(uint8(ones), ip.String()), offset), nil default: - return nil, fmt.Errorf("invalid type. only RF_FS_IPv4_UC or RF_FS_IPv6_UC is allowed") + return nil, fmt.Errorf("invalid type") } } return nil, fmt.Errorf("invalid type. only destination or source is allowed") |