On 2/19/19, 10:30 AM, "Eric Dumazet" <eric.duma...@gmail.com> wrote:

    
    
    On 02/18/2019 09:38 PM, brakmo wrote:
    > This patch adds a new bpf helper BPF_FUNC_skb_set_ecn
    > "int bpf_skb_set_Ecn(struct sk_buff *skb)". It is added to
    > BPF_PROG_TYPE_CGROUP_SKB typed bpf_prog which currently can
    > be attached to the ingress and egress path. This type of
    > bpf_prog cannot modify the skb directly.
    > 
    > This helper is used to set the ECN bits (2) of the IPv6 or IPv4
    > header in skb. It can be used by a bpf_prog to manage egress
    > network bandwdith limit per cgroupv2 by inducing an ECN
    > response in the TCP sender (when the packet is ECN enabled).
    > This works best when using DCTCP.
    
    
    > +
    > +BPF_CALL_2(bpf_skb_set_ecn, struct sk_buff *, skb, u32, val)
    > +{
    > + struct ipv6hdr *ip6h = ipv6_hdr(skb);
    > +
    > + if ((val & ~0x3) != 0)
    > +         return -EINVAL;
    > +
    > + if (ip6h->version == 6) {
    > +         ip6h->flow_lbl[0] = (ip6h->flow_lbl[0] & ~0x30) | (val << 4);
    > +         return 0;
    > + } else if (ip6h->version == 4) {
    > +         struct iphdr *ip4h = (struct iphdr *)ip6h;
    > +
    > +         ip4h->tos = (ip4h->tos & ~0x3) | val;
    
    Why is not the IPv4 checksum recomputed here ?
    
    If you leave this task to the caller, this should be documented.
    
    These hard coded constants are not really nice.
    
    Why not simply using INET_ECN_set_ce() which is IPv4/IPv6 ready ?
    
    Do you really need to set anything else than CE ?

Good point, thank you. I will use it.
    
    
    

Reply via email to