func Dial(fn Func) *netlink.Conn {
	sock := &socket{
		fn: fn,
	}
	return netlink.NewConn(sock, PID)
}
Dial sets up a netlink.Conn for testing using the specified Func. All requests
sent from the connection will be passed to the Func.  The connection should be
closed as usual when it is no longer needed.
package nltest
import (
	"fmt"
	"io"
	"os"
	"github.com/mdlayher/netlink"
	"github.com/mdlayher/netlink/nlenc"
)
const PID = 1
func MustMarshalAttributes(attrs []netlink.Attribute) []byte {
	b, err := netlink.MarshalAttributes(attrs)
	if err != nil {
		panic(fmt.Sprintf("failed to marshal attributes to binary: %v", err))
	}
	return b
}
func Multipart(msgs []netlink.Message) ([]netlink.Message, error) {
	if len(msgs) < 2 {
		return msgs, nil
	}
	for i := range msgs {
		if i == len(msgs)-1 {
			msgs[i].Header.Type = netlink.Done
		}
		msgs[i].Header.Flags |= netlink.Multi
	}
	return msgs, nil
}
func Error(number int, reqs []netlink.Message) ([]netlink.Message, error) {
	req := reqs[0]
	req.Header.Length += 4
	req.Header.Type = netlink.Error
	errno := -1 * int32(number)
	req.Data = append(nlenc.Int32Bytes(errno), req.Data...)
	return []netlink.Message{req}, nil
}
type Func func(req []netlink.Message) ([]netlink.Message, error)