diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2016-01-14 22:26:54 -0800 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2016-01-14 22:26:54 -0800 |
commit | 49ec4a328fd2e1bdc81797f150089818031ae6e1 (patch) | |
tree | a9e81364d467dab75cd39f5b98becbfd0f6c422a | |
parent | 3f0fc3ccc9709b070c6424e0be33e53a8a407fe3 (diff) |
rpki: fix serial notify handling
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r-- | server/rpki.go | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/server/rpki.go b/server/rpki.go index 742dac91..e6097d00 100644 --- a/server/rpki.go +++ b/server/rpki.go @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Nippon Telegraph and Telephone Corporation. +// Copyright (C) 2015,2016 Nippon Telegraph and Telephone Corporation. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -141,7 +141,7 @@ func (m *roaManager) operate(op api.Operation, address string) error { if add == address { switch op { case api.Operation_ENABLE: - client.enable() + client.enable(client.serialNumber) case api.Operation_DISABLE: case api.Operation_RESET: client.reset() @@ -262,8 +262,12 @@ func (c *roaManager) handleRTRMsg(client *roaClient, state *config.RpkiServerSta if err == nil { switch msg := m.(type) { case *bgp.RTRSerialNotify: - client.sessionID = msg.RTRCommon.SessionID - client.serialNumber = msg.RTRCommon.SerialNumber + if client.serialNumber < msg.RTRCommon.SerialNumber { + client.enable(client.serialNumber) + } else if client.serialNumber > msg.RTRCommon.SerialNumber { + // should not happen. try to get the whole ROAs. + client.softReset() + } received.SerialNotify++ case *bgp.RTRSerialQuery: case *bgp.RTRResetQuery: @@ -482,9 +486,9 @@ type roaClient struct { serialNumber uint32 } -func (c *roaClient) enable() error { +func (c *roaClient) enable(serial uint32) error { if c.conn != nil { - r := bgp.NewRTRSerialQuery(c.sessionID, c.serialNumber) + r := bgp.NewRTRSerialQuery(c.sessionID, serial) data, _ := r.Serialize() _, err := c.conn.Write(data) if err != nil { |