VTY: don't save dynamically-allocated "unknown" peers

The VTY code should write/save only those peers that were configured
using the VTY.

Closes: OS#4929
Change-Id: If02694be4e4cb9cb27e7d9d07e533bfed4a999a9
This commit is contained in:
Harald Welte 2021-01-24 23:27:59 +01:00
parent fa4826bfa6
commit e74594b247
3 changed files with 7 additions and 1 deletions

View File

@ -26,6 +26,7 @@ struct cbc_peer {
char *remote_host; /* remote IP address in string format */
int remote_port; /* remote port number or -1 for random */
bool unknown_dynamic_peer; /* dynamic/unknown peer; not saved in VTY */
enum cbc_peer_protocol proto;
union {

View File

@ -494,8 +494,12 @@ static void write_one_peer(struct vty *vty, struct cbc_peer *peer)
static int config_write_peer(struct vty *vty)
{
struct cbc_peer *peer;
llist_for_each_entry(peer, &g_cbc->peers, list)
llist_for_each_entry(peer, &g_cbc->peers, list) {
/* only save those configured via the VTY, not the "unknown" peers */
if (peer->unknown_dynamic_peer)
continue;
write_one_peer(vty, peer);
}
return CMD_SUCCESS;
}

View File

@ -150,6 +150,7 @@ static int cbsp_cbc_accept_cb(struct osmo_stream_srv_link *link, int fd)
remote_ip, remote_port);
client->peer = cbc_peer_create(NULL, CBC_PEER_PROTO_CBSP);
OSMO_ASSERT(client->peer);
client->peer->unknown_dynamic_peer = true;
} else {
LOGPCC(client, LOGL_NOTICE, "Rejecting unknown CBSP peer %s:%d (not permitted)\n",
remote_ip, remote_port);