Commit eb818ae5 authored by Mikio Hara's avatar Mikio Hara

ipv4: enable {Read,Write}Batch methods of {Packet,Raw}Conn on NetBSD

Change-Id: I21ec68eef6cf14e0ff30b437d717d46e1dc9fea5
Reviewed-on: https://go-review.googlesource.com/82456
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
parent 5c0ad186
...@@ -66,7 +66,7 @@ type Message = socket.Message ...@@ -66,7 +66,7 @@ type Message = socket.Message
// On a successful read it returns the number of messages received, up // On a successful read it returns the number of messages received, up
// to len(ms). // to len(ms).
// //
// On Linux, a batch read will be optimized. // On Linux and NetBSD, a batch read will be optimized.
// On other platforms, this method will read only a single message. // On other platforms, this method will read only a single message.
// //
// Unlike the ReadFrom method, it doesn't strip the IPv4 header // Unlike the ReadFrom method, it doesn't strip the IPv4 header
...@@ -79,7 +79,7 @@ func (c *payloadHandler) ReadBatch(ms []Message, flags int) (int, error) { ...@@ -79,7 +79,7 @@ func (c *payloadHandler) ReadBatch(ms []Message, flags int) (int, error) {
return 0, syscall.EINVAL return 0, syscall.EINVAL
} }
switch runtime.GOOS { switch runtime.GOOS {
case "linux": case "linux", "netbsd":
n, err := c.RecvMsgs([]socket.Message(ms), flags) n, err := c.RecvMsgs([]socket.Message(ms), flags)
if err != nil { if err != nil {
err = &net.OpError{Op: "read", Net: c.PacketConn.LocalAddr().Network(), Source: c.PacketConn.LocalAddr(), Err: err} err = &net.OpError{Op: "read", Net: c.PacketConn.LocalAddr().Network(), Source: c.PacketConn.LocalAddr(), Err: err}
...@@ -103,14 +103,14 @@ func (c *payloadHandler) ReadBatch(ms []Message, flags int) (int, error) { ...@@ -103,14 +103,14 @@ func (c *payloadHandler) ReadBatch(ms []Message, flags int) (int, error) {
// //
// It returns the number of messages written on a successful write. // It returns the number of messages written on a successful write.
// //
// On Linux, a batch write will be optimized. // On Linux and NetBSD, a batch write will be optimized.
// On other platforms, this method will write only a single message. // On other platforms, this method will write only a single message.
func (c *payloadHandler) WriteBatch(ms []Message, flags int) (int, error) { func (c *payloadHandler) WriteBatch(ms []Message, flags int) (int, error) {
if !c.ok() { if !c.ok() {
return 0, syscall.EINVAL return 0, syscall.EINVAL
} }
switch runtime.GOOS { switch runtime.GOOS {
case "linux": case "linux", "netbsd":
n, err := c.SendMsgs([]socket.Message(ms), flags) n, err := c.SendMsgs([]socket.Message(ms), flags)
if err != nil { if err != nil {
err = &net.OpError{Op: "write", Net: c.PacketConn.LocalAddr().Network(), Source: c.PacketConn.LocalAddr(), Err: err} err = &net.OpError{Op: "write", Net: c.PacketConn.LocalAddr().Network(), Source: c.PacketConn.LocalAddr(), Err: err}
...@@ -135,14 +135,14 @@ func (c *payloadHandler) WriteBatch(ms []Message, flags int) (int, error) { ...@@ -135,14 +135,14 @@ func (c *payloadHandler) WriteBatch(ms []Message, flags int) (int, error) {
// On a successful read it returns the number of messages received, up // On a successful read it returns the number of messages received, up
// to len(ms). // to len(ms).
// //
// On Linux, a batch read will be optimized. // On Linux and NetBSD, a batch read will be optimized.
// On other platforms, this method will read only a single message. // On other platforms, this method will read only a single message.
func (c *packetHandler) ReadBatch(ms []Message, flags int) (int, error) { func (c *packetHandler) ReadBatch(ms []Message, flags int) (int, error) {
if !c.ok() { if !c.ok() {
return 0, syscall.EINVAL return 0, syscall.EINVAL
} }
switch runtime.GOOS { switch runtime.GOOS {
case "linux": case "linux", "netbsd":
n, err := c.RecvMsgs([]socket.Message(ms), flags) n, err := c.RecvMsgs([]socket.Message(ms), flags)
if err != nil { if err != nil {
err = &net.OpError{Op: "read", Net: c.IPConn.LocalAddr().Network(), Source: c.IPConn.LocalAddr(), Err: err} err = &net.OpError{Op: "read", Net: c.IPConn.LocalAddr().Network(), Source: c.IPConn.LocalAddr(), Err: err}
...@@ -166,14 +166,14 @@ func (c *packetHandler) ReadBatch(ms []Message, flags int) (int, error) { ...@@ -166,14 +166,14 @@ func (c *packetHandler) ReadBatch(ms []Message, flags int) (int, error) {
// //
// It returns the number of messages written on a successful write. // It returns the number of messages written on a successful write.
// //
// On Linux, a batch write will be optimized. // On Linux and NetBSD, a batch write will be optimized.
// On other platforms, this method will write only a single message. // On other platforms, this method will write only a single message.
func (c *packetHandler) WriteBatch(ms []Message, flags int) (int, error) { func (c *packetHandler) WriteBatch(ms []Message, flags int) (int, error) {
if !c.ok() { if !c.ok() {
return 0, syscall.EINVAL return 0, syscall.EINVAL
} }
switch runtime.GOOS { switch runtime.GOOS {
case "linux": case "linux", "netbsd":
n, err := c.SendMsgs([]socket.Message(ms), flags) n, err := c.SendMsgs([]socket.Message(ms), flags)
if err != nil { if err != nil {
err = &net.OpError{Op: "write", Net: c.IPConn.LocalAddr().Network(), Source: c.IPConn.LocalAddr(), Err: err} err = &net.OpError{Op: "write", Net: c.IPConn.LocalAddr().Network(), Source: c.IPConn.LocalAddr(), Err: err}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment