Skip to content

Cannot re-use peer address #2893

@wez470

Description

@wez470

Doing an action like below will cause an err

peer1 := &api.Peer{
	Conf: &api.PeerConf{
		NeighborAddress: "127.0.0.1",
		PeerAsn:         11111,
	},
	Transport: &api.Transport{
		RemotePort: 10179,
	},
	Timers: &api.Timers{
		Config: &api.TimersConfig{
			ConnectRetry:           1,
			IdleHoldTimeAfterReset: 1,
		},
	},
}
myBGPServer.AddPeer(context.Background(), &api.AddPeerRequest{Peer: peer1})
peer2 := &api.Peer{
	Conf: &api.PeerConf{
		NeighborAddress: "127.0.0.1",
		PeerAsn:         22222,
	},
	Transport: &api.Transport{
		RemotePort: 20179,
	},
	Timers: &api.Timers{
		Config: &api.TimersConfig{
			ConnectRetry:           1,
			IdleHoldTimeAfterReset: 1,
		},
	},
}
err := myBGPServer.AddPeer(context.Background(), &api.AddPeerRequest{Peer: peer2})
fmt.Println(err)

can't overwrite the existing peer: 127.0.0.1

Because the neighbour map uses address string only as the key. You can bypass this one time on local by changing one of the peers to "localhost". It would be useful (mostly for testing) if the PeerAsn was used as part of the neighbour map key so multiple peers can live at a single address.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions