diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2017-08-01 09:23:06 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2017-08-01 09:24:14 +0900 |
commit | 15f598ad8e5be47725cc7aea31c80e38e346c408 (patch) | |
tree | 53ab0a933c7a87d58b358da7a1fc934cfbe6ffed /server | |
parent | f54a995391c4d0d8f22c6e9e6420f8ad0e6047b7 (diff) |
server: fix zclient to handle route messages without nexthop
Seems that zebra could send a route message without nexthop (makes
sense for withdraw).
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'server')
-rw-r--r-- | server/zclient.go | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/server/zclient.go b/server/zclient.go index 85d238c8..6a1231a4 100644 --- a/server/zclient.go +++ b/server/zclient.go @@ -361,7 +361,6 @@ func createPathFromIPRouteMessage(m *zebra.Message) *table.Path { var nlri bgp.AddrPrefixInterface pattr := make([]bgp.PathAttributeInterface, 0) - var mpnlri *bgp.PathAttributeMpReachNLRI var isWithdraw bool = header.Command == zebra.IPV4_ROUTE_DELETE || header.Command == zebra.IPV6_ROUTE_DELETE origin := bgp.NewPathAttributeOrigin(bgp.BGP_ORIGIN_ATTR_TYPE_IGP) @@ -385,12 +384,16 @@ func createPathFromIPRouteMessage(m *zebra.Message) *table.Path { switch family { case bgp.RF_IPv4_UC: nlri = bgp.NewIPAddrPrefix(body.PrefixLength, body.Prefix.String()) - nexthop := bgp.NewPathAttributeNextHop(body.Nexthops[0].String()) - pattr = append(pattr, nexthop) + if len(body.Nexthops) > 0 { + pattr = append(pattr, bgp.NewPathAttributeNextHop(body.Nexthops[0].String())) + } case bgp.RF_IPv6_UC: nlri = bgp.NewIPv6AddrPrefix(body.PrefixLength, body.Prefix.String()) - mpnlri = bgp.NewPathAttributeMpReachNLRI(body.Nexthops[0].String(), []bgp.AddrPrefixInterface{nlri}) - pattr = append(pattr, mpnlri) + nexthop := "" + if len(body.Nexthops) > 0 { + nexthop = body.Nexthops[0].String() + } + pattr = append(pattr, bgp.NewPathAttributeMpReachNLRI(nexthop, []bgp.AddrPrefixInterface{nlri})) default: log.WithFields(log.Fields{ "Topic": "Zebra", |