naccyde / rpms / iproute

Forked from rpms/iproute 5 months ago
Clone

Blame SOURCES/0155-ipaddress-Allow-listing-addresses-by-type.patch

049c96
From 836bc8fd1c04199a9a2b40fc8c2cf07debb7fd0b Mon Sep 17 00:00:00 2001
049c96
From: Phil Sutter <psutter@redhat.com>
049c96
Date: Thu, 16 Jun 2016 16:41:52 +0200
049c96
Subject: [PATCH] ipaddress: Allow listing addresses by type
049c96
049c96
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1341343
049c96
Upstream Status: iproute2.git commit 24604eb2877a3
049c96
049c96
commit 24604eb2877a3be3f3167ca329b37cba178537f2
049c96
Author: Phil Sutter <phil@nwl.cc>
049c96
Date:   Thu Jun 9 19:20:36 2016 +0200
049c96
049c96
    ipaddress: Allow listing addresses by type
049c96
049c96
    Not sure why this was limited to ip-link before. It is semantically
049c96
    equal to the 'master' keyword, which is not restricted at all.
049c96
049c96
    The man page and help text adjustments include the 'master' keyword as
049c96
    well since that is also supported but wasn't documented before.
049c96
049c96
    Cc: Vadim Kochan <vadim4j@gmail.com>
049c96
    Signed-off-by: Phil Sutter <phil@nwl.cc>
049c96
---
049c96
 ip/ipaddress.c           | 11 ++++++++--
049c96
 man/man8/ip-address.8.in | 57 +++++++++++++++++++++++++++++++++++++++++++++---
049c96
 2 files changed, 63 insertions(+), 5 deletions(-)
049c96
049c96
diff --git a/ip/ipaddress.c b/ip/ipaddress.c
049c96
index 4720de0..f10f58a 100644
049c96
--- a/ip/ipaddress.c
049c96
+++ b/ip/ipaddress.c
049c96
@@ -73,8 +73,11 @@ static void usage(void)
049c96
 	fprintf(stderr, "Usage: ip address {add|change|replace} IFADDR dev IFNAME [ LIFETIME ]\n");
049c96
 	fprintf(stderr, "                                                      [ CONFFLAG-LIST ]\n");
049c96
 	fprintf(stderr, "       ip address del IFADDR dev IFNAME [mngtmpaddr]\n");
049c96
-	fprintf(stderr, "       ip address {show|save|flush} [ dev IFNAME ] [ scope SCOPE-ID ]\n");
049c96
+	fprintf(stderr, "       ip address {save|flush} [ dev IFNAME ] [ scope SCOPE-ID ]\n");
049c96
 	fprintf(stderr, "                            [ to PREFIX ] [ FLAG-LIST ] [ label LABEL ] [up]\n");
049c96
+	fprintf(stderr, "       ip address [ show [ dev IFNAME ] [ scope SCOPE-ID ] [ master DEVICE ]\n");
049c96
+	fprintf(stderr, "                         [ type TYPE ] [ to PREFIX ] [ FLAG-LIST ]\n");
049c96
+	fprintf(stderr, "                         [ label LABEL ] [up] ]\n");
049c96
 	fprintf(stderr, "       ip address {showdump|restore}\n");
049c96
 	fprintf(stderr, "IFADDR := PREFIX | ADDR peer PREFIX\n");
049c96
 	fprintf(stderr, "          [ broadcast ADDR ] [ anycast ADDR ]\n");
049c96
@@ -88,6 +91,10 @@ static void usage(void)
049c96
 	fprintf(stderr, "CONFFLAG  := [ home | nodad | mngtmpaddr | noprefixroute | autojoin ]\n");
049c96
 	fprintf(stderr, "LIFETIME := [ valid_lft LFT ] [ preferred_lft LFT ]\n");
049c96
 	fprintf(stderr, "LFT := forever | SECONDS\n");
049c96
+	fprintf(stderr, "TYPE := { vlan | veth | vcan | dummy | ifb | macvlan | macvtap |\n");
049c96
+	fprintf(stderr, "          bridge | bond | ipoib | ip6tnl | ipip | sit | vxlan |\n");
049c96
+	fprintf(stderr, "          gre | gretap | ip6gre | ip6gretap | vti | nlmon |\n");
049c96
+	fprintf(stderr, "          bond_slave | ipvlan | geneve | bridge_slave | vrf }\n");
049c96
 
049c96
 	exit(-1);
049c96
 }
049c96
@@ -1332,7 +1339,7 @@ static int ipaddr_list_flush_or_save(int argc, char **argv, int action)
049c96
 			if (!ifindex)
049c96
 				invarg("Device does not exist\n", *argv);
049c96
 			filter.master = ifindex;
049c96
-		} else if (do_link && strcmp(*argv, "type") == 0) {
049c96
+		} else if (strcmp(*argv, "type") == 0) {
049c96
 			NEXT_ARG();
049c96
 			filter.kind = *argv;
049c96
 		} else {
049c96
diff --git a/man/man8/ip-address.8.in b/man/man8/ip-address.8.in
049c96
index ff3fe0b..ab0942d 100644
049c96
--- a/man/man8/ip-address.8.in
049c96
+++ b/man/man8/ip-address.8.in
049c96
@@ -23,7 +23,7 @@ ip-address \- protocol address management
049c96
 .IB IFADDR " dev " IFNAME " [ " mngtmpaddr " ]"
049c96
 
049c96
 .ti -8
049c96
-.BR "ip address" " { " show " | " save " | " flush " } [ " dev
049c96
+.BR "ip address" " { " save " | " flush " } [ " dev
049c96
 .IR IFNAME " ] [ "
049c96
 .B  scope
049c96
 .IR SCOPE-ID " ] [ "
049c96
@@ -33,6 +33,21 @@ ip-address \- protocol address management
049c96
 .IR PATTERN " ] [ " up " ]"
049c96
 
049c96
 .ti -8
049c96
+.BR "ip address" " [ " show  " [ " dev
049c96
+.IR IFNAME " ] [ "
049c96
+.B  scope
049c96
+.IR SCOPE-ID " ] [ "
049c96
+.B  to
049c96
+.IR PREFIX " ] [ " FLAG-LIST " ] [ "
049c96
+.B  label
049c96
+.IR PATTERN " ] [ "
049c96
+.B  master
049c96
+.IR DEVICE " ] [ "
049c96
+.B  type
049c96
+.IR TYPE " ] [ "
049c96
+.BR up " ] ]"
049c96
+
049c96
+.ti -8
049c96
 .BR "ip address" " { " showdump " | " restore " }"
049c96
 
049c96
 .ti -8
049c96
@@ -80,6 +95,34 @@ ip-address \- protocol address management
049c96
 .BR forever " |"
049c96
 .IR SECONDS " ]"
049c96
 
049c96
+.ti -8
049c96
+.IR TYPE " := [ "
049c96
+.BR bridge " | "
049c96
+.BR bond " | "
049c96
+.BR can " | "
049c96
+.BR dummy " | "
049c96
+.BR hsr " | "
049c96
+.BR ifb " | "
049c96
+.BR ipoib " |"
049c96
+.BR macvlan  " | "
049c96
+.BR macvtap  " | "
049c96
+.BR vcan " | "
049c96
+.BR veth " | "
049c96
+.BR vlan " | "
049c96
+.BR vxlan " |"
049c96
+.BR ip6tnl " |"
049c96
+.BR ipip " |"
049c96
+.BR sit " |"
049c96
+.BR gre " |"
049c96
+.BR gretap " |"
049c96
+.BR ip6gre " |"
049c96
+.BR ip6gretap " |"
049c96
+.BR vti " |"
049c96
+.BR nlmon " |"
049c96
+.BR ipvlan " |"
049c96
+.BR lowpan " |"
049c96
+.BR geneve " ]"
049c96
+
049c96
 .SH "DESCRIPTION"
049c96
 The
049c96
 .B address
049c96
@@ -230,6 +273,14 @@ only list addresses with labels matching the
049c96
 is a usual shell style pattern.
049c96
 
049c96
 .TP
049c96
+.BI master " DEVICE"
049c96
+only list interfaces enslaved to this master device.
049c96
+
049c96
+.TP
049c96
+.BI type " TYPE"
049c96
+only list interfaces of the given type.
049c96
+
049c96
+.TP
049c96
 .B up
049c96
 only list running interfaces.
049c96
 
049c96
@@ -280,8 +331,8 @@ This command flushes the protocol addresses selected by some criteria.
049c96
 
049c96
 .PP
049c96
 This command has the same arguments as
049c96
-.B show.
049c96
-The difference is that it does not run when no arguments are given.
049c96
+.BR show " except that " type " and " master " selectors are not supported."
049c96
+Another difference is that it does not run when no arguments are given.
049c96
 
049c96
 .PP
049c96
 .B Warning:
049c96
-- 
049c96
1.8.3.1
049c96