hnbgw: Unregister HNB if SCTP link is restarted

Sometimes an hNodeB may reconnect (SCTP INIT) using same SCTP tuple without
closing the previous conn. This is handled by the SCTP stack by means of
pushing a RESET notification up the stack to the sctp_recvmsg() user.
Let's handle this by marking the HNB as unregistered, since most
probably a HNB Register Req comes next as the upper layer state is
considered lost.

Depends: libosmo-netif.git Change-Id I0ee94846a15a23950b9d70eaaef1251267296bdd
Related: SYS#6113
Change-Id: Ib22881b1a34b1c3dd350912b3de8904917cf34ef
This commit is contained in:
Pau Espin 2022-09-19 14:54:35 +02:00
parent d046306b63
commit 1de2091515
1 changed files with 19 additions and 2 deletions

View File

@ -251,8 +251,25 @@ static int hnb_read_cb(struct osmo_stream_srv *conn)
msg->dst = hnb; msg->dst = hnb;
rc = osmo_stream_srv_recv(conn, msg); rc = osmo_stream_srv_recv(conn, msg);
if (rc == -EAGAIN) { /* Notification received */
/* Notification received */ if (msgb_sctp_msg_flags(msg) & OSMO_STREAM_SCTP_MSG_FLAGS_NOTIFICATION) {
union sctp_notification *notif = (union sctp_notification *)msgb_data(msg);
switch (notif->sn_header.sn_type) {
case SCTP_ASSOC_CHANGE:
switch (notif->sn_assoc_change.sac_state) {
case SCTP_RESTART:
LOGHNB(hnb, DMAIN, LOGL_NOTICE, "HNB SCTP conn RESTARTed, marking as HNBAP-unregistered\n");
hnb->hnb_registered = false;
break;
}
break;
}
msgb_free(msg);
return 0;
} else if (rc == -EAGAIN) {
/* Older versions of osmo_stream_srv_recv() not supporting
* msgb_sctp_msg_flags() may still return -EAGAIN when an sctp
* notification is received. */
msgb_free(msg); msgb_free(msg);
return 0; return 0;
} else if (rc < 0) { } else if (rc < 0) {