diff --git a/integration/dhcpv4/dhcpv4_test.go b/integration/dhcpv4/dhcpv4_test.go index caaa60b..b4ba3e7 100644 --- a/integration/dhcpv4/dhcpv4_test.go +++ b/integration/dhcpv4/dhcpv4_test.go @@ -114,7 +114,6 @@ func TestDHCPv4(t *testing.T) { } cfg := c.Config() - t.Logf("cfg = %+v", cfg) if got, want := cfg.Router, "192.168.23.1"; got != want { t.Errorf("config: unexpected router: got %q, want %q", got, want) } diff --git a/integration/netconfig/netconfig_test.go b/integration/netconfig/netconfig_test.go index 83baa27..22fe756 100644 --- a/integration/netconfig/netconfig_test.go +++ b/integration/netconfig/netconfig_test.go @@ -136,7 +136,7 @@ func TestNetconfig(t *testing.T) { return } - const ns = "ns1" // name of the network namespace to use for this test + const ns = "ns3" // name of the network namespace to use for this test if err := exec.Command("ip", "netns", "add", ns).Run(); err != nil { t.Fatalf("ip netns add %s: %v", ns, err) diff --git a/integration/radvd/radvd_test.go b/integration/radvd/radvd_test.go index ab98b53..2bce53e 100644 --- a/integration/radvd/radvd_test.go +++ b/integration/radvd/radvd_test.go @@ -7,6 +7,8 @@ import ( "os/exec" "router7/internal/radvd" "testing" + + "github.com/google/go-cmp/cmp" ) func TestRouterAdvertisement(t *testing.T) { @@ -26,6 +28,7 @@ func TestRouterAdvertisement(t *testing.T) { exec.Command("/bin/sh", "-c", "echo 0 > /proc/sys/net/ipv6/conf/veth2a/accept_dad"), exec.Command("ip", "netns", "exec", ns, "/bin/sh", "-c", "echo 0 > /proc/sys/net/ipv6/conf/veth2b/accept_dad"), + exec.Command("ip", "link", "set", "veth2a", "address", "02:73:53:00:ca:fe"), exec.Command("ip", "link", "set", "veth2a", "up"), exec.Command("ip", "netns", "exec", ns, "ip", "addr", "add", "192.168.23.1/24", "dev", "veth2b"), exec.Command("ip", "netns", "exec", ns, "ip", "link", "set", "veth2b", "up"), @@ -74,6 +77,30 @@ func TestRouterAdvertisement(t *testing.T) { if err != nil { t.Fatalf("%v: %v (output: %v)", rdisc6.Args, err, string(b)) } - t.Logf("b = %s", string(b)) + got := string(b) + want := `Soliciting ff02::2 (ff02::2) on veth2b... +Hop limit : 64 ( 0x40) +Stateful address conf. : Yes +Stateful other conf. : No +Mobile home agent : No +Router preference : medium +Neighbor discovery proxy : No +Router lifetime : 1800 (0x00000708) seconds +Reachable time : unspecified (0x00000000) +Retransmit time : unspecified (0x00000000) + Recursive DNS server : 2a02:168:4a00::1 + DNS server lifetime : 1800 (0x00000708) seconds + Prefix : 2a02:168:4a00::/64 + On-link : Yes + Autonomous address conf.: Yes + Valid time : 7200 (0x00001c20) seconds + Pref. time : 1800 (0x00000708) seconds + MTU : 1500 bytes (valid) + Source link-layer address: 02:73:53:00:CA:FE + from fe80::73:53ff:fe00:cafe +` + if diff := cmp.Diff(got, want); diff != "" { + t.Fatalf("unexpected rdisc6 output: diff (-got +want):\n%s", diff) + } } diff --git a/internal/radvd/radvd.go b/internal/radvd/radvd.go index ae89d61..1a682c9 100644 --- a/internal/radvd/radvd.go +++ b/internal/radvd/radvd.go @@ -224,7 +224,7 @@ func (s *Server) sendAdvertisement(addr net.Addr) error { if err != nil { return err } - log.Printf("sending to %s (%#v)", addr, addr) + log.Printf("sending to %s", addr) if _, err := s.pc.WriteTo(mb, nil, addr); err != nil { return err }