From patchwork Thu Dec 3 07:53:40 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Stringer X-Patchwork-Id: 552058 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from archives.nicira.com (li376-54.members.linode.com [96.126.127.54]) by ozlabs.org (Postfix) with ESMTP id AE9821402EC for ; Thu, 3 Dec 2015 18:54:50 +1100 (AEDT) Received: from archives.nicira.com (localhost [127.0.0.1]) by archives.nicira.com (Postfix) with ESMTP id EC5B310B65; Wed, 2 Dec 2015 23:54:26 -0800 (PST) X-Original-To: dev@openvswitch.org Delivered-To: dev@openvswitch.org Received: from mx1e3.cudamail.com (mx1.cudamail.com [69.90.118.67]) by archives.nicira.com (Postfix) with ESMTPS id 567E210B61 for ; Wed, 2 Dec 2015 23:54:25 -0800 (PST) Received: from bar2.cudamail.com (localhost [127.0.0.1]) by mx1e3.cudamail.com (Postfix) with ESMTPS id 852B142004B for ; Thu, 3 Dec 2015 00:54:24 -0700 (MST) X-ASG-Debug-ID: 1449129264-03dc5344fcb0f40001-byXFYA Received: from mx1-pf1.cudamail.com ([192.168.24.1]) by bar2.cudamail.com with ESMTP id 06nSXEj3qS7qRUnZ (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 03 Dec 2015 00:54:24 -0700 (MST) X-Barracuda-Envelope-From: joe@ovn.org X-Barracuda-RBL-Trusted-Forwarder: 192.168.24.1 Received: from unknown (HELO relay4-d.mail.gandi.net) (217.70.183.196) by mx1-pf1.cudamail.com with ESMTPS (DHE-RSA-AES256-SHA encrypted); 3 Dec 2015 07:54:23 -0000 Received-SPF: pass (mx1-pf1.cudamail.com: SPF record at ovn.org designates 217.70.183.196 as permitted sender) X-Barracuda-Apparent-Source-IP: 217.70.183.196 X-Barracuda-RBL-IP: 217.70.183.196 Received: from mfilter24-d.gandi.net (mfilter24-d.gandi.net [217.70.178.152]) by relay4-d.mail.gandi.net (Postfix) with ESMTP id 508471720BC; Thu, 3 Dec 2015 08:54:22 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at mfilter24-d.gandi.net Received: from relay4-d.mail.gandi.net ([IPv6:::ffff:217.70.183.196]) by mfilter24-d.gandi.net (mfilter24-d.gandi.net [::ffff:10.0.15.180]) (amavisd-new, port 10024) with ESMTP id dShQfbIKl6p7; Thu, 3 Dec 2015 08:54:20 +0100 (CET) X-Originating-IP: 208.91.1.34 Received: from localhost.localdomain (unknown [208.91.1.34]) (Authenticated sender: joe@ovn.org) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id 7765C1720A9; Thu, 3 Dec 2015 08:54:19 +0100 (CET) X-CudaMail-Envelope-Sender: joe@ovn.org From: Joe Stringer To: dev@openvswitch.org X-CudaMail-Whitelist-To: dev@openvswitch.org X-CudaMail-MID: CM-E1-1202001383 X-CudaMail-DTE: 120315 X-CudaMail-Originating-IP: 217.70.183.196 Date: Wed, 2 Dec 2015 23:53:40 -0800 X-ASG-Orig-Subj: [##CM-E1-1202001383##][PATCHv2 04/20] compat: Backport 'dst' functions. Message-Id: <1449129236-5038-5-git-send-email-joe@ovn.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1449129236-5038-1-git-send-email-joe@ovn.org> References: <1449129236-5038-1-git-send-email-joe@ovn.org> X-Barracuda-Connect: UNKNOWN[192.168.24.1] X-Barracuda-Start-Time: 1449129264 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://web.cudamail.com:443/cgi-mod/mark.cgi X-ASG-Whitelist: Header =?UTF-8?B?eFwtY3VkYW1haWxcLXdoaXRlbGlzdFwtdG8=?= X-Virus-Scanned: by bsmtpd at cudamail.com X-Barracuda-BRTS-Status: 1 Subject: [ovs-dev] [PATCHv2 04/20] compat: Backport 'dst' functions. X-BeenThere: dev@openvswitch.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dev-bounces@openvswitch.org Sender: "dev" From: Joe Stringer Signed-off-by: Joe Stringer --- acinclude.m4 | 2 + datapath/linux/compat/include/net/dst.h | 78 +++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+) diff --git a/acinclude.m4 b/acinclude.m4 index a3dd3eb99bbd..da1d39704c7b 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -450,6 +450,8 @@ AC_DEFUN([OVS_CHECK_LINUX_COMPAT], [ OVS_GREP_IFELSE([$KSRC/include/net/checksum.h], [csum_replace4]) OVS_GREP_IFELSE([$KSRC/include/net/checksum.h], [csum_unfold]) + OVS_GREP_IFELSE([$KSRC/include/net/dst.h], [dst_discard_sk]) + OVS_GREP_IFELSE([$KSRC/include/net/genetlink.h], [genl_has_listeners]) OVS_GREP_IFELSE([$KSRC/include/net/genetlink.h], [mcgrp_offset]) OVS_GREP_IFELSE([$KSRC/include/net/genetlink.h], [parallel_ops]) diff --git a/datapath/linux/compat/include/net/dst.h b/datapath/linux/compat/include/net/dst.h index 9d9e6160351d..de74c9383b8b 100644 --- a/datapath/linux/compat/include/net/dst.h +++ b/datapath/linux/compat/include/net/dst.h @@ -22,4 +22,82 @@ static inline void skb_dst_drop(struct sk_buff *skb) #endif +#ifndef DST_OBSOLETE_NONE +#define DST_OBSOLETE_NONE 0 +#endif + +#ifndef DST_NOCOUNT +#define DST_NOCOUNT 0 +#endif + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35) +static inline void __skb_dst_copy(struct sk_buff *nskb, unsigned long refdst) +{ + nskb->_skb_dst = refdst; + dst_clone(skb_dst(nskb)); +} + +static inline void refdst_drop(unsigned long refdst) { } +static inline void skb_dst_set_noref(struct sk_buff *skb, + struct dst_entry *dst) { } +static inline void dst_init_metrics(struct dst_entry *dst, const u32 *metrics, + bool read_only) { } +#elif LINUX_VERSION_CODE < KERNEL_VERSION(4,3,0) +static inline void __skb_dst_copy(struct sk_buff *nskb, unsigned long refdst) +{ + nskb->_skb_refdst = refdst; + if (!(nskb->_skb_refdst & SKB_DST_NOREF)) + dst_clone(skb_dst(nskb)); +} +#endif + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,37) +static inline void dst_entries_add(struct dst_ops *ops, int count) +{ + atomic_add(count, &ops->entries); +} +#endif + +#if LINUX_VERSION_CODE < KERNEL_VERSION(4,3,0) +static const u32 rpl_dst_default_metrics[RTAX_MAX + 1] = { + /* This initializer is needed to force linker to place this variable + * into const section. Otherwise it might end into bss section. + * We really want to avoid false sharing on this variable, and catch + * any writes on it. + */ + [RTAX_MAX] = 0xdeadbeef, +}; +#define dst_default_metrics rpl_dst_default_metrics + +static inline void rpl_dst_init(struct dst_entry *dst, struct dst_ops *ops, + struct net_device *dev, int initial_ref, + int initial_obsolete, unsigned short flags) +{ + /* XXX: It's easier to handle compatibility by zeroing, as we can + * refer to fewer fields. Do that here. + */ + memset(dst, 0, sizeof *dst); + + dst->dev = dev; + if (dev) + dev_hold(dev); + dst->ops = ops; + dst_init_metrics(dst, dst_default_metrics, true); + dst->path = dst; + dst->input = dst_discard; +#ifndef HAVE_DST_DISCARD_SK + dst->output = dst_discard; +#else + dst->output = dst_discard_sk; +#endif + dst->obsolete = initial_obsolete; + atomic_set(&dst->__refcnt, initial_ref); + dst->lastuse = jiffies; + dst->flags = flags; + if (!(flags & DST_NOCOUNT)) + dst_entries_add(ops, 1); +} +#define dst_init rpl_dst_init +#endif + #endif