From 6b2cd37bd965bb51f2fd098c164f2441ad4f525c Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Fri, 26 Feb 2016 17:36:00 +0000 Subject: [PATCH] re PR go/69966 (libgo: Port syscall.SetsockoptUcred from golang) PR go/69966 syscall: Add new Getsockopt functions. Add GetsockoptICMPv6Filter, GetsockoptIPv6MTUInfo, GetsockoptUcred as appropriate. These functions exist in the master library. For GCC PR 69966. Reviewed-on: https://go-review.googlesource.com/19960 From-SVN: r233747 --- gcc/go/gofrontend/MERGE | 2 +- libgo/go/syscall/socket.go | 7 +++++++ libgo/go/syscall/socket_bsd.go | 7 +++++++ libgo/go/syscall/socket_linux.go | 14 ++++++++++++++ libgo/mksysinfo.sh | 10 +++++++++- 5 files changed, 38 insertions(+), 2 deletions(-) diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE index 9bebd30c431..07ae4d0f00c 100644 --- a/gcc/go/gofrontend/MERGE +++ b/gcc/go/gofrontend/MERGE @@ -1,4 +1,4 @@ -156f5f0152797ac2afe5f23803aeb3c7b8f8418e +3de822d11255d439fac9717897b017aae2de18c2 The first line of this file holds the git revision number of the last merge done from the gofrontend repository. diff --git a/libgo/go/syscall/socket.go b/libgo/go/syscall/socket.go index d96a717303b..93bbc389f4d 100644 --- a/libgo/go/syscall/socket.go +++ b/libgo/go/syscall/socket.go @@ -251,6 +251,13 @@ func GetsockoptIPv6Mreq(fd, level, opt int) (*IPv6Mreq, error) { return &value, err } +func GetsockoptICMPv6Filter(fd, level, opt int) (*ICMPv6Filter, error) { + var value ICMPv6Filter + vallen := Socklen_t(SizeofICMPv6Filter) + err := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen) + return &value, err +} + //sys setsockopt(s int, level int, name int, val unsafe.Pointer, vallen Socklen_t) (err error) //setsockopt(s _C_int, level _C_int, optname _C_int, val *byte, vallen Socklen_t) _C_int diff --git a/libgo/go/syscall/socket_bsd.go b/libgo/go/syscall/socket_bsd.go index 72d7180b6ed..c8da1022218 100644 --- a/libgo/go/syscall/socket_bsd.go +++ b/libgo/go/syscall/socket_bsd.go @@ -80,3 +80,10 @@ func BindToDevice(fd int, device string) (err error) { func anyToSockaddrOS(rsa *RawSockaddrAny) (Sockaddr, error) { return nil, EAFNOSUPPORT } + +func GetsockoptIPv6MTUInfo(fd, level, opt int) (*IPv6MTUInfo, error) { + var value IPv6MTUInfo + vallen := Socklen_t(SizeofIPv6MTUInfo) + err := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen) + return &value, err +} diff --git a/libgo/go/syscall/socket_linux.go b/libgo/go/syscall/socket_linux.go index 5064e771221..3c3098e0564 100644 --- a/libgo/go/syscall/socket_linux.go +++ b/libgo/go/syscall/socket_linux.go @@ -168,6 +168,20 @@ func anyToSockaddrOS(rsa *RawSockaddrAny) (Sockaddr, error) { return nil, EAFNOSUPPORT } +func GetsockoptIPv6MTUInfo(fd, level, opt int) (*IPv6MTUInfo, error) { + var value IPv6MTUInfo + vallen := Socklen_t(SizeofIPv6MTUInfo) + err := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen) + return &value, err +} + +func GetsockoptUcred(fd, level, opt int) (*Ucred, error) { + var value Ucred + vallen := Socklen_t(SizeofUcred) + err := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen) + return &value, err +} + //sysnb EpollCreate(size int) (fd int, err error) //epoll_create(size _C_int) _C_int diff --git a/libgo/mksysinfo.sh b/libgo/mksysinfo.sh index 9062c2c9236..1271e1a550f 100755 --- a/libgo/mksysinfo.sh +++ b/libgo/mksysinfo.sh @@ -870,6 +870,14 @@ if ! grep 'type ICMPv6Filter ' ${OUT} > /dev/null 2>&1; then echo 'type ICMPv6Filter struct { Data [8]uint32 }' >> ${OUT} fi +# The ip6_mtuinfo struct. +grep '^type _ip6_mtuinfo ' gen-sysinfo.go | \ + sed -e 's/_ip6_mtuinfo/IPv6MTUInfo/' \ + -e 's/ip6m_addr/Addr/' \ + -e 's/_sockaddr_in6/RawSockaddrInet6/' \ + -e 's/ip6m_mtu/Mtu/' \ + >> ${OUT} + # Try to guess the type to use for fd_set. fd_set=`grep '^type _fd_set ' gen-sysinfo.go || true` fds_bits_type="_C_long" @@ -1464,7 +1472,7 @@ set cmsghdr Cmsghdr ip_mreq IPMreq ip_mreqn IPMreqn ipv6_mreq IPv6Mreq \ msghdr Msghdr nlattr NlAttr nlmsgerr NlMsgerr nlmsghdr NlMsghdr \ rtattr RtAttr rtgenmsg RtGenmsg rtmsg RtMsg rtnexthop RtNexthop \ sock_filter SockFilter sock_fprog SockFprog ucred Ucred \ - icmp6_filter ICMPv6Filter + icmp6_filter ICMPv6Filter ip6_mtuinfo IPv6MTUInfo while test $# != 0; do nc=$1 ngo=$2