Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions dataplane/saiserver/acl.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
16 changes: 16 additions & 0 deletions dataplane/saiserver/routing.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down
28 changes: 27 additions & 1 deletion dataplane/saiserver/tunnel.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down
Loading