On 27 May 2022, at 11:00, Jianbo Liu wrote:

> To reuse the code for manipulating police action, move the common
> initialization code to a function, and change PPS parameters as meter
> pktps is in unit of packet per second.
>
> null_police is redundant because either BPS or PPS, not both, can be
> configured in one message. So the police passed in to
> nl_msg_put_act_police can be reused as its rate is zero for PPS, and
> it also provides the index for police action to be created.

One small comment below, which I guess you missed earlier.

> Signed-off-by: Jianbo Liu <[email protected]>

<SNIP>

> @@ -5648,9 +5650,12 @@ tc_add_policer(struct netdev *netdev, uint32_t 
> kbits_rate,
>      tcmsg->tcm_info = tc_make_handle(49,
>                                       (OVS_FORCE uint16_t) htons(ETH_P_ALL));
>      nl_msg_put_string(&request, TCA_KIND, "basic");
> +
>      basic_offset = nl_msg_start_nested(&request, TCA_OPTIONS);
>      police_offset = nl_msg_start_nested(&request, TCA_BASIC_ACT);
> -    nl_msg_put_act_police(&request, tc_police, kpkts_rate, kpkts_burst);
> +    tc_policer_init(&tc_police, kbits_rate, kbits_burst);
> +    nl_msg_put_act_police(&request, &tc_police, kpkts_rate * 1000,
> +                          kpkts_burst * 1000);

As both kpkts_rate and kpkts_burst are uint32 the result will also be uint32, 
so you need to multiply by 1000ULL. So:

  +    nl_msg_put_act_police(&request, &tc_police, kpkts_rate * 1000ULL,
  +                          kpkts_burst * 1000ULL);

>      nl_msg_end_nested(&request, police_offset);
>      nl_msg_end_nested(&request, basic_offset);
>
> -- 
> 2.26.2

_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to