@@ -99,9 +99,8 @@ func contains(addrs []netlink.Addr, addr *net.IPNet) bool {
9999}
100100
101101const (
102- VethName = "ethwe" // name inside container namespace
103- //vethPrefix = "v" + VethName // starts with "veth" to suppress UI notifications
104- vethPrefix = "v"
102+ VethName = "ethwe" // name inside container namespace
103+ vethPrefix = "v" + VethName // starts with "veth" to suppress UI notifications
105104)
106105
107106func interfaceExistsInNamespace (netNSPath string , ifName string ) bool {
@@ -120,13 +119,11 @@ func AttachContainer(netNSPath, id, ifName, bridgeName string, mtu int, withMult
120119 defer ns .Close ()
121120
122121 if ! interfaceExistsInNamespace (netNSPath , ifName ) {
123- //maxIDLen := IFNAMSIZ - 1 - len(vethPrefix+"pl")
124- maxIDLen := IFNAMSIZ - 1 - len (vethPrefix + "l" )
122+ maxIDLen := IFNAMSIZ - 1 - len (vethPrefix + "pl" )
125123 if len (id ) > maxIDLen {
126124 id = id [:maxIDLen ] // trim passed ID if too long
127125 }
128- //name, peerName := vethPrefix+"pl"+id, vethPrefix+"pg"+id
129- name , peerName := vethPrefix + "l" + id , vethPrefix + "g" + id
126+ name , peerName := vethPrefix + "pl" + id , vethPrefix + "pg" + id
130127 veth , err := CreateAndAttachVeth (name , peerName , bridgeName , mtu , keepTXOn , true , func (veth netlink.Link ) error {
131128 if err := netlink .LinkSetNsFd (veth , int (ns )); err != nil {
132129 return fmt .Errorf ("failed to move veth to container netns: %s" , err )
0 commit comments