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