Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Network socket options: add support for IPPROTO_IP/IP_MTU_DISCOVER #2075

Merged
merged 1 commit into from
Oct 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions src/net/netsyscall.c
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,7 @@ static inline s64 lwip_to_errno(s8 err)
case ERR_RST: return -ECONNRESET;
case ERR_CLSD: return -ENOTCONN;
case ERR_ARG: return -EIO;
case ERR_MSGSIZE: return -EMSGSIZE;
}
return -EINVAL; /* XXX unknown - check return value */
}
Expand Down Expand Up @@ -2386,6 +2387,24 @@ static sysreturn netsock_setsockopt(struct sock *sock, int level,
int int_optval;
sysreturn rv;
switch (level) {
case IPPROTO_IP:
switch (optname) {
case IP_MTU_DISCOVER:
rv = sockopt_copy_from_user(optval, optlen, &int_optval, sizeof(int));
if (rv)
goto out;
if (s->sock.type == SOCK_STREAM) {
struct tcp_pcb *tcp_lw = netsock_tcp_get(s);
tcp_lw->pmtudisc = int_optval;
netsock_tcp_put(tcp_lw);
} else {
s->info.udp.lw->pmtudisc = int_optval;
}
break;
default:
goto unimplemented;
}
break;
case IPPROTO_IPV6:
switch (optname) {
case IPV6_V6ONLY:
Expand Down Expand Up @@ -2696,6 +2715,21 @@ static sysreturn netsock_getsockopt(struct sock *sock, int level,
goto unimplemented;
}
break;
case IPPROTO_IP:
switch (optname) {
case IP_MTU_DISCOVER:
if (s->sock.type == SOCK_STREAM) {
struct tcp_pcb *tcp_lw = netsock_tcp_get(s);
ret_optval.val = tcp_lw->pmtudisc;
netsock_tcp_put(tcp_lw);
} else {
ret_optval.val = s->info.udp.lw->pmtudisc;
}
break;
default:
goto unimplemented;
}
break;
case IPPROTO_IPV6:
switch (optname) {
case IPV6_V6ONLY:
Expand Down
1 change: 1 addition & 0 deletions src/unix/system_structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -863,6 +863,7 @@ struct io_uring_params {
#define IP_TOS 1
#define IP_TTL 2
#define IP_OPTIONS 4
#define IP_MTU_DISCOVER 10
#define IP_MINTTL 21
#define IP_MULTICAST_IF 32
#define IP_MULTICAST_TTL 33
Expand Down