* [patch iproute2 0/3] iproute2: ipa: show port id
@ 2014-05-15 13:10 Jiri Pirko
2014-05-15 13:10 ` [patch iproute2 1/3] iproute2: arpd: use ll_addr_a2n and ll_addr_n2a Jiri Pirko
` (2 more replies)
0 siblings, 3 replies; 11+ messages in thread
From: Jiri Pirko @ 2014-05-15 13:10 UTC (permalink / raw)
To: netdev; +Cc: stephen, mschmidt
The port id is in kernel for some while. Make is available for ip user.
Jiri Pirko (3):
iproute2: arpd: use ll_addr_a2n and ll_addr_n2a
iproute2: utils: change hexstring_n2a and hexstring_a2n to do not work
with ":"
iproute2: ipa: show port id
ip/ipaddress.c | 8 ++++++++
lib/utils.c | 46 +++++++++++++---------------------------------
misc/arpd.c | 6 +++---
3 files changed, 24 insertions(+), 36 deletions(-)
--
1.9.0
^ permalink raw reply [flat|nested] 11+ messages in thread
* [patch iproute2 1/3] iproute2: arpd: use ll_addr_a2n and ll_addr_n2a
2014-05-15 13:10 [patch iproute2 0/3] iproute2: ipa: show port id Jiri Pirko
@ 2014-05-15 13:10 ` Jiri Pirko
2014-05-15 15:43 ` Stephen Hemminger
2014-05-15 13:10 ` [patch iproute2 2/3] iproute2: utils: change hexstring_n2a and hexstring_a2n to do not work with ":" Jiri Pirko
2014-05-15 13:10 ` [patch iproute2 3/3] iproute2: ipa: show port id Jiri Pirko
2 siblings, 1 reply; 11+ messages in thread
From: Jiri Pirko @ 2014-05-15 13:10 UTC (permalink / raw)
To: netdev; +Cc: stephen, mschmidt
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
---
misc/arpd.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/misc/arpd.c b/misc/arpd.c
index bfe7de9..0839e3f 100644
--- a/misc/arpd.c
+++ b/misc/arpd.c
@@ -36,6 +36,7 @@
#include "libnetlink.h"
#include "utils.h"
+#include "rt_names.h"
int resolve_hosts;
@@ -721,8 +722,7 @@ int main(int argc, char **argv)
goto do_abort;
}
- dbdat.data = hexstring_a2n(macbuf, b1, 6);
- if (dbdat.data == NULL)
+ if (ll_addr_a2n((char *) b1, 6, macbuf) != 6)
goto do_abort;
dbdat.size = 6;
@@ -747,7 +747,7 @@ int main(int argc, char **argv)
printf("%-8d %-15s %s\n",
key->iface,
inet_ntoa(*(struct in_addr*)&key->addr),
- hexstring_n2a(dbdat.data, 6, b1, 18));
+ ll_addr_n2a(dbdat.data, 6, ARPHRD_ETHER, b1, 18));
} else {
printf("%-8d %-15s FAILED: %dsec ago\n",
key->iface,
--
1.9.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [patch iproute2 2/3] iproute2: utils: change hexstring_n2a and hexstring_a2n to do not work with ":"
2014-05-15 13:10 [patch iproute2 0/3] iproute2: ipa: show port id Jiri Pirko
2014-05-15 13:10 ` [patch iproute2 1/3] iproute2: arpd: use ll_addr_a2n and ll_addr_n2a Jiri Pirko
@ 2014-05-15 13:10 ` Jiri Pirko
2014-05-15 13:10 ` [patch iproute2 3/3] iproute2: ipa: show port id Jiri Pirko
2 siblings, 0 replies; 11+ messages in thread
From: Jiri Pirko @ 2014-05-15 13:10 UTC (permalink / raw)
To: netdev; +Cc: stephen, mschmidt
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
---
lib/utils.c | 46 +++++++++++++---------------------------------
1 file changed, 13 insertions(+), 33 deletions(-)
diff --git a/lib/utils.c b/lib/utils.c
index 4e9c719..e9e1040 100644
--- a/lib/utils.c
+++ b/lib/utils.c
@@ -743,10 +743,6 @@ char *hexstring_n2a(const __u8 *str, int len, char *buf, int blen)
sprintf(ptr, "%02x", str[i]);
ptr += 2;
blen -= 2;
- if (i != len-1 && blen > 1) {
- *ptr++ = ':';
- blen--;
- }
}
return buf;
}
@@ -754,38 +750,22 @@ char *hexstring_n2a(const __u8 *str, int len, char *buf, int blen)
__u8* hexstring_a2n(const char *str, __u8 *buf, int blen)
{
int cnt = 0;
+ char *endptr;
- for (;;) {
- unsigned acc;
- char ch;
-
- acc = 0;
-
- while ((ch = *str) != ':' && ch != 0) {
- if (ch >= '0' && ch <= '9')
- ch -= '0';
- else if (ch >= 'a' && ch <= 'f')
- ch -= 'a'-10;
- else if (ch >= 'A' && ch <= 'F')
- ch -= 'A'-10;
- else
- return NULL;
- acc = (acc<<4) + ch;
- str++;
- }
-
- if (acc > 255)
+ if (strlen(str) % 2)
+ return NULL;
+ while (cnt < blen && strlen(str) > 1) {
+ unsigned int tmp;
+ char tmpstr[3];
+
+ strncpy(tmpstr, str, 2);
+ tmpstr[2] = '\0';
+ tmp = strtoul(tmpstr, &endptr, 16);
+ if (errno != 0 || tmp > 0xFF || *endptr != '\0')
return NULL;
- if (cnt < blen) {
- buf[cnt] = acc;
- cnt++;
- }
- if (ch == 0)
- break;
- ++str;
+ buf[cnt++] = tmp;
+ str += 2;
}
- if (cnt < blen)
- memset(buf+cnt, 0, blen-cnt);
return buf;
}
--
1.9.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [patch iproute2 3/3] iproute2: ipa: show port id
2014-05-15 13:10 [patch iproute2 0/3] iproute2: ipa: show port id Jiri Pirko
2014-05-15 13:10 ` [patch iproute2 1/3] iproute2: arpd: use ll_addr_a2n and ll_addr_n2a Jiri Pirko
2014-05-15 13:10 ` [patch iproute2 2/3] iproute2: utils: change hexstring_n2a and hexstring_a2n to do not work with ":" Jiri Pirko
@ 2014-05-15 13:10 ` Jiri Pirko
2 siblings, 0 replies; 11+ messages in thread
From: Jiri Pirko @ 2014-05-15 13:10 UTC (permalink / raw)
To: netdev; +Cc: stephen, mschmidt
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
---
ip/ipaddress.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/ip/ipaddress.c b/ip/ipaddress.c
index 32f930e..ce5e762 100644
--- a/ip/ipaddress.c
+++ b/ip/ipaddress.c
@@ -485,6 +485,14 @@ int print_linkinfo(const struct sockaddr_nl *who,
fprintf(fp, "master %s ", ll_idx_n2a(*(int*)RTA_DATA(tb[IFLA_MASTER]), b1));
}
+ if (tb[IFLA_PHYS_PORT_ID]) {
+ SPRINT_BUF(b1);
+ fprintf(fp, "portid %s ",
+ hexstring_n2a(RTA_DATA(tb[IFLA_PHYS_PORT_ID]),
+ RTA_PAYLOAD(tb[IFLA_PHYS_PORT_ID]),
+ b1, sizeof(b1)));
+ }
+
if (tb[IFLA_OPERSTATE])
print_operstate(fp, rta_getattr_u8(tb[IFLA_OPERSTATE]));
--
1.9.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [patch iproute2 1/3] iproute2: arpd: use ll_addr_a2n and ll_addr_n2a
2014-05-15 13:10 ` [patch iproute2 1/3] iproute2: arpd: use ll_addr_a2n and ll_addr_n2a Jiri Pirko
@ 2014-05-15 15:43 ` Stephen Hemminger
2014-05-15 16:50 ` Jiri Pirko
0 siblings, 1 reply; 11+ messages in thread
From: Stephen Hemminger @ 2014-05-15 15:43 UTC (permalink / raw)
To: Jiri Pirko; +Cc: netdev, mschmidt
On Thu, 15 May 2014 15:10:20 +0200
Jiri Pirko <jiri@resnulli.us> wrote:
> Signed-off-by: Jiri Pirko <jiri@resnulli.us>
> ---
> misc/arpd.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
Why not use more standard ether_ntoa ?
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [patch iproute2 1/3] iproute2: arpd: use ll_addr_a2n and ll_addr_n2a
2014-05-15 15:43 ` Stephen Hemminger
@ 2014-05-15 16:50 ` Jiri Pirko
2014-05-17 3:58 ` Stephen Hemminger
0 siblings, 1 reply; 11+ messages in thread
From: Jiri Pirko @ 2014-05-15 16:50 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: netdev, mschmidt
Thu, May 15, 2014 at 05:43:42PM CEST, stephen@networkplumber.org wrote:
>On Thu, 15 May 2014 15:10:20 +0200
>Jiri Pirko <jiri@resnulli.us> wrote:
>
>> Signed-off-by: Jiri Pirko <jiri@resnulli.us>
>> ---
>> misc/arpd.c | 6 +++---
>> 1 file changed, 3 insertions(+), 3 deletions(-)
>>
>
>Why not use more standard ether_ntoa ?
Because the rest of the code uses ll_addr_n2a. There is no user of
ether_ntoa in iproute2.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [patch iproute2 1/3] iproute2: arpd: use ll_addr_a2n and ll_addr_n2a
2014-05-15 16:50 ` Jiri Pirko
@ 2014-05-17 3:58 ` Stephen Hemminger
2014-05-17 8:50 ` Jiri Pirko
0 siblings, 1 reply; 11+ messages in thread
From: Stephen Hemminger @ 2014-05-17 3:58 UTC (permalink / raw)
To: Jiri Pirko; +Cc: netdev, mschmidt
On Thu, 15 May 2014 18:50:51 +0200
Jiri Pirko <jiri@resnulli.us> wrote:
> Thu, May 15, 2014 at 05:43:42PM CEST, stephen@networkplumber.org wrote:
> >On Thu, 15 May 2014 15:10:20 +0200
> >Jiri Pirko <jiri@resnulli.us> wrote:
> >
> >> Signed-off-by: Jiri Pirko <jiri@resnulli.us>
> >> ---
> >> misc/arpd.c | 6 +++---
> >> 1 file changed, 3 insertions(+), 3 deletions(-)
> >>
> >
> >Why not use more standard ether_ntoa ?
>
> Because the rest of the code uses ll_addr_n2a. There is no user of
> ether_ntoa in iproute2.
arpd is more of a standalone program.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [patch iproute2 1/3] iproute2: arpd: use ll_addr_a2n and ll_addr_n2a
2014-05-17 3:58 ` Stephen Hemminger
@ 2014-05-17 8:50 ` Jiri Pirko
2014-06-09 19:47 ` Stephen Hemminger
0 siblings, 1 reply; 11+ messages in thread
From: Jiri Pirko @ 2014-05-17 8:50 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: netdev, mschmidt
Sat, May 17, 2014 at 05:58:16AM CEST, stephen@networkplumber.org wrote:
>On Thu, 15 May 2014 18:50:51 +0200
>Jiri Pirko <jiri@resnulli.us> wrote:
>
>> Thu, May 15, 2014 at 05:43:42PM CEST, stephen@networkplumber.org wrote:
>> >On Thu, 15 May 2014 15:10:20 +0200
>> >Jiri Pirko <jiri@resnulli.us> wrote:
>> >
>> >> Signed-off-by: Jiri Pirko <jiri@resnulli.us>
>> >> ---
>> >> misc/arpd.c | 6 +++---
>> >> 1 file changed, 3 insertions(+), 3 deletions(-)
>> >>
>> >
>> >Why not use more standard ether_ntoa ?
>>
>> Because the rest of the code uses ll_addr_n2a. There is no user of
>> ether_ntoa in iproute2.
>
>arpd is more of a standalone program.
I know but it is a part of the package (git tree). The other instances
use ll_addr_n2a. I'm ok with using ether_ntoa, I just wanted to follow
what is already there.
I can change it and post v2 it you want. I can also change other instances
of usage ll_addr_n2a to ether_ntoa.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [patch iproute2 1/3] iproute2: arpd: use ll_addr_a2n and ll_addr_n2a
2014-05-17 8:50 ` Jiri Pirko
@ 2014-06-09 19:47 ` Stephen Hemminger
2014-06-10 15:50 ` Jiri Pirko
0 siblings, 1 reply; 11+ messages in thread
From: Stephen Hemminger @ 2014-06-09 19:47 UTC (permalink / raw)
To: Jiri Pirko; +Cc: netdev, mschmidt
On Sat, 17 May 2014 10:50:31 +0200
Jiri Pirko <jiri@resnulli.us> wrote:
> Sat, May 17, 2014 at 05:58:16AM CEST, stephen@networkplumber.org wrote:
> >On Thu, 15 May 2014 18:50:51 +0200
> >Jiri Pirko <jiri@resnulli.us> wrote:
> >
> >> Thu, May 15, 2014 at 05:43:42PM CEST, stephen@networkplumber.org wrote:
> >> >On Thu, 15 May 2014 15:10:20 +0200
> >> >Jiri Pirko <jiri@resnulli.us> wrote:
> >> >
> >> >> Signed-off-by: Jiri Pirko <jiri@resnulli.us>
> >> >> ---
> >> >> misc/arpd.c | 6 +++---
> >> >> 1 file changed, 3 insertions(+), 3 deletions(-)
> >> >>
> >> >
> >> >Why not use more standard ether_ntoa ?
> >>
> >> Because the rest of the code uses ll_addr_n2a. There is no user of
> >> ether_ntoa in iproute2.
> >
> >arpd is more of a standalone program.
>
> I know but it is a part of the package (git tree). The other instances
> use ll_addr_n2a. I'm ok with using ether_ntoa, I just wanted to follow
> what is already there.
>
> I can change it and post v2 it you want. I can also change other instances
> of usage ll_addr_n2a to ether_ntoa.
>
>
This is fine, just went ahead and merged this version.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [patch iproute2 1/3] iproute2: arpd: use ll_addr_a2n and ll_addr_n2a
2014-06-09 19:47 ` Stephen Hemminger
@ 2014-06-10 15:50 ` Jiri Pirko
2014-06-10 16:09 ` Jiri Pirko
0 siblings, 1 reply; 11+ messages in thread
From: Jiri Pirko @ 2014-06-10 15:50 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: netdev, mschmidt
Mon, Jun 09, 2014 at 09:47:22PM CEST, stephen@networkplumber.org wrote:
>On Sat, 17 May 2014 10:50:31 +0200
>Jiri Pirko <jiri@resnulli.us> wrote:
>
>> Sat, May 17, 2014 at 05:58:16AM CEST, stephen@networkplumber.org wrote:
>> >On Thu, 15 May 2014 18:50:51 +0200
>> >Jiri Pirko <jiri@resnulli.us> wrote:
>> >
>> >> Thu, May 15, 2014 at 05:43:42PM CEST, stephen@networkplumber.org wrote:
>> >> >On Thu, 15 May 2014 15:10:20 +0200
>> >> >Jiri Pirko <jiri@resnulli.us> wrote:
>> >> >
>> >> >> Signed-off-by: Jiri Pirko <jiri@resnulli.us>
>> >> >> ---
>> >> >> misc/arpd.c | 6 +++---
>> >> >> 1 file changed, 3 insertions(+), 3 deletions(-)
>> >> >>
>> >> >
>> >> >Why not use more standard ether_ntoa ?
>> >>
>> >> Because the rest of the code uses ll_addr_n2a. There is no user of
>> >> ether_ntoa in iproute2.
>> >
>> >arpd is more of a standalone program.
>>
>> I know but it is a part of the package (git tree). The other instances
>> use ll_addr_n2a. I'm ok with using ether_ntoa, I just wanted to follow
>> what is already there.
>>
>> I can change it and post v2 it you want. I can also change other instances
>> of usage ll_addr_n2a to ether_ntoa.
>>
>>
>
>This is fine, just went ahead and merged this version.
Stephen, looks like you missed the last (3/3) patch from this set. I
can't see it in the iproute2 git.
Thanks
Jiri
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [patch iproute2 1/3] iproute2: arpd: use ll_addr_a2n and ll_addr_n2a
2014-06-10 15:50 ` Jiri Pirko
@ 2014-06-10 16:09 ` Jiri Pirko
0 siblings, 0 replies; 11+ messages in thread
From: Jiri Pirko @ 2014-06-10 16:09 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: netdev, mschmidt
Tue, Jun 10, 2014 at 05:50:25PM CEST, jiri@resnulli.us wrote:
>Mon, Jun 09, 2014 at 09:47:22PM CEST, stephen@networkplumber.org wrote:
>>On Sat, 17 May 2014 10:50:31 +0200
>>Jiri Pirko <jiri@resnulli.us> wrote:
>>
>>> Sat, May 17, 2014 at 05:58:16AM CEST, stephen@networkplumber.org wrote:
>>> >On Thu, 15 May 2014 18:50:51 +0200
>>> >Jiri Pirko <jiri@resnulli.us> wrote:
>>> >
>>> >> Thu, May 15, 2014 at 05:43:42PM CEST, stephen@networkplumber.org wrote:
>>> >> >On Thu, 15 May 2014 15:10:20 +0200
>>> >> >Jiri Pirko <jiri@resnulli.us> wrote:
>>> >> >
>>> >> >> Signed-off-by: Jiri Pirko <jiri@resnulli.us>
>>> >> >> ---
>>> >> >> misc/arpd.c | 6 +++---
>>> >> >> 1 file changed, 3 insertions(+), 3 deletions(-)
>>> >> >>
>>> >> >
>>> >> >Why not use more standard ether_ntoa ?
>>> >>
>>> >> Because the rest of the code uses ll_addr_n2a. There is no user of
>>> >> ether_ntoa in iproute2.
>>> >
>>> >arpd is more of a standalone program.
>>>
>>> I know but it is a part of the package (git tree). The other instances
>>> use ll_addr_n2a. I'm ok with using ether_ntoa, I just wanted to follow
>>> what is already there.
>>>
>>> I can change it and post v2 it you want. I can also change other instances
>>> of usage ll_addr_n2a to ether_ntoa.
>>>
>>>
>>
>>This is fine, just went ahead and merged this version.
>
>
>Stephen, looks like you missed the last (3/3) patch from this set. I
>can't see it in the iproute2 git.
Oh, you already applied that before. That confused me because "iproute2:
ipa: show port id" actuall adds code which calls hexstring_n2a :)
Anyway, all good now. Sorry for the fuzz.
>
>Thanks
>
>Jiri
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2014-06-10 16:09 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-15 13:10 [patch iproute2 0/3] iproute2: ipa: show port id Jiri Pirko
2014-05-15 13:10 ` [patch iproute2 1/3] iproute2: arpd: use ll_addr_a2n and ll_addr_n2a Jiri Pirko
2014-05-15 15:43 ` Stephen Hemminger
2014-05-15 16:50 ` Jiri Pirko
2014-05-17 3:58 ` Stephen Hemminger
2014-05-17 8:50 ` Jiri Pirko
2014-06-09 19:47 ` Stephen Hemminger
2014-06-10 15:50 ` Jiri Pirko
2014-06-10 16:09 ` Jiri Pirko
2014-05-15 13:10 ` [patch iproute2 2/3] iproute2: utils: change hexstring_n2a and hexstring_a2n to do not work with ":" Jiri Pirko
2014-05-15 13:10 ` [patch iproute2 3/3] iproute2: ipa: show port id Jiri Pirko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).