Skip to content

Commit

Permalink
Fix setsockopt (deleted it)
Browse files Browse the repository at this point in the history
  • Loading branch information
Waujito committed Sep 1, 2024
1 parent b249903 commit 1b7026c
Showing 1 changed file with 7 additions and 20 deletions.
27 changes: 7 additions & 20 deletions kmod_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,9 @@ int open_raw_socket(void) {
.is_kernel = 1
};

int mark = config.mark;
optval.kernel = &mark;
ret = sock_setsockopt(rawsocket, SOL_SOCKET, SO_MARK, optval, sizeof(mark));
if (ret < 0)
{
pr_alert("setsockopt(SO_MARK, %d) failed\n", mark);
goto sr_err;
}
int one = 1;
optval.kernel = &one;
// That's funny, but this is how it is done in the kernel
// https://elixir.bootlin.com/linux/v3.17.7/source/net/core/sock.c#L916
rawsocket->sk->sk_mark=config.mark;

return 0;
sr_err:
Expand Down Expand Up @@ -109,16 +102,10 @@ int open_raw6_socket(void) {
.is_kernel = 1
};

int mark = config.mark;
optval.kernel = &mark;
ret = sock_setsockopt(raw6socket, SOL_SOCKET, SO_MARK, optval, sizeof(mark));
if (ret < 0)
{
pr_alert("setsockopt(SO_MARK, %d) failed\n", mark);
goto sr_err;
}
int one = 1;
optval.kernel = &one;

// That's funny, but this is how it is done in the kernel
// https://elixir.bootlin.com/linux/v3.17.7/source/net/core/sock.c#L916
raw6socket->sk->sk_mark=config.mark;

return 0;
sr_err:
Expand Down

0 comments on commit 1b7026c

Please sign in to comment.