in cmd/core_plugin/network/nic/nic.go [63:106]
func NewConfigs(desc *metadata.Descriptor, config *cfg.Sections, ignore address.IPAddressMap) ([]*Configuration, error) {
var res []*Configuration
// Iterate over the NICs and create the nicConfig for each NIC. The configured
// addresses will have the wsfcAddresses ignored when constructing the extra
// addresses mappings.
for index, nic := range desc.Instance().NetworkInterfaces() {
if !config.NetworkInterfaces.ManagePrimaryNIC && index == 0 {
galog.Infof("Skipping primary NIC configuration, disabled by configuration.")
continue
}
data, err := newConfig(nic, config, ignore)
if err != nil {
return nil, fmt.Errorf("failed to create NIC config for NIC(%d) %s: %w", index, nic.MAC(), err)
}
data.Index = uint32(index)
res = append(res, data)
}
// Initializes the VLAN interfaces and set them to their parent NIC.
for _, vlanSlice := range desc.Instance().VlanInterfaces() {
for _, vic := range vlanSlice {
parent, err := ethernet.VlanParentInterface(vic.ParentInterface())
if err != nil {
return nil, fmt.Errorf("failed to create VLAN config for VLAN (%d) %s: %w", vic.Vlan(), vic.MAC(), err)
}
if parent < 0 || parent >= len(res) {
return nil, fmt.Errorf("VLAN interface's parent NIC (%d) is out of bounds", parent)
}
parentConfig := res[parent]
data, err := ethernet.NewVlanInterface(vic, parentConfig.Interface)
if err != nil {
return nil, fmt.Errorf("failed to create VLAN config for VLAN (%d) %s: %w", vic.Vlan(), vic.MAC(), err)
}
parentConfig.VlanInterfaces = append(parentConfig.VlanInterfaces, data)
}
}
return res, nil
}