Skip to content

Commit a6a9d7a

Browse files
rluboscarlescufi
authored andcommitted
net: websocket: Fix ioctl implementation for websocket
The websocket implementation of ioctl wrongly passed websocket context to the undrelying `ioctl` implementation instead of the context of the underlying socket. Additionally, currentl implementation used the vtable of the native socket implementation unconditionally, making it unusable with an offloaded underlying socket. Signed-off-by: Robert Lubos <[email protected]>
1 parent 4295b19 commit a6a9d7a

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

subsys/net/lib/websocket/websocket.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ static struct websocket_context contexts[CONFIG_WEBSOCKET_MAX_CONTEXTS];
4646

4747
static struct k_sem contexts_lock;
4848

49-
extern const struct socket_op_vtable sock_fd_op_vtable;
5049
static const struct socket_op_vtable websocket_fd_op_vtable;
5150

5251
#if defined(CONFIG_NET_TEST)
@@ -437,7 +436,21 @@ static int websocket_close_vmeth(void *obj)
437436

438437
static int websocket_ioctl_vmeth(void *obj, unsigned int request, va_list args)
439438
{
440-
return sock_fd_op_vtable.fd_vtable.ioctl(obj, request, args);
439+
struct websocket_context *ctx = obj;
440+
const struct fd_op_vtable *vtable;
441+
void *core_obj;
442+
443+
core_obj = z_get_fd_obj_and_vtable(
444+
ctx->real_sock,
445+
(const struct fd_op_vtable **)&vtable,
446+
NULL);
447+
if (core_obj == NULL) {
448+
errno = EBADF;
449+
return -1;
450+
}
451+
452+
/* Pass the call to the core socket implementation. */
453+
return vtable->ioctl(core_obj, request, args);
441454
}
442455

443456
static int websocket_prepare_and_send(struct websocket_context *ctx,

0 commit comments

Comments
 (0)