Skip to content

Commit

Permalink
[tc-filter]: add nat action, change action to container to hold both …
Browse files Browse the repository at this point in the history
…nat and gact actions

Signed-off-by: ali-aqrabawi <aaqrabaw@okdanetworks.com>
  • Loading branch information
Ali-aqrabawi committed Aug 8, 2024
1 parent 4452278 commit 9beae6f
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 17 deletions.
33 changes: 25 additions & 8 deletions tests/cases/test_tc_filter_data.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@
<src_ip>1.1.1.1/32</src_ip>
</match>
<classid>8001:20</classid>
<action>pass</action>
<actions>
<gact>pass</gact>
</actions>

</flower>
</rule>
<rule>
Expand All @@ -54,7 +57,9 @@
<src_ip>5.5.5.5/32</src_ip>
</match>
<classid>8001:30</classid>
<action>pass</action>
<actions>
<gact>pass</gact>
</actions>
</flower>
</rule>
<rule>
Expand All @@ -64,7 +69,9 @@
<dst_ip>9.9.9.0/24</dst_ip>
</match>
<classid>8001:40</classid>
<action>pass</action>
<actions>
<gact>pass</gact>
</actions>
</flower>
</rule>
</qdisc-filter>
Expand Down Expand Up @@ -95,13 +102,17 @@
<ip_proto>icmp</ip_proto>
<src_ip>1.2.1.2/32</src_ip>
</match>
<action>pass</action>
<actions>
<gact>pass</gact>
</actions>
</flower>
</rule>
<rule>
<pref>20</pref>
<flower>
<action>drop</action>
<actions>
<gact>drop</gact>
</actions>
</flower>
</rule>
</dev-filter>
Expand All @@ -116,13 +127,17 @@
<ip_proto>icmp</ip_proto>
<src_ip>11.21.11.21/32</src_ip>
</match>
<action>pass</action>
<actions>
<gact>pass</gact>
</actions>
</flower>
</rule>
<rule>
<pref>201</pref>
<flower>
<action>drop</action>
<actions>
<gact>drop</gact>
</actions>
</flower>
</rule>
</dev-filter>
Expand All @@ -132,7 +147,9 @@
<rule>
<pref>10</pref>
<flower>
<action>pass</action>
<actions>
<gact>pass</gact>
</actions>
</flower>
</rule>
</shared-block-filter>
Expand Down
55 changes: 46 additions & 9 deletions yang/iproute2-tc-filter.yang
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,53 @@ module iproute2-tc-filter {
is in the form X:Y, while X and Y are interpreted as
numbers in hexadecimal format.";
}
leaf action {
type enumeration {
enum "pass";
enum "drop";
enum "reclassify";
enum "continue";
enum "pipe";

container actions {
leaf gact {
ipr2cgen:arg-name "action";
type enumeration {
enum "pass";
enum "drop";
enum "reclassify";
enum "continue";
enum "pipe";
}
description
"specify action";
}
container nat {
leaf direction {
ipr2cgen:arg-name "action nat ";
must "../old_ip and ../new_ip"{
error-message "direction, old_ip and new_ip are mandatory for nat action.";
}
type enumeration {
enum "ingress";
enum "egress";
}
description "NAT direction";
}
leaf old_ip {
ipr2cgen:value-only;
must "../direction and ../new_ip"{
error-message "direction, old_ip and new_ip are mandatory for nat action.";
}
type union {
type inet:ip-address;
type inet:ip-prefix;
}
description "original ip";
}
leaf new_ip {
ipr2cgen:value-only;
must "../direction and ../old_ip"{
error-message "direction, old_ip and new_ip are mandatory for nat action.";
}
type inet:ip-address;
description "natted ip";
}

}
description
"specify action";
}
}
grouping filter-rule{
Expand Down

0 comments on commit 9beae6f

Please sign in to comment.