From patchwork Mon Jan 11 12:17:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Frederic Sowa X-Patchwork-Id: 565783 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 703391402DE for ; Mon, 11 Jan 2016 23:17:54 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=stressinduktion.org header.i=@stressinduktion.org header.b=LD5zEcbr; dkim=pass (1024-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b=PwlZB6aW; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932861AbcAKMRt (ORCPT ); Mon, 11 Jan 2016 07:17:49 -0500 Received: from out4-smtp.messagingengine.com ([66.111.4.28]:59851 "EHLO out4-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759595AbcAKMRq (ORCPT ); Mon, 11 Jan 2016 07:17:46 -0500 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id C46FD20B45 for ; Mon, 11 Jan 2016 07:17:45 -0500 (EST) Received: from frontend1 ([10.202.2.160]) by compute6.internal (MEProxy); Mon, 11 Jan 2016 07:17:45 -0500 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= stressinduktion.org; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-sasl-enc:x-sasl-enc; s=mesmtp; bh=9MRkY JYiuGKmy/8VsoJkyWNusRQ=; b=LD5zEcbrhCLKLCbacAy0xqgM4DlNdBqXu7lMc IO1G1xmM0DokwRZZ0HekYQVbK5KsC5EHgKOxDCwGSSigWC/jll/gTRqBzSw6JUHJ 58u98HsIW56XSrKKJEt+T2F46bfcIt40Ssd2yhSs2MrzcW0Zi3lcCJy107JPWjD4 6ICJ38= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=9MRk YJYiuGKmy/8VsoJkyWNusRQ=; b=PwlZB6aWjNx6/9gdr4hngdaTQBQMLqb/20A0 JBMrP4r9x9CB7hEBtz3I5YQJl/0Dfi+ssUkr31ltbC7yC221BWtVlknXKculuInr 8hdY1HqxJiw1Da+PgNs82Yh2+xUE5/Bs8YLCfGYc/pmifiOk4fsUtrs5o2FfAV8n x3O5vAY= X-Sasl-enc: XR0EdRyZBWcqaJ3vd4FP9vWnFgFqo/MiXU4zPx38L/qb 1452514665 Received: from z.localhost.localdomain (unknown [217.192.177.51]) by mail.messagingengine.com (Postfix) with ESMTPA id 396F6C016C4; Mon, 11 Jan 2016 07:17:45 -0500 (EST) From: Hannes Frederic Sowa To: netdev@vger.kernel.org Cc: jesse@kernel.org Subject: [PATCH net-next v5 07/10] vxlan: break dependency to network drivers Date: Mon, 11 Jan 2016 13:17:28 +0100 Message-Id: <1452514651-15445-8-git-send-email-hannes@stressinduktion.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1452514651-15445-1-git-send-email-hannes@stressinduktion.org> References: <1452514651-15445-1-git-send-email-hannes@stressinduktion.org> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Signed-off-by: Hannes Frederic Sowa --- drivers/net/vxlan.c | 20 ++++++++++++++------ include/net/vxlan.h | 5 +---- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c index fecf7b6c732e96..ee45c796cb03cd 100644 --- a/drivers/net/vxlan.c +++ b/drivers/net/vxlan.c @@ -2468,7 +2468,7 @@ static struct device_type vxlan_type = { * supply the listening VXLAN udp ports. Callers are expected * to implement the ndo_add_vxlan_port. */ -void vxlan_get_rx_port(struct net_device *dev) +static void vxlan_notify_refresh_netdev(struct net_device *dev) { struct vxlan_sock *vs; struct net *net = dev_net(dev); @@ -2477,6 +2477,9 @@ void vxlan_get_rx_port(struct net_device *dev) __be16 port; unsigned int i; + if (!dev->netdev_ops->ndo_add_vxlan_port) + return; + spin_lock(&vn->sock_lock); for (i = 0; i < PORT_HASH_SIZE; ++i) { hlist_for_each_entry_rcu(vs, &vn->sock_list[i], hlist) { @@ -2488,7 +2491,6 @@ void vxlan_get_rx_port(struct net_device *dev) } spin_unlock(&vn->sock_lock); } -EXPORT_SYMBOL_GPL(vxlan_get_rx_port); /* Initialize the device structure. */ static void vxlan_setup(struct net_device *dev) @@ -3164,20 +3166,26 @@ static void vxlan_handle_lowerdev_unregister(struct vxlan_net *vn, unregister_netdevice_many(&list_kill); } -static int vxlan_lowerdev_event(struct notifier_block *unused, - unsigned long event, void *ptr) +static int vxlan_notifier(struct notifier_block *unused, + unsigned long event, void *ptr) { struct net_device *dev = netdev_notifier_info_to_dev(ptr); struct vxlan_net *vn = net_generic(dev_net(dev), vxlan_net_id); - if (event == NETDEV_UNREGISTER) + switch (event) { + case NETDEV_REFRESH_OFFLOADS: + vxlan_notify_refresh_netdev(dev); + break; + case NETDEV_UNREGISTER: vxlan_handle_lowerdev_unregister(vn, dev); + break; + } return NOTIFY_DONE; } static struct notifier_block vxlan_notifier_block __read_mostly = { - .notifier_call = vxlan_lowerdev_event, + .notifier_call = vxlan_notifier, }; static __net_init int vxlan_init_net(struct net *net) diff --git a/include/net/vxlan.h b/include/net/vxlan.h index 0fb86442544b26..48d0450160c91f 100644 --- a/include/net/vxlan.h +++ b/include/net/vxlan.h @@ -242,13 +242,10 @@ static inline netdev_features_t vxlan_features_check(struct sk_buff *skb, /* IPv6 header + UDP + VXLAN + Ethernet header */ #define VXLAN6_HEADROOM (40 + 8 + 8 + 14) -#if IS_ENABLED(CONFIG_VXLAN) -void vxlan_get_rx_port(struct net_device *netdev); -#else static inline void vxlan_get_rx_port(struct net_device *netdev) { + call_netdevice_notifiers(NETDEV_REFRESH_OFFLOADS, netdev); } -#endif static inline unsigned short vxlan_get_sk_family(struct vxlan_sock *vs) {