public inbox for b.a.t.m.a.n@lists.open-mesh.org
 help / color / mirror / Atom feed
From: Sven Eckelmann <sven@narfation.org>
To: b.a.t.m.a.n@lists.open-mesh.org
Subject: [B.A.T.M.A.N.] [PATCH next v2 2/4] batman-adv: Don't propagate negative dev_queue_xmit return values
Date: Mon, 20 Jun 2016 19:53:28 +0200	[thread overview]
Message-ID: <1466445210-17616-2-git-send-email-sven@narfation.org> (raw)
In-Reply-To: <1466445210-17616-1-git-send-email-sven@narfation.org>

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 <sven@narfation.org>
---
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;
-- 
2.8.1


  reply	other threads:[~2016-06-20 17:53 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-20 17:53 [B.A.T.M.A.N.] [PATCH next v2 1/4] batman-adv: Free tp_meter ack skb when it was not consumed Sven Eckelmann
2016-06-20 17:53 ` Sven Eckelmann [this message]
2016-07-05  8:38   ` [B.A.T.M.A.N.] [PATCH next v2 2/4] batman-adv: Don't propagate negative dev_queue_xmit return values Marek Lindner
2016-06-20 17:54 ` [B.A.T.M.A.N.] [PATCH next v2 3/4] batman-adv: remove NET_XMIT_POLICED Sven Eckelmann
2016-07-05  8:41   ` Marek Lindner
2016-06-20 17:54 ` [B.A.T.M.A.N.] [PATCH next v2 4/4] batman-adv: Remove unnecessary call to dev_xmit_complete Sven Eckelmann
2016-07-05  8:42   ` Marek Lindner
2016-07-05  8:32 ` [B.A.T.M.A.N.] [PATCH next v2 1/4] batman-adv: Free tp_meter ack skb when it was not consumed Marek Lindner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1466445210-17616-2-git-send-email-sven@narfation.org \
    --to=sven@narfation.org \
    --cc=b.a.t.m.a.n@lists.open-mesh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox