Skip to content

Commit b400031

Browse files
Boris Sukholitkodavem330
authored andcommitted
net/sched: flower: Add number of vlan tags filter
These are bookkeeping parts of the new num_of_vlans filter. Defines, dump, load and set are being done here. Signed-off-by: Boris Sukholitko <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 34951fc commit b400031

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

include/uapi/linux/pkt_cls.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,8 @@ enum {
587587
TCA_FLOWER_KEY_HASH, /* u32 */
588588
TCA_FLOWER_KEY_HASH_MASK, /* u32 */
589589

590+
TCA_FLOWER_KEY_NUM_OF_VLANS, /* u8 */
591+
590592
__TCA_FLOWER_MAX,
591593
};
592594

net/sched/cls_flower.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ struct fl_flow_key {
7272
} tp_range;
7373
struct flow_dissector_key_ct ct;
7474
struct flow_dissector_key_hash hash;
75+
struct flow_dissector_key_num_of_vlans num_of_vlans;
7576
} __aligned(BITS_PER_LONG / 8); /* Ensure that we can do comparisons as longs. */
7677

7778
struct fl_flow_mask_range {
@@ -712,6 +713,7 @@ static const struct nla_policy fl_policy[TCA_FLOWER_MAX + 1] = {
712713
[TCA_FLOWER_FLAGS] = { .type = NLA_U32 },
713714
[TCA_FLOWER_KEY_HASH] = { .type = NLA_U32 },
714715
[TCA_FLOWER_KEY_HASH_MASK] = { .type = NLA_U32 },
716+
[TCA_FLOWER_KEY_NUM_OF_VLANS] = { .type = NLA_U8 },
715717

716718
};
717719

@@ -1615,6 +1617,11 @@ static int fl_set_key(struct net *net, struct nlattr **tb,
16151617
fl_set_key_val(tb, key->eth.src, TCA_FLOWER_KEY_ETH_SRC,
16161618
mask->eth.src, TCA_FLOWER_KEY_ETH_SRC_MASK,
16171619
sizeof(key->eth.src));
1620+
fl_set_key_val(tb, &key->num_of_vlans,
1621+
TCA_FLOWER_KEY_NUM_OF_VLANS,
1622+
&mask->num_of_vlans,
1623+
TCA_FLOWER_UNSPEC,
1624+
sizeof(key->num_of_vlans));
16181625

16191626
if (is_vlan_key(tb[TCA_FLOWER_KEY_ETH_TYPE], &ethertype, key, mask)) {
16201627
fl_set_key_vlan(tb, ethertype, TCA_FLOWER_KEY_VLAN_ID,
@@ -1906,6 +1913,8 @@ static void fl_init_dissector(struct flow_dissector *dissector,
19061913
FLOW_DISSECTOR_KEY_CT, ct);
19071914
FL_KEY_SET_IF_MASKED(mask, keys, cnt,
19081915
FLOW_DISSECTOR_KEY_HASH, hash);
1916+
FL_KEY_SET_IF_MASKED(mask, keys, cnt,
1917+
FLOW_DISSECTOR_KEY_NUM_OF_VLANS, num_of_vlans);
19091918

19101919
skb_flow_dissector_init(dissector, keys, cnt);
19111920
}
@@ -2994,6 +3003,11 @@ static int fl_dump_key(struct sk_buff *skb, struct net *net,
29943003
sizeof(key->basic.n_proto)))
29953004
goto nla_put_failure;
29963005

3006+
if (mask->num_of_vlans.num_of_vlans) {
3007+
if (nla_put_u8(skb, TCA_FLOWER_KEY_NUM_OF_VLANS, key->num_of_vlans.num_of_vlans))
3008+
goto nla_put_failure;
3009+
}
3010+
29973011
if (fl_dump_key_mpls(skb, &key->mpls, &mask->mpls))
29983012
goto nla_put_failure;
29993013

0 commit comments

Comments
 (0)