aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2008-12-28 15:49:40 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2008-12-28 15:49:40 -0500
commit0191b625ca5a46206d2fb862bb08f36f2fcb3b31 (patch)
tree454d1842b1833d976da62abcbd5c47521ebe9bd7 /lib
parent54a696bd07c14d3b1192d03ce7269bc59b45209a (diff)
parenteb56092fc168bf5af199d47af50c0d84a96db898 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next-2.6: (1429 commits) net: Allow dependancies of FDDI & Tokenring to be modular. igb: Fix build warning when DCA is disabled. net: Fix warning fallout from recent NAPI interface changes. gro: Fix potential use after free sfc: If AN is enabled, always read speed/duplex from the AN advertising bits sfc: When disabling the NIC, close the device rather than unregistering it sfc: SFT9001: Add cable diagnostics sfc: Add support for multiple PHY self-tests sfc: Merge top-level functions for self-tests sfc: Clean up PHY mode management in loopback self-test sfc: Fix unreliable link detection in some loopback modes sfc: Generate unique names for per-NIC workqueues 802.3ad: use standard ethhdr instead of ad_header 802.3ad: generalize out mac address initializer 802.3ad: initialize ports LACPDU from const initializer 802.3ad: remove typedef around ad_system 802.3ad: turn ports is_individual into a bool 802.3ad: turn ports is_enabled into a bool 802.3ad: make ntt bool ixgbe: Fix set_ringparam in ixgbe to use the same memory pools. ... Fixed trivial IPv4/6 address printing conflicts in fs/cifs/connect.c due to the conversion to %pI (in this networking merge) and the addition of doing IPv6 addresses (from the earlier merge of CIFS).
Diffstat (limited to 'lib')
-rw-r--r--lib/vsprintf.c77
1 files changed, 77 insertions, 0 deletions
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index a013bbc2371..3b777025d87 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -581,6 +581,62 @@ static char *resource_string(char *buf, char *end, struct resource *res, int fie
581 return string(buf, end, sym, field_width, precision, flags); 581 return string(buf, end, sym, field_width, precision, flags);
582} 582}
583 583
584static char *mac_address_string(char *buf, char *end, u8 *addr, int field_width,
585 int precision, int flags)
586{
587 char mac_addr[6 * 3]; /* (6 * 2 hex digits), 5 colons and trailing zero */
588 char *p = mac_addr;
589 int i;
590
591 for (i = 0; i < 6; i++) {
592 p = pack_hex_byte(p, addr[i]);
593 if (!(flags & SPECIAL) && i != 5)
594 *p++ = ':';
595 }
596 *p = '\0';
597
598 return string(buf, end, mac_addr, field_width, precision, flags & ~SPECIAL);
599}
600
601static char *ip6_addr_string(char *buf, char *end, u8 *addr, int field_width,
602 int precision, int flags)
603{
604 char ip6_addr[8 * 5]; /* (8 * 4 hex digits), 7 colons and trailing zero */
605 char *p = ip6_addr;
606 int i;
607
608 for (i = 0; i < 8; i++) {
609 p = pack_hex_byte(p, addr[2 * i]);
610 p = pack_hex_byte(p, addr[2 * i + 1]);
611 if (!(flags & SPECIAL) && i != 7)
612 *p++ = ':';
613 }
614 *p = '\0';
615
616 return string(buf, end, ip6_addr, field_width, precision, flags & ~SPECIAL);
617}
618
619static char *ip4_addr_string(char *buf, char *end, u8 *addr, int field_width,
620 int precision, int flags)
621{
622 char ip4_addr[4 * 4]; /* (4 * 3 decimal digits), 3 dots and trailing zero */
623 char temp[3]; /* hold each IP quad in reverse order */
624 char *p = ip4_addr;
625 int i, digits;
626
627 for (i = 0; i < 4; i++) {
628 digits = put_dec_trunc(temp, addr[i]) - temp;
629 /* reverse the digits in the quad */
630 while (digits--)
631 *p++ = temp[digits];
632 if (i != 3)
633 *p++ = '.';
634 }
635 *p = '\0';
636
637 return string(buf, end, ip4_addr, field_width, precision, flags & ~SPECIAL);
638}
639
584/* 640/*
585 * Show a '%p' thing. A kernel extension is that the '%p' is followed 641 * Show a '%p' thing. A kernel extension is that the '%p' is followed
586 * by an extra set of alphanumeric characters that are extended format 642 * by an extra set of alphanumeric characters that are extended format
@@ -592,6 +648,12 @@ static char *resource_string(char *buf, char *end, struct resource *res, int fie
592 * - 'S' For symbolic direct pointers 648 * - 'S' For symbolic direct pointers
593 * - 'R' For a struct resource pointer, it prints the range of 649 * - 'R' For a struct resource pointer, it prints the range of
594 * addresses (not the name nor the flags) 650 * addresses (not the name nor the flags)
651 * - 'M' For a 6-byte MAC address, it prints the address in the
652 * usual colon-separated hex notation
653 * - 'I' [46] for IPv4/IPv6 addresses printed in the usual way (dot-separated
654 * decimal for v4 and colon separated network-order 16 bit hex for v6)
655 * - 'i' [46] for 'raw' IPv4/IPv6 addresses, IPv6 omits the colons, IPv4 is
656 * currently the same
595 * 657 *
596 * Note: The difference between 'S' and 'F' is that on ia64 and ppc64 658 * Note: The difference between 'S' and 'F' is that on ia64 and ppc64
597 * function pointers are really function descriptors, which contain a 659 * function pointers are really function descriptors, which contain a
@@ -607,6 +669,21 @@ static char *pointer(const char *fmt, char *buf, char *end, void *ptr, int field
607 return symbol_string(buf, end, ptr, field_width, precision, flags); 669 return symbol_string(buf, end, ptr, field_width, precision, flags);
608 case 'R': 670 case 'R':
609 return resource_string(buf, end, ptr, field_width, precision, flags); 671 return resource_string(buf, end, ptr, field_width, precision, flags);
672 case 'm':
673 flags |= SPECIAL;
674 /* Fallthrough */
675 case 'M':
676 return mac_address_string(buf, end, ptr, field_width, precision, flags);
677 case 'i':
678 flags |= SPECIAL;
679 /* Fallthrough */
680 case 'I':
681 if (fmt[1] == '6')
682 return ip6_addr_string(buf, end, ptr, field_width, precision, flags);
683 if (fmt[1] == '4')
684 return ip4_addr_string(buf, end, ptr, field_width, precision, flags);
685 flags &= ~SPECIAL;
686 break;
610 } 687 }
611 flags |= SMALL; 688 flags |= SMALL;
612 if (field_width == -1) { 689 if (field_width == -1) {