- add more linux socket options (sorted by value)

- map those IPv4 / IPv6 socket options which exist in FreeBSD
   + most of them visually verified to have the same type/layout of arguments
   + not tested with linux programs to behave as intended
 - be more human readable for known options which are not handled
 - be more verbose for unhandled socket message flags we know about
 - print the jail ID in linux_msg if run in a jail
 - add possibility to print debug message about known missing parts only once
 - add multiple levels of sysctl linux.debug:
   1: print debug messages, tell about unimplemented stuff (only once)
   2: like 1, but also print messages about implemented but not tested
      stuff (only once)
   3+: like 2, but no rate limiting of messages
 - increase default linux debug level from 1 to 3

We are a lot more verbose in as we need to be (e.g. some of the IP socket
options which are the same, and share the same memory layout, and are
believed to work). The reason is that we have no good testsuite to test those
linux-bits. The LTP or other test suites like the python one, are not fully
up to the task we need. As such the excessive messages about emulated but not
tested socket options.

IMO any MFC (possible, but most probably not by me) should set the default
debug level to 1.

Discussed with:	trasz
This commit is contained in:
Alexander Leidinger 2020-11-08 09:50:58 +00:00
parent 83a252c6a1
commit 8ec6c4a38b
6 changed files with 452 additions and 30 deletions

View File

@ -98,7 +98,12 @@ tunables:
.It Va compat.linux.debug
Enable debugging messages.
Set to 0 to silence them.
Defaults to 1.
Defaults to 3.
A setting of 1 prints debug messages, tells about unimplemented stuff (only
once).
Set to 2 is like 1, but also prints messages about implemented but not tested
stuff (only once).
Setting it to 3 or higher is like 2, but no rate limiting of messages.
.It Va compat.linux.default_openfiles
Default soft openfiles resource limit for Linux applications.
Set to -1 to disable the limit.

View File

@ -63,7 +63,7 @@ static unsigned linux_osd_jail_slot;
SYSCTL_NODE(_compat, OID_AUTO, linux, CTLFLAG_RW | CTLFLAG_MPSAFE, 0,
"Linux mode");
int linux_debug = 1;
int linux_debug = 3;
SYSCTL_INT(_compat_linux, OID_AUTO, debug, CTLFLAG_RWTUN,
&linux_debug, 0, "Log warnings from linux(4); or 0 to disable");

View File

@ -112,12 +112,37 @@ linux_to_bsd_ip_sockopt(int opt)
{
switch (opt) {
/* known and translated sockopts */
case LINUX_IP_TOS:
return (IP_TOS);
case LINUX_IP_TTL:
return (IP_TTL);
case LINUX_IP_HDRINCL:
return (IP_HDRINCL);
case LINUX_IP_OPTIONS:
return (IP_OPTIONS);
case LINUX_IP_RECVOPTS:
LINUX_RATELIMIT_MSG_NOTTESTED("IPv4 socket option IP_RECVOPTS");
return (IP_RECVOPTS);
case LINUX_IP_RETOPTS:
LINUX_RATELIMIT_MSG_NOTTESTED("IPv4 socket option IP_REETOPTS");
return (IP_RETOPTS);
case LINUX_IP_RECVTTL:
LINUX_RATELIMIT_MSG_NOTTESTED("IPv4 socket option IP_RECVTTL");
return (IP_RECVTTL);
case LINUX_IP_RECVTOS:
LINUX_RATELIMIT_MSG_NOTTESTED("IPv4 socket option IP_RECVTOS");
return (IP_RECVTOS);
case LINUX_IP_FREEBIND:
LINUX_RATELIMIT_MSG_NOTTESTED("IPv4 socket option IP_FREEBIND");
return (IP_BINDANY);
case LINUX_IP_IPSEC_POLICY:
/* we have this option, but not documented in ip(4) manpage */
LINUX_RATELIMIT_MSG_NOTTESTED("IPv4 socket option IP_IPSEC_POLICY");
return (IP_IPSEC_POLICY);
case LINUX_IP_MINTTL:
LINUX_RATELIMIT_MSG_NOTTESTED("IPv4 socket option IP_MINTTL");
return (IP_MINTTL);
case LINUX_IP_MULTICAST_IF:
return (IP_MULTICAST_IF);
case LINUX_IP_MULTICAST_TTL:
@ -128,10 +153,120 @@ linux_to_bsd_ip_sockopt(int opt)
return (IP_ADD_MEMBERSHIP);
case LINUX_IP_DROP_MEMBERSHIP:
return (IP_DROP_MEMBERSHIP);
case LINUX_IP_HDRINCL:
return (IP_HDRINCL);
case LINUX_IP_UNBLOCK_SOURCE:
LINUX_RATELIMIT_MSG_NOTTESTED("IPv4 socket option IP_UNBLOCK_SOURCE");
return (IP_UNBLOCK_SOURCE);
case LINUX_IP_BLOCK_SOURCE:
LINUX_RATELIMIT_MSG_NOTTESTED("IPv4 socket option IP_BLOCK_SOURCE");
return (IP_BLOCK_SOURCE);
case LINUX_IP_ADD_SOURCE_MEMBERSHIP:
LINUX_RATELIMIT_MSG_NOTTESTED("IPv4 socket option IP_ADD_SOURCE_MEMBERSHIP");
return (IP_ADD_SOURCE_MEMBERSHIP);
case LINUX_IP_DROP_SOURCE_MEMBERSHIP:
LINUX_RATELIMIT_MSG_NOTTESTED("IPv4 socket option IP_DROP_SOURCE_MEMBERSHIP");
return (IP_DROP_SOURCE_MEMBERSHIP);
case LINUX_MCAST_JOIN_GROUP:
LINUX_RATELIMIT_MSG_NOTTESTED("IPv4 socket option IP_MCAST_JOIN_GROUP");
return (MCAST_JOIN_GROUP);
case LINUX_MCAST_LEAVE_GROUP:
LINUX_RATELIMIT_MSG_NOTTESTED("IPv4 socket option IP_MCAST_LEAVE_GROUP");
return (MCAST_LEAVE_GROUP);
case LINUX_MCAST_JOIN_SOURCE_GROUP:
LINUX_RATELIMIT_MSG_NOTTESTED("IPv4 socket option IP_MCAST_JOIN_SOURCE_GROUP");
return (MCAST_JOIN_SOURCE_GROUP);
case LINUX_MCAST_LEAVE_SOURCE_GROUP:
LINUX_RATELIMIT_MSG_NOTTESTED("IPv4 socket option IP_MCAST_LEAVE_SOURCE_GROUP");
return (MCAST_LEAVE_SOURCE_GROUP);
/* known but not implemented sockopts */
case LINUX_IP_ROUTER_ALERT:
LINUX_RATELIMIT_MSG_OPT1(
"unsupported IPv4 socket option IP_ROUTER_ALERT (%d), you can not do user-space routing from linux programs",
opt);
return (-2);
case LINUX_IP_PKTINFO:
LINUX_RATELIMIT_MSG_OPT1(
"unsupported IPv4 socket option IP_PKTINFO (%d), you can not get extended packet info for datagram sockets in linux programs",
opt);
return (-2);
case LINUX_IP_PKTOPTIONS:
LINUX_RATELIMIT_MSG_OPT1(
"unsupported IPv4 socket option IP_PKTOPTIONS (%d)",
opt);
return (-2);
case LINUX_IP_MTU_DISCOVER:
LINUX_RATELIMIT_MSG_OPT1(
"unsupported IPv4 socket option IP_MTU_DISCOVER (%d), your linux program can not control path-MTU discovery",
opt);
return (-2);
case LINUX_IP_RECVERR:
/* needed by steam */
LINUX_RATELIMIT_MSG_OPT1(
"unsupported IPv4 socket option IP_RECVERR (%d), you can not get extended reliability info in linux programs",
opt);
return (-2);
case LINUX_IP_MTU:
LINUX_RATELIMIT_MSG_OPT1(
"unsupported IPv4 socket option IP_MTU (%d), your linux program can not control the MTU on this socket",
opt);
return (-2);
case LINUX_IP_XFRM_POLICY:
LINUX_RATELIMIT_MSG_OPT1(
"unsupported IPv4 socket option IP_XFRM_POLICY (%d)",
opt);
return (-2);
case LINUX_IP_PASSSEC:
/* needed by steam */
LINUX_RATELIMIT_MSG_OPT1(
"unsupported IPv4 socket option IP_PASSSEC (%d), you can not get IPSEC related credential information associated with this socket in linux programs -- if you do not use IPSEC, you can ignore this",
opt);
return (-2);
case LINUX_IP_TRANSPARENT:
/* IP_BINDANY or more? */
LINUX_RATELIMIT_MSG_OPT1(
"unsupported IPv4 socket option IP_TRANSPARENT (%d), you can not enable transparent proxying in linux programs -- note, IP_FREEBIND is supported, no idea if the FreeBSD IP_BINDANY is equivalent to the Linux IP_TRANSPARENT or not, any info is welcome",
opt);
return (-2);
case LINUX_IP_NODEFRAG:
LINUX_RATELIMIT_MSG_OPT1(
"unsupported IPv4 socket option IP_NODEFRAG (%d)",
opt);
return (-2);
case LINUX_IP_CHECKSUM:
LINUX_RATELIMIT_MSG_OPT1(
"unsupported IPv4 socket option IP_CHECKSUM (%d)",
opt);
return (-2);
case LINUX_IP_BIND_ADDRESS_NO_PORT:
LINUX_RATELIMIT_MSG_OPT1(
"unsupported IPv4 socket option IP_BIND_ADDRESS_NO_PORT (%d)",
opt);
return (-2);
case LINUX_IP_RECVFRAGSIZE:
LINUX_RATELIMIT_MSG_OPT1(
"unsupported IPv4 socket option IP_RECVFRAGSIZE (%d)",
opt);
return (-2);
case LINUX_MCAST_MSFILTER:
LINUX_RATELIMIT_MSG_OPT1(
"unsupported IPv4 socket option IP_MCAST_MSFILTER (%d)",
opt);
return (-2);
case LINUX_IP_MULTICAST_ALL:
LINUX_RATELIMIT_MSG_OPT1(
"unsupported IPv4 socket option IP_MULTICAST_ALL (%d), your linux program will not see all multicast groups joined by the entire system, only those the program joined itself on this socket",
opt);
return (-2);
case LINUX_IP_UNICAST_IF:
LINUX_RATELIMIT_MSG_OPT1(
"unsupported IPv4 socket option IP_UNICAST_IF (%d)",
opt);
return (-2);
/* unknown sockopts */
default:
return (-1);
}
return (-1);
}
static int
@ -139,6 +274,28 @@ linux_to_bsd_ip6_sockopt(int opt)
{
switch (opt) {
/* known and translated sockopts */
case LINUX_IPV6_2292PKTINFO:
LINUX_RATELIMIT_MSG_NOTTESTED("IPv6 socket option IPV6_2292PKTINFO");
return (IPV6_2292PKTINFO);
case LINUX_IPV6_2292HOPOPTS:
LINUX_RATELIMIT_MSG_NOTTESTED("IPv6 socket option IPV6_2292HOPOPTS");
return (IPV6_2292HOPOPTS);
case LINUX_IPV6_2292DSTOPTS:
LINUX_RATELIMIT_MSG_NOTTESTED("IPv6 socket option IPV6_2292DSTOPTS");
return (IPV6_2292DSTOPTS);
case LINUX_IPV6_2292RTHDR:
LINUX_RATELIMIT_MSG_NOTTESTED("IPv6 socket option IPV6_2292RTHDR");
return (IPV6_2292RTHDR);
case LINUX_IPV6_2292PKTOPTIONS:
LINUX_RATELIMIT_MSG_NOTTESTED("IPv6 socket option IPV6_2292PKTOPTIONS");
return (IPV6_2292PKTOPTIONS);
case LINUX_IPV6_CHECKSUM:
LINUX_RATELIMIT_MSG_NOTTESTED("IPv6 socket option IPV6_CHECKSUM");
return (IPV6_CHECKSUM);
case LINUX_IPV6_2292HOPLIMIT:
LINUX_RATELIMIT_MSG_NOTTESTED("IPv6 socket option IPV6_2292HOPLIMIT");
return (IPV6_2292HOPLIMIT);
case LINUX_IPV6_NEXTHOP:
return (IPV6_NEXTHOP);
case LINUX_IPV6_UNICAST_HOPS:
@ -155,40 +312,194 @@ linux_to_bsd_ip6_sockopt(int opt)
return (IPV6_LEAVE_GROUP);
case LINUX_IPV6_V6ONLY:
return (IPV6_V6ONLY);
case LINUX_IPV6_DONTFRAG:
return (IPV6_DONTFRAG);
#if 0
case LINUX_IPV6_CHECKSUM:
return (IPV6_CHECKSUM);
case LINUX_IPV6_IPSEC_POLICY:
/* we have this option, but not documented in ip6(4) manpage */
LINUX_RATELIMIT_MSG_NOTTESTED("IPv6 socket option IPV6_IPSEC_POLICY");
return (IPV6_IPSEC_POLICY);
case LINUX_MCAST_JOIN_GROUP:
LINUX_RATELIMIT_MSG_NOTTESTED("IPv6 socket option IPV6_JOIN_GROUP");
return (IPV6_JOIN_GROUP);
case LINUX_MCAST_LEAVE_GROUP:
LINUX_RATELIMIT_MSG_NOTTESTED("IPv6 socket option IPV6_LEAVE_GROUP");
return (IPV6_LEAVE_GROUP);
case LINUX_IPV6_RECVPKTINFO:
LINUX_RATELIMIT_MSG_NOTTESTED("IPv6 socket option IPV6_RECVPKTINFO");
return (IPV6_RECVPKTINFO);
case LINUX_IPV6_PKTINFO:
LINUX_RATELIMIT_MSG_NOTTESTED("IPv6 socket option IPV6_PKTINFO");
return (IPV6_PKTINFO);
case LINUX_IPV6_RECVHOPLIMIT:
LINUX_RATELIMIT_MSG_NOTTESTED("IPv6 socket option IPV6_RECVHOPLIMIT");
return (IPV6_RECVHOPLIMIT);
case LINUX_IPV6_HOPLIMIT:
LINUX_RATELIMIT_MSG_NOTTESTED("IPv6 socket option IPV6_HOPLIMIT");
return (IPV6_HOPLIMIT);
case LINUX_IPV6_RECVHOPOPTS:
LINUX_RATELIMIT_MSG_NOTTESTED("IPv6 socket option IPV6_RECVHOPOPTS");
return (IPV6_RECVHOPOPTS);
case LINUX_IPV6_HOPOPTS:
LINUX_RATELIMIT_MSG_NOTTESTED("IPv6 socket option IPV6_HOPOPTS");
return (IPV6_HOPOPTS);
case LINUX_IPV6_RTHDRDSTOPTS:
LINUX_RATELIMIT_MSG_NOTTESTED("IPv6 socket option IPV6_RTHDRDSTOPTS");
return (IPV6_RTHDRDSTOPTS);
case LINUX_IPV6_RECVRTHDR:
LINUX_RATELIMIT_MSG_NOTTESTED("IPv6 socket option IPV6_RECVRTHDR");
return (IPV6_RECVRTHDR);
case LINUX_IPV6_RTHDR:
LINUX_RATELIMIT_MSG_NOTTESTED("IPv6 socket option IPV6_RTHDR");
return (IPV6_RTHDR);
case LINUX_IPV6_RECVDSTOPTS:
LINUX_RATELIMIT_MSG_NOTTESTED("IPv6 socket option IPV6_RECVDSTOPTS");
return (IPV6_RECVDSTOPTS);
case LINUX_IPV6_DSTOPTS:
LINUX_RATELIMIT_MSG_NOTTESTED("IPv6 socket option IPV6_DSTOPTS");
return (IPV6_DSTOPTS);
case LINUX_IPV6_RECVPATHMTU:
LINUX_RATELIMIT_MSG_NOTTESTED("IPv6 socket option IPV6_RECVPATHMTU");
return (IPV6_RECVPATHMTU);
case LINUX_IPV6_PATHMTU:
LINUX_RATELIMIT_MSG_NOTTESTED("IPv6 socket option IPV6_PATHMTU");
return (IPV6_PATHMTU);
#endif
case LINUX_IPV6_DONTFRAG:
return (IPV6_DONTFRAG);
case LINUX_IPV6_AUTOFLOWLABEL:
LINUX_RATELIMIT_MSG_NOTTESTED("IPv6 socket option IPV6_AUTOFLOWLABEL");
return (IPV6_AUTOFLOWLABEL);
case LINUX_IPV6_ORIGDSTADDR:
LINUX_RATELIMIT_MSG_NOTTESTED("IPv6 socket option IPV6_ORIGDSTADDR");
return (IPV6_ORIGDSTADDR);
case LINUX_IPV6_FREEBIND:
LINUX_RATELIMIT_MSG_NOTTESTED("IPv6 socket option IPV6_FREEBIND");
return (IPV6_BINDANY);
/* known but not implemented sockopts */
case LINUX_IPV6_ADDRFORM:
LINUX_RATELIMIT_MSG_OPT1(
"unsupported IPv6 socket option IPV6_ADDRFORM (%d), you linux program can not convert the socket to IPv4",
opt);
return (-2);
case LINUX_IPV6_AUTHHDR:
LINUX_RATELIMIT_MSG_OPT1(
"unsupported IPv6 socket option IPV6_AUTHHDR (%d), your linux program can not get the authentication header info of IPv6 packets",
opt);
return (-2);
case LINUX_IPV6_FLOWINFO:
LINUX_RATELIMIT_MSG_OPT1(
"unsupported IPv6 socket option IPV6_FLOWINFO (%d), your linux program can not get the flowid of IPv6 packets",
opt);
return (-2);
case LINUX_IPV6_ROUTER_ALERT:
LINUX_RATELIMIT_MSG_OPT1(
"unsupported IPv6 socket option IPV6_ROUTER_ALERT (%d), you can not do user-space routing from linux programs",
opt);
return (-2);
case LINUX_IPV6_MTU_DISCOVER:
LINUX_RATELIMIT_MSG_OPT1(
"unsupported IPv6 socket option IPV6_MTU_DISCOVER (%d), your linux program can not control path-MTU discovery",
opt);
return (-2);
case LINUX_IPV6_MTU:
LINUX_RATELIMIT_MSG_OPT1(
"unsupported IPv6 socket option IPV6_MTU (%d), your linux program can not control the MTU on this socket",
opt);
return (-2);
case LINUX_IPV6_JOIN_ANYCAST:
LINUX_RATELIMIT_MSG_OPT1(
"unsupported IPv6 socket option IPV6_JOIN_ANYCAST (%d)",
opt);
return (-2);
case LINUX_IPV6_LEAVE_ANYCAST:
LINUX_RATELIMIT_MSG_OPT1(
"unsupported IPv6 socket option IPV6_LEAVE_ANYCAST (%d)",
opt);
return (-2);
case LINUX_IPV6_MULTICAST_ALL:
LINUX_RATELIMIT_MSG_OPT1(
"unsupported IPv6 socket option IPV6_MULTICAST_ALL (%d)",
opt);
return (-2);
case LINUX_IPV6_ROUTER_ALERT_ISOLATE:
LINUX_RATELIMIT_MSG_OPT1(
"unsupported IPv6 socket option IPV6_ROUTER_ALERT_ISOLATE (%d)",
opt);
return (-2);
case LINUX_IPV6_FLOWLABEL_MGR:
LINUX_RATELIMIT_MSG_OPT1(
"unsupported IPv6 socket option IPV6_FLOWLABEL_MGR (%d)",
opt);
return (-2);
case LINUX_IPV6_FLOWINFO_SEND:
LINUX_RATELIMIT_MSG_OPT1(
"unsupported IPv6 socket option IPV6_FLOWINFO_SEND (%d)",
opt);
return (-2);
case LINUX_IPV6_XFRM_POLICY:
LINUX_RATELIMIT_MSG_OPT1(
"unsupported IPv6 socket option IPV6_XFRM_POLICY (%d)",
opt);
return (-2);
case LINUX_IPV6_HDRINCL:
LINUX_RATELIMIT_MSG_OPT1(
"unsupported IPv6 socket option IPV6_HDRINCL (%d)",
opt);
return (-2);
case LINUX_MCAST_BLOCK_SOURCE:
LINUX_RATELIMIT_MSG_OPT1(
"unsupported IPv6 socket option MCAST_BLOCK_SOURCE (%d), your linux program may see more multicast stuff than it wants",
opt);
return (-2);
case LINUX_MCAST_UNBLOCK_SOURCE:
LINUX_RATELIMIT_MSG_OPT1(
"unsupported IPv6 socket option MCAST_UNBLOCK_SOURCE (%d), your linux program may not see all the multicast stuff it wants",
opt);
return (-2);
case LINUX_MCAST_JOIN_SOURCE_GROUP:
LINUX_RATELIMIT_MSG_OPT1(
"unsupported IPv6 socket option MCAST_JOIN_SOURCE_GROUP (%d), your linux program is not able to join a multicast source group",
opt);
return (-2);
case LINUX_MCAST_LEAVE_SOURCE_GROUP:
LINUX_RATELIMIT_MSG_OPT1(
"unsupported IPv6 socket option MCAST_LEAVE_SOURCE_GROUP (%d), your linux program is not able to leave a multicast source group -- but it was also not able to join one, so no issue",
opt);
return (-2);
case LINUX_MCAST_MSFILTER:
LINUX_RATELIMIT_MSG_OPT1(
"unsupported IPv6 socket option MCAST_MSFILTER (%d), your linux program can not manipulate the multicast filter, it may see more multicast data than it wants to see",
opt);
return (-2);
case LINUX_IPV6_ADDR_PREFERENCES:
LINUX_RATELIMIT_MSG_OPT1(
"unsupported IPv6 socket option IPV6_ADDR_PREFERENCES (%d)",
opt);
return (-2);
case LINUX_IPV6_MINHOPCOUNT:
LINUX_RATELIMIT_MSG_OPT1(
"unsupported IPv6 socket option IPV6_MINHOPCOUNT (%d)",
opt);
return (-2);
case LINUX_IPV6_TRANSPARENT:
/* IP_BINDANY or more? */
LINUX_RATELIMIT_MSG_OPT1(
"unsupported IPv6 socket option IPV6_TRANSPARENT (%d), you can not enable transparent proxying in linux programs -- note, IP_FREEBIND is supported, no idea if the FreeBSD IP_BINDANY is equivalent to the Linux IP_TRANSPARENT or not, any info is welcome",
opt);
return (-2);
case LINUX_IPV6_UNICAST_IF:
LINUX_RATELIMIT_MSG_OPT1(
"unsupported IPv6 socket option IPV6_UNICAST_IF (%d)",
opt);
return (-2);
case LINUX_IPV6_RECVFRAGSIZE:
LINUX_RATELIMIT_MSG_OPT1(
"unsupported IPv6 socket option IPV6_RECVFRAGSIZE (%d)",
opt);
return (-2);
/* unknown sockopts */
default:
return (-1);
}
return (-1);
}
static int
@ -290,20 +601,24 @@ linux_to_bsd_msg_flags(int flags)
ret_flags |= MSG_WAITALL;
if (flags & LINUX_MSG_NOSIGNAL)
ret_flags |= MSG_NOSIGNAL;
#if 0 /* not handled */
if (flags & LINUX_MSG_PROXY)
;
LINUX_RATELIMIT_MSG_OPT1("socket message flag MSG_PROXY (%d) not handled",
LINUX_MSG_PROXY);
if (flags & LINUX_MSG_FIN)
;
LINUX_RATELIMIT_MSG_OPT1("socket message flag MSG_FIN (%d) not handled",
LINUX_MSG_FIN);
if (flags & LINUX_MSG_SYN)
;
LINUX_RATELIMIT_MSG_OPT1("socket message flag MSG_SYN (%d) not handled",
LINUX_MSG_SYN);
if (flags & LINUX_MSG_CONFIRM)
;
LINUX_RATELIMIT_MSG_OPT1("socket message flag MSG_CONFIRM (%d) not handled",
LINUX_MSG_CONFIRM);
if (flags & LINUX_MSG_RST)
;
LINUX_RATELIMIT_MSG_OPT1("socket message flag MSG_RST (%d) not handled",
LINUX_MSG_RST);
if (flags & LINUX_MSG_ERRQUEUE)
;
#endif
LINUX_RATELIMIT_MSG_OPT1("socket message flag MSG_ERRQUEUE (%d) not handled",
LINUX_MSG_ERRQUEUE);
return (ret_flags);
}
@ -1505,10 +1820,11 @@ linux_setsockopt(struct thread *td, struct linux_setsockopt_args *args)
name = -1;
break;
}
if (name == -1) {
linux_msg(curthread,
"unsupported setsockopt level %d optname %d",
args->level, args->optname);
if (name < 0) {
if (name == -1)
linux_msg(curthread,
"unsupported setsockopt level %d optname %d",
args->level, args->optname);
return (ENOPROTOOPT);
}
@ -1605,10 +1921,11 @@ linux_getsockopt(struct thread *td, struct linux_getsockopt_args *args)
name = -1;
break;
}
if (name == -1) {
linux_msg(curthread,
"unsupported getsockopt level %d optname %d",
args->level, args->optname);
if (name < 0) {
if (name == -1)
linux_msg(curthread,
"unsupported getsockopt level %d optname %d",
args->level, args->optname);
return (EINVAL);
}

View File

@ -204,23 +204,83 @@ int linux_accept(struct thread *td, struct linux_accept_args *args);
#define LINUX_IP_TTL 2
#define LINUX_IP_HDRINCL 3
#define LINUX_IP_OPTIONS 4
#define LINUX_IP_ROUTER_ALERT 5
#define LINUX_IP_RECVOPTS 6
#define LINUX_IP_RETOPTS 7
#define LINUX_IP_PKTINFO 8
#define LINUX_IP_PKTOPTIONS 9
#define LINUX_IP_MTU_DISCOVER 10
#define LINUX_IP_RECVERR 11
#define LINUX_IP_RECVTTL 12
#define LINUX_IP_RECVTOS 13
#define LINUX_IP_MTU 14
#define LINUX_IP_FREEBIND 15
#define LINUX_IP_IPSEC_POLICY 16
#define LINUX_IP_XFRM_POLICY 17
#define LINUX_IP_PASSSEC 18
#define LINUX_IP_TRANSPARENT 19
#define LINUX_IP_MINTTL 21
#define LINUX_IP_NODEFRAG 22
#define LINUX_IP_CHECKSUM 23
#define LINUX_IP_BIND_ADDRESS_NO_PORT 24
#define LINUX_IP_RECVFRAGSIZE 25
#define LINUX_IP_MULTICAST_IF 32
#define LINUX_IP_MULTICAST_TTL 33
#define LINUX_IP_MULTICAST_LOOP 34
#define LINUX_IP_ADD_MEMBERSHIP 35
#define LINUX_IP_DROP_MEMBERSHIP 36
#define LINUX_IP_UNBLOCK_SOURCE 37
#define LINUX_IP_BLOCK_SOURCE 38
#define LINUX_IP_ADD_SOURCE_MEMBERSHIP 39
#define LINUX_IP_DROP_SOURCE_MEMBERSHIP 40
#define LINUX_IP_MSFILTER 41
#define LINUX_MCAST_JOIN_GROUP 42
#define LINUX_MCAST_BLOCK_SOURCE 43
#define LINUX_MCAST_UNBLOCK_SOURCE 44
#define LINUX_MCAST_LEAVE_GROUP 45
#define LINUX_MCAST_JOIN_SOURCE_GROUP 46
#define LINUX_MCAST_LEAVE_SOURCE_GROUP 47
#define LINUX_MCAST_MSFILTER 48
#define LINUX_IP_MULTICAST_ALL 49
#define LINUX_IP_UNICAST_IF 50
#define LINUX_IPV6_ADDRFORM 1
#define LINUX_IPV6_2292PKTINFO 2
#define LINUX_IPV6_2292HOPOPTS 3
#define LINUX_IPV6_2292DSTOPTS 4
#define LINUX_IPV6_2292RTHDR 5
#define LINUX_IPV6_2292PKTOPTIONS 6
#define LINUX_IPV6_CHECKSUM 7
#define LINUX_IPV6_2292HOPLIMIT 8
#define LINUX_IPV6_NEXTHOP 9
#define LINUX_IPV6_AUTHHDR 10
#define LINUX_IPV6_FLOWINFO 11
#define LINUX_IPV6_UNICAST_HOPS 16
#define LINUX_IPV6_MULTICAST_IF 17
#define LINUX_IPV6_MULTICAST_HOPS 18
#define LINUX_IPV6_MULTICAST_LOOP 19
#define LINUX_IPV6_ADD_MEMBERSHIP 20
#define LINUX_IPV6_DROP_MEMBERSHIP 21
#define LINUX_IPV6_ROUTER_ALERT 22
#define LINUX_IPV6_MTU_DISCOVER 23
#define LINUX_IPV6_MTU 24
#define LINUX_IPV6_RECVERR 25
#define LINUX_IPV6_V6ONLY 26
#define LINUX_IPV6_JOIN_ANYCAST 27
#define LINUX_IPV6_LEAVE_ANYCAST 28
#define LINUX_IPV6_MULTICAST_ALL 29
#define LINUX_IPV6_ROUTER_ALERT_ISOLATE 30
#define LINUX_IPV6_FLOWLABEL_MGR 32
#define LINUX_IPV6_FLOWINFO_SEND 33
#define LINUX_IPV6_IPSEC_POLICY 34
#define LINUX_IPV6_XFRM_POLICY 35
#define LINUX_IPV6_HDRINCL 36
#define LINUX_IPV6_RECVPKTINFO 49
#define LINUX_IPV6_PKTINFO 50
@ -237,6 +297,15 @@ int linux_accept(struct thread *td, struct linux_accept_args *args);
#define LINUX_IPV6_PATHMTU 61
#define LINUX_IPV6_DONTFRAG 62
#define LINUX_IPV6_AUTOFLOWLABEL 70
#define LINUX_IPV6_ADDR_PREFERENCES 72
#define LINUX_IPV6_MINHOPCOUNT 73
#define LINUX_IPV6_ORIGDSTADDR 74
#define LINUX_IPV6_TRANSPARENT 75
#define LINUX_IPV6_UNICAST_IF 76
#define LINUX_IPV6_RECVFRAGSIZE 77
#define LINUX_IPV6_FREEBIND 78
#define LINUX_TCP_NODELAY 1
#define LINUX_TCP_MAXSEG 2
#define LINUX_TCP_CORK 3

View File

@ -38,6 +38,7 @@ __FBSDID("$FreeBSD$");
#include <sys/bus.h>
#include <sys/conf.h>
#include <sys/fcntl.h>
#include <sys/jail.h>
#include <sys/lock.h>
#include <sys/malloc.h>
#include <sys/kernel.h>
@ -96,7 +97,8 @@ linux_msg(const struct thread *td, const char *fmt, ...)
return;
p = td->td_proc;
printf("linux: pid %d (%s): ", (int)p->p_pid, p->p_comm);
printf("linux: jid %d pid %d (%s): ", p->p_ucred->cr_prison->pr_id,
(int)p->p_pid, p->p_comm);
va_start(ap, fmt);
vprintf(fmt, ap);
va_end(ap);

View File

@ -155,4 +155,33 @@ void linux_free_get_char_devices(char *string);
#define LINUX_CTR6(f, m, p1, p2, p3, p4, p5, p6)
#endif
#endif /* !_LINUX_UTIL_H_ */
/*
* Some macros for rate limiting messages:
* - noisy if compat.linux.debug = 1
* - print only once if compat.linux.debug > 1
*/
#define LINUX_RATELIMIT_MSG_NOTTESTED(_what) \
do { \
static int seen = 0; \
\
if (seen == 0 && linux_debug >= 2) { \
linux_msg(curthread, "%s is not tested, please report on emulation@FreeBSD.org how it works", _what); \
\
if (linux_debug < 3) \
seen = 1; \
} \
} while (0)
#define LINUX_RATELIMIT_MSG_OPT1(_message, _opt1) \
do { \
static int seen = 0; \
\
if (seen == 0) { \
linux_msg(curthread, _message, _opt1); \
\
if (linux_debug < 3) \
seen = 1; \
} \
} while (0)
#endif /* ! _LINUX_UTIL_H_ */