This patch is to simplify the uapi bpf.h regarding to the tstamp type and use a similar way as the kernel to describe the value stored in __sk_buff->tstamp. My earlier thought was to avoid describing the semantic and clock base for the rcv timestamp until there is more clarity on the use case, so the __sk_buff->delivery_time_type naming instead of __sk_buff->tstamp_type. With some thoughts, it can reuse the UNSPEC naming. This patch first removes BPF_SKB_DELIVERY_TIME_NONE and also rename BPF_SKB_DELIVERY_TIME_UNSPEC to BPF_SKB_TSTAMP_UNSPEC and BPF_SKB_DELIVERY_TIME_MONO to BPF_SKB_TSTAMP_DELIVERY_MONO. The semantic of BPF_SKB_TSTAMP_DELIVERY_MONO is the same: __sk_buff->tstamp has delivery time in mono clock base. BPF_SKB_TSTAMP_UNSPEC means __sk_buff->tstamp has the (rcv) tstamp at ingress and the delivery time at egress. At egress, the clock base could be found from skb->sk->sk_clockid. __sk_buff->tstamp == 0 naturally means NONE, so NONE is not needed. With BPF_SKB_TSTAMP_UNSPEC for the rcv tstamp at ingress, the __sk_buff->delivery_time_type is also renamed to __sk_buff->tstamp_type which was also suggested in the earlier discussion: https://lore.kernel.org/bpf/b181acbe-caf8-502d-4b7b-7d96b9fc5d55@iogearbox.net/ The above will then make __sk_buff->tstamp and __sk_buff->tstamp_type the same as its kernel skb->tstamp and skb->mono_delivery_time counter part. The internal kernel function bpf_skb_convert_dtime_type_read() is then renamed to bpf_skb_convert_tstamp_type_read() and it can be simplified with the BPF_SKB_DELIVERY_TIME_NONE gone. A BPF_ALU32_IMM(BPF_AND) insn is also saved by using BPF_JMP32_IMM(BPF_JSET). The bpf helper bpf_skb_set_delivery_time() is also renamed to bpf_skb_set_tstamp(). The arg name is changed from dtime to tstamp also. It only allows setting tstamp 0 for BPF_SKB_TSTAMP_UNSPEC and it could be relaxed later if there is use case to change mono delivery time to non mono. prog->delivery_time_access is also renamed to prog->tstamp_type_access.
Unified · Split
| @@ -573,7 +573,7 @@ struct bpf_prog { · 572 unmodified lines | ||
| 573 | 573 | enforce_expected_attach_type:1, /* Enforce expected_attach_type checking at attach time */ |
| 574 | 574 | call_get_stack:1, /* Do we call bpf_get_stack() or bpf_get_stackid() */ |
| 575 | 575 | call_get_func_ip:1, /* Do we call get_func_ip() */ |
| 576 | − delivery_time_access:1; /* Accessed __sk_buff->delivery_time_type */ | |
| 576 | + tstamp_type_access:1; /* Accessed __sk_buff->tstamp_type */ | |
| 577 | 577 | enum bpf_prog_type type; /* Type of BPF program */ |
| 578 | 578 | enum bpf_attach_type expected_attach_type; /* For some prog types */ |
| 579 | 579 | u32 len; /* Number of filter blocks */ |
| @@ -5090,23 +5090,22 @@ union bpf_attr { · 5089 unmodified lines | ||
| 5090 | 5090 | * 0 on success, or a negative error in case of failure. On error |
| 5091 | 5091 | * *dst* buffer is zeroed out. |
| 5092 | 5092 | * |
| 5093 | − * long bpf_skb_set_delivery_time(struct sk_buff *skb, u64 dtime, u32 dtime_type) | |
| 5093 | + * long bpf_skb_set_tstamp(struct sk_buff *skb, u64 tstamp, u32 tstamp_type) | |
| 5094 | 5094 | * Description |
| 5095 | − * Set a *dtime* (delivery time) to the __sk_buff->tstamp and also | |
| 5096 | − * change the __sk_buff->delivery_time_type to *dtime_type*. | |
| 5095 | + * Change the __sk_buff->tstamp_type to *tstamp_type* | |
| 5096 | + * and set *tstamp* to the __sk_buff->tstamp together. | |
| 5097 | 5097 | * |
| 5098 | − * When setting a delivery time (non zero *dtime*) to | |
| 5099 | − * __sk_buff->tstamp, only BPF_SKB_DELIVERY_TIME_MONO *dtime_type* | |
| 5100 | − * is supported. It is the only delivery_time_type that will be | |
| 5101 | − * kept after bpf_redirect_*(). | |
| 5102 | − * | |
| 5103 | − * If there is no need to change the __sk_buff->delivery_time_type, | |
| 5104 | − * the delivery time can be directly written to __sk_buff->tstamp | |
| 5098 | + * If there is no need to change the __sk_buff->tstamp_type, | |
| 5099 | + * the tstamp value can be directly written to __sk_buff->tstamp | |
| 5105 | 5100 | * instead. |
| 5106 | 5101 | * |
| 5107 | − * *dtime* 0 and *dtime_type* BPF_SKB_DELIVERY_TIME_NONE | |
| 5108 | − * can be used to clear any delivery time stored in | |
| 5109 | − * __sk_buff->tstamp. | |
| 5102 | + * BPF_SKB_TSTAMP_DELIVERY_MONO is the only tstamp that | |
| 5103 | + * will be kept during bpf_redirect_*(). A non zero | |
| 5104 | + * *tstamp* must be used with the BPF_SKB_TSTAMP_DELIVERY_MONO | |
| 5105 | + * *tstamp_type*. | |
| 5106 | + * | |
| 5107 | + * A BPF_SKB_TSTAMP_UNSPEC *tstamp_type* can only be used | |
| 5108 | + * with a zero *tstamp*. | |
| 5110 | 5109 | * |
| 5111 | 5110 | * Only IPv4 and IPv6 skb->protocol are supported. |
| 5112 | 5111 | * |
| @@ -5119,7 +5118,7 @@ union bpf_attr { · 6 unmodified lines | ||
| 5119 | 5118 | * Return |
| 5120 | 5119 | * 0 on success. |
| 5121 | 5120 | * **-EINVAL** for invalid input |
| 5122 | − * **-EOPNOTSUPP** for unsupported delivery_time_type and protocol | |
| 5121 | + * **-EOPNOTSUPP** for unsupported protocol | |
| 5123 | 5122 | */ |
| 5124 | 5123 | #define __BPF_FUNC_MAPPER(FN) \ |
| 5125 | 5124 | FN(unspec), \ |
| @@ -5314,7 +5313,7 @@ union bpf_attr { · 188 unmodified lines | ||
| 5314 | 5313 | FN(xdp_load_bytes), \ |
| 5315 | 5314 | FN(xdp_store_bytes), \ |
| 5316 | 5315 | FN(copy_from_user_task), \ |
| 5317 | − FN(skb_set_delivery_time), \ | |
| 5316 | + FN(skb_set_tstamp), \ | |
| 5318 | 5317 | /* */ |
| 5319 | 5318 | |
| 5320 | 5319 | /* integer value in 'imm' field of BPF_CALL instruction selects which helper |
| @@ -5505,9 +5504,12 @@ union { \ · 184 unmodified lines | ||
| 5505 | 5504 | } __attribute__((aligned(8))) |
| 5506 | 5505 | |
| 5507 | 5506 | enum { |
| 5508 | − BPF_SKB_DELIVERY_TIME_NONE, | |
| 5509 | − BPF_SKB_DELIVERY_TIME_UNSPEC, | |
| 5510 | − BPF_SKB_DELIVERY_TIME_MONO, | |
| 5507 | + BPF_SKB_TSTAMP_UNSPEC, | |
| 5508 | + BPF_SKB_TSTAMP_DELIVERY_MONO, /* tstamp has mono delivery time */ | |
| 5509 | + /* For any BPF_SKB_TSTAMP_* that the bpf prog cannot handle, | |
| 5510 | + * the bpf prog should handle it like BPF_SKB_TSTAMP_UNSPEC | |
| 5511 | + * and try to deduce it by ingress, egress or skb->sk->sk_clockid. | |
| 5512 | + */ | |
| 5511 | 5513 | }; |
| 5512 | 5514 | |
| 5513 | 5515 | /* user accessible mirror of in-kernel sk_buff. |
| @@ -5550,7 +5552,7 @@ struct __sk_buff { · 36 unmodified lines | ||
| 5550 | 5552 | __u32 gso_segs; |
| 5551 | 5553 | __bpf_md_ptr(struct bpf_sock *, sk); |
| 5552 | 5554 | __u32 gso_size; |
| 5553 | − __u8 delivery_time_type; | |
| 5555 | + __u8 tstamp_type; | |
| 5554 | 5556 | __u32 :24; /* Padding, future use. */ |
| 5555 | 5557 | __u64 hwtstamp; |
| 5556 | 5558 | }; |
| @@ -7388,36 +7388,36 @@ static const struct bpf_func_proto bpf_sock_ops_reserve_hdr_opt_proto = { · 7387 unmodified lines | ||
| 7388 | 7388 | .arg3_type = ARG_ANYTHING, |
| 7389 | 7389 | }; |
| 7390 | 7390 | |
| 7391 | −BPF_CALL_3(bpf_skb_set_delivery_time, struct sk_buff *, skb, | |
| 7392 | − u64, dtime, u32, dtime_type) | |
| 7391 | +BPF_CALL_3(bpf_skb_set_tstamp, struct sk_buff *, skb, | |
| 7392 | + u64, tstamp, u32, tstamp_type) | |
| 7393 | 7393 | { |
| 7394 | 7394 | /* skb_clear_delivery_time() is done for inet protocol */ |
| 7395 | 7395 | if (skb->protocol != htons(ETH_P_IP) && |
| 7396 | 7396 | skb->protocol != htons(ETH_P_IPV6)) |
| 7397 | 7397 | return -EOPNOTSUPP; |
| 7398 | 7398 | |
| 7399 | − switch (dtime_type) { | |
| 7400 | − case BPF_SKB_DELIVERY_TIME_MONO: | |
| 7401 | − if (!dtime) | |
| 7399 | + switch (tstamp_type) { | |
| 7400 | + case BPF_SKB_TSTAMP_DELIVERY_MONO: | |
| 7401 | + if (!tstamp) | |
| 7402 | 7402 | return -EINVAL; |
| 7403 | − skb->tstamp = dtime; | |
| 7403 | + skb->tstamp = tstamp; | |
| 7404 | 7404 | skb->mono_delivery_time = 1; |
| 7405 | 7405 | break; |
| 7406 | − case BPF_SKB_DELIVERY_TIME_NONE: | |
| 7407 | − if (dtime) | |
| 7406 | + case BPF_SKB_TSTAMP_UNSPEC: | |
| 7407 | + if (tstamp) | |
| 7408 | 7408 | return -EINVAL; |
| 7409 | 7409 | skb->tstamp = 0; |
| 7410 | 7410 | skb->mono_delivery_time = 0; |
| 7411 | 7411 | break; |
| 7412 | 7412 | default: |
| 7413 | − return -EOPNOTSUPP; | |
| 7413 | + return -EINVAL; | |
| 7414 | 7414 | } |
| 7415 | 7415 | |
| 7416 | 7416 | return 0; |
| 7417 | 7417 | } |
| 7418 | 7418 | |
| 7419 | −static const struct bpf_func_proto bpf_skb_set_delivery_time_proto = { | |
| 7420 | − .func = bpf_skb_set_delivery_time, | |
| 7419 | +static const struct bpf_func_proto bpf_skb_set_tstamp_proto = { | |
| 7420 | + .func = bpf_skb_set_tstamp, | |
| 7421 | 7421 | .gpl_only = false, |
| 7422 | 7422 | .ret_type = RET_INTEGER, |
| 7423 | 7423 | .arg1_type = ARG_PTR_TO_CTX, |
| @@ -7786,8 +7786,8 @@ tc_cls_act_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog) · 362 unmodified lines | ||
| 7786 | 7786 | return &bpf_tcp_gen_syncookie_proto; |
| 7787 | 7787 | case BPF_FUNC_sk_assign: |
| 7788 | 7788 | return &bpf_sk_assign_proto; |
| 7789 | − case BPF_FUNC_skb_set_delivery_time: | |
| 7790 | − return &bpf_skb_set_delivery_time_proto; | |
| 7789 | + case BPF_FUNC_skb_set_tstamp: | |
| 7790 | + return &bpf_skb_set_tstamp_proto; | |
| 7791 | 7791 | #endif |
| 7792 | 7792 | default: |
| 7793 | 7793 | return bpf_sk_base_func_proto(func_id); |
| @@ -8127,9 +8127,9 @@ static bool bpf_skb_is_valid_access(int off, int size, enum bpf_access_type type · 333 unmodified lines | ||
| 8127 | 8127 | return false; |
| 8128 | 8128 | info->reg_type = PTR_TO_SOCK_COMMON_OR_NULL; |
| 8129 | 8129 | break; |
| 8130 | − case offsetof(struct __sk_buff, delivery_time_type): | |
| 8130 | + case offsetof(struct __sk_buff, tstamp_type): | |
| 8131 | 8131 | return false; |
| 8132 | − case offsetofend(struct __sk_buff, delivery_time_type) ... offsetof(struct __sk_buff, hwtstamp) - 1: | |
| 8132 | + case offsetofend(struct __sk_buff, tstamp_type) ... offsetof(struct __sk_buff, hwtstamp) - 1: | |
| 8133 | 8133 | /* Explicitly prohibit access to padding in __sk_buff. */ |
| 8134 | 8134 | return false; |
| 8135 | 8135 | default: |
| @@ -8484,14 +8484,14 @@ static bool tc_cls_act_is_valid_access(int off, int size, · 348 unmodified lines | ||
| 8484 | 8484 | break; |
| 8485 | 8485 | case bpf_ctx_range_till(struct __sk_buff, family, local_port): |
| 8486 | 8486 | return false; |
| 8487 | − case offsetof(struct __sk_buff, delivery_time_type): | |
| 8487 | + case offsetof(struct __sk_buff, tstamp_type): | |
| 8488 | 8488 | /* The convert_ctx_access() on reading and writing |
| 8489 | 8489 | * __sk_buff->tstamp depends on whether the bpf prog |
| 8490 | − * has used __sk_buff->delivery_time_type or not. | |
| 8491 | − * Thus, we need to set prog->delivery_time_access | |
| 8490 | + * has used __sk_buff->tstamp_type or not. | |
| 8491 | + * Thus, we need to set prog->tstamp_type_access | |
| 8492 | 8492 | * earlier during is_valid_access() here. |
| 8493 | 8493 | */ |
| 8494 | − ((struct bpf_prog *)prog)->delivery_time_access = 1; | |
| 8494 | + ((struct bpf_prog *)prog)->tstamp_type_access = 1; | |
| 8495 | 8495 | return size == sizeof(__u8); |
| 8496 | 8496 | } |
| 8497 | 8497 | |
| @@ -8888,42 +8888,22 @@ static u32 flow_dissector_convert_ctx_access(enum bpf_access_type type, · 390 unmodified lines | ||
| 8888 | 8888 | return insn - insn_buf; |
| 8889 | 8889 | } |
| 8890 | 8890 | |
| 8891 | −static struct bpf_insn *bpf_convert_dtime_type_read(const struct bpf_insn *si, | |
| 8892 | − struct bpf_insn *insn) | |
| 8891 | +static struct bpf_insn *bpf_convert_tstamp_type_read(const struct bpf_insn *si, | |
| 8892 | + struct bpf_insn *insn) | |
| 8893 | 8893 | { |
| 8894 | 8894 | __u8 value_reg = si->dst_reg; |
| 8895 | 8895 | __u8 skb_reg = si->src_reg; |
| 8896 | + /* AX is needed because src_reg and dst_reg could be the same */ | |
| 8896 | 8897 | __u8 tmp_reg = BPF_REG_AX; |
| 8897 | 8898 | |
| 8898 | 8899 | *insn++ = BPF_LDX_MEM(BPF_B, tmp_reg, skb_reg, |
| 8899 | 8900 | PKT_VLAN_PRESENT_OFFSET); |
| 8900 | − *insn++ = BPF_ALU32_IMM(BPF_AND, tmp_reg, | |
| 8901 | − SKB_MONO_DELIVERY_TIME_MASK); | |
| 8902 | − *insn++ = BPF_JMP32_IMM(BPF_JEQ, tmp_reg, 0, 2); | |
| 8903 | − /* value_reg = BPF_SKB_DELIVERY_TIME_MONO */ | |
| 8904 | − *insn++ = BPF_MOV32_IMM(value_reg, BPF_SKB_DELIVERY_TIME_MONO); | |
| 8905 | − *insn++ = BPF_JMP_A(IS_ENABLED(CONFIG_NET_CLS_ACT) ? 10 : 5); | |
| 8906 | − | |
| 8907 | − *insn++ = BPF_LDX_MEM(BPF_DW, tmp_reg, skb_reg, | |
| 8908 | − offsetof(struct sk_buff, tstamp)); | |
| 8909 | − *insn++ = BPF_JMP_IMM(BPF_JNE, tmp_reg, 0, 2); | |
| 8910 | − /* value_reg = BPF_SKB_DELIVERY_TIME_NONE */ | |
| 8911 | − *insn++ = BPF_MOV32_IMM(value_reg, BPF_SKB_DELIVERY_TIME_NONE); | |
| 8912 | − *insn++ = BPF_JMP_A(IS_ENABLED(CONFIG_NET_CLS_ACT) ? 6 : 1); | |
| 8913 | − | |
| 8914 | −#ifdef CONFIG_NET_CLS_ACT | |
| 8915 | − *insn++ = BPF_LDX_MEM(BPF_B, tmp_reg, skb_reg, PKT_VLAN_PRESENT_OFFSET); | |
| 8916 | − *insn++ = BPF_ALU32_IMM(BPF_AND, tmp_reg, TC_AT_INGRESS_MASK); | |
| 8917 | − *insn++ = BPF_JMP32_IMM(BPF_JEQ, tmp_reg, 0, 2); | |
| 8918 | − /* At ingress, value_reg = 0 */ | |
| 8919 | − *insn++ = BPF_MOV32_IMM(value_reg, 0); | |
| 8901 | + *insn++ = BPF_JMP32_IMM(BPF_JSET, tmp_reg, | |
| 8902 | + SKB_MONO_DELIVERY_TIME_MASK, 2); | |
| 8903 | + *insn++ = BPF_MOV32_IMM(value_reg, BPF_SKB_TSTAMP_UNSPEC); | |
| 8920 | 8904 | *insn++ = BPF_JMP_A(1); |
| 8921 | −#endif | |
| 8922 | − | |
| 8923 | − /* value_reg = BPF_SKB_DELIVERYT_TIME_UNSPEC */ | |
| 8924 | − *insn++ = BPF_MOV32_IMM(value_reg, BPF_SKB_DELIVERY_TIME_UNSPEC); | |
| 8905 | + *insn++ = BPF_MOV32_IMM(value_reg, BPF_SKB_TSTAMP_DELIVERY_MONO); | |
| 8925 | 8906 | |
| 8926 | − /* 15 insns with CONFIG_NET_CLS_ACT */ | |
| 8927 | 8907 | return insn; |
| 8928 | 8908 | } |
| 8929 | 8909 | |
| @@ -8956,11 +8936,11 @@ static struct bpf_insn *bpf_convert_tstamp_read(const struct bpf_prog *prog, · 26 unmodified lines | ||
| 8956 | 8936 | __u8 skb_reg = si->src_reg; |
| 8957 | 8937 | |
| 8958 | 8938 | #ifdef CONFIG_NET_CLS_ACT |
| 8959 | − /* If the delivery_time_type is read, | |
| 8939 | + /* If the tstamp_type is read, | |
| 8960 | 8940 | * the bpf prog is aware the tstamp could have delivery time. |
| 8961 | − * Thus, read skb->tstamp as is if delivery_time_access is true. | |
| 8941 | + * Thus, read skb->tstamp as is if tstamp_type_access is true. | |
| 8962 | 8942 | */ |
| 8963 | − if (!prog->delivery_time_access) { | |
| 8943 | + if (!prog->tstamp_type_access) { | |
| 8964 | 8944 | /* AX is needed because src_reg and dst_reg could be the same */ |
| 8965 | 8945 | __u8 tmp_reg = BPF_REG_AX; |
| 8966 | 8946 | |
| @@ -8990,13 +8970,13 @@ static struct bpf_insn *bpf_convert_tstamp_write(const struct bpf_prog *prog, · 23 unmodified lines | ||
| 8990 | 8970 | __u8 skb_reg = si->dst_reg; |
| 8991 | 8971 | |
| 8992 | 8972 | #ifdef CONFIG_NET_CLS_ACT |
| 8993 | − /* If the delivery_time_type is read, | |
| 8973 | + /* If the tstamp_type is read, | |
| 8994 | 8974 | * the bpf prog is aware the tstamp could have delivery time. |
| 8995 | − * Thus, write skb->tstamp as is if delivery_time_access is true. | |
| 8975 | + * Thus, write skb->tstamp as is if tstamp_type_access is true. | |
| 8996 | 8976 | * Otherwise, writing at ingress will have to clear the |
| 8997 | 8977 | * mono_delivery_time bit also. |
| 8998 | 8978 | */ |
| 8999 | − if (!prog->delivery_time_access) { | |
| 8979 | + if (!prog->tstamp_type_access) { | |
| 9000 | 8980 | __u8 tmp_reg = BPF_REG_AX; |
| 9001 | 8981 | |
| 9002 | 8982 | *insn++ = BPF_LDX_MEM(BPF_B, tmp_reg, skb_reg, PKT_VLAN_PRESENT_OFFSET); |
| @@ -9329,8 +9309,8 @@ static u32 bpf_convert_ctx_access(enum bpf_access_type type, · 326 unmodified lines | ||
| 9329 | 9309 | insn = bpf_convert_tstamp_read(prog, si, insn); |
| 9330 | 9310 | break; |
| 9331 | 9311 | |
| 9332 | − case offsetof(struct __sk_buff, delivery_time_type): | |
| 9333 | − insn = bpf_convert_dtime_type_read(si, insn); | |
| 9312 | + case offsetof(struct __sk_buff, tstamp_type): | |
| 9313 | + insn = bpf_convert_tstamp_type_read(si, insn); | |
| 9334 | 9314 | break; |
| 9335 | 9315 | |
| 9336 | 9316 | case offsetof(struct __sk_buff, gso_segs): |
| @@ -5090,23 +5090,22 @@ union bpf_attr { · 5089 unmodified lines | ||
| 5090 | 5090 | * 0 on success, or a negative error in case of failure. On error |
| 5091 | 5091 | * *dst* buffer is zeroed out. |
| 5092 | 5092 | * |
| 5093 | − * long bpf_skb_set_delivery_time(struct sk_buff *skb, u64 dtime, u32 dtime_type) | |
| 5093 | + * long bpf_skb_set_tstamp(struct sk_buff *skb, u64 tstamp, u32 tstamp_type) | |
| 5094 | 5094 | * Description |
| 5095 | − * Set a *dtime* (delivery time) to the __sk_buff->tstamp and also | |
| 5096 | − * change the __sk_buff->delivery_time_type to *dtime_type*. | |
| 5095 | + * Change the __sk_buff->tstamp_type to *tstamp_type* | |
| 5096 | + * and set *tstamp* to the __sk_buff->tstamp together. | |
| 5097 | 5097 | * |
| 5098 | − * When setting a delivery time (non zero *dtime*) to | |
| 5099 | − * __sk_buff->tstamp, only BPF_SKB_DELIVERY_TIME_MONO *dtime_type* | |
| 5100 | − * is supported. It is the only delivery_time_type that will be | |
| 5101 | − * kept after bpf_redirect_*(). | |
| 5102 | − * | |
| 5103 | − * If there is no need to change the __sk_buff->delivery_time_type, | |
| 5104 | − * the delivery time can be directly written to __sk_buff->tstamp | |
| 5098 | + * If there is no need to change the __sk_buff->tstamp_type, | |
| 5099 | + * the tstamp value can be directly written to __sk_buff->tstamp | |
| 5105 | 5100 | * instead. |
| 5106 | 5101 | * |
| 5107 | − * *dtime* 0 and *dtime_type* BPF_SKB_DELIVERY_TIME_NONE | |
| 5108 | − * can be used to clear any delivery time stored in | |
| 5109 | − * __sk_buff->tstamp. | |
| 5102 | + * BPF_SKB_TSTAMP_DELIVERY_MONO is the only tstamp that | |
| 5103 | + * will be kept during bpf_redirect_*(). A non zero | |
| 5104 | + * *tstamp* must be used with the BPF_SKB_TSTAMP_DELIVERY_MONO | |
| 5105 | + * *tstamp_type*. | |
| 5106 | + * | |
| 5107 | + * A BPF_SKB_TSTAMP_UNSPEC *tstamp_type* can only be used | |
| 5108 | + * with a zero *tstamp*. | |
| 5110 | 5109 | * |
| 5111 | 5110 | * Only IPv4 and IPv6 skb->protocol are supported. |
| 5112 | 5111 | * |
| @@ -5119,7 +5118,7 @@ union bpf_attr { · 6 unmodified lines | ||
| 5119 | 5118 | * Return |
| 5120 | 5119 | * 0 on success. |
| 5121 | 5120 | * **-EINVAL** for invalid input |
| 5122 | − * **-EOPNOTSUPP** for unsupported delivery_time_type and protocol | |
| 5121 | + * **-EOPNOTSUPP** for unsupported protocol | |
| 5123 | 5122 | */ |
| 5124 | 5123 | #define __BPF_FUNC_MAPPER(FN) \ |
| 5125 | 5124 | FN(unspec), \ |
| @@ -5314,7 +5313,7 @@ union bpf_attr { · 188 unmodified lines | ||
| 5314 | 5313 | FN(xdp_load_bytes), \ |
| 5315 | 5314 | FN(xdp_store_bytes), \ |
| 5316 | 5315 | FN(copy_from_user_task), \ |
| 5317 | − FN(skb_set_delivery_time), \ | |
| 5316 | + FN(skb_set_tstamp), \ | |
| 5318 | 5317 | /* */ |
| 5319 | 5318 | |
| 5320 | 5319 | /* integer value in 'imm' field of BPF_CALL instruction selects which helper |
| @@ -5505,9 +5504,12 @@ union { \ · 184 unmodified lines | ||
| 5505 | 5504 | } __attribute__((aligned(8))) |
| 5506 | 5505 | |
| 5507 | 5506 | enum { |
| 5508 | − BPF_SKB_DELIVERY_TIME_NONE, | |
| 5509 | − BPF_SKB_DELIVERY_TIME_UNSPEC, | |
| 5510 | − BPF_SKB_DELIVERY_TIME_MONO, | |
| 5507 | + BPF_SKB_TSTAMP_UNSPEC, | |
| 5508 | + BPF_SKB_TSTAMP_DELIVERY_MONO, /* tstamp has mono delivery time */ | |
| 5509 | + /* For any BPF_SKB_TSTAMP_* that the bpf prog cannot handle, | |
| 5510 | + * the bpf prog should handle it like BPF_SKB_TSTAMP_UNSPEC | |
| 5511 | + * and try to deduce it by ingress, egress or skb->sk->sk_clockid. | |
| 5512 | + */ | |
| 5511 | 5513 | }; |
| 5512 | 5514 | |
| 5513 | 5515 | /* user accessible mirror of in-kernel sk_buff. |
| @@ -5550,7 +5552,7 @@ struct __sk_buff { · 36 unmodified lines | ||
| 5550 | 5552 | __u32 gso_segs; |
| 5551 | 5553 | __bpf_md_ptr(struct bpf_sock *, sk); |
| 5552 | 5554 | __u32 gso_size; |
| 5553 | − __u8 delivery_time_type; | |
| 5555 | + __u8 tstamp_type; | |
| 5554 | 5556 | __u32 :24; /* Padding, future use. */ |
| 5555 | 5557 | __u64 hwtstamp; |
| 5556 | 5558 | }; |