You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the below code I would have done it a bit differently. I would have first checked for the type of port and the do a for loop for the logical bridges. That is because you would have always one type of BridgePort for all the logical Birdges in the list
for _, bridgeRefName := range in.BridgePort.Spec.LogicalBridges {
fmt.Printf("add iface to logical bridge %s", bridgeRefName)
// get object from DB
bridgeObject, ok := s.Bridges[bridgeRefName]
if !ok {
err := status.Errorf(codes.NotFound, "unable to find key %s", bridgeRefName)
log.Printf("error: %v", err)
return nil, err
}
vid := uint16(bridgeObject.Spec.VlanId)
switch in.BridgePort.Spec.Ptype {
case pb.BridgePortType_ACCESS:
// Example: bridge vlan add dev eth2 vid 20 pvid untagged
if err := netlink.BridgeVlanAdd(iface, vid, true, true, false, false); err != nil {
fmt.Printf("Failed to add vlan to bridge: %v", err)
return nil, err
}
case pb.BridgePortType_TRUNK:
// Example: bridge vlan add dev eth2 vid 20
if err := netlink.BridgeVlanAdd(iface, vid, false, false, false, false); err != nil {
fmt.Printf("Failed to add vlan to bridge: %v", err)
return nil, err
}
default:
msg := fmt.Sprintf("Only ACCESS or TRUNK supported and not (%d)", in.BridgePort.Spec.Ptype)
log.Print(msg)
return nil, status.Errorf(codes.InvalidArgument, msg)
}
}
see
opi-evpn-bridge/pkg/evpn/port.go
Lines 54 to 117 in 6b0df33
need another look and review
The text was updated successfully, but these errors were encountered: