From patchwork Tue May 10 18:19:51 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Ahern X-Patchwork-Id: 620762 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 3r46xD2jyJz9sBR for ; Wed, 11 May 2016 04:20:16 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=cumulusnetworks.com header.i=@cumulusnetworks.com header.b=LW3BUolK; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752045AbcEJSUG (ORCPT ); Tue, 10 May 2016 14:20:06 -0400 Received: from mail-pf0-f170.google.com ([209.85.192.170]:35223 "EHLO mail-pf0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752015AbcEJSUD (ORCPT ); Tue, 10 May 2016 14:20:03 -0400 Received: by mail-pf0-f170.google.com with SMTP id 77so8480653pfv.2 for ; Tue, 10 May 2016 11:20:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cumulusnetworks.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=A0hou2f1owTwkiwVQSkJUNwL2pH+/DUE4JGM0zOBBXY=; b=LW3BUolKQ4vmdTLH54r4cFxaPI+bH8iHyFLE+CIqS0S7luYm+oEL8q7rHx2wultEny K/hXuJFDxhQDanqTGiOXVoAeJMCZEB7MJA+gQVu40XZfhMkoc23QPQwya/jlikic+K98 Hj4cdPUDQmIe68DKc4ZaBeVBbUCX/H+mA0fL8= 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:in-reply-to :references; bh=A0hou2f1owTwkiwVQSkJUNwL2pH+/DUE4JGM0zOBBXY=; b=Hx1AjHQMZbdIlX4ku4DYdHRWobyU9zeFDb9e2U12TQmPyprWCIJ+AEXjE0S0evdPIx YqZ7CLALmbIodVf0uRQUc8MH17GqDS8vNK8G2qL+aXJgbiAwxyrNDZz2e6+nIL53IDr9 qLa0rZtsZ3jMUwmBXwe+QrtfXM/xQOCKr72FM89j9jOoQ7m57DEfB+Uz6LmGHKWIKxr2 ljR0TPUSHQ/KFUBK26SmVT/n1y/i5HeLEMPgsyMVU2YdDS5b2a0mbkw2kaHeiVZtOG2N lOzelFBWVXORPzMrbnmwFXKXuqCMXNNXyFxvH+k1lXE6Rtf0Opgt6/O+MtESA600Dlak 5S9Q== X-Gm-Message-State: AOPr4FW/bkeZdIBhxsla7/6aHefk0M3l/uvm/1Q6mm870N1NaNEMK32P8qcGlw2TfSOyuQgb X-Received: by 10.98.47.194 with SMTP id v185mr59799884pfv.120.1462904401403; Tue, 10 May 2016 11:20:01 -0700 (PDT) Received: from kenny.cumulusnetworks.com. ([216.129.126.126]) by smtp.googlemail.com with ESMTPSA id l123sm6137602pfl.36.2016.05.10.11.20.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 10 May 2016 11:20:00 -0700 (PDT) From: David Ahern To: netdev@vger.kernel.org Cc: David Ahern Subject: [PATCH net-next 2/2] net: original ingress device index in PKTINFO Date: Tue, 10 May 2016 11:19:51 -0700 Message-Id: <1462904391-1253-3-git-send-email-dsa@cumulusnetworks.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1462904391-1253-1-git-send-email-dsa@cumulusnetworks.com> References: <1462904391-1253-1-git-send-email-dsa@cumulusnetworks.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Applications such as OSPF and BFD need the original ingress device not the VRF device; the latter can be derived from the former. To that end add the skb_iif to inet_skb_parm and set it in ipv4 code after clearing the skb control buffer similar to IPv6. From there the pktinfo can just pull it from cb with the PKTINFO_SKB_CB cast. The previous patch moving the skb->dev change to L3 means nothing else is needed for IPv6; it just works. Signed-off-by: David Ahern --- include/net/ip.h | 1 + net/ipv4/ip_input.c | 1 + net/ipv4/ip_sockglue.c | 7 ++++++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/include/net/ip.h b/include/net/ip.h index 247ac82e9cf2..37165fba3741 100644 --- a/include/net/ip.h +++ b/include/net/ip.h @@ -36,6 +36,7 @@ struct sock; struct inet_skb_parm { + int iif; struct ip_options opt; /* Compiled IP options */ unsigned char flags; diff --git a/net/ipv4/ip_input.c b/net/ipv4/ip_input.c index 37375eedeef9..4b351af3e67b 100644 --- a/net/ipv4/ip_input.c +++ b/net/ipv4/ip_input.c @@ -478,6 +478,7 @@ int ip_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt, /* Remove any debris in the socket control block */ memset(IPCB(skb), 0, sizeof(struct inet_skb_parm)); + IPCB(skb)->iif = skb->skb_iif; /* Must drop socket now because of tproxy. */ skb_orphan(skb); diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c index bdb222c0c6a2..5805762d7fc7 100644 --- a/net/ipv4/ip_sockglue.c +++ b/net/ipv4/ip_sockglue.c @@ -1193,7 +1193,12 @@ void ipv4_pktinfo_prepare(const struct sock *sk, struct sk_buff *skb) ipv6_sk_rxinfo(sk); if (prepare && skb_rtable(skb)) { - pktinfo->ipi_ifindex = inet_iif(skb); + /* skb->cb is overloaded: prior to this point it is IP{6}CB + * which has interface index (iif) as the first member of the + * underlying inet{6}_skb_parm struct. This code then overlays + * PKTINFO_SKB_CB and in_pktinfo also has iif as the first + * element so the iif is picked up from the prior IPCB + */ pktinfo->ipi_spec_dst.s_addr = fib_compute_spec_dst(skb); } else { pktinfo->ipi_ifindex = 0;