@@ -52,6 +52,7 @@ struct fl_flow_key {
5252 struct flow_dissector_key_mpls mpls ;
5353 struct flow_dissector_key_tcp tcp ;
5454 struct flow_dissector_key_ip ip ;
55+ struct flow_dissector_key_ip enc_ip ;
5556} __aligned (BITS_PER_LONG / 8 ); /* Ensure that we can do comparisons as longs. */
5657
5758struct fl_flow_mask_range {
@@ -453,6 +454,10 @@ static const struct nla_policy fl_policy[TCA_FLOWER_MAX + 1] = {
453454 [TCA_FLOWER_KEY_CVLAN_ID ] = { .type = NLA_U16 },
454455 [TCA_FLOWER_KEY_CVLAN_PRIO ] = { .type = NLA_U8 },
455456 [TCA_FLOWER_KEY_CVLAN_ETH_TYPE ] = { .type = NLA_U16 },
457+ [TCA_FLOWER_KEY_ENC_IP_TOS ] = { .type = NLA_U8 },
458+ [TCA_FLOWER_KEY_ENC_IP_TOS_MASK ] = { .type = NLA_U8 },
459+ [TCA_FLOWER_KEY_ENC_IP_TTL ] = { .type = NLA_U8 },
460+ [TCA_FLOWER_KEY_ENC_IP_TTL_MASK ] = { .type = NLA_U8 },
456461};
457462
458463static void fl_set_key_val (struct nlattr * * tb ,
@@ -561,17 +566,17 @@ static int fl_set_key_flags(struct nlattr **tb,
561566 return 0 ;
562567}
563568
564- static void fl_set_key_ip (struct nlattr * * tb ,
569+ static void fl_set_key_ip (struct nlattr * * tb , bool encap ,
565570 struct flow_dissector_key_ip * key ,
566571 struct flow_dissector_key_ip * mask )
567572{
568- fl_set_key_val (tb , & key -> tos , TCA_FLOWER_KEY_IP_TOS ,
569- & mask -> tos , TCA_FLOWER_KEY_IP_TOS_MASK ,
570- sizeof (key -> tos ));
573+ int tos_key = encap ? TCA_FLOWER_KEY_ENC_IP_TOS : TCA_FLOWER_KEY_IP_TOS ;
574+ int ttl_key = encap ? TCA_FLOWER_KEY_ENC_IP_TTL : TCA_FLOWER_KEY_IP_TTL ;
575+ int tos_mask = encap ? TCA_FLOWER_KEY_ENC_IP_TOS_MASK : TCA_FLOWER_KEY_IP_TOS_MASK ;
576+ int ttl_mask = encap ? TCA_FLOWER_KEY_ENC_IP_TTL_MASK : TCA_FLOWER_KEY_IP_TTL_MASK ;
571577
572- fl_set_key_val (tb , & key -> ttl , TCA_FLOWER_KEY_IP_TTL ,
573- & mask -> ttl , TCA_FLOWER_KEY_IP_TTL_MASK ,
574- sizeof (key -> ttl ));
578+ fl_set_key_val (tb , & key -> tos , tos_key , & mask -> tos , tos_mask , sizeof (key -> tos ));
579+ fl_set_key_val (tb , & key -> ttl , ttl_key , & mask -> ttl , ttl_mask , sizeof (key -> ttl ));
575580}
576581
577582static int fl_set_key (struct net * net , struct nlattr * * tb ,
@@ -633,7 +638,7 @@ static int fl_set_key(struct net *net, struct nlattr **tb,
633638 fl_set_key_val (tb , & key -> basic .ip_proto , TCA_FLOWER_KEY_IP_PROTO ,
634639 & mask -> basic .ip_proto , TCA_FLOWER_UNSPEC ,
635640 sizeof (key -> basic .ip_proto ));
636- fl_set_key_ip (tb , & key -> ip , & mask -> ip );
641+ fl_set_key_ip (tb , false, & key -> ip , & mask -> ip );
637642 }
638643
639644 if (tb [TCA_FLOWER_KEY_IPV4_SRC ] || tb [TCA_FLOWER_KEY_IPV4_DST ]) {
@@ -768,6 +773,8 @@ static int fl_set_key(struct net *net, struct nlattr **tb,
768773 & mask -> enc_tp .dst , TCA_FLOWER_KEY_ENC_UDP_DST_PORT_MASK ,
769774 sizeof (key -> enc_tp .dst ));
770775
776+ fl_set_key_ip (tb , true, & key -> enc_ip , & mask -> enc_ip );
777+
771778 if (tb [TCA_FLOWER_KEY_FLAGS ])
772779 ret = fl_set_key_flags (tb , & key -> control .flags , & mask -> control .flags );
773780
@@ -860,6 +867,8 @@ static void fl_init_dissector(struct fl_flow_mask *mask)
860867 enc_control );
861868 FL_KEY_SET_IF_MASKED (& mask -> key , keys , cnt ,
862869 FLOW_DISSECTOR_KEY_ENC_PORTS , enc_tp );
870+ FL_KEY_SET_IF_MASKED (& mask -> key , keys , cnt ,
871+ FLOW_DISSECTOR_KEY_ENC_IP , enc_ip );
863872
864873 skb_flow_dissector_init (& mask -> dissector , keys , cnt );
865874}
@@ -1208,14 +1217,17 @@ static int fl_dump_key_mpls(struct sk_buff *skb,
12081217 return 0 ;
12091218}
12101219
1211- static int fl_dump_key_ip (struct sk_buff * skb ,
1220+ static int fl_dump_key_ip (struct sk_buff * skb , bool encap ,
12121221 struct flow_dissector_key_ip * key ,
12131222 struct flow_dissector_key_ip * mask )
12141223{
1215- if (fl_dump_key_val (skb , & key -> tos , TCA_FLOWER_KEY_IP_TOS , & mask -> tos ,
1216- TCA_FLOWER_KEY_IP_TOS_MASK , sizeof (key -> tos )) ||
1217- fl_dump_key_val (skb , & key -> ttl , TCA_FLOWER_KEY_IP_TTL , & mask -> ttl ,
1218- TCA_FLOWER_KEY_IP_TTL_MASK , sizeof (key -> ttl )))
1224+ int tos_key = encap ? TCA_FLOWER_KEY_ENC_IP_TOS : TCA_FLOWER_KEY_IP_TOS ;
1225+ int ttl_key = encap ? TCA_FLOWER_KEY_ENC_IP_TTL : TCA_FLOWER_KEY_IP_TTL ;
1226+ int tos_mask = encap ? TCA_FLOWER_KEY_ENC_IP_TOS_MASK : TCA_FLOWER_KEY_IP_TOS_MASK ;
1227+ int ttl_mask = encap ? TCA_FLOWER_KEY_ENC_IP_TTL_MASK : TCA_FLOWER_KEY_IP_TTL_MASK ;
1228+
1229+ if (fl_dump_key_val (skb , & key -> tos , tos_key , & mask -> tos , tos_mask , sizeof (key -> tos )) ||
1230+ fl_dump_key_val (skb , & key -> ttl , ttl_key , & mask -> ttl , ttl_mask , sizeof (key -> ttl )))
12191231 return -1 ;
12201232
12211233 return 0 ;
@@ -1361,7 +1373,7 @@ static int fl_dump(struct net *net, struct tcf_proto *tp, void *fh,
13611373 (fl_dump_key_val (skb , & key -> basic .ip_proto , TCA_FLOWER_KEY_IP_PROTO ,
13621374 & mask -> basic .ip_proto , TCA_FLOWER_UNSPEC ,
13631375 sizeof (key -> basic .ip_proto )) ||
1364- fl_dump_key_ip (skb , & key -> ip , & mask -> ip )))
1376+ fl_dump_key_ip (skb , false, & key -> ip , & mask -> ip )))
13651377 goto nla_put_failure ;
13661378
13671379 if (key -> control .addr_type == FLOW_DISSECTOR_KEY_IPV4_ADDRS &&
@@ -1486,7 +1498,8 @@ static int fl_dump(struct net *net, struct tcf_proto *tp, void *fh,
14861498 TCA_FLOWER_KEY_ENC_UDP_DST_PORT ,
14871499 & mask -> enc_tp .dst ,
14881500 TCA_FLOWER_KEY_ENC_UDP_DST_PORT_MASK ,
1489- sizeof (key -> enc_tp .dst )))
1501+ sizeof (key -> enc_tp .dst )) ||
1502+ fl_dump_key_ip (skb , true, & key -> enc_ip , & mask -> enc_ip ))
14901503 goto nla_put_failure ;
14911504
14921505 if (fl_dump_key_flags (skb , key -> control .flags , mask -> control .flags ))
0 commit comments