Skip to content
This repository has been archived by the owner on Sep 19, 2024. It is now read-only.

Commit

Permalink
fix for ipv6
Browse files Browse the repository at this point in the history
  • Loading branch information
bonifaido committed Apr 8, 2024
1 parent 82031a4 commit b3d58c5
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ static struct proto camblet_ktls_prot;
static struct proto camblet_v6_prot;
static struct proto camblet_v6_ktls_prot;

static struct proto_ops camblet_stream_ops;
static struct proto_ops camblet_v6_stream_ops;

static br_rsa_private_key *rsa_priv;
static br_rsa_public_key *rsa_pub;

Expand Down Expand Up @@ -1964,9 +1967,6 @@ struct sock *camblet_accept(struct sock *sk, int flags, int *err, bool kern)
return NULL;
}

struct proto_ops camblet_stream_ops;
struct proto_ops camblet_v6_stream_ops;

__poll_t camblet_poll(struct file *file, struct socket *sock,
struct poll_table_struct *wait)
{
Expand All @@ -1978,7 +1978,7 @@ __poll_t camblet_poll(struct file *file, struct socket *sock,
if (poll_requested_events(wait) & POLLIN)
{
size_t left;

mutex_lock(&s->lock);
{
br_ssl_engine_context *ctx = get_ssl_engine_context(s);
Expand Down Expand Up @@ -2016,7 +2016,14 @@ int camblet_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
{
err = connect_v6(sk, uaddr, addr_len);
prot = &camblet_v6_prot;
// prot_ops = &camblet_v6_stream_ops;

if (!camblet_v6_stream_ops.poll)
{
camblet_v6_stream_ops = *sk->sk_socket->ops;
camblet_v6_stream_ops.poll = camblet_poll;
}

prot_ops = &camblet_v6_stream_ops;
}

if (err != 0)
Expand Down Expand Up @@ -2113,10 +2120,14 @@ int socket_init(void)
return err;
}

// for poll support we need to overwrite the inet ops
camblet_stream_ops = inet_stream_ops;
camblet_stream_ops.poll = camblet_poll;

camblet_v6_stream_ops.poll = camblet_poll;
// inet6_stream_ops is not EXPORT-ed in the kernel, so we need to capture it in
// camblet_connect and create our own version.
// Here we mark our version uninitialized so we can later check if it was initialized.
camblet_v6_stream_ops.poll = NULL;

// let's overwrite tcp_prot with our own implementation

Expand Down

0 comments on commit b3d58c5

Please sign in to comment.