m_mirred: style cleanups
Fix whitespace and long lines. Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
This commit is contained in:
parent
5c235ac27e
commit
c6a656f4f9
|
|
@ -28,13 +28,13 @@
|
||||||
static void
|
static void
|
||||||
explain(void)
|
explain(void)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Usage: mirred <DIRECTION> <ACTION> [index INDEX] <dev DEVICENAME>\n");
|
fprintf(stderr,
|
||||||
fprintf(stderr, "where:\n");
|
"Usage: mirred <DIRECTION> <ACTION> [index INDEX] <dev DEVICENAME>\n"
|
||||||
fprintf(stderr, "\tDIRECTION := <ingress | egress>\n");
|
"where:\n"
|
||||||
fprintf(stderr, "\tACTION := <mirror | redirect>\n");
|
"\tDIRECTION := <ingress | egress>\n"
|
||||||
fprintf(stderr, "\tINDEX is the specific policy instance id\n");
|
"\tACTION := <mirror | redirect>\n"
|
||||||
fprintf(stderr, "\tDEVICENAME is the devicename\n");
|
"\tINDEX is the specific policy instance id\n"
|
||||||
|
"\tDEVICENAME is the devicename\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
@ -107,7 +107,8 @@ parse_direction(struct action_util *a, int *argc_p, char ***argv_p,
|
||||||
} else if (!egress && matches(*argv, "egress") == 0) {
|
} else if (!egress && matches(*argv, "egress") == 0) {
|
||||||
egress = 1;
|
egress = 1;
|
||||||
if (ingress) {
|
if (ingress) {
|
||||||
fprintf(stderr, "Can't have both egress and ingress\n");
|
fprintf(stderr,
|
||||||
|
"Can't have both egress and ingress\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
NEXT_ARG();
|
NEXT_ARG();
|
||||||
|
|
@ -116,7 +117,8 @@ parse_direction(struct action_util *a, int *argc_p, char ***argv_p,
|
||||||
} else if (!ingress && matches(*argv, "ingress") == 0) {
|
} else if (!ingress && matches(*argv, "ingress") == 0) {
|
||||||
ingress = 1;
|
ingress = 1;
|
||||||
if (egress) {
|
if (egress) {
|
||||||
fprintf(stderr, "Can't have both ingress and egress\n");
|
fprintf(stderr,
|
||||||
|
"Can't have both ingress and egress\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
NEXT_ARG();
|
NEXT_ARG();
|
||||||
|
|
@ -137,30 +139,35 @@ parse_direction(struct action_util *a, int *argc_p, char ***argv_p,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else if (!ok) {
|
} else if (!ok) {
|
||||||
fprintf(stderr, "was expecting egress or ingress (%s)\n", *argv);
|
fprintf(stderr,
|
||||||
|
"was expecting egress or ingress (%s)\n",
|
||||||
|
*argv);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
} else if (!mirror && matches(*argv, "mirror") == 0) {
|
} else if (!mirror && matches(*argv, "mirror") == 0) {
|
||||||
mirror = 1;
|
mirror = 1;
|
||||||
if (redir) {
|
if (redir) {
|
||||||
fprintf(stderr, "Can't have both mirror and redir\n");
|
fprintf(stderr,
|
||||||
|
"Can't have both mirror and redir\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
p.eaction = egress ? TCA_EGRESS_MIRROR :
|
p.eaction = egress ? TCA_EGRESS_MIRROR :
|
||||||
TCA_INGRESS_MIRROR;
|
TCA_INGRESS_MIRROR;
|
||||||
p.action = TC_ACT_PIPE;
|
p.action = TC_ACT_PIPE;
|
||||||
ok++;
|
ok++;
|
||||||
} else if (!redir && matches(*argv, "redirect") == 0) {
|
} else if (!redir && matches(*argv, "redirect") == 0) {
|
||||||
redir = 1;
|
redir = 1;
|
||||||
if (mirror) {
|
if (mirror) {
|
||||||
fprintf(stderr, "Can't have both mirror and redir\n");
|
fprintf(stderr,
|
||||||
|
"Can't have both mirror and redir\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
p.eaction = egress ? TCA_EGRESS_REDIR :
|
p.eaction = egress ? TCA_EGRESS_REDIR :
|
||||||
TCA_INGRESS_REDIR;
|
TCA_INGRESS_REDIR;
|
||||||
p.action = TC_ACT_STOLEN;
|
p.action = TC_ACT_STOLEN;
|
||||||
ok++;
|
ok++;
|
||||||
} else if ((redir || mirror) && matches(*argv, "dev") == 0) {
|
} else if ((redir || mirror) &&
|
||||||
|
matches(*argv, "dev") == 0) {
|
||||||
NEXT_ARG();
|
NEXT_ARG();
|
||||||
if (strlen(d))
|
if (strlen(d))
|
||||||
duparg("dev", *argv);
|
duparg("dev", *argv);
|
||||||
|
|
@ -177,18 +184,16 @@ parse_direction(struct action_util *a, int *argc_p, char ***argv_p,
|
||||||
NEXT_ARG();
|
NEXT_ARG();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ok && !iok) {
|
if (!ok && !iok)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (d[0]) {
|
if (d[0]) {
|
||||||
int idx;
|
int idx;
|
||||||
|
|
||||||
ll_init_map(&rth);
|
ll_init_map(&rth);
|
||||||
|
|
||||||
if ((idx = ll_name_to_index(d)) == 0) {
|
idx = ll_name_to_index(d);
|
||||||
|
if (idx == 0) {
|
||||||
fprintf(stderr, "Cannot find device \"%s\"\n", d);
|
fprintf(stderr, "Cannot find device \"%s\"\n", d);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
@ -204,16 +209,17 @@ parse_direction(struct action_util *a, int *argc_p, char ***argv_p,
|
||||||
if (iok && matches(*argv, "index") == 0) {
|
if (iok && matches(*argv, "index") == 0) {
|
||||||
fprintf(stderr, "mirred: Illegal double index\n");
|
fprintf(stderr, "mirred: Illegal double index\n");
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
}
|
||||||
if (matches(*argv, "index") == 0) {
|
|
||||||
NEXT_ARG();
|
if (matches(*argv, "index") == 0) {
|
||||||
if (get_u32(&p.index, *argv, 10)) {
|
NEXT_ARG();
|
||||||
fprintf(stderr, "mirred: Illegal \"index\"\n");
|
if (get_u32(&p.index, *argv, 10)) {
|
||||||
return -1;
|
fprintf(stderr,
|
||||||
}
|
"mirred: Illegal \"index\"\n");
|
||||||
argc--;
|
return -1;
|
||||||
argv++;
|
|
||||||
}
|
}
|
||||||
|
argc--;
|
||||||
|
argv++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -270,7 +276,7 @@ parse_mirred(struct action_util *a, int *argc_p, char ***argv_p,
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
print_mirred(struct action_util *au, FILE * f, struct rtattr *arg)
|
print_mirred(struct action_util *au, FILE *f, struct rtattr *arg)
|
||||||
{
|
{
|
||||||
struct tc_mirred *p;
|
struct tc_mirred *p;
|
||||||
struct rtattr *tb[TCA_MIRRED_MAX + 1];
|
struct rtattr *tb[TCA_MIRRED_MAX + 1];
|
||||||
|
|
@ -287,12 +293,8 @@ print_mirred(struct action_util *au, FILE * f, struct rtattr *arg)
|
||||||
}
|
}
|
||||||
p = RTA_DATA(tb[TCA_MIRRED_PARMS]);
|
p = RTA_DATA(tb[TCA_MIRRED_PARMS]);
|
||||||
|
|
||||||
/*
|
dev = ll_index_to_name(p->ifindex);
|
||||||
ll_init_map(&rth);
|
if (dev == 0) {
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
if ((dev = ll_index_to_name(p->ifindex)) == 0) {
|
|
||||||
fprintf(stderr, "Cannot find device %d\n", p->ifindex);
|
fprintf(stderr, "Cannot find device %d\n", p->ifindex);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue