@@ -39,6 +39,7 @@ struct fl_flow_key {
39
39
struct flow_dissector_key_ipv6_addrs ipv6 ;
40
40
};
41
41
struct flow_dissector_key_ports tp ;
42
+ struct flow_dissector_key_icmp icmp ;
42
43
struct flow_dissector_key_keyid enc_key_id ;
43
44
union {
44
45
struct flow_dissector_key_ipv4_addrs enc_ipv4 ;
@@ -388,6 +389,14 @@ static const struct nla_policy fl_policy[TCA_FLOWER_MAX + 1] = {
388
389
[TCA_FLOWER_KEY_ENC_UDP_DST_PORT_MASK ] = { .type = NLA_U16 },
389
390
[TCA_FLOWER_KEY_FLAGS ] = { .type = NLA_U32 },
390
391
[TCA_FLOWER_KEY_FLAGS_MASK ] = { .type = NLA_U32 },
392
+ [TCA_FLOWER_KEY_ICMPV4_TYPE ] = { .type = NLA_U8 },
393
+ [TCA_FLOWER_KEY_ICMPV4_TYPE_MASK ] = { .type = NLA_U8 },
394
+ [TCA_FLOWER_KEY_ICMPV4_CODE ] = { .type = NLA_U8 },
395
+ [TCA_FLOWER_KEY_ICMPV4_CODE_MASK ] = { .type = NLA_U8 },
396
+ [TCA_FLOWER_KEY_ICMPV6_TYPE ] = { .type = NLA_U8 },
397
+ [TCA_FLOWER_KEY_ICMPV6_TYPE_MASK ] = { .type = NLA_U8 },
398
+ [TCA_FLOWER_KEY_ICMPV6_CODE ] = { .type = NLA_U8 },
399
+ [TCA_FLOWER_KEY_ICMPV6_CODE_MASK ] = { .type = NLA_U8 },
391
400
};
392
401
393
402
static void fl_set_key_val (struct nlattr * * tb ,
@@ -537,6 +546,26 @@ static int fl_set_key(struct net *net, struct nlattr **tb,
537
546
fl_set_key_val (tb , & key -> tp .dst , TCA_FLOWER_KEY_SCTP_DST ,
538
547
& mask -> tp .dst , TCA_FLOWER_KEY_SCTP_DST_MASK ,
539
548
sizeof (key -> tp .dst ));
549
+ } else if (key -> basic .n_proto == htons (ETH_P_IP ) &&
550
+ key -> basic .ip_proto == IPPROTO_ICMP ) {
551
+ fl_set_key_val (tb , & key -> icmp .type , TCA_FLOWER_KEY_ICMPV4_TYPE ,
552
+ & mask -> icmp .type ,
553
+ TCA_FLOWER_KEY_ICMPV4_TYPE_MASK ,
554
+ sizeof (key -> icmp .type ));
555
+ fl_set_key_val (tb , & key -> icmp .code , TCA_FLOWER_KEY_ICMPV4_CODE ,
556
+ & mask -> icmp .code ,
557
+ TCA_FLOWER_KEY_ICMPV4_CODE_MASK ,
558
+ sizeof (key -> icmp .code ));
559
+ } else if (key -> basic .n_proto == htons (ETH_P_IPV6 ) &&
560
+ key -> basic .ip_proto == IPPROTO_ICMPV6 ) {
561
+ fl_set_key_val (tb , & key -> icmp .type , TCA_FLOWER_KEY_ICMPV6_TYPE ,
562
+ & mask -> icmp .type ,
563
+ TCA_FLOWER_KEY_ICMPV6_TYPE_MASK ,
564
+ sizeof (key -> icmp .type ));
565
+ fl_set_key_val (tb , & key -> icmp .code , TCA_FLOWER_KEY_ICMPV4_CODE ,
566
+ & mask -> icmp .code ,
567
+ TCA_FLOWER_KEY_ICMPV4_CODE_MASK ,
568
+ sizeof (key -> icmp .code ));
540
569
}
541
570
542
571
if (tb [TCA_FLOWER_KEY_ENC_IPV4_SRC ] ||
@@ -648,6 +677,8 @@ static void fl_init_dissector(struct cls_fl_head *head,
648
677
FLOW_DISSECTOR_KEY_IPV6_ADDRS , ipv6 );
649
678
FL_KEY_SET_IF_MASKED (& mask -> key , keys , cnt ,
650
679
FLOW_DISSECTOR_KEY_PORTS , tp );
680
+ FL_KEY_SET_IF_MASKED (& mask -> key , keys , cnt ,
681
+ FLOW_DISSECTOR_KEY_ICMP , icmp );
651
682
FL_KEY_SET_IF_MASKED (& mask -> key , keys , cnt ,
652
683
FLOW_DISSECTOR_KEY_VLAN , vlan );
653
684
FL_KEY_SET_IF_MASKED (& mask -> key , keys , cnt ,
@@ -1050,6 +1081,28 @@ static int fl_dump(struct net *net, struct tcf_proto *tp, unsigned long fh,
1050
1081
& mask -> tp .dst , TCA_FLOWER_KEY_SCTP_DST_MASK ,
1051
1082
sizeof (key -> tp .dst ))))
1052
1083
goto nla_put_failure ;
1084
+ else if (key -> basic .n_proto == htons (ETH_P_IP ) &&
1085
+ key -> basic .ip_proto == IPPROTO_ICMP &&
1086
+ (fl_dump_key_val (skb , & key -> icmp .type ,
1087
+ TCA_FLOWER_KEY_ICMPV4_TYPE , & mask -> icmp .type ,
1088
+ TCA_FLOWER_KEY_ICMPV4_TYPE_MASK ,
1089
+ sizeof (key -> icmp .type )) ||
1090
+ fl_dump_key_val (skb , & key -> icmp .code ,
1091
+ TCA_FLOWER_KEY_ICMPV4_CODE , & mask -> icmp .code ,
1092
+ TCA_FLOWER_KEY_ICMPV4_CODE_MASK ,
1093
+ sizeof (key -> icmp .code ))))
1094
+ goto nla_put_failure ;
1095
+ else if (key -> basic .n_proto == htons (ETH_P_IPV6 ) &&
1096
+ key -> basic .ip_proto == IPPROTO_ICMPV6 &&
1097
+ (fl_dump_key_val (skb , & key -> icmp .type ,
1098
+ TCA_FLOWER_KEY_ICMPV6_TYPE , & mask -> icmp .type ,
1099
+ TCA_FLOWER_KEY_ICMPV6_TYPE_MASK ,
1100
+ sizeof (key -> icmp .type )) ||
1101
+ fl_dump_key_val (skb , & key -> icmp .code ,
1102
+ TCA_FLOWER_KEY_ICMPV6_CODE , & mask -> icmp .code ,
1103
+ TCA_FLOWER_KEY_ICMPV6_CODE_MASK ,
1104
+ sizeof (key -> icmp .code ))))
1105
+ goto nla_put_failure ;
1053
1106
1054
1107
if (key -> enc_control .addr_type == FLOW_DISSECTOR_KEY_IPV4_ADDRS &&
1055
1108
(fl_dump_key_val (skb , & key -> enc_ipv4 .src ,
0 commit comments