[PATCH] Fix ether_ntoa() output format

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH] Fix ether_ntoa() output format

Nikita Izyumtsev
Hi everybody!
 
I have bumped into issue in ether_ntoa() implementation.
All leading zeros were suppressed.
e.g instead of 00:01:13:25:18:fa
0:1:13:25:18:fa is printed.
 
As far as issue is minor and straightforward to fix, I'm sending bugfix
instead of opening issue in bugzilla. Please accept it, if it's possible.
 
P.S: please CC me in reply because I'm not subscribed to the mailing list.
 
Thanks,
Nikita
 
2010-07-26  Nikita Izyumtsev  <[hidden email]>
 
        * inet/ether_ntoa_r.c (ether_ntoa_r): fix ether_ntoa() output format.
 
---------------------------------------------
From 474c9f61d079aa4e3c46ac0f9c4d1019dea1dbad Mon Sep 17 00:00:00 2001
From: Nikita Izyumtsev <[hidden email]>
Date: Sat, 24 Jul 2010 23:54:02 +0300
Subject: [PATCH] Fix ether_ntoa() output format
 
All leading zeros were suppressed.
e.g instead of 00:01:13:25:18:fa
0:1:13:25:18:fa is printed.
---
 inet/ether_ntoa_r.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
 
diff --git a/inet/ether_ntoa_r.c b/inet/ether_ntoa_r.c
index c5f347c..5730e60 100644
--- a/inet/ether_ntoa_r.c
+++ b/inet/ether_ntoa_r.c
@@ -25,7 +25,7 @@
 char *
 ether_ntoa_r (const struct ether_addr *addr, char *buf)
 {
-  sprintf (buf, "%x:%x:%x:%x:%x:%x",
+  sprintf (buf, "%02x:%02x:%02x:%02x:%02x:%02x",
        addr->ether_addr_octet[0], addr->ether_addr_octet[1],
        addr->ether_addr_octet[2], addr->ether_addr_octet[3],
        addr->ether_addr_octet[4], addr->ether_addr_octet[5]);
--
1.7.0.2
---------------------------------------------
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] Fix ether_ntoa() output format

Ulrich Drepper
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 07/26/2010 09:49 AM, Nikita Izyumtsev wrote:
> I have bumped into issue in ether_ntoa() implementation.
> All leading zeros were suppressed.
> e.g instead of 00:01:13:25:18:fa
> 0:1:13:25:18:fa is printed.

And the problem is?  This is perfectly valid for all I know.  You cannot
just claim there is a problem without backing this up.

- --
➧ Ulrich Drepper ➧ Red Hat, Inc. ➧ 444 Castro St ➧ Mountain View, CA ❖
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (GNU/Linux)

iEYEARECAAYFAkxRkMIACgkQ2ijCOnn/RHTuWgCeLnqHZBzSf5Wq7Zs/jsMq80we
xZ4An23c6CBsnEtvmG2LAE20RydyVNYT
=IlM3
-----END PGP SIGNATURE-----
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] Fix ether_ntoa() output format

Mathieu Lacage
On Thu, 2010-07-29 at 07:31 -0700, Ulrich Drepper wrote:

> > I have bumped into issue in ether_ntoa() implementation.
> > All leading zeros were suppressed.
> > e.g instead of 00:01:13:25:18:fa
> > 0:1:13:25:18:fa is printed.
>
> And the problem is?  This is perfectly valid for all I know.  You cannot
> just claim there is a problem without backing this up.

As you point out, the current behavior (remove leading zeros) is correct
and valid but could be made more helpful by generating a fixed-size
string because this makes it easier for the users of this function to
generate a nice-looking output. Of course, this is subjective, but I
fail to see how the current behavior could be judged more useful than
the proposed behavior according to any metric.

Mathieu

Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] Fix ether_ntoa() output format

mokhtar
In reply to this post by Ulrich Drepper
Hi everybody

I checked in  about mac address format  and I found these articles

MAC address

The standard (IEEE 802) format for printing MAC-48 addresses in human-friendly form is six groups of two hexadecimal digits, separated by hyphens (-) or colons (:), in transmission order (e.g. 01-23-45-67-89-ab   or   01:23:45:67:89:ab ). This form is also commonly used for EUI-64
.

Use of the IEEE assigned Organizationally Unique Identifier with ANSI/IEEE Std 802-2001 Local and Metropolitan Area Networks

so the format provided by ether_ntoa is not conform with the standard and the patch correct this problem.

Ulrich Drepper wrote
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 07/26/2010 09:49 AM, Nikita Izyumtsev wrote:
> I have bumped into issue in ether_ntoa() implementation.
> All leading zeros were suppressed.
> e.g instead of 00:01:13:25:18:fa
> 0:1:13:25:18:fa is printed.

And the problem is?  This is perfectly valid for all I know.  You cannot
just claim there is a problem without backing this up.

- --
➧ Ulrich Drepper ➧ Red Hat, Inc. ➧ 444 Castro St ➧ Mountain View, CA ❖
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (GNU/Linux)

iEYEARECAAYFAkxRkMIACgkQ2ijCOnn/RHTuWgCeLnqHZBzSf5Wq7Zs/jsMq80we
xZ4An23c6CBsnEtvmG2LAE20RydyVNYT
=IlM3
-----END PGP SIGNATURE-----
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] Fix ether_ntoa() output format

Ondřej Bílka
On Sat, Oct 12, 2013 at 02:34:51PM -0700, mokhtar wrote:

> Hi everybody
>
> I checked in  about mac address format  and I found these articles
>
> MAC address <http://en.wikipedia.org/wiki/MAC_address>  
> /
> The standard (IEEE 802) format for printing MAC-48 addresses in
> human-friendly form is six groups of two hexadecimal digits, separated by
> hyphens (-) or colons (:), in transmission order (e.g. 01-23-45-67-89-ab  
> or   01:23:45:67:89:ab ). This form is also commonly used for EUI-64/.

A relevant patch is following. Any objections to this?

2010-07-26  Nikita Izyumtsev  <[hidden email]>
 
        * inet/ether_ntoa_r.c (ether_ntoa_r): fix ether_ntoa() output format.
 
---
 inet/ether_ntoa_r.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
 
diff --git a/inet/ether_ntoa_r.c b/inet/ether_ntoa_r.c
index c5f347c..5730e60 100644
--- a/inet/ether_ntoa_r.c
+++ b/inet/ether_ntoa_r.c
@@ -25,7 +25,7 @@
 char *
 ether_ntoa_r (const struct ether_addr *addr, char *buf)
 {
-  sprintf (buf, "%x:%x:%x:%x:%x:%x",
+  sprintf (buf, "%02x:%02x:%02x:%02x:%02x:%02x",
        addr->ether_addr_octet[0], addr->ether_addr_octet[1],
        addr->ether_addr_octet[2], addr->ether_addr_octet[3],
        addr->ether_addr_octet[4], addr->ether_addr_octet[5]);
--
1.7.0.2
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] Fix ether_ntoa() output format

Ondřej Bílka
On Mon, Oct 14, 2013 at 10:19:56PM +0100, Mokhtar BEN MESSAOUD wrote:

 Hi 
   I think that the patch should also be applied for ether_ntoa
   Regards

It handles that as implementation is following

char *
ether_ntoa (const struct ether_addr *addr)
{
  static char asc[18];

  return ether_ntoa_r (addr, asc);
}
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] Fix ether_ntoa() output format

Roland McGrath-4
In reply to this post by Ondřej Bílka
This change may need further justification.  It is the de facto norm that
MAC address notation is accepted with one-digit fields, so there is no
particular reason to think that the existing behavior causes any problems.
Conservatism/paranoia says don't perturb in fear of unintended effects on
existing users.  The middle road would be to change with a new symbol
version and keep the existing behavior for existing binaries.

OTOH, recent FreeBSD uses %02x format so it's likely that the change won't
cause trouble.  So I don't really have an objection.

The log entry is inadequate.  Pretty much any entry that says "fix foobar"
is wrong.  It should describe the change, which is very simple to describe
in this case ("Use %02x rather than %x for each address byte.").

This user-visible change needs a BZ report (which should give
justification, preferably something practical rather than just a vague
reference to a non-binding not-really-a-spec) and BZ# tag in its log entry.
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] Fix ether_ntoa() output format

mokhtar
Hi Roland

Could you please tell me where the notation with only one digit is
used ? since as you said is defacto norm it should be wide used
the wide used ifconfif command display in 2 digit format

http://en.wikipedia.org/wiki/Ifconfig
eth0      Link encap:Ethernet  HWaddr 00:0F:20:CF:8B:42