From 4b7e51305fcbf27d8c447e165484f513f9ec7185 Mon Sep 17 00:00:00 2001
From: John Crispin <john@phrozen.org>
Date: Wed, 4 Aug 2021 08:36:30 +0200
Subject: [PATCH 39/43] netifd: fix compile on older kernels

The ethtool features do not exist on ancient qualcomm kernels.
Disable that feature if running on QCA.

Signed-off-by: John Crispin <john@phrozen.org>
---
 .../config/netifd/patches/003-ethtool.patch   | 31 +++++++++++++++++++
 1 file changed, 31 insertions(+)
 create mode 100644 package/network/config/netifd/patches/003-ethtool.patch

diff --git a/package/network/config/netifd/patches/003-ethtool.patch b/package/network/config/netifd/patches/003-ethtool.patch
new file mode 100644
index 0000000000..6aee86283e
--- /dev/null
+++ b/package/network/config/netifd/patches/003-ethtool.patch
@@ -0,0 +1,31 @@
+Index: netifd-2021-05-26-1eb0fafa/system-linux.c
+===================================================================
+--- netifd-2021-05-26-1eb0fafa.orig/system-linux.c
++++ netifd-2021-05-26-1eb0fafa/system-linux.c
+@@ -1578,6 +1578,8 @@ int system_vlandev_del(struct device *vl
+ 	return system_link_del(vlandev->ifname);
+ }
+ 
++#ifdef SPEED_400000
++// ugly hack to detect if we are running on an ancient kernel
+ static void
+ system_set_ethtool_settings(struct device *dev, struct device_settings *s)
+ {
+@@ -1628,6 +1630,7 @@ system_set_ethtool_settings(struct devic
+ 	ecmd.cmd = ETHTOOL_SSET;
+ 	ioctl(sock_ioctl, SIOCETHTOOL, &ifr);
+ }
++#endif
+ 
+ void
+ system_if_get_settings(struct device *dev, struct device_settings *s)
+@@ -1852,7 +1855,9 @@ system_if_apply_settings(struct device *
+ 		system_set_drop_unsolicited_na(dev, s->drop_unsolicited_na ? "1" : "0");
+ 	if (apply_mask & DEV_OPT_ARP_ACCEPT)
+ 		system_set_arp_accept(dev, s->arp_accept ? "1" : "0");
++#ifdef SPEED_400000
+ 	system_set_ethtool_settings(dev, s);
++#endif
+ }
+ 
+ int system_if_up(struct device *dev)
-- 
2.25.1

