Skip to content

Commit

Permalink
apply review suggestion
Browse files Browse the repository at this point in the history
Signed-off-by: Date Huang <tjjh89017@hotmail.com>
  • Loading branch information
tjjh89017 committed Apr 18, 2023
1 parent cd4987f commit 5f9ae6e
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions plugins/main/bridge/bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,31 +153,32 @@ func collectVlanTrunk(vlanTrunk []*VlanTrunk) ([]int, error) {
var minID int
var maxID int
var ID int
if item.MinID != nil {

if item.MinID != nil && item.MaxID != nil {
minID = *item.MinID
if minID < 0 || minID > 4094 {
if minID <= 0 || minID > 4094 {
return nil, errors.New("incorrect trunk minID parameter")
}
}
if item.MaxID != nil {
maxID = *item.MaxID
if maxID < 0 || maxID > 4094 {
if maxID <= 0 || maxID > 4094 {
return nil, errors.New("incorrect trunk maxID parameter")
}
if maxID < minID {
return nil, errors.New("minID is greater than maxID in trunk parameter")
}
}
if minID > 0 && maxID > 0 {
for v := minID; v <= maxID; v++ {
vlanMap[v] = struct{}{}
}
}

if item.MinID != nil || item.MaxID != nil {
return nil, errors.New("minID and maxID should be configured simultaneously")
}

// single vid
if item.ID != nil {
ID = *item.ID
if ID < 0 || ID > 4094 {
if ID <= 0 || ID > 4094 {
return nil, errors.New("incorrect trunk id parameter")
}
vlanMap[ID] = struct{}{}
Expand Down

0 comments on commit 5f9ae6e

Please sign in to comment.