Skip to content

Commit

Permalink
net: selftest: fix build issue if INET is disabled
Browse files Browse the repository at this point in the history
In case ethernet driver is enabled and INET is disabled, selftest will
fail to build.

Reported-by: Randy Dunlap <[email protected]>
Fixes: 3e1e58d ("net: add generic selftest support")
Signed-off-by: Oleksij Rempel <[email protected]>
Acked-by: Randy Dunlap <[email protected]> # build-tested
Reviewed-by: Florian Fainelli <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jakub Kicinski <[email protected]>
  • Loading branch information
olerem authored and kuba-moo committed Apr 28, 2021
1 parent 15c0a64 commit 4a52dd8
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 5 deletions.
2 changes: 1 addition & 1 deletion drivers/net/ethernet/atheros/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/ethernet/freescale/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 19 additions & 0 deletions include/net/selftests.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
2 changes: 1 addition & 1 deletion net/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion net/core/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion net/dsa/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 4a52dd8

Please sign in to comment.