From 9beae6fc58a399d40dec36270533d04ff06e27f6 Mon Sep 17 00:00:00 2001 From: ali-aqrabawi Date: Thu, 8 Aug 2024 21:34:06 +0300 Subject: [PATCH] [tc-filter]: add nat action, change action to container to hold both nat and gact actions Signed-off-by: ali-aqrabawi --- tests/cases/test_tc_filter_data.xml | 33 ++++++++++++----- yang/iproute2-tc-filter.yang | 55 ++++++++++++++++++++++++----- 2 files changed, 71 insertions(+), 17 deletions(-) diff --git a/tests/cases/test_tc_filter_data.xml b/tests/cases/test_tc_filter_data.xml index 498e3b3..d3b299c 100644 --- a/tests/cases/test_tc_filter_data.xml +++ b/tests/cases/test_tc_filter_data.xml @@ -44,7 +44,10 @@ 1.1.1.1/32 8001:20 - pass + + pass + + @@ -54,7 +57,9 @@ 5.5.5.5/32 8001:30 - pass + + pass + @@ -64,7 +69,9 @@ 9.9.9.0/24 8001:40 - pass + + pass + @@ -95,13 +102,17 @@ icmp 1.2.1.2/32 - pass + + pass + 20 - drop + + drop + @@ -116,13 +127,17 @@ icmp 11.21.11.21/32 - pass + + pass + 201 - drop + + drop + @@ -132,7 +147,9 @@ 10 - pass + + pass + diff --git a/yang/iproute2-tc-filter.yang b/yang/iproute2-tc-filter.yang index cc27dc0..b2d671e 100644 --- a/yang/iproute2-tc-filter.yang +++ b/yang/iproute2-tc-filter.yang @@ -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{