@@ -548,12 +548,10 @@ static CALI_BPF_INLINE void calico_tc_process_ct_lookup(struct cali_tc_ctx *ctx)
548548 ctx -> state -> flags |= CALI_ST_NAT_OUTGOING ;
549549 }
550550 }
551- // Check if traffic is leaving cluster. It might need to set DSCP.
552- if (cali_rt_flags_is_in_pool (r -> flags )) {
553- if (rt_addr_is_external (& ctx -> state -> post_nat_ip_dst )) {
554- CALI_DEBUG ("Outside cluster dest " IP_FMT "" , debug_ip (ctx -> state -> post_nat_ip_dst ));
555- ctx -> state -> flags |= CALI_ST_CLUSTER_EXTERNAL ;
556- }
551+ // Check if traffic is leaving cluster. We might need to set DSCP later.
552+ if (cali_rt_flags_is_in_pool (r -> flags ) && rt_addr_is_external (& ctx -> state -> post_nat_ip_dst )) {
553+ CALI_DEBUG ("Outside cluster dest " IP_FMT "" , debug_ip (ctx -> state -> post_nat_ip_dst ));
554+ ctx -> state -> flags |= CALI_ST_CLUSTER_EXTERNAL ;
557555 }
558556 /* If 3rd party CNI is used and dest is outside cluster. See commit fc711b192f for details. */
559557 if (!(cali_rt_flags_is_in_pool (r -> flags ))) {
@@ -565,25 +563,16 @@ static CALI_BPF_INLINE void calico_tc_process_ct_lookup(struct cali_tc_ctx *ctx)
565563 }
566564 }
567565
568- // If either destination is outside cluster, set flag as might need to update DSCP later.
569- if (CALI_F_TO_HEP ) {
570- struct cali_rt * r = cali_rt_lookup (& ctx -> state -> ip_src );
571- if (r && cali_rt_flags_host (r -> flags )) {
572- if (rt_addr_is_external (& ctx -> state -> post_nat_ip_dst )) {
573- CALI_DEBUG ("Outside cluster dest " IP_FMT "" , debug_ip (ctx -> state -> post_nat_ip_dst ));
574- ctx -> state -> flags |= CALI_ST_CLUSTER_EXTERNAL ;
575- }
576- }
566+ // If either source or destination is outside cluster, set flag as might need to update DSCP later.
567+ if ((CALI_F_TO_HEP ) && (rt_addr_is_local_host (& ctx -> state -> ip_src )) &&
568+ (rt_addr_is_external (& ctx -> state -> post_nat_ip_dst ))) {
569+ CALI_DEBUG ("Outside cluster dest " IP_FMT "" , debug_ip (ctx -> state -> post_nat_ip_dst ));
570+ ctx -> state -> flags |= CALI_ST_CLUSTER_EXTERNAL ;
577571 }
578- // If source is outside cluster, set flag as might need to update DSCP later.
579- if (CALI_F_FROM_HEP ) {
580- struct cali_rt * r = cali_rt_lookup (& ctx -> state -> post_nat_ip_dst );
581- if (r && (cali_rt_flags_host (r -> flags ) || cali_rt_flags_is_in_pool (r -> flags ))) {
582- if (rt_addr_is_external (& ctx -> state -> ip_src )) {
583- CALI_DEBUG ("Outside cluster source " IP_FMT "" , debug_ip (ctx -> state -> ip_src ));
584- ctx -> state -> flags |= CALI_ST_CLUSTER_EXTERNAL ;
585- }
586- }
572+ if ((CALI_F_FROM_HEP ) && (rt_addr_is_host_or_in_pool (& ctx -> state -> post_nat_ip_dst )) &&
573+ (rt_addr_is_external (& ctx -> state -> ip_src ))) {
574+ CALI_DEBUG ("Outside cluster source " IP_FMT "" , debug_ip (ctx -> state -> ip_src ));
575+ ctx -> state -> flags |= CALI_ST_CLUSTER_EXTERNAL ;
587576 }
588577
589578 /* [SMC] I had to add this revalidation when refactoring the conntrack code to use the context and
@@ -1357,7 +1346,7 @@ int calico_tc_skb_accepted_entrypoint(struct __sk_buff *skb)
13571346 deny_reason (ctx , CALI_REASON_DROPPED_BY_QOS );
13581347 goto deny ;
13591348 }
1360- if ((CALI_F_FROM_WEP || CALI_F_TO_HEP ) && qos_dscp_need_update (ctx ) && !qos_dscp_set (ctx )) {
1349+ if ((CALI_F_FROM_WEP || CALI_F_TO_HEP ) && qos_dscp_needs_update (ctx ) && !qos_dscp_set (ctx )) {
13611350 goto deny ;
13621351 }
13631352 ctx -> fwd = calico_tc_skb_accepted (ctx );
0 commit comments