Merge branch 'master' into next

Signed-off-by: David Ahern <dsahern@gmail.com>
This commit is contained in:
David Ahern 2019-07-10 14:41:13 -07:00
commit 1f250b6c53
3 changed files with 33 additions and 8 deletions

View File

@ -576,6 +576,7 @@ static void print_rta_metrics(FILE *fp, const struct rtattr *rta)
int i; int i;
open_json_array(PRINT_JSON, "metrics"); open_json_array(PRINT_JSON, "metrics");
open_json_object(NULL);
parse_rtattr(mxrta, RTAX_MAX, RTA_DATA(rta), RTA_PAYLOAD(rta)); parse_rtattr(mxrta, RTAX_MAX, RTA_DATA(rta), RTA_PAYLOAD(rta));
@ -609,7 +610,7 @@ static void print_rta_metrics(FILE *fp, const struct rtattr *rta)
print_rtax_features(fp, val); print_rtax_features(fp, val);
break; break;
default: default:
fprintf(fp, "%u ", val); print_uint(PRINT_ANY, mx_names[i], "%u ", val);
break; break;
case RTAX_RTT: case RTAX_RTT:
@ -637,6 +638,7 @@ static void print_rta_metrics(FILE *fp, const struct rtattr *rta)
} }
} }
close_json_object();
close_json_array(PRINT_JSON, NULL); close_json_array(PRINT_JSON, NULL);
} }

View File

@ -9,8 +9,7 @@ skbedit - SKB editing action
.IR QUEUE_MAPPING " ] [" .IR QUEUE_MAPPING " ] ["
.B priority .B priority
.IR PRIORITY " ] [" .IR PRIORITY " ] ["
.B mark .BI mark " MARK\fR[\fB/\fIMASK] ] ["
.IR MARK " ] ["
.B ptype .B ptype
.IR PTYPE " ] [" .IR PTYPE " ] ["
.BR inheritdsfield " ]" .BR inheritdsfield " ]"
@ -49,12 +48,14 @@ or a hexadecimal major class ID optionally followed by a colon
.RB ( : ) .RB ( : )
and a hexadecimal minor class ID. and a hexadecimal minor class ID.
.TP .TP
.BI mark " MARK" .BI mark " MARK\fR[\fB/\fIMASK]"
Change the packet's firewall mark value. Change the packet's firewall mark value.
.I MARK .I MARK
is an unsigned 32bit value in automatically detected format (i.e., prefix with is an unsigned 32bit value in automatically detected format (i.e., prefix with
.RB ' 0x ' .RB ' 0x '
for hexadecimal interpretation, etc.). for hexadecimal interpretation, etc.).
.I MASK
defines the 32-bit mask selecting bits of mark value. Default is 0xffffffff.
.TP .TP
.BI ptype " PTYPE" .BI ptype " PTYPE"
Override the packet's type. Useful for setting packet type to host when Override the packet's type. Useful for setting packet type to host when

View File

@ -33,7 +33,7 @@ static void explain(void)
fprintf(stderr, "Usage: ... skbedit <[QM] [PM] [MM] [PT] [IF]>\n" fprintf(stderr, "Usage: ... skbedit <[QM] [PM] [MM] [PT] [IF]>\n"
"QM = queue_mapping QUEUE_MAPPING\n" "QM = queue_mapping QUEUE_MAPPING\n"
"PM = priority PRIORITY\n" "PM = priority PRIORITY\n"
"MM = mark MARK\n" "MM = mark MARK[/MASK]\n"
"PT = ptype PACKETYPE\n" "PT = ptype PACKETYPE\n"
"IF = inheritdsfield\n" "IF = inheritdsfield\n"
"PACKETYPE = is one of:\n" "PACKETYPE = is one of:\n"
@ -41,6 +41,7 @@ static void explain(void)
"QUEUE_MAPPING = device transmit queue to use\n" "QUEUE_MAPPING = device transmit queue to use\n"
"PRIORITY = classID to assign to priority field\n" "PRIORITY = classID to assign to priority field\n"
"MARK = firewall mark to set\n" "MARK = firewall mark to set\n"
"MASK = mask applied to firewall mark (0xffffffff by default)\n"
"note: inheritdsfield maps DS field to skb->priority\n"); "note: inheritdsfield maps DS field to skb->priority\n");
} }
@ -61,7 +62,7 @@ parse_skbedit(struct action_util *a, int *argc_p, char ***argv_p, int tca_id,
struct rtattr *tail; struct rtattr *tail;
unsigned int tmp; unsigned int tmp;
__u16 queue_mapping, ptype; __u16 queue_mapping, ptype;
__u32 flags = 0, priority, mark; __u32 flags = 0, priority, mark, mask;
__u64 pure_flags = 0; __u64 pure_flags = 0;
struct tc_skbedit sel = { 0 }; struct tc_skbedit sel = { 0 };
@ -89,12 +90,26 @@ parse_skbedit(struct action_util *a, int *argc_p, char ***argv_p, int tca_id,
} }
ok++; ok++;
} else if (matches(*argv, "mark") == 0) { } else if (matches(*argv, "mark") == 0) {
flags |= SKBEDIT_F_MARK; char *slash;
NEXT_ARG(); NEXT_ARG();
slash = strchr(*argv, '/');
if (slash)
*slash = '\0';
flags |= SKBEDIT_F_MARK;
if (get_u32(&mark, *argv, 0)) { if (get_u32(&mark, *argv, 0)) {
fprintf(stderr, "Illegal mark\n"); fprintf(stderr, "Illegal mark\n");
return -1; return -1;
} }
if (slash) {
if (get_u32(&mask, slash + 1, 0)) {
fprintf(stderr, "Illegal mask\n");
return -1;
}
flags |= SKBEDIT_F_MASK;
}
ok++; ok++;
} else if (matches(*argv, "ptype") == 0) { } else if (matches(*argv, "ptype") == 0) {
@ -133,7 +148,7 @@ parse_skbedit(struct action_util *a, int *argc_p, char ***argv_p, int tca_id,
if (matches(*argv, "index") == 0) { if (matches(*argv, "index") == 0) {
NEXT_ARG(); NEXT_ARG();
if (get_u32(&sel.index, *argv, 10)) { if (get_u32(&sel.index, *argv, 10)) {
fprintf(stderr, "Pedit: Illegal \"index\"\n"); fprintf(stderr, "skbedit: Illegal \"index\"\n");
return -1; return -1;
} }
argc--; argc--;
@ -159,6 +174,9 @@ parse_skbedit(struct action_util *a, int *argc_p, char ***argv_p, int tca_id,
if (flags & SKBEDIT_F_MARK) if (flags & SKBEDIT_F_MARK)
addattr_l(n, MAX_MSG, TCA_SKBEDIT_MARK, addattr_l(n, MAX_MSG, TCA_SKBEDIT_MARK,
&mark, sizeof(mark)); &mark, sizeof(mark));
if (flags & SKBEDIT_F_MASK)
addattr_l(n, MAX_MSG, TCA_SKBEDIT_MASK,
&mask, sizeof(mask));
if (flags & SKBEDIT_F_PTYPE) if (flags & SKBEDIT_F_PTYPE)
addattr_l(n, MAX_MSG, TCA_SKBEDIT_PTYPE, addattr_l(n, MAX_MSG, TCA_SKBEDIT_PTYPE,
&ptype, sizeof(ptype)); &ptype, sizeof(ptype));
@ -206,6 +224,10 @@ static int print_skbedit(struct action_util *au, FILE *f, struct rtattr *arg)
print_uint(PRINT_ANY, "mark", " mark %u", print_uint(PRINT_ANY, "mark", " mark %u",
rta_getattr_u32(tb[TCA_SKBEDIT_MARK])); rta_getattr_u32(tb[TCA_SKBEDIT_MARK]));
} }
if (tb[TCA_SKBEDIT_MASK]) {
print_hex(PRINT_ANY, "mask", "/%#x",
rta_getattr_u32(tb[TCA_SKBEDIT_MASK]));
}
if (tb[TCA_SKBEDIT_PTYPE] != NULL) { if (tb[TCA_SKBEDIT_PTYPE] != NULL) {
ptype = rta_getattr_u16(tb[TCA_SKBEDIT_PTYPE]); ptype = rta_getattr_u16(tb[TCA_SKBEDIT_PTYPE]);
if (ptype == PACKET_HOST) if (ptype == PACKET_HOST)