You need to sign in or sign up before continuing.
  • Martin KaFai Lau's avatar
    bpf: Keep the (rcv) timestamp behavior for the existing tc-bpf@ingress · 7449197d
    Martin KaFai Lau authored
    The current tc-bpf@ingress reads and writes the __sk_buff->tstamp
    as a (rcv) timestamp which currently could either be 0 (not available)
    or ktime_get_real().  This patch is to backward compatible with the
    (rcv) timestamp expectation at ingress.  If the skb->tstamp has
    the delivery_time, the bpf insn rewrite will read 0 for tc-bpf
    running at ingress as it is not available.  When writing at ingress,
    it will also clear the skb->mono_delivery_time bit.
    
    /* BPF_READ: a = __sk_buff->tstamp */
    if (!skb->tc_at_ingress || !skb->mono_delivery_time)
    	a = skb->tstamp;
    else
    	a = 0
    
    /* BPF_WRITE: __sk_buff->tstamp = a */
    if (skb->tc_at_ingress)
    	skb->mono_delivery_time = 0;
    skb->tstamp = a;
    
    [ A note on the BPF_CGROUP_INET_INGRESS which can also access
      skb->tstamp.  At that point, the skb is delivered locally
      and skb_clear_delivery_time() has already been done,
      so the skb->tstamp will only have the (rcv) timestamp. ]
    
    If the tc-bpf@egress writ...
    7449197d
cls_bpf.c 16.9 KB