@@ -469,7 +469,6 @@ func TestDefaultBridgeAddresses(t *testing.T) {
469469 skip .If (t , testEnv .DaemonInfo .OSType == "windows" )
470470
471471 ctx := setupTest (t )
472- d := daemon .New (t )
473472
474473 type testStep struct {
475474 stepName string
@@ -487,21 +486,21 @@ func TestDefaultBridgeAddresses(t *testing.T) {
487486 {
488487 stepName : "Set up initial UL prefix" ,
489488 fixedCIDRV6 : "fd1c:f1a0:5d8d:aaaa::/64" ,
490- expAddrs : []string {"fd1c:f1a0:5d8d:aaaa::1/64" , "fe80::1/64 " },
489+ expAddrs : []string {"fd1c:f1a0:5d8d:aaaa::1/64" , "fe80::" },
491490 },
492491 {
493492 // Modify that prefix, the default bridge's address must be deleted and re-added.
494493 stepName : "Modify UL prefix - address change" ,
495494 fixedCIDRV6 : "fd1c:f1a0:5d8d:bbbb::/64" ,
496- expAddrs : []string {"fd1c:f1a0:5d8d:bbbb::1/64" , "fe80::1/64 " },
495+ expAddrs : []string {"fd1c:f1a0:5d8d:bbbb::1/64" , "fe80::" },
497496 },
498497 {
499498 // Modify the prefix length, the default bridge's address should not change.
500499 stepName : "Modify UL prefix - no address change" ,
501500 fixedCIDRV6 : "fd1c:f1a0:5d8d:bbbb::/80" ,
502501 // The prefix length displayed by 'ip a' is not updated - it's informational, and
503502 // can't be changed without unnecessarily deleting and re-adding the address.
504- expAddrs : []string {"fd1c:f1a0:5d8d:bbbb::1/64" , "fe80::1/64 " },
503+ expAddrs : []string {"fd1c:f1a0:5d8d:bbbb::1/64" , "fe80::" },
505504 },
506505 },
507506 },
@@ -511,47 +510,63 @@ func TestDefaultBridgeAddresses(t *testing.T) {
511510 {
512511 stepName : "Standard LL subnet prefix" ,
513512 fixedCIDRV6 : "fe80::/64" ,
514- expAddrs : []string {"fe80::1/64 " },
513+ expAddrs : []string {"fe80::" },
515514 },
516515 {
517516 // Modify that prefix, the default bridge's address must be deleted and re-added.
518517 // The bridge must still have an address in the required (standard) LL subnet.
519518 stepName : "Nonstandard LL prefix - address change" ,
520519 fixedCIDRV6 : "fe80:1234::/32" ,
521- expAddrs : []string {"fe80:1234::1/32" , "fe80::1/64 " },
520+ expAddrs : []string {"fe80:1234::1/32" , "fe80::" },
522521 },
523522 {
524523 // Modify the prefix length, the addresses should not change.
525524 stepName : "Modify LL prefix - no address change" ,
526525 fixedCIDRV6 : "fe80:1234::/64" ,
527526 // The prefix length displayed by 'ip a' is not updated - it's informational, and
528527 // can't be changed without unnecessarily deleting and re-adding the address.
529- expAddrs : []string {"fe80:1234::1/" , "fe80::1/64 " },
528+ expAddrs : []string {"fe80:1234::1/" , "fe80::" },
530529 },
531530 },
532531 },
533532 }
534533
535- for _ , tc := range testcases {
536- t .Run (tc .name , func (t * testing.T ) {
534+ for _ , preserveKernelLL := range []bool {false , true } {
535+ var dopts []daemon.Option
536+ if preserveKernelLL {
537+ dopts = append (dopts , daemon .WithEnvVars ("DOCKER_BRIDGE_PRESERVE_KERNEL_LL=1" ))
538+ }
539+ d := daemon .New (t , dopts ... )
540+ c := d .NewClientT (t )
541+
542+ for _ , tc := range testcases {
537543 for _ , step := range tc .steps {
538- // Check that the daemon starts - regression test for:
539- // https://github.com/moby/moby/issues/46829
540- d .Start (t , "--experimental" , "--ipv6" , "--ip6tables" , "--fixed-cidr-v6=" + step .fixedCIDRV6 )
541- d .Stop (t )
542-
543- // Check that the expected addresses have been applied to the bridge. (Skip in
544- // rootless mode, because the bridge is in a different network namespace.)
545- if ! testEnv .IsRootless () {
546- res := testutil .RunCommand (ctx , "ip" , "-6" , "addr" , "show" , "docker0" )
547- assert .Equal (t , res .ExitCode , 0 , step .stepName )
548- stdout := res .Stdout ()
549- for _ , expAddr := range step .expAddrs {
550- assert .Check (t , is .Contains (stdout , expAddr ))
544+ tcName := fmt .Sprintf ("kernel_ll_%v/%s/%s" , preserveKernelLL , tc .name , step .stepName )
545+ t .Run (tcName , func (t * testing.T ) {
546+ ctx := testutil .StartSpan (ctx , t )
547+ // Check that the daemon starts - regression test for:
548+ // https://github.com/moby/moby/issues/46829
549+ d .StartWithBusybox (ctx , t , "--experimental" , "--ipv6" , "--ip6tables" , "--fixed-cidr-v6=" + step .fixedCIDRV6 )
550+
551+ // Start a container, so that the bridge is set "up" and gets a kernel_ll address.
552+ cID := container .Run (ctx , t , c )
553+ defer c .ContainerRemove (ctx , cID , containertypes.RemoveOptions {Force : true })
554+
555+ d .Stop (t )
556+
557+ // Check that the expected addresses have been applied to the bridge. (Skip in
558+ // rootless mode, because the bridge is in a different network namespace.)
559+ if ! testEnv .IsRootless () {
560+ res := testutil .RunCommand (ctx , "ip" , "-6" , "addr" , "show" , "docker0" )
561+ assert .Equal (t , res .ExitCode , 0 , step .stepName )
562+ stdout := res .Stdout ()
563+ for _ , expAddr := range step .expAddrs {
564+ assert .Check (t , is .Contains (stdout , expAddr ))
565+ }
551566 }
552- }
567+ })
553568 }
554- })
569+ }
555570 }
556571}
557572
0 commit comments