TestNoLinkLocalAutoGenForLoopbackNIC tests that IPv6 link-local addresses are not auto-generated for loopback NICs.
(t *testing.T)
| 2905 | // TestNoLinkLocalAutoGenForLoopbackNIC tests that IPv6 link-local addresses are |
| 2906 | // not auto-generated for loopback NICs. |
| 2907 | func TestNoLinkLocalAutoGenForLoopbackNIC(t *testing.T) { |
| 2908 | const nicID = 1 |
| 2909 | const nicName = "nicName" |
| 2910 | |
| 2911 | tests := []struct { |
| 2912 | name string |
| 2913 | opaqueIIDOpts ipv6.OpaqueInterfaceIdentifierOptions |
| 2914 | }{ |
| 2915 | { |
| 2916 | name: "IID From MAC", |
| 2917 | opaqueIIDOpts: ipv6.OpaqueInterfaceIdentifierOptions{}, |
| 2918 | }, |
| 2919 | { |
| 2920 | name: "Opaque IID", |
| 2921 | opaqueIIDOpts: ipv6.OpaqueInterfaceIdentifierOptions{ |
| 2922 | NICNameFromID: func(_ tcpip.NICID, nicName string) string { |
| 2923 | return nicName |
| 2924 | }, |
| 2925 | }, |
| 2926 | }, |
| 2927 | } |
| 2928 | |
| 2929 | for _, test := range tests { |
| 2930 | t.Run(test.name, func(t *testing.T) { |
| 2931 | opts := stack.Options{ |
| 2932 | NetworkProtocols: []stack.NetworkProtocolFactory{ipv6.NewProtocolWithOptions(ipv6.Options{ |
| 2933 | AutoGenLinkLocal: true, |
| 2934 | OpaqueIIDOpts: test.opaqueIIDOpts, |
| 2935 | })}, |
| 2936 | } |
| 2937 | |
| 2938 | e := loopback.New() |
| 2939 | s := stack.New(opts) |
| 2940 | nicOpts := stack.NICOptions{Name: nicName} |
| 2941 | if err := s.CreateNICWithOptions(nicID, e, nicOpts); err != nil { |
| 2942 | t.Fatalf("CreateNICWithOptions(%d, _, %+v) = %s", nicID, nicOpts, err) |
| 2943 | } |
| 2944 | |
| 2945 | if err := checkGetMainNICAddress(s, 1, header.IPv6ProtocolNumber, tcpip.AddressWithPrefix{}); err != nil { |
| 2946 | t.Fatal(err) |
| 2947 | } |
| 2948 | }) |
| 2949 | } |
| 2950 | } |
| 2951 | |
| 2952 | // TestNICAutoGenAddrDoesDAD tests that the successful auto-generation of IPv6 |
| 2953 | // link-local addresses will only be assigned after the DAD process resolves. |
nothing calls this directly
no test coverage detected
searching dependent graphs…