Skip to content

Commit

Permalink
[Server] send vmac to agent by segment #22202
Browse files Browse the repository at this point in the history
  • Loading branch information
roryye authored and jin-xiaofeng committed Sep 7, 2023
1 parent 7868a65 commit ffa1203
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
4 changes: 2 additions & 2 deletions cli/ctl/trisolaris_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,10 +255,10 @@ func Uint64ToMac(v uint64) net.HardwareAddr {

func formatString(data *trident.Interface) string {
buffer := bytes.Buffer{}
format := "Id: %d Mac: %s VMac: %s EpcId: %d DeviceType: %d DeviceId: %d IfType: %d" +
format := "Id: %d Mac: %s EpcId: %d DeviceType: %d DeviceId: %d IfType: %d" +
" LaunchServer: %s LaunchServerId: %d RegionId: %d AzId: %d, PodGroupId: %d, " +
"PodNsId: %d, PodId: %d, PodClusterId: %d, NetnsId: %d, VtapId: %d, IsVipInterface: %t "
buffer.WriteString(fmt.Sprintf(format, data.GetId(), Uint64ToMac(data.GetMac()), Uint64ToMac(data.GetVmac()),
buffer.WriteString(fmt.Sprintf(format, data.GetId(), Uint64ToMac(data.GetMac()),
data.GetEpcId(), data.GetDeviceType(), data.GetDeviceId(), data.GetIfType(),
data.GetLaunchServer(), data.GetLaunchServerId(), data.GetRegionId(),
data.GetAzId(), data.GetPodGroupId(), data.GetPodNsId(), data.GetPodId(),
Expand Down
13 changes: 9 additions & 4 deletions server/controller/trisolaris/metadata/segment.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,16 @@ import (
)

type MacID struct {
Mac string
ID int
Mac string
VMac string
ID int
}

func newMacID(vif *models.VInterface) *MacID {
return &MacID{
Mac: vif.Mac,
ID: vif.ID,
Mac: vif.Mac,
ID: vif.ID,
VMac: vif.VMac,
}
}

Expand Down Expand Up @@ -332,16 +334,19 @@ func (s *Segment) generateGatewayHostSegments() {
for _, hostSegments := range s.gatewayHostIDToSegments {
for _, macIDs := range hostSegments {
macs := make([]string, 0, len(macIDs))
vmacs := make([]string, 0, len(macIDs))
vifIDs := make([]uint32, 0, len(macIDs))
for _, macID := range macIDs {
if !isMacNullOrDefault(macID.Mac) {
macs = append(macs, macID.Mac)
vifIDs = append(vifIDs, uint32(macID.ID))
vmacs = append(vmacs, macID.VMac)
}
}
segment := &trident.Segment{
Id: proto.Uint32(uint32(1)),
Mac: macs,
Vmac: vmacs,
InterfaceId: vifIDs,
}
segments = append(segments, segment)
Expand Down

0 comments on commit ffa1203

Please sign in to comment.