-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial version for protobuf files and its conversion. Based on: https://github.com/sonic-net/DASH/blob/f0517f92b70d05a3b3d55268bec1795c4434f684/documentation/general/dash-sonic-hld.md Signed-off-by: Ze Gan <[email protected]>
- Loading branch information
Showing
20 changed files
with
510 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
proto/* | ||
!proto/*.proto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,25 @@ | ||
# sonic-dash-api | ||
|
||
This repository hosts the DASH API definition for the SONiC project. The schema of DASH APP DB is at [DASH APP DB](https://github.com/sonic-net/DASH/blob/main/documentation/general/dash-sonic-hld.md#32-dash-app-db) and all entries of DASH APP DB will be encoded as protobuf. | ||
|
||
## Protobuf Convention | ||
|
||
1. File name use underscore case, E.G. `acl_rule.proto` | ||
2. All file except common utility should include and only include one message of entry and one message of its key. | ||
3. Message name of entry use camel case. E.G. `AclRule`. | ||
4. Message name of entry key use the entry name with a fixed postfix `Key`. E.G. `AclRuleKey`. | ||
5. If the value of entry is a list, the item use the entry name with a fixed postfix `Item`. E.G. `RouteTypeItem`. | ||
6. Member variable use underscore case. E.G. `src_addr`. | ||
7. For enumerations type, the enum name use camel case, E.G. `IpVersion` | ||
8. The field of enum use full capital with underscore case, and the enum name use as the prefix for each field. E.G. | ||
`IP_VERSION_IPV4` | ||
|
||
## Redis DB | ||
|
||
1. Table name will be full capital with underscore. And the prefix `DASH` and postfix `Table` will be added to entry name. E.G. `DASH_VNET_MAPPING_TABLE` | ||
2. The key message is sequentially joint as the Redis key with colon separator. E.G. `AclRuleKey{group_id=group1, rule_num=3}`, the key of Redis entry will be `DASH_ACL_RULE_TABLE:group1:3` | ||
3. The value is the entry message with the bytes array of protobuf | ||
|
||
## GNMI | ||
|
||
TODO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
syntax = "proto3"; | ||
|
||
package dash.acl_group; | ||
|
||
import "types.proto"; | ||
|
||
message AclGroup { | ||
types.IpVersion ip_version = 1; | ||
types.Guid guid = 2; | ||
} | ||
|
||
message AclGroupKey { | ||
string group_id = 1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
syntax = "proto3"; | ||
|
||
package dash.acl_in; | ||
|
||
message AclIn { | ||
// Optional | ||
// IPv4 ACL group ID | ||
string v4_acl_group_id = 1; | ||
// Optional | ||
// IPv6 ACL group ID | ||
string v6_acl_group_id = 2; | ||
} | ||
|
||
message AclInKey { | ||
string eni = 1; | ||
// ACL stage can be {1, 2, 3, 4, 5} | ||
uint32 stage = 2; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
syntax = "proto3"; | ||
|
||
package dash.acl_out; | ||
|
||
message AclOut { | ||
// Optional | ||
// IPv4 ACL group ID | ||
string v4_acl_group_id = 1; | ||
// Optional | ||
// IPv6 ACL group ID | ||
string v6_acl_group_id = 2; | ||
} | ||
|
||
message AclOutKey { | ||
string eni = 1; | ||
// ACL stage can be {1, 2, 3, 4, 5} | ||
uint32 stage = 2; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
syntax = "proto3"; | ||
|
||
package dash.acl_rule; | ||
|
||
import "types.proto"; | ||
|
||
enum Action { | ||
ACTION_DENY = 0; | ||
ACTION_PERMIT = 1; | ||
} | ||
|
||
message AclRule { | ||
// priority of the rule, lower the value, higher the priority | ||
uint32 priority = 1; | ||
// allow/deny | ||
acl_rule.Action action = 2; | ||
// true/false ; if true, stop processing further rules | ||
bool terminating = 3; | ||
// Optional | ||
// Protocol list. E.g. 6-tcp, 17-udp; if not provided, match on all protocols | ||
repeated uint32 protocol = 4; | ||
// Optional | ||
// list of source tag name, if not provided, match on ANY tag or NO tag. | ||
repeated string src_tag = 9; | ||
// Optional | ||
// list of destination tag name, if not provided, match on ANY tag or NO tag. | ||
repeated string dst_tag = 10; | ||
// Optional | ||
// list of source ip prefixes, if not provided, match on all source IPs. | ||
repeated types.IpPrefix src_addr = 5; | ||
// Optional | ||
// list of destination ip prefixes, if not provided, match on all destination IPs. | ||
repeated types.IpPrefix dst_addr = 6; | ||
// Optional | ||
// list of range of source ports, if not provided, match on all source ports. | ||
repeated types.ValueOrRange src_port = 7; | ||
// Optional | ||
// list of range of destination ports, if not provided, match on all destination ports. | ||
repeated types.ValueOrRange dst_port = 8; | ||
} | ||
|
||
message AclRuleKey { | ||
string group_id = 1; | ||
// unique rule num within the group. | ||
uint32 rule_num = 2; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
syntax = "proto3"; | ||
|
||
package dash.appliance; | ||
|
||
import "types.proto"; | ||
|
||
message Appliance { | ||
// source ip address, to be used in encap | ||
types.IpAddress sip = 1; | ||
// VM VNI that is used for setting direction. Also used for inbound encap to VM | ||
uint32 vm_vni = 2; | ||
} | ||
|
||
message ApplianceKey { | ||
// Attributes specific for the appliance | ||
string appliance_id = 1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
syntax = "proto3"; | ||
|
||
package dash.eni; | ||
|
||
import "types.proto"; | ||
|
||
enum State{ | ||
STATE_DISABLED = 0; | ||
STATE_ENABLED = 1; | ||
} | ||
|
||
message Eni { | ||
string eni_id = 1; | ||
bytes mac_address = 2; | ||
// Associated Qos profile | ||
string qos = 3; | ||
// PA address for Inbound encapsulation to VM | ||
types.IpAddress underlay_ip = 4; | ||
// Enabled after all configurations are applied | ||
eni.State admin_state = 5; | ||
// Vnet that ENI belongs to | ||
string vnet = 6; | ||
// Optional | ||
// Private Link encoding for IPv6 SIP transpositions | ||
optional types.IpPrefix pl_sip_encoding = 7; | ||
// Optional | ||
// Underlay SIP (ST GW VIP) to be used for all private link transformation for this ENI | ||
optional types.IpAddress pl_underlay_sip = 8; | ||
// Optional | ||
// IPv4 meter policy ID | ||
optional string v4_meter_policy_id = 9; | ||
// Optional | ||
// IPv6 meter policy ID | ||
optional string v6_meter_policy_id = 10; | ||
} | ||
|
||
message EniKey { | ||
// ENI MAC as key | ||
string eni = 1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
syntax = "proto3"; | ||
|
||
package dash.meter_rule; | ||
|
||
message Meter { | ||
// Optional | ||
optional string metadata = 1; | ||
// Number of transmitted bytes (read-only) | ||
bytes tx_counter = 2; | ||
// Number of received bytes (read-only) | ||
bytes rx_counter = 3; | ||
} | ||
|
||
message MeterKey { | ||
string eni = 1; | ||
// metering class id table per (ENI) | ||
uint64 metering_class_id = 2; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
syntax = "proto3"; | ||
|
||
package dash.meter_policy; | ||
|
||
import "types.proto"; | ||
|
||
message MeterPolicy { | ||
// IP version (IPv4/IPv6) | ||
types.IpVersion ip_version = 1; | ||
} | ||
|
||
message MeterPolicyKey { | ||
string meter_policy_id = 1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
syntax = "proto3"; | ||
|
||
package dash.meter_rule; | ||
|
||
import "types.proto"; | ||
|
||
message MeterRule { | ||
// priority of the rule: lower the value, higher the priority | ||
uint32 priority = 1; | ||
// ip prefix for matching | ||
types.IpPrefix ip_prefix = 2; | ||
uint64 metering_class = 3; | ||
} | ||
|
||
message MeterRuleKey { | ||
string meter_policy_id = 1; | ||
uint32 rule_num = 2; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
syntax = "proto3"; | ||
|
||
package dash.tag; | ||
|
||
import "types.proto"; | ||
|
||
message PrefixTag { | ||
types.IpVersion ip_version = 1; | ||
// valid to have empty list of prefixes. | ||
// If the prefix is empty, no packet will be assigned to this TAG. | ||
repeated types.IpPrefix prefix_list = 2; | ||
} | ||
|
||
message PrefixTagKey { | ||
string tag_name = 1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
syntax = "proto3"; | ||
|
||
package dash.qos; | ||
|
||
message Qos { | ||
string qos_id = 1; | ||
// bandwidth in kbps | ||
uint32 bw = 2; | ||
// Number of connection per second | ||
uint32 cps = 3; | ||
// Number of flows | ||
uint32 flows = 4; | ||
} | ||
|
||
message QosKey { | ||
string qos_name = 1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
syntax = "proto3"; | ||
|
||
package dash.route_lpm; | ||
|
||
import "types.proto"; | ||
import "route_type.proto"; | ||
|
||
message VnetDirect { | ||
// destination vnet name if action_type is {vnet, vnet_direct}, a vnet other than eni's vnet means vnet peering | ||
string vnet = 1; | ||
// overly_ip to lookup if routing_type is {vnet_direct}, use dst ip from packet if not specified | ||
optional types.IpAddress overlay_ip = 2; | ||
} | ||
|
||
message ServiceTunnel { | ||
// overlay ipv6 src ip if routing_type is {servicetunnel} | ||
types.IpAddress overlay_sip = 1; | ||
// overlay ipv6 dst ip if routing_type is {servicetunnel} | ||
types.IpAddress overlay_dip = 2; | ||
// underlay ipv4 src ip if routing_type is {servicetunnel}, this is the ST GW VIP (for ST traffic) or custom VIP | ||
types.IpAddress underlay_sip = 3; | ||
// underlay ipv4 dst ip to override if routing_type is {servicetunnel}, use dst ip from packet if not specified | ||
types.IpAddress underlay_dip = 4; | ||
} | ||
|
||
message Route { | ||
route_type.RoutingType action_type = 1; | ||
oneof Action { | ||
// destination vnet name if action_type is vnet,, a vnet other than eni's vnet means vnet peering | ||
string vnet = 2; | ||
// destination vnet name if action_type is vnet_direct,, a vnet other than eni's vnet means vnet peering | ||
string vnet_direct = 3; | ||
// appliance id if action_type is {appliance} | ||
string appliance = 4; | ||
// service tunnel if action_type is {service_tunnel} | ||
route_lpm.ServiceTunnel service_tunnel = 5; | ||
} | ||
// Metering policy lookup enable (optional), default = false | ||
optional bool metering_policy_en = 6; | ||
// Metering class-id, used if metering policy lookup is not enabled | ||
optional uint64 metering_class = 7; | ||
} | ||
|
||
// ENI route table with CA prefix for packet Outbound | ||
message RouteKey { | ||
string eni = 1; | ||
// IP prefix string with prefix length. E.G. 10.1.0.0/16 | ||
string prefix = 2; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
syntax = "proto3"; | ||
|
||
package dash.route_rule; | ||
|
||
import "route_type.proto"; | ||
|
||
message RouteRule { | ||
// reference to routing type, action can be decap or drop | ||
route_type.RoutingType action_type = 1; | ||
// priority of the rule, lower the value, higher the priority | ||
uint32 priority = 2; | ||
// Optional | ||
// protocol value of incoming packet to match; 0 (any) | ||
optional uint32 protocol = 3; | ||
// Optional | ||
// mapped VNET for the key vni/pa | ||
optional string vnet = 4; | ||
// Optional | ||
// perform PA validation in the mapping table belonging to vnet_name. Default is set to true | ||
optional bool pa_validation = 5; | ||
// Optional | ||
// Metering class-id | ||
optional uint64 metering_class = 6; | ||
// Optional | ||
// optional region_id which the vni/prefix belongs to as a string for any vendor optimizations | ||
optional string region = 7; | ||
} | ||
|
||
// ENI Inbound route table with VNI and optional SRC PA prefix | ||
message RouteRuleKey { | ||
string eni = 1; | ||
uint32 vni = 2; | ||
// IP prefix string with prefix length. E.G. 10.1.0.0/16 | ||
string prefix = 3; | ||
}; |
Oops, something went wrong.