@@ -2572,17 +2572,20 @@ static int cake_change(struct Qdisc *sch, struct nlattr *opt,
2572
2572
{
2573
2573
struct cake_sched_data * q = qdisc_priv (sch );
2574
2574
struct nlattr * tb [TCA_CAKE_MAX + 1 ];
2575
+ u16 rate_flags ;
2576
+ u8 flow_mode ;
2575
2577
int err ;
2576
2578
2577
2579
err = nla_parse_nested_deprecated (tb , TCA_CAKE_MAX , opt , cake_policy ,
2578
2580
extack );
2579
2581
if (err < 0 )
2580
2582
return err ;
2581
2583
2584
+ flow_mode = q -> flow_mode ;
2582
2585
if (tb [TCA_CAKE_NAT ]) {
2583
2586
#if IS_ENABLED (CONFIG_NF_CONNTRACK )
2584
- q -> flow_mode &= ~CAKE_FLOW_NAT_FLAG ;
2585
- q -> flow_mode |= CAKE_FLOW_NAT_FLAG *
2587
+ flow_mode &= ~CAKE_FLOW_NAT_FLAG ;
2588
+ flow_mode |= CAKE_FLOW_NAT_FLAG *
2586
2589
!!nla_get_u32 (tb [TCA_CAKE_NAT ]);
2587
2590
#else
2588
2591
NL_SET_ERR_MSG_ATTR (extack , tb [TCA_CAKE_NAT ],
@@ -2592,29 +2595,34 @@ static int cake_change(struct Qdisc *sch, struct nlattr *opt,
2592
2595
}
2593
2596
2594
2597
if (tb [TCA_CAKE_BASE_RATE64 ])
2595
- q -> rate_bps = nla_get_u64 (tb [TCA_CAKE_BASE_RATE64 ]);
2598
+ WRITE_ONCE (q -> rate_bps ,
2599
+ nla_get_u64 (tb [TCA_CAKE_BASE_RATE64 ]));
2596
2600
2597
2601
if (tb [TCA_CAKE_DIFFSERV_MODE ])
2598
- q -> tin_mode = nla_get_u32 (tb [TCA_CAKE_DIFFSERV_MODE ]);
2602
+ WRITE_ONCE (q -> tin_mode ,
2603
+ nla_get_u32 (tb [TCA_CAKE_DIFFSERV_MODE ]));
2599
2604
2605
+ rate_flags = q -> rate_flags ;
2600
2606
if (tb [TCA_CAKE_WASH ]) {
2601
2607
if (!!nla_get_u32 (tb [TCA_CAKE_WASH ]))
2602
- q -> rate_flags |= CAKE_FLAG_WASH ;
2608
+ rate_flags |= CAKE_FLAG_WASH ;
2603
2609
else
2604
- q -> rate_flags &= ~CAKE_FLAG_WASH ;
2610
+ rate_flags &= ~CAKE_FLAG_WASH ;
2605
2611
}
2606
2612
2607
2613
if (tb [TCA_CAKE_FLOW_MODE ])
2608
- q -> flow_mode = ((q -> flow_mode & CAKE_FLOW_NAT_FLAG ) |
2614
+ flow_mode = ((flow_mode & CAKE_FLOW_NAT_FLAG ) |
2609
2615
(nla_get_u32 (tb [TCA_CAKE_FLOW_MODE ]) &
2610
2616
CAKE_FLOW_MASK ));
2611
2617
2612
2618
if (tb [TCA_CAKE_ATM ])
2613
- q -> atm_mode = nla_get_u32 (tb [TCA_CAKE_ATM ]);
2619
+ WRITE_ONCE (q -> atm_mode ,
2620
+ nla_get_u32 (tb [TCA_CAKE_ATM ]));
2614
2621
2615
2622
if (tb [TCA_CAKE_OVERHEAD ]) {
2616
- q -> rate_overhead = nla_get_s32 (tb [TCA_CAKE_OVERHEAD ]);
2617
- q -> rate_flags |= CAKE_FLAG_OVERHEAD ;
2623
+ WRITE_ONCE (q -> rate_overhead ,
2624
+ nla_get_s32 (tb [TCA_CAKE_OVERHEAD ]));
2625
+ rate_flags |= CAKE_FLAG_OVERHEAD ;
2618
2626
2619
2627
q -> max_netlen = 0 ;
2620
2628
q -> max_adjlen = 0 ;
@@ -2623,7 +2631,7 @@ static int cake_change(struct Qdisc *sch, struct nlattr *opt,
2623
2631
}
2624
2632
2625
2633
if (tb [TCA_CAKE_RAW ]) {
2626
- q -> rate_flags &= ~CAKE_FLAG_OVERHEAD ;
2634
+ rate_flags &= ~CAKE_FLAG_OVERHEAD ;
2627
2635
2628
2636
q -> max_netlen = 0 ;
2629
2637
q -> max_adjlen = 0 ;
@@ -2632,54 +2640,58 @@ static int cake_change(struct Qdisc *sch, struct nlattr *opt,
2632
2640
}
2633
2641
2634
2642
if (tb [TCA_CAKE_MPU ])
2635
- q -> rate_mpu = nla_get_u32 (tb [TCA_CAKE_MPU ]);
2643
+ WRITE_ONCE (q -> rate_mpu ,
2644
+ nla_get_u32 (tb [TCA_CAKE_MPU ]));
2636
2645
2637
2646
if (tb [TCA_CAKE_RTT ]) {
2638
- q -> interval = nla_get_u32 (tb [TCA_CAKE_RTT ]);
2647
+ u32 interval = nla_get_u32 (tb [TCA_CAKE_RTT ]);
2639
2648
2640
- if (!q -> interval )
2641
- q -> interval = 1 ;
2649
+ WRITE_ONCE (q -> interval , max (interval , 1U ));
2642
2650
}
2643
2651
2644
2652
if (tb [TCA_CAKE_TARGET ]) {
2645
- q -> target = nla_get_u32 (tb [TCA_CAKE_TARGET ]);
2653
+ u32 target = nla_get_u32 (tb [TCA_CAKE_TARGET ]);
2646
2654
2647
- if (!q -> target )
2648
- q -> target = 1 ;
2655
+ WRITE_ONCE (q -> target , max (target , 1U ));
2649
2656
}
2650
2657
2651
2658
if (tb [TCA_CAKE_AUTORATE ]) {
2652
2659
if (!!nla_get_u32 (tb [TCA_CAKE_AUTORATE ]))
2653
- q -> rate_flags |= CAKE_FLAG_AUTORATE_INGRESS ;
2660
+ rate_flags |= CAKE_FLAG_AUTORATE_INGRESS ;
2654
2661
else
2655
- q -> rate_flags &= ~CAKE_FLAG_AUTORATE_INGRESS ;
2662
+ rate_flags &= ~CAKE_FLAG_AUTORATE_INGRESS ;
2656
2663
}
2657
2664
2658
2665
if (tb [TCA_CAKE_INGRESS ]) {
2659
2666
if (!!nla_get_u32 (tb [TCA_CAKE_INGRESS ]))
2660
- q -> rate_flags |= CAKE_FLAG_INGRESS ;
2667
+ rate_flags |= CAKE_FLAG_INGRESS ;
2661
2668
else
2662
- q -> rate_flags &= ~CAKE_FLAG_INGRESS ;
2669
+ rate_flags &= ~CAKE_FLAG_INGRESS ;
2663
2670
}
2664
2671
2665
2672
if (tb [TCA_CAKE_ACK_FILTER ])
2666
- q -> ack_filter = nla_get_u32 (tb [TCA_CAKE_ACK_FILTER ]);
2673
+ WRITE_ONCE (q -> ack_filter ,
2674
+ nla_get_u32 (tb [TCA_CAKE_ACK_FILTER ]));
2667
2675
2668
2676
if (tb [TCA_CAKE_MEMORY ])
2669
- q -> buffer_config_limit = nla_get_u32 (tb [TCA_CAKE_MEMORY ]);
2677
+ WRITE_ONCE (q -> buffer_config_limit ,
2678
+ nla_get_u32 (tb [TCA_CAKE_MEMORY ]));
2670
2679
2671
2680
if (tb [TCA_CAKE_SPLIT_GSO ]) {
2672
2681
if (!!nla_get_u32 (tb [TCA_CAKE_SPLIT_GSO ]))
2673
- q -> rate_flags |= CAKE_FLAG_SPLIT_GSO ;
2682
+ rate_flags |= CAKE_FLAG_SPLIT_GSO ;
2674
2683
else
2675
- q -> rate_flags &= ~CAKE_FLAG_SPLIT_GSO ;
2684
+ rate_flags &= ~CAKE_FLAG_SPLIT_GSO ;
2676
2685
}
2677
2686
2678
2687
if (tb [TCA_CAKE_FWMARK ]) {
2679
- q -> fwmark_mask = nla_get_u32 (tb [TCA_CAKE_FWMARK ]);
2680
- q -> fwmark_shft = q -> fwmark_mask ? __ffs (q -> fwmark_mask ) : 0 ;
2688
+ WRITE_ONCE (q -> fwmark_mask , nla_get_u32 (tb [TCA_CAKE_FWMARK ]));
2689
+ WRITE_ONCE (q -> fwmark_shft ,
2690
+ q -> fwmark_mask ? __ffs (q -> fwmark_mask ) : 0 );
2681
2691
}
2682
2692
2693
+ WRITE_ONCE (q -> rate_flags , rate_flags );
2694
+ WRITE_ONCE (q -> flow_mode , flow_mode );
2683
2695
if (q -> tins ) {
2684
2696
sch_tree_lock (sch );
2685
2697
cake_reconfigure (sch );
@@ -2774,68 +2786,72 @@ static int cake_dump(struct Qdisc *sch, struct sk_buff *skb)
2774
2786
{
2775
2787
struct cake_sched_data * q = qdisc_priv (sch );
2776
2788
struct nlattr * opts ;
2789
+ u16 rate_flags ;
2790
+ u8 flow_mode ;
2777
2791
2778
2792
opts = nla_nest_start_noflag (skb , TCA_OPTIONS );
2779
2793
if (!opts )
2780
2794
goto nla_put_failure ;
2781
2795
2782
- if (nla_put_u64_64bit (skb , TCA_CAKE_BASE_RATE64 , q -> rate_bps ,
2783
- TCA_CAKE_PAD ))
2796
+ if (nla_put_u64_64bit (skb , TCA_CAKE_BASE_RATE64 ,
2797
+ READ_ONCE ( q -> rate_bps ), TCA_CAKE_PAD ))
2784
2798
goto nla_put_failure ;
2785
2799
2786
- if ( nla_put_u32 ( skb , TCA_CAKE_FLOW_MODE ,
2787
- q -> flow_mode & CAKE_FLOW_MASK ))
2800
+ flow_mode = READ_ONCE ( q -> flow_mode );
2801
+ if ( nla_put_u32 ( skb , TCA_CAKE_FLOW_MODE , flow_mode & CAKE_FLOW_MASK ))
2788
2802
goto nla_put_failure ;
2789
2803
2790
- if (nla_put_u32 (skb , TCA_CAKE_RTT , q -> interval ))
2804
+ if (nla_put_u32 (skb , TCA_CAKE_RTT , READ_ONCE ( q -> interval ) ))
2791
2805
goto nla_put_failure ;
2792
2806
2793
- if (nla_put_u32 (skb , TCA_CAKE_TARGET , q -> target ))
2807
+ if (nla_put_u32 (skb , TCA_CAKE_TARGET , READ_ONCE ( q -> target ) ))
2794
2808
goto nla_put_failure ;
2795
2809
2796
- if (nla_put_u32 (skb , TCA_CAKE_MEMORY , q -> buffer_config_limit ))
2810
+ if (nla_put_u32 (skb , TCA_CAKE_MEMORY ,
2811
+ READ_ONCE (q -> buffer_config_limit )))
2797
2812
goto nla_put_failure ;
2798
2813
2814
+ rate_flags = READ_ONCE (q -> rate_flags );
2799
2815
if (nla_put_u32 (skb , TCA_CAKE_AUTORATE ,
2800
- !!(q -> rate_flags & CAKE_FLAG_AUTORATE_INGRESS )))
2816
+ !!(rate_flags & CAKE_FLAG_AUTORATE_INGRESS )))
2801
2817
goto nla_put_failure ;
2802
2818
2803
2819
if (nla_put_u32 (skb , TCA_CAKE_INGRESS ,
2804
- !!(q -> rate_flags & CAKE_FLAG_INGRESS )))
2820
+ !!(rate_flags & CAKE_FLAG_INGRESS )))
2805
2821
goto nla_put_failure ;
2806
2822
2807
- if (nla_put_u32 (skb , TCA_CAKE_ACK_FILTER , q -> ack_filter ))
2823
+ if (nla_put_u32 (skb , TCA_CAKE_ACK_FILTER , READ_ONCE ( q -> ack_filter ) ))
2808
2824
goto nla_put_failure ;
2809
2825
2810
2826
if (nla_put_u32 (skb , TCA_CAKE_NAT ,
2811
- !!(q -> flow_mode & CAKE_FLOW_NAT_FLAG )))
2827
+ !!(flow_mode & CAKE_FLOW_NAT_FLAG )))
2812
2828
goto nla_put_failure ;
2813
2829
2814
- if (nla_put_u32 (skb , TCA_CAKE_DIFFSERV_MODE , q -> tin_mode ))
2830
+ if (nla_put_u32 (skb , TCA_CAKE_DIFFSERV_MODE , READ_ONCE ( q -> tin_mode ) ))
2815
2831
goto nla_put_failure ;
2816
2832
2817
2833
if (nla_put_u32 (skb , TCA_CAKE_WASH ,
2818
- !!(q -> rate_flags & CAKE_FLAG_WASH )))
2834
+ !!(rate_flags & CAKE_FLAG_WASH )))
2819
2835
goto nla_put_failure ;
2820
2836
2821
- if (nla_put_u32 (skb , TCA_CAKE_OVERHEAD , q -> rate_overhead ))
2837
+ if (nla_put_u32 (skb , TCA_CAKE_OVERHEAD , READ_ONCE ( q -> rate_overhead ) ))
2822
2838
goto nla_put_failure ;
2823
2839
2824
- if (!(q -> rate_flags & CAKE_FLAG_OVERHEAD ))
2840
+ if (!(rate_flags & CAKE_FLAG_OVERHEAD ))
2825
2841
if (nla_put_u32 (skb , TCA_CAKE_RAW , 0 ))
2826
2842
goto nla_put_failure ;
2827
2843
2828
- if (nla_put_u32 (skb , TCA_CAKE_ATM , q -> atm_mode ))
2844
+ if (nla_put_u32 (skb , TCA_CAKE_ATM , READ_ONCE ( q -> atm_mode ) ))
2829
2845
goto nla_put_failure ;
2830
2846
2831
- if (nla_put_u32 (skb , TCA_CAKE_MPU , q -> rate_mpu ))
2847
+ if (nla_put_u32 (skb , TCA_CAKE_MPU , READ_ONCE ( q -> rate_mpu ) ))
2832
2848
goto nla_put_failure ;
2833
2849
2834
2850
if (nla_put_u32 (skb , TCA_CAKE_SPLIT_GSO ,
2835
- !!(q -> rate_flags & CAKE_FLAG_SPLIT_GSO )))
2851
+ !!(rate_flags & CAKE_FLAG_SPLIT_GSO )))
2836
2852
goto nla_put_failure ;
2837
2853
2838
- if (nla_put_u32 (skb , TCA_CAKE_FWMARK , q -> fwmark_mask ))
2854
+ if (nla_put_u32 (skb , TCA_CAKE_FWMARK , READ_ONCE ( q -> fwmark_mask ) ))
2839
2855
goto nla_put_failure ;
2840
2856
2841
2857
return nla_nest_end (skb , opts );
0 commit comments