From patchwork Thu Oct 8 15:33:54 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Schultz X-Patchwork-Id: 527791 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 75CA3140DEF for ; Fri, 9 Oct 2015 02:34:16 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934279AbbJHPeL (ORCPT ); Thu, 8 Oct 2015 11:34:11 -0400 Received: from mail.tpip.net ([92.43.49.48]:50206 "EHLO mail.tpip.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934107AbbJHPd7 (ORCPT ); Thu, 8 Oct 2015 11:33:59 -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 5E2E74F404; Thu, 8 Oct 2015 15:33:56 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by office.tpip.net (Postfix) with ESMTP id 00470A2F77; Thu, 8 Oct 2015 17:33:54 +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 Efn6Y5_7SdPy; Thu, 8 Oct 2015 17:33:54 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by office.tpip.net (Postfix) with ESMTP id 96D20A2F78; Thu, 8 Oct 2015 17:33:54 +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 UKDL4IZol0hB; Thu, 8 Oct 2015 17:33:54 +0200 (CEST) Received: from [192.168.13.53] (unknown [192.168.13.53]) by office.tpip.net (Postfix) with ESMTPSA id 41312A2F77; Thu, 8 Oct 2015 17:33:54 +0200 (CEST) Subject: Re: [PATCH net v2] fix return of iptunnel_xmit To: Jiri Benc References: <1444299114-21345-1-git-send-email-aschultz@tpip.net> <20151008170849.22bc8632@griffin> Cc: netdev@vger.kernel.org, Pravin B Shelar , "David S. Miller" From: Andreas Schultz Message-ID: <56168CE2.6060208@tpip.net> Date: Thu, 8 Oct 2015 17:33:54 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: <20151008170849.22bc8632@griffin> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On 10/08/2015 05:08 PM, Jiri Benc wrote: > On Thu, 8 Oct 2015 12:11:54 +0200, Andreas Schultz wrote: >> All users of iptunnel_xmit expect the return value to be the error >> code from ip_output_local, but currently the return value is length >> of the send data on success or zero on error. >> Change iptunnel_xmit returns to match the callers expectation. > > That's not true. All users pass the returned value to > iptunnel_xmit_stats() where it is used to increase tx_bytes. Yes, but iptunnel_xmit_stats() basically has three different counters: 1. count packets and bytes when err > 0 2. count tx_errors when err < 0 3. count tx_dropped when err == 0 Case 2 got lost in cset 0e6fbc5b6c6218987c93b8c7ca60cf786062899d, since the return value of iptunnel_xmit() can only be >= 0. I tried to find out if ip_local_out_sk() can ever return a negative value. If it can't then iptunnel_xmit_stats() could be simplified and tipc_udp_send_msg should be fixed. I've reread my change, and it I do have messed up the non-error case. pkt_len should be returned when ip_local_out_sk returns NET_XMIT_SUCCESS or NET_XMIT_CN, 0 when err > 0 and err when err < 0. Like this: Andreas > > The only exception is tipc_udp_send_msg which should be fixed instead. > > Jiri > --- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/net/ipv4/ip_tunnel_core.c b/net/ipv4/ip_tunnel_core.c index 84dce6a..5cced3b 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, skb_shinfo(skb)->gso_segs ?: 1); err = ip_local_out_sk(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);