From 76f40ede0d466dfc7b1151d4e36b619a0daae51e Mon Sep 17 00:00:00 2001 From: Marcus Wichelmann Date: Sat, 20 Feb 2021 17:48:11 +0100 Subject: Added DeleteDynamicNeighbor message to API --- api/attribute.pb.go | 1 + api/gobgp.proto | 9 +++++++-- pkg/server/peer.go | 4 ++++ pkg/server/server.go | 7 +++++++ 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/api/attribute.pb.go b/api/attribute.pb.go index 8cbf6096..efa63584 100644 --- a/api/attribute.pb.go +++ b/api/attribute.pb.go @@ -160,6 +160,7 @@ It has these top-level messages: ListPeerGroupRequest ListPeerGroupResponse AddDynamicNeighborRequest + DeleteDynamicNeighborRequest AddPathRequest AddPathResponse DeletePathRequest diff --git a/api/gobgp.proto b/api/gobgp.proto index 3263adf8..99dc6b4d 100644 --- a/api/gobgp.proto +++ b/api/gobgp.proto @@ -49,8 +49,8 @@ service GobgpApi { rpc ListPeerGroup(ListPeerGroupRequest) returns(stream ListPeerGroupResponse); rpc UpdatePeerGroup(UpdatePeerGroupRequest) returns(UpdatePeerGroupResponse); - rpc AddDynamicNeighbor(AddDynamicNeighborRequest) - returns(google.protobuf.Empty); + rpc AddDynamicNeighbor(AddDynamicNeighborRequest) returns(google.protobuf.Empty); + rpc DeleteDynamicNeighbor(DeleteDynamicNeighborRequest) returns(google.protobuf.Empty); rpc AddPath(AddPathRequest) returns(AddPathResponse); rpc DeletePath(DeletePathRequest) returns(google.protobuf.Empty); @@ -186,6 +186,11 @@ message ListPeerGroupResponse { PeerGroup peer_group = 1; } message AddDynamicNeighborRequest { DynamicNeighbor dynamic_neighbor = 1; } +message DeleteDynamicNeighborRequest { + string prefix = 1; + string peer_group = 2; +} + message AddPathRequest { TableType table_type = 1; string vrf_id = 2; diff --git a/pkg/server/peer.go b/pkg/server/peer.go index 4a7d5922..243a3dcc 100644 --- a/pkg/server/peer.go +++ b/pkg/server/peer.go @@ -57,6 +57,10 @@ func (pg *peerGroup) AddDynamicNeighbor(c *config.DynamicNeighbor) { pg.dynamicNeighbors[c.Config.Prefix] = c } +func (pg *peerGroup) DeleteDynamicNeighbor(prefix string) { + delete(pg.dynamicNeighbors, prefix) +} + func newDynamicPeer(g *config.Global, neighborAddress string, pg *config.PeerGroup, loc *table.TableManager, policy *table.RoutingPolicy) *peer { conf := config.Neighbor{ Config: config.NeighborConfig{ diff --git a/pkg/server/server.go b/pkg/server/server.go index 25fd31cc..090d97b8 100644 --- a/pkg/server/server.go +++ b/pkg/server/server.go @@ -3002,6 +3002,13 @@ func (s *BgpServer) DeletePeer(ctx context.Context, r *api.DeletePeerRequest) er }, true) } +func (s *BgpServer) DeleteDynamicNeighbor(ctx context.Context, r *api.DeleteDynamicNeighborRequest) error { + return s.mgmtOperation(func() error { + s.peerGroupMap[r.PeerGroup].DeleteDynamicNeighbor(r.Prefix) + return nil + }, true) +} + func (s *BgpServer) updatePeerGroup(pg *config.PeerGroup) (needsSoftResetIn bool, err error) { name := pg.Config.PeerGroupName -- cgit v1.2.3