[ETH]: Combine format_addr() with print_mac().
print_mac() used many most net drivers and format_addr() used by net-sysfs.c are very similar and they can be intergrated. format_addr() is also identically redefined in the qla4xxx iscsi driver. Export a new function sysfs_format_mac() to be used by net-sysfs, qla4xxx and others in the future. Both print_mac() and sysfs_format_mac() call _format_mac_addr() to do the formatting. Changed print_mac() to use unsigned char * to be consistent with net_device struct's dev_addr. Added buffer length overrun checking as suggested by Joe Perches. Signed-off-by: Michael Chan <mchan@broadcom.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:

committed by
David S. Miller

parent
21371f768b
commit
7ffc49a6ee
@@ -124,12 +124,14 @@ int eth_header_parse(const struct sk_buff *skb, unsigned char *haddr);
|
||||
extern struct ctl_table ether_table[];
|
||||
#endif
|
||||
|
||||
extern ssize_t sysfs_format_mac(char *buf, const unsigned char *addr, int len);
|
||||
|
||||
/*
|
||||
* Display a 6 byte device address (MAC) in a readable format.
|
||||
*/
|
||||
#define MAC_FMT "%02x:%02x:%02x:%02x:%02x:%02x"
|
||||
extern char *print_mac(char *buf, const u8 *addr);
|
||||
#define DECLARE_MAC_BUF(var) char var[18] __maybe_unused
|
||||
extern char *print_mac(char *buf, const unsigned char *addr);
|
||||
#define MAC_BUF_SIZE 18
|
||||
#define DECLARE_MAC_BUF(var) char var[MAC_BUF_SIZE] __maybe_unused
|
||||
|
||||
#endif
|
||||
|
||||
|
Reference in New Issue
Block a user