nftables: Add support for reserved header and addrs for routing header type 0
PATCH v2 1/1 nftables: Add support for reserved header and addrs for routing header type 0
Add support for IPV6 routing header type 0 reserved field and addresses with corresponding tests
---
For struct exthdr_rt0, I have specified type to be IPPROTO_ROUTING due to which when exthdr_init_raw is called in exthdr_find_template which initialises expr->exthdr.desc to exthdr_protocols[type] and that will be $exthdr_rt and not &exthdr_rt0, when testing the testcases this warning comes 'rt0 rserved 2' mismatches 'rt unknown 0x2' and same for the addrs. Fot this one possible way is to define IPPROTO_ROUTING0 in header file in /usr/include/. Can anyone please suggest what will be the best way to fix these warnings ? I'll add more testcases once these warnings are fixed. Thanks.
Changes in v2:
-Changed log message
-Added tests and removed errors but warning is still there
include/exthdr.h | 2 ++ src/exthdr.c | 4 ++-- src/parser_bison.y | 6 ++---- tests/py/ip6/rt0.t | 4 ++++ tests/py/ip6/rt0.t.payload | 14 ++++++++++++++ 5 files changed, 24 insertions(+), 6 deletions(-)
include/exthdr.h +2 -0
@@ -14,6 +14,8 @@struct exthdr_desc {const char *name;uint8_t type; +unsigned int protocol_key; +const struct exthdr_desc *protocols[3 ];struct proto_hdr_template templates[10 ]; };
src/exthdr.c +2 -2
@@ -246,6 +246,8 @@ const struct exthdr_desc exthdr_rt2 = { HDR_TEMPLATE(__name, __dtype, struct ip6_rthdr0, __member)const struct exthdr_desc exthdr_rt0 = { + .name ="rt0" , + .type =IPPROTO_ROUTING , .templates = { [RT0HDR_RESERVED ] =RT0_FIELD ("reserved" , ip6r0_reserved, &integer_type), [RT0HDR_ADDR_1 ] =RT0_FIELD ("addr[1]" , ip6r0_addr[0 ], &ip6addr_type),
@@ -260,13 +262,11 @@ const struct exthdr_desc exthdr_rt0 = {const struct exthdr_desc exthdr_rt = { .name ="rt" , .type =IPPROTO_ROUTING , -#if 0 .protocol_key =RTHDR_TYPE , .protocols = { [0 ] = &exthdr_rt0, [2 ] = &exthdr_rt2, }, -#endif .templates = { [RTHDR_NEXTHDR ] =RT_FIELD ("nexthdr" , ip6r_nxt, &inet_protocol_type), [RTHDR_HDRLENGTH ] =RT_FIELD ("hdrlength" , ip6r_len, &integer_type),
src/parser_bison.y +2 -4
@@ -3697,10 +3697,8 @@ rt0_hdr_expr : RT0 rt0_hdr_field } ; -rt0_hdr_field : ADDR '[' NUM ']' - { - $$ = RT0HDR_ADDR_1 + $3 - 1; - } +rt0_hdr_field : ADDR'['NUM']' { $$ = RT0HDR_ADDR_1 + $3 - 1;} + | RESERVED { $$ = RT0HDR_RESERVED; } ; rt2_hdr_expr : RT2 rt2_hdr_field
tests/py/ip6/rt0.t +4 -0
@@ -4,3 +4,7 @@ rt nexthop 192.168.0.1;fail rt nexthop fd00::1;ok;rt ip6 nexthop fd00::1 + +rt0 reserved 2;ok +rt0 addr [1] 2001:db8:0:1:1:1:1:1;ok +rt0 addr [2] 2001:db8:0:0:0:0:1:1;ok
tests/py/ip6/rt0.t.payload +14 -0
@@ -3,3 +3,17 @@ ip6 test-ip6 output [ rt load nexthop6 => reg 1 ] [ cmp eq reg 1 0x000000fd 0x00000000 0x00000000 0x01000000 ] +# rt0 reserved 2 +ip6 test-ip6 output + [ exthdr load 1b @ 43 + 4 => reg 1 ] + [ cmp eq reg 1 0x00000002 ] + +# rt0 addr [1] 2001:db8:0:1:1:1:1:1 +ip6 test-ip6 output + [ exthdr load 16b @ 43 + 8 => reg 1 ] + [ cmp eq reg 1 0xb80d0120 0x01000000 0x01000100 0x01000100 ] + +# rt0 addr [2] 2001:db8:0:0:0:0:1:1 +ip6 test-ip6 output + [ exthdr load 16b @ 43 + 8 => reg 1 ] + [ cmp eq reg 1 0xb80d0120 0x00000000 0x00000000 0x01000100 ]
Signature · 1 line
2.11.0
Quoted 108 lines · Harsha Sharma
Add support for IPV6 routing header type 0 reserved field and addresses with corresponding tests
Signed-off-by Harsha Sharma <[email protected]>---
For structexthdr_rt0, I have specified type to beIPPROTO_ROUTINGdue to which whenexthdr_init_rawis called inexthdr_find_templatewhich initialisesexpr->exthdr.descto exthdr_protocols[type] and that will be $exthdr_rt and not&exthdr_rt0, when testing the testcases this warning comes 'rt0 rserved 2' mismatches 'rt unknown0x2' and same for the addrs. Fot this one possible way is to defineIPPROTO_ROUTING0in header file in/usr/include/. Can anyone please suggest what will be the best way to fix these warnings ? I'll add more testcases once these warnings are fixed. Thanks.Changes in v2:
-Changed log message
-Added tests and removed errors but warning is still thereinclude/exthdr.h | 2 ++ src/exthdr.c | 4 ++-- src/parser_bison.y | 6 ++---- tests/py/ip6/rt0.t | 4 ++++ tests/py/ip6/rt0.t.payload | 14 ++++++++++++++ 5 files changed, 24 insertions(+), 6 deletions(-)include/exthdr.h +2
-0@@ -14,6 +14,8 @@struct exthdr_desc {const char *name;uint8_t type; +unsigned int protocol_key; +const struct exthdr_desc *protocols[3 ];struct proto_hdr_template templates[10 ]; };src/exthdr.c +2
-2@@ -246,6 +246,8 @@ const struct exthdr_desc exthdr_rt2 = { HDR_TEMPLATE(__name, __dtype, struct ip6_rthdr0, __member)const struct exthdr_desc exthdr_rt0 = { + .name ="rt0" , + .type =IPPROTO_ROUTING , .templates = { [RT0HDR_RESERVED ] =RT0_FIELD ("reserved" , ip6r0_reserved, &integer_type), [RT0HDR_ADDR_1 ] =RT0_FIELD ("addr[1]" , ip6r0_addr[0 ], &ip6addr_type),@@ -260,13 +262,11 @@ const struct exthdr_desc exthdr_rt0 = {const struct exthdr_desc exthdr_rt = { .name ="rt" , .type =IPPROTO_ROUTING , -#if 0 .protocol_key =RTHDR_TYPE , .protocols = { [0 ] = &exthdr_rt0, [2 ] = &exthdr_rt2, }, -#endif .templates = { [RTHDR_NEXTHDR ] =RT_FIELD ("nexthdr" , ip6r_nxt, &inet_protocol_type), [RTHDR_HDRLENGTH ] =RT_FIELD ("hdrlength" , ip6r_len, &integer_type),src/parser_bison.y +2
-4@@ -3697,10 +3697,8 @@ rt0_hdr_expr : RT0 rt0_hdr_field } ; -rt0_hdr_field : ADDR '[' NUM ']' - { - $$ = RT0HDR_ADDR_1 + $3 - 1; - } +rt0_hdr_field : ADDR'['NUM']' { $$ = RT0HDR_ADDR_1 + $3 - 1;} + | RESERVED { $$ = RT0HDR_RESERVED; } ; rt2_hdr_expr : RT2 rt2_hdr_fieldtests/py/ip6/rt0.t +4
-0@@ -4,3 +4,7 @@ rt nexthop 192.168.0.1;fail rt nexthop fd00::1;ok;rt ip6 nexthop fd00::1 + +rt0 reserved 2;ok +rt0 addr [1] 2001:db8:0:1:1:1:1:1;ok +rt0 addr [2] 2001:db8:0:0:0:0:1:1;oktests/py/ip6/rt0.t.payload +4
-0@@ -3,3 +3,17 @@ ip6 test-ip6 output [ rt load nexthop6 => reg 1 ] [ cmp eq reg 1 0x000000fd 0x00000000 0x00000000 0x01000000 ] +# rt0 reserved 2 +ip6 test-ip6 output + [ exthdr load 1b @ 43 + 4 => reg 1 ] + [ cmp eq reg 1 0x00000002 ]
tests/py/ip6/rt0.t.payload ip6 test-ip6 output · line 19
Quoted 10 lines
tests/py/ip6/rt0.t.payload +10
-0+ +# rt0 addr [1] 2001:db8:0:1:1:1:1:1 +ip6 test-ip6 output + [ exthdr load 16b @ 43 + 8 => reg 1 ] + [ cmp eq reg 1 0xb80d0120 0x01000000 0x01000100 0x01000100 ] + +# rt0 addr [2] 2001:db8:0:0:0:0:1:1 +ip6 test-ip6 output + [ exthdr load 16b @ 43 + 8 => reg 1 ] + [ cmp eq reg 1 0xb80d0120 0x00000000 0x00000000 0x01000100 ]
Hi,
Any updates on this ?
Thanks for your time.
Regards,
Harsha Sharma
Quoted 3 lines
--
2.11.0