File 0567-kernel-gen_sctp-document-the-sctp_error-.-message.patch of Package erlang

From a252ea0d7bf0951f487ae1dbdb84ae021b037b8b Mon Sep 17 00:00:00 2001
From: Vadim Yanitskiy <fixeria@osmocom.org>
Date: Tue, 25 Nov 2025 01:28:47 +0700
Subject: [PATCH 2/2] kernel: gen_sctp: document the {sctp_error, ...} message

The `{sctp_error, ...}` message is not documented, but it does exist.
The logic that generates both `{sctp, ...}` and `{sctp_error, ...}`
messages resides in inet_drv.c, specifically in packet_binary_message()
and sctp_parse_async_event().  Within sctp_parse_async_event(), an error
is indicated by replacing the initial `sctp` atom with `sctp_error`.

The following SCTP events are currently reported as errors:

* SCTP_SEND_FAILED (becomes #sctp_send_failed{}),
* SCTP_REMOTE_ERROR (becomes #sctp_remote_error{}),
* SCTP_PARTIAL_DELIVERY_EVENT (becomes #sctp_pdapi_event{}).

Document this and update the example code to print errors.
---
 lib/kernel/src/gen_sctp.erl | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/lib/kernel/src/gen_sctp.erl b/lib/kernel/src/gen_sctp.erl
index 9ad56a1df8..1fa7d86c00 100644
--- a/lib/kernel/src/gen_sctp.erl
+++ b/lib/kernel/src/gen_sctp.erl
@@ -613,6 +613,11 @@ client_loop(S, Peer1, Port1, AssocId1, Peer2, Port2, AssocId2) ->
             client_loop(S, Peer1, Port1, AssocId1,
                         Peer2, Port2, AssocId2);
 
+        {sctp_error, S, _Peer, _Port, {_Anc, Error}} ->
+            io:format("SCTP error: ~p~n", [Error]),
+            client_loop(S, Peer1, Port1, AssocId1,
+                        Peer2, Port2, AssocId2);
+
         Other ->
             io:format("Other ~p~n", [Other]),
             client_loop(S, Peer1, Port1, AssocId1,
@@ -818,6 +823,14 @@ received data is delivered to the controlling process as messages:
 {sctp, Socket, FromIP, FromPort, {AncData, Data}}
 ```
 
+Error-related events - such as `#sctp_send_failed{}`, `#sctp_pdapi_event{}`,
+and `#sctp_remote_error{}` - are also delivered to the controlling process
+as messages, but use a different tuple tag:
+
+```erlang
+{sctp_error, Socket, FromIP, FromPort, {AncData, Data}}
+```
+
 See [`recv/1,2`](`recv/1`) for a description of the message fields.
 
 > #### Note {: .info }
-- 
2.51.0

openSUSE Build Service is sponsored by