Skip to content

Commit

Permalink
Additional renames from ul to adapter
Browse files Browse the repository at this point in the history
Signed-off-by: eriknordmark <[email protected]>
  • Loading branch information
eriknordmark committed Oct 24, 2023
1 parent f2ccce8 commit b1e433f
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 24 deletions.
5 changes: 2 additions & 3 deletions pkg/pillar/cmd/zedmanager/handledomainmgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,8 @@ func MaybeAddDomainConfig(ctx *zedmanagerContext,
anaCount := len(ns.AppNetAdapterList)

dc.VifList = make([]types.VifConfig, anaCount)
// Put UL before OL
for i, ul := range ns.AppNetAdapterList {
dc.VifList[i] = ul.VifInfo.VifConfig
for i, adapter := range ns.AppNetAdapterList {
dc.VifList[i] = adapter.VifInfo.VifConfig
}
}
log.Functionf("MaybeAddDomainConfig done for %s", key)
Expand Down
8 changes: 4 additions & 4 deletions pkg/pillar/cmd/zedrouter/appnetwork.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ func (z *zedrouter) updateVIFsForStateCollecting(
// Determine the set of affected network instances.
var networks []uuid.UUID
if prevAppConf != nil {
for _, ul := range prevAppConf.AppNetAdapterList {
networks = append(networks, ul.Network)
for _, adapter := range prevAppConf.AppNetAdapterList {
networks = append(networks, adapter.Network)
}
}
if newAppConfig != nil {
for _, ul := range newAppConfig.AppNetAdapterList {
networks = append(networks, ul.Network)
for _, adapter := range newAppConfig.AppNetAdapterList {
networks = append(networks, adapter.Network)
}
}
networks = generics.FilterDuplicates(networks)
Expand Down
24 changes: 12 additions & 12 deletions pkg/pillar/cmd/zedrouter/ipam.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,36 +167,36 @@ func (z *zedrouter) reloadStatusOfAssignedIPs(status *types.AppNetworkStatus) {
adapterStatus := &status.AppNetAdapterList[i]
allAddrs, _ := z.niStateCollector.GetIPAssignments(adapterStatus.Network)
vifAddrs := allAddrs.LookupByAdapterName(status.UUIDandVersion.UUID, adapterStatus.Name)
z.recordAssignedIPsToULStatus(adapterStatus, vifAddrs)
z.recordAssignedIPsToAdapterStatus(adapterStatus, vifAddrs)
}
}

func (z *zedrouter) recordAssignedIPsToULStatus(ul *types.AppNetAdapterStatus,
func (z *zedrouter) recordAssignedIPsToAdapterStatus(adapter *types.AppNetAdapterStatus,
vifAddrs *nistate.VIFAddrs) {
if vifAddrs == nil {
z.removeAssignedIPsFromULStatus(ul)
z.removeAssignedIPsFromAdapterStatus(adapter)
return
}
ul.AllocatedIPv4Addr = vifAddrs.IPv4Addr
if !isEmptyIP(ul.AppIPAddr) &&
!ul.AppIPAddr.Equal(ul.AllocatedIPv4Addr) {
adapter.AllocatedIPv4Addr = vifAddrs.IPv4Addr
if !isEmptyIP(adapter.AppIPAddr) &&
!adapter.AppIPAddr.Equal(adapter.AllocatedIPv4Addr) {
// Config and status do not match.
ul.IPAddrMisMatch = true
adapter.IPAddrMisMatch = true
} else {
ul.IPAddrMisMatch = false
adapter.IPAddrMisMatch = false
}
ul.AllocatedIPv6List = vifAddrs.IPv6Addrs
ul.IPv4Assigned = !isEmptyIP(vifAddrs.IPv4Addr)
adapter.AllocatedIPv6List = vifAddrs.IPv6Addrs
adapter.IPv4Assigned = !isEmptyIP(vifAddrs.IPv4Addr)
}

func (z *zedrouter) removeAssignedIPsFromAppNetStatus(status *types.AppNetworkStatus) {
for i := range status.AppNetAdapterList {
adapterStatus := &status.AppNetAdapterList[i]
z.removeAssignedIPsFromULStatus(adapterStatus)
z.removeAssignedIPsFromAdapterStatus(adapterStatus)
}
}

func (z *zedrouter) removeAssignedIPsFromULStatus(adapterStatus *types.AppNetAdapterStatus) {
func (z *zedrouter) removeAssignedIPsFromAdapterStatus(adapterStatus *types.AppNetAdapterStatus) {
adapterStatus.AllocatedIPv6List = nil
adapterStatus.AllocatedIPv4Addr = nil
adapterStatus.IPAddrMisMatch = false
Expand Down
8 changes: 4 additions & 4 deletions pkg/pillar/cmd/zedrouter/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,13 +248,13 @@ func (z *zedrouter) checkForPortMapOverlap(adapterCfgList1 []types.AppNetAdapter
for _, adapterCfg1 := range adapterCfgList1 {
network1 := adapterCfg1.Network
// Validate whether there are duplicate portmap rules within itself.
if z.detectPortMapConflictWithinUL(adapterCfg1.ACLs) {
if z.detectPortMapConflictWithinAdapter(adapterCfg1.ACLs) {
return true
}
for _, adapterCfg2 := range adapterCfgList2 {
network2 := adapterCfg2.Network
if network1 == network2 || z.checkUplinkPortOverlap(network1, network2) {
if z.detectPortMapConflictAcrossULs(adapterCfg1.ACLs, adapterCfg2.ACLs) {
if z.detectPortMapConflictAcrossAdapters(adapterCfg1.ACLs, adapterCfg2.ACLs) {
return true
}
}
Expand Down Expand Up @@ -296,7 +296,7 @@ func appendError(allErrors string, prefix string, lasterr string) (
return fmt.Sprintf("%s%s: %s\n\n", allErrors, prefix, lasterr), true
}

func (z *zedrouter) detectPortMapConflictWithinUL(ACLs []types.ACE) bool {
func (z *zedrouter) detectPortMapConflictWithinAdapter(ACLs []types.ACE) bool {
matchTypes1 := []string{"protocol"}
matchTypes2 := []string{"protocol", "lport"}
idx1 := 0
Expand Down Expand Up @@ -338,7 +338,7 @@ func (z *zedrouter) detectPortMapConflictWithinUL(ACLs []types.ACE) bool {

// Check for duplicate portmap rules in between two set of ACLs.
// For this, we will match the protocol/lport being same.
func (z *zedrouter) detectPortMapConflictAcrossULs(
func (z *zedrouter) detectPortMapConflictAcrossAdapters(
ACLs []types.ACE, ACLs1 []types.ACE) bool {
matchTypes := []string{"protocol", "lport"}
for _, ace1 := range ACLs {
Expand Down
2 changes: 1 addition & 1 deletion pkg/pillar/cmd/zedrouter/zedrouter.go
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ func (z *zedrouter) run(ctx context.Context) (err error) {
if adapterStatus.Name != vif.NetAdapterName {
continue
}
z.recordAssignedIPsToULStatus(adapterStatus, &newAddrs)
z.recordAssignedIPsToAdapterStatus(adapterStatus, &newAddrs)
break
}
z.publishAppNetworkStatus(appStatus)
Expand Down

0 comments on commit b1e433f

Please sign in to comment.