On 10/18/2024 11:18 AM, Denis Kenzior wrote:
Introduce the ability to bind a QIPCRTR family socket to a specific endpoint. When a socket is bound, only messages from the bound endpoint can be received, and any messages sent from the socket are by default directed to the bound endpoint. Clients can bind a socket by using the setsockopt system call with the QRTR_BIND_ENDPOINT option set to the desired endpoint binding. A previously set binding can be reset by setting QRTR_BIND_ENDPOINT option to zero. This behavior matches that of SO_BINDTOIFINDEX. This functionality is useful for clients that need to communicate with a specific device (i.e. endpoint), such as a PCIe-based 5G modem, and are not interested in messages from other endpoints / nodes. Signed-off-by: Denis Kenzior <denkenz@xxxxxxxxx> Reviewed-by: Marcel Holtmann <marcel@xxxxxxxxxxxx> Reviewed-by: Andy Gross <agross@xxxxxxxxxx> --- include/uapi/linux/qrtr.h | 1 + net/qrtr/af_qrtr.c | 54 ++++++++++++++++++++++++++++----------- 2 files changed, 40 insertions(+), 15 deletions(-)
...
@@ -1313,6 +1331,9 @@ static int qrtr_setsockopt(struct socket *sock, int level, int optname, case QRTR_REPORT_ENDPOINT: assign_bit(QRTR_F_REPORT_ENDPOINT, &ipc->flags, val); break; + case QRTR_BIND_ENDPOINT: + ipc->bound_endpoint = val; + break; default: rc = -ENOPROTOOPT; } @@ -1346,6 +1367,9 @@ static int qrtr_getsockopt(struct socket *sock, int level, int optname, case QRTR_REPORT_ENDPOINT: val = test_bit(QRTR_F_REPORT_ENDPOINT, &ipc->flags); break; + case QRTR_BIND_ENDPOINT: + val = ipc->bound_endpoint; + break;
In the case where an endpoint goes away and a client has bound their socket to an endpoint, would there be any notification to unbind the socket?
Is the expectation that the client would get notified through ECONNRESET on the next sendmsg() or receive the BYE/DEL_CLIENT/DEL_SERVER control message.
On that cleanup, I guess the client would either re-bind the socket back to 0 or wait for the mhi sysfs to come back and get the new endpoint id?
default: rc = -ENOPROTOOPT; }