Commit Graph

13 Commits

Author SHA1 Message Date
Antoine Tenart 2bd3ea7861 gro: fix ownership transfer
JIRA: https://issues.redhat.com/browse/RHEL-19729
Upstream Status: net.git

commit ed4cccef64c1d0d5b91e69f7a8a6697c3a865486
Author: Antoine Tenart <atenart@kernel.org>
Date:   Tue Mar 26 12:33:59 2024 +0100

    gro: fix ownership transfer

    If packets are GROed with fraglist they might be segmented later on and
    continue their journey in the stack. In skb_segment_list those skbs can
    be reused as-is. This is an issue as their destructor was removed in
    skb_gro_receive_list but not the reference to their socket, and then
    they can't be orphaned. Fix this by also removing the reference to the
    socket.

    For example this could be observed,

      kernel BUG at include/linux/skbuff.h:3131!  (skb_orphan)
      RIP: 0010:ip6_rcv_core+0x11bc/0x19a0
      Call Trace:
       ipv6_list_rcv+0x250/0x3f0
       __netif_receive_skb_list_core+0x49d/0x8f0
       netif_receive_skb_list_internal+0x634/0xd40
       napi_complete_done+0x1d2/0x7d0
       gro_cell_poll+0x118/0x1f0

    A similar construction is found in skb_gro_receive, apply the same
    change there.

    Fixes: 5e10da5385d2 ("skbuff: allow 'slow_gro' for skb carring sock reference")
    Signed-off-by: Antoine Tenart <atenart@kernel.org>
    Reviewed-by: Willem de Bruijn <willemb@google.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Signed-off-by: Antoine Tenart <atenart@redhat.com>
2024-03-29 13:55:04 +01:00
Antoine Tenart b2c4833a40 net: skbuff: update and rename __kfree_skb_defer()
JIRA: https://issues.redhat.com/browse/RHEL-14554
Upstream Status: linux.git

commit 8fa66e4a1bdd41d55d7842928e60a40fed65715d
Author: Jakub Kicinski <kuba@kernel.org>
Date:   Wed Apr 19 19:00:05 2023 -0700

    net: skbuff: update and rename __kfree_skb_defer()

    __kfree_skb_defer() uses the old naming where "defer" meant
    slab bulk free/alloc APIs. In the meantime we also made
    __kfree_skb_defer() feed the per-NAPI skb cache, which
    implies bulk APIs. So take away the 'defer' and add 'napi'.

    While at it add a drop reason. This only matters on the
    tx_action path, if the skb has a frag_list. But getting
    rid of a SKB_DROP_REASON_NOT_SPECIFIED seems like a net
    benefit so why not.

    Reviewed-by: Alexander Lobakin <aleksander.lobakin@intel.com>
    Link: https://lore.kernel.org/r/20230420020005.815854-1-kuba@kernel.org
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Signed-off-by: Antoine Tenart <atenart@redhat.com>
2023-11-10 17:40:29 +01:00
Scott Weaver 03206d751a Merge: CNB94: net: move gso declarations and functions to their own files
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/3198

JIRA: https://issues.redhat.com/browse/RHEL-12679
Tested: Just built... no functional change

Commits:
```
d457a0e329b0 ("net: move gso declarations and functions to their own files")
```

Signed-off-by: Ivan Vecera <ivecera@redhat.com>

Approved-by: José Ignacio Tornos Martínez <jtornosm@redhat.com>
Approved-by: Sabrina Dubroca <sdubroca@redhat.com>

Signed-off-by: Scott Weaver <scweaver@redhat.com>
2023-10-19 10:36:22 -04:00
Ivan Vecera 497f645693 net: move gso declarations and functions to their own files
JIRA: https://issues.redhat.com/browse/RHEL-12679

commit d457a0e329b0bfd3a1450e0b1a18cd2b47a25a08
Author: Eric Dumazet <edumazet@google.com>
Date:   Thu Jun 8 19:17:37 2023 +0000

    net: move gso declarations and functions to their own files

    Move declarations into include/net/gso.h and code into net/core/gso.c

    Signed-off-by: Eric Dumazet <edumazet@google.com>
    Cc: Stanislav Fomichev <sdf@google.com>
    Reviewed-by: Simon Horman <simon.horman@corigine.com>
    Reviewed-by: David Ahern <dsahern@kernel.org>
    Link: https://lore.kernel.org/r/20230608191738.3947077-1-edumazet@google.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Signed-off-by: Ivan Vecera <ivecera@redhat.com>
2023-10-11 13:35:27 +02:00
Ivan Vecera b4aa21f5ad net: introduce and use skb_frag_fill_page_desc()
JIRA: https://issues.redhat.com/browse/RHEL-12625

Conflicts:
* drivers/net/ethernet/freescale/enetc/enetc.c
- context due to missing 8feb020f92a5 ("net: ethernet: enetc: unlock
  XDP_REDIRECT for XDP non-linear buffers")
* drivers/net/ethernet/fungible/funeth/funeth_rx.c
  - removed hunk for non-existing file
* drivers/net/ethernet/marvell/mvneta.c
  - context due to missing 76a676947b56 ("net: mvneta: update frags bit
    before passing the xdp buffer to eBPF layer")
* drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
  - adjusted due to missing 27602319e328 ("net/mlx5e: RX, Take shared
    info fragment addition into a function")

commit b51f4113ebb02011f0ca86abc3134b28d2071b6a
Author: Yunsheng Lin <linyunsheng@huawei.com>
Date:   Thu May 11 09:12:12 2023 +0800

    net: introduce and use skb_frag_fill_page_desc()

    Most users use __skb_frag_set_page()/skb_frag_off_set()/
    skb_frag_size_set() to fill the page desc for a skb frag.

    Introduce skb_frag_fill_page_desc() to do that.

    net/bpf/test_run.c does not call skb_frag_off_set() to
    set the offset, "copy_from_user(page_address(page), ...)"
    and 'shinfo' being part of the 'data' kzalloced in
    bpf_test_init() suggest that it is assuming offset to be
    initialized as zero, so call skb_frag_fill_page_desc()
    with offset being zero for this case.

    Also, skb_frag_set_page() is not used anymore, so remove
    it.

    Signed-off-by: Yunsheng Lin <linyunsheng@huawei.com>
    Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
    Reviewed-by: Simon Horman <simon.horman@corigine.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Signed-off-by: Ivan Vecera <ivecera@redhat.com>
2023-10-11 12:38:04 +02:00
Paolo Abeni 128a6de17c skb: Do mix page pool and page referenced frags in GRO
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2188560
Tested: LNST, Tier1
Conflicts: the upstream commit conflicts with the bit TCP ipv4 \
  support. Bring here the conflict resolution from commit 82b4a9412b4d \
  ("Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net") \
  so that rhel-9 code follows closely the current upstream.

Upstream commit:
commit 7d2c89b325874a35564db5630a459966afab04cc
Author: Alexander Duyck <alexanderduyck@fb.com>
Date:   Thu Jan 26 11:06:59 2023 -0800

    skb: Do mix page pool and page referenced frags in GRO

    GSO should not merge page pool recycled frames with standard reference
    counted frames. Traditionally this didn't occur, at least not often.
    However as we start looking at adding support for wireless adapters there
    becomes the potential to mix the two due to A-MSDU repartitioning frames in
    the receive path. There are possibly other places where this may have
    occurred however I suspect they must be few and far between as we have not
    seen this issue until now.

    Fixes: 53e0961da1c7 ("page_pool: add frag page recycling support in page pool")
    Reported-by: Felix Fietkau <nbd@nbd.name>
    Signed-off-by: Alexander Duyck <alexanderduyck@fb.com>
    Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
    Reviewed-by: Eric Dumazet <edumazet@google.com>
    Link: https://lore.kernel.org/r/167475990764.1934330.11960904198087757911.stgit@localhost.localdomain
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2023-05-02 19:07:34 +02:00
Xin Long 5a01b46698 net: add support for ipv4 big tcp
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2185290
Tested: big tcp selftest

commit b1a78b9b98862cda167b643690e43662ea060625
Author: Xin Long <lucien.xin@gmail.com>
Date:   Sat Jan 28 10:58:39 2023 -0500

    net: add support for ipv4 big tcp

    Similar to Eric's IPv6 BIG TCP, this patch is to enable IPv4 BIG TCP.

    Firstly, allow sk->sk_gso_max_size to be set to a value greater than
    GSO_LEGACY_MAX_SIZE by not trimming gso_max_size in sk_trim_gso_size()
    for IPv4 TCP sockets.

    Then on TX path, set IP header tot_len to 0 when skb->len > IP_MAX_MTU
    in __ip_local_out() to allow to send BIG TCP packets, and this implies
    that skb->len is the length of a IPv4 packet; On RX path, use skb->len
    as the length of the IPv4 packet when the IP header tot_len is 0 and
    skb->len > IP_MAX_MTU in ip_rcv_core(). As the API iph_set_totlen() and
    skb_ip_totlen() are used in __ip_local_out() and ip_rcv_core(), we only
    need to update these APIs.

    Also in GRO receive, add the check for ETH_P_IP/IPPROTO_TCP, and allows
    the merged packet size >= GRO_LEGACY_MAX_SIZE in skb_gro_receive(). In
    GRO complete, set IP header tot_len to 0 when the merged packet size
    greater than IP_MAX_MTU in iph_set_totlen() so that it can be processed
    on RX path.

    Note that by checking skb_is_gso_tcp() in API iph_totlen(), it makes
    this implementation safe to use iph->len == 0 indicates IPv4 BIG TCP
    packets.

    Signed-off-by: Xin Long <lucien.xin@gmail.com>
    Reviewed-by: David Ahern <dsahern@kernel.org>
    Reviewed-by: Eric Dumazet <edumazet@google.com>
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Signed-off-by: Xin Long <lxin@redhat.com>
2023-05-02 10:36:11 -04:00
Frantisek Hrbata 27a89b8946 Merge: tcp: BIG TCP implementation
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/1560

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2139501
Depends: https://bugzilla.redhat.com/show_bug.cgi?id=2128180
Tested: Using netperf and veth driver. Results meet the assumptions. See https://bugzilla.redhat.com/show_bug.cgi?id=2139501#c1

The series introduces support for BIG TCP.

- Patch 1-2: Preliminary dependencies
- Patch 3-14: Commits from upstream series 7fa2e481ff2f ("Merge branch 'big-tcp'", 2022-05-16)
- Patch 15-19: Follow-ups

Signed-off-by: Ivan Vecera <ivecera@redhat.com>

Approved-by: Antoine Tenart <atenart@redhat.com>
Approved-by: Florian Westphal <fwestpha@redhat.com>

Signed-off-by: Frantisek Hrbata <fhrbata@redhat.com>
2022-11-15 07:30:55 -05:00
Ivan Vecera fccce056fa net: allow gro_max_size to exceed 65536
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2139501

commit 0fe79f28bfaf73b66b7b1562d2468f94aa03bd12
Author: Alexander Duyck <alexanderduyck@fb.com>
Date:   Fri May 13 11:34:03 2022 -0700

    net: allow gro_max_size to exceed 65536

    Allow the gro_max_size to exceed a value larger than 65536.

    There weren't really any external limitations that prevented this other
    than the fact that IPv4 only supports a 16 bit length field. Since we have
    the option of adding a hop-by-hop header for IPv6 we can allow IPv6 to
    exceed this value and for IPv4 and non-TCP flows we can cap things at 65536
    via a constant rather than relying on gro_max_size.

    [edumazet] limit GRO_MAX_SIZE to (8 * 65535) to avoid overflows.

    Signed-off-by: Alexander Duyck <alexanderduyck@fb.com>
    Signed-off-by: Eric Dumazet <edumazet@google.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Signed-off-by: Ivan Vecera <ivecera@redhat.com>
2022-11-02 18:56:09 +01:00
Ivan Vecera 017d0aca36 gro: add ability to control gro max packet size
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2139501

Conflicts:
- context due to existing backport of 14d7b8122fd5 ("net: don't allow
  user space to lift the device limits")

commit eac1b93c14d645ef147b049ace0d5230df755548
Author: Coco Li <lixiaoyan@google.com>
Date:   Wed Jan 5 02:48:38 2022 -0800

    gro: add ability to control gro max packet size

    Eric Dumazet suggested to allow users to modify max GRO packet size.

    We have seen GRO being disabled by users of appliances (such as
    wifi access points) because of claimed bufferbloat issues,
    or some work arounds in sch_cake, to split GRO/GSO packets.

    Instead of disabling GRO completely, one can chose to limit
    the maximum packet size of GRO packets, depending on their
    latency constraints.

    This patch adds a per device gro_max_size attribute
    that can be changed with ip link command.

    ip link set dev eth0 gro_max_size 16000

    Suggested-by: Eric Dumazet <edumazet@google.com>
    Signed-off-by: Coco Li <lixiaoyan@google.com>
    Signed-off-by: Eric Dumazet <edumazet@google.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Signed-off-by: Ivan Vecera <ivecera@redhat.com>
2022-11-02 18:55:37 +01:00
Sabrina Dubroca 0cc0ad860c net: Fix esp GSO on inter address family tunnels.
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2136174
Tested: basic ipsec tests

commit 23c7f8d7989e1646aac82f75761b7648c355cb8a
Author: Steffen Klassert <steffen.klassert@secunet.com>
Date:   Mon Mar 7 13:11:41 2022 +0100

    net: Fix esp GSO on inter address family tunnels.

    The esp tunnel GSO handlers use skb_mac_gso_segment to
    push the inner packet to the segmentation handlers.
    However, skb_mac_gso_segment takes the Ethernet Protocol
    ID from 'skb->protocol' which is wrong for inter address
    family tunnels. We fix this by introducing a new
    skb_eth_gso_segment function.

    This function can be used if it is necessary to pass the
    Ethernet Protocol ID directly to the segmentation handler.
    First users of this function will be the esp4 and esp6
    tunnel segmentation handlers.

    Fixes: c35fe4106b ("xfrm: Add mode handlers for IPsec on layer 2")
    Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>

Signed-off-by: Sabrina Dubroca <sdubroca@redhat.com>
2022-10-25 15:18:34 +02:00
Ivan Vecera 7ba9ae4395 net: gro: populate net/core/gro.c
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2101789

Conflicts:
- adjusted due to existing backport of 7881453e4adf ("net: gro: avoid
  re-computing truesize twice on recycle")

commit 587652bbdd06ab38a4c1b85e40f933d2cf4a1147
Author: Eric Dumazet <edumazet@google.com>
Date:   Mon Nov 15 09:05:54 2021 -0800

    net: gro: populate net/core/gro.c

    Move gro code and data from net/core/dev.c to net/core/gro.c
    to ease maintenance.

    gro_normal_list() and gro_normal_one() are inlined
    because they are called from both files.

    Signed-off-by: Eric Dumazet <edumazet@google.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Signed-off-by: Ivan Vecera <ivecera@redhat.com>
2022-06-28 13:28:41 +02:00
Ivan Vecera 756015f0e8 net: gro: move skb_gro_receive into net/core/gro.c
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2101789

commit e456a18a390b96f22b0de2acd4d0f49c72ed2280
Author: Eric Dumazet <edumazet@google.com>
Date:   Mon Nov 15 09:05:53 2021 -0800

    net: gro: move skb_gro_receive into net/core/gro.c

    net/core/gro.c will contain all core gro functions,
    to shrink net/core/skbuff.c and net/core/dev.c

    Signed-off-by: Eric Dumazet <edumazet@google.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Signed-off-by: Ivan Vecera <ivecera@redhat.com>
2022-06-28 13:28:40 +02:00