@@ -123,39 +123,34 @@ func (n *LinuxNetwork) addSingleEndpoint(ctx context.Context, s *Sandbox, netInf
123123
124124 // Check if interface is a physical interface. Do not create
125125 // tap interface/bridge if it is.
126- isPhysical , err := isPhysicalIface (netInfo .Iface .Name )
127- if err != nil {
128- return nil , err
126+ isPhysical := isPhysicalIface (netInfo .Link )
127+ var err error
128+ idx := len (n .eps )
129+
130+ // Avoid endpoint naming conflicts
131+ // When creating a new endpoint, we check existing endpoint names and automatically adjust the naming of the new endpoint to ensure uniqueness.
132+ lastIdx := - 1
133+ if len (n .eps ) > 0 {
134+ lastEndpoint := n .eps [len (n .eps )- 1 ]
135+ re := regexp .MustCompile ("[0-9]+" )
136+ matchStr := re .FindString (lastEndpoint .Name ())
137+ n , err := strconv .ParseInt (matchStr , 10 , 64 )
138+ if err != nil {
139+ return nil , err
140+ }
141+ lastIdx = int (n )
142+ }
143+ if idx <= lastIdx {
144+ idx = lastIdx + 1
129145 }
130146
131147 if isPhysical {
132- if s .config .HypervisorConfig .ColdPlugVFIO == config .NoPort {
133- // When `cold_plug_vfio` is set to "no-port", the PhysicalEndpoint's VFIO device cannot be attached to the guest VM.
134- // Fail early to prevent the VF interface from being unbound and rebound to the VFIO driver.
135- return nil , fmt .Errorf ("unable to add PhysicalEndpoint %s because cold_plug_vfio is disabled" , netInfo .Iface .Name )
136- }
137148 networkLogger ().WithField ("interface" , netInfo .Iface .Name ).Info ("Physical network interface found" )
138- endpoint , err = createPhysicalEndpoint (netInfo )
149+ isFVIODisabled := (s .config .HypervisorConfig .ColdPlugVFIO == config .NoPort )
150+ endpoint , err = createPhysicalEndpoint (idx , netInfo , isFVIODisabled , n .interworkingModel )
139151 } else {
140152 var socketPath string
141- idx := len (n .eps )
142-
143- // Avoid endpoint naming conflicts
144- // When creating a new endpoint, we check existing endpoint names and automatically adjust the naming of the new endpoint to ensure uniqueness.
145- lastIdx := - 1
146- if len (n .eps ) > 0 {
147- lastEndpoint := n .eps [len (n .eps )- 1 ]
148- re := regexp .MustCompile ("[0-9]+" )
149- matchStr := re .FindString (lastEndpoint .Name ())
150- n , err := strconv .ParseInt (matchStr , 10 , 64 )
151- if err != nil {
152- return nil , err
153- }
154- lastIdx = int (n )
155- }
156- if idx <= lastIdx {
157- idx = lastIdx + 1
158- }
153+
159154 // Check if this is a dummy interface which has a vhost-user socket associated with it
160155 socketPath , err = vhostUserSocketPath (netInfo )
161156 if err != nil {
@@ -654,6 +649,8 @@ func getLinkForEndpoint(endpoint Endpoint, netHandle *netlink.Handle) (netlink.L
654649 var link netlink.Link
655650
656651 switch ep := endpoint .(type ) {
652+ case * PhysicalEndpoint :
653+ link = & netlink.Device {}
657654 case * VethEndpoint :
658655 link = & netlink.Veth {}
659656 case * MacvlanEndpoint :
@@ -676,6 +673,10 @@ func getLinkByName(netHandle *netlink.Handle, name string, expectedLink netlink.
676673 }
677674
678675 switch expectedLink .Type () {
676+ case (& netlink.Device {}).Type ():
677+ if l , ok := link .(* netlink.Device ); ok {
678+ return l , nil
679+ }
679680 case (& netlink.Tuntap {}).Type ():
680681 if l , ok := link .(* netlink.Tuntap ); ok {
681682 return l , nil
0 commit comments