diff options
author | IWASE Yusuke <iwase.yusuke0@gmail.com> | 2018-01-05 14:18:00 +0900 |
---|---|---|
committer | IWASE Yusuke <iwase.yusuke0@gmail.com> | 2018-01-09 08:36:37 +0900 |
commit | a4b070be96f1482e397948f7c93ad0a9da9c8192 (patch) | |
tree | 10140686a3d7420d1a639721228886e65d00d44f | |
parent | c17563a8df441b8fd389dcc9c399f372e02bcdcf (diff) |
zebra/zapi: Fix Zebra API type when IPv6 routes
When implementing the FRRouting message format, missed to detect the
Zebra API type for adding/deleting IPv6 routes, and all API type will be
encoded with the types for IPv4 routes unexpectedly.
This patch fixes the encoded API type by determine the given prefix is
IPv4 or IPv6.
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
-rw-r--r-- | zebra/zapi.go | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/zebra/zapi.go b/zebra/zapi.go index e4de6253..b20da8e5 100644 --- a/zebra/zapi.go +++ b/zebra/zapi.go @@ -23,8 +23,9 @@ import ( "strings" "syscall" - "github.com/osrg/gobgp/packet/bgp" log "github.com/sirupsen/logrus" + + "github.com/osrg/gobgp/packet/bgp" ) const ( @@ -755,14 +756,30 @@ func (c *Client) SendRedistributeDelete(t ROUTE_TYPE) error { func (c *Client) SendIPRoute(vrfId uint16, body *IPRouteBody, isWithdraw bool) error { command := IPV4_ROUTE_ADD if c.Version <= 3 { - if isWithdraw { - command = IPV4_ROUTE_DELETE + if body.Prefix.To4() != nil { + if isWithdraw { + command = IPV4_ROUTE_DELETE + } + } else { + if isWithdraw { + command = IPV6_ROUTE_DELETE + } else { + command = IPV6_ROUTE_ADD + } } } else { // version >= 4 - if isWithdraw { - command = FRR_IPV4_ROUTE_DELETE + if body.Prefix.To4() != nil { + if isWithdraw { + command = FRR_IPV4_ROUTE_DELETE + } else { + command = FRR_IPV4_ROUTE_ADD + } } else { - command = FRR_IPV4_ROUTE_ADD + if isWithdraw { + command = FRR_IPV6_ROUTE_DELETE + } else { + command = FRR_IPV6_ROUTE_ADD + } } } return c.SendCommand(command, vrfId, body) |