linux-2.6-microblaze.git
3 years agonet: packetengines: switch from 'pci_' to 'dma_' API
Christophe JAILLET [Mon, 20 Jul 2020 12:29:12 +0000 (14:29 +0200)]
net: packetengines: switch from 'pci_' to 'dma_' API

The wrappers in include/linux/pci-dma-compat.h should go away.

The patch has been generated with the coccinelle script below and has been
hand modified to replace GFP_ with a correct flag.
It has been compile tested.

When memory is allocated in 'hamachi_init_one()' (hamachi.c), GFP_KERNEL
can be used because it is a probe function and no lock is acquired.

When memory is allocated in 'yellowfin_init_one()' (yellowfin.c),
GFP_KERNEL can be used because it is a probe function and no lock is
acquired.

@@
@@
-    PCI_DMA_BIDIRECTIONAL
+    DMA_BIDIRECTIONAL

@@
@@
-    PCI_DMA_TODEVICE
+    DMA_TO_DEVICE

@@
@@
-    PCI_DMA_FROMDEVICE
+    DMA_FROM_DEVICE

@@
@@
-    PCI_DMA_NONE
+    DMA_NONE

@@
expression e1, e2, e3;
@@
-    pci_alloc_consistent(e1, e2, e3)
+    dma_alloc_coherent(&e1->dev, e2, e3, GFP_)

@@
expression e1, e2, e3;
@@
-    pci_zalloc_consistent(e1, e2, e3)
+    dma_alloc_coherent(&e1->dev, e2, e3, GFP_)

@@
expression e1, e2, e3, e4;
@@
-    pci_free_consistent(e1, e2, e3, e4)
+    dma_free_coherent(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4;
@@
-    pci_map_single(e1, e2, e3, e4)
+    dma_map_single(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4;
@@
-    pci_unmap_single(e1, e2, e3, e4)
+    dma_unmap_single(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4, e5;
@@
-    pci_map_page(e1, e2, e3, e4, e5)
+    dma_map_page(&e1->dev, e2, e3, e4, e5)

@@
expression e1, e2, e3, e4;
@@
-    pci_unmap_page(e1, e2, e3, e4)
+    dma_unmap_page(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4;
@@
-    pci_map_sg(e1, e2, e3, e4)
+    dma_map_sg(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4;
@@
-    pci_unmap_sg(e1, e2, e3, e4)
+    dma_unmap_sg(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4;
@@
-    pci_dma_sync_single_for_cpu(e1, e2, e3, e4)
+    dma_sync_single_for_cpu(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4;
@@
-    pci_dma_sync_single_for_device(e1, e2, e3, e4)
+    dma_sync_single_for_device(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4;
@@
-    pci_dma_sync_sg_for_cpu(e1, e2, e3, e4)
+    dma_sync_sg_for_cpu(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4;
@@
-    pci_dma_sync_sg_for_device(e1, e2, e3, e4)
+    dma_sync_sg_for_device(&e1->dev, e2, e3, e4)

@@
expression e1, e2;
@@
-    pci_dma_mapping_error(e1, e2)
+    dma_mapping_error(&e1->dev, e2)

@@
expression e1, e2;
@@
-    pci_set_dma_mask(e1, e2)
+    dma_set_mask(&e1->dev, e2)

@@
expression e1, e2;
@@
-    pci_set_consistent_dma_mask(e1, e2)
+    dma_set_coherent_mask(&e1->dev, e2)

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agoarch, net: remove the last csum_partial_copy() leftovers
Christoph Hellwig [Mon, 20 Jul 2020 11:36:09 +0000 (13:36 +0200)]
arch, net: remove the last csum_partial_copy() leftovers

Most of the tree only uses and implements csum_partial_copy_nocheck,
but the c6x and lib/checksum.c implement a csum_partial_copy that
isn't used anywere except to define csum_partial_copy.  Get rid of
this pointless alias.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonet: fs_enet: remove redundant null check
Zhang Changzhong [Mon, 20 Jul 2020 11:12:33 +0000 (19:12 +0800)]
net: fs_enet: remove redundant null check

Because clk_prepare_enable and clk_disable_unprepare already
checked NULL clock parameter, so the additional checks are
unnecessary, just remove them.

Signed-off-by: Zhang Changzhong <zhangchangzhong@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agoMerge branch 'net-macb-Wake-on-Lan-magic-packet-GEM-and-MACB-handling'
David S. Miller [Tue, 21 Jul 2020 00:01:45 +0000 (17:01 -0700)]
Merge branch 'net-macb-Wake-on-Lan-magic-packet-GEM-and-MACB-handling'

Nicolas Ferre says:

====================
net: macb: Wake-on-Lan magic packet GEM and MACB handling

Here is the second part of support for WoL magic-packet on the current macb
driver. This one
is addressing the bulk of the feature and is based on current net-next/master.

MACB and GEM code must co-exist and as they don't share exactly the same
register layout, I had to specialize a bit the suspend/resume paths and plug a
specific IRQ handler in order to avoid overloading the "normal" IRQ hot path.

These changes were tested on both sam9x60 which embeds a MACB+FIFO controller
and sama5d2 which has a GEM+packet buffer type of controller.

Best regards,
  Nicolas

Changes in v7:
- Release the spinlock before exiting macb_suspend/resume in case of error
  changing IRQ handler

Changes in v6:
- rebase on net-next/master now that the "fixes" patches of the series are
  merged in both net and net-next.
- GEM addition and MACB update to finish the support of WoL magic-packet on the
  two revisions of the controller.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonet: macb: Add WoL interrupt support for MACB type of Ethernet controller
Nicolas Ferre [Mon, 20 Jul 2020 08:56:53 +0000 (10:56 +0200)]
net: macb: Add WoL interrupt support for MACB type of Ethernet controller

Handle the Wake-on-Lan interrupt for the Cadence MACB Ethernet
controller.
As we do for the GEM version, we handle of WoL interrupt in a
specialized interrupt handler for MACB version that is positionned
just between suspend() and resume() calls.

Cc: Claudiu Beznea <claudiu.beznea@microchip.com>
Cc: Harini Katakam <harini.katakam@xilinx.com>
Signed-off-by: Nicolas Ferre <nicolas.ferre@microchip.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonet: macb: WoL support for GEM type of Ethernet controller
Nicolas Ferre [Mon, 20 Jul 2020 08:56:52 +0000 (10:56 +0200)]
net: macb: WoL support for GEM type of Ethernet controller

Adapt the Wake-on-Lan feature to the Cadence GEM Ethernet controller.
This controller has different register layout and cannot be handled by
previous code.
We disable completely interrupts on all the queues but the queue 0.
Handling of WoL interrupt is done in another interrupt handler
positioned depending on the controller version used, just between
suspend() and resume() calls.
It allows to lower pressure on the generic interrupt hot path by
removing the need to handle 2 tests for each IRQ: the first figuring out
the controller revision, the second for actually knowing if the WoL bit
is set.

Queue management in suspend()/resume() functions inspired from RFC patch
by Harini Katakam <harinik@xilinx.com>, thanks!

Cc: Claudiu Beznea <claudiu.beznea@microchip.com>
Cc: Harini Katakam <harini.katakam@xilinx.com>
Signed-off-by: Nicolas Ferre <nicolas.ferre@microchip.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agosched: sch_api: add missing rcu read lock to silence the warning
Jiri Pirko [Mon, 20 Jul 2020 08:10:41 +0000 (10:10 +0200)]
sched: sch_api: add missing rcu read lock to silence the warning

In case the qdisc_match_from_root function() is called from non-rcu path
with rtnl mutex held, a suspiciout rcu usage warning appears:

[  241.504354] =============================
[  241.504358] WARNING: suspicious RCU usage
[  241.504366] 5.8.0-rc4-custom-01521-g72a7c7d549c3 #32 Not tainted
[  241.504370] -----------------------------
[  241.504378] net/sched/sch_api.c:270 RCU-list traversed in non-reader section!!
[  241.504382]
               other info that might help us debug this:
[  241.504388]
               rcu_scheduler_active = 2, debug_locks = 1
[  241.504394] 1 lock held by tc/1391:
[  241.504398]  #0: ffffffff85a27850 (rtnl_mutex){+.+.}-{3:3}, at: rtnetlink_rcv_msg+0x49a/0xbd0
[  241.504431]
               stack backtrace:
[  241.504440] CPU: 0 PID: 1391 Comm: tc Not tainted 5.8.0-rc4-custom-01521-g72a7c7d549c3 #32
[  241.504446] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.13.0-2.fc32 04/01/2014
[  241.504453] Call Trace:
[  241.504465]  dump_stack+0x100/0x184
[  241.504482]  lockdep_rcu_suspicious+0x153/0x15d
[  241.504499]  qdisc_match_from_root+0x293/0x350

Fix this by passing the rtnl held lockdep condition down to
hlist_for_each_entry_rcu()

Reported-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonet: ena: Fix using plain integer as NULL pointer in ena_init_napi_in_range
Wang Hai [Mon, 20 Jul 2020 07:56:14 +0000 (15:56 +0800)]
net: ena: Fix using plain integer as NULL pointer in ena_init_napi_in_range

Fix sparse build warning:

drivers/net/ethernet/amazon/ena/ena_netdev.c:2193:34: warning:
 Using plain integer as NULL pointer

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Wang Hai <wanghai38@huawei.com>
Suggested-by: Joe Perches <joe@perches.com>
Acked-by: Shay Agroskin <shayagr@amazon.com>
Acked-by: Shay Agroskin <shayagr@amazon.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonet: hns: use eth_broadcast_addr() to assign broadcast address
Xu Wang [Mon, 20 Jul 2020 06:24:10 +0000 (06:24 +0000)]
net: hns: use eth_broadcast_addr() to assign broadcast address

This patch is to use eth_broadcast_addr() to assign broadcast address
insetad of memset().

Signed-off-by: Xu Wang <vulab@iscas.ac.cn>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agoMerge branch 'net-dsa-Setup-dsa_netdev_ops'
David S. Miller [Mon, 20 Jul 2020 23:48:22 +0000 (16:48 -0700)]
Merge branch 'net-dsa-Setup-dsa_netdev_ops'

Florian Fainelli says:

====================
net: dsa: Setup dsa_netdev_ops

This patch series addresses the overloading of a DSA CPU/management
interface's netdev_ops for the purpose of providing useful information
from the switch side.

Up until now we had duplicated the existing netdev_ops structure and
added specific function pointers to return information of interest. Here
we have a more controlled way of doing this by involving the specific
netdev_ops function pointers that we want to be patched, which is easier
for auditing code in the future. As a byproduct we can now maintain
netdev_ops pointer comparisons which would be failing before (no known
in tree problems because of that though).

Let me know if this approach looks reasonable to you and we might do the
same with our ethtool_ops overloading as well.

Changes in v2:

- use static inline int vs. static int inline (Kbuild robot)
- fixed typos in patch 4 (Andrew)
- avoid using macros (Andrew)
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonet: dsa: Setup dsa_netdev_ops
Florian Fainelli [Mon, 20 Jul 2020 03:49:54 +0000 (20:49 -0700)]
net: dsa: Setup dsa_netdev_ops

Now that we have all the infrastructure in place for calling into the
dsa_ptr->netdev_ops function pointers, install them when we configure
the DSA CPU/management interface and tear them down. The flow is
unchanged from before, but now we preserve equality of tests when
network device drivers do tests like dev->netdev_ops == &foo_ops which
was not the case before since we were allocating an entirely new
structure.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonet: Call into DSA netdevice_ops wrappers
Florian Fainelli [Mon, 20 Jul 2020 03:49:53 +0000 (20:49 -0700)]
net: Call into DSA netdevice_ops wrappers

Make the core net_device code call into our ndo_do_ioctl() and
ndo_get_phys_port_name() functions via the wrappers defined previously

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonet: dsa: Add wrappers for overloaded ndo_ops
Florian Fainelli [Mon, 20 Jul 2020 03:49:52 +0000 (20:49 -0700)]
net: dsa: Add wrappers for overloaded ndo_ops

Add definitions for the dsa_netdevice_ops structure which is a subset of
the net_device_ops structure for the specific operations that we care
about overlaying on top of the DSA CPU port net_device and provide
inline stubs that take core managing whether DSA code is reachable.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonet: Wrap ndo_do_ioctl() to prepare for DSA stacked ops
Florian Fainelli [Mon, 20 Jul 2020 03:49:51 +0000 (20:49 -0700)]
net: Wrap ndo_do_ioctl() to prepare for DSA stacked ops

In preparation for adding another layer of call into a DSA stacked ops
singleton, wrap the ndo_do_ioctl() call into dev_do_ioctl().

Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonet: vxge-main: Remove unnecessary cast in kfree()
Xu Wang [Mon, 20 Jul 2020 03:09:59 +0000 (03:09 +0000)]
net: vxge-main: Remove unnecessary cast in kfree()

Remove unnecassary casts in the argument to kfree.

Signed-off-by: Xu Wang <vulab@iscas.ac.cn>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agoMerge branch 'Fully-describe-the-waveform-for-PTP-periodic-output'
David S. Miller [Mon, 20 Jul 2020 02:22:57 +0000 (19:22 -0700)]
Merge branch 'Fully-describe-the-waveform-for-PTP-periodic-output'

Vladimir Oltean says:

====================
Fully describe the waveform for PTP periodic output

While using the ancillary pin functionality of PTP hardware clocks to
synchronize multiple DSA switches on a board, a need arised to be able
to configure the duty cycle of the master of this PPS hierarchy.

Also, the PPS master is not able to emit PPS starting from arbitrary
absolute times, so a new flag is introduced to support such hardware
without making guesses.

With these patches, struct ptp_perout_request now basically describes a
general-purpose square wave.

Changes in v2:
Made sure this applies to net-next.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonet: mscc: ocelot: add support for PTP waveform configuration
Vladimir Oltean [Thu, 16 Jul 2020 22:45:31 +0000 (01:45 +0300)]
net: mscc: ocelot: add support for PTP waveform configuration

For PPS output (perout period is 1.000000000), accept the new "phase"
parameter from the periodic output request structure.

For both PPS and freeform output, accept the new "on" argument for
specifying the duty cycle of the generated signal. Preserve the old
defaults for this "on" time: 1 us for PPS, and half the period for
freeform output.

Also preserve the old behavior that accepted the "phase" via the "start"
argument.

Signed-off-by: Vladimir Oltean <olteanv@gmail.com>
Reviewed-by: Horatiu Vultur <horatiu.vultur@microchip.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agoptp: introduce a phase offset in the periodic output request
Vladimir Oltean [Thu, 16 Jul 2020 22:45:30 +0000 (01:45 +0300)]
ptp: introduce a phase offset in the periodic output request

Some PHCs like the ocelot/felix switch cannot emit generic periodic
output, but just PPS (pulse per second) signals, which:
- don't start from arbitrary absolute times, but are rather
  phase-aligned to the beginning of [the closest next] second.
- have an optional phase offset relative to that beginning of the
  second.

For those, it was initially established that they should reject any
other absolute time for the PTP_PEROUT_REQUEST than 0.000000000 [1].

But when it actually came to writing an application [2] that makes use
of this functionality, we realized that we can't really deal generically
with PHCs that support absolute start time, and with PHCs that don't,
without an explicit interface. Namely, in an ideal world, PHC drivers
would ensure that the "perout.start" value written to hardware will
result in a functional output. This means that if the PTP time has
become in the past of this PHC's current time, it should be
automatically fast-forwarded by the driver into a close enough future
time that is known to work (note: this is necessary only if the hardware
doesn't do this fast-forward by itself). But we don't really know what
is the status for PHC drivers in use today, so in the general sense,
user space would be risking to have a non-functional periodic output if
it simply asked for a start time of 0.000000000.

So let's introduce a flag for this type of reduced-functionality
hardware, named PTP_PEROUT_PHASE. The start time is just "soon", the
only thing we know for sure about this signal is that its rising edge
events, Rn, occur at:

Rn = perout.phase + n * perout.period

The "phase" in the periodic output structure is simply an alias to the
"start" time, since both cannot logically be specified at the same time.
Therefore, the binary layout of the structure is not affected.

[1]: https://patchwork.ozlabs.org/project/netdev/patch/20200320103726.32559-7-yangbo.lu@nxp.com/
[2]: https://www.mail-archive.com/linuxptp-devel@lists.sourceforge.net/msg04142.html

Signed-off-by: Vladimir Oltean <olteanv@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agoptp: add ability to configure duty cycle for periodic output
Vladimir Oltean [Thu, 16 Jul 2020 22:45:29 +0000 (01:45 +0300)]
ptp: add ability to configure duty cycle for periodic output

There are external event timestampers (PHCs with support for
PTP_EXTTS_REQUEST) that timestamp both event edges.

When those edges are very close (such as in the case of a short pulse),
there is a chance that the collected timestamp might be of the rising,
or of the falling edge, we never know.

There are also PHCs capable of generating periodic output with a
configurable duty cycle. This is good news, because we can space the
rising and falling edge out enough in time, that the risks to overrun
the 1-entry timestamp FIFO of the extts PHC are lower (example: the
perout PHC can be configured for a period of 1 second, and an "on" time
of 0.5 seconds, resulting in a duty cycle of 50%).

A flag is introduced for signaling that an on time is present in the
perout request structure, for preserving compatibility. Logically
speaking, the duty cycle cannot exceed 100% and the PTP core checks for
this.

PHC drivers that don't support this flag emit a periodic output of an
unspecified duty cycle, same as before.

The duty cycle is encoded as an "on" time, similar to the "start" and
"period" times, and reuses the reserved space while preserving overall
binary layout.

Pahole reported before:

struct ptp_perout_request {
        struct ptp_clock_time start;                     /*     0    16 */
        struct ptp_clock_time period;                    /*    16    16 */
        unsigned int               index;                /*    32     4 */
        unsigned int               flags;                /*    36     4 */
        unsigned int               rsv[4];               /*    40    16 */

        /* size: 56, cachelines: 1, members: 5 */
        /* last cacheline: 56 bytes */
};

And now:

struct ptp_perout_request {
        struct ptp_clock_time start;                     /*     0    16 */
        struct ptp_clock_time period;                    /*    16    16 */
        unsigned int               index;                /*    32     4 */
        unsigned int               flags;                /*    36     4 */
        union {
                struct ptp_clock_time on;                /*    40    16 */
                unsigned int       rsv[4];               /*    40    16 */
        };                                               /*    40    16 */

        /* size: 56, cachelines: 1, members: 5 */
        /* last cacheline: 56 bytes */
};

Signed-off-by: Vladimir Oltean <olteanv@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agoicmp: support rfc 4884
Willem de Bruijn [Fri, 10 Jul 2020 13:29:02 +0000 (09:29 -0400)]
icmp: support rfc 4884

Add setsockopt SOL_IP/IP_RECVERR_4884 to return the offset to an
extension struct if present.

ICMP messages may include an extension structure after the original
datagram. RFC 4884 standardized this behavior. It stores the offset
in words to the extension header in u8 icmphdr.un.reserved[1].

The field is valid only for ICMP types destination unreachable, time
exceeded and parameter problem, if length is at least 128 bytes and
entire packet does not exceed 576 bytes.

Return the offset to the start of the extension struct when reading an
ICMP error from the error queue, if it matches the above constraints.

Do not return the raw u8 field. Return the offset from the start of
the user buffer, in bytes. The kernel does not return the network and
transport headers, so subtract those.

Also validate the headers. Return the offset regardless of validation,
as an invalid extension must still not be misinterpreted as part of
the original datagram. Note that !invalid does not imply valid. If
the extension version does not match, no validation can take place,
for instance.

For backward compatibility, make this optional, set by setsockopt
SOL_IP/IP_RECVERR_RFC4884. For API example and feature test, see
github.com/wdebruij/kerneltools/blob/master/tests/recv_icmp_v2.c

For forward compatibility, reserve only setsockopt value 1, leaving
other bits for additional icmp extensions.

Changes
  v1->v2:
  - convert word offset to byte offset from start of user buffer
    - return in ee_data as u8 may be insufficient
  - define extension struct and object header structs
  - return len only if constraints met
  - if returning len, also validate

Signed-off-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agoMerge branch 'rework-mvneta-napi_poll-loop-for-XDP-multi-buffers'
David S. Miller [Mon, 20 Jul 2020 01:28:34 +0000 (18:28 -0700)]
Merge branch 'rework-mvneta-napi_poll-loop-for-XDP-multi-buffers'

Lorenzo Bianconi says:

====================
rework mvneta napi_poll loop for XDP multi-buffers

Rework mvneta_rx_swbm routine in order to process all rx descriptors before
building the skb or run the xdp program attached to the interface.
Introduce xdp_get_shared_info_from_{buff,frame} utility routines to get the
skb_shared_info pointer from xdp_buff or xdp_frame.
This is a preliminary series to enable multi-buffers and jumbo frames for XDP
according to [1]

[1] https://github.com/xdp-project/xdp-project/blob/master/areas/core/xdp-multi-buffer01-design.org

Changes since v1:
- rely on skb_frag_* utility routines to access page/offset/len of the xdp multi-buffer
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonet: mvneta: move rxq->left_size on the stack
Lorenzo Bianconi [Thu, 16 Jul 2020 22:16:34 +0000 (00:16 +0200)]
net: mvneta: move rxq->left_size on the stack

Allocate rxq->left_size on mvneta_rx_swbm stack since it is used just
in sw bm napi_poll

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonet: mvneta: get rid of skb in mvneta_rx_queue
Lorenzo Bianconi [Thu, 16 Jul 2020 22:16:33 +0000 (00:16 +0200)]
net: mvneta: get rid of skb in mvneta_rx_queue

Remove skb pointer in mvneta_rx_queue data structure since it is no
longer used

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonet: mvneta: drop all fragments in XDP_DROP
Lorenzo Bianconi [Thu, 16 Jul 2020 22:16:32 +0000 (00:16 +0200)]
net: mvneta: drop all fragments in XDP_DROP

Release all consumed pages if the eBPF program returns XDP_DROP for XDP
multi-buffers

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonet: mvneta: move mvneta_run_xdp after descriptors processing
Lorenzo Bianconi [Thu, 16 Jul 2020 22:16:31 +0000 (00:16 +0200)]
net: mvneta: move mvneta_run_xdp after descriptors processing

Move mvneta_run_xdp routine after all descriptor processing. This is a
preliminary patch to enable multi-buffers and JUMBO frames support for
XDP

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonet: mvneta: move skb build after descriptors processing
Lorenzo Bianconi [Thu, 16 Jul 2020 22:16:30 +0000 (00:16 +0200)]
net: mvneta: move skb build after descriptors processing

Move skb build after all descriptors processing. This is a preliminary
patch to enable multi-buffers and JUMBO frames support for XDP.
Introduce mvneta_xdp_put_buff routine to release all pages used by a
XDP multi-buffer

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agoxdp: introduce xdp_get_shared_info_from_{buff, frame} utility routines
Lorenzo Bianconi [Thu, 16 Jul 2020 22:16:29 +0000 (00:16 +0200)]
xdp: introduce xdp_get_shared_info_from_{buff, frame} utility routines

Introduce xdp_get_shared_info_from_{buff,frame} utility routines to get
skb_shared_info from xdp buffer/frame pointer.
xdp_get_shared_info_from_{buff,frame} will be used to implement xdp
multi-buffer support

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agoMerge branch 'do-a-single-memdup_user-in-sctp_setsockopt-v2'
David S. Miller [Mon, 20 Jul 2020 01:26:44 +0000 (18:26 -0700)]
Merge branch 'do-a-single-memdup_user-in-sctp_setsockopt-v2'

Christoph Hellwig says:

====================
do a single memdup_user in sctp_setsockopt v2

here is a resend of my series to lift the copy_from_user out of the
individual sctp sockopt handlers into the main sctp_setsockopt
routine.

Changes since v1:
 - fixes a few sizeof calls.
 - use memzero_explicit in sctp_setsockopt_auth_key instead of special
   casing it for a kzfree in the caller
 - remove some minor cleanups from sctp_setsockopt_autoclose to keep
   it closer to the existing version
 - add another little only vaguely related cleanup patch
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agosctp: remove the out_nounlock label in sctp_setsockopt
Christoph Hellwig [Sun, 19 Jul 2020 07:22:28 +0000 (09:22 +0200)]
sctp: remove the out_nounlock label in sctp_setsockopt

This is just used once, and a direct return for the redirect to the AF
case is much easier to follow than jumping to the end of a very long
function.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agosctp: pass a kernel pointer to sctp_setsockopt_pf_expose
Christoph Hellwig [Sun, 19 Jul 2020 07:22:27 +0000 (09:22 +0200)]
sctp: pass a kernel pointer to sctp_setsockopt_pf_expose

Use the kernel pointer that sctp_setsockopt has available instead of
directly handling the user pointer.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agosctp: pass a kernel pointer to sctp_setsockopt_ecn_supported
Christoph Hellwig [Sun, 19 Jul 2020 07:22:26 +0000 (09:22 +0200)]
sctp: pass a kernel pointer to sctp_setsockopt_ecn_supported

Use the kernel pointer that sctp_setsockopt has available instead of
directly handling the user pointer.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agosctp: pass a kernel pointer to sctp_setsockopt_auth_supported
Christoph Hellwig [Sun, 19 Jul 2020 07:22:25 +0000 (09:22 +0200)]
sctp: pass a kernel pointer to sctp_setsockopt_auth_supported

Use the kernel pointer that sctp_setsockopt has available instead of
directly handling the user pointer.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agosctp: pass a kernel pointer to sctp_setsockopt_event
Christoph Hellwig [Sun, 19 Jul 2020 07:22:24 +0000 (09:22 +0200)]
sctp: pass a kernel pointer to sctp_setsockopt_event

Use the kernel pointer that sctp_setsockopt has available instead of
directly handling the user pointer.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agosctp: pass a kernel pointer to sctp_setsockopt_event
Christoph Hellwig [Sun, 19 Jul 2020 07:22:23 +0000 (09:22 +0200)]
sctp: pass a kernel pointer to sctp_setsockopt_event

Use the kernel pointer that sctp_setsockopt has available instead of
directly handling the user pointer.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agosctp: pass a kernel pointer to sctp_setsockopt_reuse_port
Christoph Hellwig [Sun, 19 Jul 2020 07:22:22 +0000 (09:22 +0200)]
sctp: pass a kernel pointer to sctp_setsockopt_reuse_port

Use the kernel pointer that sctp_setsockopt has available instead of
directly handling the user pointer.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agosctp: pass a kernel pointer to sctp_setsockopt_interleaving_supported
Christoph Hellwig [Sun, 19 Jul 2020 07:22:21 +0000 (09:22 +0200)]
sctp: pass a kernel pointer to sctp_setsockopt_interleaving_supported

Use the kernel pointer that sctp_setsockopt has available instead of
directly handling the user pointer.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agosctp: pass a kernel pointer to sctp_setsockopt_scheduler_value
Christoph Hellwig [Sun, 19 Jul 2020 07:22:20 +0000 (09:22 +0200)]
sctp: pass a kernel pointer to sctp_setsockopt_scheduler_value

Use the kernel pointer that sctp_setsockopt has available instead of
directly handling the user pointer.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agosctp: pass a kernel pointer to sctp_setsockopt_scheduler
Christoph Hellwig [Sun, 19 Jul 2020 07:22:19 +0000 (09:22 +0200)]
sctp: pass a kernel pointer to sctp_setsockopt_scheduler

Use the kernel pointer that sctp_setsockopt has available instead of
directly handling the user pointer.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agosctp: pass a kernel pointer to sctp_setsockopt_add_streams
Christoph Hellwig [Sun, 19 Jul 2020 07:22:18 +0000 (09:22 +0200)]
sctp: pass a kernel pointer to sctp_setsockopt_add_streams

Use the kernel pointer that sctp_setsockopt has available instead of
directly handling the user pointer.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agosctp: pass a kernel pointer to sctp_setsockopt_reset_assoc
Christoph Hellwig [Sun, 19 Jul 2020 07:22:17 +0000 (09:22 +0200)]
sctp: pass a kernel pointer to sctp_setsockopt_reset_assoc

Use the kernel pointer that sctp_setsockopt has available instead of
directly handling the user pointer.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agosctp: pass a kernel pointer to sctp_setsockopt_reset_streams
Christoph Hellwig [Sun, 19 Jul 2020 07:22:16 +0000 (09:22 +0200)]
sctp: pass a kernel pointer to sctp_setsockopt_reset_streams

Use the kernel pointer that sctp_setsockopt has available instead of
directly handling the user pointer.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agosctp: pass a kernel pointer to sctp_setsockopt_enable_strreset
Christoph Hellwig [Sun, 19 Jul 2020 07:22:15 +0000 (09:22 +0200)]
sctp: pass a kernel pointer to sctp_setsockopt_enable_strreset

Use the kernel pointer that sctp_setsockopt has available instead of
directly handling the user pointer.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agosctp: pass a kernel pointer to sctp_setsockopt_reconfig_supported
Christoph Hellwig [Sun, 19 Jul 2020 07:22:14 +0000 (09:22 +0200)]
sctp: pass a kernel pointer to sctp_setsockopt_reconfig_supported

Use the kernel pointer that sctp_setsockopt has available instead of
directly handling the user pointer.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agosctp: pass a kernel pointer to sctp_setsockopt_default_prinfo
Christoph Hellwig [Sun, 19 Jul 2020 07:22:13 +0000 (09:22 +0200)]
sctp: pass a kernel pointer to sctp_setsockopt_default_prinfo

Use the kernel pointer that sctp_setsockopt has available instead of
directly handling the user pointer.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agosctp: pass a kernel pointer to sctp_setsockopt_pr_supported
Christoph Hellwig [Sun, 19 Jul 2020 07:22:12 +0000 (09:22 +0200)]
sctp: pass a kernel pointer to sctp_setsockopt_pr_supported

Use the kernel pointer that sctp_setsockopt has available instead of
directly handling the user pointer.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agosctp: pass a kernel pointer to sctp_setsockopt_recvnxtinfo
Christoph Hellwig [Sun, 19 Jul 2020 07:22:11 +0000 (09:22 +0200)]
sctp: pass a kernel pointer to sctp_setsockopt_recvnxtinfo

Use the kernel pointer that sctp_setsockopt has available instead of
directly handling the user pointer.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agosctp: pass a kernel pointer to sctp_setsockopt_recvrcvinfo
Christoph Hellwig [Sun, 19 Jul 2020 07:22:10 +0000 (09:22 +0200)]
sctp: pass a kernel pointer to sctp_setsockopt_recvrcvinfo

Use the kernel pointer that sctp_setsockopt has available instead of
directly handling the user pointer.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agosctp: pass a kernel pointer to sctp_setsockopt_paddr_thresholds
Christoph Hellwig [Sun, 19 Jul 2020 07:22:09 +0000 (09:22 +0200)]
sctp: pass a kernel pointer to sctp_setsockopt_paddr_thresholds

Use the kernel pointer that sctp_setsockopt has available instead of
directly handling the user pointer.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agosctp: pass a kernel pointer to sctp_setsockopt_auto_asconf
Christoph Hellwig [Sun, 19 Jul 2020 07:22:08 +0000 (09:22 +0200)]
sctp: pass a kernel pointer to sctp_setsockopt_auto_asconf

Use the kernel pointer that sctp_setsockopt has available instead of
directly handling the user pointer.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agosctp: pass a kernel pointer to sctp_setsockopt_deactivate_key
Christoph Hellwig [Sun, 19 Jul 2020 07:22:07 +0000 (09:22 +0200)]
sctp: pass a kernel pointer to sctp_setsockopt_deactivate_key

Use the kernel pointer that sctp_setsockopt has available instead of
directly handling the user pointer.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agosctp: pass a kernel pointer to sctp_setsockopt_del_key
Christoph Hellwig [Sun, 19 Jul 2020 07:22:06 +0000 (09:22 +0200)]
sctp: pass a kernel pointer to sctp_setsockopt_del_key

Use the kernel pointer that sctp_setsockopt has available instead of
directly handling the user pointer.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agosctp: pass a kernel pointer to sctp_setsockopt_active_key
Christoph Hellwig [Sun, 19 Jul 2020 07:22:05 +0000 (09:22 +0200)]
sctp: pass a kernel pointer to sctp_setsockopt_active_key

Use the kernel pointer that sctp_setsockopt has available instead of
directly handling the user pointer.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agosctp: pass a kernel pointer to sctp_setsockopt_auth_key
Christoph Hellwig [Sun, 19 Jul 2020 07:22:04 +0000 (09:22 +0200)]
sctp: pass a kernel pointer to sctp_setsockopt_auth_key

Use the kernel pointer that sctp_setsockopt has available instead of
directly handling the user pointer.  Adapt sctp_setsockopt to use a
kzfree for this case.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agosctp: switch sctp_setsockopt_auth_key to use memzero_explicit
Christoph Hellwig [Sun, 19 Jul 2020 07:22:03 +0000 (09:22 +0200)]
sctp: switch sctp_setsockopt_auth_key to use memzero_explicit

Switch from kzfree to sctp_setsockopt_auth_key + kfree to prepare for
moving the kfree to common code.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agosctp: pass a kernel pointer to sctp_setsockopt_hmac_ident
Christoph Hellwig [Sun, 19 Jul 2020 07:22:02 +0000 (09:22 +0200)]
sctp: pass a kernel pointer to sctp_setsockopt_hmac_ident

Use the kernel pointer that sctp_setsockopt has available instead of
directly handling the user pointer.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agosctp: pass a kernel pointer to sctp_setsockopt_auth_chunk
Christoph Hellwig [Sun, 19 Jul 2020 07:22:01 +0000 (09:22 +0200)]
sctp: pass a kernel pointer to sctp_setsockopt_auth_chunk

Use the kernel pointer that sctp_setsockopt has available instead of
directly handling the user pointer.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agosctp: pass a kernel pointer to sctp_setsockopt_maxburst
Christoph Hellwig [Sun, 19 Jul 2020 07:22:00 +0000 (09:22 +0200)]
sctp: pass a kernel pointer to sctp_setsockopt_maxburst

Use the kernel pointer that sctp_setsockopt has available instead of
directly handling the user pointer.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agosctp: pass a kernel pointer to sctp_setsockopt_fragment_interleave
Christoph Hellwig [Sun, 19 Jul 2020 07:21:59 +0000 (09:21 +0200)]
sctp: pass a kernel pointer to sctp_setsockopt_fragment_interleave

Use the kernel pointer that sctp_setsockopt has available instead of
directly handling the user pointer.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agosctp: pass a kernel pointer to sctp_setsockopt_context
Christoph Hellwig [Sun, 19 Jul 2020 07:21:58 +0000 (09:21 +0200)]
sctp: pass a kernel pointer to sctp_setsockopt_context

Use the kernel pointer that sctp_setsockopt has available instead of
directly handling the user pointer.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agosctp: pass a kernel pointer to sctp_setsockopt_adaptation_layer
Christoph Hellwig [Sun, 19 Jul 2020 07:21:57 +0000 (09:21 +0200)]
sctp: pass a kernel pointer to sctp_setsockopt_adaptation_layer

Use the kernel pointer that sctp_setsockopt has available instead of
directly handling the user pointer.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agosctp: pass a kernel pointer to sctp_setsockopt_maxseg
Christoph Hellwig [Sun, 19 Jul 2020 07:21:56 +0000 (09:21 +0200)]
sctp: pass a kernel pointer to sctp_setsockopt_maxseg

Use the kernel pointer that sctp_setsockopt has available instead of
directly handling the user pointer.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agosctp: pass a kernel pointer to sctp_setsockopt_mappedv4
Christoph Hellwig [Sun, 19 Jul 2020 07:21:55 +0000 (09:21 +0200)]
sctp: pass a kernel pointer to sctp_setsockopt_mappedv4

Use the kernel pointer that sctp_setsockopt has available instead of
directly handling the user pointer.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agosctp: pass a kernel pointer to sctp_setsockopt_associnfo
Christoph Hellwig [Sun, 19 Jul 2020 07:21:54 +0000 (09:21 +0200)]
sctp: pass a kernel pointer to sctp_setsockopt_associnfo

Use the kernel pointer that sctp_setsockopt has available instead of
directly handling the user pointer.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agosctp: pass a kernel pointer to sctp_setsockopt_rtoinfo
Christoph Hellwig [Sun, 19 Jul 2020 07:21:53 +0000 (09:21 +0200)]
sctp: pass a kernel pointer to sctp_setsockopt_rtoinfo

Use the kernel pointer that sctp_setsockopt has available instead of
directly handling the user pointer.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agosctp: pass a kernel pointer to sctp_setsockopt_nodelay
Christoph Hellwig [Sun, 19 Jul 2020 07:21:52 +0000 (09:21 +0200)]
sctp: pass a kernel pointer to sctp_setsockopt_nodelay

Use the kernel pointer that sctp_setsockopt has available instead of
directly handling the user pointer.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agosctp: pass a kernel pointer to sctp_setsockopt_peer_primary_addr
Christoph Hellwig [Sun, 19 Jul 2020 07:21:51 +0000 (09:21 +0200)]
sctp: pass a kernel pointer to sctp_setsockopt_peer_primary_addr

Use the kernel pointer that sctp_setsockopt has available instead of
directly handling the user pointer.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agosctp: pass a kernel pointer to sctp_setsockopt_primary_addr
Christoph Hellwig [Sun, 19 Jul 2020 07:21:50 +0000 (09:21 +0200)]
sctp: pass a kernel pointer to sctp_setsockopt_primary_addr

Use the kernel pointer that sctp_setsockopt has available instead of
directly handling the user pointer.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agosctp: pass a kernel pointer to sctp_setsockopt_default_sndinfo
Christoph Hellwig [Sun, 19 Jul 2020 07:21:49 +0000 (09:21 +0200)]
sctp: pass a kernel pointer to sctp_setsockopt_default_sndinfo

Use the kernel pointer that sctp_setsockopt has available instead of
directly handling the user pointer.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agosctp: pass a kernel pointer to sctp_setsockopt_default_send_param
Christoph Hellwig [Sun, 19 Jul 2020 07:21:48 +0000 (09:21 +0200)]
sctp: pass a kernel pointer to sctp_setsockopt_default_send_param

Use the kernel pointer that sctp_setsockopt has available instead of
directly handling the user pointer.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agosctp: pass a kernel pointer to sctp_setsockopt_initmsg
Christoph Hellwig [Sun, 19 Jul 2020 07:21:47 +0000 (09:21 +0200)]
sctp: pass a kernel pointer to sctp_setsockopt_initmsg

Use the kernel pointer that sctp_setsockopt has available instead of
directly handling the user pointer.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agosctp: pass a kernel pointer to sctp_setsockopt_partial_delivery_point
Christoph Hellwig [Sun, 19 Jul 2020 07:21:46 +0000 (09:21 +0200)]
sctp: pass a kernel pointer to sctp_setsockopt_partial_delivery_point

Use the kernel pointer that sctp_setsockopt has available instead of
directly handling the user pointer.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agosctp: pass a kernel pointer to sctp_setsockopt_delayed_ack
Christoph Hellwig [Sun, 19 Jul 2020 07:21:45 +0000 (09:21 +0200)]
sctp: pass a kernel pointer to sctp_setsockopt_delayed_ack

Use the kernel pointer that sctp_setsockopt has available instead of
directly handling the user pointer.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agosctp: pass a kernel pointer to sctp_setsockopt_peer_addr_params
Christoph Hellwig [Sun, 19 Jul 2020 07:21:44 +0000 (09:21 +0200)]
sctp: pass a kernel pointer to sctp_setsockopt_peer_addr_params

Use the kernel pointer that sctp_setsockopt has available instead of
directly handling the user pointer.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agosctp: pass a kernel pointer to sctp_setsockopt_autoclose
Christoph Hellwig [Sun, 19 Jul 2020 07:21:43 +0000 (09:21 +0200)]
sctp: pass a kernel pointer to sctp_setsockopt_autoclose

Use the kernel pointer that sctp_setsockopt has available instead of
directly handling the user pointer.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agosctp: pass a kernel pointer to sctp_setsockopt_events
Christoph Hellwig [Sun, 19 Jul 2020 07:21:42 +0000 (09:21 +0200)]
sctp: pass a kernel pointer to sctp_setsockopt_events

Use the kernel pointer that sctp_setsockopt has available instead of
directly handling the user pointer.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agosctp: pass a kernel pointer to sctp_setsockopt_disable_fragments
Christoph Hellwig [Sun, 19 Jul 2020 07:21:41 +0000 (09:21 +0200)]
sctp: pass a kernel pointer to sctp_setsockopt_disable_fragments

Use the kernel pointer that sctp_setsockopt has available instead of
directly handling the user pointer.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agosctp: pass a kernel pointer to __sctp_setsockopt_connectx
Christoph Hellwig [Sun, 19 Jul 2020 07:21:40 +0000 (09:21 +0200)]
sctp: pass a kernel pointer to __sctp_setsockopt_connectx

Use the kernel pointer that sctp_setsockopt has available instead of
directly handling the user pointer.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agosctp: pass a kernel pointer to sctp_setsockopt_bindx
Christoph Hellwig [Sun, 19 Jul 2020 07:21:39 +0000 (09:21 +0200)]
sctp: pass a kernel pointer to sctp_setsockopt_bindx

Rename sctp_setsockopt_bindx_kernel back to sctp_setsockopt_bindx,
and use the kernel pointer that sctp_setsockopt has available instead of
directly handling the user pointer in the old sctp_setsockopt_bindx.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agosctp: copy the optval from user space in sctp_setsockopt
Christoph Hellwig [Sun, 19 Jul 2020 07:21:38 +0000 (09:21 +0200)]
sctp: copy the optval from user space in sctp_setsockopt

Prepare for for moving the copy_from_user from the individual sockopts
to the main setsockopt helper.  As of this commit the kopt variable
is not used yet, but the following commits will start using it.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agoMerge branch 'sockopt-cleanups'
David S. Miller [Mon, 20 Jul 2020 01:16:41 +0000 (18:16 -0700)]
Merge branch 'sockopt-cleanups'

Christoph Hellwig says:

====================
sockopt cleanups

this series cleans up various lose ends in the sockopt code, most
importantly removing the compat_{get,set}sockopt infrastructure in favor
of just using in_compat_syscall() in the few places that care.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonet: make ->{get,set}sockopt in proto_ops optional
Christoph Hellwig [Fri, 17 Jul 2020 06:23:31 +0000 (08:23 +0200)]
net: make ->{get,set}sockopt in proto_ops optional

Just check for a NULL method instead of wiring up
sock_no_{get,set}sockopt.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonet/ipv6: remove compat_ipv6_{get,set}sockopt
Christoph Hellwig [Fri, 17 Jul 2020 06:23:30 +0000 (08:23 +0200)]
net/ipv6: remove compat_ipv6_{get,set}sockopt

Handle the few cases that need special treatment in-line using
in_compat_syscall().  This also removes all the now unused
compat_{get,set}sockopt methods.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonet/ipv6: factor out mcast join/leave setsockopt helpers
Christoph Hellwig [Fri, 17 Jul 2020 06:23:29 +0000 (08:23 +0200)]
net/ipv6: factor out mcast join/leave setsockopt helpers

Factor out one helper each for setting the native and compat
version of the MCAST_MSFILTER option.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonet/ipv6: factor out MCAST_MSFILTER setsockopt helpers
Christoph Hellwig [Fri, 17 Jul 2020 06:23:28 +0000 (08:23 +0200)]
net/ipv6: factor out MCAST_MSFILTER setsockopt helpers

Factor out one helper each for setting the native and compat
version of the MCAST_MSFILTER option.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonet/ipv6: factor out MCAST_MSFILTER getsockopt helpers
Christoph Hellwig [Fri, 17 Jul 2020 06:23:27 +0000 (08:23 +0200)]
net/ipv6: factor out MCAST_MSFILTER getsockopt helpers

Factor out one helper each for getting the native and compat
version of the MCAST_MSFILTER option.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonet/ipv4: remove compat_ip_{get,set}sockopt
Christoph Hellwig [Fri, 17 Jul 2020 06:23:26 +0000 (08:23 +0200)]
net/ipv4: remove compat_ip_{get,set}sockopt

Handle the few cases that need special treatment in-line using
in_compat_syscall().

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonet/ipv4: factor out mcast join/leave setsockopt helpers
Christoph Hellwig [Fri, 17 Jul 2020 06:23:25 +0000 (08:23 +0200)]
net/ipv4: factor out mcast join/leave setsockopt helpers

Factor out one helper each for setting the native and compat
version of the MCAST_MSFILTER option.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonet/ipv4: factor out MCAST_MSFILTER setsockopt helpers
Christoph Hellwig [Fri, 17 Jul 2020 06:23:24 +0000 (08:23 +0200)]
net/ipv4: factor out MCAST_MSFILTER setsockopt helpers

Factor out one helper each for setting the native and compat
version of the MCAST_MSFILTER option.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonet/ipv4: factor out MCAST_MSFILTER getsockopt helpers
Christoph Hellwig [Fri, 17 Jul 2020 06:23:23 +0000 (08:23 +0200)]
net/ipv4: factor out MCAST_MSFILTER getsockopt helpers

Factor out one helper each for getting the native and compat
version of the MCAST_MSFILTER option.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonetfilter: split nf_sockopt
Christoph Hellwig [Fri, 17 Jul 2020 06:23:22 +0000 (08:23 +0200)]
netfilter: split nf_sockopt

Split nf_sockopt into a getsockopt and setsockopt side as they share
very little code.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonetfilter: remove the compat argument to xt_copy_counters_from_user
Christoph Hellwig [Fri, 17 Jul 2020 06:23:21 +0000 (08:23 +0200)]
netfilter: remove the compat argument to xt_copy_counters_from_user

Lift the in_compat_syscall() from the callers instead.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonetfilter: remove the compat_{get,set} methods
Christoph Hellwig [Fri, 17 Jul 2020 06:23:20 +0000 (08:23 +0200)]
netfilter: remove the compat_{get,set} methods

All instances handle compat sockopts via in_compat_syscall() now, so
remove the compat_{get,set} methods as well as the
compat_nf_{get,set}sockopt wrappers.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonetfilter/ebtables: clean up compat {get, set}sockopt handling
Christoph Hellwig [Fri, 17 Jul 2020 06:23:19 +0000 (08:23 +0200)]
netfilter/ebtables: clean up compat {get, set}sockopt handling

Merge the native and compat {get,set}sockopt handlers using
in_compat_syscall().  Note that this required moving a fair
amout of code around to be done sanely.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonetfilter/ip6_tables: clean up compat {get, set}sockopt handling
Christoph Hellwig [Fri, 17 Jul 2020 06:23:18 +0000 (08:23 +0200)]
netfilter/ip6_tables: clean up compat {get, set}sockopt handling

Merge the native and compat {get,set}sockopt handlers using
in_compat_syscall().

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonetfilter/ip_tables: clean up compat {get,set}sockopt handling
Christoph Hellwig [Fri, 17 Jul 2020 06:23:17 +0000 (08:23 +0200)]
netfilter/ip_tables: clean up compat {get,set}sockopt handling

Merge the native and compat {get,set}sockopt handlers using
in_compat_syscall().

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonetfilter/arp_tables: clean up compat {get, set}sockopt handling
Christoph Hellwig [Fri, 17 Jul 2020 06:23:16 +0000 (08:23 +0200)]
netfilter/arp_tables: clean up compat {get, set}sockopt handling

Merge the native and compat {get,set}sockopt handlers using
in_compat_syscall().

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonet: remove compat_sys_{get,set}sockopt
Christoph Hellwig [Fri, 17 Jul 2020 06:23:15 +0000 (08:23 +0200)]
net: remove compat_sys_{get,set}sockopt

Now that the ->compat_{get,set}sockopt proto_ops methods are gone
there is no good reason left to keep the compat syscalls separate.

This fixes the odd use of unsigned int for the compat_setsockopt
optlen and the missing sock_use_custom_sol_socket.

It would also easily allow running the eBPF hooks for the compat
syscalls, but such a large change in behavior does not belong into
a consolidation patch like this one.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonet: remove compat_sock_common_{get,set}sockopt
Christoph Hellwig [Fri, 17 Jul 2020 06:23:14 +0000 (08:23 +0200)]
net: remove compat_sock_common_{get,set}sockopt

Add the compat handling to sock_common_{get,set}sockopt instead,
keyed of in_compat_syscall().  This allow to remove the now unused
->compat_{get,set}sockopt methods from struct proto_ops.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Matthieu Baerts <matthieu.baerts@tessares.net>
Acked-by: Stefan Schmidt <stefan@datenfreihafen.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonet: simplify cBPF setsockopt compat handling
Christoph Hellwig [Fri, 17 Jul 2020 06:23:13 +0000 (08:23 +0200)]
net: simplify cBPF setsockopt compat handling

Add a helper that copies either a native or compat bpf_fprog from
userspace after verifying the length, and remove the compat setsockopt
handlers that now aren't required.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonet: streamline __sys_getsockopt
Christoph Hellwig [Fri, 17 Jul 2020 06:23:12 +0000 (08:23 +0200)]
net: streamline __sys_getsockopt

Return early when sockfd_lookup_light fails to reduce a level of
indentation for most of the function body.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: David S. Miller <davem@davemloft.net>