Skip to content

Commit

Permalink
Support temporary view mode in syncd (#133)
Browse files Browse the repository at this point in the history
* Support temporary view mode in syncd

* Addressing comments
  • Loading branch information
kcudnik authored Dec 12, 2016
1 parent bb3eab1 commit e393930
Show file tree
Hide file tree
Showing 18 changed files with 548 additions and 185 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,4 @@ meta/tests
###################
**/*~
**/*.swp
**/*.rec
1 change: 1 addition & 0 deletions lib/inc/sairedis.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ extern "C" {
#define SYNCD_INIT_VIEW "INIT_VIEW"
#define SYNCD_APPLY_VIEW "APPLY_VIEW"
#define ASIC_STATE_TABLE "ASIC_STATE"
#define TEMP_PREFIX "TEMP_"

typedef enum _sai_redis_notify_syncd_t
{
Expand Down
2 changes: 1 addition & 1 deletion lib/src/sai_redis_generic_create.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ sai_object_id_t redis_create_virtual_object_id(

sai_object_id_t objectId = (((sai_object_id_t)object_type) << 48) | virtual_id;

SWSS_LOG_DEBUG("created VID %llx", objectId);
SWSS_LOG_DEBUG("created VID 0x%lx", objectId);

return objectId;
}
Expand Down
2 changes: 1 addition & 1 deletion meta/sai_extra_tunnel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ sai_status_t meta_pre_create_tunnel_map(
const sai_tunnel_map_t* tunnel_map = &tunnel_map_list->list[i];

// TODO validate tunnel map
SWSS_LOG_DEBUG("tunnel map pointer: %llx", tunnel_map);
SWSS_LOG_DEBUG("tunnel map pointer: %p", tunnel_map);
}
}

Expand Down
86 changes: 43 additions & 43 deletions meta/sai_meta.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ bool object_reference_exists(

bool exists = ObjectReferences.find(oid) != ObjectReferences.end();

SWSS_LOG_DEBUG("object 0x%llx refrence: %s", oid, exists ? "exists" : "missing");
SWSS_LOG_DEBUG("object 0x%lx refrence: %s", oid, exists ? "exists" : "missing");

return exists;
}
Expand All @@ -385,13 +385,13 @@ void object_reference_inc(

if (!object_reference_exists(oid))
{
SWSS_LOG_ERROR("FATAL: object oid 0x%llx not in reference map", oid);
SWSS_LOG_ERROR("FATAL: object oid 0x%lx not in reference map", oid);
throw;
}

ObjectReferences[oid]++;

SWSS_LOG_DEBUG("increased reference on oid 0x%llx to %d", oid, ObjectReferences[oid]);
SWSS_LOG_DEBUG("increased reference on oid 0x%lx to %d", oid, ObjectReferences[oid]);
}

void object_reference_dec(
Expand All @@ -406,19 +406,19 @@ void object_reference_dec(

if (!object_reference_exists(oid))
{
SWSS_LOG_ERROR("FATAL: object oid 0x%llx not in reference map", oid);
SWSS_LOG_ERROR("FATAL: object oid 0x%lx not in reference map", oid);
throw;
}

ObjectReferences[oid]--;

if (ObjectReferences[oid] < 0)
{
SWSS_LOG_ERROR("FATAL: object oid 0x%llx reference count is negative!", oid);
SWSS_LOG_ERROR("FATAL: object oid 0x%lx reference count is negative!", oid);
throw;
}

SWSS_LOG_DEBUG("decreased reference on oid 0x%llx to %d", oid, ObjectReferences[oid]);
SWSS_LOG_DEBUG("decreased reference on oid 0x%lx to %d", oid, ObjectReferences[oid]);
}

void object_reference_dec(
Expand Down Expand Up @@ -450,13 +450,13 @@ void object_reference_insert(

if (object_reference_exists(oid))
{
SWSS_LOG_ERROR("FATAL: object oid 0x%llx already in reference map");
SWSS_LOG_ERROR("FATAL: object oid 0x%lx already in reference map", oid);
throw;
}

ObjectReferences[oid] = 0;

SWSS_LOG_DEBUG("inserted reference on 0x%llx", oid);
SWSS_LOG_DEBUG("inserted reference on 0x%lx", oid);
}

int32_t object_reference_count(
Expand All @@ -468,12 +468,12 @@ int32_t object_reference_count(
{
int32_t count = ObjectReferences[oid];

SWSS_LOG_DEBUG("reference count on oid 0x%llx is %d", oid, count);
SWSS_LOG_DEBUG("reference count on oid 0x%lx is %d", oid, count);

return count;
}

SWSS_LOG_ERROR("FATAL: object oid 0x%llx reference not in map", oid);
SWSS_LOG_ERROR("FATAL: object oid 0x%lx reference not in map", oid);
throw;
}

Expand All @@ -488,12 +488,12 @@ void object_reference_remove(

if (count > 0)
{
SWSS_LOG_ERROR("FATAL: removing object oid 0x%llx but reference count is: %d", oid, count);
SWSS_LOG_ERROR("FATAL: removing object oid 0x%lx but reference count is: %d", oid, count);
throw;
}
}

SWSS_LOG_DEBUG("removing object oid 0x%llx reference", oid);
SWSS_LOG_DEBUG("removing object oid 0x%lx reference", oid);

ObjectReferences.erase(oid);
}
Expand Down Expand Up @@ -580,7 +580,7 @@ int32_t vlan_reference_count(
return count;
}

SWSS_LOG_ERROR("FATAL: vlan vlanid 0x%llx reference not in map", vlanid);
SWSS_LOG_ERROR("FATAL: vlan vlanid %d reference not in map", vlanid);
throw;
}

Expand All @@ -595,7 +595,7 @@ void vlan_reference_remove(

if (count > 0)
{
SWSS_LOG_ERROR("FATAL: removing vlan vlanid 0x%llx but reference count is: %d", vlanid, count);
SWSS_LOG_ERROR("FATAL: removing vlan vlanid %d but reference count is: %d", vlanid, count);
throw;
}
}
Expand Down Expand Up @@ -841,7 +841,7 @@ sai_status_t meta_generic_validation_objlist(

if (oids.find(oid) != oids.end())
{
META_LOG_ERROR(md, "object on list [%u] oid 0x%llx is duplicated, but not allowed", i, oid);
META_LOG_ERROR(md, "object on list [%u] oid 0x%lx is duplicated, but not allowed", i, oid);

return SAI_STATUS_INVALID_PARAMETER;
}
Expand All @@ -865,21 +865,21 @@ sai_status_t meta_generic_validation_objlist(

if (ot == SAI_NULL_OBJECT_ID)
{
META_LOG_ERROR(md, "object on list [%u] oid 0x%llx is not valid, returned null object id", i, oid);
META_LOG_ERROR(md, "object on list [%u] oid 0x%lx is not valid, returned null object id", i, oid);

return SAI_STATUS_INVALID_PARAMETER;
}

if (md.allowedobjecttypes.find(ot) == md.allowedobjecttypes.end())
{
META_LOG_ERROR(md, "object on list [%u] oid 0x%llx object type %d is not allowed on this attribute", i, oid, ot);
META_LOG_ERROR(md, "object on list [%u] oid 0x%lx object type %d is not allowed on this attribute", i, oid, ot);

return SAI_STATUS_INVALID_PARAMETER;
}

if (!object_reference_exists(oid))
{
META_LOG_ERROR(md, "object on list [%u] oid 0x%llx object type %d does not exists in local DB", i, oid, ot);
META_LOG_ERROR(md, "object on list [%u] oid 0x%lx object type %d does not exists in local DB", i, oid, ot);

return SAI_STATUS_INVALID_PARAMETER;
}
Expand Down Expand Up @@ -1304,7 +1304,7 @@ sai_status_t meta_generic_validation_create(

if (value.u32range.min > value.u32range.max)
{
META_LOG_ERROR(md, "invalid range %u .. %u", value.u32range.min > value.u32range.max);
META_LOG_ERROR(md, "invalid range %u .. %u", value.u32range.min, value.u32range.max);

return SAI_STATUS_INVALID_PARAMETER;
}
Expand All @@ -1315,7 +1315,7 @@ sai_status_t meta_generic_validation_create(

if (value.s32range.min > value.s32range.max)
{
META_LOG_ERROR(md, "invalid range %u .. %u", value.s32range.min > value.s32range.max);
META_LOG_ERROR(md, "invalid range %u .. %u", value.s32range.min, value.s32range.max);

return SAI_STATUS_INVALID_PARAMETER;
}
Expand Down Expand Up @@ -1649,21 +1649,21 @@ sai_status_t meta_generic_validation_remove(

if (object_type == SAI_NULL_OBJECT_ID)
{
SWSS_LOG_ERROR("oid 0x%llx is not valid, returned null object id", oid);
SWSS_LOG_ERROR("oid 0x%lx is not valid, returned null object id", oid);

return SAI_STATUS_INVALID_PARAMETER;
}

if (object_type != meta_key.object_type)
{
SWSS_LOG_ERROR("oid 0x%llx type %d is not accepted, expected object type %d", oid, object_type, meta_key.object_type);
SWSS_LOG_ERROR("oid 0x%lx type %d is not accepted, expected object type %d", oid, object_type, meta_key.object_type);

return SAI_STATUS_INVALID_PARAMETER;
}

if (!object_reference_exists(oid))
{
SWSS_LOG_ERROR("object 0x%llx reference don't exists", oid);
SWSS_LOG_ERROR("object 0x%lx reference don't exists", oid);

return SAI_STATUS_INVALID_PARAMETER;
}
Expand All @@ -1672,7 +1672,7 @@ sai_status_t meta_generic_validation_remove(

if (count != 0)
{
SWSS_LOG_ERROR("object 0x%llx reference count is %d, can't remove", oid, count);
SWSS_LOG_ERROR("object 0x%lx reference count is %d, can't remove", oid, count);

return SAI_STATUS_INVALID_PARAMETER;
}
Expand Down Expand Up @@ -1921,7 +1921,7 @@ sai_status_t meta_generic_validation_set(

if (value.u32range.min > value.u32range.max)
{
META_LOG_ERROR(md, "invalid range %u .. %u", value.u32range.min > value.u32range.max);
META_LOG_ERROR(md, "invalid range %u .. %u", value.u32range.min, value.u32range.max);

return SAI_STATUS_INVALID_PARAMETER;
}
Expand All @@ -1932,7 +1932,7 @@ sai_status_t meta_generic_validation_set(

if (value.s32range.min > value.s32range.max)
{
META_LOG_ERROR(md, "invalid range %u .. %u", value.s32range.min > value.s32range.max);
META_LOG_ERROR(md, "invalid range %u .. %u", value.s32range.min, value.s32range.max);

return SAI_STATUS_INVALID_PARAMETER;
}
Expand Down Expand Up @@ -2056,14 +2056,14 @@ sai_status_t meta_generic_validation_set(

if (object_type == SAI_NULL_OBJECT_ID)
{
META_LOG_ERROR(md, "oid 0x%llx is not valid, returned null object id", oid);
META_LOG_ERROR(md, "oid 0x%lx is not valid, returned null object id", oid);

return SAI_STATUS_INVALID_PARAMETER;
}

if (object_type != meta_key.object_type)
{
META_LOG_ERROR(md, "oid 0x%llx type %d is not accepted, expected object type %d", oid, object_type, meta_key.object_type);
META_LOG_ERROR(md, "oid 0x%lx type %d is not accepted, expected object type %d", oid, object_type, meta_key.object_type);

return SAI_STATUS_INVALID_PARAMETER;
}
Expand Down Expand Up @@ -2311,14 +2311,14 @@ sai_status_t meta_generic_validation_get(

if (object_type == SAI_NULL_OBJECT_ID)
{
SWSS_LOG_ERROR("oid 0x%llx is not valid, returned null object id", oid);
SWSS_LOG_ERROR("oid 0x%lx is not valid, returned null object id", oid);

return SAI_STATUS_INVALID_PARAMETER;
}

if (object_type != meta_key.object_type)
{
SWSS_LOG_ERROR("oid 0x%llx type %d is not accepted, expected object type %d", oid, object_type, meta_key.object_type);
SWSS_LOG_ERROR("oid 0x%lx type %d is not accepted, expected object type %d", oid, object_type, meta_key.object_type);

return SAI_STATUS_INVALID_PARAMETER;
}
Expand Down Expand Up @@ -2392,13 +2392,13 @@ void meta_generic_validation_post_create(

if (object_type == SAI_NULL_OBJECT_ID)
{
SWSS_LOG_ERROR("created oid 0x%llx is not valid object type after create, returned null object id (vendor bug?)", oid);
SWSS_LOG_ERROR("created oid 0x%lx is not valid object type after create, returned null object id (vendor bug?)", oid);
break;
}

if (object_type != meta_key.object_type)
{
SWSS_LOG_ERROR("created oid 0x%llx type %d is wrond type, expected object type %d (vendor bug?)", oid, object_type, meta_key.object_type);
SWSS_LOG_ERROR("created oid 0x%lx type %d is wrond type, expected object type %d (vendor bug?)", oid, object_type, meta_key.object_type);
break;
}

Expand Down Expand Up @@ -2956,13 +2956,13 @@ void meta_generic_validation_post_get_objlist(

if (ot == SAI_NULL_OBJECT_ID)
{
META_LOG_ERROR(md, "returned get object on list [%u] oid 0x%llx is not valid, returned null object id", i, oid);
META_LOG_ERROR(md, "returned get object on list [%u] oid 0x%lx is not valid, returned null object id", i, oid);
continue;
}

if (md.allowedobjecttypes.find(ot) == md.allowedobjecttypes.end())
{
META_LOG_ERROR(md, "returned get object on list [%u] oid 0x%llx object type %d is not allowed on this attribute", i, oid, ot);
META_LOG_ERROR(md, "returned get object on list [%u] oid 0x%lx object type %d is not allowed on this attribute", i, oid, ot);
}

if (!object_reference_exists(oid))
Expand All @@ -2971,7 +2971,7 @@ void meta_generic_validation_post_get_objlist(
// and first list was retrived ok, but second failed with overflow
// then we may forget to snoop

META_LOG_INFO(md, "returned get object on list [%u] oid 0x%llx object type %d does not exists in local DB (snoop)", i, oid, ot);
META_LOG_INFO(md, "returned get object on list [%u] oid 0x%lx object type %d does not exists in local DB (snoop)", i, oid, ot);

sai_object_meta_key_t key = { .object_type = ot, .key = { .object_id = oid } };

Expand Down Expand Up @@ -3149,7 +3149,7 @@ void meta_generic_validation_post_get(

if (value.u32range.min > value.u32range.max)
{
META_LOG_ERROR(md, "invalid range %u .. %u", value.u32range.min > value.u32range.max);
META_LOG_ERROR(md, "invalid range %u .. %u", value.u32range.min, value.u32range.max);
}

break;
Expand All @@ -3158,7 +3158,7 @@ void meta_generic_validation_post_get(

if (value.s32range.min > value.s32range.max)
{
META_LOG_ERROR(md, "invalid range %u .. %u", value.s32range.min > value.s32range.max);
META_LOG_ERROR(md, "invalid range %u .. %u", value.s32range.min, value.s32range.max);
}

break;
Expand Down Expand Up @@ -3632,7 +3632,7 @@ sai_status_t meta_sai_validate_neighbor_entry(

if (object_type == SAI_NULL_OBJECT_ID)
{
SWSS_LOG_ERROR("router interface oid 0x%llx is not valid object type, returned null object id", rif);
SWSS_LOG_ERROR("router interface oid 0x%lx is not valid object type, returned null object id", rif);

return SAI_STATUS_INVALID_PARAMETER;
}
Expand All @@ -3641,7 +3641,7 @@ sai_status_t meta_sai_validate_neighbor_entry(

if (object_type != expected)
{
SWSS_LOG_ERROR("router interface oid 0x%llx type %d is wrond type, expected object type %d", rif, object_type, expected);
SWSS_LOG_ERROR("router interface oid 0x%lx type %d is wrond type, expected object type %d", rif, object_type, expected);

return SAI_STATUS_INVALID_PARAMETER;
}
Expand Down Expand Up @@ -4182,7 +4182,7 @@ sai_status_t meta_sai_validate_route_entry(

if (object_type == SAI_NULL_OBJECT_ID)
{
SWSS_LOG_ERROR("virtual router oid 0x%llx is not valid object type, returned null object id", vr);
SWSS_LOG_ERROR("virtual router oid 0x%lx is not valid object type, returned null object id", vr);

return SAI_STATUS_INVALID_PARAMETER;
}
Expand All @@ -4191,7 +4191,7 @@ sai_status_t meta_sai_validate_route_entry(

if (object_type != expected)
{
SWSS_LOG_ERROR("virtual router oid 0x%llx type %d is wrond type, expected object type %d", vr, object_type, expected);
SWSS_LOG_ERROR("virtual router oid 0x%lx type %d is wrond type, expected object type %d", vr, object_type, expected);

return SAI_STATUS_INVALID_PARAMETER;
}
Expand Down Expand Up @@ -4613,7 +4613,7 @@ sai_status_t meta_sai_validate_oid(

if (ot == SAI_NULL_OBJECT_ID)
{
SWSS_LOG_ERROR("%s oid 0x%llx is not valid object type, returned null object id", otname, oid);
SWSS_LOG_ERROR("%s oid 0x%lx is not valid object type, returned null object id", otname, oid);

return SAI_STATUS_INVALID_PARAMETER;
}
Expand All @@ -4622,7 +4622,7 @@ sai_status_t meta_sai_validate_oid(

if (ot != expected)
{
SWSS_LOG_ERROR("%s oid 0x%llx type %d is wrond type, expected object type %d", otname, oid, ot, expected);
SWSS_LOG_ERROR("%s oid 0x%lx type %d is wrond type, expected object type %d", otname, oid, ot, expected);

return SAI_STATUS_INVALID_PARAMETER;
}
Expand Down
Loading

0 comments on commit e393930

Please sign in to comment.