diff options
author | Hitoshi Irino <irino@sfc.wide.ad.jp> | 2020-01-13 18:55:51 +0900 |
---|---|---|
committer | Hitoshi Irino <irino@sfc.wide.ad.jp> | 2020-01-13 18:55:51 +0900 |
commit | 05a7e0e993de741a6a674305ed93562e93532ec4 (patch) | |
tree | 410c847550726ce246c074814874b408101fbdfa | |
parent | 377213886c32d869e52bad434dda764bc69f6a53 (diff) |
Supporting FRR7.2
-rw-r--r-- | docs/sources/zebra.md | 25 | ||||
-rw-r--r-- | internal/pkg/config/default.go | 2 | ||||
-rw-r--r-- | internal/pkg/zebra/zapi.go | 45 | ||||
-rw-r--r-- | tools/pyang_plugins/gobgp.yang | 2 |
4 files changed, 47 insertions, 27 deletions
diff --git a/docs/sources/zebra.md b/docs/sources/zebra.md index 89b02f99..f2ee25a0 100644 --- a/docs/sources/zebra.md +++ b/docs/sources/zebra.md @@ -17,9 +17,9 @@ message and it doesn't keep backward compatibility for FRRouting version 4.0.x although FRRouting version 4.0.x and 5.0.x use Zebra API version 5. Also, FRRouting version 7.0.x and 7.1.x changes zebra message and it doesn't keep backward compatibility for FRRouting -version 6.0.x although FRRouting version 6.0.x, 7.0.x and 7.1.x use -Zebra API version 6. If you need to integrate with FRRouting version -4.0.x or 6.0x, please use `software-name` configuration. +version 6.0.x although FRRouting version 6.0.x, 7.0.x, 7.1.x and 7.2.x +use Zebra API version 6. If you need to integrate with FRRouting +version 4.0.x or 6.0x, please use `software-name` configuration. ## Contents @@ -60,19 +60,20 @@ You need to enable the zebra feature in the Global configuration as follows. - `mpls-label-range-size` specifies mpls label range size for requesting to Zebra. It works with FRRouting 5.0.x, FRRouting 6.0.x, - FRRouting 7.0.x and FRRouting 7.1.x. + FRRouting 7.0.x, FRRouting 7.1.x and FRRouting 7.2.x. - `sotware-name` specifies software name for zebra when only `version` configuration cannot specify software uniquely. This configuration is used with 'version' configuration. For connecting to FRRouting - 7.1.x, please specify `6` as `version` and `frr7.1` as - `software-name`. For connecting to FRRouting 6.0.x, please specify - `6` as `version` and `frr6` as `software-name`. For connecting to - FRRouting 4.0.x, please specify `5` as `version` and `frr4` as - `software-name`. For connecting to Cumulus Linux please specify `5` - as `version` and `cumulus` as `software-name`. GoBGP is tested with - Cumulus Linux VX 3.7.7 whose zebra version is 4.0+cl3u13 and its - Zebra API version is 5. + 7.2.x, please specify `6` as `version` and `frr7.2` as + `software-name`. For connecting to FRRouting 7.1.x, please specify + `6` as `version` and `frr7.1` as `software-name`. For connecting to + FRRouting 6.0.x, please specify `6` as `version` and `frr6` as + `software-name`. For connecting to FRRouting 4.0.x, please specify + `5` as `version` and `frr4` as `software-name`. For connecting to + Cumulus Linux please specify `5` as `version` and `cumulus` as + `software-name`. GoBGP is tested with Cumulus Linux VX 3.7.7 whose + zebra version is 4.0+cl3u13 and its Zebra API version is 5. ## Check Routes from zebra diff --git a/internal/pkg/config/default.go b/internal/pkg/config/default.go index c86ada57..bf8b0791 100644 --- a/internal/pkg/config/default.go +++ b/internal/pkg/config/default.go @@ -422,7 +422,7 @@ func setDefaultConfigValuesWithViper(v *viper.Viper, b *BgpConfigSet) error { } //SoftwareName for Zebra - allowableZebraSoftwareName := []string{"", "quagga", "frr3", "frr4", "frr5", "frr6", "frr7", "frr7.1", "cumulus"} + allowableZebraSoftwareName := []string{"", "quagga", "frr3", "frr4", "frr5", "frr6", "frr7", "frr7.1", "frr7.2", "cumulus"} isAllowable := false for _, allowable := range allowableZebraSoftwareName { if b.Zebra.Config.SoftwareName == allowable { diff --git a/internal/pkg/zebra/zapi.go b/internal/pkg/zebra/zapi.go index 2094c8f6..931ddd1e 100644 --- a/internal/pkg/zebra/zapi.go +++ b/internal/pkg/zebra/zapi.go @@ -217,6 +217,7 @@ const ( FRR_ZAPI6_INTERFACE_UP FRR_ZAPI6_INTERFACE_DOWN FRR_ZAPI6_INTERFACE_SET_MASTER + //FRR_ZAPI6_INTERFACE_SET_PROTODOWN // Add Frr 7.2 FRR_ZAPI6_ROUTE_ADD FRR_ZAPI6_ROUTE_DELETE FRR_ZAPI6_ROUTE_NOTIFY_OWNER @@ -536,6 +537,7 @@ const ( FRR_ZAPI6_ROUTE_PBR FRR_ZAPI6_ROUTE_BFD FRR_ZAPI6_ROUTE_OPENFABRIC // FRRRouting version 7 adds. + FRR_ZAPI6_ROUTE_VRRP // FRRRouting version 7.2 adds. FRR_ZAPI6_ROUTE_ALL FRR_ZAPI6_ROUTE_MAX ) @@ -645,6 +647,8 @@ var routeTypeValueMapFrrZapi6 = map[string]ROUTE_TYPE{ "sharp": FRR_ZAPI6_ROUTE_SHARP, "pbr": FRR_ZAPI6_ROUTE_PBR, "bfd": FRR_ZAPI6_ROUTE_BFD, + "openfabric": FRR_ZAPI6_ROUTE_OPENFABRIC, + "vrrp": FRR_ZAPI6_ROUTE_VRRP, "all": FRR_ZAPI6_ROUTE_ALL, } @@ -733,7 +737,8 @@ func RouteTypeFromString(typ string, version uint8, softwareName string) (ROUTE_ } t, ok := delegateRouteTypeValueMap[typ] if (version == 5 && softwareName == "frr4" && t == FRR_ZAPI5_ROUTE_PBR) || - (version == 6 && softwareName == "frr6" && t == FRR_ZAPI6_ROUTE_OPENFABRIC) { + (version == 6 && softwareName == "frr6" && t == FRR_ZAPI6_ROUTE_OPENFABRIC) || + (version == 6 && softwareName != "frr7.2" && t == FRR_ZAPI6_ROUTE_VRRP) { ok = false } if ok { @@ -1064,7 +1069,7 @@ func NewClient(network, address string, typ ROUTE_TYPE, version uint8, software if ((version == 2 || version == 3) && software != "" && software != "quagga") || (version == 4 && software != "" && software != "frr3") || (version == 5 && software != "" && software != "frr4" && software != "frr5" && software != "cumulus") || - (version == 6 && software != "" && software != "frr6" && software != "frr7" && software != "frr7.1") { + (version == 6 && software != "" && software != "frr6" && software != "frr7" && software != "frr7.1" && software != "frr7.2") { isAllowableSoftware = false } if !isAllowableSoftware { @@ -1238,6 +1243,11 @@ func (c *Client) SendCommand(command API_TYPE, vrfId uint32, body Body) error { } else { return err } + } else if c.Version == 6 && c.SoftwareName == "frr7.2" { + // frr7.2 adds INTERFACE_SET_PROTODOWN between INTERFACE_SET_MASTER(6) and ROUTE_ADD + if command >= FRR_ZAPI6_ROUTE_ADD { + command++ + } } else if c.Version == 5 && c.SoftwareName == "frr4" { if frr4Command, err := frr4Zapi5Command(command, c.SoftwareName, false); err == nil { command = frr4Command @@ -1725,6 +1735,7 @@ type InterfaceUpdateBody struct { MTU uint32 MTU6 uint32 Bandwidth uint32 + LinkIfindex uint32 Linktype LINK_TYPE HardwareAddr net.HardwareAddr LinkParam LinkParam @@ -1756,16 +1767,19 @@ func (b *InterfaceUpdateBody) DecodeFromBytes(data []byte, version uint8, softwa b.MTU = binary.BigEndian.Uint32(data[0:4]) b.MTU6 = binary.BigEndian.Uint32(data[4:8]) b.Bandwidth = binary.BigEndian.Uint32(data[8:12]) + data = data[12:] + if version == 6 && softwareName == "frr7.2" { + b.LinkIfindex = binary.BigEndian.Uint32(data[:4]) + data = data[4:] + } if version >= 3 { - b.Linktype = LINK_TYPE(binary.BigEndian.Uint32(data[12:16])) - data = data[16:] - } else { - data = data[12:] + b.Linktype = LINK_TYPE(binary.BigEndian.Uint32(data[:4])) + data = data[4:] } l := binary.BigEndian.Uint32(data[:4]) if l > 0 { if len(data) < 4+int(l) { - return fmt.Errorf("lack of bytes. need %d but %d", 4+l, len(data)) + return fmt.Errorf("lack of bytes in remain data. need %d but %d", 4+l, len(data)) } b.HardwareAddr = data[4 : 4+l] } @@ -2145,7 +2159,7 @@ func (b *IPRouteBody) Serialize(version uint8, softwareName string) ([]byte, err buf = append(buf, uint8(nexthop.Type)) - if version == 6 && softwareName == "frr7.1" { + if version == 6 && (softwareName == "frr7.1" || softwareName == "frr7.2") { buf = append(buf, nexthop.Onlink) } if (version <= 3 && nexthop.Type == NEXTHOP_TYPE_IPV4) || @@ -2332,7 +2346,7 @@ func (b *IPRouteBody) DecodeFromBytes(data []byte, version uint8, softwareName s nexthop.VrfId = binary.BigEndian.Uint32(data[pos : pos+4]) nexthop.Type = NEXTHOP_TYPE(data[pos+4]) pos += 5 - if softwareName == "frr7.1" { + if softwareName == "frr7.1" || softwareName == "frr7.2" { nexthop.Onlink = uint8(data[pos]) pos += 1 } @@ -3234,6 +3248,11 @@ func (m *Message) parseFrrZapi6Message(data []byte, software string) error { } else { return err } + } else if software == "frr7.2" { + // frr7.2 adds INTERFACE_SET_PROTODOWN between INTERFACE_SET_MASTER(6) and ROUTE_ADD + if command >= FRR_ZAPI6_ROUTE_ADD { + command-- + } } switch command { case FRR_ZAPI6_INTERFACE_ADD, FRR_ZAPI6_INTERFACE_DELETE, FRR_ZAPI6_INTERFACE_UP, FRR_ZAPI6_INTERFACE_DOWN: @@ -3300,18 +3319,18 @@ func ParseMessage(hdr *Header, data []byte, software string) (m *Message, err er return m, nil } -// frr6Zapi6Command adjust command (API_TYPE) between Frr6 Zebra and latest Zapi6 +// frr6Zapi6Command adjust command (API_TYPE) between Frr6 Zebra and frr7 Zapi6 func frr6Zapi6Command(command API_TYPE, softwareName string, from bool) (API_TYPE, error) { if softwareName != "frr6" { return command, fmt.Errorf("softwareName %s is not supported", softwareName) } - // frr6 has ZEBRA_IPV4_ROUTE_IPV6_NEXTHOP_ADD (ID:28), frr7 (zapi6 latest) removes it. + // frr6 has ZEBRA_IPV4_ROUTE_IPV6_NEXTHOP_ADD (ID:28), frr7 removes it. // frr7 adds ZEBRA_DUPLICATE_ADDR_DETECTION (ID:72). if from && FRR_ZAPI6_BFD_DEST_REGISTER < command && command < FRR_ZAPI6_PW_ADD { - // if true, command will be converted from Frr6 Zebra to latest Zapi6 (for parsing) + // if true, command will be converted from Frr6 Zebra to Frr7 Zapi6 (for parsing) return command - 1, nil } else if !from && FRR_ZAPI6_IMPORT_CHECK_UPDATE < command && command < FRR_ZAPI6_DUPLICATE_ADDR_DETECTION { - // if false, command will be converted from latest Zapi6 to Frr6 Zebra (for send) + // if false, command will be converted from Frr7 Zapi6 to Frr6 Zebra (for send) return command + 1, nil } return command, nil diff --git a/tools/pyang_plugins/gobgp.yang b/tools/pyang_plugins/gobgp.yang index 0829bee3..a4a2dc64 100644 --- a/tools/pyang_plugins/gobgp.yang +++ b/tools/pyang_plugins/gobgp.yang @@ -1248,7 +1248,7 @@ module gobgp { type string; description "Configure zebra software name. - quagga, frr3, frr4, frr5, frr6, frr7 can be used."; + quagga, frr3, frr4, frr5, frr6, frr7, frr7.1 and frr7.2 can be used."; } } |