mirror of
https://git.proxmox.com/git/mirror_iproute2
synced 2025-10-10 20:10:05 +00:00
ip link: Allow to filter devices by master dev
Added 'master' option to 'ip link show' command to filter devices by master dev. Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
This commit is contained in:
parent
1fa804e0d3
commit
1b94414854
@ -56,6 +56,7 @@ static struct
|
|||||||
int flushp;
|
int flushp;
|
||||||
int flushe;
|
int flushe;
|
||||||
int group;
|
int group;
|
||||||
|
int master;
|
||||||
} filter;
|
} filter;
|
||||||
|
|
||||||
static int do_link;
|
static int do_link;
|
||||||
@ -542,6 +543,14 @@ int print_linkinfo(const struct sockaddr_nl *who,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (tb[IFLA_MASTER]) {
|
||||||
|
int master = *(int*)RTA_DATA(tb[IFLA_MASTER]);
|
||||||
|
if (filter.master > 0 && master != filter.master)
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
else if (filter.master > 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
if (n->nlmsg_type == RTM_DELLINK)
|
if (n->nlmsg_type == RTM_DELLINK)
|
||||||
fprintf(fp, "Deleted ");
|
fprintf(fp, "Deleted ");
|
||||||
|
|
||||||
@ -1277,6 +1286,13 @@ static int ipaddr_list_flush_or_save(int argc, char **argv, int action)
|
|||||||
NEXT_ARG();
|
NEXT_ARG();
|
||||||
if (rtnl_group_a2n(&filter.group, *argv))
|
if (rtnl_group_a2n(&filter.group, *argv))
|
||||||
invarg("Invalid \"group\" value\n", *argv);
|
invarg("Invalid \"group\" value\n", *argv);
|
||||||
|
} else if (strcmp(*argv, "master") == 0) {
|
||||||
|
int ifindex;
|
||||||
|
NEXT_ARG();
|
||||||
|
ifindex = ll_name_to_index(*argv);
|
||||||
|
if (!ifindex)
|
||||||
|
invarg("Device does not exist\n", *argv);
|
||||||
|
filter.master = ifindex;
|
||||||
} else {
|
} else {
|
||||||
if (strcmp(*argv, "dev") == 0) {
|
if (strcmp(*argv, "dev") == 0) {
|
||||||
NEXT_ARG();
|
NEXT_ARG();
|
||||||
|
@ -82,7 +82,7 @@ void iplink_usage(void)
|
|||||||
fprintf(stderr, " [ master DEVICE ]\n");
|
fprintf(stderr, " [ master DEVICE ]\n");
|
||||||
fprintf(stderr, " [ nomaster ]\n");
|
fprintf(stderr, " [ nomaster ]\n");
|
||||||
fprintf(stderr, " [ addrgenmode { eui64 | none } ]\n");
|
fprintf(stderr, " [ addrgenmode { eui64 | none } ]\n");
|
||||||
fprintf(stderr, " ip link show [ DEVICE | group GROUP ] [up]\n");
|
fprintf(stderr, " ip link show [ DEVICE | group GROUP ] [up] [master DEV]\n");
|
||||||
|
|
||||||
if (iplink_have_newlink()) {
|
if (iplink_have_newlink()) {
|
||||||
fprintf(stderr, " ip link help [ TYPE ]\n");
|
fprintf(stderr, " ip link help [ TYPE ]\n");
|
||||||
|
@ -145,9 +145,10 @@ ip-link \- network device configuration
|
|||||||
.B ip link show
|
.B ip link show
|
||||||
.RI "[ " DEVICE " | "
|
.RI "[ " DEVICE " | "
|
||||||
.B group
|
.B group
|
||||||
.IR GROUP " |"
|
.IR GROUP " | "
|
||||||
.B up
|
.BR up " | "
|
||||||
]
|
.B master
|
||||||
|
.IR DEVICE " ]"
|
||||||
|
|
||||||
.SH "DESCRIPTION"
|
.SH "DESCRIPTION"
|
||||||
.SS ip link add - add virtual link
|
.SS ip link add - add virtual link
|
||||||
@ -678,6 +679,11 @@ specifies what group of devices to show.
|
|||||||
.B up
|
.B up
|
||||||
only display running interfaces.
|
only display running interfaces.
|
||||||
|
|
||||||
|
.TP
|
||||||
|
.BI master " DEVICE "
|
||||||
|
.I DEVICE
|
||||||
|
specifies the master device which enslaves devices to show.
|
||||||
|
|
||||||
The show command has additional formatting options:
|
The show command has additional formatting options:
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
|
Loading…
Reference in New Issue
Block a user