summaryrefslogtreecommitdiffhomepage
path: root/pkg/server/zclient.go
diff options
context:
space:
mode:
authorHitoshi Irino <irino@sfc.wide.ad.jp>2019-05-05 20:35:52 +0900
committerFUJITA Tomonori <fujita.tomonori@gmail.com>2019-05-08 08:48:26 +0900
commit7d2823d4c037caf39c7222632669210a4b6d1ed4 (patch)
treedb6523171ffe4f086629ec95108cfa2cc6766d43 /pkg/server/zclient.go
parentcc267fad9e6410705420af220d73d25d288e8a58 (diff)
zebra: supporting FRRouting version 7
- the "version" parameter (which means ZAPI) 6 in zebra config changes supporting FRRouting version 7 instead of FRRouting version 6. - the "software-name" parameter which supports backward compatibility is added in zebra config. (GoBGP support FRRouting version 6 when "version = 6" and "software-name = frr6" is configured.)
Diffstat (limited to 'pkg/server/zclient.go')
-rw-r--r--pkg/server/zclient.go19
1 files changed, 11 insertions, 8 deletions
diff --git a/pkg/server/zclient.go b/pkg/server/zclient.go
index e16edd93..a4b8e378 100644
--- a/pkg/server/zclient.go
+++ b/pkg/server/zclient.go
@@ -185,9 +185,12 @@ func newIPRouteBody(dst []*table.Path, vrfId uint32, z *zebraClient) (body *zebr
}
var flags zebra.FLAG
if path.IsIBGP() {
- flags = zebra.FLAG_IBGP | zebra.FLAG_INTERNAL
+ flags = zebra.FLAG_IBGP | zebra.FLAG_ALLOW_RECURSION // 0x08|0x01
+ if z.client.Version == 6 && z.client.SoftwareName != "frr6" {
+ flags = zebra.FRR_ZAPI6_FLAG_IBGP | zebra.FRR_ZAPI6_FLAG_ALLOW_RECURSION //0x04|0x01
+ }
} else if path.GetSource().MultihopTtl > 0 {
- flags = zebra.FLAG_INTERNAL
+ flags = zebra.FLAG_ALLOW_RECURSION // 0x01, FRR_ZAPI6_FLAG_ALLOW_RECURSION is same.
}
return &zebra.IPRouteBody{
Type: zebra.ROUTE_BGP,
@@ -252,7 +255,7 @@ func newNexthopUnregisterBody(family uint16, prefix net.IP) *zebra.NexthopRegist
}
}
-func newPathFromIPRouteMessage(m *zebra.Message, version uint8) *table.Path {
+func newPathFromIPRouteMessage(m *zebra.Message, version uint8, software string) *table.Path {
header := m.Header
body := m.Body.(*zebra.IPRouteBody)
family := body.RouteFamily(version)
@@ -266,7 +269,7 @@ func newPathFromIPRouteMessage(m *zebra.Message, version uint8) *table.Path {
log.WithFields(log.Fields{
"Topic": "Zebra",
"RouteType": body.Type.String(),
- "Flag": body.Flags.String(),
+ "Flag": body.Flags.String(version, software),
"Message": body.Message,
"Family": body.Prefix.Family,
"Prefix": body.Prefix.Prefix,
@@ -379,7 +382,7 @@ func (z *zebraClient) loop() {
}
switch body := msg.Body.(type) {
case *zebra.IPRouteBody:
- if path := newPathFromIPRouteMessage(msg, z.client.Version); path != nil {
+ if path := newPathFromIPRouteMessage(msg, z.client.Version, z.client.SoftwareName); path != nil {
if err := z.server.addPathList("", []*table.Path{path}); err != nil {
log.WithFields(log.Fields{
"Topic": "Zebra",
@@ -462,7 +465,7 @@ func (z *zebraClient) loop() {
}
}
-func newZebraClient(s *BgpServer, url string, protos []string, version uint8, nhtEnable bool, nhtDelay uint8, mplsLabelRangeSize uint32) (*zebraClient, error) {
+func newZebraClient(s *BgpServer, url string, protos []string, version uint8, nhtEnable bool, nhtDelay uint8, mplsLabelRangeSize uint32, softwareName string) (*zebraClient, error) {
l := strings.SplitN(url, ":", 2)
if len(l) != 2 {
return nil, fmt.Errorf("unsupported url: %s", url)
@@ -480,7 +483,7 @@ func newZebraClient(s *BgpServer, url string, protos []string, version uint8, nh
ver++
}
for elem, ver := range zapivers {
- cli, err = zebra.NewClient(l[0], l[1], zebra.ROUTE_BGP, ver)
+ cli, err = zebra.NewClient(l[0], l[1], zebra.ROUTE_BGP, ver, softwareName)
if cli != nil && err == nil {
usingVersion = ver
break
@@ -508,7 +511,7 @@ func newZebraClient(s *BgpServer, url string, protos []string, version uint8, nh
// cli.SendRouterIDAdd()
cli.SendInterfaceAdd()
for _, typ := range protos {
- t, err := zebra.RouteTypeFromString(typ, version)
+ t, err := zebra.RouteTypeFromString(typ, version, softwareName)
if err != nil {
return nil, err
}