* Re: [iproute PATCH] tc-simple: Fix documentation
From: Stephen Hemminger @ 2017-08-03 23:03 UTC (permalink / raw)
To: Phil Sutter; +Cc: netdev
In-Reply-To: <20170803150051.19741-1-phil@nwl.cc>
On Thu, 3 Aug 2017 17:00:51 +0200
Phil Sutter <phil@nwl.cc> wrote:
> - CONTROL has to come last, otherwise 'index' applies to gact and not
> simple itself.
> - Man page wasn't updated to reflect syntax changes.
>
> Signed-off-by: Phil Sutter <phil@nwl.cc>
Applid, thanks Phil
^ permalink raw reply
* Re: [iproute PATCH] Really fix get_addr() and get_prefix() error messages
From: Stephen Hemminger @ 2017-08-03 23:02 UTC (permalink / raw)
To: Phil Sutter; +Cc: netdev
In-Reply-To: <20170801163611.10094-1-phil@nwl.cc>
On Tue, 1 Aug 2017 18:36:11 +0200
Phil Sutter <phil@nwl.cc> wrote:
> Both functions take the desired address family as a parameter. So using
> that to notify the user what address family was expected is correct,
> unlike using dst->family which will tell the user only what address
> family was specified.
>
> The situation which commit 334af76143368 tried to fix was when 'ip'
> would accept addresses from multiple families. In that case, the family
> parameter is set to AF_UNSPEC so that get_addr_1() may accept any valid
> address.
>
> This patch introduces a wrapper around family_name() which returns the
> string "any valid" for AF_UNSPEC instead of the three question marks
> unsuitable for use in error messages.
>
> Tests for AF_UNSPEC:
>
> | # ip a a 256.10.166.1/24 dev d0
> | Error: any valid prefix is expected rather than "256.10.166.1/24".
>
> | # ip neighbor add proxy 2001:db8::g dev d0
> | Error: any valid address is expected rather than "2001:db8::g".
>
> Tests for explicit address family:
>
> | # ip -6 addrlabel add prefix 1.1.1.1/24 label 123
> | Error: inet6 prefix is expected rather than "1.1.1.1/24".
>
> | # ip -4 addrlabel add prefix dead:beef::1/24 label 123
> | Error: inet prefix is expected rather than "dead:beef::1/24".
>
> Reported-by: Jaroslav Aster <jaster@redhat.com>
> Fixes: 334af76143368 ("fix get_addr() and get_prefix() error messages")
> Signed-off-by: Phil Sutter <phil@nwl.cc>
Moderately more helpful, so sure.
^ permalink raw reply
* Re: [iproute PATCH] bpf: Make bytecode-file reading a little more robust
From: Stephen Hemminger @ 2017-08-03 22:59 UTC (permalink / raw)
To: Phil Sutter; +Cc: netdev, Daniel Borkmann
In-Reply-To: <20170802125756.26210-1-phil@nwl.cc>
On Wed, 2 Aug 2017 14:57:56 +0200
Phil Sutter <phil@nwl.cc> wrote:
> bpf_parse_string() will now correctly handle:
>
> - Extraneous whitespace,
> - OPs on multiple lines and
> - overlong file names.
>
> The added feature of allowing to have OPs on multiple lines (like e.g.
> tcpdump prints them) is rather a side effect of fixing detection of
> malformed bytecode files having random content on a second line, like
> e.g.:
>
> | 4,40 0 0 12,21 0 1 2048,6 0 0 262144,6 0 0 0
> | foobar
>
> Cc: Daniel Borkmann <daniel@iogearbox.net>
> Signed-off-by: Phil Sutter <phil@nwl.cc>
Looks good applied.
^ permalink raw reply
* Re: [patch net-next 00/21] mlxsw: Support for IPv6 UC router
From: David Ahern @ 2017-08-03 22:54 UTC (permalink / raw)
To: David Miller
Cc: jiri, netdev, idosch, mlxsw, roopa, nikolay, kafai, hannes,
yoshfuji, edumazet, yanhaishuang
In-Reply-To: <20170803.154124.2094532576602544160.davem@davemloft.net>
On 8/3/17 4:41 PM, David Miller wrote:
> But unlike the percpu flag, don't we want to somehow propagate offload
> state to the user?
It's a per nexthop flag. For IPv4 it is tracked in fib_nh.nh_flags.
Perhaps it is time for rt6_info to have nh_flags as well.
>
> I'm sure whatever we decide Jiri will send and appropriate follow-up
> so don't panic :)
>
^ permalink raw reply
* Re: [PATCH v4] ss: Enclose IPv6 address in brackets
From: Stephen Hemminger @ 2017-08-03 22:54 UTC (permalink / raw)
To: Florian Lehner; +Cc: netdev
In-Reply-To: <821a72fb-3758-8a44-2b1e-727a73208e14@der-flo.net>
On Tue, 1 Aug 2017 18:54:33 +0200
Florian Lehner <dev@der-flo.net> wrote:
> - if (a->family == AF_INET) {
> - if (a->data[0] == 0) {
> + if (a->data[0] == 0) {
> buf[0] = '*';
> buf[1] = 0;
This won't work right with IPv6 you need to look at the whole address being 0
not just a->data[0]
^ permalink raw reply
* Re: [iproute PATCH] iplink: Notify user if EEXIST error might be spurious
From: Stephen Hemminger @ 2017-08-03 22:52 UTC (permalink / raw)
To: Phil Sutter; +Cc: netdev
In-Reply-To: <20170801172747.2817-1-phil@nwl.cc>
On Tue, 1 Aug 2017 19:27:47 +0200
Phil Sutter <phil@nwl.cc> wrote:
> Back in the days when RTM_NEWLINK wasn't yet implemented, people had to
> rely upon kernel modules to create (virtual) interfaces for them. The
> number of those was usually defined via module parameter, and a sane
> default value was chosen. Now that iproute2 allows users to instantiate
> new interfaces at will, this is no longer required - though for
> backwards compatibility reasons, we're stuck with both methods which
> collide at the point when one tries to create an interface with a
> standard name for a type which exists in a kernel module: The kernel
> will load the module, which instantiates the interface and the following
> RTM_NEWLINK request will fail since the interface exists already. For
> instance:
>
> | # lsmod | grep dummy
> | # ip link show | grep dummy0
> | # ip link add dummy0 type dummy
> | RTNETLINK answers: File exists
> | # ip link show | grep -c dummy0
> | 1
>
> There is no race-free solution in userspace for this dilemma as far as I
> can tell, so try to detect whether a user might have run into this and
> notify that the given error message might be irrelevant.
>
> Signed-off-by: Phil Sutter <phil@nwl.cc>
There is already a workable solution. There is already module parameters to block autocreation
in bonding and dummy network device. The others should have it as well.
This patch just seems like creating more clutter.
^ permalink raw reply
* Re: [patch net-next 00/21] mlxsw: Support for IPv6 UC router
From: David Miller @ 2017-08-03 22:41 UTC (permalink / raw)
To: dsahern
Cc: jiri, netdev, idosch, mlxsw, roopa, nikolay, kafai, hannes,
yoshfuji, edumazet, yanhaishuang
In-Reply-To: <d6bd0d34-b69f-10c2-059d-a45b1dfae80f@gmail.com>
From: David Ahern <dsahern@gmail.com>
Date: Thu, 3 Aug 2017 16:39:54 -0600
> On 8/3/17 4:36 PM, David Miller wrote:
>> From: Jiri Pirko <jiri@resnulli.us>
>> Date: Thu, 3 Aug 2017 13:28:10 +0200
>>
>>> This set adds support for IPv6 unicast routes offload.
>>
>> Series applied, thanks.
>>
>
> I take it you disagree with my comment on patch 10 about the RTF_OFFLOAD
> flag? that is a nexthop flag and has no business being part of the UAPI
> for IPv6.
Oh crap, I missed that.
But unlike the percpu flag, don't we want to somehow propagate offload
state to the user?
I'm sure whatever we decide Jiri will send and appropriate follow-up
so don't panic :)
^ permalink raw reply
* Re: [patch net-next 00/21] mlxsw: Support for IPv6 UC router
From: David Ahern @ 2017-08-03 22:39 UTC (permalink / raw)
To: David Miller, jiri
Cc: netdev, idosch, mlxsw, roopa, nikolay, kafai, hannes, yoshfuji,
edumazet, yanhaishuang
In-Reply-To: <20170803.153631.974713672754752484.davem@davemloft.net>
On 8/3/17 4:36 PM, David Miller wrote:
> From: Jiri Pirko <jiri@resnulli.us>
> Date: Thu, 3 Aug 2017 13:28:10 +0200
>
>> This set adds support for IPv6 unicast routes offload.
>
> Series applied, thanks.
>
I take it you disagree with my comment on patch 10 about the RTF_OFFLOAD
flag? that is a nexthop flag and has no business being part of the UAPI
for IPv6.
^ permalink raw reply
* Re: [PATCH net-next v2 00/13] Change DSA's FDB API and perform switchdev cleanup
From: Arkadi Sharshevsky @ 2017-08-03 22:39 UTC (permalink / raw)
To: Vivien Didelot, netdev, jiri
Cc: davem, ivecera, f.fainelli, andrew, Woojung.Huh, stephen, mlxsw
In-Reply-To: <ede22100-3a66-f54d-a618-a3b840a2664c@mellanox.com>
[...]
>> Now we have the "offload" read only flag, which is good to inform about
>> a successfully programmed hardware, but adds another level of complexity
>> to understand the interaction with the hardware.
>>
>> I think iproute2 is getting more and more confusing. From what I
>> understood, respecting the "self" flag as described is not possible
>> anymore due to some retro-compatibility reasons.
>>
>> Also Linux must use the hardware as an accelerator (so "self" or
>> "offload" must be the default), and always fall back to software
>> otherwise, hence "master" do not make sense here.
>>
>> What do you think about this synopsis for bridge fdb add?
>>
>> # bridge fdb add LLADDR dev DEV [ offload { on | off } ]
>>
>> Where offload defaults to "on". This option should also be ported to
>> other offloaded features like MDB and VLAN. Even though this is a bit
>> out of scope of this patchset, do you think this is feasible?
>>
>
> I agree completely that currently its confusing. The documentation
> should be updated for sure. I think that 'self' was primarily introduced
> (Commit 77162022a) for NIC embedded switches which are used for sriov, in
> that case the self is related to the internal eswitch, which completely
> diverge from the software one (clearly not swithcdev).
>
> IMHO For switchdev devices 'self' should not be an option at all, or any
> other arg regarding hardware. Furthermore, the 'offload' flag should be
> only relevant during the dump as an indication to the user.
>
> Unfortunately, the lack of ability of syncing the sw with hw in DSA's
> case introduces a problem for indicating that the entries are only
> in hw, I mean marking it only as offloaded is not enough.
Hi,
It seems impossible currently to move the self to be the default, and
this introduces regression which you don't approve, so it seems few
options left:
a) Leave two ways to add fdb, through the bridge (by using the master
flag) which is introduced in this patchset, and by using the self
which is the legacy way. In this way no regression will be introduced,
yet, it feels confusing a bit. The benefit is that we (DSA/mlxsw)
will be synced.
b) Leave only the self (which means removing patch no 4,5).
In both cases the switchdev implementation of .ndo_fdb_add() will be
moved inside DSA in a similar way to the dump because its only used by
you.
Option b) actually turns this patchset into cosmetic one which does
only cleanup.
Thanks,
Arkadi
^ permalink raw reply
* Re: [PATCH v2 net 0/3] tcp: fix xmit timer rearming to avoid stalls
From: David Miller @ 2017-08-03 22:39 UTC (permalink / raw)
To: ncardwell; +Cc: netdev
In-Reply-To: <20170803131954.15441-1-ncardwell@google.com>
From: Neal Cardwell <ncardwell@google.com>
Date: Thu, 3 Aug 2017 09:19:51 -0400
> This patch series is a bug fix for a TCP loss recovery performance bug
> reported independently in recent netdev threads:
>
> (i) July 26, 2017: netdev thread "TCP fast retransmit issues"
> (ii) July 26, 2017: netdev thread:
> "[PATCH V2 net-next] TLP: Don't reschedule PTO when there's one
> outstanding TLP retransmission"
>
> Many thanks to Klavs Klavsen and Mao Wenan for the detailed reports,
> traces, and packetdrill test cases, which enabled us to root-cause
> this issue and verify the fix.
>
> - v1 -> v2:
> - In patch 2/3, changed an unclear comment in the pre-existing code
> in tcp_schedule_loss_probe() to be more clear (thanks to Eric Dumazet
> for suggesting we improve this).
Series applied, thanks Neal.
^ permalink raw reply
* Re: [patch net-next 00/21] mlxsw: Support for IPv6 UC router
From: David Miller @ 2017-08-03 22:36 UTC (permalink / raw)
To: jiri
Cc: netdev, idosch, mlxsw, dsahern, roopa, nikolay, kafai, hannes,
yoshfuji, edumazet, yanhaishuang
In-Reply-To: <20170803112831.1831-1-jiri@resnulli.us>
From: Jiri Pirko <jiri@resnulli.us>
Date: Thu, 3 Aug 2017 13:28:10 +0200
> This set adds support for IPv6 unicast routes offload.
Series applied, thanks.
^ permalink raw reply
* Re: [PATCH V3 net-next 03/21] net-next/hinic: Initialize api cmd resources
From: David Miller @ 2017-08-03 22:35 UTC (permalink / raw)
To: aviad.krawczyk
Cc: linux-kernel, netdev, bc.y, victor.gissin, zhaochen6, tony.qu
In-Reply-To: <18d3bfccc0eb9c7da53075c6fe2ba9aa583e0bff.1501752425.git.aviad.krawczyk@huawei.com>
From: Aviad Krawczyk <aviad.krawczyk@huawei.com>
Date: Thu, 3 Aug 2017 17:54:09 +0800
> +static int alloc_cmd_buf(struct hinic_api_cmd_chain *chain,
> + struct hinic_api_cmd_cell *cell, int cell_idx)
> +{
> + struct hinic_hwif *hwif = chain->hwif;
> + struct pci_dev *pdev = hwif->pdev;
> + struct hinic_api_cmd_cell_ctxt *cell_ctxt;
> + dma_addr_t cmd_paddr;
> + u8 *cmd_vaddr;
> + int err = 0;
Order local variables from longest to shortest line.
> +static int api_cmd_create_cell(struct hinic_api_cmd_chain *chain,
> + int cell_idx,
> + struct hinic_api_cmd_cell *pre_node,
> + struct hinic_api_cmd_cell **node_vaddr)
> +{
> + struct hinic_hwif *hwif = chain->hwif;
> + struct pci_dev *pdev = hwif->pdev;
> + struct hinic_api_cmd_cell_ctxt *cell_ctxt;
> + struct hinic_api_cmd_cell *node;
> + dma_addr_t node_paddr;
> + int err;
Likewise.
> +static void api_cmd_destroy_cell(struct hinic_api_cmd_chain *chain,
> + int cell_idx)
> +{
> + struct hinic_hwif *hwif = chain->hwif;
> + struct pci_dev *pdev = hwif->pdev;
> + struct hinic_api_cmd_cell_ctxt *cell_ctxt;
> + struct hinic_api_cmd_cell *node;
> + dma_addr_t node_paddr;
> + size_t node_size;
Likewise.
etc. etc. etc.
Please audit your entire submission for this problem.
Thanks.
^ permalink raw reply
* Re: [PATCH V3 net-next 02/21] net-next/hinic: Initialize hw device components
From: David Miller @ 2017-08-03 22:34 UTC (permalink / raw)
To: aviad.krawczyk
Cc: linux-kernel, netdev, bc.y, victor.gissin, zhaochen6, tony.qu
In-Reply-To: <f15df6eed91d1a2b05864be90928b8e778d270e2.1501752425.git.aviad.krawczyk@huawei.com>
From: Aviad Krawczyk <aviad.krawczyk@huawei.com>
Date: Thu, 3 Aug 2017 17:54:08 +0800
> +static int get_capability(struct hinic_hwdev *hwdev,
> + struct hinic_dev_cap *dev_cap)
> +{
> + struct hinic_hwif *hwif = hwdev->hwif;
> + struct hinic_cap *nic_cap = &hwdev->nic_cap;
> + int num_aeqs, num_ceqs, num_irqs, num_qps;
Please order local variable declarations from longest to shortest
line (aka: reverse christmas tree order).
Move the initialization down into the code if that is necessary
to achiever this.
> +static int get_dev_cap(struct hinic_hwdev *hwdev)
> +{
> + struct hinic_pfhwdev *pfhwdev;
> + struct hinic_hwif *hwif = hwdev->hwif;
> + struct pci_dev *pdev = hwif->pdev;
> + int err;
Likewise.
^ permalink raw reply
* Re: [PATCH net-next v2 0/7] net: mvpp2: add TX interrupts support
From: David Miller @ 2017-08-03 22:16 UTC (permalink / raw)
To: thomas.petazzoni
Cc: netdev, nadavh, hannah, yehuday, stefanc, mw, antoine.tenart,
jason, andrew, sebastian.hesselbarth, gregory.clement,
miquel.raynal, linux-arm-kernel
In-Reply-To: <20170803084201.30305-1-thomas.petazzoni@free-electrons.com>
From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Date: Thu, 3 Aug 2017 10:41:54 +0200
> So far, the mvpp2 driver was using an hrtimer to handle TX
> completion. This patch series adds support for using TX interrupts
> (for each CPU) on PPv2.2, the variant of the IP used on Marvell Armada
> 7K/8K.
>
> Dave: this version can be applied right away, it no longer depends on
> Antoine's patch series. Antoine series had some comments, so he will
> have to respin later on. Therefore, let's merge this smaller patch
> series first.
>
> Changes since v1:
>
> - Rebased on top of net-next, instead of on top of Antoine's series.
>
> - Removed the Device Tree patch, as it shouldn't go through the net
> tree.
Series applied.
^ permalink raw reply
* Re: [PATCH] PCI: Update ACS quirk for more Intel 10G NICs
From: Alex Williamson @ 2017-08-03 22:16 UTC (permalink / raw)
To: Bjorn Helgaas
Cc: Roland Dreier, Bjorn Helgaas, linux-pci, netdev, Emil Tantilov
In-Reply-To: <20170803214911.GG20308@bhelgaas-glaptop.roam.corp.google.com>
On Thu, 3 Aug 2017 16:49:11 -0500
Bjorn Helgaas <helgaas@kernel.org> wrote:
> On Thu, Jul 20, 2017 at 02:41:01PM -0700, Roland Dreier wrote:
> > From: Roland Dreier <roland@purestorage.com>
> >
> > Add one more variant of the 82599 plus the device IDs for X540 and X550
> > variants. Intel has confirmed that none of these devices does peer-to-peer
> > between functions. The X540 and X550 have added ACS capabilities in their
> > PCI config space, but the ACS control register is hard-wired to 0 for both
> > devices, so we still need the quirk for IOMMU grouping to allow assignment
> > of individual SR-IOV functions.
> >
> > Signed-off-by: Roland Dreier <roland@purestorage.com>
>
> I haven't seen a real conclusion to the discussion yet, so I'm waiting on
> that and hopefully an ack from Alex. Can you please repost with that,
> since I'm dropping it from patchwork for now?
I think the conclusion is that a hard-wired ACS capability is a
positive indication of isolation for a multifunction device, the code
is intended to support this and appears to do so, and Roland was going
to investigate the sightings that inspired this patch in more detail.
Dropping for now is appropriate. Thanks,
Alex
> > ---
> > drivers/pci/quirks.c | 21 +++++++++++++++++++++
> > 1 file changed, 21 insertions(+)
> >
> > diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
> > index 6967c6b4cf6b..b939db671326 100644
> > --- a/drivers/pci/quirks.c
> > +++ b/drivers/pci/quirks.c
> > @@ -4335,12 +4335,33 @@ static const struct pci_dev_acs_enabled {
> > { PCI_VENDOR_ID_INTEL, 0x1507, pci_quirk_mf_endpoint_acs },
> > { PCI_VENDOR_ID_INTEL, 0x1514, pci_quirk_mf_endpoint_acs },
> > { PCI_VENDOR_ID_INTEL, 0x151C, pci_quirk_mf_endpoint_acs },
> > + { PCI_VENDOR_ID_INTEL, 0x1528, pci_quirk_mf_endpoint_acs },
> > { PCI_VENDOR_ID_INTEL, 0x1529, pci_quirk_mf_endpoint_acs },
> > + { PCI_VENDOR_ID_INTEL, 0x154A, pci_quirk_mf_endpoint_acs },
> > { PCI_VENDOR_ID_INTEL, 0x152A, pci_quirk_mf_endpoint_acs },
> > { PCI_VENDOR_ID_INTEL, 0x154D, pci_quirk_mf_endpoint_acs },
> > { PCI_VENDOR_ID_INTEL, 0x154F, pci_quirk_mf_endpoint_acs },
> > { PCI_VENDOR_ID_INTEL, 0x1551, pci_quirk_mf_endpoint_acs },
> > { PCI_VENDOR_ID_INTEL, 0x1558, pci_quirk_mf_endpoint_acs },
> > + { PCI_VENDOR_ID_INTEL, 0x1560, pci_quirk_mf_endpoint_acs },
> > + { PCI_VENDOR_ID_INTEL, 0x1563, pci_quirk_mf_endpoint_acs },
> > + { PCI_VENDOR_ID_INTEL, 0x15AA, pci_quirk_mf_endpoint_acs },
> > + { PCI_VENDOR_ID_INTEL, 0x15AB, pci_quirk_mf_endpoint_acs },
> > + { PCI_VENDOR_ID_INTEL, 0x15AC, pci_quirk_mf_endpoint_acs },
> > + { PCI_VENDOR_ID_INTEL, 0x15AD, pci_quirk_mf_endpoint_acs },
> > + { PCI_VENDOR_ID_INTEL, 0x15AE, pci_quirk_mf_endpoint_acs },
> > + { PCI_VENDOR_ID_INTEL, 0x15B0, pci_quirk_mf_endpoint_acs },
> > + { PCI_VENDOR_ID_INTEL, 0x15AB, pci_quirk_mf_endpoint_acs },
> > + { PCI_VENDOR_ID_INTEL, 0x15C2, pci_quirk_mf_endpoint_acs },
> > + { PCI_VENDOR_ID_INTEL, 0x15C3, pci_quirk_mf_endpoint_acs },
> > + { PCI_VENDOR_ID_INTEL, 0x15C4, pci_quirk_mf_endpoint_acs },
> > + { PCI_VENDOR_ID_INTEL, 0x15C6, pci_quirk_mf_endpoint_acs },
> > + { PCI_VENDOR_ID_INTEL, 0x15C7, pci_quirk_mf_endpoint_acs },
> > + { PCI_VENDOR_ID_INTEL, 0x15C8, pci_quirk_mf_endpoint_acs },
> > + { PCI_VENDOR_ID_INTEL, 0x15CE, pci_quirk_mf_endpoint_acs },
> > + { PCI_VENDOR_ID_INTEL, 0x15E4, pci_quirk_mf_endpoint_acs },
> > + { PCI_VENDOR_ID_INTEL, 0x15E5, pci_quirk_mf_endpoint_acs },
> > + { PCI_VENDOR_ID_INTEL, 0x15D1, pci_quirk_mf_endpoint_acs },
> > /* 82580 */
> > { PCI_VENDOR_ID_INTEL, 0x1509, pci_quirk_mf_endpoint_acs },
> > { PCI_VENDOR_ID_INTEL, 0x150E, pci_quirk_mf_endpoint_acs },
> > --
> > 2.11.0
> >
^ permalink raw reply
* Re: [PATCH] net: arc_emac: Add support for ndo_do_ioctl net_device_ops operation
From: David Miller @ 2017-08-03 22:14 UTC (permalink / raw)
To: romain.perier
Cc: al.kochet, weiyongjun1, edumazet, peter.chen, netdev,
linux-kernel
In-Reply-To: <20170803074903.19688-1-romain.perier@collabora.com>
From: Romain Perier <romain.perier@collabora.com>
Date: Thu, 3 Aug 2017 09:49:03 +0200
> This operation is required for handling ioctl commands like SIOCGMIIREG,
> when debugging MDIO registers from userspace.
>
> This commit adds support for this operation.
>
> Signed-off-by: Romain Perier <romain.perier@collabora.com>
Applied, thanks.
^ permalink raw reply
* Re: [PATCH net] ipv6: set rt6i_protocol properly in the route when it is installed
From: David Miller @ 2017-08-03 22:10 UTC (permalink / raw)
To: lucien.xin; +Cc: netdev, grawity, dsahern
In-Reply-To: <4b7ab03445cf34a630d5185b216de8ab103a20d8.1501740826.git.lucien.xin@gmail.com>
From: Xin Long <lucien.xin@gmail.com>
Date: Thu, 3 Aug 2017 14:13:46 +0800
> After commit c2ed1880fd61 ("net: ipv6: check route protocol when
> deleting routes"), ipv6 route checks rt protocol when trying to
> remove a rt entry.
>
> It introduced a side effect causing 'ip -6 route flush cache' not
> to work well. When flushing caches with iproute, all route caches
> get dumped from kernel then removed one by one by sending DELROUTE
> requests to kernel for each cache.
>
> The thing is iproute sends the request with the cache whose proto
> is set with RTPROT_REDIRECT by rt6_fill_node() when kernel dumps
> it. But in kernel the rt_cache protocol is still 0, which causes
> the cache not to be matched and removed.
>
> So the real reason is rt6i_protocol in the route is not set when
> it is allocated. As David Ahern's suggestion, this patch is to
> set rt6i_protocol properly in the route when it is installed and
> remove the codes setting rtm_protocol according to rt6i_flags in
> rt6_fill_node.
>
> This is also an improvement to keep rt6i_protocol consistent with
> rtm_protocol.
>
> Fixes: c2ed1880fd61 ("net: ipv6: check route protocol when deleting routes")
> Reported-by: Jianlin Shi <jishi@redhat.com>
> Suggested-by: David Ahern <dsahern@gmail.com>
> Signed-off-by: Xin Long <lucien.xin@gmail.com>
Applied and queued up for -stable, thanks.
^ permalink raw reply
* [PATCH net-next] liquidio: moved console_bitmask module param to lio_main.c
From: Felix Manlunas @ 2017-08-03 22:10 UTC (permalink / raw)
To: davem
Cc: netdev, raghu.vatsavayi, derek.chickles, satananda.burla,
intiyaz.basha
From: Intiyaz Basha <intiyaz.basha@cavium.com>
Moving PF module param console_bitmask to lio_main.c for consistency.
Signed-off-by: Intiyaz Basha <intiyaz.basha@cavium.com>
Signed-off-by: Felix Manlunas <felix.manlunas@cavium.com>
---
drivers/net/ethernet/cavium/liquidio/lio_main.c | 15 +++++++++++++++
drivers/net/ethernet/cavium/liquidio/octeon_console.c | 14 --------------
drivers/net/ethernet/cavium/liquidio/octeon_device.h | 2 ++
3 files changed, 17 insertions(+), 14 deletions(-)
diff --git a/drivers/net/ethernet/cavium/liquidio/lio_main.c b/drivers/net/ethernet/cavium/liquidio/lio_main.c
index 39a8dca..8c2cd80 100644
--- a/drivers/net/ethernet/cavium/liquidio/lio_main.c
+++ b/drivers/net/ethernet/cavium/liquidio/lio_main.c
@@ -59,6 +59,21 @@ static char fw_type[LIO_MAX_FW_TYPE_LEN];
module_param_string(fw_type, fw_type, sizeof(fw_type), 0000);
MODULE_PARM_DESC(fw_type, "Type of firmware to be loaded. Default \"nic\"");
+static u32 console_bitmask;
+module_param(console_bitmask, int, 0644);
+MODULE_PARM_DESC(console_bitmask,
+ "Bitmask indicating which consoles have debug output redirected to syslog.");
+
+/**
+ * \brief determines if a given console has debug enabled.
+ * @param console console to check
+ * @returns 1 = enabled. 0 otherwise
+ */
+int octeon_console_debug_enabled(u32 console)
+{
+ return (console_bitmask >> (console)) & 0x1;
+}
+
static int ptp_enable = 1;
/* Polling interval for determining when NIC application is alive */
diff --git a/drivers/net/ethernet/cavium/liquidio/octeon_console.c b/drivers/net/ethernet/cavium/liquidio/octeon_console.c
index 15ad1ab..dd0efc9 100644
--- a/drivers/net/ethernet/cavium/liquidio/octeon_console.c
+++ b/drivers/net/ethernet/cavium/liquidio/octeon_console.c
@@ -37,10 +37,6 @@ static u64 cvmx_bootmem_phy_named_block_find(struct octeon_device *oct,
u32 flags);
static int octeon_console_read(struct octeon_device *oct, u32 console_num,
char *buffer, u32 buf_size);
-static u32 console_bitmask;
-module_param(console_bitmask, int, 0644);
-MODULE_PARM_DESC(console_bitmask,
- "Bitmask indicating which consoles have debug output redirected to syslog.");
#define BOOTLOADER_PCI_READ_BUFFER_DATA_ADDR 0x0006c008
#define BOOTLOADER_PCI_READ_BUFFER_LEN_ADDR 0x0006c004
@@ -136,16 +132,6 @@ struct octeon_pci_console_desc {
};
/**
- * \brief determines if a given console has debug enabled.
- * @param console console to check
- * @returns 1 = enabled. 0 otherwise
- */
-static int octeon_console_debug_enabled(u32 console)
-{
- return (console_bitmask >> (console)) & 0x1;
-}
-
-/**
* This function is the implementation of the get macros defined
* for individual structure members. The argument are generated
* by the macros inorder to read only the needed memory.
diff --git a/drivers/net/ethernet/cavium/liquidio/octeon_device.h b/drivers/net/ethernet/cavium/liquidio/octeon_device.h
index ad46478..31efdef 100644
--- a/drivers/net/ethernet/cavium/liquidio/octeon_device.h
+++ b/drivers/net/ethernet/cavium/liquidio/octeon_device.h
@@ -739,6 +739,8 @@ int octeon_wait_for_bootloader(struct octeon_device *oct,
*/
int octeon_init_consoles(struct octeon_device *oct);
+int octeon_console_debug_enabled(u32 console);
+
/**
* Adds access to a console to the device.
*
^ permalink raw reply related
* Re: [PATCH V6 net-next 0/8] Hisilicon Network Subsystem 3 Ethernet Driver
From: David Miller @ 2017-08-03 22:09 UTC (permalink / raw)
To: salil.mehta
Cc: yisen.zhuang, huangdaode, lipeng321, mehta.salil.lnk, netdev,
linux-kernel, linux-rdma, linuxarm
In-Reply-To: <20170802155952.185564-1-salil.mehta@huawei.com>
From: Salil Mehta <salil.mehta@huawei.com>
Date: Wed, 2 Aug 2017 16:59:44 +0100
> This patch-set contains the support of the HNS3 (Hisilicon Network Subsystem 3)
> Ethernet driver for hip08 family of SoCs and future upcoming SoCs.
...
Series applied, thanks.
^ permalink raw reply
* Re: [PATCH] PCI: Update ACS quirk for more Intel 10G NICs
From: Bjorn Helgaas @ 2017-08-03 21:49 UTC (permalink / raw)
To: Roland Dreier; +Cc: Bjorn Helgaas, linux-pci, netdev, Emil Tantilov
In-Reply-To: <20170720214101.7449-1-roland@kernel.org>
On Thu, Jul 20, 2017 at 02:41:01PM -0700, Roland Dreier wrote:
> From: Roland Dreier <roland@purestorage.com>
>
> Add one more variant of the 82599 plus the device IDs for X540 and X550
> variants. Intel has confirmed that none of these devices does peer-to-peer
> between functions. The X540 and X550 have added ACS capabilities in their
> PCI config space, but the ACS control register is hard-wired to 0 for both
> devices, so we still need the quirk for IOMMU grouping to allow assignment
> of individual SR-IOV functions.
>
> Signed-off-by: Roland Dreier <roland@purestorage.com>
I haven't seen a real conclusion to the discussion yet, so I'm waiting on
that and hopefully an ack from Alex. Can you please repost with that,
since I'm dropping it from patchwork for now?
> ---
> drivers/pci/quirks.c | 21 +++++++++++++++++++++
> 1 file changed, 21 insertions(+)
>
> diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
> index 6967c6b4cf6b..b939db671326 100644
> --- a/drivers/pci/quirks.c
> +++ b/drivers/pci/quirks.c
> @@ -4335,12 +4335,33 @@ static const struct pci_dev_acs_enabled {
> { PCI_VENDOR_ID_INTEL, 0x1507, pci_quirk_mf_endpoint_acs },
> { PCI_VENDOR_ID_INTEL, 0x1514, pci_quirk_mf_endpoint_acs },
> { PCI_VENDOR_ID_INTEL, 0x151C, pci_quirk_mf_endpoint_acs },
> + { PCI_VENDOR_ID_INTEL, 0x1528, pci_quirk_mf_endpoint_acs },
> { PCI_VENDOR_ID_INTEL, 0x1529, pci_quirk_mf_endpoint_acs },
> + { PCI_VENDOR_ID_INTEL, 0x154A, pci_quirk_mf_endpoint_acs },
> { PCI_VENDOR_ID_INTEL, 0x152A, pci_quirk_mf_endpoint_acs },
> { PCI_VENDOR_ID_INTEL, 0x154D, pci_quirk_mf_endpoint_acs },
> { PCI_VENDOR_ID_INTEL, 0x154F, pci_quirk_mf_endpoint_acs },
> { PCI_VENDOR_ID_INTEL, 0x1551, pci_quirk_mf_endpoint_acs },
> { PCI_VENDOR_ID_INTEL, 0x1558, pci_quirk_mf_endpoint_acs },
> + { PCI_VENDOR_ID_INTEL, 0x1560, pci_quirk_mf_endpoint_acs },
> + { PCI_VENDOR_ID_INTEL, 0x1563, pci_quirk_mf_endpoint_acs },
> + { PCI_VENDOR_ID_INTEL, 0x15AA, pci_quirk_mf_endpoint_acs },
> + { PCI_VENDOR_ID_INTEL, 0x15AB, pci_quirk_mf_endpoint_acs },
> + { PCI_VENDOR_ID_INTEL, 0x15AC, pci_quirk_mf_endpoint_acs },
> + { PCI_VENDOR_ID_INTEL, 0x15AD, pci_quirk_mf_endpoint_acs },
> + { PCI_VENDOR_ID_INTEL, 0x15AE, pci_quirk_mf_endpoint_acs },
> + { PCI_VENDOR_ID_INTEL, 0x15B0, pci_quirk_mf_endpoint_acs },
> + { PCI_VENDOR_ID_INTEL, 0x15AB, pci_quirk_mf_endpoint_acs },
> + { PCI_VENDOR_ID_INTEL, 0x15C2, pci_quirk_mf_endpoint_acs },
> + { PCI_VENDOR_ID_INTEL, 0x15C3, pci_quirk_mf_endpoint_acs },
> + { PCI_VENDOR_ID_INTEL, 0x15C4, pci_quirk_mf_endpoint_acs },
> + { PCI_VENDOR_ID_INTEL, 0x15C6, pci_quirk_mf_endpoint_acs },
> + { PCI_VENDOR_ID_INTEL, 0x15C7, pci_quirk_mf_endpoint_acs },
> + { PCI_VENDOR_ID_INTEL, 0x15C8, pci_quirk_mf_endpoint_acs },
> + { PCI_VENDOR_ID_INTEL, 0x15CE, pci_quirk_mf_endpoint_acs },
> + { PCI_VENDOR_ID_INTEL, 0x15E4, pci_quirk_mf_endpoint_acs },
> + { PCI_VENDOR_ID_INTEL, 0x15E5, pci_quirk_mf_endpoint_acs },
> + { PCI_VENDOR_ID_INTEL, 0x15D1, pci_quirk_mf_endpoint_acs },
> /* 82580 */
> { PCI_VENDOR_ID_INTEL, 0x1509, pci_quirk_mf_endpoint_acs },
> { PCI_VENDOR_ID_INTEL, 0x150E, pci_quirk_mf_endpoint_acs },
> --
> 2.11.0
>
^ permalink raw reply
* Re: [PATCH net-next 1/3] proto_ops: Add locked held versions of sendmsg and sendpage
From: Tom Herbert @ 2017-08-03 21:07 UTC (permalink / raw)
To: John Fastabend; +Cc: Tom Herbert, Linux Kernel Network Developers, Rohit Seth
In-Reply-To: <598385D4.5050205@gmail.com>
On Thu, Aug 3, 2017 at 1:21 PM, John Fastabend <john.fastabend@gmail.com> wrote:
> On 07/28/2017 04:22 PM, Tom Herbert wrote:
>> Add new proto_ops sendmsg_locked and sendpage_locked that can be
>> called when the socket lock is already held. Correspondingly, add
>> kernel_sendmsg_locked and kernel_sendpage_locked as front end
>> functions.
>>
>> These functions will be used in zero proxy so that we can take
>> the socket lock in a ULP sendmsg/sendpage and then directly call the
>> backend transport proto_ops functions.
>>
>
> [...]
>
>>
>> +int kernel_sendpage_locked(struct sock *sk, struct page *page, int offset,
>> + size_t size, int flags)
>> +{
>> + struct socket *sock = sk->sk_socket;
>> +
>> + if (sock->ops->sendpage_locked)
>> + return sock->ops->sendpage_locked(sk, page, offset, size,
>> + flags);
>> +
>> + return sock_no_sendpage_locked(sk, page, offset, size, flags);
>> +}
>
> How about just returning EOPNOTSUPP here and force implementations to do both
> sendmsg and sendpage. The only implementation of these callbacks already does
> this. And if its any other socket it will just wind its way through a few
> layers of calls before returning EOPNOTSUPP.
>
Seems reasonable, but we should probably make the same change to
kernel_sendpage to be consistent.
Tom
> .John
^ permalink raw reply
* [PATCH net v2] net/mlx4_en: don't set CHECKSUM_COMPLETE on SCTP packets
From: Davide Caratti @ 2017-08-03 20:54 UTC (permalink / raw)
To: Tariq Toukan, netdev; +Cc: David S . Miller
if the NIC fails to validate the checksum on TCP/UDP, and validation of IP
checksum is successful, the driver subtracts the pseudo-header checksum
from the value obtained by the hardware and sets CHECKSUM_COMPLETE. Don't
do that if protocol is IPPROTO_SCTP, otherwise CRC32c validation fails.
V2: don't test MLX4_CQE_STATUS_IPV6 if MLX4_CQE_STATUS_IPV4 is set
Reported-by: Shuang Li <shuali@redhat.com>
Fixes: f8c6455bb04b ("net/mlx4_en: Extend checksum offloading by CHECKSUM COMPLETE")
Signed-off-by: Davide Caratti <dcaratti@redhat.com>
---
drivers/net/ethernet/mellanox/mlx4/en_rx.c | 29 ++++++++++++++++++-----------
1 file changed, 18 insertions(+), 11 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_rx.c b/drivers/net/ethernet/mellanox/mlx4/en_rx.c
index 436f768..bf16380 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_rx.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_rx.c
@@ -574,16 +574,21 @@ static inline __wsum get_fixed_vlan_csum(__wsum hw_checksum,
* header, the HW adds it. To address that, we are subtracting the pseudo
* header checksum from the checksum value provided by the HW.
*/
-static void get_fixed_ipv4_csum(__wsum hw_checksum, struct sk_buff *skb,
- struct iphdr *iph)
+static int get_fixed_ipv4_csum(__wsum hw_checksum, struct sk_buff *skb,
+ struct iphdr *iph)
{
__u16 length_for_csum = 0;
__wsum csum_pseudo_header = 0;
+ __u8 ipproto = iph->protocol;
+
+ if (unlikely(ipproto == IPPROTO_SCTP))
+ return -1;
length_for_csum = (be16_to_cpu(iph->tot_len) - (iph->ihl << 2));
csum_pseudo_header = csum_tcpudp_nofold(iph->saddr, iph->daddr,
- length_for_csum, iph->protocol, 0);
+ length_for_csum, ipproto, 0);
skb->csum = csum_sub(hw_checksum, csum_pseudo_header);
+ return 0;
}
#if IS_ENABLED(CONFIG_IPV6)
@@ -594,17 +599,20 @@ static void get_fixed_ipv4_csum(__wsum hw_checksum, struct sk_buff *skb,
static int get_fixed_ipv6_csum(__wsum hw_checksum, struct sk_buff *skb,
struct ipv6hdr *ipv6h)
{
+ __u8 nexthdr = ipv6h->nexthdr;
__wsum csum_pseudo_hdr = 0;
- if (unlikely(ipv6h->nexthdr == IPPROTO_FRAGMENT ||
- ipv6h->nexthdr == IPPROTO_HOPOPTS))
+ if (unlikely(nexthdr == IPPROTO_FRAGMENT ||
+ nexthdr == IPPROTO_HOPOPTS ||
+ nexthdr == IPPROTO_SCTP))
return -1;
- hw_checksum = csum_add(hw_checksum, (__force __wsum)htons(ipv6h->nexthdr));
+ hw_checksum = csum_add(hw_checksum, (__force __wsum)htons(nexthdr));
csum_pseudo_hdr = csum_partial(&ipv6h->saddr,
sizeof(ipv6h->saddr) + sizeof(ipv6h->daddr), 0);
csum_pseudo_hdr = csum_add(csum_pseudo_hdr, (__force __wsum)ipv6h->payload_len);
- csum_pseudo_hdr = csum_add(csum_pseudo_hdr, (__force __wsum)ntohs(ipv6h->nexthdr));
+ csum_pseudo_hdr = csum_add(csum_pseudo_hdr,
+ (__force __wsum)htons(nexthdr));
skb->csum = csum_sub(hw_checksum, csum_pseudo_hdr);
skb->csum = csum_add(skb->csum, csum_partial(ipv6h, sizeof(struct ipv6hdr), 0));
@@ -627,11 +635,10 @@ static int check_csum(struct mlx4_cqe *cqe, struct sk_buff *skb, void *va,
}
if (cqe->status & cpu_to_be16(MLX4_CQE_STATUS_IPV4))
- get_fixed_ipv4_csum(hw_checksum, skb, hdr);
+ return get_fixed_ipv4_csum(hw_checksum, skb, hdr);
#if IS_ENABLED(CONFIG_IPV6)
- else if (cqe->status & cpu_to_be16(MLX4_CQE_STATUS_IPV6))
- if (unlikely(get_fixed_ipv6_csum(hw_checksum, skb, hdr)))
- return -1;
+ if (cqe->status & cpu_to_be16(MLX4_CQE_STATUS_IPV6))
+ return get_fixed_ipv6_csum(hw_checksum, skb, hdr);
#endif
return 0;
}
--
2.9.4
^ permalink raw reply related
* [PATCH net-next v4 8/9] tcp: enable MSG_ZEROCOPY
From: Willem de Bruijn @ 2017-08-03 20:29 UTC (permalink / raw)
To: netdev; +Cc: davem, linux-api, Willem de Bruijn
In-Reply-To: <20170803202945.70750-1-willemdebruijn.kernel@gmail.com>
From: Willem de Bruijn <willemb@google.com>
Enable support for MSG_ZEROCOPY to the TCP stack. TSO and GSO are
both supported. Only data sent to remote destinations is sent without
copying. Packets looped onto a local destination have their payload
copied to avoid unbounded latency.
Tested:
A 10x TCP_STREAM between two hosts showed a reduction in netserver
process cycles by up to 70%, depending on packet size. Systemwide,
savings are of course much less pronounced, at up to 20% best case.
msg_zerocopy.sh 4 tcp:
without zerocopy
tx=121792 (7600 MB) txc=0 zc=n
rx=60458 (7600 MB)
with zerocopy
tx=286257 (17863 MB) txc=286257 zc=y
rx=140022 (17863 MB)
This test opens a pair of sockets over veth, one one calls send with
64KB and optionally MSG_ZEROCOPY and on the other reads the initial
bytes. The receiver truncates, so this is strictly an upper bound on
what is achievable. It is more representative of sending data out of
a physical NIC (when payload is not touched, either).
Signed-off-by: Willem de Bruijn <willemb@google.com>
---
net/ipv4/tcp.c | 32 +++++++++++++++++++++++++++++++-
1 file changed, 31 insertions(+), 1 deletion(-)
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 9dd6f4dba9b1..71b25567e787 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -1165,6 +1165,7 @@ static int tcp_sendmsg_fastopen(struct sock *sk, struct msghdr *msg,
int tcp_sendmsg_locked(struct sock *sk, struct msghdr *msg, size_t size)
{
struct tcp_sock *tp = tcp_sk(sk);
+ struct ubuf_info *uarg = NULL;
struct sk_buff *skb;
struct sockcm_cookie sockc;
int flags, err, copied = 0;
@@ -1174,6 +1175,26 @@ int tcp_sendmsg_locked(struct sock *sk, struct msghdr *msg, size_t size)
long timeo;
flags = msg->msg_flags;
+
+ if (flags & MSG_ZEROCOPY && size) {
+ if (sk->sk_state != TCP_ESTABLISHED) {
+ err = -EINVAL;
+ goto out_err;
+ }
+
+ skb = tcp_send_head(sk) ? tcp_write_queue_tail(sk) : NULL;
+ uarg = sock_zerocopy_realloc(sk, size, skb_zcopy(skb));
+ if (!uarg) {
+ err = -ENOBUFS;
+ goto out_err;
+ }
+
+ /* skb may be freed in main loop, keep extra ref on uarg */
+ sock_zerocopy_get(uarg);
+ if (!(sk_check_csum_caps(sk) && sk->sk_route_caps & NETIF_F_SG))
+ uarg->zerocopy = 0;
+ }
+
if (unlikely(flags & MSG_FASTOPEN || inet_sk(sk)->defer_connect)) {
err = tcp_sendmsg_fastopen(sk, msg, &copied_syn, size);
if (err == -EINPROGRESS && copied_syn > 0)
@@ -1297,7 +1318,7 @@ int tcp_sendmsg_locked(struct sock *sk, struct msghdr *msg, size_t size)
err = skb_add_data_nocache(sk, skb, &msg->msg_iter, copy);
if (err)
goto do_fault;
- } else {
+ } else if (!uarg || !uarg->zerocopy) {
bool merge = true;
int i = skb_shinfo(skb)->nr_frags;
struct page_frag *pfrag = sk_page_frag(sk);
@@ -1335,6 +1356,13 @@ int tcp_sendmsg_locked(struct sock *sk, struct msghdr *msg, size_t size)
page_ref_inc(pfrag->page);
}
pfrag->offset += copy;
+ } else {
+ err = skb_zerocopy_iter_stream(sk, skb, msg, copy, uarg);
+ if (err == -EMSGSIZE || err == -EEXIST)
+ goto new_segment;
+ if (err < 0)
+ goto do_error;
+ copy = err;
}
if (!copied)
@@ -1381,6 +1409,7 @@ int tcp_sendmsg_locked(struct sock *sk, struct msghdr *msg, size_t size)
tcp_push(sk, flags, mss_now, tp->nonagle, size_goal);
}
out_nopush:
+ sock_zerocopy_put(uarg);
return copied + copied_syn;
do_fault:
@@ -1397,6 +1426,7 @@ int tcp_sendmsg_locked(struct sock *sk, struct msghdr *msg, size_t size)
if (copied + copied_syn)
goto out;
out_err:
+ sock_zerocopy_put_abort(uarg);
err = sk_stream_error(sk, flags, err);
/* make sure we wake any epoll edge trigger waiter */
if (unlikely(skb_queue_len(&sk->sk_write_queue) == 0 &&
--
2.14.0.rc1.383.gd1ce394fe2-goog
^ permalink raw reply related
* [PATCH net-next v4 7/9] sock: ulimit on MSG_ZEROCOPY pages
From: Willem de Bruijn @ 2017-08-03 20:29 UTC (permalink / raw)
To: netdev; +Cc: davem, linux-api, Willem de Bruijn
In-Reply-To: <20170803202945.70750-1-willemdebruijn.kernel@gmail.com>
From: Willem de Bruijn <willemb@google.com>
Bound the number of pages that a user may pin.
Follow the lead of perf tools to maintain a per-user bound on memory
locked pages commit 789f90fcf6b0 ("perf_counter: per user mlock gift")
Signed-off-by: Willem de Bruijn <willemb@google.com>
---
include/linux/sched/user.h | 3 ++-
include/linux/skbuff.h | 5 +++++
net/core/skbuff.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 55 insertions(+), 1 deletion(-)
diff --git a/include/linux/sched/user.h b/include/linux/sched/user.h
index 5d5415e129d4..3c07e4135127 100644
--- a/include/linux/sched/user.h
+++ b/include/linux/sched/user.h
@@ -36,7 +36,8 @@ struct user_struct {
struct hlist_node uidhash_node;
kuid_t uid;
-#if defined(CONFIG_PERF_EVENTS) || defined(CONFIG_BPF_SYSCALL)
+#if defined(CONFIG_PERF_EVENTS) || defined(CONFIG_BPF_SYSCALL) || \
+ defined(CONFIG_NET)
atomic_long_t locked_vm;
#endif
};
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index f5bdd93a87da..8c0708d2e5e6 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -457,6 +457,11 @@ struct ubuf_info {
};
};
atomic_t refcnt;
+
+ struct mmpin {
+ struct user_struct *user;
+ unsigned int num_pg;
+ } mmp;
};
#define skb_uarg(SKB) ((struct ubuf_info *)(skb_shinfo(SKB)->destructor_arg))
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index dcee0f64f1fa..42b62c716a33 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -897,6 +897,44 @@ struct sk_buff *skb_morph(struct sk_buff *dst, struct sk_buff *src)
}
EXPORT_SYMBOL_GPL(skb_morph);
+static int mm_account_pinned_pages(struct mmpin *mmp, size_t size)
+{
+ unsigned long max_pg, num_pg, new_pg, old_pg;
+ struct user_struct *user;
+
+ if (capable(CAP_IPC_LOCK) || !size)
+ return 0;
+
+ num_pg = (size >> PAGE_SHIFT) + 2; /* worst case */
+ max_pg = rlimit(RLIMIT_MEMLOCK) >> PAGE_SHIFT;
+ user = mmp->user ? : current_user();
+
+ do {
+ old_pg = atomic_long_read(&user->locked_vm);
+ new_pg = old_pg + num_pg;
+ if (new_pg > max_pg)
+ return -ENOBUFS;
+ } while (atomic_long_cmpxchg(&user->locked_vm, old_pg, new_pg) !=
+ old_pg);
+
+ if (!mmp->user) {
+ mmp->user = get_uid(user);
+ mmp->num_pg = num_pg;
+ } else {
+ mmp->num_pg += num_pg;
+ }
+
+ return 0;
+}
+
+static void mm_unaccount_pinned_pages(struct mmpin *mmp)
+{
+ if (mmp->user) {
+ atomic_long_sub(mmp->num_pg, &mmp->user->locked_vm);
+ free_uid(mmp->user);
+ }
+}
+
struct ubuf_info *sock_zerocopy_alloc(struct sock *sk, size_t size)
{
struct ubuf_info *uarg;
@@ -913,6 +951,12 @@ struct ubuf_info *sock_zerocopy_alloc(struct sock *sk, size_t size)
BUILD_BUG_ON(sizeof(*uarg) > sizeof(skb->cb));
uarg = (void *)skb->cb;
+ uarg->mmp.user = NULL;
+
+ if (mm_account_pinned_pages(&uarg->mmp, size)) {
+ kfree_skb(skb);
+ return NULL;
+ }
uarg->callback = sock_zerocopy_callback;
uarg->id = ((u32)atomic_inc_return(&sk->sk_zckey)) - 1;
@@ -956,6 +1000,8 @@ struct ubuf_info *sock_zerocopy_realloc(struct sock *sk, size_t size,
next = (u32)atomic_read(&sk->sk_zckey);
if ((u32)(uarg->id + uarg->len) == next) {
+ if (mm_account_pinned_pages(&uarg->mmp, size))
+ return NULL;
uarg->len++;
uarg->bytelen = bytelen;
atomic_set(&sk->sk_zckey, ++next);
@@ -1038,6 +1084,8 @@ EXPORT_SYMBOL_GPL(sock_zerocopy_callback);
void sock_zerocopy_put(struct ubuf_info *uarg)
{
if (uarg && atomic_dec_and_test(&uarg->refcnt)) {
+ mm_unaccount_pinned_pages(&uarg->mmp);
+
if (uarg->callback)
uarg->callback(uarg, uarg->zerocopy);
else
--
2.14.0.rc1.383.gd1ce394fe2-goog
^ permalink raw reply related
* [PATCH net-next v4 5/9] sock: enable MSG_ZEROCOPY
From: Willem de Bruijn @ 2017-08-03 20:29 UTC (permalink / raw)
To: netdev; +Cc: davem, linux-api, Willem de Bruijn
In-Reply-To: <20170803202945.70750-1-willemdebruijn.kernel@gmail.com>
From: Willem de Bruijn <willemb@google.com>
Prepare the datapath for refcounted ubuf_info. Clone ubuf_info with
skb_zerocopy_clone() wherever needed due to skb split, merge, resize
or clone.
Split skb_orphan_frags into two variants. The split, merge, .. paths
support reference counted zerocopy buffers, so do not do a deep copy.
Add skb_orphan_frags_rx for paths that may loop packets to receive
sockets. That is not allowed, as it may cause unbounded latency.
Deep copy all zerocopy copy buffers, ref-counted or not, in this path.
The exact locations to modify were chosen by exhaustively searching
through all code that might modify skb_frag references and/or the
the SKBTX_DEV_ZEROCOPY tx_flags bit.
The changes err on the safe side, in two ways.
(1) legacy ubuf_info paths virtio and tap are not modified. They keep
a 1:1 ubuf_info to sk_buff relationship. Calls to skb_orphan_frags
still call skb_copy_ubufs and thus copy frags in this case.
(2) not all copies deep in the stack are addressed yet. skb_shift,
skb_split and skb_try_coalesce can be refined to avoid copying.
These are not in the hot path and this patch is hairy enough as
is, so that is left for future refinement.
Signed-off-by: Willem de Bruijn <willemb@google.com>
---
drivers/net/tun.c | 2 +-
drivers/vhost/net.c | 1 +
include/linux/skbuff.h | 14 +++++++++++++-
net/core/dev.c | 4 ++--
net/core/skbuff.c | 48 +++++++++++++++++++-----------------------------
5 files changed, 36 insertions(+), 33 deletions(-)
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 68add55f8460..d21510d47aa2 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -892,7 +892,7 @@ static netdev_tx_t tun_net_xmit(struct sk_buff *skb, struct net_device *dev)
sk_filter(tfile->socket.sk, skb))
goto drop;
- if (unlikely(skb_orphan_frags(skb, GFP_ATOMIC)))
+ if (unlikely(skb_orphan_frags_rx(skb, GFP_ATOMIC)))
goto drop;
skb_tx_timestamp(skb);
diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
index 06d044862e58..ba08b78ed630 100644
--- a/drivers/vhost/net.c
+++ b/drivers/vhost/net.c
@@ -533,6 +533,7 @@ static void handle_tx(struct vhost_net *net)
ubuf->callback = vhost_zerocopy_callback;
ubuf->ctx = nvq->ubufs;
ubuf->desc = nvq->upend_idx;
+ atomic_set(&ubuf->refcnt, 1);
msg.msg_control = ubuf;
msg.msg_controllen = sizeof(ubuf);
ubufs = nvq->ubufs;
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 59cff7aa494e..e5387932c266 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -2512,7 +2512,17 @@ static inline void skb_orphan(struct sk_buff *skb)
*/
static inline int skb_orphan_frags(struct sk_buff *skb, gfp_t gfp_mask)
{
- if (likely(!(skb_shinfo(skb)->tx_flags & SKBTX_DEV_ZEROCOPY)))
+ if (likely(!skb_zcopy(skb)))
+ return 0;
+ if (skb_uarg(skb)->callback == sock_zerocopy_callback)
+ return 0;
+ return skb_copy_ubufs(skb, gfp_mask);
+}
+
+/* Frags must be orphaned, even if refcounted, if skb might loop to rx path */
+static inline int skb_orphan_frags_rx(struct sk_buff *skb, gfp_t gfp_mask)
+{
+ if (likely(!skb_zcopy(skb)))
return 0;
return skb_copy_ubufs(skb, gfp_mask);
}
@@ -2944,6 +2954,8 @@ static inline int skb_add_data(struct sk_buff *skb,
static inline bool skb_can_coalesce(struct sk_buff *skb, int i,
const struct page *page, int off)
{
+ if (skb_zcopy(skb))
+ return false;
if (i) {
const struct skb_frag_struct *frag = &skb_shinfo(skb)->frags[i - 1];
diff --git a/net/core/dev.c b/net/core/dev.c
index 8ea6b4b42611..1d75499add72 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -1853,7 +1853,7 @@ static inline int deliver_skb(struct sk_buff *skb,
struct packet_type *pt_prev,
struct net_device *orig_dev)
{
- if (unlikely(skb_orphan_frags(skb, GFP_ATOMIC)))
+ if (unlikely(skb_orphan_frags_rx(skb, GFP_ATOMIC)))
return -ENOMEM;
refcount_inc(&skb->users);
return pt_prev->func(skb, skb->dev, pt_prev, orig_dev);
@@ -4412,7 +4412,7 @@ static int __netif_receive_skb_core(struct sk_buff *skb, bool pfmemalloc)
}
if (pt_prev) {
- if (unlikely(skb_orphan_frags(skb, GFP_ATOMIC)))
+ if (unlikely(skb_orphan_frags_rx(skb, GFP_ATOMIC)))
goto drop;
else
ret = pt_prev->func(skb, skb->dev, pt_prev, orig_dev);
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 29e34bc6a17c..74d3c36f8419 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -567,21 +567,10 @@ static void skb_release_data(struct sk_buff *skb)
for (i = 0; i < shinfo->nr_frags; i++)
__skb_frag_unref(&shinfo->frags[i]);
- /*
- * If skb buf is from userspace, we need to notify the caller
- * the lower device DMA has done;
- */
- if (shinfo->tx_flags & SKBTX_DEV_ZEROCOPY) {
- struct ubuf_info *uarg;
-
- uarg = shinfo->destructor_arg;
- if (uarg->callback)
- uarg->callback(uarg, true);
- }
-
if (shinfo->frag_list)
kfree_skb_list(shinfo->frag_list);
+ skb_zcopy_clear(skb, true);
skb_free_head(skb);
}
@@ -695,14 +684,7 @@ EXPORT_SYMBOL(kfree_skb_list);
*/
void skb_tx_error(struct sk_buff *skb)
{
- if (skb_shinfo(skb)->tx_flags & SKBTX_DEV_ZEROCOPY) {
- struct ubuf_info *uarg;
-
- uarg = skb_shinfo(skb)->destructor_arg;
- if (uarg->callback)
- uarg->callback(uarg, false);
- skb_shinfo(skb)->tx_flags &= ~SKBTX_DEV_ZEROCOPY;
- }
+ skb_zcopy_clear(skb, true);
}
EXPORT_SYMBOL(skb_tx_error);
@@ -1029,9 +1011,7 @@ int skb_zerocopy_iter_stream(struct sock *sk, struct sk_buff *skb,
}
EXPORT_SYMBOL_GPL(skb_zerocopy_iter_stream);
-/* unused only until next patch in the series; will remove attribute */
-static int __attribute__((unused))
- skb_zerocopy_clone(struct sk_buff *nskb, struct sk_buff *orig,
+static int skb_zerocopy_clone(struct sk_buff *nskb, struct sk_buff *orig,
gfp_t gfp_mask)
{
if (skb_zcopy(orig)) {
@@ -1068,7 +1048,6 @@ static int __attribute__((unused))
*/
int skb_copy_ubufs(struct sk_buff *skb, gfp_t gfp_mask)
{
- struct ubuf_info *uarg = skb_shinfo(skb)->destructor_arg;
int num_frags = skb_shinfo(skb)->nr_frags;
struct page *page, *head = NULL;
int i, new_frags;
@@ -1127,8 +1106,6 @@ int skb_copy_ubufs(struct sk_buff *skb, gfp_t gfp_mask)
for (i = 0; i < num_frags; i++)
skb_frag_unref(skb, i);
- uarg->callback(uarg, false);
-
/* skb frags point to kernel buffers */
for (i = 0; i < new_frags - 1; i++) {
__skb_fill_page_desc(skb, i, head, 0, PAGE_SIZE);
@@ -1137,7 +1114,7 @@ int skb_copy_ubufs(struct sk_buff *skb, gfp_t gfp_mask)
__skb_fill_page_desc(skb, new_frags - 1, head, 0, d_off);
skb_shinfo(skb)->nr_frags = new_frags;
- skb_shinfo(skb)->tx_flags &= ~SKBTX_DEV_ZEROCOPY;
+ skb_zcopy_clear(skb, false);
return 0;
}
EXPORT_SYMBOL_GPL(skb_copy_ubufs);
@@ -1298,7 +1275,8 @@ struct sk_buff *__pskb_copy_fclone(struct sk_buff *skb, int headroom,
if (skb_shinfo(skb)->nr_frags) {
int i;
- if (skb_orphan_frags(skb, gfp_mask)) {
+ if (skb_orphan_frags(skb, gfp_mask) ||
+ skb_zerocopy_clone(n, skb, gfp_mask)) {
kfree_skb(n);
n = NULL;
goto out;
@@ -1375,9 +1353,10 @@ int pskb_expand_head(struct sk_buff *skb, int nhead, int ntail,
* be since all we did is relocate the values
*/
if (skb_cloned(skb)) {
- /* copy this zero copy skb frags */
if (skb_orphan_frags(skb, gfp_mask))
goto nofrags;
+ if (skb_zcopy(skb))
+ atomic_inc(&skb_uarg(skb)->refcnt);
for (i = 0; i < skb_shinfo(skb)->nr_frags; i++)
skb_frag_ref(skb, i);
@@ -1872,6 +1851,9 @@ void *__pskb_pull_tail(struct sk_buff *skb, int delta)
skb->tail += delta;
skb->data_len -= delta;
+ if (!skb->data_len)
+ skb_zcopy_clear(skb, false);
+
return skb_tail_pointer(skb);
}
EXPORT_SYMBOL(__pskb_pull_tail);
@@ -2627,6 +2609,7 @@ skb_zerocopy(struct sk_buff *to, struct sk_buff *from, int len, int hlen)
skb_tx_error(from);
return -ENOMEM;
}
+ skb_zerocopy_clone(to, from, GFP_ATOMIC);
for (i = 0; i < skb_shinfo(from)->nr_frags; i++) {
if (!len)
@@ -2924,6 +2907,7 @@ void skb_split(struct sk_buff *skb, struct sk_buff *skb1, const u32 len)
skb_shinfo(skb1)->tx_flags |= skb_shinfo(skb)->tx_flags &
SKBTX_SHARED_FRAG;
+ skb_zerocopy_clone(skb1, skb, 0);
if (len < pos) /* Split line is inside header. */
skb_split_inside_header(skb, skb1, len, pos);
else /* Second chunk has no header, nothing to copy. */
@@ -2967,6 +2951,8 @@ int skb_shift(struct sk_buff *tgt, struct sk_buff *skb, int shiftlen)
if (skb_headlen(skb))
return 0;
+ if (skb_zcopy(tgt) || skb_zcopy(skb))
+ return 0;
todo = shiftlen;
from = 0;
@@ -3540,6 +3526,8 @@ struct sk_buff *skb_segment(struct sk_buff *head_skb,
skb_shinfo(nskb)->tx_flags |= skb_shinfo(head_skb)->tx_flags &
SKBTX_SHARED_FRAG;
+ if (skb_zerocopy_clone(nskb, head_skb, GFP_ATOMIC))
+ goto err;
while (pos < offset + len) {
if (i >= nfrags) {
@@ -4663,6 +4651,8 @@ bool skb_try_coalesce(struct sk_buff *to, struct sk_buff *from,
if (skb_has_frag_list(to) || skb_has_frag_list(from))
return false;
+ if (skb_zcopy(to) || skb_zcopy(from))
+ return false;
if (skb_headlen(from) != 0) {
struct page *page;
--
2.14.0.rc1.383.gd1ce394fe2-goog
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox