Centos-kernel-stream-9/net/ipv4
Jiri Benc ffd8cd8977 bpf: tcp: Allow bpf-tcp-cc to call bpf_(get|set)sockopt
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2071618

Conflicts:
- [minor] context difference in bpf_tcp_ca_get_func_proto due to out of
  order backport of 5e0bc3082e2e "bpf: Forbid bpf_ktime_get_coarse_ns and
  bpf_timer_* in tracing progs"

commit eb18b49ea758ec052ac2a12c6bb204e1e877ec31
Author: Martin KaFai Lau <kafai@fb.com>
Date:   Tue Aug 24 10:30:07 2021 -0700

    bpf: tcp: Allow bpf-tcp-cc to call bpf_(get|set)sockopt

    This patch allows the bpf-tcp-cc to call bpf_setsockopt.  One use
    case is to allow a bpf-tcp-cc switching to another cc during init().
    For example, when the tcp flow is not ecn ready, the bpf_dctcp
    can switch to another cc by calling setsockopt(TCP_CONGESTION).

    During setsockopt(TCP_CONGESTION), the new tcp-cc's init() will be
    called and this could cause a recursion but it is stopped by the
    current trampoline's logic (in the prog->active counter).

    While retiring a bpf-tcp-cc (e.g. in tcp_v[46]_destroy_sock()),
    the tcp stack calls bpf-tcp-cc's release().  To avoid the retiring
    bpf-tcp-cc making further changes to the sk, bpf_setsockopt is not
    available to the bpf-tcp-cc's release().  This will avoid release()
    making setsockopt() call that will potentially allocate new resources.

    Although the bpf-tcp-cc already has a more powerful way to read tcp_sock
    from the PTR_TO_BTF_ID, it is usually expected that bpf_getsockopt and
    bpf_setsockopt are available together.  Thus, bpf_getsockopt() is also
    added to all tcp_congestion_ops except release().

    When the old bpf-tcp-cc is calling setsockopt(TCP_CONGESTION)
    to switch to a new cc, the old bpf-tcp-cc will be released by
    bpf_struct_ops_put().  Thus, this patch also puts the bpf_struct_ops_map
    after a rcu grace period because the trampoline's image cannot be freed
    while the old bpf-tcp-cc is still running.

    bpf-tcp-cc can only access icsk_ca_priv as SCALAR.  All kernel's
    tcp-cc is also accessing the icsk_ca_priv as SCALAR.   The size
    of icsk_ca_priv has already been raised a few times to avoid
    extra kmalloc and memory referencing.  The only exception is the
    kernel's tcp_cdg.c that stores a kmalloc()-ed pointer in icsk_ca_priv.
    To avoid the old bpf-tcp-cc accidentally overriding this tcp_cdg's pointer
    value stored in icsk_ca_priv after switching and without over-complicating
    the bpf's verifier for this one exception in tcp_cdg, this patch does not
    allow switching to tcp_cdg.  If there is a need, bpf_tcp_cdg can be
    implemented and then use the bpf_sk_storage as the extended storage.

    bpf_sk_setsockopt proto has only been recently added and used
    in bpf-sockopt and bpf-iter-tcp, so impose the tcp_cdg limitation in the
    same proto instead of adding a new proto specifically for bpf-tcp-cc.

    Signed-off-by: Martin KaFai Lau <kafai@fb.com>
    Signed-off-by: Alexei Starovoitov <ast@kernel.org>
    Link: https://lore.kernel.org/bpf/20210824173007.3976921-1-kafai@fb.com

Signed-off-by: Jiri Benc <jbenc@redhat.com>
2022-05-12 17:29:46 +02:00
..
bpfilter
netfilter proc: remove PDE_DATA() completely 2022-04-08 17:38:02 +02:00
Kconfig
Makefile bpf: Clean up sockmap related Kconfigs 2021-02-26 12:28:03 -08:00
af_inet.c bpf: Migrate cgroup_bpf to internal cgroup_bpf_attach_type enum 2022-04-29 18:14:44 +02:00
ah4.c Networking changes for 5.14. 2021-06-30 15:51:09 -07:00
arp.c
bpf_tcp_ca.c bpf: tcp: Allow bpf-tcp-cc to call bpf_(get|set)sockopt 2022-05-12 17:29:46 +02:00
cipso_ipv4.c net: remove the unnecessary check in cipso_v4_doi_free 2022-04-12 17:54:18 +02:00
datagram.c
devinet.c net: socket: remove register_gifconf 2021-10-11 15:43:40 +02:00
esp4.c Networking changes for 5.14. 2021-06-30 15:51:09 -07:00
esp4_offload.c xfrm: remove description from xfrm_type struct 2021-06-09 09:38:52 +02:00
fib_frontend.c ipv4: convert fib_num_tclassid_users to atomic_t 2022-01-27 12:51:25 +01:00
fib_lookup.h ipv4: Fix spelling mistakes 2021-06-07 14:08:30 -07:00
fib_notifier.c
fib_rules.c Merge: ipv6: 9.0 P2 backports from upstream 2022-02-15 01:29:58 +00:00
fib_semantics.c ipv4: convert fib_num_tclassid_users to atomic_t 2022-01-27 12:51:25 +01:00
fib_trie.c IPv4: Extend 'fib_notify_on_flag_change' sysctl 2021-02-08 16:47:03 -08:00
fou.c
gre_demux.c net: Remove the member netns_ok 2021-05-17 15:29:35 -07:00
gre_offload.c ip_gre: add csum offload support for gre header 2021-01-29 20:39:14 -08:00
icmp.c net: Remove redundant if statements 2022-01-10 16:20:08 +01:00
igmp.c net: igmp: increase size of mr_ifc_count 2021-08-11 15:54:10 -07:00
inet_connection_sock.c inet: use #ifdef CONFIG_SOCK_RX_QUEUE_MAPPING consistently 2022-01-27 12:51:28 +01:00
inet_diag.c Merge: udp: backports from upstream, 2nd phase 2022-02-15 02:14:03 +00:00
inet_fragment.c
inet_hashtables.c net: prefer socket bound to interface when not in VRF 2021-11-27 11:07:13 -05:00
inet_timewait_sock.c
inetpeer.c inetpeer: use div64_ul() and clamp_val() calculate inet_peer_threshold 2021-03-01 13:32:12 -08:00
ip_forward.c
ip_fragment.c
ip_gre.c gre: Don't accidentally set RTO_ONLINK in gre_fill_metadata_dst() 2022-01-27 12:51:36 +01:00
ip_input.c net: use indirect call helpers for dst_input 2021-02-03 14:51:39 -08:00
ip_options.c
ip_output.c ipv4: use skb_expand_head in ip_finish_output2 2021-12-09 10:44:30 +01:00
ip_sockglue.c ipv4: Exposing __ip_sock_set_tos() in ip.h 2022-01-12 10:49:55 +01:00
ip_tunnel.c ip_tunnel: use ndo_siocdevprivate 2021-10-11 15:43:53 +02:00
ip_tunnel_core.c net: ip_tunnel: clean up endianness conversions 2021-01-08 19:25:35 -08:00
ip_vti.c ip_tunnel: use ndo_siocdevprivate 2021-10-11 15:43:53 +02:00
ipcomp.c Networking changes for 5.14. 2021-06-30 15:51:09 -07:00
ipconfig.c net: ipconfig: Don't override command-line hostnames or domains 2021-06-02 13:27:03 -07:00
ipip.c ip_tunnel: use ndo_siocdevprivate 2021-10-11 15:43:53 +02:00
ipmr.c ipmr: Fix indentation issue 2021-07-07 20:52:25 -07:00
ipmr_base.c
metrics.c
netfilter.c netfilter: Dissect flow after packet mangling 2021-04-18 22:04:16 +02:00
netlink.c
nexthop.c net: nexthop: reduce rcu synchronizations when replacing resilient groups 2022-02-07 11:49:50 +08:00
ping.c net: sock: introduce sk_error_report 2021-06-29 11:28:21 -07:00
proc.c tcp: Add stats for socket migration. 2021-06-23 12:56:08 -07:00
protocol.c net: Remove the member netns_ok 2021-05-17 15:29:35 -07:00
raw.c proc: remove PDE_DATA() completely 2022-04-08 17:38:02 +02:00
raw_diag.c net: Use nlmsg_unicast() instead of netlink_unicast() 2021-07-13 09:28:29 -07:00
route.c Merge: CNB: net: Remove redundant if statements 2022-01-26 22:11:25 +00:00
syncookies.c
sysctl_net_ipv4.c tcp: remove sk_{tr}x_skb_cache 2022-01-12 10:49:53 +01:00
tcp.c net: remove sk_route_forced_caps 2022-01-21 16:26:18 +01:00
tcp_bbr.c tcp_bbr: fix u32 wrap bug in round logic if bbr_init() called after 2B packets 2021-08-11 15:00:15 -07:00
tcp_bic.c
tcp_bpf.c bpf, sockmap, tcp: sk_prot needs inuse_idx set for proc stats 2021-07-15 19:54:22 +02:00
tcp_cdg.c
tcp_cong.c net: Only allow init netns to set default tcp cong to a restricted algo 2021-05-04 11:58:28 -07:00
tcp_cubic.c tcp_cubic: fix spurious Hystart ACK train detections for not-cwnd-limited flows 2021-12-02 12:03:43 +01:00
tcp_dctcp.c
tcp_dctcp.h
tcp_diag.c
tcp_fastopen.c tcp: disable TFO blackhole logic by default 2021-07-21 22:50:31 -07:00
tcp_highspeed.c
tcp_htcp.c
tcp_hybla.c
tcp_illinois.c
tcp_input.c tcp: fix tp->undo_retrans accounting in tcp_sacktag_one() 2021-12-02 12:04:16 +01:00
tcp_ipv4.c bpf: tcp: Support bpf_(get|set)sockopt in bpf tcp iter 2022-05-12 17:29:46 +02:00
tcp_lp.c ipv4: tcp_lp.c: Couple of typo fixes 2021-03-28 17:31:13 -07:00
tcp_metrics.c
tcp_minisocks.c tcp: Add stats for socket migration. 2021-06-23 12:56:08 -07:00
tcp_nv.c
tcp_offload.c net, gro: Set inner transport header offset in tcp/udp GRO hook 2021-08-02 10:20:56 +01:00
tcp_output.c Merge: net: backports before kABI freeze 2022-02-07 15:11:27 +00:00
tcp_rate.c
tcp_recovery.c tcp: fix TLP timer not set when CA_STATE changes from DISORDER to OPEN 2021-01-23 21:33:01 -08:00
tcp_scalable.c
tcp_timer.c net: sock: introduce sk_error_report 2021-06-29 11:28:21 -07:00
tcp_ulp.c
tcp_vegas.c
tcp_vegas.h
tcp_veno.c
tcp_westwood.c
tcp_yeah.c tcp_yeah: check struct yeah size at compile time 2021-06-29 11:54:36 -07:00
tunnel4.c net: Remove the member netns_ok 2021-05-17 15:29:35 -07:00
udp.c bpf: Migrate cgroup_bpf to internal cgroup_bpf_attach_type enum 2022-04-29 18:14:44 +02:00
udp_bpf.c sock_map: Lift socket state restriction for datagram sockets 2022-05-12 17:29:43 +02:00
udp_diag.c net: Use nlmsg_unicast() instead of netlink_unicast() 2021-07-13 09:28:29 -07:00
udp_impl.h
udp_offload.c net, gro: Set inner transport header offset in tcp/udp GRO hook 2021-08-02 10:20:56 +01:00
udp_tunnel_core.c net/ipv4/udp_tunnel_core.c: remove superfluous header files from udp_tunnel_core.c 2021-11-27 11:07:12 -05:00
udp_tunnel_nic.c udp_tunnel: Fix udp_tunnel_nic work-queue type 2021-11-27 11:07:12 -05:00
udp_tunnel_stub.c
udplite.c net: Remove the member netns_ok 2021-05-17 15:29:35 -07:00
xfrm4_input.c
xfrm4_output.c
xfrm4_policy.c
xfrm4_protocol.c net: Remove the member netns_ok 2021-05-17 15:29:35 -07:00
xfrm4_state.c
xfrm4_tunnel.c xfrm: remove description from xfrm_type struct 2021-06-09 09:38:52 +02:00