From patchwork Thu Nov 2 16:14:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Pirko X-Patchwork-Id: 833417 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=resnulli-us.20150623.gappssmtp.com header.i=@resnulli-us.20150623.gappssmtp.com header.b="lBXzKocp"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3ySVXk6JW8z9t2r for ; Fri, 3 Nov 2017 03:14:46 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934073AbdKBQOp (ORCPT ); Thu, 2 Nov 2017 12:14:45 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:50835 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933567AbdKBQOO (ORCPT ); Thu, 2 Nov 2017 12:14:14 -0400 Received: by mail-wm0-f68.google.com with SMTP id s66so4191wmf.5 for ; Thu, 02 Nov 2017 09:14:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=resnulli-us.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=bVh0y1EtQ9fkky1igMLPK3N9jNy91yCbCLrloocFCFY=; b=lBXzKocpe5FhJ5K1BoY/I6s+YY2wUa0CfuuIBsw2nUU3P34yt7cDU6fYFUhYruDXkA v6zr+pWx4DK48hyihlGvgZUqLMTwPm+f7OPtqgFaJ8NwETCRbwi4TafJOLzi/s+QhgNu /abFr+1hXDxjdCh8keeK+F7hVEJH3orDduXMw2zFN5/1NiJp2SLObGv0d+ulM4TjYdRR QtjyoD5U4dwuJnANj479snBGT+q6WbtaOOSVL2Bxbt7fYJ9GLs5oTOi2fbqEW3mUyVkZ TO2YRoU0OzmgKWzbdZeAx+JIW8XK6l4U4a13T2BA6BfWOHOLyTbOqEIElNVtGNt/dMJE bKDw== 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=bVh0y1EtQ9fkky1igMLPK3N9jNy91yCbCLrloocFCFY=; b=sVgR1TDRn9fPFLFl5XRZSZobI6emNmh3LGp2SyFNcofcxmgakTEnfPldF4zn9uqXs3 vk/+dQoO1H8+wjV8CHdW0inDQGaPty/z8E2MsAqKqL5gA9cYda+bVPzZzLjXkeTur7xy i2IeMmKx7eKjZD4HYI5oX9Z8C7Xh7RxSwUEEALbL3aR6BSwK4KeTXCVpRpfdl91oE7X8 5rIbZAN41fhTlwBiI2RRlN07ZF9hK05dUoQ1KSDB4fBMU1at5TcD8Bj8ztscfMzroDMD 5qMx6H0Nwusof0QNCEH0+GJePC4m6CdhY6C2vY0EUT1Yal6I2iGzRt9qFo2r3B96zWzl 5adQ== X-Gm-Message-State: AJaThX6ZN6K07EcOs+I2DtdcMmOXmgf55CFfw2Ynk9FDjCpqpJPoi4TV 0GF69uSDD9NwneivHbJOiZRnvpjJ X-Google-Smtp-Source: ABhQp+RR+LQDJXxqk5cbMQ9GGF/sTYIL3KwlnnBVX2Syo3Sl/e5KsMTZcCRIcv3CggFjx6Ie9ud2kQ== X-Received: by 10.28.211.15 with SMTP id k15mr2021551wmg.33.1509639253327; Thu, 02 Nov 2017 09:14:13 -0700 (PDT) Received: from localhost (ip-94-113-127-32.net.upcbroadband.cz. [94.113.127.32]) by smtp.gmail.com with ESMTPSA id k69sm5255061wmg.45.2017.11.02.09.14.12 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 Nov 2017 09:14:12 -0700 (PDT) From: Jiri Pirko To: netdev@vger.kernel.org Cc: davem@davemloft.net, idosch@mellanox.com, mlxsw@mellanox.com, dsahern@gmail.com Subject: [patch net-next 1/6] ipv4: Send a netevent whenever multipath hash policy is changed Date: Thu, 2 Nov 2017 17:14:05 +0100 Message-Id: <20171102161410.12171-2-jiri@resnulli.us> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20171102161410.12171-1-jiri@resnulli.us> References: <20171102161410.12171-1-jiri@resnulli.us> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Ido Schimmel Devices performing IPv4 forwarding need to update their multipath hash policy whenever it is changed. Inform these devices by generating a netevent. Signed-off-by: Ido Schimmel Reviewed-by: Petr Machata Signed-off-by: Jiri Pirko Acked-by: David Ahern --- include/net/netevent.h | 1 + net/ipv4/sysctl_net_ipv4.c | 20 +++++++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/include/net/netevent.h b/include/net/netevent.h index f440df1..e3f0e8f 100644 --- a/include/net/netevent.h +++ b/include/net/netevent.h @@ -25,6 +25,7 @@ enum netevent_notif_type { NETEVENT_NEIGH_UPDATE = 1, /* arg is struct neighbour ptr */ NETEVENT_REDIRECT, /* arg is struct netevent_redirect ptr */ NETEVENT_DELAY_PROBE_TIME_UPDATE, /* arg is struct neigh_parms ptr */ + NETEVENT_MULTIPATH_HASH_UPDATE, /* arg is struct net ptr */ }; int register_netevent_notifier(struct notifier_block *nb); diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c index 4602af6..8dcc2b1 100644 --- a/net/ipv4/sysctl_net_ipv4.c +++ b/net/ipv4/sysctl_net_ipv4.c @@ -25,6 +25,7 @@ #include #include #include +#include static int zero; static int one = 1; @@ -385,6 +386,23 @@ static int proc_tcp_available_ulp(struct ctl_table *ctl, return ret; } +#ifdef CONFIG_IP_ROUTE_MULTIPATH +static int proc_fib_multipath_hash_policy(struct ctl_table *table, int write, + void __user *buffer, size_t *lenp, + loff_t *ppos) +{ + struct net *net = container_of(table->data, struct net, + ipv4.sysctl_fib_multipath_hash_policy); + int ret; + + ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos); + if (write && ret == 0) + call_netevent_notifiers(NETEVENT_MULTIPATH_HASH_UPDATE, net); + + return ret; +} +#endif + static struct ctl_table ipv4_table[] = { { .procname = "tcp_max_orphans", @@ -907,7 +925,7 @@ static struct ctl_table ipv4_net_table[] = { .data = &init_net.ipv4.sysctl_fib_multipath_hash_policy, .maxlen = sizeof(int), .mode = 0644, - .proc_handler = proc_dointvec_minmax, + .proc_handler = proc_fib_multipath_hash_policy, .extra1 = &zero, .extra2 = &one, },