mirror of
https://github.com/opnsense/src.git
synced 2026-06-04 14:26:03 -04:00
ifconfig: add -D option to print driver name for interface
Add -D option to add the drivername and unit number to ifconfig output
for normal display, including -a. Use ifconfig_get_orig_name() from
libifconfig to fetch the name. Note that this is the original name
for many drivers, but not for some exceptions like epair (which appends
'a' or 'b' to the unit number). epair interface pairs both display
as "epair0", etc. Make -v imply -D; might as well be fully verbose.
Reviewed by: zlei, kp
Differential Revision: https://reviews.freebsd.org/D42721
(cherry picked from commit cd201c0908)
This commit is contained in:
parent
020432848e
commit
9b8515f71b
4 changed files with 30 additions and 3 deletions
|
|
@ -36,7 +36,7 @@
|
|||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Op Fl j Ar jail
|
||||
.Op Fl kLmn
|
||||
.Op Fl DkLmn
|
||||
.Op Fl f Ar type Ns Cm \&: Ns Ar format
|
||||
.Ar interface
|
||||
.Op Cm create
|
||||
|
|
@ -55,7 +55,7 @@
|
|||
.Nm
|
||||
.Op Fl j Ar jail
|
||||
.Fl a
|
||||
.Op Fl dkLmuv
|
||||
.Op Fl dDkLmuv
|
||||
.Op Fl f Ar type Ns Cm \&: Ns Ar format
|
||||
.Op Fl G Ar groupname
|
||||
.Op Fl g Ar groupname
|
||||
|
|
@ -104,6 +104,12 @@ with no additional information.
|
|||
Use of this flag is mutually exclusive with all other flags and commands.
|
||||
.It Fl d
|
||||
Display only the interfaces that are down.
|
||||
.It Fl D
|
||||
Include the driver name and unit number of the interface in the output.
|
||||
This is normally the original name of the interface,
|
||||
even if it has been renamed; it may differ from the original name
|
||||
in some cases, such as
|
||||
.Xr epair 4 .
|
||||
.It Fl f Xo
|
||||
.Ar type Ns Cm \&: Ns Ar format Ns
|
||||
.Op Cm \&, Ns Ar type Ns Cm \&: Ns Ar format Ar ...
|
||||
|
|
|
|||
|
|
@ -465,7 +465,7 @@ args_parse(struct ifconfig_args *args, int argc, char *argv[])
|
|||
int c;
|
||||
|
||||
/* Parse leading line options */
|
||||
strlcpy(options, "G:adf:j:klmnuv", sizeof(options));
|
||||
strlcpy(options, "G:adDf:j:klmnuv", sizeof(options));
|
||||
for (p = opts; p != NULL; p = p->next)
|
||||
strlcat(options, p->opt, sizeof(options));
|
||||
while ((c = getopt(argc, argv, options)) != -1) {
|
||||
|
|
@ -476,6 +476,9 @@ args_parse(struct ifconfig_args *args, int argc, char *argv[])
|
|||
case 'd': /* restrict scan to "down" interfaces */
|
||||
args->downonly = true;
|
||||
break;
|
||||
case 'D': /* Print driver name */
|
||||
args->drivername = true;
|
||||
break;
|
||||
case 'f':
|
||||
if (optarg == NULL)
|
||||
usage();
|
||||
|
|
|
|||
|
|
@ -230,6 +230,7 @@ struct ifconfig_args {
|
|||
bool supmedia; /* Supported media */
|
||||
bool printkeys; /* Print security keys */
|
||||
bool allfamilies; /* Print all families */
|
||||
bool drivername; /* Print driver name */
|
||||
int verbose; /* verbosity level */
|
||||
int argc;
|
||||
char **argv;
|
||||
|
|
|
|||
|
|
@ -369,6 +369,7 @@ status_nl(if_ctx *ctx, struct iface *iface)
|
|||
{
|
||||
if_link_t *link = &iface->link;
|
||||
struct ifconfig_args *args = ctx->args;
|
||||
char *drivername = NULL;
|
||||
|
||||
printf("%s: ", link->ifla_ifname);
|
||||
|
||||
|
|
@ -413,6 +414,22 @@ status_nl(if_ctx *ctx, struct iface *iface)
|
|||
args->afp->af_other_status(ctx);
|
||||
|
||||
print_ifstatus(ctx);
|
||||
if (args->drivername || args->verbose) {
|
||||
if (ifconfig_get_orig_name(lifh, link->ifla_ifname,
|
||||
&drivername) != 0) {
|
||||
if (ifconfig_err_errtype(lifh) == OTHER)
|
||||
fprintf(stderr, "get original name: %s\n",
|
||||
strerror(ifconfig_err_errno(lifh)));
|
||||
else
|
||||
fprintf(stderr,
|
||||
"get original name: error type %d\n",
|
||||
ifconfig_err_errtype(lifh));
|
||||
exit_code = 1;
|
||||
}
|
||||
if (drivername != NULL)
|
||||
printf("\tdrivername: %s\n", drivername);
|
||||
free(drivername);
|
||||
}
|
||||
if (args->verbose > 0)
|
||||
sfp_status(ctx);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue