From patchwork Mon Jun 20 17:53:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Eckelmann X-Patchwork-Id: 16387 X-Patchwork-Delegate: mareklindner@neomailbox.ch Return-Path: X-Original-To: patchwork@open-mesh.org Delivered-To: patchwork@open-mesh.org Received: from open-mesh.org (localhost [IPv6:::1]) by open-mesh.org (Postfix) with ESMTP id B883581D1B; Mon, 20 Jun 2016 19:53:46 +0200 (CEST) Authentication-Results: open-mesh.org; dmarc=none header.from=narfation.org Authentication-Results: open-mesh.org; dkim=fail reason="verification failed; unprotected key" header.d=narfation.org header.i=@narfation.org header.b=wFWbOPnK; dkim-adsp=fail (unprotected policy); dkim-atps=neutral Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=79.140.41.39; helo=v3-1039.vlinux.de; envelope-from=sven@narfation.org; receiver=b.a.t.m.a.n@lists.open-mesh.org Authentication-Results: open-mesh.org; dmarc=pass header.from=narfation.org Received: from v3-1039.vlinux.de (narfation.org [79.140.41.39]) by open-mesh.org (Postfix) with ESMTPS id 9C59281D72 for ; Mon, 20 Jun 2016 19:53:40 +0200 (CEST) Received: from sven-desktop.home.narfation.org (p200300C593C047F90000000000002E16.dip0.t-ipconnect.de [IPv6:2003:c5:93c0:47f9::2e16]) by v3-1039.vlinux.de (Postfix) with ESMTPSA id 29DCA1100E8; Mon, 20 Jun 2016 19:53:40 +0200 (CEST) Authentication-Results: v3-1039.vlinux.de; dmarc=none header.from=narfation.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=narfation.org; s=20121; t=1466445220; bh=ucYKzRu6UIZnNtNJd0OtylIAXTZKy7oAzvPD3c+RcVE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wFWbOPnKu0MfbzRWCrncqsP6MLWPhP1YUWoAHztAgF5UiFrZUntQTMuDEG/d60pBi V/hPViXnjBx8m06Zz8f+OCAJXmAiOmye1sK2O3Ayvkae3ZaBYL9K67uhz8FqrXlaKo yuebPwOuGO2hNlx0jlgd6hvNCO1aiQ0A6eMG6rrk= From: Sven Eckelmann To: b.a.t.m.a.n@lists.open-mesh.org Date: Mon, 20 Jun 2016 19:53:28 +0200 Message-Id: <1466445210-17616-2-git-send-email-sven@narfation.org> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1466445210-17616-1-git-send-email-sven@narfation.org> References: <1466445210-17616-1-git-send-email-sven@narfation.org> Subject: [B.A.T.M.A.N.] [PATCH next v2 2/4] batman-adv: Don't propagate negative dev_queue_xmit return values X-BeenThere: b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: The list for a Better Approach To Mobile Ad-hoc Networking List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking Errors-To: b.a.t.m.a.n-bounces@lists.open-mesh.org Sender: "B.A.T.M.A.N" batadv_send_skb_packet used by batadv_send_skb_to_orig and its return value is given directly to callers of batadv_send_skb_packet. batadv_send_skb_to_orig -> batadv_send_unicast_skb -> batadv_send_skb_packet -> dev_queue_xmit These callers of batadv_send_skb_to_orig expect that the skb isn't consumed when they receive a -1. But dev_queue_xmit may still have consumed it and still returned -1. Thus the free for the skb would be called twice. Fixes: e3b8acbff9c8 ("batman-adv: return netdev status in the TX path") Signed-off-by: Sven Eckelmann --- v2: - rebased on current master - added patch to a common set of related patches net/batman-adv/send.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/net/batman-adv/send.c b/net/batman-adv/send.c index 49836da..70a8c1d 100644 --- a/net/batman-adv/send.c +++ b/net/batman-adv/send.c @@ -72,6 +72,7 @@ int batadv_send_skb_packet(struct sk_buff *skb, { struct batadv_priv *bat_priv; struct ethhdr *ethhdr; + int ret; bat_priv = netdev_priv(hard_iface->soft_iface); @@ -109,8 +110,15 @@ int batadv_send_skb_packet(struct sk_buff *skb, /* dev_queue_xmit() returns a negative result on error. However on * congestion and traffic shaping, it drops and returns NET_XMIT_DROP * (which is > 0). This will not be treated as an error. + * + * a negative value cannot be returned because it could be interepreted + * as not consumed skb by callers of batadv_send_skb_to_orig. */ - return dev_queue_xmit(skb); + ret = dev_queue_xmit(skb); + if (ret < 0) + ret = NET_XMIT_DROP; + + return ret; send_skb_err: kfree_skb(skb); return NET_XMIT_DROP;