Merge branch 'master' into net-next
This commit is contained in:
commit
d72ac5a17b
|
|
@ -18,7 +18,6 @@
|
||||||
|
|
||||||
struct rtnl_handle rth = { .fd = -1 };
|
struct rtnl_handle rth = { .fd = -1 };
|
||||||
int preferred_family = AF_UNSPEC;
|
int preferred_family = AF_UNSPEC;
|
||||||
int resolve_hosts;
|
|
||||||
int oneline;
|
int oneline;
|
||||||
int show_stats;
|
int show_stats;
|
||||||
int show_details;
|
int show_details;
|
||||||
|
|
|
||||||
|
|
@ -3803,12 +3803,16 @@ static int cmd_dpipe(struct dl *dl)
|
||||||
static void help(void)
|
static void help(void)
|
||||||
{
|
{
|
||||||
pr_err("Usage: devlink [ OPTIONS ] OBJECT { COMMAND | help }\n"
|
pr_err("Usage: devlink [ OPTIONS ] OBJECT { COMMAND | help }\n"
|
||||||
|
" devlink [ -f[orce] ] -b[atch] filename\n"
|
||||||
"where OBJECT := { dev | port | sb | monitor | dpipe }\n"
|
"where OBJECT := { dev | port | sb | monitor | dpipe }\n"
|
||||||
" OPTIONS := { -V[ersion] | -n[no-nice-names] | -j[json] | -p[pretty] | -v[verbose] }\n");
|
" OPTIONS := { -V[ersion] | -n[no-nice-names] | -j[json] | -p[pretty] | -v[verbose] }\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dl_cmd(struct dl *dl)
|
static int dl_cmd(struct dl *dl, int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
dl->argc = argc;
|
||||||
|
dl->argv = argv;
|
||||||
|
|
||||||
if (dl_argv_match(dl, "help") || dl_no_arg(dl)) {
|
if (dl_argv_match(dl, "help") || dl_no_arg(dl)) {
|
||||||
help();
|
help();
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -3832,13 +3836,10 @@ static int dl_cmd(struct dl *dl)
|
||||||
return -ENOENT;
|
return -ENOENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dl_init(struct dl *dl, int argc, char **argv)
|
static int dl_init(struct dl *dl)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
dl->argc = argc;
|
|
||||||
dl->argv = argv;
|
|
||||||
|
|
||||||
dl->nlg = mnlg_socket_open(DEVLINK_GENL_NAME, DEVLINK_GENL_VERSION);
|
dl->nlg = mnlg_socket_open(DEVLINK_GENL_NAME, DEVLINK_GENL_VERSION);
|
||||||
if (!dl->nlg) {
|
if (!dl->nlg) {
|
||||||
pr_err("Failed to connect to devlink Netlink\n");
|
pr_err("Failed to connect to devlink Netlink\n");
|
||||||
|
|
@ -3890,16 +3891,59 @@ static void dl_free(struct dl *dl)
|
||||||
free(dl);
|
free(dl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int dl_batch(struct dl *dl, const char *name, bool force)
|
||||||
|
{
|
||||||
|
char *line = NULL;
|
||||||
|
size_t len = 0;
|
||||||
|
int ret = EXIT_SUCCESS;
|
||||||
|
|
||||||
|
if (name && strcmp(name, "-") != 0) {
|
||||||
|
if (freopen(name, "r", stdin) == NULL) {
|
||||||
|
fprintf(stderr,
|
||||||
|
"Cannot open file \"%s\" for reading: %s\n",
|
||||||
|
name, strerror(errno));
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cmdlineno = 0;
|
||||||
|
while (getcmdline(&line, &len, stdin) != -1) {
|
||||||
|
char *largv[100];
|
||||||
|
int largc;
|
||||||
|
|
||||||
|
largc = makeargs(line, largv, 100);
|
||||||
|
if (!largc)
|
||||||
|
continue; /* blank line */
|
||||||
|
|
||||||
|
if (dl_cmd(dl, largc, largv)) {
|
||||||
|
fprintf(stderr, "Command failed %s:%d\n",
|
||||||
|
name, cmdlineno);
|
||||||
|
ret = EXIT_FAILURE;
|
||||||
|
if (!force)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (line)
|
||||||
|
free(line);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
static const struct option long_options[] = {
|
static const struct option long_options[] = {
|
||||||
{ "Version", no_argument, NULL, 'V' },
|
{ "Version", no_argument, NULL, 'V' },
|
||||||
|
{ "force", no_argument, NULL, 'f' },
|
||||||
|
{ "batch", required_argument, NULL, 'b' },
|
||||||
{ "no-nice-names", no_argument, NULL, 'n' },
|
{ "no-nice-names", no_argument, NULL, 'n' },
|
||||||
{ "json", no_argument, NULL, 'j' },
|
{ "json", no_argument, NULL, 'j' },
|
||||||
{ "pretty", no_argument, NULL, 'p' },
|
{ "pretty", no_argument, NULL, 'p' },
|
||||||
{ "verbose", no_argument, NULL, 'v' },
|
{ "verbose", no_argument, NULL, 'v' },
|
||||||
{ NULL, 0, NULL, 0 }
|
{ NULL, 0, NULL, 0 }
|
||||||
};
|
};
|
||||||
|
const char *batch_file = NULL;
|
||||||
|
bool force = false;
|
||||||
struct dl *dl;
|
struct dl *dl;
|
||||||
int opt;
|
int opt;
|
||||||
int err;
|
int err;
|
||||||
|
|
@ -3911,7 +3955,7 @@ int main(int argc, char **argv)
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
while ((opt = getopt_long(argc, argv, "Vnjpv",
|
while ((opt = getopt_long(argc, argv, "Vfb:njpv",
|
||||||
long_options, NULL)) >= 0) {
|
long_options, NULL)) >= 0) {
|
||||||
|
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
|
|
@ -3919,6 +3963,12 @@ int main(int argc, char **argv)
|
||||||
printf("devlink utility, iproute2-ss%s\n", SNAPSHOT);
|
printf("devlink utility, iproute2-ss%s\n", SNAPSHOT);
|
||||||
ret = EXIT_SUCCESS;
|
ret = EXIT_SUCCESS;
|
||||||
goto dl_free;
|
goto dl_free;
|
||||||
|
case 'f':
|
||||||
|
force = true;
|
||||||
|
break;
|
||||||
|
case 'b':
|
||||||
|
batch_file = optarg;
|
||||||
|
break;
|
||||||
case 'n':
|
case 'n':
|
||||||
dl->no_nice_names = true;
|
dl->no_nice_names = true;
|
||||||
break;
|
break;
|
||||||
|
|
@ -3942,13 +3992,17 @@ int main(int argc, char **argv)
|
||||||
argc -= optind;
|
argc -= optind;
|
||||||
argv += optind;
|
argv += optind;
|
||||||
|
|
||||||
err = dl_init(dl, argc, argv);
|
err = dl_init(dl);
|
||||||
if (err) {
|
if (err) {
|
||||||
ret = EXIT_FAILURE;
|
ret = EXIT_FAILURE;
|
||||||
goto dl_free;
|
goto dl_free;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = dl_cmd(dl);
|
if (batch_file)
|
||||||
|
err = dl_batch(dl, batch_file, force);
|
||||||
|
else
|
||||||
|
err = dl_cmd(dl, argc, argv);
|
||||||
|
|
||||||
if (err) {
|
if (err) {
|
||||||
ret = EXIT_FAILURE;
|
ret = EXIT_FAILURE;
|
||||||
goto dl_fini;
|
goto dl_fini;
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,6 @@
|
||||||
int show_stats = 0;
|
int show_stats = 0;
|
||||||
int show_details = 0;
|
int show_details = 0;
|
||||||
int show_raw = 0;
|
int show_raw = 0;
|
||||||
int resolve_hosts = 0;
|
|
||||||
|
|
||||||
static void *BODY;
|
static void *BODY;
|
||||||
static struct genl_util * genl_list;
|
static struct genl_util * genl_list;
|
||||||
|
|
|
||||||
1
ip/ip.c
1
ip/ip.c
|
|
@ -30,7 +30,6 @@ int human_readable;
|
||||||
int use_iec;
|
int use_iec;
|
||||||
int show_stats;
|
int show_stats;
|
||||||
int show_details;
|
int show_details;
|
||||||
int resolve_hosts;
|
|
||||||
int oneline;
|
int oneline;
|
||||||
int brief;
|
int brief;
|
||||||
int json;
|
int json;
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,6 @@
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "libnetlink.h"
|
#include "libnetlink.h"
|
||||||
|
|
||||||
int resolve_hosts;
|
|
||||||
static int init_phase = 1;
|
static int init_phase = 1;
|
||||||
|
|
||||||
static void write_stamp(FILE *fp)
|
static void write_stamp(FILE *fp)
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,7 @@
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "namespace.h"
|
#include "namespace.h"
|
||||||
|
|
||||||
|
int resolve_hosts;
|
||||||
int timestamp_short;
|
int timestamp_short;
|
||||||
|
|
||||||
int get_hex(char c)
|
int get_hex(char c)
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,12 @@ devlink \- Devlink tool
|
||||||
.BR help " }"
|
.BR help " }"
|
||||||
.sp
|
.sp
|
||||||
|
|
||||||
|
.ti -8
|
||||||
|
.B devlink
|
||||||
|
.RB "[ " -force " ] "
|
||||||
|
.BI "-batch " filename
|
||||||
|
.sp
|
||||||
|
|
||||||
.ti -8
|
.ti -8
|
||||||
.IR OBJECT " := { "
|
.IR OBJECT " := { "
|
||||||
.BR dev " | " port " | " monitor " }"
|
.BR dev " | " port " | " monitor " }"
|
||||||
|
|
@ -31,6 +37,16 @@ Print the version of the
|
||||||
.B devlink
|
.B devlink
|
||||||
utility and exit.
|
utility and exit.
|
||||||
|
|
||||||
|
.TP
|
||||||
|
.BR "\-b", " \-batch " <FILENAME>
|
||||||
|
Read commands from provided file or standard input and invoke them.
|
||||||
|
First failure will cause termination of devlink.
|
||||||
|
|
||||||
|
.TP
|
||||||
|
.BR "\-force"
|
||||||
|
Don't terminate devlink on errors in batch mode.
|
||||||
|
If there were any errors during execution of the commands, the application return code will be non zero.
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.BR "\-n" , " --no-nice-names"
|
.BR "\-n" , " --no-nice-names"
|
||||||
Turn off printing out nice names, for example netdevice ifnames instead of devlink port identification.
|
Turn off printing out nice names, for example netdevice ifnames instead of devlink port identification.
|
||||||
|
|
|
||||||
|
|
@ -38,8 +38,6 @@
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "rt_names.h"
|
#include "rt_names.h"
|
||||||
|
|
||||||
int resolve_hosts;
|
|
||||||
|
|
||||||
DB *dbase;
|
DB *dbase;
|
||||||
char *dbname = "/var/lib/arpd/arpd.db";
|
char *dbname = "/var/lib/arpd/arpd.db";
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -89,7 +89,6 @@ static int security_get_initial_context(char *name, char **context)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int resolve_hosts;
|
|
||||||
int resolve_services = 1;
|
int resolve_services = 1;
|
||||||
int preferred_family = AF_UNSPEC;
|
int preferred_family = AF_UNSPEC;
|
||||||
int show_options;
|
int show_options;
|
||||||
|
|
|
||||||
1
tc/tc.c
1
tc/tc.c
|
|
@ -39,7 +39,6 @@ int show_graph;
|
||||||
int timestamp;
|
int timestamp;
|
||||||
|
|
||||||
int batch_mode;
|
int batch_mode;
|
||||||
int resolve_hosts;
|
|
||||||
int use_iec;
|
int use_iec;
|
||||||
int force;
|
int force;
|
||||||
bool use_names;
|
bool use_names;
|
||||||
|
|
|
||||||
|
|
@ -231,6 +231,16 @@ int print_qdisc(const struct sockaddr_nl *who,
|
||||||
if (n->nlmsg_type == RTM_DELQDISC)
|
if (n->nlmsg_type == RTM_DELQDISC)
|
||||||
fprintf(fp, "deleted ");
|
fprintf(fp, "deleted ");
|
||||||
|
|
||||||
|
if (n->nlmsg_type == RTM_NEWQDISC &&
|
||||||
|
(n->nlmsg_flags & NLM_F_CREATE) &&
|
||||||
|
(n->nlmsg_flags & NLM_F_REPLACE))
|
||||||
|
fprintf(fp, "replaced ");
|
||||||
|
|
||||||
|
if (n->nlmsg_type == RTM_NEWQDISC &&
|
||||||
|
(n->nlmsg_flags & NLM_F_CREATE) &&
|
||||||
|
(n->nlmsg_flags & NLM_F_EXCL))
|
||||||
|
fprintf(fp, "added ");
|
||||||
|
|
||||||
if (show_raw)
|
if (show_raw)
|
||||||
fprintf(fp, "qdisc %s %x:[%08x] ",
|
fprintf(fp, "qdisc %s %x:[%08x] ",
|
||||||
rta_getattr_str(tb[TCA_KIND]),
|
rta_getattr_str(tb[TCA_KIND]),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue