diff --git a/dataplane/saiserver/acl.go b/dataplane/saiserver/acl.go index 7c13db67..3db5522e 100644 --- a/dataplane/saiserver/acl.go +++ b/dataplane/saiserver/acl.go @@ -234,6 +234,12 @@ func (a *acl) createAclEntryFields(req *saipb.CreateAclEntryRequest, id uint64, Bytes: []byte{0x4}, // IPv4 0100 IPv6 0110 Masks: []byte{0x4}, // Mask 0100 } + case saipb.AclIpType_ACL_IP_TYPE_NON_IP: + fieldMask = &fwdpb.PacketFieldMaskedBytes{ + FieldId: &fwdpb.PacketFieldId{Field: &fwdpb.PacketField{FieldNum: fwdpb.PacketFieldNum_PACKET_FIELD_NUM_IP_VERSION}}, + Bytes: []byte{0x0}, // Non IP packets return 0x0 for IP VERSION + Masks: []byte{0x4}, + } default: return nil, status.Errorf(codes.InvalidArgument, "unsupported ACL_IP_TYPE: %v", t) } diff --git a/dataplane/saiserver/routing.go b/dataplane/saiserver/routing.go index f1759170..b4bf970d 100644 --- a/dataplane/saiserver/routing.go +++ b/dataplane/saiserver/routing.go @@ -107,6 +107,21 @@ func (n *neighbor) CreateNeighborEntries(ctx context.Context, re *saipb.CreateNe return resp, nil } +// SetNeighborEntryAttribute updates the attribute for the neighbor entry. +// TODO: Update neighbor table to use attrmgr to persist other fields besides mac address. +func (n *neighbor) SetNeighborEntryAttribute(ctx context.Context, req *saipb.SetNeighborEntryAttributeRequest) (*saipb.SetNeighborEntryAttributeResponse, error) { + entry := fwdconfig.TableEntryAddRequest(n.dataplane.ID(), NeighborTable).AppendEntry(fwdconfig.EntryDesc(fwdconfig.ExactEntry( + fwdconfig.PacketFieldBytes(fwdpb.PacketFieldNum_PACKET_FIELD_NUM_OUTPUT_IFACE).WithUint64(req.GetEntry().GetRifId()), + fwdconfig.PacketFieldBytes(fwdpb.PacketFieldNum_PACKET_FIELD_NUM_NEXT_HOP_IP).WithBytes(req.GetEntry().GetIpAddress()), + )), fwdconfig.UpdateAction(fwdpb.UpdateType_UPDATE_TYPE_SET, fwdpb.PacketFieldNum_PACKET_FIELD_NUM_ETHER_MAC_DST).WithValue(req.GetDstMacAddress()), + ).Build() + + if _, err := n.dataplane.TableEntryAdd(ctx, entry); err != nil { + return nil, err + } + return &saipb.SetNeighborEntryAttributeResponse{}, nil +} + type groupMember struct { nextHop uint64 // ID of the next hop weight uint32 @@ -1269,6 +1284,7 @@ func (vlan *vlan) RemoveVlan(ctx context.Context, r *saipb.RemoveVlanRequest) (* // Update the internal map. vlan.mu.Lock() delete(vlan.vlans, r.GetOid()) + delete(vlan.oidByVId, vId) vlan.mu.Unlock() return &saipb.RemoveVlanResponse{}, nil } diff --git a/dataplane/saiserver/tunnel.go b/dataplane/saiserver/tunnel.go index bf1d7515..e6e44608 100644 --- a/dataplane/saiserver/tunnel.go +++ b/dataplane/saiserver/tunnel.go @@ -50,7 +50,7 @@ func (t *tunnel) CreateTunnel(ctx context.Context, req *saipb.CreateTunnelReques tunType := req.GetType() switch tunType { - case saipb.TunnelType_TUNNEL_TYPE_IPINIP: + case saipb.TunnelType_TUNNEL_TYPE_IPINIP, saipb.TunnelType_TUNNEL_TYPE_IPINIP_GRE: default: return nil, status.Errorf(codes.InvalidArgument, "unsupported tunnel type: %v", tunType) } @@ -90,6 +90,8 @@ func (t *tunnel) CreateTunnel(ctx context.Context, req *saipb.CreateTunnelReques return nil, err } + t.mgr.StoreAttributes(id, req) + return &saipb.CreateTunnelResponse{ Oid: id, }, nil @@ -107,6 +109,30 @@ func (t *tunnel) RemoveTunnel(ctx context.Context, req *saipb.RemoveTunnelReques return &saipb.RemoveTunnelResponse{}, nil } +func (t *tunnel) CreateTunnels(ctx context.Context, req *saipb.CreateTunnelsRequest) (*saipb.CreateTunnelsResponse, error) { + resp := &saipb.CreateTunnelsResponse{} + for _, r := range req.GetReqs() { + res, err := t.CreateTunnel(ctx, r) + if err != nil { + return nil, err + } + resp.Resps = append(resp.Resps, res) + } + return resp, nil +} + +func (t *tunnel) RemoveTunnels(ctx context.Context, req *saipb.RemoveTunnelsRequest) (*saipb.RemoveTunnelsResponse, error) { + resp := &saipb.RemoveTunnelsResponse{} + for _, r := range req.GetReqs() { + res, err := t.RemoveTunnel(ctx, r) + if err != nil { + return nil, err + } + resp.Resps = append(resp.Resps, res) + } + return resp, nil +} + var ( ipV4ExactMask = []byte{0xFF, 0xFF, 0xFF, 0xFF} ipV4AnyMask = make([]byte, 4)