Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: core: move mac_pton() to lib/net_utils.c

Since we have at least one user of this function outside of CONFIG_NET
scope, we have to provide this function independently. The proposed
solution is to move it under lib/net_utils.c with corresponding
configuration variable and select wherever it is needed.

Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Reported-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: David S. Miller <davem@davemloft.net>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Andy Shevchenko and committed by
Greg Kroah-Hartman
4cd5773a 143e9c76

+37 -23
+1
drivers/misc/Kconfig
··· 480 480 481 481 config PCH_PHUB 482 482 tristate "Intel EG20T PCH/LAPIS Semicon IOH(ML7213/ML7223/ML7831) PHUB" 483 + select GENERIC_NET_UTILS 483 484 depends on PCI 484 485 help 485 486 This driver is for PCH(Platform controller Hub) PHUB(Packet Hub) of
+1
drivers/net/netconsole.c
··· 40 40 #include <linux/slab.h> 41 41 #include <linux/console.h> 42 42 #include <linux/moduleparam.h> 43 + #include <linux/kernel.h> 43 44 #include <linux/string.h> 44 45 #include <linux/netpoll.h> 45 46 #include <linux/inet.h>
-1
include/linux/if_ether.h
··· 30 30 31 31 int eth_header_parse(const struct sk_buff *skb, unsigned char *haddr); 32 32 33 - int mac_pton(const char *s, u8 *mac); 34 33 extern ssize_t sysfs_format_mac(char *buf, const unsigned char *addr, int len); 35 34 36 35 #endif /* _LINUX_IF_ETHER_H */
+2
include/linux/kernel.h
··· 450 450 extern int hex_to_bin(char ch); 451 451 extern int __must_check hex2bin(u8 *dst, const char *src, size_t count); 452 452 453 + int mac_pton(const char *s, u8 *mac); 454 + 453 455 /* 454 456 * General tracing related utility functions - trace_printk(), 455 457 * tracing_on/tracing_off and tracing_start()/tracing_stop
+3
lib/Kconfig
··· 22 22 config GENERIC_STRNLEN_USER 23 23 bool 24 24 25 + config GENERIC_NET_UTILS 26 + bool 27 + 25 28 config GENERIC_FIND_FIRST_BIT 26 29 bool 27 30
+2
lib/Makefile
··· 137 137 obj-$(CONFIG_GENERIC_STRNCPY_FROM_USER) += strncpy_from_user.o 138 138 obj-$(CONFIG_GENERIC_STRNLEN_USER) += strnlen_user.o 139 139 140 + obj-$(CONFIG_GENERIC_NET_UTILS) += net_utils.o 141 + 140 142 obj-$(CONFIG_STMP_DEVICE) += stmp_device.o 141 143 142 144 libfdt_files = fdt.o fdt_ro.o fdt_wip.o fdt_rw.o fdt_sw.o fdt_strerror.o
+26
lib/net_utils.c
··· 1 + #include <linux/string.h> 2 + #include <linux/if_ether.h> 3 + #include <linux/ctype.h> 4 + #include <linux/kernel.h> 5 + 6 + int mac_pton(const char *s, u8 *mac) 7 + { 8 + int i; 9 + 10 + /* XX:XX:XX:XX:XX:XX */ 11 + if (strlen(s) < 3 * ETH_ALEN - 1) 12 + return 0; 13 + 14 + /* Don't dirty result unless string is valid MAC. */ 15 + for (i = 0; i < ETH_ALEN; i++) { 16 + if (!isxdigit(s[i * 3]) || !isxdigit(s[i * 3 + 1])) 17 + return 0; 18 + if (i != ETH_ALEN - 1 && s[i * 3 + 2] != ':') 19 + return 0; 20 + } 21 + for (i = 0; i < ETH_ALEN; i++) { 22 + mac[i] = (hex_to_bin(s[i * 3]) << 4) | hex_to_bin(s[i * 3 + 1]); 23 + } 24 + return 1; 25 + } 26 + EXPORT_SYMBOL(mac_pton);
+1
net/Kconfig
··· 5 5 menuconfig NET 6 6 bool "Networking support" 7 7 select NLATTR 8 + select GENERIC_NET_UTILS 8 9 ---help--- 9 10 Unless you really know what you are doing, you should say Y here. 10 11 The reason is that some programs need kernel networking support even
+1
net/core/netpoll.c
··· 12 12 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 13 13 14 14 #include <linux/moduleparam.h> 15 + #include <linux/kernel.h> 15 16 #include <linux/netdevice.h> 16 17 #include <linux/etherdevice.h> 17 18 #include <linux/string.h>
-22
net/core/utils.c
··· 338 338 csum_unfold(*sum))); 339 339 } 340 340 EXPORT_SYMBOL(inet_proto_csum_replace16); 341 - 342 - int mac_pton(const char *s, u8 *mac) 343 - { 344 - int i; 345 - 346 - /* XX:XX:XX:XX:XX:XX */ 347 - if (strlen(s) < 3 * ETH_ALEN - 1) 348 - return 0; 349 - 350 - /* Don't dirty result unless string is valid MAC. */ 351 - for (i = 0; i < ETH_ALEN; i++) { 352 - if (!isxdigit(s[i * 3]) || !isxdigit(s[i * 3 + 1])) 353 - return 0; 354 - if (i != ETH_ALEN - 1 && s[i * 3 + 2] != ':') 355 - return 0; 356 - } 357 - for (i = 0; i < ETH_ALEN; i++) { 358 - mac[i] = (hex_to_bin(s[i * 3]) << 4) | hex_to_bin(s[i * 3 + 1]); 359 - } 360 - return 1; 361 - } 362 - EXPORT_SYMBOL(mac_pton);