From patchwork Fri Nov 1 22:04:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Remi Pommarel X-Patchwork-Id: 18674 X-Patchwork-Delegate: a@unstable.cc Return-Path: X-Original-To: patchwork@open-mesh.org Delivered-To: patchwork@open-mesh.org Received: from diktynna.open-mesh.org (localhost [IPv6:::1]) by diktynna.open-mesh.org (Postfix) with ESMTP id 0749783EF8 for ; Fri, 1 Nov 2024 23:06:35 +0100 (CET) ARC-Seal: i=2; cv=pass; a=rsa-sha256; d=open-mesh.org; s=20121; t=1730498795; b=wgNdaQcfpfAOGIe140AoZDTgDcsElX5G4QhTWmGmq30yd0Bv37eh8tjaOT8LJKBWvcdky /9zNMCd/UmmbnorXMVnt+0ZUSUitELc1DBucaENvwR1Lgxg2j4MR2Zpl0YhTntmqreg+ii3 dQpTpVgX44WBCIKYvVf10YI7knuNNQk= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=open-mesh.org; s=20121; t=1730498795; h=from : sender : reply-to : subject : date : message-id : to : cc : mime-version : content-type : content-transfer-encoding : content-id : content-description : resent-date : resent-from : resent-sender : resent-to : resent-cc : resent-message-id : in-reply-to : references : list-id : list-help : list-unsubscribe : list-subscribe : list-post : list-owner : list-archive; bh=u6z1fpT89DJv+WCGgPTmM9WnXFPOlNs13l5DouQ0kuU=; b=stnbAhNjW7tHdxoG/brEaFxxiIhkcrSjbzB0I4Uzw2jcojc66jB7wSA6363yLQCqDJTd6 8UPiZmEdmMTKisue7HSHPLN774tzLiwgb8y/wKCMgF7vt0Kf78a31GSb9yxqOWYz3z1jbFL DEeMIpXfV80zy4iTpixRYv2WwXbkH4A= ARC-Authentication-Results: i=2; open-mesh.org; dkim=fail header.d=smtpservice.net; arc=pass; dmarc=fail (Used From Domain Record) header.from=triplefau.lt policy.dmarc=quarantine Authentication-Results: open-mesh.org; dkim=fail header.d=smtpservice.net; arc=pass; dmarc=fail (Used From Domain Record) header.from=triplefau.lt policy.dmarc=quarantine Received: from e2i340.smtp2go.com (e2i340.smtp2go.com [103.2.141.84]) by diktynna.open-mesh.org (Postfix) with ESMTPS id 80A858176B for ; Fri, 1 Nov 2024 23:05:41 +0100 (CET) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=open-mesh.org; s=20121; t=1730498742; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=u6z1fpT89DJv+WCGgPTmM9WnXFPOlNs13l5DouQ0kuU=; b=X4FlJ2kiW0XP5zJGy8jPuaMbjMQjuhQiFqEMsmgRjq+EKM+q2U9CIXxbZe9W0PcnmCG9L1 NwWh/h+zHOFP5ACG0qvDfEgdEE0AsWRW0NQ2lRLKbPCVdyTz5UVJP3If7MUMgTUD1ev9QA VBhhfeQg4O8htIgUsLOU3M2+dXmKJbA= ARC-Seal: i=1; s=20121; d=open-mesh.org; t=1730498742; a=rsa-sha256; cv=none; b=dHvXXUBvDkopRbMEC2kBEI/6Y+WzFjPXHM2ojU62pyv3ec8qp+BHEbXoXEpJDOFKtHSc5y MWe7zf1tT6WhGukMEwHNcIg35LLJDSQixWbT3/EYuogmHt33USQzgECTccb6LdF5JVxHBy ku4/t9RjGvZ/QAsJmI8jgMdeqGqsX6A= ARC-Authentication-Results: i=1; diktynna.open-mesh.org; dkim=none ("invalid DKIM record") header.d=smtpservice.net header.s=maxzs0.a1-4.dyn header.b=Pzz57RzQ; dkim=pass header.d=triplefau.lt header.s=s510616 header.b=O+vsLc+u; spf=pass (diktynna.open-mesh.org: domain of "bT.gd4j7je6im3lkx3=qcvergyup0pc=xe1qo0c7976jge@em510616.triplefau.lt" designates 103.2.141.84 as permitted sender) smtp.mailfrom="bT.gd4j7je6im3lkx3=qcvergyup0pc=xe1qo0c7976jge@em510616.triplefau.lt"; dmarc=pass (policy=quarantine) header.from=triplefau.lt DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=smtpservice.net; s=maxzs0.a1-4.dyn; x=1730499641; h=Feedback-ID: X-Smtpcorp-Track:Message-Id:Date:Subject:To:From:Reply-To:Sender: List-Unsubscribe:List-Unsubscribe-Post; bh=u6z1fpT89DJv+WCGgPTmM9WnXFPOlNs13l5DouQ0kuU=; b=Pzz57RzQnna/jZ1xvxfzSCTIKz OQ/xtHfixKFdiCVno1+ynYSWjYqxWtuqmKcJoreO5HeV0ZZ4W4aWCDp20DrkZ2RqZBnXoNpSH1WZ9 se6A5ErlTzIiReMX4s30K9xAABqHBIiwUS2Rr+5YdmAh4+pSLfIkfCtvPs1bnxcH2l65mxu3KiUVi J8y9lHSJypEGHVI025+5FMg+tZS6vIz24drqY2wCxVAOpeXrRSN2/VW8V6CWziX7C153bZ6GbTzV5 bX5ukOKasWLhFVE3xqA/4/5UVtgDD3PhXwPEUm/jul15bkezujFYrYc7AJ7sXl+WQlVoukxKrGyu2 /i6jjdIw==; DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=triplefau.lt; i=@triplefau.lt; q=dns/txt; s=s510616; t=1730498741; h=from : subject : to : message-id : date; bh=u6z1fpT89DJv+WCGgPTmM9WnXFPOlNs13l5DouQ0kuU=; b=O+vsLc+uePYsxRhM5chOWdScMNTHEFFJNOCUckjocff7wCq1oeoA6xFHakwaCQwUbaxc3 HWrzHOrqX/EXCFInYxn3rrwwcifUcB/jMHhJg0Kf6Z7e8z3hb9qs9ISacigVaDS+WKbfokk qxWER96/ri+hEqsFWg1IBYJEE2UULs0APBJ58JE78LVUtezcoborsRk+FmeMFAOw6GQULHJ ayG3Bef1efeJwIZXKWu2p5X73a8cC7RgK1nRso0VtQog6BABKNmYc8yQlZSOsfiMv0JuINm BHGY8jyWg8V22PK0q0cRrLLrvOrdy27BOSzLWnoJTYCmQN7K7ANWQ+MwumZA== Received: from [10.139.162.187] (helo=SmtpCorp) by smtpcorp.com with esmtpsa (TLS1.3:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.94.2-S2G) (envelope-from ) id 1t6zm0-TRk4ix-5M; Fri, 01 Nov 2024 22:05:40 +0000 Received: from [10.12.239.196] (helo=localhost) by smtpcorp.com with esmtpsa (TLS1.3:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.97.1-S2G) (envelope-from ) id 1t6zlz-4o5NDgrjB2u-nxSx; Fri, 01 Nov 2024 22:05:39 +0000 From: Remi Pommarel To: b.a.t.m.a.n@lists.open-mesh.org Cc: Marek Lindner , Simon Wunderlich , Sven Eckelmann , Remi Pommarel Subject: [RFC PATCH 1/4] batman-adv: Do not send uninitialized TT changes Date: Fri, 1 Nov 2024 23:04:59 +0100 Message-Id: X-Mailer: git-send-email 2.40.0 In-Reply-To: References: MIME-Version: 1.0 X-Smtpcorp-Track: RLBjiffkR9U1.wuq7D_IO-IM9.qPcCFwZ05i_ Feedback-ID: 510616m:510616apGKSTK:510616sEG0V39Zeo X-Report-Abuse: Please forward a copy of this message, including all headers, to Message-ID-Hash: YRZVZADUOHDBY2FMMQLHAFB4KEOZDSMK X-Message-ID-Hash: YRZVZADUOHDBY2FMMQLHAFB4KEOZDSMK X-MailFrom: bT.gd4j7je6im3lkx3=qcvergyup0pc=xe1qo0c7976jge@em510616.triplefau.lt X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-b.a.t.m.a.n.lists.open-mesh.org-0; header-match-b.a.t.m.a.n.lists.open-mesh.org-1; header-match-b.a.t.m.a.n.lists.open-mesh.org-2; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: The list for a Better Approach To Mobile Ad-hoc Networking Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: The number of TT changes can be less than initially expected in batadv_tt_tvlv_container_update() (changes can be removed by batadv_tt_local_event() in ADD+DEL sequence between reading tt_diff_entries_num and actually iterating the change list under lock). Thus tt_diff_len could be bigger than the actual changes size that need to be sent. Because batadv_send_my_tt_response sends the whole packet, uninitialized data can be interpreted as TT changes on other nodes leading to weird TT global entries on those nodes such as: * 00:00:00:00:00:00 -1 [....] ( 0) 88:12:4e:ad:7e:ba (179) (0x45845380) * 00:00:00:00:78:79 4092 [.W..] ( 0) 88:12:4e:ad:7e:3c (145) (0x8ebadb8b) All of the above also applies to OGM tvlv container buffer's tvlv_len. Remove the extra allocated space to avoid sending uninitialized TT changes in batadv_send_my_tt_response() and batadv_v_ogm_send_softif(). Fixes: e1bf0c14096f ("batman-adv: tvlv - convert tt data sent within OGMs") Signed-off-by: Remi Pommarel --- net/batman-adv/translation-table.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c index 2243cec18ecc..f0590f9bc2b1 100644 --- a/net/batman-adv/translation-table.c +++ b/net/batman-adv/translation-table.c @@ -990,6 +990,7 @@ static void batadv_tt_tvlv_container_update(struct batadv_priv *bat_priv) int tt_diff_len, tt_change_len = 0; int tt_diff_entries_num = 0; int tt_diff_entries_count = 0; + size_t tt_extra_len = 0; u16 tvlv_len; tt_diff_entries_num = atomic_read(&bat_priv->tt.local_changes); @@ -1027,6 +1028,9 @@ static void batadv_tt_tvlv_container_update(struct batadv_priv *bat_priv) } spin_unlock_bh(&bat_priv->tt.changes_list_lock); + tt_extra_len = batadv_tt_len(tt_diff_entries_num - + tt_diff_entries_count); + /* Keep the buffer for possible tt_request */ spin_lock_bh(&bat_priv->tt.last_changeset_lock); kfree(bat_priv->tt.last_changeset); @@ -1035,6 +1039,7 @@ static void batadv_tt_tvlv_container_update(struct batadv_priv *bat_priv) tt_change_len = batadv_tt_len(tt_diff_entries_count); /* check whether this new OGM has no changes due to size problems */ if (tt_diff_entries_count > 0) { + tt_diff_len -= tt_extra_len; /* if kmalloc() fails we will reply with the full table * instead of providing the diff */ @@ -1047,6 +1052,8 @@ static void batadv_tt_tvlv_container_update(struct batadv_priv *bat_priv) } spin_unlock_bh(&bat_priv->tt.last_changeset_lock); + /* Remove extra packet space for OGM */ + tvlv_len -= tt_extra_len; container_register: batadv_tvlv_container_register(bat_priv, BATADV_TVLV_TT, 1, tt_data, tvlv_len); From patchwork Fri Nov 1 22:05:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Remi Pommarel X-Patchwork-Id: 18675 X-Patchwork-Delegate: a@unstable.cc Return-Path: X-Original-To: patchwork@open-mesh.org Delivered-To: patchwork@open-mesh.org Received: from diktynna.open-mesh.org (localhost [IPv6:::1]) by diktynna.open-mesh.org (Postfix) with ESMTP id B812D83EF9 for ; Fri, 1 Nov 2024 23:07:16 +0100 (CET) ARC-Seal: i=2; cv=pass; a=rsa-sha256; d=open-mesh.org; s=20121; t=1730498836; b=g/1laAaLaD9e6Uw1twEHUzRucbNydenqrKjB/2utU8aagwEXffPJFpDLpMp601Emb+mjn Nvg8Fuf+GlEWxa81hA3hcvAN/JYnfSrwppQd3BXfcA77KHwdCqadKSkoDY2iG8y8d4VuUBd Jk0AZfCjY/UxNMa6P/JrA6z7hklTJVE= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=open-mesh.org; s=20121; t=1730498836; h=from : sender : reply-to : subject : date : message-id : to : cc : mime-version : content-type : content-transfer-encoding : content-id : content-description : resent-date : resent-from : resent-sender : resent-to : resent-cc : resent-message-id : in-reply-to : references : list-id : list-help : list-unsubscribe : list-subscribe : list-post : list-owner : list-archive; bh=IveEP2X7jrTAvWzb1q0J/x29KcGWnCG2VYMO6ZpjbgQ=; b=F/2nnurTFP4Lzqb7Og/HdngwHzQJ86dizem92pnzvrEyBOrIYg85X6EmuHLTqOESZiTa5 IpH76XysfWyX5D0wmJSD6F/doSCcBiNVSIFI5SQqrRNFSz7SrUEmqim4E/e65+E0K6cQ4+n 0WJSqg3vybM5GhctYxyTX8aN0vDE+d4= ARC-Authentication-Results: i=2; open-mesh.org; dkim=fail header.d=smtpservice.net; arc=pass; dmarc=fail (Used From Domain Record) header.from=triplefau.lt policy.dmarc=quarantine Authentication-Results: open-mesh.org; dkim=fail header.d=smtpservice.net; arc=pass; dmarc=fail (Used From Domain Record) header.from=triplefau.lt policy.dmarc=quarantine Received: from e2i340.smtp2go.com (e2i340.smtp2go.com [103.2.141.84]) by diktynna.open-mesh.org (Postfix) with ESMTPS id B628282714 for ; Fri, 1 Nov 2024 23:05:41 +0100 (CET) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=open-mesh.org; s=20121; t=1730498742; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=IveEP2X7jrTAvWzb1q0J/x29KcGWnCG2VYMO6ZpjbgQ=; b=o/IIfehEFMnCEQfiUXgEXLHDO5tl5BY8vKszT3o7h2uizNWsTWTZs2I16VO0Qu1bKQUhxG vxEFbTiixapgZMbnWC1G8GSRLBnxYGP+61lZXP2D3xwQ07uyHOiRLOukJzX7wdgWu0a/LA mRhq4jyRE4LqJiE9bcFrpizQaeVjmjc= ARC-Seal: i=1; s=20121; d=open-mesh.org; t=1730498742; a=rsa-sha256; cv=none; b=voeKhKQZxTBCu/hULEvMzduDb2G79PFXOVI0HodA4su8AIT1nYsPmmKkrbKI1BEw3t7LCF ecgQdjaGDim/Tar8zyDPpxlMpda/rLhax3Miay9HRauZDfJzmwLSs+SumOuyNM1ygGlV+T HAJIDP3bo/lu9576OKC20p9c+Mt8TDY= ARC-Authentication-Results: i=1; diktynna.open-mesh.org; dkim=none ("invalid DKIM record") header.d=smtpservice.net header.s=maxzs0.a1-4.dyn header.b=S48H1QBa; dkim=pass header.d=triplefau.lt header.s=s510616 header.b=mMSVimqb; spf=pass (diktynna.open-mesh.org: domain of "bT.f30wenro0suazq2=gp4qj95lt7yr=h87uajyvzy7zwq@em510616.triplefau.lt" designates 103.2.141.84 as permitted sender) smtp.mailfrom="bT.f30wenro0suazq2=gp4qj95lt7yr=h87uajyvzy7zwq@em510616.triplefau.lt"; dmarc=pass (policy=quarantine) header.from=triplefau.lt DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=smtpservice.net; s=maxzs0.a1-4.dyn; x=1730499641; h=Feedback-ID: X-Smtpcorp-Track:Message-Id:Date:Subject:To:From:Reply-To:Sender: List-Unsubscribe:List-Unsubscribe-Post; bh=IveEP2X7jrTAvWzb1q0J/x29KcGWnCG2VYMO6ZpjbgQ=; b=S48H1QBavrav0E2ePInhF7lXUl yfmAjcAaaR3K1YlUSCCseFSphQkxiQRgTNbuNb0Ou2wXoJ+bPM+qT7pJa4x3Y/BYedc8Iov6xlkoH cJZOb8KPiRH97d10b7SFX164FcX6SAZ0bHEuM16NCQBBIGOs8gDnJrHgdBx8SPfokPgdK52GjkAne K10buD4VM6iLH/WWiFGP/tX/Mq5l2QSb6xsSxhKHTsy82M6bwiAnwid7MQvNGPE5i01kUvT119x31 858da/5FAlnWuJ9252tGcnFjBOw1C7UQs2RVibharsURryU6hHEh0nrwFgQJb5CNIrI1Db9sIr2Dh g64qI5hw==; DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=triplefau.lt; i=@triplefau.lt; q=dns/txt; s=s510616; t=1730498741; h=from : subject : to : message-id : date; bh=IveEP2X7jrTAvWzb1q0J/x29KcGWnCG2VYMO6ZpjbgQ=; b=mMSVimqbixBaBHY/MTPT6ChpUNFT6rlRCYNVLsCoRCiHSJcIg0LD3bAtW2drwj1MZdM1I +cLmTvxgTV0LdZT6vtEin2uo8QL8Kt17GepuujHoJz5R1wILn+DLyLY4KFCiHwlcFgihaZB Tv7Ef3JNjhJ0iV3nid2w9prpW7Lmr815Bk/V0/A64XZNxUOxkhag7ZiesKlo4cHG2mArPys fSURhofKOg3qscADZAitlYViBc3IlVtYohz+x/KGOU4evRwR/TGX1H6jUei9P7iqr9ChBbI AC2bENYb9nnR41S8fcJ3QvsivqlOPY1cAcXpXiE270A/frzA+N7207FM3vrQ== Received: from [10.176.58.103] (helo=SmtpCorp) by smtpcorp.com with esmtpsa (TLS1.3:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.94.2-S2G) (envelope-from ) id 1t6zm0-TRk4kD-Hq; Fri, 01 Nov 2024 22:05:40 +0000 Received: from [10.12.239.196] (helo=localhost) by smtpcorp.com with esmtpsa (TLS1.3:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.97.1-S2G) (envelope-from ) id 1t6zm0-4o5NDgrqMzl-pUqN; Fri, 01 Nov 2024 22:05:40 +0000 From: Remi Pommarel To: b.a.t.m.a.n@lists.open-mesh.org Cc: Marek Lindner , Simon Wunderlich , Sven Eckelmann , Remi Pommarel Subject: [RFC PATCH 2/4] batman-adv: Do not let TT changes list grows indefinitely Date: Fri, 1 Nov 2024 23:05:00 +0100 Message-Id: <2496501ec84ce1b33abeb868c038eec782fdb907.1730497875.git.repk@triplefau.lt> X-Mailer: git-send-email 2.40.0 In-Reply-To: References: MIME-Version: 1.0 X-Smtpcorp-Track: J6ymRoENXzK3.c7-xBgp4Y1nn.NEeXiQJr3K8 Feedback-ID: 510616m:510616apGKSTK:510616ssW2ct_rvu X-Report-Abuse: Please forward a copy of this message, including all headers, to Message-ID-Hash: BBPQDLEAS62U2JQ7NCPOSLDZLYOYGDIK X-Message-ID-Hash: BBPQDLEAS62U2JQ7NCPOSLDZLYOYGDIK X-MailFrom: bT.f30wenro0suazq2=gp4qj95lt7yr=h87uajyvzy7zwq@em510616.triplefau.lt X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-b.a.t.m.a.n.lists.open-mesh.org-0; header-match-b.a.t.m.a.n.lists.open-mesh.org-1; header-match-b.a.t.m.a.n.lists.open-mesh.org-2; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: The list for a Better Approach To Mobile Ad-hoc Networking Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: When TT changes list is too big to fit in packet due to MTU size, an empty OGM is sent expected other node to send TT request to get the changes. The issue is that tt.last_changeset was not built thus the originator was responding with previous changes to those TT requests (see batadv_send_my_tt_response). Also the changes list was never cleaned up effectively never ending growing from this point onwards, repeatedly sending the same TT response changes over and over, and a creatind a new empty OGM every OGM interval expecting for the local changes to be purged. When there is more TT changes that can fit in packet, drop all changes, send emtpy OGM and wait for TT request so we can respond with a full table instead. Fixes: e1bf0c14096f ("batman-adv: tvlv - convert tt data sent within OGMs") Signed-off-by: Remi Pommarel --- net/batman-adv/translation-table.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c index f0590f9bc2b1..50af82e7b50a 100644 --- a/net/batman-adv/translation-table.c +++ b/net/batman-adv/translation-table.c @@ -990,6 +990,7 @@ static void batadv_tt_tvlv_container_update(struct batadv_priv *bat_priv) int tt_diff_len, tt_change_len = 0; int tt_diff_entries_num = 0; int tt_diff_entries_count = 0; + bool drop_changes = false; size_t tt_extra_len = 0; u16 tvlv_len; @@ -997,21 +998,29 @@ static void batadv_tt_tvlv_container_update(struct batadv_priv *bat_priv) tt_diff_len = batadv_tt_len(tt_diff_entries_num); /* if we have too many changes for one packet don't send any - * and wait for the tt table request which will be fragmented + * and wait for the tt table request so we can reply with the full + * table. + * + * The local change history should still be cleaned up or it will only + * grow from this point onwards. Also tt.last_changeset should be set + * to NULL so tt response could send the full table instead of diff. */ - if (tt_diff_len > bat_priv->soft_iface->mtu) + if (tt_diff_len > bat_priv->soft_iface->mtu) { tt_diff_len = 0; + tt_diff_entries_num = 0; + drop_changes = true; + } tvlv_len = batadv_tt_prepare_tvlv_local_data(bat_priv, &tt_data, &tt_change, &tt_diff_len); if (!tvlv_len) return; - tt_data->flags = BATADV_TT_OGM_DIFF; - - if (tt_diff_len == 0) + if (!drop_changes && tt_diff_len == 0) goto container_register; + tt_data->flags = BATADV_TT_OGM_DIFF; + spin_lock_bh(&bat_priv->tt.changes_list_lock); atomic_set(&bat_priv->tt.local_changes, 0); From patchwork Fri Nov 1 22:05:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Remi Pommarel X-Patchwork-Id: 18676 X-Patchwork-Delegate: a@unstable.cc Return-Path: X-Original-To: patchwork@open-mesh.org Delivered-To: patchwork@open-mesh.org Received: from diktynna.open-mesh.org (localhost [IPv6:::1]) by diktynna.open-mesh.org (Postfix) with ESMTP id A481D83F77 for ; Fri, 1 Nov 2024 23:07:58 +0100 (CET) ARC-Seal: i=2; cv=pass; a=rsa-sha256; d=open-mesh.org; s=20121; t=1730498878; b=34PswF4kWpjNMGmOxAphBZaSCrTMWjKMIkZjfyWx7ET7eWhEp6h0vrpJLakSTs0XckZwo mXfJdbIvcTyCwRqGL+LGL7uQ+mSNLbG9+2hQBlrq1GqxwmWl/ls3834ZLM/KyPE4kKn4Quc f+eIHQpfvZpMBIqfALh/ujUn52nv1bk= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=open-mesh.org; s=20121; t=1730498878; h=from : sender : reply-to : subject : date : message-id : to : cc : mime-version : content-type : content-transfer-encoding : content-id : content-description : resent-date : resent-from : resent-sender : resent-to : resent-cc : resent-message-id : in-reply-to : references : list-id : list-help : list-unsubscribe : list-subscribe : list-post : list-owner : list-archive; bh=mRwwZcgXFXYl5sXx8boQulcaUR9D20rIPNRkwAyJKIk=; b=alpDdhLV0dg/unG5nFn3vZk+1/f7qpCPNoJgUtCDOICxMFs/eILwauxbwGHD37pSIg6sm cEFIRB/CecB/aMccr89X+X56i7kH7Q/5qNncpLZXFI2zOLvSeMzfLUOAbrgHeetSLCi8QT5 cnH5Ds3VZSwk95EI58RSJyOaR3Wi+MQ= ARC-Authentication-Results: i=2; open-mesh.org; dkim=fail header.d=smtpservice.net; arc=pass; dmarc=fail (Used From Domain Record) header.from=triplefau.lt policy.dmarc=quarantine Authentication-Results: open-mesh.org; dkim=fail header.d=smtpservice.net; arc=pass; dmarc=fail (Used From Domain Record) header.from=triplefau.lt policy.dmarc=quarantine Received: from e2i340.smtp2go.com (e2i340.smtp2go.com [103.2.141.84]) by diktynna.open-mesh.org (Postfix) with ESMTPS id 2946F8176B for ; Fri, 1 Nov 2024 23:05:43 +0100 (CET) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=open-mesh.org; s=20121; t=1730498743; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=mRwwZcgXFXYl5sXx8boQulcaUR9D20rIPNRkwAyJKIk=; b=oBMIs3JzQ9JwTbD47W9TiDfOPXGrywXhSnTYoNnMRFQzhwvnhjO4JbsS73DBLVsr9Np2VN Li5q/vowpHQ5wCsRE6RzHGU76PA7/l18nnBHnx8URWoE5zgLpIKBgDp7S0sfBhL5rBI77h 52xcnQZtZk/2E4NpqLCqw2aGuEJsezg= ARC-Seal: i=1; s=20121; d=open-mesh.org; t=1730498743; a=rsa-sha256; cv=none; b=m9XETN3sALHOfThpvq13ksdlkWvhSlao8iLMFo5pWts2NdSM4Rt7WwWOxYeXYGac18Cjc+ 5rZP4SlIo1Vr5ofPTVDxhKZqqBs0Gq8/pMeRogW+dcmkcYEpCcKX8rdQTrBSx4h76Lfc/V hlk4D403btO7BosM5hzN6KBi/RrjWxw= ARC-Authentication-Results: i=1; diktynna.open-mesh.org; dkim=none ("invalid DKIM record") header.d=smtpservice.net header.s=maxzs0.a1-4.dyn header.b=SPb0KFWf; dkim=pass header.d=triplefau.lt header.s=s510616 header.b=MvqboimW; spf=pass (diktynna.open-mesh.org: domain of "bT.n3fmj6chkhz6aa7=h6bm5ui6ip0a=0ayilt0w8clcsr@em510616.triplefau.lt" designates 103.2.141.84 as permitted sender) smtp.mailfrom="bT.n3fmj6chkhz6aa7=h6bm5ui6ip0a=0ayilt0w8clcsr@em510616.triplefau.lt"; dmarc=pass (policy=quarantine) header.from=triplefau.lt DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=smtpservice.net; s=maxzs0.a1-4.dyn; x=1730499643; h=Feedback-ID: X-Smtpcorp-Track:Message-Id:Date:Subject:To:From:Reply-To:Sender: List-Unsubscribe:List-Unsubscribe-Post; bh=mRwwZcgXFXYl5sXx8boQulcaUR9D20rIPNRkwAyJKIk=; b=SPb0KFWfoc2TyYxYJL1EJ75B1p myZujnPdtTJnOqnHCv4KElqvzi3e/eC5VOLUzajkHrsNseZl3RsRBvnKN/bj7KOVXG/Rd4Ahj/BZg wGBDCiTmsXR6FZRE6bAWguqLPCYoQq3sFQ2catrSJIqkHdqL9MSRsfkZ+NkVNRuZYn+vL1DqSqWY4 WhCqve4WRB5oL11qtC32KMB/ZYiNyrnjNRFHa7zkOdYqgWJaoNaq17hskLv2lVd43tsCSapa0TRzC 8Yk33uTcg6GV3boQVxhjMDIQUuzCSPgk5pK5/+pXnbI+r/eq9gFlhoeGWjcpA1A9i9ifxWXvIxlU5 pjq14NzQ==; DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=triplefau.lt; i=@triplefau.lt; q=dns/txt; s=s510616; t=1730498743; h=from : subject : to : message-id : date; bh=mRwwZcgXFXYl5sXx8boQulcaUR9D20rIPNRkwAyJKIk=; b=MvqboimW7MY9lnOZjOUXyxEiNxBmWwgOVI7+otvmkldinSCmEimCU9ZVepGkTrx7CHZiB FaKTWWZe09Butra5xlKvkNz3UWfB7ChN3BdPH9gIM6qtJmljImJo+X21Ee3DcLAzi2xI8YY JKCGgHL/4QYFPZMm+vE29wiaRcze7M2HmgvSUYmTGBvYPeJJWNHE93XwVYjN5Jfr94O250e APM9cFGoX2NKY2K0fpTXTpcj1UaIF4zQlmpm4ms7cgTKBbajFcJfKJJpR4TarEWtlchm/4/ q2muUqVYfCMTUzRjhZP5YuEhFW59hEpHeBkDeVd/PBDeBOcFruzPbLI4+Glw== Received: from [10.172.233.58] (helo=SmtpCorp) by smtpcorp.com with esmtpsa (TLS1.3:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.94.2-S2G) (envelope-from ) id 1t6zm2-TRk4qV-BX; Fri, 01 Nov 2024 22:05:42 +0000 Received: from [10.12.239.196] (helo=localhost) by smtpcorp.com with esmtpsa (TLS1.3:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.97.1-S2G) (envelope-from ) id 1t6zm1-FnQW0hQ0fcn-oA4w; Fri, 01 Nov 2024 22:05:42 +0000 From: Remi Pommarel To: b.a.t.m.a.n@lists.open-mesh.org Cc: Marek Lindner , Simon Wunderlich , Sven Eckelmann , Remi Pommarel Subject: [RFC PATCH 3/4] batman-adv: Remove atomic usage for tt.local_changes Date: Fri, 1 Nov 2024 23:05:01 +0100 Message-Id: <76a873bb36c47de9dfa5c9a028a6354341416e55.1730497875.git.repk@triplefau.lt> X-Mailer: git-send-email 2.40.0 In-Reply-To: References: MIME-Version: 1.0 X-Smtpcorp-Track: oee0yuRNAaks.cPS4KyLKlYUY.HebwRQzQ7VY Feedback-ID: 510616m:510616apGKSTK:510616sbOVPCYDuJ X-Report-Abuse: Please forward a copy of this message, including all headers, to Message-ID-Hash: THBOYIHKFEB4CTF2RIKKQ4RLTMFXJAH3 X-Message-ID-Hash: THBOYIHKFEB4CTF2RIKKQ4RLTMFXJAH3 X-MailFrom: bT.n3fmj6chkhz6aa7=h6bm5ui6ip0a=0ayilt0w8clcsr@em510616.triplefau.lt X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-b.a.t.m.a.n.lists.open-mesh.org-0; header-match-b.a.t.m.a.n.lists.open-mesh.org-1; header-match-b.a.t.m.a.n.lists.open-mesh.org-2; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: The list for a Better Approach To Mobile Ad-hoc Networking Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: The tt.local_changes atomic is either written with tt.changes_list_lock or close to it (see batadv_tt_local_event()). Thus the performance gain using an atomic was limited (or because of atomic_read() impact even negative). Using atomic also comes with the need to be wary of potential negative tt.local_changes value. Simplify the tt.local_changes usage by removing the atomic property and modifying it only with tt.changes_list_lock held. Signed-off-by: Remi Pommarel --- net/batman-adv/soft-interface.c | 2 +- net/batman-adv/translation-table.c | 17 ++++++----------- net/batman-adv/types.h | 4 ++-- 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c index 2758aba47a2f..2575f13992d2 100644 --- a/net/batman-adv/soft-interface.c +++ b/net/batman-adv/soft-interface.c @@ -783,13 +783,13 @@ static int batadv_softif_init_late(struct net_device *dev) atomic_set(&bat_priv->mesh_state, BATADV_MESH_INACTIVE); atomic_set(&bat_priv->bcast_seqno, 1); atomic_set(&bat_priv->tt.vn, 0); - atomic_set(&bat_priv->tt.local_changes, 0); atomic_set(&bat_priv->tt.ogm_append_cnt, 0); #ifdef CONFIG_BATMAN_ADV_BLA atomic_set(&bat_priv->bla.num_requests, 0); #endif atomic_set(&bat_priv->tp_num, 0); + bat_priv->tt.local_changes = 0; bat_priv->tt.last_changeset = NULL; bat_priv->tt.last_changeset_len = 0; bat_priv->isolation_mark = 0; diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c index 50af82e7b50a..a22029511eb2 100644 --- a/net/batman-adv/translation-table.c +++ b/net/batman-adv/translation-table.c @@ -463,7 +463,6 @@ static void batadv_tt_local_event(struct batadv_priv *bat_priv, struct batadv_tt_change_node *tt_change_node, *entry, *safe; struct batadv_tt_common_entry *common = &tt_local_entry->common; u8 flags = common->flags | event_flags; - bool event_removed = false; bool del_op_requested, del_op_entry; tt_change_node = kmem_cache_alloc(batadv_tt_change_cache, GFP_ATOMIC); @@ -508,21 +507,17 @@ static void batadv_tt_local_event(struct batadv_priv *bat_priv, del: list_del(&entry->list); kmem_cache_free(batadv_tt_change_cache, entry); + bat_priv->tt.local_changes--; kmem_cache_free(batadv_tt_change_cache, tt_change_node); - event_removed = true; goto unlock; } /* track the change in the OGMinterval list */ list_add_tail(&tt_change_node->list, &bat_priv->tt.changes_list); + bat_priv->tt.local_changes++; unlock: spin_unlock_bh(&bat_priv->tt.changes_list_lock); - - if (event_removed) - atomic_dec(&bat_priv->tt.local_changes); - else - atomic_inc(&bat_priv->tt.local_changes); } /** @@ -994,7 +989,7 @@ static void batadv_tt_tvlv_container_update(struct batadv_priv *bat_priv) size_t tt_extra_len = 0; u16 tvlv_len; - tt_diff_entries_num = atomic_read(&bat_priv->tt.local_changes); + tt_diff_entries_num = READ_ONCE(bat_priv->tt.local_changes); tt_diff_len = batadv_tt_len(tt_diff_entries_num); /* if we have too many changes for one packet don't send any @@ -1022,7 +1017,7 @@ static void batadv_tt_tvlv_container_update(struct batadv_priv *bat_priv) tt_data->flags = BATADV_TT_OGM_DIFF; spin_lock_bh(&bat_priv->tt.changes_list_lock); - atomic_set(&bat_priv->tt.local_changes, 0); + bat_priv->tt.local_changes = 0; list_for_each_entry_safe(entry, safe, &bat_priv->tt.changes_list, list) { @@ -1438,7 +1433,7 @@ static void batadv_tt_changes_list_free(struct batadv_priv *bat_priv) kmem_cache_free(batadv_tt_change_cache, entry); } - atomic_set(&bat_priv->tt.local_changes, 0); + bat_priv->tt.local_changes = 0; spin_unlock_bh(&bat_priv->tt.changes_list_lock); } @@ -3701,7 +3696,7 @@ static void batadv_tt_local_commit_changes_nolock(struct batadv_priv *bat_priv) { lockdep_assert_held(&bat_priv->tt.commit_lock); - if (atomic_read(&bat_priv->tt.local_changes) < 1) { + if (READ_ONCE(bat_priv->tt.local_changes) < 1) { if (!batadv_atomic_dec_not_zero(&bat_priv->tt.ogm_append_cnt)) batadv_tt_tvlv_container_update(bat_priv); return; diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h index 04f6398b3a40..f491bff8c51b 100644 --- a/net/batman-adv/types.h +++ b/net/batman-adv/types.h @@ -1022,7 +1022,7 @@ struct batadv_priv_tt { atomic_t ogm_append_cnt; /** @local_changes: changes registered in an originator interval */ - atomic_t local_changes; + size_t local_changes; /** * @changes_list: tracks tt local changes within an originator interval @@ -1044,7 +1044,7 @@ struct batadv_priv_tt { */ struct list_head roam_list; - /** @changes_list_lock: lock protecting changes_list */ + /** @changes_list_lock: lock protecting changes_list & local_changes */ spinlock_t changes_list_lock; /** @req_list_lock: lock protecting req_list */ From patchwork Fri Nov 1 22:05:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Remi Pommarel X-Patchwork-Id: 18677 X-Patchwork-Delegate: a@unstable.cc Return-Path: X-Original-To: patchwork@open-mesh.org Delivered-To: patchwork@open-mesh.org Received: from diktynna.open-mesh.org (localhost [IPv6:::1]) by diktynna.open-mesh.org (Postfix) with ESMTP id E62DE83DE3 for ; Fri, 1 Nov 2024 23:09:00 +0100 (CET) ARC-Seal: i=2; cv=pass; a=rsa-sha256; d=open-mesh.org; s=20121; t=1730498940; b=tBru7Iq39/mTKmevJHhTRNRrK7ds0PmLSRZpyfXbrxbP5HJyyxFuZ0wWaRDTBmgK2sKRP nS+YD5EHuIl+QRnD7qp0FFUwW24OhgL+RZWIWEn2EKI+5JZ6QYqZF1nPb2tGgr/WvpJv+cq UMxQ+l3x+9IMJhn3D3hqzKwwzJ/kfeE= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=open-mesh.org; s=20121; t=1730498940; h=from : sender : reply-to : subject : date : message-id : to : cc : mime-version : content-type : content-transfer-encoding : content-id : content-description : resent-date : resent-from : resent-sender : resent-to : resent-cc : resent-message-id : in-reply-to : references : list-id : list-help : list-unsubscribe : list-subscribe : list-post : list-owner : list-archive; bh=vdM5SRDDmui8Is1rfSkI506zj3M7HuysI6wgSRgy7+g=; b=jMUJdVoRm4s2jnFQKR68Zt2i9s5EspN/rePKfeE6Ho+Objha8XNZeNDaTuQsuyslO8Q7/ VDiNKV9yhoJWi1uabTgBXeb0uDIx/vWNnrLtoS1MmTSxXSxXK/f9YbeeMu21z/RBmiM7ath mvo8YkV42hpiLaD5rvbbO6DdIveZQHk= ARC-Authentication-Results: i=2; open-mesh.org; dkim=fail header.d=smtpservice.net; arc=pass; dmarc=fail (Used From Domain Record) header.from=triplefau.lt policy.dmarc=quarantine Authentication-Results: open-mesh.org; dkim=fail header.d=smtpservice.net; arc=pass; dmarc=fail (Used From Domain Record) header.from=triplefau.lt policy.dmarc=quarantine Received: from e2i340.smtp2go.com (e2i340.smtp2go.com [103.2.141.84]) by diktynna.open-mesh.org (Postfix) with ESMTPS id B53E483CA0 for ; Fri, 1 Nov 2024 23:05:45 +0100 (CET) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=open-mesh.org; s=20121; t=1730498745; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=vdM5SRDDmui8Is1rfSkI506zj3M7HuysI6wgSRgy7+g=; b=3xfb3eUNbW4qlEA7+LAZUaQ2zzGvNWtlQbOcAKNUZgFkb9f5YG5zwgagsvyNXgVmPOV3e/ 4jUIZN//uipGepqtgD5+04Tew/bM2y2ym8uLGWucc4or3x21T/61U2tlCotw9GonJQM10Q yBaj+amCBCHIOFkR+fLq45NdeK5qL9s= ARC-Seal: i=1; s=20121; d=open-mesh.org; t=1730498745; a=rsa-sha256; cv=none; b=eCzTLjrRKnZSVHR8FFDuGdUmWF4pENd5mqGD+3POXWnLcoqoFx2xY7/gVxOyjGoYxumyYN 2XU2654sp9Qi+YMcUcTZ1z4zzp1Eyezbcp+JG2TlYG2TPZWyH5xYsjYJdc1NpeVxEojTck n4KV3irCU/onxolIXecpR300qQoOHwg= ARC-Authentication-Results: i=1; diktynna.open-mesh.org; dkim=none ("invalid DKIM record") header.d=smtpservice.net header.s=maxzs0.a1-4.dyn header.b=Ke0PcaDP; dkim=pass header.d=triplefau.lt header.s=s510616 header.b=Pwv0id0I; spf=pass (diktynna.open-mesh.org: domain of "bT.aimj6c956hqfv69=j6um73nqh2sb=1kb40e8homs1e1@em510616.triplefau.lt" designates 103.2.141.84 as permitted sender) smtp.mailfrom="bT.aimj6c956hqfv69=j6um73nqh2sb=1kb40e8homs1e1@em510616.triplefau.lt"; dmarc=pass (policy=quarantine) header.from=triplefau.lt DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=smtpservice.net; s=maxzs0.a1-4.dyn; x=1730499645; h=Feedback-ID: X-Smtpcorp-Track:Message-Id:Date:Subject:To:From:Reply-To:Sender: List-Unsubscribe:List-Unsubscribe-Post; bh=vdM5SRDDmui8Is1rfSkI506zj3M7HuysI6wgSRgy7+g=; b=Ke0PcaDPFTOFvSXkV6Y5nrS0LS bW3NlfZZxLPmr50Z353er0JLOEd7KTnc3lMoabEEGI1eP6Gb35x8DknGrta4+2sLfDQ0gTxtFLh22 /VNDDbTQqWYFdZ1w2viGgomGXqHttHg1+Taw7b58VDSq7fe3hkA/syhVI9A+G/Lj9DS1fqIeY5amd xrpMVDXJl5auJpcC4W2qggzwvvaHaP/BQl20foZdX+y7cNbBDi+FchghHvvt+vXH/g2/XJ+WBUP4g OGMTZhV+8LlSsqYOxbPv9ddG4RhfU0+vD6rTYI/2dpAQr8eJYPDBVZSSS7l4Rctan0BATrudMNelg kSjhPcBg==; DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=triplefau.lt; i=@triplefau.lt; q=dns/txt; s=s510616; t=1730498745; h=from : subject : to : message-id : date; bh=vdM5SRDDmui8Is1rfSkI506zj3M7HuysI6wgSRgy7+g=; b=Pwv0id0ItEQmdBKDGDE8TRKCUNk8sX54+9XDLQMmq5hrFRM8rT44xUcO+vS/rrZPY2tSo SGByi/VSBUETVNN7iIkxjqFwlFvCs2sTaJYa0s5pN445AKwPDm1kNiL0ZnF09I1MYh64J77 0llWotx652Kz/noSXx/EbA0DepD8Z4nQV1NAo+CKm/KvRD0MS8wal2C3OT3q59hzHx46nXD vJpzfP1HPwvR/mrHDVrsvYZUqJ0qpjbD02c1jbujLmpG0gLBm68Bdggfx4SyL3yLWH9PgB8 B8Pbj0WisVT61/qMLRPNToVQkMsRcTzOA8BGFVzKl9wpNrd0aPwjjQAVHCiQ== Received: from [10.172.233.45] (helo=SmtpCorp) by smtpcorp.com with esmtpsa (TLS1.3:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.94.2-S2G) (envelope-from ) id 1t6zm5-TRk4zb-4Q; Fri, 01 Nov 2024 22:05:45 +0000 Received: from [10.12.239.196] (helo=localhost) by smtpcorp.com with esmtpsa (TLS1.3:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.97.1-S2G) (envelope-from ) id 1t6zm4-AIkwcC8uxyx-KEad; Fri, 01 Nov 2024 22:05:44 +0000 From: Remi Pommarel To: b.a.t.m.a.n@lists.open-mesh.org Cc: Marek Lindner , Simon Wunderlich , Sven Eckelmann , Remi Pommarel Subject: [RFC PATCH 4/4] batman-adv: Don't keep redundant TT change events Date: Fri, 1 Nov 2024 23:05:02 +0100 Message-Id: X-Mailer: git-send-email 2.40.0 In-Reply-To: References: MIME-Version: 1.0 X-Smtpcorp-Track: _u5XGM-cfz03.qkK9GQGsPJkD.6elkYwBhQYh Feedback-ID: 510616m:510616apGKSTK:510616say1Vf6Ye2 X-Report-Abuse: Please forward a copy of this message, including all headers, to Message-ID-Hash: HGNXTWVZMEGO66WNQ36MOAK5JED4LZJK X-Message-ID-Hash: HGNXTWVZMEGO66WNQ36MOAK5JED4LZJK X-MailFrom: bT.aimj6c956hqfv69=j6um73nqh2sb=1kb40e8homs1e1@em510616.triplefau.lt X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-b.a.t.m.a.n.lists.open-mesh.org-0; header-match-b.a.t.m.a.n.lists.open-mesh.org-1; header-match-b.a.t.m.a.n.lists.open-mesh.org-2; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: The list for a Better Approach To Mobile Ad-hoc Networking Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: When adding a local TT twice within the same OGM interval (e.g. happens when flag get updated), the flags of the first TT change entry is updated with the second one and both change events is added to the change list. This leads to having the same ADD change entry twice. Similarly a DEL+DEL scenario is also creating twice the same event. Deduplicate ADD+ADD or DEL+DEL scenarios to reduce the TT change events that need to be sent in both OGM and TT response. Signed-off-by: Remi Pommarel --- net/batman-adv/translation-table.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c index a22029511eb2..01fc19803304 100644 --- a/net/batman-adv/translation-table.c +++ b/net/batman-adv/translation-table.c @@ -500,14 +500,17 @@ static void batadv_tt_local_event(struct batadv_priv *bat_priv, /* this is a second add in the same originator interval. It * means that flags have been changed: update them! */ - if (!del_op_requested && !del_op_entry) + if (del_op_requested == del_op_entry) { entry->change.flags = flags; + goto discard; + } continue; del: list_del(&entry->list); kmem_cache_free(batadv_tt_change_cache, entry); bat_priv->tt.local_changes--; +discard: kmem_cache_free(batadv_tt_change_cache, tt_change_node); goto unlock; }