" [ ipproto PROTOCOL ]\n"
" [ sport [ NUMBER | NUMBER-NUMBER ]\n"
" [ dport [ NUMBER | NUMBER-NUMBER ] ]\n"
- " [ dscp DSCP ]\n"
+ " [ dscp DSCP ] [ flowlabel FLOWLABEL[/MASK] ]\n"
"ACTION := [ table TABLE_ID ]\n"
" [ protocol PROTO ]\n"
" [ nat ADDRESS ]\n"
unsigned int pref, prefmask;
unsigned int fwmark, fwmask;
unsigned int dscp, dscpmask;
+ __u32 flowlabel, flowlabel_mask;
uint64_t tun_id;
char iif[IFNAMSIZ];
char oif[IFNAMSIZ];
}
}
+ if (filter.flowlabel_mask) {
+ __u32 flowlabel, flowlabel_mask;
+
+ if (!tb[FRA_FLOWLABEL] || !tb[FRA_FLOWLABEL_MASK])
+ return false;
+ flowlabel = rta_getattr_be32(tb[FRA_FLOWLABEL]);
+ flowlabel_mask = rta_getattr_be32(tb[FRA_FLOWLABEL_MASK]);
+
+ if (filter.flowlabel != flowlabel ||
+ filter.flowlabel_mask != flowlabel_mask)
+ return false;
+ }
+
table = frh_get_table(frh, tb);
if (filter.tb > 0 && filter.tb ^ table)
return false;
rtnl_dscp_n2a(dscp, b1, sizeof(b1)));
}
+ /* The kernel will either provide both attributes, or none */
+ if (tb[FRA_FLOWLABEL] && tb[FRA_FLOWLABEL_MASK]) {
+ __u32 flowlabel, flowlabel_mask;
+
+ flowlabel = rta_getattr_be32(tb[FRA_FLOWLABEL]);
+ flowlabel_mask = rta_getattr_be32(tb[FRA_FLOWLABEL_MASK]);
+
+ print_0xhex(PRINT_ANY, "flowlabel", " flowlabel %#llx",
+ flowlabel);
+ if (flowlabel_mask == LABEL_MAX_MASK)
+ print_0xhex(PRINT_JSON, "flowlabel_mask", NULL,
+ flowlabel_mask);
+ else
+ print_0xhex(PRINT_ANY, "flowlabel_mask", "/%#llx",
+ flowlabel_mask);
+ }
+
print_string(PRINT_FP, NULL, "\n", "");
close_json_object();
fflush(fp);
return 0;
}
+static void iprule_flowlabel_parse(char *arg, __u32 *flowlabel,
+ __u32 *flowlabel_mask)
+{
+ char *slash;
+
+ slash = strchr(arg, '/');
+ if (slash != NULL)
+ *slash = '\0';
+ if (get_u32(flowlabel, arg, 0))
+ invarg("invalid flowlabel", arg);
+ if (slash) {
+ if (get_u32(flowlabel_mask, slash + 1, 0))
+ invarg("invalid flowlabel mask", slash + 1);
+ } else {
+ *flowlabel_mask = LABEL_MAX_MASK;
+ }
+}
+
static int iprule_list_flush_or_save(int argc, char **argv, int action)
{
rtnl_filter_t filter_fn;
invarg("invalid dscp\n", *argv);
filter.dscp = dscp;
filter.dscpmask = 1;
+ } else if (strcmp(*argv, "flowlabel") == 0) {
+ NEXT_ARG();
+
+ iprule_flowlabel_parse(*argv, &filter.flowlabel,
+ &filter.flowlabel_mask);
} else {
if (matches(*argv, "dst") == 0 ||
matches(*argv, "to") == 0) {
if (rtnl_dscp_a2n(&dscp, *argv))
invarg("invalid dscp\n", *argv);
addattr8(&req.n, sizeof(req), FRA_DSCP, dscp);
+ } else if (strcmp(*argv, "flowlabel") == 0) {
+ __u32 flowlabel, flowlabel_mask;
+
+ NEXT_ARG();
+ iprule_flowlabel_parse(*argv, &flowlabel,
+ &flowlabel_mask);
+ addattr32(&req.n, sizeof(req), FRA_FLOWLABEL,
+ htonl(flowlabel));
+ addattr32(&req.n, sizeof(req), FRA_FLOWLABEL_MASK,
+ htonl(flowlabel_mask));
} else {
int type;