* [PATCH iproute2] iplink: allow to show ip addresses
@ 2014-11-24 16:42 Nicolas Dichtel
2014-11-25 6:10 ` Michal Kubecek
0 siblings, 1 reply; 6+ messages in thread
From: Nicolas Dichtel @ 2014-11-24 16:42 UTC (permalink / raw)
To: shemminger; +Cc: netdev, Nicolas Dichtel
This patch adds a new option (-addresses) to the 'ip link' command so that the
user can display link details and IP addresses with the same command.
Example:
$ ip -d -a l ls gre1
9: gre1@NONE: <POINTOPOINT,NOARP,UP,LOWER_UP> mtu 1468 qdisc noqueue state UNKNOWN mode DEFAULT group default
link/gre 10.16.0.249 peer 10.16.0.121 promiscuity 0
gre remote 10.16.0.121 local 10.16.0.249 ttl inherit ikey 0.0.0.10 okey 0.0.0.10 icsum ocsum
inet 192.168.0.249 peer 192.168.0.121/32 scope global gre1
valid_lft forever preferred_lft forever
inet6 fe80::5efe:a10:f9/64 scope link
valid_lft forever preferred_lft forever
Suggested-by: Christophe Gouault <christophe.gouault@6wind.com>
Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
---
include/utils.h | 1 +
ip/ip.c | 3 +++
ip/ipaddress.c | 5 +++--
3 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/include/utils.h b/include/utils.h
index eef9c42d2fd5..9d0f2ad83e49 100644
--- a/include/utils.h
+++ b/include/utils.h
@@ -15,6 +15,7 @@ extern int human_readable;
extern int use_iec;
extern int show_stats;
extern int show_details;
+extern int show_addresses;
extern int show_raw;
extern int resolve_hosts;
extern int oneline;
diff --git a/ip/ip.c b/ip/ip.c
index 5f759d5424aa..ad53d14a1fd9 100644
--- a/ip/ip.c
+++ b/ip/ip.c
@@ -28,6 +28,7 @@ int human_readable = 0;
int use_iec = 0;
int show_stats = 0;
int show_details = 0;
+int show_addresses = 0;
int resolve_hosts = 0;
int oneline = 0;
int timestamp = 0;
@@ -226,6 +227,8 @@ int main(int argc, char **argv)
++show_stats;
} else if (matches(opt, "-details") == 0) {
++show_details;
+ } else if (matches(opt, "-addresses") == 0) {
+ ++show_addresses;
} else if (matches(opt, "-resolve") == 0) {
++resolve_hosts;
} else if (matches(opt, "-oneline") == 0) {
diff --git a/ip/ipaddress.c b/ip/ipaddress.c
index db39437305a9..10cbb4248a67 100644
--- a/ip/ipaddress.c
+++ b/ip/ipaddress.c
@@ -1323,7 +1323,7 @@ static int ipaddr_list_flush_or_save(int argc, char **argv, int action)
* link filters are present, use RTM_GETLINK to get
* the link device
*/
- if (filter_dev && filter.group == -1 && do_link == 1) {
+ if (filter_dev && filter.group == -1 && do_link == 1 && show_addresses == 0) {
if (iplink_get(0, filter_dev, RTEXT_FILTER_VF) < 0) {
perror("Cannot send link get request");
exit(1);
@@ -1437,7 +1437,8 @@ void ipaddr_get_vf_rate(int vfnum, int *min, int *max, int idx)
int ipaddr_list_link(int argc, char **argv)
{
- preferred_family = AF_PACKET;
+ if (show_addresses == 0)
+ preferred_family = AF_PACKET;
do_link = 1;
return ipaddr_list_flush_or_save(argc, argv, IPADD_LIST);
}
--
2.1.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH iproute2] iplink: allow to show ip addresses
2014-11-24 16:42 [PATCH iproute2] iplink: allow to show ip addresses Nicolas Dichtel
@ 2014-11-25 6:10 ` Michal Kubecek
2014-11-26 13:12 ` Jiri Benc
2014-12-04 16:41 ` [PATCH v2 iproute2] ipaddress: enable -details option Nicolas Dichtel
0 siblings, 2 replies; 6+ messages in thread
From: Michal Kubecek @ 2014-11-25 6:10 UTC (permalink / raw)
To: Nicolas Dichtel; +Cc: shemminger, netdev
On Mon, Nov 24, 2014 at 05:42:17PM +0100, Nicolas Dichtel wrote:
> This patch adds a new option (-addresses) to the 'ip link' command so that the
> user can display link details and IP addresses with the same command.
>
> Example:
> $ ip -d -a l ls gre1
> 9: gre1@NONE: <POINTOPOINT,NOARP,UP,LOWER_UP> mtu 1468 qdisc noqueue state UNKNOWN mode DEFAULT group default
> link/gre 10.16.0.249 peer 10.16.0.121 promiscuity 0
> gre remote 10.16.0.121 local 10.16.0.249 ttl inherit ikey 0.0.0.10 okey 0.0.0.10 icsum ocsum
> inet 192.168.0.249 peer 192.168.0.121/32 scope global gre1
> valid_lft forever preferred_lft forever
> inet6 fe80::5efe:a10:f9/64 scope link
> valid_lft forever preferred_lft forever
Perhaps it would be more consistent to add -d option to "ip addr show"
instead as we already have -s for statistics there (commit 5d5cf1b43).
Michal Kubecek
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH iproute2] iplink: allow to show ip addresses
2014-11-25 6:10 ` Michal Kubecek
@ 2014-11-26 13:12 ` Jiri Benc
2014-11-26 14:00 ` Nicolas Dichtel
2014-12-04 16:41 ` [PATCH v2 iproute2] ipaddress: enable -details option Nicolas Dichtel
1 sibling, 1 reply; 6+ messages in thread
From: Jiri Benc @ 2014-11-26 13:12 UTC (permalink / raw)
To: Michal Kubecek; +Cc: Nicolas Dichtel, shemminger, netdev
On Tue, 25 Nov 2014 07:10:23 +0100, Michal Kubecek wrote:
> On Mon, Nov 24, 2014 at 05:42:17PM +0100, Nicolas Dichtel wrote:
> > This patch adds a new option (-addresses) to the 'ip link' command so that the
> > user can display link details and IP addresses with the same command.
> >
> > Example:
> > $ ip -d -a l ls gre1
> > 9: gre1@NONE: <POINTOPOINT,NOARP,UP,LOWER_UP> mtu 1468 qdisc noqueue state UNKNOWN mode DEFAULT group default
> > link/gre 10.16.0.249 peer 10.16.0.121 promiscuity 0
> > gre remote 10.16.0.121 local 10.16.0.249 ttl inherit ikey 0.0.0.10 okey 0.0.0.10 icsum ocsum
> > inet 192.168.0.249 peer 192.168.0.121/32 scope global gre1
> > valid_lft forever preferred_lft forever
> > inet6 fe80::5efe:a10:f9/64 scope link
> > valid_lft forever preferred_lft forever
>
> Perhaps it would be more consistent to add -d option to "ip addr show"
> instead as we already have -s for statistics there (commit 5d5cf1b43).
Agreed.
Jiri
--
Jiri Benc
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH iproute2] iplink: allow to show ip addresses
2014-11-26 13:12 ` Jiri Benc
@ 2014-11-26 14:00 ` Nicolas Dichtel
0 siblings, 0 replies; 6+ messages in thread
From: Nicolas Dichtel @ 2014-11-26 14:00 UTC (permalink / raw)
To: Jiri Benc, Michal Kubecek; +Cc: shemminger, netdev
Le 26/11/2014 14:12, Jiri Benc a écrit :
> On Tue, 25 Nov 2014 07:10:23 +0100, Michal Kubecek wrote:
>> On Mon, Nov 24, 2014 at 05:42:17PM +0100, Nicolas Dichtel wrote:
>>> This patch adds a new option (-addresses) to the 'ip link' command so that the
>>> user can display link details and IP addresses with the same command.
>>>
>>> Example:
>>> $ ip -d -a l ls gre1
>>> 9: gre1@NONE: <POINTOPOINT,NOARP,UP,LOWER_UP> mtu 1468 qdisc noqueue state UNKNOWN mode DEFAULT group default
>>> link/gre 10.16.0.249 peer 10.16.0.121 promiscuity 0
>>> gre remote 10.16.0.121 local 10.16.0.249 ttl inherit ikey 0.0.0.10 okey 0.0.0.10 icsum ocsum
>>> inet 192.168.0.249 peer 192.168.0.121/32 scope global gre1
>>> valid_lft forever preferred_lft forever
>>> inet6 fe80::5efe:a10:f9/64 scope link
>>> valid_lft forever preferred_lft forever
>>
>> Perhaps it would be more consistent to add -d option to "ip addr show"
>> instead as we already have -s for statistics there (commit 5d5cf1b43).
>
> Agreed.
I also agree ;-)
Will send a v2.
Thank you,
Nicolas
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2 iproute2] ipaddress: enable -details option
2014-11-25 6:10 ` Michal Kubecek
2014-11-26 13:12 ` Jiri Benc
@ 2014-12-04 16:41 ` Nicolas Dichtel
2014-12-10 4:14 ` Stephen Hemminger
1 sibling, 1 reply; 6+ messages in thread
From: Nicolas Dichtel @ 2014-12-04 16:41 UTC (permalink / raw)
To: shemminger; +Cc: netdev, mkubecek, jbenc, Nicolas Dichtel
This option was used only for 'ip link', but it can be useful to have it for
'ip address'. Thus it is possible to display link details and addresses with one
command.
Example:
$ ip -d a ls dev gre1
9: gre1@NONE: <POINTOPOINT,NOARP,UP,LOWER_UP> mtu 1468 qdisc noqueue state UNKNOWN group default
link/gre 10.16.0.249 peer 10.16.0.121 promiscuity 0
gre remote 10.16.0.121 local 10.16.0.249 ttl inherit ikey 0.0.0.10 okey 0.0.0.10 icsum ocsum
inet 192.168.0.249 peer 192.168.0.121/32 scope global gre1
valid_lft forever preferred_lft forever
inet6 fe80::5efe:a10:f9/64 scope link
valid_lft forever preferred_lft forever
Suggested-by: Christophe Gouault <christophe.gouault@6wind.com>
Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
---
v2: patch 'ip address' to display link details instead
of patching 'ip link' to display addresses
ip/ipaddress.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/ip/ipaddress.c b/ip/ipaddress.c
index 4d993243d5f8..221ae1fc054a 100644
--- a/ip/ipaddress.c
+++ b/ip/ipaddress.c
@@ -604,7 +604,7 @@ int print_linkinfo(const struct sockaddr_nl *who,
if (filter.showqueue)
print_queuelen(fp, tb);
- if (!filter.family || filter.family == AF_PACKET) {
+ if (!filter.family || filter.family == AF_PACKET || show_details) {
SPRINT_BUF(b1);
fprintf(fp, "%s", _SL_);
fprintf(fp, " link/%s ", ll_type_n2a(ifi->ifi_type, b1, sizeof(b1)));
@@ -627,14 +627,14 @@ int print_linkinfo(const struct sockaddr_nl *who,
}
}
- if (do_link && tb[IFLA_PROMISCUITY] && show_details)
+ if (tb[IFLA_PROMISCUITY] && show_details)
fprintf(fp, " promiscuity %u ",
*(int*)RTA_DATA(tb[IFLA_PROMISCUITY]));
- if (do_link && tb[IFLA_LINKINFO] && show_details)
+ if (tb[IFLA_LINKINFO] && show_details)
print_linktype(fp, tb[IFLA_LINKINFO]);
- if (do_link && tb[IFLA_IFALIAS]) {
+ if ((do_link || show_details) && tb[IFLA_IFALIAS]) {
fprintf(fp, "%s alias %s", _SL_,
rta_getattr_str(tb[IFLA_IFALIAS]));
}
@@ -644,7 +644,7 @@ int print_linkinfo(const struct sockaddr_nl *who,
__print_link_stats(fp, tb);
}
- if (do_link && tb[IFLA_VFINFO_LIST] && tb[IFLA_NUM_VF]) {
+ if ((do_link || show_details) && tb[IFLA_VFINFO_LIST] && tb[IFLA_NUM_VF]) {
struct rtattr *i, *vflist = tb[IFLA_VFINFO_LIST];
int rem = RTA_PAYLOAD(vflist);
for (i = RTA_DATA(vflist); RTA_OK(i, rem); i = RTA_NEXT(i, rem))
--
2.1.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v2 iproute2] ipaddress: enable -details option
2014-12-04 16:41 ` [PATCH v2 iproute2] ipaddress: enable -details option Nicolas Dichtel
@ 2014-12-10 4:14 ` Stephen Hemminger
0 siblings, 0 replies; 6+ messages in thread
From: Stephen Hemminger @ 2014-12-10 4:14 UTC (permalink / raw)
To: Nicolas Dichtel; +Cc: shemminger, netdev, mkubecek, jbenc
On Thu, 4 Dec 2014 17:41:07 +0100
Nicolas Dichtel <nicolas.dichtel@6wind.com> wrote:
> This option was used only for 'ip link', but it can be useful to have it for
> 'ip address'. Thus it is possible to display link details and addresses with one
> command.
>
> Example:
> $ ip -d a ls dev gre1
> 9: gre1@NONE: <POINTOPOINT,NOARP,UP,LOWER_UP> mtu 1468 qdisc noqueue state UNKNOWN group default
> link/gre 10.16.0.249 peer 10.16.0.121 promiscuity 0
> gre remote 10.16.0.121 local 10.16.0.249 ttl inherit ikey 0.0.0.10 okey 0.0.0.10 icsum ocsum
> inet 192.168.0.249 peer 192.168.0.121/32 scope global gre1
> valid_lft forever preferred_lft forever
> inet6 fe80::5efe:a10:f9/64 scope link
> valid_lft forever preferred_lft forever
>
> Suggested-by: Christophe Gouault <christophe.gouault@6wind.com>
> Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Looks good, accepted.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2014-12-10 4:14 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-24 16:42 [PATCH iproute2] iplink: allow to show ip addresses Nicolas Dichtel
2014-11-25 6:10 ` Michal Kubecek
2014-11-26 13:12 ` Jiri Benc
2014-11-26 14:00 ` Nicolas Dichtel
2014-12-04 16:41 ` [PATCH v2 iproute2] ipaddress: enable -details option Nicolas Dichtel
2014-12-10 4:14 ` Stephen Hemminger
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).