net: selftest: fix build issue if INET is disabled
authorOleksij Rempel <o.rempel@pengutronix.de>
Wed, 28 Apr 2021 13:09:46 +0000 (15:09 +0200)
committerJakub Kicinski <kuba@kernel.org>
Wed, 28 Apr 2021 21:06:45 +0000 (14:06 -0700)
In case ethernet driver is enabled and INET is disabled, selftest will
fail to build.

Reported-by: Randy Dunlap <rdunlap@infradead.org>
Fixes: 3e1e58d64c3d ("net: add generic selftest support")
Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
Acked-by: Randy Dunlap <rdunlap@infradead.org> # build-tested
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Link: https://lore.kernel.org/r/20210428130947.29649-1-o.rempel@pengutronix.de
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/atheros/Kconfig
drivers/net/ethernet/freescale/Kconfig
include/net/selftests.h
net/Kconfig
net/core/Makefile
net/dsa/Kconfig

index 6842b74b0696b7e521da99eb3332fe7a4b814e05..482c58c4c5844ac9b982e3591c94f615db70a6ae 100644 (file)
@@ -20,8 +20,8 @@ if NET_VENDOR_ATHEROS
 config AG71XX
        tristate "Atheros AR7XXX/AR9XXX built-in ethernet mac support"
        depends on ATH79
-       select NET_SELFTESTS
        select PHYLINK
+       imply NET_SELFTESTS
        help
          If you wish to compile a kernel for AR7XXX/91XXX and enable
          ethernet support, then you should always answer Y to this.
index 3d937b4650b2dee70aaa2da68d82c987ac1ee2eb..2d1abdd58fab6faebd78fd174d3b124dd5599793 100644 (file)
@@ -26,8 +26,8 @@ config FEC
                   ARCH_MXC || SOC_IMX28 || COMPILE_TEST)
        default ARCH_MXC || SOC_IMX28 if ARM
        select CRC32
-       select NET_SELFTESTS
        select PHYLIB
+       imply NET_SELFTESTS
        imply PTP_1588_CLOCK
        help
          Say Y here if you want to use the built-in 10/100 Fast ethernet
index 9993b9498cf3f7fa5a2f530bfa270021c144e05c..e65e8d230d33c2410f58c06b2907097f4a8621d9 100644 (file)
@@ -4,9 +4,28 @@
 
 #include <linux/ethtool.h>
 
+#if IS_ENABLED(CONFIG_NET_SELFTESTS)
+
 void net_selftest(struct net_device *ndev, struct ethtool_test *etest,
                  u64 *buf);
 int net_selftest_get_count(void);
 void net_selftest_get_strings(u8 *data);
 
+#else
+
+static inline void net_selftest(struct net_device *ndev, struct ethtool_test *etest,
+                               u64 *buf)
+{
+}
+
+static inline int net_selftest_get_count(void)
+{
+       return 0;
+}
+
+static inline void net_selftest_get_strings(u8 *data)
+{
+}
+
+#endif
 #endif /* _NET_SELFTESTS */
index 8d955195c06926255fbcc3d612a5d4833bcec690..f5ee7c65e6b4b905970ae91c7ab8e06eeb9878fc 100644 (file)
@@ -431,7 +431,7 @@ config SOCK_VALIDATE_XMIT
 
 config NET_SELFTESTS
        def_tristate PHYLIB
-       depends on PHYLIB
+       depends on PHYLIB && INET
 
 config NET_SOCK_MSG
        bool
index 1a6168d8f23b1e01df95dac436551e97389104c9..f7f16650fe9ef22f509852fb77d9cade12e5ddfb 100644 (file)
@@ -21,6 +21,7 @@ obj-$(CONFIG_NETPOLL) += netpoll.o
 obj-$(CONFIG_FIB_RULES) += fib_rules.o
 obj-$(CONFIG_TRACEPOINTS) += net-traces.o
 obj-$(CONFIG_NET_DROP_MONITOR) += drop_monitor.o
+obj-$(CONFIG_NET_SELFTESTS) += selftests.o
 obj-$(CONFIG_NETWORK_PHY_TIMESTAMPING) += timestamping.o
 obj-$(CONFIG_NET_PTP_CLASSIFY) += ptp_classifier.o
 obj-$(CONFIG_CGROUP_NET_PRIO) += netprio_cgroup.o
@@ -33,7 +34,6 @@ obj-$(CONFIG_NET_DEVLINK) += devlink.o
 obj-$(CONFIG_GRO_CELLS) += gro_cells.o
 obj-$(CONFIG_FAILOVER) += failover.o
 ifeq ($(CONFIG_INET),y)
-obj-$(CONFIG_NET_SELFTESTS) += selftests.o
 obj-$(CONFIG_NET_SOCK_MSG) += skmsg.o
 obj-$(CONFIG_BPF_SYSCALL) += sock_map.o
 endif
index 5baba702142764eaabf8c8cad785d53ea8e5855a..00bb89b2d86fca4af728c6412e2da55d7bf16543 100644 (file)
@@ -9,7 +9,7 @@ menuconfig NET_DSA
        select NET_SWITCHDEV
        select PHYLINK
        select NET_DEVLINK
-       select NET_SELFTESTS
+       imply NET_SELFTESTS
        help
          Say Y if you want to enable support for the hardware switches supported
          by the Distributed Switch Architecture.