Skip to content

Commit 442f730

Browse files
Guillaume Naultdavem330
authored andcommitted
cls_flower: Add extack support for mpls options
Pass extack down to fl_set_key_mpls() and set message on error. Signed-off-by: Guillaume Nault <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent e4a58ef commit 442f730

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

net/sched/cls_flower.c

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -766,7 +766,8 @@ static int fl_set_key_port_range(struct nlattr **tb, struct fl_flow_key *key,
766766

767767
static int fl_set_key_mpls(struct nlattr **tb,
768768
struct flow_dissector_key_mpls *key_val,
769-
struct flow_dissector_key_mpls *key_mask)
769+
struct flow_dissector_key_mpls *key_mask,
770+
struct netlink_ext_ack *extack)
770771
{
771772
if (tb[TCA_FLOWER_KEY_MPLS_TTL]) {
772773
key_val->mpls_ttl = nla_get_u8(tb[TCA_FLOWER_KEY_MPLS_TTL]);
@@ -775,24 +776,36 @@ static int fl_set_key_mpls(struct nlattr **tb,
775776
if (tb[TCA_FLOWER_KEY_MPLS_BOS]) {
776777
u8 bos = nla_get_u8(tb[TCA_FLOWER_KEY_MPLS_BOS]);
777778

778-
if (bos & ~MPLS_BOS_MASK)
779+
if (bos & ~MPLS_BOS_MASK) {
780+
NL_SET_ERR_MSG_ATTR(extack,
781+
tb[TCA_FLOWER_KEY_MPLS_BOS],
782+
"Bottom Of Stack (BOS) must be 0 or 1");
779783
return -EINVAL;
784+
}
780785
key_val->mpls_bos = bos;
781786
key_mask->mpls_bos = MPLS_BOS_MASK;
782787
}
783788
if (tb[TCA_FLOWER_KEY_MPLS_TC]) {
784789
u8 tc = nla_get_u8(tb[TCA_FLOWER_KEY_MPLS_TC]);
785790

786-
if (tc & ~MPLS_TC_MASK)
791+
if (tc & ~MPLS_TC_MASK) {
792+
NL_SET_ERR_MSG_ATTR(extack,
793+
tb[TCA_FLOWER_KEY_MPLS_TC],
794+
"Traffic Class (TC) must be between 0 and 7");
787795
return -EINVAL;
796+
}
788797
key_val->mpls_tc = tc;
789798
key_mask->mpls_tc = MPLS_TC_MASK;
790799
}
791800
if (tb[TCA_FLOWER_KEY_MPLS_LABEL]) {
792801
u32 label = nla_get_u32(tb[TCA_FLOWER_KEY_MPLS_LABEL]);
793802

794-
if (label & ~MPLS_LABEL_MASK)
803+
if (label & ~MPLS_LABEL_MASK) {
804+
NL_SET_ERR_MSG_ATTR(extack,
805+
tb[TCA_FLOWER_KEY_MPLS_LABEL],
806+
"Label must be between 0 and 1048575");
795807
return -EINVAL;
808+
}
796809
key_val->mpls_label = label;
797810
key_mask->mpls_label = MPLS_LABEL_MASK;
798811
}
@@ -1364,7 +1377,7 @@ static int fl_set_key(struct net *net, struct nlattr **tb,
13641377
sizeof(key->icmp.code));
13651378
} else if (key->basic.n_proto == htons(ETH_P_MPLS_UC) ||
13661379
key->basic.n_proto == htons(ETH_P_MPLS_MC)) {
1367-
ret = fl_set_key_mpls(tb, &key->mpls, &mask->mpls);
1380+
ret = fl_set_key_mpls(tb, &key->mpls, &mask->mpls, extack);
13681381
if (ret)
13691382
return ret;
13701383
} else if (key->basic.n_proto == htons(ETH_P_ARP) ||

0 commit comments

Comments
 (0)