From patchwork Thu Jun 25 13:08:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Berg X-Patchwork-Id: 215248 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B0193C433E0 for ; Thu, 25 Jun 2020 13:08:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8F93520702 for ; Thu, 25 Jun 2020 13:08:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404958AbgFYNI6 (ORCPT ); Thu, 25 Jun 2020 09:08:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34168 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404923AbgFYNI4 (ORCPT ); Thu, 25 Jun 2020 09:08:56 -0400 Received: from sipsolutions.net (s3.sipsolutions.net [IPv6:2a01:4f8:191:4433::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F1D6BC08C5DC for ; Thu, 25 Jun 2020 06:08:55 -0700 (PDT) Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.93) (envelope-from ) id 1joRcc-00BrnC-6e; Thu, 25 Jun 2020 15:08:54 +0200 From: Johannes Berg To: me@bcopeland.com Cc: linux-wireless@vger.kernel.org, Johannes Berg Subject: [PATCH 6/9] wmediumd: fix RX message with cookie Date: Thu, 25 Jun 2020 15:08:41 +0200 Message-Id: <20200625150754.f1b8860bb95b.Ifb8f79b3edacce8832697ca796861aad92b2ce7b@changeid> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200625130844.22893-1-johannes@sipsolutions.net> References: <20200625130844.22893-1-johannes@sipsolutions.net> MIME-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Johannes Berg The cookie message needs to be built properly, fix the code to do this, otherwise a client with WMEDIUMD_CTL_RX_ALL_FRAMES doesn't know its own messages. The code was just completely broken in all kinds of ways. --- wmediumd/wmediumd.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/wmediumd/wmediumd.c b/wmediumd/wmediumd.c index aa169e1602be..afc4f16d9ae9 100644 --- a/wmediumd/wmediumd.c +++ b/wmediumd/wmediumd.c @@ -606,11 +606,12 @@ static void send_cloned_frame_msg(struct wmediumd *ctx, struct client *src, list_for_each_entry(client, &ctx->clients, list) { if (client->flags & WMEDIUMD_CTL_RX_ALL_FRAMES) { - if (!cmsg) { - cmsg = nlmsg_convert(nlmsg_hdr(msg)); - if (!cmsg) - continue; - nla_put_u64(msg, HWSIM_ATTR_COOKIE, cookie); + if (src == client && !cmsg) { + struct nlmsghdr *nlh = nlmsg_hdr(msg); + + cmsg = nlmsg_inherit(nlh); + nlmsg_append(cmsg, nlmsg_data(nlh), nlmsg_datalen(nlh), 0); + assert(nla_put_u64(cmsg, HWSIM_ATTR_COOKIE, cookie) == 0); } wmediumd_send_to_client(ctx, client, src == client ? cmsg : msg);