From patchwork Wed Nov 9 17:07:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Ahern X-Patchwork-Id: 692857 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 3tDXfz1XJmz9vF4 for ; Thu, 10 Nov 2016 04:07:39 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=cumulusnetworks.com header.i=@cumulusnetworks.com header.b="JJigVfn7"; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754561AbcKIRHf (ORCPT ); Wed, 9 Nov 2016 12:07:35 -0500 Received: from mail-pf0-f176.google.com ([209.85.192.176]:34105 "EHLO mail-pf0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753562AbcKIRHe (ORCPT ); Wed, 9 Nov 2016 12:07:34 -0500 Received: by mail-pf0-f176.google.com with SMTP id n85so129721621pfi.1 for ; Wed, 09 Nov 2016 09:07:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cumulusnetworks.com; s=google; h=from:to:cc:subject:date:message-id; bh=BP7HnII80VFphlinFQraDRf5EpZZxKfrY5eHVF85kqc=; b=JJigVfn7giauCXUFX+z1JNE04hZcSD35cu2QF8lpednm7paFzW2YnehpmCZucxuiib G8wyMLcfkVymmH1/B/ggQammF1kF5lLeyjJNCWebGOmUOIh2klddVgTDD0p2sTWCn/FH dlcqssQKcngO6HT3wBSoaIr+ZNe76wk2tvYM4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=BP7HnII80VFphlinFQraDRf5EpZZxKfrY5eHVF85kqc=; b=GrAl/0C9ocrE+PkCa/q417pFMz+d5OA76EcDqGEnt45MZV5YP0mbQPDKmG2UWpKqDT tPSdqaPY7QCQsJoiaUwqSFZP05cxIU1v964wWiSN+jaG4LTX2JVLiZIc0YguaxDtCH7m UlW5BqIUak/F58JujcdbT2/XS95/DAAATSD+VwSUwrbytllw81ZcNYnHYYi7Xhj+mcbp JeOmx9lyqobEld/GcPYXbkhD4mPsR+QYvr1W4vsWrskwRckxcPVN8YIvg7ArSmXoyegO xaNiL8uz1Kq4SkYdYs2KBhlv1aqAovi3bw5oWjZ7of3jiP4o7SbRMvXHYcQyDVfEKVP2 Toyg== X-Gm-Message-State: ABUngvc9xDKmZ42lCNr2w/cjGCO1BICprCGd/ZTb2GryPN0hpBrXO0EUiar16heQoVC9htDy X-Received: by 10.99.202.72 with SMTP id o8mr7493476pgi.41.1478711253760; Wed, 09 Nov 2016 09:07:33 -0800 (PST) Received: from kenny.cumulusnetworks.com. ([216.129.126.126]) by smtp.googlemail.com with ESMTPSA id j63sm572834pfj.70.2016.11.09.09.07.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 09 Nov 2016 09:07:33 -0800 (PST) From: David Ahern To: netdev@vger.kernel.org Cc: lorenzo@google.com, David Ahern Subject: [PATCH] net: tcp response should set oif only if it is L3 master Date: Wed, 9 Nov 2016 09:07:26 -0800 Message-Id: <1478711246-17440-1-git-send-email-dsa@cumulusnetworks.com> X-Mailer: git-send-email 2.1.4 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Lorenzo noted an Android unit test failed due to e0d56fdd7342: "The expectation in the test was that the RST replying to a SYN sent to a closed port should be generated with oif=0. In other words it should not prefer the interface where the SYN came in on, but instead should follow whatever the routing table says it should do." Revert the change to ip_send_unicast_reply and tcp_v6_send_response such that the oif in the flow is set to the skb_iif only if skb_iif is an L3 master. Fixes: e0d56fdd7342 ("net: l3mdev: remove redundant calls") Reported-by: Lorenzo Colitti Signed-off-by: David Ahern Tested-by: Lorenzo Colitti Acked-by: Lorenzo Colitti --- net/ipv4/ip_output.c | 3 ++- net/ipv6/tcp_ipv6.c | 8 ++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c index 03e7f7310423..7cf627b0b248 100644 --- a/net/ipv4/ip_output.c +++ b/net/ipv4/ip_output.c @@ -1579,7 +1579,8 @@ void ip_send_unicast_reply(struct sock *sk, struct sk_buff *skb, } oif = arg->bound_dev_if; - oif = oif ? : skb->skb_iif; + if (!oif && netif_index_is_l3_master(net, skb->skb_iif)) + oif = skb->skb_iif; flowi4_init_output(&fl4, oif, IP4_REPLY_MARK(net, skb->mark), diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index 5a27ab4eab39..6ca23c2e76f7 100644 --- a/net/ipv6/tcp_ipv6.c +++ b/net/ipv6/tcp_ipv6.c @@ -818,8 +818,12 @@ static void tcp_v6_send_response(const struct sock *sk, struct sk_buff *skb, u32 fl6.flowi6_proto = IPPROTO_TCP; if (rt6_need_strict(&fl6.daddr) && !oif) fl6.flowi6_oif = tcp_v6_iif(skb); - else - fl6.flowi6_oif = oif ? : skb->skb_iif; + else { + if (!oif && netif_index_is_l3_master(net, skb->skb_iif)) + oif = skb->skb_iif; + + fl6.flowi6_oif = oif; + } fl6.flowi6_mark = IP6_REPLY_MARK(net, skb->mark); fl6.fl6_dport = t1->dest;