From a0c5c176a0d39530732879e7bf22ce7ac9d793da Mon Sep 17 00:00:00 2001 From: Marcin Niestroj Date: Thu, 7 Apr 2022 19:53:49 +0200 Subject: [PATCH] modem: ublox-sara-r4: implement 'is_supported' socket offload cb Check if requested socket family, type and protocol are all supported by the driver, instead of blindly acknowledging every possible variant. There is explicit support for UDP, TCP and TLS on top of IPv4 and IPv6. TLS seems to be supported only in 1.2 version, so allow just that version. Signed-off-by: Marcin Niestroj --- drivers/modem/ublox-sara-r4.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/drivers/modem/ublox-sara-r4.c b/drivers/modem/ublox-sara-r4.c index 97f31eb1403..c62cef4d933 100644 --- a/drivers/modem/ublox-sara-r4.c +++ b/drivers/modem/ublox-sara-r4.c @@ -1947,7 +1947,22 @@ static const struct socket_op_vtable offload_socket_fd_op_vtable = { static bool offload_is_supported(int family, int type, int proto) { - /* TODO offloading always enabled for now. */ + if (family != AF_INET && + family != AF_INET6) { + return false; + } + + if (type != SOCK_DGRAM && + type != SOCK_STREAM) { + return false; + } + + if (proto != IPPROTO_TCP && + proto != IPPROTO_UDP && + proto != IPPROTO_TLS_1_2) { + return false; + } + return true; }