From 32eca3ff7558db36a91467a6e9e3eda31d01cd47 Mon Sep 17 00:00:00 2001 From: Junchao-Mellanox <57339448+Junchao-Mellanox@users.noreply.github.com> Date: Tue, 29 Nov 2022 22:49:13 +0800 Subject: [PATCH] [YANG] Support syslog rate limit configuration (#12488) - Why I did it Change YANG model to support syslog rate limit configuration feature - How I did it modified sonic-syslog.yang and sonic-feature.yang to support the new added configuration schema - How to verify it Unit test --- src/sonic-yang-models/doc/Configuration.md | 273 ++++++++++-------- .../tests/files/sample_config_db.json | 37 ++- .../tests/yang_model_tests/tests/syslog.json | 26 ++ .../tests_config/feature.json | 28 +- .../yang_model_tests/tests_config/syslog.json | 108 +++++++ .../yang-models/sonic-feature.yang | 7 + .../yang-models/sonic-syslog.yang | 62 ++++ 7 files changed, 405 insertions(+), 136 deletions(-) diff --git a/src/sonic-yang-models/doc/Configuration.md b/src/sonic-yang-models/doc/Configuration.md index ba51e8e1aa..7060b352bc 100644 --- a/src/sonic-yang-models/doc/Configuration.md +++ b/src/sonic-yang-models/doc/Configuration.md @@ -3,57 +3,58 @@ Table of Contents ================= - * [Introduction](#introduction) - * [Configuration](#configuration) - * [Config Load and Save](#config-load-and-save) - * [Incremental Configuration](#incremental-configuration) - * [Redis and Json Schema](#redis-and-json-schema) - * [ACL and Mirroring](#acl-and-mirroring) - * [BGP Device Global](#bgp-device-global) - * [BGP Sessions](#bgp-sessions) - * [BUFFER_PG](#buffer_pg) - * [Buffer pool](#buffer-pool) - * [Buffer profile](#buffer-profile) - * [Buffer queue](#buffer-queue) - * [Buffer port ingress profile list](#buffer-port-ingress-profile-list) - * [Buffer port egress profile list](#buffer-port-egress-profile-list) - * [Cable length](#cable-length) - * [COPP_TABLE](#copp_table) - * [Console](#console) - * [CRM](#crm) - * [Data Plane L3 Interfaces](#data-plane-l3-interfaces) - * [DEFAULT_LOSSLESS_BUFFER_PARAMETER](#DEFAULT_LOSSLESS_BUFFER_PARAMETER) - * [Device Metadata](#device-metadata) - * [Device neighbor metada](#device-neighbor-metada) - * [DSCP_TO_TC_MAP](#dscp_to_tc_map) - * [FLEX_COUNTER_TABLE](#flex_counter_table) - * [KDUMP](#kdump) - * [Kubernetes Master](#kubernetes-master) - * [L2 Neighbors](#l2-neighbors) - * [Loopback Interface](#loopback-interface) - * [LOSSLESS_TRAFFIC_PATTERN](#LOSSLESS_TRAFFIC_PATTERN) - * [Management Interface](#management-interface) - * [Management port](#management-port) - * [Management VRF](#management-vrf) - * [MAP_PFC_PRIORITY_TO_QUEUE](#map_pfc_priority_to_queue) - * [MUX_CABLE](#muxcable) - * [NTP Global Configuration](#ntp-global-configuration) - * [NTP and SYSLOG servers](#ntp-and-syslog-servers) - * [Peer Switch](#peer-switch) - * [Policer](#policer) - * [Port](#port) - * [Port Channel](#port-channel) - * [Portchannel member](#portchannel-member) - * [Scheduler](#scheduler) - * [Port QoS Map](#port-qos-map) - * [Queue](#queue) - * [Restapi](#restapi) - * [Tacplus Server](#tacplus-server) - * [TC to Priority group map](#tc-to-priority-group-map) - * [TC to Queue map](#tc-to-queue-map) - * [Telemetry](#telemetry) - * [Versions](#versions) - * [VLAN](#vlan) + * [Introduction](#introduction) + * [Configuration](#configuration) + * [Config Load and Save](#config-load-and-save) + * [Incremental Configuration](#incremental-configuration) + * [Redis and Json Schema](#redis-and-json-schema) + * [ACL and Mirroring](#acl-and-mirroring) + * [BGP Device Global](#bgp-device-global) + * [BGP Sessions](#bgp-sessions) + * [BUFFER_PG](#buffer_pg) + * [Buffer pool](#buffer-pool) + * [Buffer profile](#buffer-profile) + * [Buffer queue](#buffer-queue) + * [Buffer port ingress profile list](#buffer-port-ingress-profile-list) + * [Buffer port egress profile list](#buffer-port-egress-profile-list) + * [Cable length](#cable-length) + * [COPP_TABLE](#copp_table) + * [Console](#console) + * [CRM](#crm) + * [Data Plane L3 Interfaces](#data-plane-l3-interfaces) + * [DEFAULT_LOSSLESS_BUFFER_PARAMETER](#DEFAULT_LOSSLESS_BUFFER_PARAMETER) + * [Device Metadata](#device-metadata) + * [Device neighbor metada](#device-neighbor-metada) + * [DSCP_TO_TC_MAP](#dscp_to_tc_map) + * [FLEX_COUNTER_TABLE](#flex_counter_table) + * [KDUMP](#kdump) + * [Kubernetes Master](#kubernetes-master) + * [L2 Neighbors](#l2-neighbors) + * [Loopback Interface](#loopback-interface) + * [LOSSLESS_TRAFFIC_PATTERN](#LOSSLESS_TRAFFIC_PATTERN) + * [Management Interface](#management-interface) + * [Management port](#management-port) + * [Management VRF](#management-vrf) + * [MAP_PFC_PRIORITY_TO_QUEUE](#map_pfc_priority_to_queue) + * [MUX_CABLE](#muxcable) + * [NTP Global Configuration](#ntp-global-configuration) + * [NTP and SYSLOG servers](#ntp-and-syslog-servers) + * [Peer Switch](#peer-switch) + * [Policer](#policer) + * [Port](#port) + * [Port Channel](#port-channel) + * [Portchannel member](#portchannel-member) + * [Scheduler](#scheduler) + * [Port QoS Map](#port-qos-map) + * [Queue](#queue) + * [Restapi](#restapi) + * [SYSLOG Rate Limit](#syslog-rate-limit) + * [Tacplus Server](#tacplus-server) + * [TC to Priority group map](#tc-to-priority-group-map) + * [TC to Queue map](#tc-to-queue-map) + * [Telemetry](#telemetry) + * [Versions](#versions) + * [VLAN](#vlan) * [VLAN_MEMBER](#vlan_member) * [VOQ Inband Interface](#voq-inband-interface) * [VXLAN](#vxlan) @@ -62,14 +63,14 @@ Table of Contents * [WRED_PROFILE](#wred_profile) * [PASSWORD_HARDENING](#password_hardening) * [SYSTEM_DEFAULTS table](#systemdefaults-table) - * [For Developers](#for-developers) + * [For Developers](#for-developers) * [Generating Application Config by Jinja2 Template](#generating-application-config-by-jinja2-template) * [Incremental Configuration by Subscribing to ConfigDB](#incremental-configuration-by-subscribing-to-configdb) -# Introduction -This document lists the configuration commands schema applied in the SONiC eco system. All these commands find relevance in collecting system information, analysis and even for trouble shooting. All the commands are categorized under relevant topics with corresponding examples. +# Introduction +This document lists the configuration commands schema applied in the SONiC eco system. All these commands find relevance in collecting system information, analysis and even for trouble shooting. All the commands are categorized under relevant topics with corresponding examples. # Configuration @@ -107,7 +108,7 @@ However, this feature is not implemented by all applications yet. By Sep is BGP (docker-fpm-quagga). For other applications, a manual restart is required after configuration changes in ConfigDB. -# **Redis and Json Schema** +# **Redis and Json Schema** ConfigDB uses a table-object schema that is similar with [AppDB](https://github.com/Azure/sonic-swss/blob/4c56d23b9ff4940bdf576cf7c9e5aa77adcbbdcc/doc/swss-schema.md), @@ -343,11 +344,11 @@ and migration plan } } ``` -### BGP Device Global +### BGP Device Global -The **BGP_DEVICE_GLOBAL** table contains device-level BGP global state. -It has a STATE object containing device state like **tsa_enabled** -which is set to true if device is currently isolated using +The **BGP_DEVICE_GLOBAL** table contains device-level BGP global state. +It has a STATE object containing device state like **tsa_enabled** +which is set to true if device is currently isolated using traffic-shift-away (TSA) route-maps in BGP ``` @@ -379,17 +380,17 @@ group name and IP ranges in **BGP_PEER_RANGE** table. "asn": 64009, "name": "ARISTA09T0" }, - + "10.0.0.63": { - "rrclient": "0", - "name": "ARISTA04T1", - "local_addr": "10.0.0.62", - "nhopself": "0", - "holdtime": "10", - "asn": "64600", + "rrclient": "0", + "name": "ARISTA04T1", + "local_addr": "10.0.0.62", + "nhopself": "0", + "holdtime": "10", + "asn": "64600", "keepalive": "3" } - + "BGP_PEER_RANGE": { "BGPSLBPassive": { "name": "BGPSLBPassive", @@ -573,7 +574,7 @@ This kind of profiles will be handled by buffer manager and won't be applied to } } } - + ``` ### Buffer port ingress profile list @@ -651,7 +652,7 @@ This kind of profiles will be handled by buffer manager and won't be applied to "queue": "0", "red_action": "drop" }, - + "trap.group.arp": { "cbs": "600", "cir": "600", @@ -663,21 +664,21 @@ This kind of profiles will be handled by buffer manager and won't be applied to "trap_ids": "arp_req,arp_resp,neigh_discovery", "trap_priority": "4" }, - + "trap.group.lldp.dhcp.udld": { "queue": "4", "trap_action": "trap", "trap_ids": "lldp,dhcp,udld", "trap_priority": "4" }, - + "trap.group.bgp.lacp": { "queue": "4", "trap_action": "trap", "trap_ids": "bgp,bgpv6,lacp", "trap_priority": "4" }, - + "trap.group.ip2me": { "cbs": "600", "cir": "600", @@ -1083,7 +1084,7 @@ instead of data network. } } } - + ``` @@ -1119,7 +1120,7 @@ instead of data network. ``` ### MUX_CABLE -The **MUX_CABLE** table is used for dualtor interface configuration. The `cable_type` and `soc_ipv4` objects are optional. +The **MUX_CABLE** table is used for dualtor interface configuration. The `cable_type` and `soc_ipv4` objects are optional. ``` { @@ -1162,7 +1163,7 @@ This option **has no effect** if the mgmt vrf is not enabled. ***NTP Source Port*** -This option sets the port which ntp will choose to send time update requests from by. +This option sets the port which ntp will choose to send time update requests from by. NOTE: If a Loopback interface is defined on the switch ntp will choose this by default, so this setting is **required** if the switch has a Loopback interface and the ntp peer does not have defined routes @@ -1232,7 +1233,7 @@ attributes in those objects. ### Peer Switch -Below is an exmaple of the peer switch table configuration. +Below is an exmaple of the peer switch table configuration. ``` { "PEER_SWITCH": { @@ -1368,9 +1369,9 @@ name as object key and member list as attribute. ``` { "PORTCHANNEL_MEMBER": { - "PortChannel0001|Ethernet50": {}, - "PortChannel0002|Ethernet52": {}, - "PortChannel0003|Ethernet54": {}, + "PortChannel0001|Ethernet50": {}, + "PortChannel0002|Ethernet52": {}, + "PortChannel0003|Ethernet54": {}, "PortChannel0004|Ethernet56": {} } } @@ -1406,17 +1407,17 @@ name as object key and member list as attribute. { "PORT_QOS_MAP": { "Ethernet50,Ethernet52,Ethernet54,Ethernet56": { - "tc_to_pg_map": "AZURE", - "tc_to_queue_map": "AZURE", - "pfc_enable": "3,4", - "pfc_to_queue_map": "AZURE", + "tc_to_pg_map": "AZURE", + "tc_to_queue_map": "AZURE", + "pfc_enable": "3,4", + "pfc_to_queue_map": "AZURE", "dscp_to_tc_map": "AZURE", "dscp_to_fc_map": "AZURE", "exp_to_fc_map": "AZURE", "scheduler": "scheduler.port" } } -} +} ``` ### Queue @@ -1424,12 +1425,12 @@ name as object key and member list as attribute. { "QUEUE": { "Ethernet56|4": { - "wred_profile": "AZURE_LOSSLESS", + "wred_profile": "AZURE_LOSSLESS", "scheduler": "scheduler.1" - }, + }, "Ethernet56|5": { "scheduler": "scheduler.0" - }, + }, "Ethernet56|6": { "scheduler": "scheduler.0" } @@ -1455,17 +1456,49 @@ name as object key and member list as attribute. } ``` +### Syslog Rate Limit + +Host side configuration: + +``` +{ +"SYSLOG_CONFIG": { + "GLOBAL": { + "rate_limit_interval": "300", + "rate_limit_burst": "20000" + } + } +} +``` + +Container side configuration: + +``` +{ +"SYSLOG_CONFIG_FEATURE": { + "bgp": { + "rate_limit_interval": "300", + "rate_limit_burst": "20000" + }, + "pmon": { + "rate_limit_interval": "300", + "rate_limit_burst": "20000" + } + } +} +``` + ### Tacplus Server ``` { "TACPLUS_SERVER": { "10.0.0.8": { - "priority": "1", + "priority": "1", "tcp_port": "49" - }, + }, "10.0.0.9": { - "priority": "1", + "priority": "1", "tcp_port": "49" } } @@ -1479,17 +1512,17 @@ name as object key and member list as attribute. { "TC_TO_PRIORITY_GROUP_MAP": { "AZURE": { - "1": "1", - "0": "0", - "3": "3", - "2": "2", - "5": "5", - "4": "4", - "7": "7", + "1": "1", + "0": "0", + "3": "3", + "2": "2", + "5": "5", + "4": "4", + "7": "7", "6": "6" } } -} +} ``` ### TC to Queue map @@ -1498,17 +1531,17 @@ name as object key and member list as attribute. { "TC_TO_QUEUE_MAP": { "AZURE": { - "1": "1", - "0": "0", - "3": "3", - "2": "2", - "5": "5", - "4": "4", - "7": "7", + "1": "1", + "0": "0", + "3": "3", + "2": "2", + "5": "5", + "4": "4", + "7": "7", "6": "6" } } -} +} ``` ### Telemetry @@ -1610,8 +1643,8 @@ VOQ_INBAND_INTERFACE holds the name of the inband system port dedicated for cpu ### VXLAN -VXLAN_TUNNEL holds the VTEP source ip configuration. -VXLAN_TUNNEL_MAP holds the vlan to vni and vni to vlan mapping configuration. +VXLAN_TUNNEL holds the VTEP source ip configuration. +VXLAN_TUNNEL_MAP holds the vlan to vni and vni to vlan mapping configuration. VXLAN_EVPN_NVO holds the VXLAN_TUNNEL object to be used for BGP-EVPN discovered tunnels. ``` @@ -1689,18 +1722,18 @@ The packet action could be: { "WRED_PROFILE": { "AZURE_LOSSLESS": { - "red_max_threshold": "2097152", - "wred_green_enable": "true", - "ecn": "ecn_all", - "green_min_threshold": "1048576", - "red_min_threshold": "1048576", - "wred_yellow_enable": "true", - "yellow_min_threshold": "1048576", - "green_max_threshold": "2097152", - "green_drop_probability": "5", - "yellow_max_threshold": "2097152", - "wred_red_enable": "true", - "yellow_drop_probability": "5", + "red_max_threshold": "2097152", + "wred_green_enable": "true", + "ecn": "ecn_all", + "green_min_threshold": "1048576", + "red_min_threshold": "1048576", + "wred_yellow_enable": "true", + "yellow_min_threshold": "1048576", + "green_max_threshold": "2097152", + "green_drop_probability": "5", + "yellow_max_threshold": "2097152", + "wred_red_enable": "true", + "yellow_drop_probability": "5", "red_drop_probability": "5" } } diff --git a/src/sonic-yang-models/tests/files/sample_config_db.json b/src/sonic-yang-models/tests/files/sample_config_db.json index 1c3531787f..e7b1a90b01 100644 --- a/src/sonic-yang-models/tests/files/sample_config_db.json +++ b/src/sonic-yang-models/tests/files/sample_config_db.json @@ -473,6 +473,22 @@ "vrf": "Vrf_blue" } }, + "SYSLOG_CONFIG" : { + "GLOBAL": { + "rate_limit_interval": "5", + "rate_limit_burst": "100" + } + }, + "SYSLOG_CONFIG_FEATURE" : { + "swss": { + "rate_limit_interval": "5", + "rate_limit_burst": "100" + }, + "bgp": { + "rate_limit_interval": "10", + "rate_limit_burst": "200" + } + }, "CABLE_LENGTH": { "AZURE": { "Ethernet0": "5m", @@ -1529,7 +1545,8 @@ "high_mem_alert": "disabled", "state": "enabled", "set_owner": "local", - "check_up_status": "False" + "check_up_status": "False", + "support_syslog_rate_limit": "True" }, "database": { "auto_restart": "always_enabled", @@ -1539,7 +1556,8 @@ "high_mem_alert": "disabled", "state": "always_enabled", "set_owner": "local", - "check_up_status": "false" + "check_up_status": "false", + "support_syslog_rate_limit": "True" }, "snmp": { "auto_restart": "enabled", @@ -1549,7 +1567,8 @@ "high_mem_alert": "disabled", "state": "enabled", "set_owner": "kube", - "check_up_status": "true" + "check_up_status": "true", + "support_syslog_rate_limit": "True" }, "swss": { "auto_restart": "enabled", @@ -1559,7 +1578,8 @@ "high_mem_alert": "disabled", "state": "enabled", "set_owner": "local", - "check_up_status": "false" + "check_up_status": "false", + "support_syslog_rate_limit": "True" }, "syncd": { "auto_restart": "enabled", @@ -1569,7 +1589,8 @@ "high_mem_alert": "disabled", "state": "enabled", "set_owner": "local", - "check_up_status": "false" + "check_up_status": "false", + "support_syslog_rate_limit": "True" }, "lldp": { "auto_restart": "enabled", @@ -1579,7 +1600,8 @@ "high_mem_alert": "disabled", "state": "enabled", "set_owner": "kube", - "check_up_status": "false" + "check_up_status": "false", + "support_syslog_rate_limit": "True" }, "dhcp_relay": { "auto_restart": "enabled", @@ -1589,7 +1611,8 @@ "high_mem_alert": "disabled", "state": "{% if not (DEVICE_METADATA is defined and DEVICE_METADATA['localhost'] is defined and DEVICE_METADATA['localhost']['type'] is defined and DEVICE_METADATA['localhost']['type'] != 'ToRRouter') %}enabled{% else %}disabled{% endif %}", "set_owner": "kube", - "check_up_status": "true" + "check_up_status": "true", + "support_syslog_rate_limit": "True" } }, "DHCP_RELAY": { diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/syslog.json b/src/sonic-yang-models/tests/yang_model_tests/tests/syslog.json index 8b110fbd8a..da277f1134 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests/syslog.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/syslog.json @@ -36,5 +36,31 @@ "SYSLOG_SERVER_INVALID_IPV6_ADDR_TEST": { "desc": "Load syslog server table with invalid ipv6 address as syslog server.", "eStrKey": "InvalidValue" + }, + "SYSLOG_CONFIG_VALID": { + "desc": "Configure SYSLOG_CONFIG." + }, + "SYSLOG_CONFIG_INVALID_INTERVAL": { + "desc": "Configure invalid rate limit interval in SYSLOG_CONFIG.", + "eStrKey": "InvalidValue" + }, + "SYSLOG_CONFIG_INVALID_BURST": { + "desc": "Configure invalid rate limit burst in SYSLOG_CONFIG.", + "eStrKey": "InvalidValue" + }, + "SYSLOG_CONFIG_FEATURE_VALID": { + "desc": "Configure SYSLOG_CONFIG_FEATURE." + }, + "SYSLOG_CONFIG_FEATURE_INVALID_SERVICE_NAME": { + "desc": "Configure invalid service in SYSLOG_CONFIG_FEATURE.", + "eStrKey": "LeafRef" + }, + "SYSLOG_CONFIG_FEATURE_INVALID_INTERVAL": { + "desc": "Configure invalid rate_limit_interval in SYSLOG_CONFIG_FEATURE.", + "eStrKey": "InvalidValue" + }, + "SYSLOG_CONFIG_FEATURE_INVALID_BURST": { + "desc": "Configure invalid rate_limit_burst in SYSLOG_CONFIG_FEATURE.", + "eStrKey": "InvalidValue" } } diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/feature.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/feature.json index 31b12b6a19..dcba0bd317 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/feature.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/feature.json @@ -11,7 +11,8 @@ "has_global_scope": "True", "has_per_asic_scope": "True", "set_owner": "local", - "check_up_status": "False" + "check_up_status": "False", + "support_syslog_rate_limit": "true" }, { "name": "swss", @@ -21,7 +22,8 @@ "has_global_scope": "false", "has_per_asic_scope": "true", "set_owner": "local", - "check_up_status": "false" + "check_up_status": "false", + "support_syslog_rate_limit": "true" }, { "name": "syncd", @@ -31,7 +33,8 @@ "has_global_scope": "false", "has_per_asic_scope": "true", "set_owner": "local", - "check_up_status": "false" + "check_up_status": "false", + "support_syslog_rate_limit": "true" }, { "name": "snmp", @@ -41,7 +44,8 @@ "has_global_scope": "true", "has_per_asic_scope": "false", "set_owner": "kube", - "check_up_status": "false" + "check_up_status": "false", + "support_syslog_rate_limit": "true" }, { "name": "lldp", @@ -51,7 +55,8 @@ "has_global_scope": "false", "has_per_asic_scope": "{% if not DEVICE_RUNTIME_METADATA['ETHERNET_PORTS_PRESENT'] or ('CHASSIS_METADATA' in DEVICE_RUNTIME_METADATA and DEVICE_RUNTIME_METADATA['CHASSIS_METADATA']['module_type'] in ['supervisor']) %}False{% else %}True{% endif %}", "set_owner": "kube", - "check_up_status": "false" + "check_up_status": "false", + "support_syslog_rate_limit": "true" }, { "name": "dhcp_relay", @@ -61,7 +66,8 @@ "has_global_scope": "false", "has_per_asic_scope": "true", "set_owner": "kube", - "check_up_status": "false" + "check_up_status": "false", + "support_syslog_rate_limit": "true" } ] } @@ -79,7 +85,8 @@ "has_global_scope": "false", "has_per_asic_scope": "{% if not DEVICE_RUNTIME_METADATA['ETHERNET_PORTS_PRESENT'] or ('CHASSIS_METADATA' in DEVICE_RUNTIME_METADATA and DEVICE_RUNTIME_METADATA['CHASSIS_METADATA']['module_type'] in ['supervisor']) %}False{% else %}True{% endif %}", "set_owner": "invalid", - "check_up_status": "false" + "check_up_status": "false", + "support_syslog_rate_limit": "true" } ] } @@ -96,7 +103,9 @@ "has_timer": "false", "has_global_scope": "false", "has_per_asic_scope": "{% if not DEVICE_RUNTIME_METADATA['ETHERNET_PORTS_PRESENT'] or ('CHASSIS_METADATA' in DEVICE_RUNTIME_METADATA and DEVICE_RUNTIME_METADATA['CHASSIS_METADATA']['module_type'] in ['supervisor']) %}False{% else %}True{% endif %}", - "check_up_status": "false" + "check_up_status": "false", + "support_syslog_rate_limit": "true" + } ] } @@ -113,7 +122,8 @@ "has_timer": "FALSE", "has_global_scope": "TRUE", "has_per_asic_scope": "TRUE", - "check_up_status": "FALSE" + "check_up_status": "FALSE", + "support_syslog_rate_limit": "TRUE" } ] } diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/syslog.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/syslog.json index 990fdcf85c..0ebaddbc70 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/syslog.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/syslog.json @@ -157,5 +157,113 @@ ] } } + }, + "SYSLOG_CONFIG_VALID": { + "sonic-syslog:sonic-syslog": { + "sonic-syslog:SYSLOG_CONFIG": { + "sonic-syslog:GLOBAL": { + "rate_limit_interval": "200", + "rate_limit_burst": "40000" + } + } + } + }, + "SYSLOG_CONFIG_INVALID_INTERVAL": { + "sonic-syslog:sonic-syslog": { + "sonic-syslog:SYSLOG_CONFIG": { + "sonic-syslog:GLOBAL": { + "rate_limit_interval": "-1" + } + } + } + }, + "SYSLOG_CONFIG_INVALID_BURST": { + "sonic-syslog:sonic-syslog": { + "sonic-syslog:SYSLOG_CONFIG": { + "sonic-syslog:GLOBAL": { + "rate_limit_burst": "-1" + } + } + } + }, + "SYSLOG_CONFIG_FEATURE_VALID": { + "sonic-syslog:sonic-syslog": { + "sonic-syslog:SYSLOG_CONFIG_FEATURE": { + "SYSLOG_CONFIG_FEATURE_LIST": [ + { + "service": "bgp", + "rate_limit_interval": "200", + "rate_limit_burst": "40000" + } + ] + } + }, + "sonic-feature:sonic-feature": { + "sonic-feature:FEATURE": { + "FEATURE_LIST": [ + { + "name": "bgp", + "support_syslog_rate_limit": "true" + } + ] + } + } + }, + "SYSLOG_CONFIG_FEATURE_INVALID_SERVICE_NAME": { + "sonic-syslog:sonic-syslog": { + "sonic-syslog:SYSLOG_CONFIG_FEATURE": { + "SYSLOG_CONFIG_FEATURE_LIST": [ + { + "service": "invalid", + "rate_limit_interval": "100", + "rate_limit_burst": "20000" + } + ] + } + } + }, + "SYSLOG_CONFIG_FEATURE_INVALID_INTERVAL": { + "sonic-syslog:sonic-syslog": { + "sonic-syslog:SYSLOG_CONFIG_FEATURE": { + "SYSLOG_CONFIG_FEATURE_LIST": [ + { + "service": "bgp", + "rate_limit_interval": "-1" + } + ] + } + }, + "sonic-feature:sonic-feature": { + "sonic-feature:FEATURE": { + "FEATURE_LIST": [ + { + "name": "bgp", + "support_syslog_rate_limit": "true" + } + ] + } + } + }, + "SYSLOG_CONFIG_FEATURE_INVALID_BURST": { + "sonic-syslog:sonic-syslog": { + "sonic-syslog:SYSLOG_CONFIG_FEATURE": { + "SYSLOG_CONFIG_FEATURE_LIST": [ + { + "service": "bgp", + "rate_limit_burst": "-1" + } + ] + } + }, + "sonic-feature:sonic-feature": { + "sonic-feature:FEATURE": { + "FEATURE_LIST": [ + { + "name": "bgp", + "support_syslog_rate_limit": "true" + } + ] + } + } } } diff --git a/src/sonic-yang-models/yang-models/sonic-feature.yang b/src/sonic-yang-models/yang-models/sonic-feature.yang index fb3c6d6520..4e514ff2f0 100644 --- a/src/sonic-yang-models/yang-models/sonic-feature.yang +++ b/src/sonic-yang-models/yang-models/sonic-feature.yang @@ -98,6 +98,13 @@ module sonic-feature{ type stypes:boolean_type; default "false"; } + + leaf support_syslog_rate_limit { + description "This configuration indicates the feature support configuring + syslog rate limit"; + type stypes:boolean_type; + default "false"; + } } } } diff --git a/src/sonic-yang-models/yang-models/sonic-syslog.yang b/src/sonic-yang-models/yang-models/sonic-syslog.yang index dc1925f463..6a4750f708 100644 --- a/src/sonic-yang-models/yang-models/sonic-syslog.yang +++ b/src/sonic-yang-models/yang-models/sonic-syslog.yang @@ -17,6 +17,10 @@ module sonic-syslog { prefix vrf; } + import sonic-feature { + prefix feature; + } + description "Syslog YANG Module for SONiC OS: remote syslog logging"; revision 2022-04-18 { @@ -31,6 +35,20 @@ module sonic-syslog { } } + typedef syslog-rate-limit-interval { + description "Message rate limit interval in second"; + type uint32 { + range 0..2147483647; + } + } + + typedef syslog-rate-limit-burst { + description "Message rate limit burst in message count"; + type uint32 { + range 0..2147483647; + } + } + container sonic-syslog { container SYSLOG_SERVER { @@ -74,6 +92,50 @@ module sonic-syslog { /* end of list SYSLOG_SERVER_LIST */ } /* end of container SYSLOG_SERVER */ + + container SYSLOG_CONFIG { + + description "SYSLOG_CONFIG part of config_db.json"; + + container GLOBAL { + leaf rate_limit_interval { + type syslog-rate-limit-interval; + } + + leaf rate_limit_burst { + type syslog-rate-limit-burst; + } + } + /* end of list SYSLOG_CONFIG_LIST */ + } + /* end of container SYSLOG_CONFIG */ + + container SYSLOG_CONFIG_FEATURE { + + description "SYSLOG_CONFIG_FEATURE part of config_db.json"; + + list SYSLOG_CONFIG_FEATURE_LIST { + + key "service"; + + leaf service { + description "Service name"; + type leafref { + path "/feature:sonic-feature/feature:FEATURE/feature:FEATURE_LIST/feature:name"; + } + } + + leaf rate_limit_interval { + type syslog-rate-limit-interval; + } + + leaf rate_limit_burst { + type syslog-rate-limit-burst; + } + } + /* end of list SYSLOG_CONFIG_FEATURE_LIST */ + } + /* end of container SYSLOG_CONFIG_FEATURE */ } /* end of container sonic-syslog */ }