@@ -621,37 +621,53 @@ static void tx_ft_put_policy(struct mlx5e_ipsec *ipsec, u32 prio)
621
621
static void setup_fte_addr4 (struct mlx5_flow_spec * spec , __be32 * saddr ,
622
622
__be32 * daddr )
623
623
{
624
+ if (!* saddr && !* daddr )
625
+ return ;
626
+
624
627
spec -> match_criteria_enable |= MLX5_MATCH_OUTER_HEADERS ;
625
628
626
629
MLX5_SET_TO_ONES (fte_match_param , spec -> match_criteria , outer_headers .ip_version );
627
630
MLX5_SET (fte_match_param , spec -> match_value , outer_headers .ip_version , 4 );
628
631
629
- memcpy (MLX5_ADDR_OF (fte_match_param , spec -> match_value ,
630
- outer_headers .src_ipv4_src_ipv6 .ipv4_layout .ipv4 ), saddr , 4 );
631
- memcpy (MLX5_ADDR_OF (fte_match_param , spec -> match_value ,
632
- outer_headers .dst_ipv4_dst_ipv6 .ipv4_layout .ipv4 ), daddr , 4 );
633
- MLX5_SET_TO_ONES (fte_match_param , spec -> match_criteria ,
634
- outer_headers .src_ipv4_src_ipv6 .ipv4_layout .ipv4 );
635
- MLX5_SET_TO_ONES (fte_match_param , spec -> match_criteria ,
636
- outer_headers .dst_ipv4_dst_ipv6 .ipv4_layout .ipv4 );
632
+ if (* saddr ) {
633
+ memcpy (MLX5_ADDR_OF (fte_match_param , spec -> match_value ,
634
+ outer_headers .src_ipv4_src_ipv6 .ipv4_layout .ipv4 ), saddr , 4 );
635
+ MLX5_SET_TO_ONES (fte_match_param , spec -> match_criteria ,
636
+ outer_headers .src_ipv4_src_ipv6 .ipv4_layout .ipv4 );
637
+ }
638
+
639
+ if (* daddr ) {
640
+ memcpy (MLX5_ADDR_OF (fte_match_param , spec -> match_value ,
641
+ outer_headers .dst_ipv4_dst_ipv6 .ipv4_layout .ipv4 ), daddr , 4 );
642
+ MLX5_SET_TO_ONES (fte_match_param , spec -> match_criteria ,
643
+ outer_headers .dst_ipv4_dst_ipv6 .ipv4_layout .ipv4 );
644
+ }
637
645
}
638
646
639
647
static void setup_fte_addr6 (struct mlx5_flow_spec * spec , __be32 * saddr ,
640
648
__be32 * daddr )
641
649
{
650
+ if (addr6_all_zero (saddr ) && addr6_all_zero (daddr ))
651
+ return ;
652
+
642
653
spec -> match_criteria_enable |= MLX5_MATCH_OUTER_HEADERS ;
643
654
644
655
MLX5_SET_TO_ONES (fte_match_param , spec -> match_criteria , outer_headers .ip_version );
645
656
MLX5_SET (fte_match_param , spec -> match_value , outer_headers .ip_version , 6 );
646
657
647
- memcpy (MLX5_ADDR_OF (fte_match_param , spec -> match_value ,
648
- outer_headers .src_ipv4_src_ipv6 .ipv6_layout .ipv6 ), saddr , 16 );
649
- memcpy (MLX5_ADDR_OF (fte_match_param , spec -> match_value ,
650
- outer_headers .dst_ipv4_dst_ipv6 .ipv6_layout .ipv6 ), daddr , 16 );
651
- memset (MLX5_ADDR_OF (fte_match_param , spec -> match_criteria ,
652
- outer_headers .src_ipv4_src_ipv6 .ipv6_layout .ipv6 ), 0xff , 16 );
653
- memset (MLX5_ADDR_OF (fte_match_param , spec -> match_criteria ,
654
- outer_headers .dst_ipv4_dst_ipv6 .ipv6_layout .ipv6 ), 0xff , 16 );
658
+ if (!addr6_all_zero (saddr )) {
659
+ memcpy (MLX5_ADDR_OF (fte_match_param , spec -> match_value ,
660
+ outer_headers .src_ipv4_src_ipv6 .ipv6_layout .ipv6 ), saddr , 16 );
661
+ memset (MLX5_ADDR_OF (fte_match_param , spec -> match_criteria ,
662
+ outer_headers .src_ipv4_src_ipv6 .ipv6_layout .ipv6 ), 0xff , 16 );
663
+ }
664
+
665
+ if (!addr6_all_zero (daddr )) {
666
+ memcpy (MLX5_ADDR_OF (fte_match_param , spec -> match_value ,
667
+ outer_headers .dst_ipv4_dst_ipv6 .ipv6_layout .ipv6 ), daddr , 16 );
668
+ memset (MLX5_ADDR_OF (fte_match_param , spec -> match_criteria ,
669
+ outer_headers .dst_ipv4_dst_ipv6 .ipv6_layout .ipv6 ), 0xff , 16 );
670
+ }
655
671
}
656
672
657
673
static void setup_fte_esp (struct mlx5_flow_spec * spec )
@@ -920,7 +936,8 @@ static int tx_add_rule(struct mlx5e_ipsec_sa_entry *sa_entry)
920
936
setup_fte_reg_a (spec );
921
937
break ;
922
938
case XFRM_DEV_OFFLOAD_PACKET :
923
- setup_fte_reg_c0 (spec , attrs -> reqid );
939
+ if (attrs -> reqid )
940
+ setup_fte_reg_c0 (spec , attrs -> reqid );
924
941
err = setup_pkt_reformat (mdev , attrs , & flow_act );
925
942
if (err )
926
943
goto err_pkt_reformat ;
@@ -989,10 +1006,12 @@ static int tx_add_policy(struct mlx5e_ipsec_pol_entry *pol_entry)
989
1006
setup_fte_no_frags (spec );
990
1007
setup_fte_upper_proto_match (spec , & attrs -> upspec );
991
1008
992
- err = setup_modify_header (mdev , attrs -> reqid , XFRM_DEV_OFFLOAD_OUT ,
993
- & flow_act );
994
- if (err )
995
- goto err_mod_header ;
1009
+ if (attrs -> reqid ) {
1010
+ err = setup_modify_header (mdev , attrs -> reqid ,
1011
+ XFRM_DEV_OFFLOAD_OUT , & flow_act );
1012
+ if (err )
1013
+ goto err_mod_header ;
1014
+ }
996
1015
997
1016
switch (attrs -> action ) {
998
1017
case XFRM_POLICY_ALLOW :
@@ -1028,7 +1047,8 @@ static int tx_add_policy(struct mlx5e_ipsec_pol_entry *pol_entry)
1028
1047
return 0 ;
1029
1048
1030
1049
err_action :
1031
- mlx5_modify_header_dealloc (mdev , flow_act .modify_hdr );
1050
+ if (attrs -> reqid )
1051
+ mlx5_modify_header_dealloc (mdev , flow_act .modify_hdr );
1032
1052
err_mod_header :
1033
1053
kvfree (spec );
1034
1054
err_alloc :
@@ -1263,7 +1283,9 @@ void mlx5e_accel_ipsec_fs_del_pol(struct mlx5e_ipsec_pol_entry *pol_entry)
1263
1283
return ;
1264
1284
}
1265
1285
1266
- mlx5_modify_header_dealloc (mdev , ipsec_rule -> modify_hdr );
1286
+ if (ipsec_rule -> modify_hdr )
1287
+ mlx5_modify_header_dealloc (mdev , ipsec_rule -> modify_hdr );
1288
+
1267
1289
tx_ft_put_policy (pol_entry -> ipsec , pol_entry -> attrs .prio );
1268
1290
}
1269
1291
0 commit comments