History

Merge git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next

Alexei Starovoitov says: ==================== pull-request: bpf-next 2019-02-16 The following pull-request contains BPF updates for your *net-next* tree. The main changes are: 1) numerous libbpf API improvements, from Andrii, Andrey, Yonghong. 2) test all bpf progs in alu32 mode, from Jiong. 3) skb->sk access and bpf_sk_fullsock(), bpf_tcp_sock() helpers, from Martin. 4) support for IP encap in lwt bpf progs, from Peter. 5) remove XDP_QUERY_XSK_UMEM dead code, from Jan. ====================

David S. Miller committed 7 years ago

Commit 885e6312 parents f186a82 5aab39292 files · +2576 −485Browse files

Showing the changes to include/uapi/linux (1 of 92 files). Show all

Unified · Split

include/uapi/linux/bpf.h+89−9
@@ -2016,6 +2016,19 @@ union bpf_attr { · 2015 unmodified lines
20162016 * Only works if *skb* contains an IPv6 packet. Insert a
20172017 * Segment Routing Header (**struct ipv6_sr_hdr**) inside
20182018 * the IPv6 header.
2019+ * **BPF_LWT_ENCAP_IP**
2020+ * IP encapsulation (GRE/GUE/IPIP/etc). The outer header
2021+ * must be IPv4 or IPv6, followed by zero or more
2022+ * additional headers, up to LWT_BPF_MAX_HEADROOM total
2023+ * bytes in all prepended headers. Please note that
2024+ * if skb_is_gso(skb) is true, no more than two headers
2025+ * can be prepended, and the inner header, if present,
2026+ * should be either GRE or UDP/GUE.
2027+ *
2028+ * BPF_LWT_ENCAP_SEG6*** types can be called by bpf programs of
2029+ * type BPF_PROG_TYPE_LWT_IN; BPF_LWT_ENCAP_IP type can be called
2030+ * by bpf programs of types BPF_PROG_TYPE_LWT_IN and
2031+ * BPF_PROG_TYPE_LWT_XMIT.
20192032 *
20202033 * A call to this helper is susceptible to change the underlaying
20212034 * packet buffer. Therefore, at load time, all checks on pointers
@@ -2329,6 +2342,23 @@ union bpf_attr { · 307 unmodified lines
23292342 * "**y**".
23302343 * Return
23312344 * 0
2345+ *
2346+ * struct bpf_sock *bpf_sk_fullsock(struct bpf_sock *sk)
2347+ * Description
2348+ * This helper gets a **struct bpf_sock** pointer such
2349+ * that all the fields in bpf_sock can be accessed.
2350+ * Return
2351+ * A **struct bpf_sock** pointer on success, or NULL in
2352+ * case of failure.
2353+ *
2354+ * struct bpf_tcp_sock *bpf_tcp_sock(struct bpf_sock *sk)
2355+ * Description
2356+ * This helper gets a **struct bpf_tcp_sock** pointer from a
2357+ * **struct bpf_sock** pointer.
2358+ *
2359+ * Return
2360+ * A **struct bpf_tcp_sock** pointer on success, or NULL in
2361+ * case of failure.
23322362 */
23332363 #define __BPF_FUNC_MAPPER(FN) \
23342364 FN(unspec), \
@@ -2425,7 +2455,9 @@ union bpf_attr { · 90 unmodified lines
24252455 FN(msg_pop_data), \
24262456 FN(rc_pointer_rel), \
24272457 FN(spin_lock), \
2428− FN(spin_unlock),
2458+ FN(spin_unlock), \
2459+ FN(sk_fullsock), \
2460+ FN(tcp_sock),
24292461
24302462 /* integer value in 'imm' field of BPF_CALL instruction selects which helper
24312463 * function eBPF program intends to call
@@ -2498,7 +2530,8 @@ enum bpf_hdr_start_off { · 66 unmodified lines
24982530 /* Encapsulation type for BPF_FUNC_lwt_push_encap helper. */
24992531 enum bpf_lwt_encap_mode {
25002532 BPF_LWT_ENCAP_SEG6,
2501− BPF_LWT_ENCAP_SEG6_INLINE
2533+ BPF_LWT_ENCAP_SEG6_INLINE,
2534+ BPF_LWT_ENCAP_IP,
25022535 };
25032536
25042537 #define __bpf_md_ptr(type, name) \
@@ -2545,6 +2578,7 @@ struct __sk_buff { · 40 unmodified lines
25452578 __u64 tstamp;
25462579 __u32 wire_len;
25472580 __u32 gso_segs;
2581+ __bpf_md_ptr(struct bpf_sock *, sk);
25482582 };
25492583
25502584 struct bpf_tunnel_key {
@@ -2586,7 +2620,15 @@ enum bpf_ret_code { · 35 unmodified lines
25862620 BPF_DROP = 2,
25872621 /* 3-6 reserved */
25882622 BPF_REDIRECT = 7,
2589− /* >127 are reserved for prog type specific return codes */
2623+ /* >127 are reserved for prog type specific return codes.
2624+ *
2625+ * BPF_LWT_REROUTE: used by BPF_PROG_TYPE_LWT_IN and
2626+ * BPF_PROG_TYPE_LWT_XMIT to indicate that skb had been
2627+ * changed and should be routed based on its new L3 header.
2628+ * (This is an L3 redirect, as opposed to L2 redirect
2629+ * represented by BPF_REDIRECT above).
2630+ */
2631+ BPF_LWT_REROUTE = 128,
25902632 };
25912633
25922634 struct bpf_sock {
@@ -2596,14 +2638,52 @@ struct bpf_sock { · 3 unmodified lines
25962638 __u32 protocol;
25972639 __u32 mark;
25982640 __u32 priority;
2599− __u32 src_ip4; /* Allows 1,2,4-byte read.
2600− * Stored in network byte order.
2641+ /* IP address also allows 1 and 2 bytes access */
2642+ __u32 src_ip4;
2643+ __u32 src_ip6[4];
2644+ __u32 src_port; /* host byte order */
2645+ __u32 dst_port; /* network byte order */
2646+ __u32 dst_ip4;
2647+ __u32 dst_ip6[4];
2648+ __u32 state;
2649+};
2650+
2651+struct bpf_tcp_sock {
2652+ __u32 snd_cwnd; /* Sending congestion window */
2653+ __u32 srtt_us; /* smoothed round trip time << 3 in usecs */
2654+ __u32 rtt_min;
2655+ __u32 snd_ssthresh; /* Slow start size threshold */
2656+ __u32 rcv_nxt; /* What we want to receive next */
2657+ __u32 snd_nxt; /* Next sequence we send */
2658+ __u32 snd_una; /* First byte we want an ack for */
2659+ __u32 mss_cache; /* Cached effective mss, not including SACKS */
2660+ __u32 ecn_flags; /* ECN status bits. */
2661+ __u32 rate_delivered; /* saved rate sample: packets delivered */
2662+ __u32 rate_interval_us; /* saved rate sample: time elapsed */
2663+ __u32 packets_out; /* Packets which are "in flight" */
2664+ __u32 retrans_out; /* Retransmitted packets out */
2665+ __u32 total_retrans; /* Total retransmits for entire connection */
2666+ __u32 segs_in; /* RFC4898 tcpEStatsPerfSegsIn
2667+ * total number of segments in.
26012668 */
2602− __u32 src_ip6[4]; /* Allows 1,2,4-byte read.
2603− * Stored in network byte order.
2669+ __u32 data_segs_in; /* RFC4898 tcpEStatsPerfDataSegsIn
2670+ * total number of data segments in.
2671+ */
2672+ __u32 segs_out; /* RFC4898 tcpEStatsPerfSegsOut
2673+ * The total number of segments sent.
2674+ */
2675+ __u32 data_segs_out; /* RFC4898 tcpEStatsPerfDataSegsOut
2676+ * total number of data segments sent.
2677+ */
2678+ __u32 lost_out; /* Lost packets */
2679+ __u32 sacked_out; /* SACK'd packets */
2680+ __u64 bytes_received; /* RFC4898 tcpEStatsAppHCThruOctetsReceived
2681+ * sum(delta(rcv_nxt)), or how many bytes
2682+ * were acked.
26042683 */
2605− __u32 src_port; /* Allows 4-byte read.
2606− * Stored in host byte order
2684+ __u64 bytes_acked; /* RFC4898 tcpEStatsAppHCThruOctetsAcked
2685+ * sum(delta(snd_una)), or how many bytes
2686+ * were acked.
26072687 */
26082688 };
26092689