From d276884206b33f112570e54658411aa423ef630e Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Mon, 27 Jun 2022 11:19:20 +0200 Subject: platform: fix routing rule test failure Since kernel 5.18 there is a stricter validation [1][2] on the tos field of routing rules, that must not include ECN bits. [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=f55fbb6afb8d701e3185e31e73f5ea9503a66744 [2] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=a410a0cf98854a698a519bfbeb604145da384c0e Fixes the following failure: >>> src/core/platform/tests/test-route-linux >>> ... # NetworkManager-MESSAGE: [1656321515.6604] platform-linux: do-add-rule: failure 22 (Invalid argument - Invalid dsfield (tos): ECN bits must be 0) >>> failing... errno=-22, rule=[routing-rule,0x13d6e80,1,+alive,+visible; [6] 0: from all tos 0xff fwmark 0x4/0 suppress_prefixlen -459579276 action-214 protocol 255] >>> existing rule: * [routing-rule,0x13d71e0,2,+alive,+visible; [6] 0: from all sport 65534 lookup 10009 suppress_prefixlen 0 none] >>> existing rule: [routing-rule,0x13d7280,2,+alive,+visible; [4] 0: from all fwmark 0/0x9a7e9992 ipproto 255 suppress_prefixlen 0 realms 0x00000008 none protocol 71] >>> existing rule: [routing-rule,0x13d7320,2,+alive,+visible; [6] 598928157: from all suppress_prefixlen 0 none] >>> existing rule: [routing-rule,0x13d73c0,2,+alive,+visible; [4] 0: from 192.192.5.200/8 lookup 254 suppress_prefixlen 0 none protocol 9] >>> existing rule: [routing-rule,0x13d7460,2,+alive,+visible; [4] 0: from all ipproto 3 suppress_prefixlen 0 realms 0xffffffff none protocol 5] >>> existing rule: [routing-rule,0x13d7500,2,+alive,+visible; [4] 0: from all fwmark 0x1/0 lookup 254 suppress_prefixlen 0 action-124 protocol 4] >>> existing rule: [routing-rule,0x13d75a0,2,+alive,+visible; [4] 0: from all suppress_prefixlen 0 action-109] 0: from all fwmark 0/0x9a7e9992 ipproto ipproto-255 realms 8 none proto 71 0: from 192.192.5.200/8 lookup main suppress_prefixlength 0 none proto ra 0: from all ipproto ggp realms 65535/65535 none proto 5 0: from all fwmark 0x1/0 lookup main suppress_prefixlength 0 124 proto static 0: from all 109 0: from all sport 65534 lookup 10009 suppress_prefixlength 0 none 598928157: from all none Bail out! nm:ERROR:../src/core/platform/tests/test-route.c:1787:test_rule: assertion failed (r == 0): (-22 == 0) Fixes: 5ae2431b0f9e ('platform/tests: add tests for handling policy routing rules') (cherry picked from commit bf9a2babb47caa11e13a2268ad88943812f83634) (cherry picked from commit 09b0014a0170565c1bdbe8b39a00f0dbdd19abf6) (cherry picked from commit e1266b3b12f95e4c985dcc680543c0343dceb062) (cherry picked from commit 8da69be278a3a3d760452658a97ac9b84a436939) --- src/core/platform/tests/test-route.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/core/platform/tests/test-route.c b/src/core/platform/tests/test-route.c index 4b1db7fad7..297230e2e4 100644 --- a/src/core/platform/tests/test-route.c +++ b/src/core/platform/tests/test-route.c @@ -1398,12 +1398,17 @@ again_table: rr->protocol = _rr_rand_choose_u8(nmtst_get_rand_uint32()); #define IPTOS_TOS_MASK 0x1E +#define INET_DSCP_MASK 0xFC again_tos: rr->tos = _rr_rand_choose_u8(nmtst_get_rand_uint32()); + if (rr->addr_family == AF_INET && rr->tos & ~IPTOS_TOS_MASK) goto again_tos; + if (rr->tos & ~INET_DSCP_MASK) + goto again_tos; + if (_rule_check_kernel_support(platform, FRA_IP_PROTO)) rr->ip_proto = _rr_rand_choose_u8(nmtst_get_rand_uint32()); -- cgit v1.2.1