shortcut-fe: Porting shortcut-fe to Linux kernel 5.4
Porting shortcut-fe to Linux kernel 5.4 and solve compilation
problems.
Signed-off-by: Tian Yang <tiany@codeaurora.org>
Change-Id: Id92c4cd0b05340dac3b674fa7d1868208f0b6948
diff --git a/shortcut-fe/sfe_ipv4.c b/shortcut-fe/sfe_ipv4.c
index 554dd08..9f7ebd1 100644
--- a/shortcut-fe/sfe_ipv4.c
+++ b/shortcut-fe/sfe_ipv4.c
@@ -2,7 +2,7 @@
* sfe_ipv4.c
* Shortcut forwarding engine - IPv4 edition.
*
- * Copyright (c) 2013-2016, 2019, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2013-2016, 2019-2020 The Linux Foundation. All rights reserved.
* Permission to use, copy, modify, and/or distribute this software for
* any purpose with or without fee is hereby granted, provided that the
* above copyright notice and this permission notice appear in all copies.
@@ -21,6 +21,7 @@
#include <linux/icmp.h>
#include <net/tcp.h>
#include <linux/etherdevice.h>
+#include <linux/version.h>
#include "sfe.h"
#include "sfe_cm.h"
@@ -1308,7 +1309,7 @@
* change the cloned skb's data section.
*/
if (unlikely(skb_cloned(skb))) {
- DEBUG_TRACE("%p: skb is a cloned skb\n", skb);
+ DEBUG_TRACE("%px: skb is a cloned skb\n", skb);
skb = skb_unshare(skb, GFP_ATOMIC);
if (!skb) {
DEBUG_WARN("Failed to unshare the cloned skb\n");
@@ -1884,7 +1885,7 @@
* change the cloned skb's data section.
*/
if (unlikely(skb_cloned(skb))) {
- DEBUG_TRACE("%p: skb is a cloned skb\n", skb);
+ DEBUG_TRACE("%px: skb is a cloned skb\n", skb);
skb = skb_unshare(skb, GFP_ATOMIC);
if (!skb) {
DEBUG_WARN("Failed to unshare the cloned skb\n");
@@ -2501,7 +2502,7 @@
spin_unlock_bh(&si->lock);
DEBUG_TRACE("connection already exists - mark: %08x, p: %d\n"
- " s: %s:%pM:%pI4:%u, d: %s:%pM:%pI4:%u\n",
+ " s: %s:%pxM:%pI4:%u, d: %s:%pxM:%pI4:%u\n",
sic->mark, sic->protocol,
sic->src_dev->name, sic->src_mac, &sic->src_ip.ip, ntohs(sic->src_port),
sic->dest_dev->name, sic->dest_mac, &sic->dest_ip.ip, ntohs(sic->dest_port));
@@ -2717,8 +2718,8 @@
* We have everything we need!
*/
DEBUG_INFO("new connection - mark: %08x, p: %d\n"
- " s: %s:%pM(%pM):%pI4(%pI4):%u(%u)\n"
- " d: %s:%pM(%pM):%pI4(%pI4):%u(%u)\n",
+ " s: %s:%pxM(%pxM):%pI4(%pI4):%u(%u)\n"
+ " d: %s:%pxM(%pxM):%pI4(%pI4):%u(%u)\n",
sic->mark, sic->protocol,
sic->src_dev->name, sic->src_mac, sic->src_mac_xlate,
&sic->src_ip.ip, &sic->src_ip_xlate.ip, ntohs(sic->src_port), ntohs(sic->src_port_xlate),
@@ -2847,9 +2848,17 @@
/*
* sfe_ipv4_periodic_sync()
*/
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0))
static void sfe_ipv4_periodic_sync(unsigned long arg)
+#else
+static void sfe_ipv4_periodic_sync(struct timer_list *tl)
+#endif
{
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0))
struct sfe_ipv4 *si = (struct sfe_ipv4 *)arg;
+#else
+ struct sfe_ipv4 *si = from_timer(si, tl, timer);
+#endif
u64 now_jiffies;
int quota;
sfe_sync_rule_callback_t sync_rule_callback;
@@ -3528,7 +3537,11 @@
/*
* Create a timer to handle periodic statistics.
*/
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0))
setup_timer(&si->timer, sfe_ipv4_periodic_sync, (unsigned long)si);
+#else
+ timer_setup(&si->timer, sfe_ipv4_periodic_sync, 0);
+#endif
mod_timer(&si->timer, jiffies + ((HZ + 99) / 100));
spin_lock_init(&si->lock);