From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2CD53C43381 for ; Fri, 22 Feb 2019 18:12:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E907A206B6 for ; Fri, 22 Feb 2019 18:12:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=cumulusnetworks.com header.i=@cumulusnetworks.com header.b="GL+WUA8u" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727550AbfBVSM4 (ORCPT ); Fri, 22 Feb 2019 13:12:56 -0500 Received: from internalmail.cumulusnetworks.com ([45.55.219.144]:60069 "EHLO internalmail.cumulusnetworks.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726902AbfBVSMw (ORCPT ); Fri, 22 Feb 2019 13:12:52 -0500 Received: from localhost (fw.cumulusnetworks.com [216.129.126.126]) by internalmail.cumulusnetworks.com (Postfix) with ESMTPSA id 3A382C11EE; Fri, 22 Feb 2019 10:06:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cumulusnetworks.com; s=mail; t=1550858801; bh=mnxJdY7/TKPb3iql/usPHWXVvNU+GbIDKdDGDz9f3i0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=GL+WUA8ufu3DzjD4Gs3zmKDXtAOXUGxo6bOjnUHNasJYbobp7dOS8xm8IEkH+xxfa jhJK1JmYckcCKQeJVfRyP4kEtP+bC5V0eK3Rk+PF5xoeq86BIixusWF2CzelzsZnZa 5igkgkkijFMom+BZ2JCmjKIW0L9Ixk7MJ7R+HGkA= From: Andy Roulin To: davem@davemloft.net Cc: netdev@vger.kernel.org, roopa@cumulusnetworks.com, aroulin@cumulusnetworks.com Subject: [PATCH net-next 1/3] net: dev: add generic protodown handler Date: Fri, 22 Feb 2019 18:06:36 +0000 Message-Id: <20190222180638.10904-2-aroulin@cumulusnetworks.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190222180638.10904-1-aroulin@cumulusnetworks.com> References: <20190222180638.10904-1-aroulin@cumulusnetworks.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Introduce dev_change_proto_down_generic, a generic ndo_change_proto_down implementation, which sets the netdev carrier state according to proto_down. This adds the ability to set protodown on vxlan and macvlan devices in a generic way for use by control protocols like VRRPD. Signed-off-by: Andy Roulin Acked-by: Roopa Prabhu --- include/linux/netdevice.h | 1 + net/core/dev.c | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index aab4d9f6613d..9a093fde030d 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -3663,6 +3663,7 @@ int dev_get_port_parent_id(struct net_device *dev, struct netdev_phys_item_id *ppid, bool recurse); bool netdev_port_same_parent_id(struct net_device *a, struct net_device *b); int dev_change_proto_down(struct net_device *dev, bool proto_down); +int dev_change_proto_down_generic(struct net_device *dev, bool proto_down); struct sk_buff *validate_xmit_skb_list(struct sk_buff *skb, struct net_device *dev, bool *again); struct sk_buff *dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev, struct netdev_queue *txq, int *ret); diff --git a/net/core/dev.c b/net/core/dev.c index a3d13f5e2bfc..e99a870772c1 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -7954,6 +7954,25 @@ int dev_change_proto_down(struct net_device *dev, bool proto_down) } EXPORT_SYMBOL(dev_change_proto_down); +/** + * dev_change_proto_down_generic - generic implementation for + * ndo_change_proto_down that sets carrier according to + * proto_down. + * + * @dev: device + * @proto_down: new value + */ +int dev_change_proto_down_generic(struct net_device *dev, bool proto_down) +{ + if (proto_down) + netif_carrier_off(dev); + else + netif_carrier_on(dev); + dev->proto_down = proto_down; + return 0; +} +EXPORT_SYMBOL(dev_change_proto_down_generic); + u32 __dev_xdp_query(struct net_device *dev, bpf_op_t bpf_op, enum bpf_netdev_command cmd) { -- 2.11.0