integrationradvd: unflake test
This commit is contained in:
parent
4baac19e13
commit
c37ddf4f6e
@ -30,6 +30,8 @@ func TestRouterAdvertisement(t *testing.T) {
|
||||
exec.Command("ip", "netns", "exec", ns, "ip", "addr", "add", "192.168.23.1/24", "dev", "veth0b"),
|
||||
exec.Command("ip", "netns", "exec", ns, "ip", "link", "set", "veth0b", "up"),
|
||||
exec.Command("ip", "netns", "exec", ns, "ip", "link", "set", "veth0b"),
|
||||
|
||||
exec.Command("/bin/sh", "-c", "echo 1 > /proc/sys/net/ipv6/conf/veth0a/forwarding"),
|
||||
}
|
||||
|
||||
for _, cmd := range nsSetup {
|
||||
@ -52,8 +54,12 @@ func TestRouterAdvertisement(t *testing.T) {
|
||||
srv.SetPrefixes([]net.IPNet{
|
||||
net.IPNet{IP: net.ParseIP("2a02:168:4a00::"), Mask: net.CIDRMask(64, 128)},
|
||||
})
|
||||
conn, err := net.ListenIP("ip6:ipv6-icmp", &net.IPAddr{net.IPv6unspecified, ""})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
go func() {
|
||||
if err := srv.ListenAndServe("veth0a"); err != nil {
|
||||
if err := srv.Serve("veth0a", conn); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}()
|
||||
@ -66,7 +72,7 @@ func TestRouterAdvertisement(t *testing.T) {
|
||||
rdisc6.Stderr = os.Stderr
|
||||
b, err := rdisc6.Output()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
t.Fatalf("%v: %v (output: %v)", rdisc6.Args, err, string(b))
|
||||
}
|
||||
t.Logf("b = %s", string(b))
|
||||
|
||||
|
@ -36,20 +36,13 @@ func (s *Server) SetPrefixes(prefixes []net.IPNet) {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Server) ListenAndServe(ifname string) error {
|
||||
func (s *Server) Serve(ifname string, conn net.PacketConn) error {
|
||||
var err error
|
||||
s.iface, err = net.InterfaceByName(ifname)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// TODO(correctness): would it be better to listen on
|
||||
// net.IPv6linklocalallrouters? Just specifying that results in an error,
|
||||
// though.
|
||||
conn, err := net.ListenIP("ip6:ipv6-icmp", &net.IPAddr{net.IPv6unspecified, ""})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer conn.Close()
|
||||
s.pc = ipv6.NewPacketConn(conn)
|
||||
s.pc.SetHopLimit(255) // as per RFC 4861, section 4.1
|
||||
@ -89,6 +82,17 @@ func (s *Server) ListenAndServe(ifname string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *Server) ListenAndServe(ifname string) error {
|
||||
// TODO(correctness): would it be better to listen on
|
||||
// net.IPv6linklocalallrouters? Just specifying that results in an error,
|
||||
// though.
|
||||
conn, err := net.ListenIP("ip6:ipv6-icmp", &net.IPAddr{net.IPv6unspecified, ""})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return s.Serve(ifname, conn)
|
||||
}
|
||||
|
||||
type sourceLinkLayerAddress struct {
|
||||
address net.HardwareAddr
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user