Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp5177493rwb; Wed, 21 Sep 2022 04:24:41 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5A9zU38q17TNkpWXYaHCDbyy1r/NzRUw5P5Mqo+fqlMBA90Kr5fijPEt4IOtSjbi3mn+1x X-Received: by 2002:a05:6402:274c:b0:44f:334e:1e11 with SMTP id z12-20020a056402274c00b0044f334e1e11mr24608781edd.304.1663759481206; Wed, 21 Sep 2022 04:24:41 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1663759481; cv=pass; d=google.com; s=arc-20160816; b=NnKlJhF5e+i8lgcsiK6lve20FzJRFfKzUBJPGyRDlOTvACqGptjotDY3IBK7wKO69j ZOdAA/MLVxSqfvZJK6KjE/KXKCb1QaKHVgKquQxaPQk+z73y14/mxShXCJuTth4r5p7z 7kIdduJKXimmqvpz5rcHIgcmYOQtOMEwdOcqqkX8qjFt4TKtBVPxPAuN9p4hwG4JEPmx KWM03Am3EAXXcJi1yJXTAJ/bTCXfZ+ghV+96G/G6k36IXU+5alQyhK4So58YfxsCWbiG iCmf4o8mqKkhn8wt2xh21jqxyTyuZV1Vadjp6WluxK+CFlEPc9h7KmQat85aVYroVy0I 6TpQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :message-id:date:subject:cc:to:from:dkim-signature; bh=un/6I1sRvo0IXfChoTh3yl4ieXK02BsG7ppods++toE=; b=W/m0y/hXMVIDsQlxLqZaBoVdwR+dx2ZgY3KI2iRXd8Q7LyDe+Sk1PePXj3xOKDonYl z1w+46X+NVQpxQdVT5EPoAHxJx2Nnr4w/8ToHpwOqCHVEHKDGTvu4CAAodjdcTkJYpzJ xBaeJOvn5QGAaCXEcI13qnwPEVZLIxgBIEbLLEq/dcqnjSBFSkApcLMTl+IMA7549nos Lo4tpamnTWGM8bOQnBGLt+SGOW7mZFRr/Z5TnoHHfmQ38d7MbkrzfSKuSu62vBuN7ZYZ tJ6UqLDtOSdJ9RUtfXxpm+C5WpFxxRZFEGijl2gJzBlntZXFUe4PSL5OyEFNWO2PI/vW LqcA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@hotmail.com header.s=selector1 header.b=lw0gnn3w; arc=pass (i=1); spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=hotmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qf28-20020a1709077f1c00b0073056870528si2571557ejc.888.2022.09.21.04.24.14; Wed, 21 Sep 2022 04:24:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@hotmail.com header.s=selector1 header.b=lw0gnn3w; arc=pass (i=1); spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=hotmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229521AbiIULRi (ORCPT + 99 others); Wed, 21 Sep 2022 07:17:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56234 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229498AbiIULRh (ORCPT ); Wed, 21 Sep 2022 07:17:37 -0400 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05olkn2072.outbound.protection.outlook.com [40.92.89.72]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7E84C474DF for ; Wed, 21 Sep 2022 04:17:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iRrufS0PwTIxbP+Bne5WHr7UbmMRgt+UG17AVYzqwqsTCZxSSw4C3Po0uv35X16spB9hAnn3ZLFIzZ4tsgUbmCsLU1VqcG63HVRJkhQqvZSPjEdOiHwYbPUAsaEfHEqQuct0kFa+pgPD8/ld2DXbW8SxTwtpNxQD1q5iSKnMMVV6tEoDEF5rCUoViE9TCUGSZVL9H/xV0myiA4EsxUTVwXRaf7jhViQLT4yr6JhHu367C7yRGWQAclCMu7q+UeEtIXRVs6qPJ4BhvihmzwTHH9MmmibG/39PEJMxGMHZPQ7XtV5NSQsGrcyBE4fH5Tgj4VeL0A68qARVjWlMoClamA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=un/6I1sRvo0IXfChoTh3yl4ieXK02BsG7ppods++toE=; b=oAUGaGvj1fNBNw45lWPL119ZdRatFg5f3vjGJ9nXgilqIo/D8ljZUyyvJyfq7mG1hH1kZZBU4E9FxTxJp/QF7ES89lPplIXmgtpzYv6I5hRry3D0hn7t4lcIQ+0gSoNZAx6xBjCNQ5naXX3rtcmRdBMS0Izo69yGHkpTHaBrTNJT3nt9bX+x6vBZ6/RpcfPsr28sMDSPBygQsbhiP4Q2BcI1djqJ3gj64uT5Ic9BvoqKYCj2v3N4ofGttItnCXTw7+1qyEtZTTnFDebXD5gAOKl/IdjcVGqhf0B1b98cNwM0Y6Opg+n9CdgWO9YPgEdAKjnda6+xVkX2IqD7OASqMg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hotmail.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=un/6I1sRvo0IXfChoTh3yl4ieXK02BsG7ppods++toE=; b=lw0gnn3wmo0BlvYb8gBOkoblDQyTvMNIj9f9uRtCvNt+EdaF4y3FWPWHsvbSt3US2lvYuBEgXIQVrKlTUHZgF+Isc2Vc3fqqwJtbGVVTP0HrhfC0Jcv7wriO+8f5PSGXsb8NiqdQlr/4h87yteM2udSKUfvpyWVaGsXJ7EtdUa8HrkM9fM2X4eBdkWVnFjdJrwmFa0DRUMJTG0kioJWwqLZfKVVe0TYv2Sx3+8K1xzgHGAJ916H+Rk0Td1uh67PTDpIy1xTymhf+dPWzfyg4Yna/5h5vBK/Zhne6u6ZjKqeKviDnSv4p0YvyvNvyvD5BFk6LHWGMo/KAgX5CREcGqw== Received: from VI1PR09MB4239.eurprd09.prod.outlook.com (2603:10a6:800:12f::23) by PR3PR09MB5361.eurprd09.prod.outlook.com (2603:10a6:102:178::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5632.18; Wed, 21 Sep 2022 11:17:34 +0000 Received: from VI1PR09MB4239.eurprd09.prod.outlook.com ([fe80::adeb:7a9b:9960:27bf]) by VI1PR09MB4239.eurprd09.prod.outlook.com ([fe80::adeb:7a9b:9960:27bf%2]) with mapi id 15.20.5632.021; Wed, 21 Sep 2022 11:17:34 +0000 From: Isak Westin To: linux-bluetooth@vger.kernel.org Cc: Isak Westin Subject: [PATCH BlueZ v2 1/3] mesh: Add interface output filter Date: Wed, 21 Sep 2022 13:16:28 +0200 Message-ID: X-Mailer: git-send-email 2.20.1 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-TMN: [Yqm0oVuzcWaAYLyiIkJlT0Gx/Ae0Wjh1] X-ClientProxiedBy: ZRAP278CA0017.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:10::27) To VI1PR09MB4239.eurprd09.prod.outlook.com (2603:10a6:800:12f::23) X-Microsoft-Original-Message-ID: <20220921111630.23589-1-isak.westin@hotmail.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR09MB4239:EE_|PR3PR09MB5361:EE_ X-MS-Office365-Filtering-Correlation-Id: 60599494-9dd3-4faa-bb7b-08da9bc2e1fb X-MS-Exchange-SLBlob-MailProps: ZILSnhm0P3lUkjXuSDdeTQka1McTh6g4T9kseV1SDoA75ob2ERencravVQwr6+olSKJ23MJOXZJ0b66FXNNpoEUs+fN1kv/rLUFiXylS/EKYTISaRLwAJqKVTuJZ4MItWZDatfyUo/Wr9+AI5TFO9TFJ1Mga+QMERXXpwcW5QId8ZCr45exJYQAey3GhtkRLOaKUyNAqzbdKr4d1WT+xkE7JWw9S8KwyhMNy7KV02WXqcYTIHOm25LI7JE1JpvNMhykG7BNiq11B7M16EFNud6IQ/CBb9Y4ijMzw3VBOMmVwAcRK/d7pydi8rxAb/9wltb8Dyj3HmCWQDvIAvNdezj8jq29/42MrSMO+2f3BoJL0f5xMzOE8F/DdgrnDOx67yyTwSQwpOCk9vGRk2cM8UPFc6QjoRRdk2L8wzPLvCI05jc+w1Pp0KOyih0zvqjM/SVGAnu1zUr4uI6feuv7gwY7MVC3gmHZ6imMn2no/lT0/VdA1lhb7ch0z8tU/e/Hil2/slwR9iHkkpe5Hn6btmfru67B8EVPOTTl3oGH+GSCCSLRpm4fxy0RtRzJQE7+L0tskBbJuen4FyyjA3P+wkIWhLP8BRlposGfPZCfzB2Ik/2ob82EGPaxbDEm4KS6bRp58m8Wnu5A/ycF0LZOmmh+bFQirsVOuN5dldypLICqdEDQfreax0l3aiJRhBwrKbHiUygtx9PcywaHiu66wBRfdrrAUBD8q5HQhzt66pCRWD+T7CZWvCnpYYmN08d+Er2hWgOnyMvHuss+8aFZSgJ6b0I0fTTW/ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: pP41nbAvmoF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eZqUhs0vWzBbLzUm+KoSLdHdCT1Ro8tYuNkLj2?= =?us-ascii?Q?0EwQV2bVmYmMGEgegn06A1oA81qBh7U+Y+ITP8InZ2/diCwluvzTaoM238nU?= =?us-ascii?Q?uGkkIfb5dZLsoDlA9//TACLGT0cJdSuPYgkMKRJ1wA=3D=3D?= X-OriginatorOrg: sct-15-20-4755-11-msonline-outlook-64da6.templateTenant X-MS-Exchange-CrossTenant-Network-Message-Id: 60599494-9dd3-4faa-bb7b-08da9bc2e1fb X-MS-Exchange-CrossTenant-AuthSource: VI1PR09MB4239.eurprd09.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Sep 2022 11:17:34.6803 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR3PR09MB5361 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org According to the mesh profile (3.4.5.2), if TTL is set to 1 for an outgoing message, that message shall be dropped. --- mesh/net.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/mesh/net.c b/mesh/net.c index e8e6d3a61..699469284 100644 --- a/mesh/net.c +++ b/mesh/net.c @@ -3067,6 +3067,13 @@ void mesh_net_send_seg(struct mesh_net *net, uint32_t net_key_id, uint8_t segO = (hdr >> SEGO_HDR_SHIFT) & SEG_MASK; uint8_t segN = (hdr >> SEGN_HDR_SHIFT) & SEG_MASK; + /* + * MshPRFv1.0.1 section 3.4.5.2, Interface output filter: + * If TTL is set to 1, message shall be dropped. + */ + if (ttl == 1) + return; + /* TODO: Only used for current POLLed segments to LPNs */ l_debug("SEQ: %6.6x", seq + segO); @@ -3135,6 +3142,13 @@ bool mesh_net_app_send(struct mesh_net *net, bool frnd_cred, uint16_t src, (dst >= net->src_addr && dst <= net->last_addr)) return true; + /* + * MshPRFv1.0.1 section 3.4.5.2, Interface output filter: + * If TTL is set to 1, message shall be dropped. + */ + if (ttl == 1) + return true; + /* Setup OTA Network send */ payload = mesh_sar_new(msg_len); memcpy(payload->buf, msg, msg_len); @@ -3206,6 +3220,13 @@ void mesh_net_ack_send(struct mesh_net *net, uint32_t net_key_id, uint8_t pkt_len; uint8_t pkt[30]; + /* + * MshPRFv1.0.1 section 3.4.5.2, Interface output filter: + * If TTL is set to 1, message shall be dropped. + */ + if (ttl == 1) + return; + hdr = NET_OP_SEG_ACKNOWLEDGE << OPCODE_HDR_SHIFT; hdr |= rly << RELAY_HDR_SHIFT; hdr |= (seqZero & SEQ_ZERO_MASK) << SEQ_ZERO_HDR_SHIFT; @@ -3264,6 +3285,13 @@ void mesh_net_transport_send(struct mesh_net *net, uint32_t net_key_id, if (*msg & 0xc0 || (9 + msg_len + 8 > 29)) return; + /* + * MshPRFv1.0.1 section 3.4.5.2, Interface output filter: + * If TTL is set to 1, message shall be dropped. + */ + if (ttl == 1) + return; + /* Enqueue for Friend if forwardable and from us */ if (!net_key_id && src >= net->src_addr && src <= net->last_addr) { uint32_t hdr = msg[0] << OPCODE_HDR_SHIFT; -- 2.20.1