From patchwork Tue Jul 25 15:38:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Ahern X-Patchwork-Id: 793504 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="sh21t43j"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3xH2V32Sq7z9rxm for ; Wed, 26 Jul 2017 01:39:23 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752763AbdGYPjC (ORCPT ); Tue, 25 Jul 2017 11:39:02 -0400 Received: from mail-pg0-f65.google.com ([74.125.83.65]:34724 "EHLO mail-pg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752510AbdGYPi7 (ORCPT ); Tue, 25 Jul 2017 11:38:59 -0400 Received: by mail-pg0-f65.google.com with SMTP id v190so14808746pgv.1 for ; Tue, 25 Jul 2017 08:38:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=2vvTjKputGfIdXJrh2xUiuJL1VlmVYe+27/L557UI1k=; b=sh21t43jn6Np9jfa8yyCZT8oM90DOsWz8rI72PQhB6Khil6Rp1FnMhkB5joUFhw5Dt vQdrZh3a84akLFOZU9BL1UnW0knHeokJgK7K3ksXa+kReY8a55qyVRtJGU9U9rueoiiB 5TR/oQoh5FD1W/rrs2uJG5lyxd5mWRTpiYzERXyVST0G7DVLPsSZS7fVCWxqR63l5Riq iRFZR7hZ+66ZQa7P4wtdyevd5Rg8OrwlEOHO9ThwV3sPkkkyyjaskHA+6MYECLi/MLRU 1vb05RgjCZDz3YD0PtTaRTZGPq6Cmd5fONHflnM62bGYNqKd9RNjA0JxqeDWK/VHte9g 8z7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=2vvTjKputGfIdXJrh2xUiuJL1VlmVYe+27/L557UI1k=; b=eT4PANsgUaM3W09hBV1k7VhdmBznW4IOZ07Kr/OKaoun9N5eNqKOCbROwNxrkhmXu6 U0s6tGq9mMO45nKG6OM2if/AyFM6JD3A0vaSALW1Fg3XQinCEOCmlyvfkxdsxqDu+IH4 pi2HeniSP+zIuMBU/tTvbo7J0BzeRbjb3NIGXVengWj60T+KSlQaJbwgIGlMeVha7Bj8 gWFhisT2rsCmICVVnXrJoCWbYlgK2KLUKK6nNL6YnZUQCip5IypcLVhzoOgS/NOWsYKS XnhENhHKFjzEW7JaFeEu1/+KDoTgTvdr9dx5TkXlvyStyaSfNXPr4irTUgPnXjvfRrr+ iuVA== X-Gm-Message-State: AIVw111II3g408MsG8lhFg5QHiG61SKSTKWaQmoZz6PGID/8ZiAFHcR4 G1ijIQ353uTPfCk8 X-Received: by 10.101.85.196 with SMTP id k4mr2588736pgs.150.1500997138590; Tue, 25 Jul 2017 08:38:58 -0700 (PDT) Received: from kenny.it.cumulusnetworks.com. (fw.cumulusnetworks.com. [216.129.126.126]) by smtp.googlemail.com with ESMTPSA id 124sm26400230pgj.57.2017.07.25.08.38.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 25 Jul 2017 08:38:58 -0700 (PDT) From: David Ahern To: netdev@vger.kernel.org Cc: David Ahern Subject: [RFC PATCH 08/10] net: Add sdif to sk_lookup Date: Tue, 25 Jul 2017 08:38:39 -0700 Message-Id: <1500997121-3218-9-git-send-email-dsahern@gmail.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1500997121-3218-1-git-send-email-dsahern@gmail.com> References: <1500997121-3218-1-git-send-email-dsahern@gmail.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Add a second device index, sdif, to the socket lookup struct. sdif will be the device index for devices enslaved to an l3mdev. It allows the lookups to consider the enslaved device as well as the L3 master device when searching for a socket. Signed-off-by: David Ahern --- include/net/sock.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/include/net/sock.h b/include/net/sock.h index a2db5fd30192..c5d93a4bcd0a 100644 --- a/include/net/sock.h +++ b/include/net/sock.h @@ -507,23 +507,27 @@ struct sk_lookup { unsigned short hnum; int dif; + int sdif; bool exact_dif; }; -/* Compare sk_bound_dev_if to socket lookup dif +/* Compare sk_bound_dev_if to socket lookup dif and sdif * Returns: * -1 exact dif required and not met * 0 sk_bound_dev_if is either not set or does not match - * 1 sk_bound_dev_if is set and matches dif + * 1 sk_bound_dev_if is set and matches dif or sdif */ static inline int sk_lookup_device_cmp(const struct sock *sk, const struct sk_lookup *params) { + bool dev_match = (sk->sk_bound_dev_if == params->dif || + sk->sk_bound_dev_if == params->sdif); + /* exact_dif true == l3mdev case */ - if (params->exact_dif && sk->sk_bound_dev_if != params->dif) + if (params->exact_dif && !dev_match) return -1; - if (sk->sk_bound_dev_if && sk->sk_bound_dev_if == params->dif) + if (sk->sk_bound_dev_if && dev_match) return 1; return 0;