skbedit: Add support to mark packets
This adds support for setting the skb mark. Signed-off-by: Jamal Hadi Salim <hadi@cyberus.ca> Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com>
This commit is contained in:
parent
2180b6b50b
commit
e04dd30a38
|
|
@ -31,10 +31,13 @@
|
||||||
static void
|
static void
|
||||||
explain(void)
|
explain(void)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Usage: ... skbedit "
|
fprintf(stderr, "Usage: ... skbedit <[QM] [PM] [MM]>\n"
|
||||||
"queue_mapping QUEUE_MAPPING | priority PRIORITY \n"
|
"QM = queue_mapping QUEUE_MAPPING\n"
|
||||||
"QUEUE_MAPPING = device transmit queue to use\n"
|
"PM = priority PRIORITY \n"
|
||||||
"PRIORITY = classID to assign to priority field\n");
|
"MM = mark MARK \n"
|
||||||
|
"QUEUE_MAPPING = device transmit queue to use\n"
|
||||||
|
"PRIORITY = classID to assign to priority field\n"
|
||||||
|
"MARK = firewall mark to set\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
@ -54,7 +57,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;
|
__u16 queue_mapping;
|
||||||
__u32 flags = 0, priority;
|
__u32 flags = 0, priority, mark;
|
||||||
struct tc_skbedit sel = { 0 };
|
struct tc_skbedit sel = { 0 };
|
||||||
|
|
||||||
if (matches(*argv, "skbedit") != 0)
|
if (matches(*argv, "skbedit") != 0)
|
||||||
|
|
@ -80,6 +83,14 @@ parse_skbedit(struct action_util *a, int *argc_p, char ***argv_p, int tca_id,
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
ok++;
|
ok++;
|
||||||
|
} else if (matches(*argv, "mark") == 0) {
|
||||||
|
flags |= SKBEDIT_F_MARK;
|
||||||
|
NEXT_ARG();
|
||||||
|
if (get_tc_classid(&mark, *argv)) {
|
||||||
|
fprintf(stderr, "Illegal mark\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
ok++;
|
||||||
} else if (matches(*argv, "help") == 0) {
|
} else if (matches(*argv, "help") == 0) {
|
||||||
usage();
|
usage();
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -137,6 +148,9 @@ parse_skbedit(struct action_util *a, int *argc_p, char ***argv_p, int tca_id,
|
||||||
if (flags & SKBEDIT_F_PRIORITY)
|
if (flags & SKBEDIT_F_PRIORITY)
|
||||||
addattr_l(n, MAX_MSG, TCA_SKBEDIT_PRIORITY,
|
addattr_l(n, MAX_MSG, TCA_SKBEDIT_PRIORITY,
|
||||||
&priority, sizeof(priority));
|
&priority, sizeof(priority));
|
||||||
|
if (flags & SKBEDIT_F_MARK)
|
||||||
|
addattr_l(n, MAX_MSG, TCA_SKBEDIT_MARK,
|
||||||
|
&mark, sizeof(mark));
|
||||||
tail->rta_len = (char *)NLMSG_TAIL(n) - (char *)tail;
|
tail->rta_len = (char *)NLMSG_TAIL(n) - (char *)tail;
|
||||||
|
|
||||||
*argc_p = argc;
|
*argc_p = argc;
|
||||||
|
|
@ -150,6 +164,7 @@ static int print_skbedit(struct action_util *au, FILE *f, struct rtattr *arg)
|
||||||
struct rtattr *tb[TCA_SKBEDIT_MAX + 1];
|
struct rtattr *tb[TCA_SKBEDIT_MAX + 1];
|
||||||
SPRINT_BUF(b1);
|
SPRINT_BUF(b1);
|
||||||
__u32 *priority;
|
__u32 *priority;
|
||||||
|
__u32 *mark;
|
||||||
__u16 *queue_mapping;
|
__u16 *queue_mapping;
|
||||||
|
|
||||||
if (arg == NULL)
|
if (arg == NULL)
|
||||||
|
|
@ -174,6 +189,10 @@ static int print_skbedit(struct action_util *au, FILE *f, struct rtattr *arg)
|
||||||
priority = RTA_DATA(tb[TCA_SKBEDIT_PRIORITY]);
|
priority = RTA_DATA(tb[TCA_SKBEDIT_PRIORITY]);
|
||||||
fprintf(f, " priority %s", sprint_tc_classid(*priority, b1));
|
fprintf(f, " priority %s", sprint_tc_classid(*priority, b1));
|
||||||
}
|
}
|
||||||
|
if (tb[TCA_SKBEDIT_MARK] != NULL) {
|
||||||
|
mark = RTA_DATA(tb[TCA_SKBEDIT_MARK]);
|
||||||
|
fprintf(f, " mark %d", *mark);
|
||||||
|
}
|
||||||
|
|
||||||
if (show_stats) {
|
if (show_stats) {
|
||||||
if (tb[TCA_SKBEDIT_TM]) {
|
if (tb[TCA_SKBEDIT_TM]) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue