Add support for IPPROTO_IPV6 socket layer for getsockopt/setsockopt calls.

Also add mapping for several options from RFC 3493 and 3542.

Reviewed by:	dchagin
Tested by:	Joe Love <joe at getsomwhere dot net>
MFC after:	2 weeks
This commit is contained in:
Andrey V. Elsukov 2016-03-09 09:12:40 +00:00
parent d424483b4b
commit 86a9058b01
2 changed files with 88 additions and 0 deletions

View File

@ -288,6 +288,63 @@ linux_to_bsd_ip_sockopt(int opt)
return (-1);
}
static int
linux_to_bsd_ip6_sockopt(int opt)
{
switch (opt) {
case LINUX_IPV6_NEXTHOP:
return (IPV6_NEXTHOP);
case LINUX_IPV6_UNICAST_HOPS:
return (IPV6_UNICAST_HOPS);
case LINUX_IPV6_MULTICAST_IF:
return (IPV6_MULTICAST_IF);
case LINUX_IPV6_MULTICAST_HOPS:
return (IPV6_MULTICAST_HOPS);
case LINUX_IPV6_MULTICAST_LOOP:
return (IPV6_MULTICAST_LOOP);
case LINUX_IPV6_ADD_MEMBERSHIP:
return (IPV6_JOIN_GROUP);
case LINUX_IPV6_DROP_MEMBERSHIP:
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_RECVPKTINFO:
return (IPV6_RECVPKTINFO);
case LINUX_IPV6_PKTINFO:
return (IPV6_PKTINFO);
case LINUX_IPV6_RECVHOPLIMIT:
return (IPV6_RECVHOPLIMIT);
case LINUX_IPV6_HOPLIMIT:
return (IPV6_HOPLIMIT);
case LINUX_IPV6_RECVHOPOPTS:
return (IPV6_RECVHOPOPTS);
case LINUX_IPV6_HOPOPTS:
return (IPV6_HOPOPTS);
case LINUX_IPV6_RTHDRDSTOPTS:
return (IPV6_RTHDRDSTOPTS);
case LINUX_IPV6_RECVRTHDR:
return (IPV6_RECVRTHDR);
case LINUX_IPV6_RTHDR:
return (IPV6_RTHDR);
case LINUX_IPV6_RECVDSTOPTS:
return (IPV6_RECVDSTOPTS);
case LINUX_IPV6_DSTOPTS:
return (IPV6_DSTOPTS);
case LINUX_IPV6_RECVPATHMTU:
return (IPV6_RECVPATHMTU);
case LINUX_IPV6_PATHMTU:
return (IPV6_PATHMTU);
#endif
}
return (-1);
}
static int
linux_to_bsd_so_sockopt(int opt)
{
@ -1529,6 +1586,9 @@ linux_setsockopt(struct thread *td, struct linux_setsockopt_args *args)
case IPPROTO_IP:
name = linux_to_bsd_ip_sockopt(args->optname);
break;
case IPPROTO_IPV6:
name = linux_to_bsd_ip6_sockopt(args->optname);
break;
case IPPROTO_TCP:
name = linux_to_bsd_tcp_sockopt(args->optname);
break;
@ -1615,6 +1675,9 @@ linux_getsockopt(struct thread *td, struct linux_getsockopt_args *args)
case IPPROTO_IP:
name = linux_to_bsd_ip_sockopt(args->optname);
break;
case IPPROTO_IPV6:
name = linux_to_bsd_ip6_sockopt(args->optname);
break;
case IPPROTO_TCP:
name = linux_to_bsd_tcp_sockopt(args->optname);
break;

View File

@ -302,6 +302,31 @@ int linux_getsockopt(struct thread *td, struct linux_getsockopt_args *args);
#define LINUX_IP_ADD_MEMBERSHIP 35
#define LINUX_IP_DROP_MEMBERSHIP 36
#define LINUX_IPV6_CHECKSUM 7
#define LINUX_IPV6_NEXTHOP 9
#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_V6ONLY 26
#define LINUX_IPV6_RECVPKTINFO 49
#define LINUX_IPV6_PKTINFO 50
#define LINUX_IPV6_RECVHOPLIMIT 51
#define LINUX_IPV6_HOPLIMIT 52
#define LINUX_IPV6_RECVHOPOPTS 53
#define LINUX_IPV6_HOPOPTS 54
#define LINUX_IPV6_RTHDRDSTOPTS 55
#define LINUX_IPV6_RECVRTHDR 56
#define LINUX_IPV6_RTHDR 57
#define LINUX_IPV6_RECVDSTOPTS 58
#define LINUX_IPV6_DSTOPTS 59
#define LINUX_IPV6_RECVPATHMTU 60
#define LINUX_IPV6_PATHMTU 61
#define LINUX_IPV6_DONTFRAG 62
#define LINUX_TCP_NODELAY 1
#define LINUX_TCP_MAXSEG 2
#define LINUX_TCP_KEEPIDLE 4