mirror of
https://github.com/containers/podman.git
synced 2025-10-15 02:06:42 +08:00
Set interface name to the network_interface name for macvlan and ipvlan networks
When interface_name attribute in containers.conf file is set to "device", then set interface names inside containers same as the network_interface names of the respective network. The change applies to macvlan and ipvlan networks only. The interface_name attribute value has no impact on any other types of networks. If the interface name is set in the user request, then that takes precedence. Fixes: #21313 Signed-off-by: Vikas Goel <vikas.goel@gmail.com>
This commit is contained in:
@ -264,11 +264,18 @@ func (r *Runtime) setupContainer(ctx context.Context, ctr *Container) (_ *Contai
|
||||
}
|
||||
i := 0
|
||||
for nameOrID, opts := range ctr.config.Networks {
|
||||
netName, err := r.normalizeNetworkName(nameOrID)
|
||||
netName, nicName, err := r.normalizeNetworkName(nameOrID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// assign interface name if empty
|
||||
|
||||
// check whether interface is to be named as the network_interface
|
||||
// when name left unspecified
|
||||
if opts.InterfaceName == "" {
|
||||
opts.InterfaceName = nicName
|
||||
}
|
||||
|
||||
// assign default interface name if empty
|
||||
if opts.InterfaceName == "" {
|
||||
for i < 100000 {
|
||||
ifName := fmt.Sprintf("eth%d", i)
|
||||
|
Reference in New Issue
Block a user