diff options
author | IWASE Yusuke <iwase.yusuke0@gmail.com> | 2017-03-22 14:03:41 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2017-03-27 14:43:54 +0900 |
commit | f6648758080cbe139a4345a384243ede52bec6bf (patch) | |
tree | 9c3f046f48cf4f98a7841dc3c3f59d4186d6392d /server | |
parent | 61240f45b0e2d09e251dbd4176a151964e98f696 (diff) |
server/zclient: Retry Zebra message version negotiation
Currently, the Zebra message version used by ZClient is configurable
(default 2), but if the given version is miss-matched with that of
Zebra daemon, ZCient will fail to connect.
This patch fixes ZClient to retry the version negotiation.
For example, if failed with the version 2, retry with the version 3.
Note: In order to receive the first message from Zebra daemon when
instantiating ZClient, this patch fixes ZClient to send HELLO and
ROUTER_ID_ADD messages automatically.
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Diffstat (limited to 'server')
-rw-r--r-- | server/zclient.go | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/server/zclient.go b/server/zclient.go index 4bba83ec..d432b96d 100644 --- a/server/zclient.go +++ b/server/zclient.go @@ -519,10 +519,23 @@ func newZebraClient(s *BgpServer, url string, protos []string, version uint8, nh } cli, err := zebra.NewClient(l[0], l[1], zebra.ROUTE_BGP, version) if err != nil { - return nil, err + // Retry with another Zebra message version + var retry_version uint8 = 2 + if version == 2 { + retry_version = 3 + } + log.WithFields(log.Fields{ + "Topic": "Zebra", + }).Warnf("cannot connect to Zebra with message version %d. retry with version %d", version, retry_version) + cli, err = zebra.NewClient(l[0], l[1], zebra.ROUTE_BGP, retry_version) + if err != nil { + return nil, err + } } - cli.SendHello() - cli.SendRouterIDAdd() + // Note: HELLO/ROUTER_ID_ADD messages are automatically sent to negotiate + // the Zebra message version in zebra.NewClient(). + // cli.SendHello() + // cli.SendRouterIDAdd() cli.SendInterfaceAdd() for _, typ := range protos { t, err := zebra.RouteTypeFromString(typ) |