了解一下数据库存储的数据,有助于排查问题。

概览

sonic-py-swsssdk/src/swsssdk/config/database.json记录了几个数据类型,另外sonic-swss-common/common/schema.h记录的更为全面一些,我们查看一下:

#define APPL_DB         0
#define ASIC_DB         1
#define COUNTERS_DB     2
#define LOGLEVEL_DB     3
#define CONFIG_DB       4
#define PFC_WD_DB       5
#define FLEX_COUNTER_DB 5
#define STATE_DB        6

APPL_DB

#define APP_PORT_TABLE_NAME             "PORT_TABLE"            //记录了Ethernet端口,内含端口名称,index,端口状态,MTU和speed
#define APP_VLAN_TABLE_NAME             "VLAN_TABLE"            //记录了VLAN信息,只包含了配置状态
#define APP_VLAN_MEMBER_TABLE_NAME      "VLAN_MEMBER_TABLE"     //记录了端口和VLAN的对应关系,内含tag状态(tagged类似trunk,untagged类似access)
#define APP_LAG_TABLE_NAME              "LAG_TABLE"             //记录了LAG端口,内含端口状态和MTU
#define APP_LAG_MEMBER_TABLE_NAME       "LAG_MEMBER_TABLE"      //记录了端口和LAG的对应关系,内含配置状态
#define APP_INTF_TABLE_NAME             "INTF_TABLE"            //记录了端口的IP地址,内含协议族类型和范围
#define APP_NEIGH_TABLE_NAME            "NEIGH_TABLE"           //记录了neighbor的IP地址,内含协议族和neigbor的mac地址
#define APP_ROUTE_TABLE_NAME            "ROUTE_TABLE"           //记录了路由IP,内含端口名称以及下一跳信息
#define APP_TUNNEL_DECAP_TABLE_NAME     "TUNNEL_DECAP_TABLE"    //记录了tunnel信息
#define APP_MIRROR_SESSION_TABLE_NAME   "MIRROR_SESSION"        //记录了mirror信息
#define APP_FDB_TABLE_NAME              "FDB_TABLE"
#define APP_PFC_WD_TABLE_NAME           "PFC_WD_TABLE"
#define APP_SWITCH_TABLE_NAME           "SWITCH_TABLE"

#define APP_COPP_TABLE_NAME             "COPP_TABLE"

ASIC_DB

sonic-sairedis/lib/inc/sairedis.h

#define ASIC_STATE_TABLE "ASIC_STATE"

后面跟着如下内容。

sonic-sairedis/SAI/inc/saitypes.h

SAI_OBJECT_TYPE_NULL                     =  0,  //invalid object type
SAI_OBJECT_TYPE_PORT                     =  1,  //端口ID,内含状态,MTU,priority,speed等
SAI_OBJECT_TYPE_LAG                      =  2,  //LAG端口ID,内含ACL信息
SAI_OBJECT_TYPE_VIRTUAL_ROUTER           =  3,  //虚拟路由
SAI_OBJECT_TYPE_NEXT_HOP                 =  4,  //下一跳信息,内含IP,端口ID,类型
SAI_OBJECT_TYPE_NEXT_HOP_GROUP           =  5,  //下一跳的组的信息,内含类型,比如ECMP
SAI_OBJECT_TYPE_ROUTER_INTERFACE         =  6,  //路由信息,内含MTU,端口ID,源MAC,类型,router id等
SAI_OBJECT_TYPE_ACL_TABLE                =  7,  //ACL表配置信息
SAI_OBJECT_TYPE_ACL_ENTRY                =  8,  //ACL表项信息,内含ACL三色,DSCP,ECN,priority,table id等
SAI_OBJECT_TYPE_ACL_COUNTER              =  9,
SAI_OBJECT_TYPE_ACL_RANGE                = 10,
SAI_OBJECT_TYPE_ACL_TABLE_GROUP          = 11,  //ACL Table Group,内含ACL Stage和类型
SAI_OBJECT_TYPE_ACL_TABLE_GROUP_MEMBER   = 12,  //ACL Table Group Member,内含ACL Table id和ACL Table Group id
SAI_OBJECT_TYPE_HOSTIF                   = 13,  //主机端口,内含name,status,type,tag
SAI_OBJECT_TYPE_MIRROR_SESSION           = 14,
SAI_OBJECT_TYPE_SAMPLEPACKET             = 15,
SAI_OBJECT_TYPE_STP                      = 16,
SAI_OBJECT_TYPE_HOSTIF_TRAP_GROUP        = 17,
SAI_OBJECT_TYPE_POLICER                  = 18,  //策略配置信息,内含cbs,cir,mode等信息
SAI_OBJECT_TYPE_WRED                     = 19,  //WRED信息配置
SAI_OBJECT_TYPE_QOS_MAP                  = 20,  //QoS映射信息
SAI_OBJECT_TYPE_QUEUE                    = 21,  //Queue信息,没看到啥东西
SAI_OBJECT_TYPE_SCHEDULER                = 22,  //调度,内含调度类型和weight
SAI_OBJECT_TYPE_SCHEDULER_GROUP          = 23,  //调度组,内含包含的调度
SAI_OBJECT_TYPE_BUFFER_POOL              = 24,  //pool的大小,threshold,type
SAI_OBJECT_TYPE_BUFFER_PROFILE           = 25,  //pool的id,reserved size
SAI_OBJECT_TYPE_INGRESS_PRIORITY_GROUP   = 26,  //包含了buffer profile的id
SAI_OBJECT_TYPE_LAG_MEMBER               = 27,  //LAG id和Port id
SAI_OBJECT_TYPE_HASH                     = 28,
SAI_OBJECT_TYPE_UDF                      = 29,
SAI_OBJECT_TYPE_UDF_MATCH                = 30,
SAI_OBJECT_TYPE_UDF_GROUP                = 31,
SAI_OBJECT_TYPE_FDB_ENTRY                = 32,  //FDB表,内含mac,switch_id,port_id,action,type
SAI_OBJECT_TYPE_SWITCH                   = 33,  //switch信息,内含hash seed,notify,LAG hash seed,mac
SAI_OBJECT_TYPE_HOSTIF_TRAP              = 34,  //内含action,group,type
SAI_OBJECT_TYPE_HOSTIF_TABLE_ENTRY       = 35,
SAI_OBJECT_TYPE_NEIGHBOR_ENTRY           = 36,  //邻居信息,ip,mac
SAI_OBJECT_TYPE_ROUTE_ENTRY              = 37,  //路由信息,dest ip,next hop id,action
SAI_OBJECT_TYPE_VLAN                     = 38,  //Vlan信息,主要是vid
SAI_OBJECT_TYPE_VLAN_MEMBER              = 39,  //vlan id和tagging mode
SAI_OBJECT_TYPE_HOSTIF_PACKET            = 40,
SAI_OBJECT_TYPE_TUNNEL_MAP               = 41,
SAI_OBJECT_TYPE_TUNNEL                   = 42,  //tunnel信息,内含不少信息
SAI_OBJECT_TYPE_TUNNEL_TERM_TABLE_ENTRY  = 43,
SAI_OBJECT_TYPE_FDB_FLUSH                = 44,
SAI_OBJECT_TYPE_NEXT_HOP_GROUP_MEMBER    = 45,  //next hop信息
SAI_OBJECT_TYPE_STP_PORT                 = 46,
SAI_OBJECT_TYPE_RPF_GROUP                = 47,
SAI_OBJECT_TYPE_RPF_GROUP_MEMBER         = 48,
SAI_OBJECT_TYPE_L2MC_GROUP               = 49,
SAI_OBJECT_TYPE_L2MC_GROUP_MEMBER        = 50,
SAI_OBJECT_TYPE_IPMC_GROUP               = 51,
SAI_OBJECT_TYPE_IPMC_GROUP_MEMBER        = 52,
SAI_OBJECT_TYPE_L2MC_ENTRY               = 53,
SAI_OBJECT_TYPE_IPMC_ENTRY               = 54,
SAI_OBJECT_TYPE_MCAST_FDB_ENTRY          = 55,
SAI_OBJECT_TYPE_HOSTIF_USER_DEFINED_TRAP = 56,
SAI_OBJECT_TYPE_BRIDGE                   = 57,
SAI_OBJECT_TYPE_BRIDGE_PORT              = 58,  //端口状态,端口id,类型
SAI_OBJECT_TYPE_TUNNEL_MAP_ENTRY         = 59,
SAI_OBJECT_TYPE_TAM                      = 60,
SAI_OBJECT_TYPE_TAM_STAT                 = 61,
SAI_OBJECT_TYPE_TAM_SNAPSHOT             = 62,
SAI_OBJECT_TYPE_TAM_TRANSPORTER          = 63,
SAI_OBJECT_TYPE_TAM_THRESHOLD            = 64,
SAI_OBJECT_TYPE_SEGMENTROUTE_SIDLIST     = 65,
SAI_OBJECT_TYPE_PORT_POOL                = 66,
SAI_OBJECT_TYPE_INSEG_ENTRY              = 67,
SAI_OBJECT_TYPE_TAM_HISTOGRAM            = 68,
SAI_OBJECT_TYPE_TAM_MICROBURST           = 69,
SAI_OBJECT_TYPE_DTEL                     = 70, /**< experimental */
SAI_OBJECT_TYPE_DTEL_QUEUE_REPORT        = 71, /**< experimental */
SAI_OBJECT_TYPE_DTEL_INT_SESSION         = 72, /**< experimental */
SAI_OBJECT_TYPE_DTEL_REPORT_SESSION      = 73, /**< experimental */
SAI_OBJECT_TYPE_DTEL_EVENT               = 74, /**< experimental */
SAI_OBJECT_TYPE_BFD_SESSION              = 75,
SAI_OBJECT_TYPE_MAX                      = 76,

COUNTERS_DB

#define COUNTERS_PORT_NAME_MAP          "COUNTERS_PORT_NAME_MAP"    //端口名字和ID的映射关系
#define COUNTERS_TABLE                  "COUNTERS"                  //端口ID和对应的端口统计信息
#define COUNTERS_QUEUE_NAME_MAP         "COUNTERS_QUEUE_NAME_MAP"   //端口名字队列和ID的映射关系
#define COUNTERS_QUEUE_PORT_MAP         "COUNTERS_QUEUE_PORT_MAP"   //端口ID和队列ID的对应关系
#define COUNTERS_QUEUE_INDEX_MAP        "COUNTERS_QUEUE_INDEX_MAP"  //队列id和端口队列index的对应关系
#define COUNTERS_QUEUE_TYPE_MAP         "COUNTERS_QUEUE_TYPE_MAP"   //队列id和类型的对应关系,单播多播之类的
#define COUNTERS_CRM_TABLE              "CRM"

LOGLEVEL_DB

#define DAEMON_TABLE_NAME "DAEMON_TABLE"
#define DAEMON_LOGLEVEL "LOGLEVEL"
#define DAEMON_LOGOUTPUT "LOGOUTPUT"

CONFIG_DB

#define CFG_PORT_TABLE_NAME           "PORT"                        //端口信息,内含名称,lanes和speed
#define CFG_PORT_CABLE_LEN_TABLE_NAME "CABLE_LENGTH"                //端口支持的线长度

#define CFG_INTF_TABLE_NAME               "INTERFACE"               //端口信息,主要是端口名称和ip
#define CFG_LOOPBACK_INTERFACE_TABLE_NAME "LOOPBACK_INTERFACE"      //loopback端口,和上面一样
#define CFG_MGMT_INTERFACE_TABLE_NAME     "MGMT_INTERFACE"          //管理端口,和上面一样
#define CFG_LAG_INTF_TABLE_NAME           "PORTCHANNEL_INTERFACE"   //portchannel端口,
#define CFG_VLAN_INTF_TABLE_NAME          "VLAN_INTERFACE"          //VLAN端口

#define CFG_LAG_TABLE_NAME         "PORTCHANNEL"                    //主要记录了portchannel中包含的端口
#define CFG_VLAN_TABLE_NAME        "VLAN"                           //主要记录了vlan id
#define CFG_VLAN_MEMBER_TABLE_NAME "VLAN_MEMBER"                    //主要记录了vlan包含的端口
#define CFG_SWITCH_TABLE_NAME      "SWITCH"
#define CFG_VRF_TABLE_NAME         "VRF"
#define CFG_CRM_TABLE_NAME         "CRM"
#define CFG_VXLAN_TUNNEL_DECAP_TABLE_NAME "VXLAN_TUNNEL_DECAP"

#define CFG_DHCP_SERVER_TABLE_NAME   "DHCP_SERVER"                  //以下记录了几个server的ip
#define CFG_NTP_SERVER_TABLE_NAME    "NTP_SERVER"
#define CFG_SYSLOG_SERVER_TABLE_NAME "SYSLOG_SERVER"

#define CFG_BGP_NEIGHBOR_TABLE_NAME "BGP_NEIGHBOR"                  //内含ip,端口状态,asn,holdtime,keepalive,本地ip,name等

#define CFG_DEVICE_METADATA_TABLE_NAME "DEVICE_METADATA"            //貌似也是和bgp相关的

#define CFG_DEVICE_NEIGHBOR_TABLE_NAME          "DEVICE_NEIGHBOR"
#define CFG_DEVICE_NEIGHBOR_METADATA_TABLE_NAME "DEVICE_NEIGHBOR_METADATA"

#define CFG_MIRROR_SESSION_TABLE_NAME "MIRROR_SESSION"              //内含源、目的IP
#define CFG_ACL_TABLE_NAME            "ACL_TABLE"
#define CFG_ACL_RULE_TABLE_NAME       "ACL_RULE"
#define CFG_PFC_WD_TABLE_NAME         "PFC_WD_TABLE"
#define CFG_FLEX_COUNTER_TABLE_NAME "FLEX_COUNTER_TABLE"

#define CFG_PFC_PRIORITY_TO_PRIORITY_GROUP_MAP_TABLE_NAME "PFC_PRIORITY_TO_PRIORITY_GROUP_MAP"
#define CFG_TC_TO_PRIORITY_GROUP_MAP_TABLE_NAME     "TC_TO_PRIORITY_GROUP_MAP"
#define CFG_PFC_PRIORITY_TO_QUEUE_MAP_TABLE_NAME    "MAP_PFC_PRIORITY_TO_QUEUE"
#define CFG_TC_TO_QUEUE_MAP_TABLE_NAME              "TC_TO_QUEUE_MAP"
#define CFG_DSCP_TO_TC_MAP_TABLE_NAME               "DSCP_TO_TC_MAP"
#define CFG_SCHEDULER_TABLE_NAME                    "SCHEDULER"
#define CFG_PORT_QOS_MAP_TABLE_NAME                 "PORT_QOS_MAP"
#define CFG_WRED_PROFILE_TABLE_NAME                 "WRED_PROFILE"
#define CFG_QUEUE_TABLE_NAME                        "QUEUE"

#define CFG_BUFFER_POOL_TABLE_NAME                  "BUFFER_POOL"
#define CFG_BUFFER_PROFILE_TABLE_NAME               "BUFFER_PROFILE"
#define CFG_BUFFER_QUEUE_TABLE_NAME                 "BUFFER_QUEUE"
#define CFG_BUFFER_PG_TABLE_NAME                    "BUFFER_PG"
#define CFG_BUFFER_PORT_INGRESS_PROFILE_LIST_NAME   "BUFFER_PORT_INGRESS_PROFILE_LIST"
#define CFG_BUFFER_PORT_EGRESS_PROFILE_LIST_NAME    "BUFFER_PORT_EGRESS_PROFILE_LIST"

PFC_WD_DB

FLEX_COUNTER_DB

#define PFC_WD_POLL_MSECS 100
#define FLEX_COUNTER_TABLE "FLEX_COUNTER_TABLE"
#define PORT_COUNTER_ID_LIST "PORT_COUNTER_ID_LIST"
#define QUEUE_COUNTER_ID_LIST "QUEUE_COUNTER_ID_LIST"
#define QUEUE_ATTR_ID_LIST "QUEUE_ATTR_ID_LIST"
#define PFC_WD_STATE_TABLE "PFC_WD_STATE_TABLE"
#define PFC_WD_PORT_COUNTER_ID_LIST "PORT_COUNTER_ID_LIST"
#define PFC_WD_QUEUE_COUNTER_ID_LIST "QUEUE_COUNTER_ID_LIST"
#define PFC_WD_QUEUE_ATTR_ID_LIST "QUEUE_ATTR_ID_LIST"
#define PLUGIN_TABLE "PLUGIN_TABLE"
#define LUA_PLUGIN_TYPE "LUA_PLUGIN_TYPE"
#define SAI_OBJECT_TYPE "SAI_OBJECT_TYPE"

#define POLL_INTERVAL_FIELD      "POLL_INTERVAL"
#define QUEUE_PLUGIN_FIELD       "QUEUE_PLUGIN_LIST"
#define PORT_PLUGIN_FIELD        "PORT_PLUGIN_LIT"
#define FLEX_COUNTER_STATUS_FIELD "FLEX_COUNTER_STATUS"
#define FLEX_COUNTER_GROUP_TABLE "FLEX_COUNTER_GROUP_TABLE"

STATE_DB

#define STATE_PORT_TABLE_NAME           "PORT_TABLE"                //记录端口的状态
#define STATE_LAG_TABLE_NAME            "LAG_TABLE"                 //LAG状态
#define STATE_VLAN_TABLE_NAME           "VLAN_TABLE"                //VLAN状态
#define STATE_VLAN_MEMBER_TABLE_NAME    "VLAN_MEMBER_TABLE"
#define STATE_INTERFACE_TABLE_NAME      "INTERFACE_TABLE"
最后修改:2021 年 08 月 18 日
如果觉得我的文章对你有用,请随意赞赏