@@ -5,12 +5,9 @@ package integration
55import (
66 "encoding/json"
77 "fmt"
8- "io"
98 "net"
109 "os"
11- "strconv"
1210 "strings"
13- "sync"
1411 "syscall"
1512
1613 "github.com/containernetworking/plugins/pkg/ns"
@@ -560,112 +557,6 @@ EXPOSE 2004-2005/tcp`, ALPINE)
560557 Expect (inspectOut [0 ].NetworkSettings .Ports ["80/tcp" ][0 ]).To (HaveField ("HostIP" , "0.0.0.0" ))
561558 })
562559
563- It ("podman run slirp4netns verify net.ipv6.conf.default.accept_dad=0" , func () {
564- session := podmanTest .Podman ([]string {"run" , "--network" , "slirp4netns:enable_ipv6=true" , ALPINE , "ip" , "addr" })
565- session .WaitWithDefaultTimeout ()
566- Expect (session ).Should (ExitCleanly ())
567- // check the ipv6 setup id done without delay (https://github.com/containers/podman/issues/11062)
568- Expect (session .OutputToString ()).To (ContainSubstring ("inet6 fd00::" ))
569-
570- const ipv6ConfDefaultAcceptDadSysctl = "/proc/sys/net/ipv6/conf/all/accept_dad"
571-
572- cat := SystemExec ("cat" , []string {ipv6ConfDefaultAcceptDadSysctl })
573- cat .WaitWithDefaultTimeout ()
574- Expect (cat ).Should (ExitCleanly ())
575- sysctlValue := cat .OutputToString ()
576-
577- session = podmanTest .Podman ([]string {"run" , "--network" , "slirp4netns:enable_ipv6=true" , ALPINE , "cat" , ipv6ConfDefaultAcceptDadSysctl })
578- session .WaitWithDefaultTimeout ()
579- Expect (session ).Should (ExitCleanly ())
580- Expect (session .OutputToString ()).To (Equal (sysctlValue ))
581- })
582-
583- It ("podman run network expose host port 8080 to container port 8000 using invalid port handler" , func () {
584- session := podmanTest .Podman ([]string {"run" , "--network" , "slirp4netns:port_handler=invalid" , "-dt" , "-p" , "8080:8000" , ALPINE , "/bin/sh" })
585- session .WaitWithDefaultTimeout ()
586- Expect (session ).To (ExitWithError (126 , `unknown port_handler for slirp4netns: "invalid"` ))
587- })
588-
589- It ("podman run slirp4netns network with host loopback" , func () {
590- session := podmanTest .Podman ([]string {"run" , "--cap-add" , "net_raw" , "--network" , "slirp4netns:allow_host_loopback=true" , ALPINE , "ping" , "-c1" , "10.0.2.2" })
591- session .WaitWithDefaultTimeout ()
592- Expect (session ).Should (ExitCleanly ())
593- })
594-
595- It ("podman run slirp4netns network with mtu" , func () {
596- session := podmanTest .Podman ([]string {"run" , "--network" , "slirp4netns:mtu=9000" , ALPINE , "ip" , "addr" })
597- session .Wait (30 )
598- Expect (session ).Should (ExitCleanly ())
599- Expect (session .OutputToString ()).To (ContainSubstring ("mtu 9000" ))
600- })
601-
602- It ("podman run slirp4netns network with different cidr" , func () {
603- slirp4netnsHelp := SystemExec ("slirp4netns" , []string {"--help" })
604- Expect (slirp4netnsHelp ).Should (ExitCleanly ())
605-
606- networkConfiguration := "slirp4netns:cidr=192.168.0.0/24,allow_host_loopback=true"
607- session := podmanTest .Podman ([]string {"run" , "--cap-add" , "net_raw" , "--network" , networkConfiguration , ALPINE , "ping" , "-c1" , "192.168.0.2" })
608- session .Wait (30 )
609-
610- if strings .Contains (slirp4netnsHelp .OutputToString (), "cidr" ) {
611- Expect (session ).Should (ExitCleanly ())
612- } else {
613- Expect (session ).To (ExitWithError (125 , "cidr not supported" ))
614- }
615- })
616-
617- for _ , local := range []bool {true , false } {
618- testName := "HostIP"
619- if local {
620- testName = "127.0.0.1"
621- }
622- It (fmt .Sprintf ("podman run network slirp4netns bind to %s" , testName ), func () {
623- ip := "127.0.0.1"
624- if ! local {
625- // Determine our likeliest outgoing IP address
626- conn , err := net .Dial ("udp" , "8.8.8.8:80" )
627- Expect (err ).ToNot (HaveOccurred ())
628-
629- defer conn .Close ()
630- ip = conn .LocalAddr ().(* net.UDPAddr ).IP .String ()
631- }
632- port := strconv .Itoa (GetPort ())
633-
634- networkConfiguration := fmt .Sprintf ("slirp4netns:outbound_addr=%s,allow_host_loopback=true" , ip )
635-
636- listener , err := net .Listen ("tcp" , ":" + port )
637- Expect (err ).ToNot (HaveOccurred ())
638- defer listener .Close ()
639-
640- msg := RandomString (10 )
641- wg := & sync.WaitGroup {}
642- wg .Add (1 )
643- // now use a new goroutine to start accepting connection in the background and make the checks there
644- go func () {
645- defer GinkgoRecover ()
646- defer wg .Done ()
647- conn , err := listener .Accept ()
648- Expect (err ).ToNot (HaveOccurred (), "accept new connection" )
649- defer conn .Close ()
650- addr := conn .RemoteAddr ()
651- // addr will be in the form ip:port, we don't care about the port as it is random
652- Expect (addr .String ()).To (HavePrefix (ip + ":" ), "remote address" )
653- gotBytes , err := io .ReadAll (conn )
654- Expect (err ).ToNot (HaveOccurred (), "read from connection" )
655- Expect (string (gotBytes )).To (Equal (msg ), "received correct message from container" )
656- }()
657-
658- session := podmanTest .Podman ([]string {"run" , "--network" , networkConfiguration , ALPINE , "sh" , "-c" , "echo -n " + msg + " | nc -w 30 10.0.2.2 " + port })
659- session .WaitWithDefaultTimeout ()
660- Expect (session ).Should (ExitCleanly ())
661-
662- // explicitly close the socket here before we wait to unlock Accept() calls in case of hangs
663- listener .Close ()
664- // wait for the checks in the goroutine to be done
665- wg .Wait ()
666- })
667- }
668-
669560 It ("podman run network expose ports in image metadata" , func () {
670561 session := podmanTest .Podman ([]string {"create" , "--name" , "test" , "-t" , "-P" , NGINX_IMAGE })
671562 session .WaitWithDefaultTimeout ()
0 commit comments