From patchwork Fri Oct 9 09:27:37 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Schultz X-Patchwork-Id: 528142 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 9B94F1406AA for ; Fri, 9 Oct 2015 20:27:55 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965179AbbJIJ1v (ORCPT ); Fri, 9 Oct 2015 05:27:51 -0400 Received: from mail.tpip.net ([92.43.49.48]:37896 "EHLO mail.tpip.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965133AbbJIJ1q (ORCPT ); Fri, 9 Oct 2015 05:27:46 -0400 Received: from office.tpip.net (office.tpip.net [92.43.51.2]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.tpip.net (Postfix) with ESMTPS id B2BBF4F416; Fri, 9 Oct 2015 09:27:44 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by office.tpip.net (Postfix) with ESMTP id BF470A2F77; Fri, 9 Oct 2015 11:27:43 +0200 (CEST) Received: from office.tpip.net ([127.0.0.1]) by localhost (office.tpip.net [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id lTcWLkR8EvgF; Fri, 9 Oct 2015 11:27:43 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by office.tpip.net (Postfix) with ESMTP id 6DCBBA2F78; Fri, 9 Oct 2015 11:27:43 +0200 (CEST) X-Virus-Scanned: amavisd-new at tpip.net Received: from office.tpip.net ([127.0.0.1]) by localhost (office.tpip.net [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id LgqT2AuSCUWX; Fri, 9 Oct 2015 11:27:43 +0200 (CEST) Received: from alice.tpip.org (unknown [192.168.13.53]) by office.tpip.net (Postfix) with ESMTPSA id 1BDA2A2F79; Fri, 9 Oct 2015 11:27:43 +0200 (CEST) From: Andreas Schultz To: netdev@vger.kernel.org Cc: Pravin B Shelar , "David S. Miller" Subject: [PATCH net-next v4 1/2] fix return of iptunnel_xmit Date: Fri, 9 Oct 2015 11:27:37 +0200 Message-Id: <1444382858-6725-2-git-send-email-aschultz@tpip.net> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1444382858-6725-1-git-send-email-aschultz@tpip.net> References: <1444382858-6725-1-git-send-email-aschultz@tpip.net> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org All users of iptunnel_xmit expect the return value to be the packet length on success (>0), negative for a tx error and zero for a tx dropped error. In cset 0e6fbc5b6c6218987c93b8c7ca60cf786062899d the negative return case was lost. This bug was introduced when the ip_tunnel_core code was refactored. Fixes: 0e6fbc5b6c6218987c93b8c7ca60cf786062899d Signed-off-by: Andreas Schultz Acked-by: Jiri Benc Acked-by: Pravin B Shelar --- Change in v2: - remove unused variable pkt_len Change in v3: - reworked based on comment from Jiri Benc Change in v4: - rebased to net-next to avoid merge conflicts - added Acked-By from Jiri Benc and Pravin B Shelar --- net/ipv4/ip_tunnel_core.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/net/ipv4/ip_tunnel_core.c b/net/ipv4/ip_tunnel_core.c index 6cb9009..453d569 100644 --- a/net/ipv4/ip_tunnel_core.c +++ b/net/ipv4/ip_tunnel_core.c @@ -80,9 +80,12 @@ int iptunnel_xmit(struct sock *sk, struct rtable *rt, struct sk_buff *skb, __ip_select_ident(net, iph, skb_shinfo(skb)->gso_segs ?: 1); err = ip_local_out(net, sk, skb); - if (unlikely(net_xmit_eval(err))) - pkt_len = 0; - return pkt_len; + if (likely(net_xmit_eval(err) == 0)) + return pkt_len; + if (err < 0) + return err; + + return 0; } EXPORT_SYMBOL_GPL(iptunnel_xmit);