Fix stuff
This commit is contained in:
		
							
								
								
									
										2
									
								
								go.mod
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								go.mod
									
									
									
									
									
								
							| @@ -7,3 +7,5 @@ require ( | ||||
| 	github.com/vishvananda/netlink v1.1.0 | ||||
| 	github.com/vishvananda/netns v0.0.4 | ||||
| ) | ||||
|  | ||||
| require golang.org/x/sys v0.2.0 // indirect | ||||
|   | ||||
							
								
								
									
										15
									
								
								main.go
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								main.go
									
									
									
									
									
								
							| @@ -4,8 +4,6 @@ import ( | ||||
| 	"encoding/json" | ||||
| 	"fmt" | ||||
| 	"net" | ||||
| 	"os" | ||||
| 	"path/filepath" | ||||
|  | ||||
| 	"github.com/containernetworking/cni/pkg/skel" | ||||
| 	"github.com/containernetworking/cni/pkg/types" | ||||
| @@ -185,7 +183,17 @@ func createVethPair(hostName, containerName string) (netlink.Link, netlink.Link, | ||||
| } | ||||
|  | ||||
| func configureContainerInterface(containerNS netns.NsHandle, ifName string, containerIP net.IP, hostVethName string) error { | ||||
| 	return netns.Set(containerNS, func(ns netns.NsHandle) error { | ||||
| 	// Switch to container namespace | ||||
| 	originalNS, err := netns.Get() | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	defer originalNS.Close() | ||||
| 	defer netns.Set(originalNS) | ||||
|  | ||||
| 	if err := netns.Set(containerNS); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 		// Get the interface | ||||
| 		link, err := netlink.LinkByName(ifName) | ||||
| 		if err != nil { | ||||
| @@ -232,7 +240,6 @@ func configureContainerInterface(containerNS netns.NsHandle, ifName string, cont | ||||
| 		} | ||||
|  | ||||
| 		return nil | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| func configureHostInterface(hostVeth netlink.Link, containerIP net.IP) error { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user