* Re: [PATCH] tipc: set sk_err correctly when connection fails
From: Paul Gortmaker @ 2013-08-27 18:12 UTC (permalink / raw)
To: Erik Hugne; +Cc: netdev, jon.maloy, ying.xue, tipc-discussion, nhan.tt.vo
In-Reply-To: <20130827151841.GE1939@eerihug-hybrid.rnd.ki.sw.ericsson.se>
On 13-08-27 11:18 AM, Erik Hugne wrote:
> On Tue, Aug 27, 2013 at 09:20:23AM -0400, Paul Gortmaker wrote:
>> What was the high level user visible symptom in this case?
>> Stalled connections or ... ?
>
> Should the connect fail, if the publication/server is unavailable or some other
> error. The connect() call returns the error code directly (as a positive value).
Please send a v2 with the end-user visible symptom clearly described;
as this information is what people use in order to triage whether
commits belong in stable, or net vs. net-next etc. For example:
Should the connect fail, say if the publication/server is unavailable or
some other error, then the code returns a positive return value. Since
most code only checks for a negative return on connect(), it tries to
continue, but will ultimately fail on the 1st sendto() as the strace
snippet below shows.
I've said "most code" since I simply don't know what it was that you were
tracing below. It would help if we knew if this part of a common application
or similar.
Thanks,
Paul.
--
>
> [...]
> socket(0x1e /* PF_??? */, SOCK_SEQPACKET, 0) = 3
> setsockopt(3, 0x10f /* SOL_?? */, 129, [0], 4) = 0
> setsockopt(3, 0x10f /* SOL_?? */, 127, [0], 4) = 0
> connect(3, {sa_family=0x1e /* AF_??? */, sa_data="\2\1\322\4\0\0\322\4\0\0\0\0\0\0"}, 16) = 111
> sendto(3, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 66000, 0, NULL, 0) = -1 EPIPE (Broken pipe)
>
> In the strace above, error checking was done as:
> if (connect(fd,.....) < 0)
> perror("connect");
>
> //E
>
^ permalink raw reply
* Re: [PATCH net-next v1 5/9] bonding: convert bond_has_this_ip() to use upper devices
From: Veaceslav Falico @ 2013-08-27 18:10 UTC (permalink / raw)
To: Jiri Pirko; +Cc: netdev, Jay Vosburgh, Andy Gospodarek
In-Reply-To: <20130827112529.GA4732@minipsycho.brq.redhat.com>
On Tue, Aug 27, 2013 at 01:25:29PM +0200, Jiri Pirko wrote:
>Tue, Aug 27, 2013 at 01:16:48PM CEST, vfalico@redhat.com wrote:
>>On Mon, Aug 26, 2013 at 10:53:38PM +0200, Jiri Pirko wrote:
>>>Mon, Aug 26, 2013 at 10:32:38PM CEST, vfalico@redhat.com wrote:
>>...snip...
>>>>+ rcu_read_lock();
>>>>+ netdev_for_each_upper_dev(bond->dev, upper, iter) {
>>>>+ if (ip == bond_confirm_addr(upper, 0, ip)) {
>>>>+ ret = true;
>>>>+ break;
>>>>+ }
>>>
>>>You need the same recursion __vlan_find_dev_deep() is doing. If you do
>>>not do that, you will miss anything over the first upper level.
>>
>>Good point, and it's true for other uses also - bond_arp_send_all(), for
>>example, will also miss anything that's higher than the first upper level.
>>
>>I can't think of a use case scenario when we would need only the first
>>upper level - so maybe we should either make netdev_for_each_upper_dev()
>>recursive by default (I don't know how it can be done easily, tbh, without
>>modifying the existing code), or add something like:
>>
>>diff --git a/net/core/dev.c b/net/core/dev.c
>>index 566e99a..4a4468f 100644
>>--- a/net/core/dev.c
>>+++ b/net/core/dev.c
>>@@ -4387,6 +4387,31 @@ static void __append_search_uppers(struct list_head *search_list,
>> }
>> }
>>+struct net_device *netdev_upper_recursive_do_rcu(struct net_device *dev,
>>+ struct net_device *orig_dev,
>>+ bool (*f)(struct net_device *,
>>+ struct net_device *))
>>+{
>>+ struct netdev_upper *upper;
>>+ struct net_device *ret = NULL;
>>+
>>+ list_for_each_entry_rcu(upper, &dev->upper_dev_list, list) {
>>+ if (f(orig_dev, upper->dev)) {
>>+ ret = upper->dev;
>>+ break;
>>+ }
>>+
>>+ if (!list_empty(&upper->dev->upper_dev_list)) {
>>+ ret = netdev_upper_recursive_do_rcu(upper->dev,
>>+ orig_dev, f);
>>+ if (ret)
>>+ break;
>>+ }
>>+ }
>>+
>>+ return ret;
>>+}
>>+
>> static bool __netdev_search_upper_dev(struct net_device *dev,
>> struct net_device *upper_dev)
>> {
>>
>>How do you think?
>
>I do not like this. How about to put all levels to upper_dev list and
>mark those who are not direct (not level1) ? Then we can use single list
>for all purposes.
I've looked at the code a bit more and I really don't see a way to do
non-recursive, RCUed way to traverse the whole list of upper devices.
I see three ways to handle this situation:
1) The one that I've posted, recursive search and calling a provided
function (the function should also get as a parameter a user-provided void
*pointer). It's, indeed, a bit hacky, however will work perfectly.
2) Implementing the search (recursive) in bonding (or any further device)
itself. Less intrusive, however it'll be code duplication actually for
point 1).
3) Adding lower_dev_list, populating it accordingly, and also adding an int
distance to the netdev_upper (or, with this approach, rather netdev_adjacent
or something like that), which will help to implement your idea - a device
will have lower/upper_dev_list populated with all lower/upper devices and
their distance (i.e. distance == 1 means that it's first level of
lower/upper device). With this approach, we might also afterwards get rid
of slave lists from 'grouping' devices like bonding/team/bridge/etc. and,
thus, the locking.
Now I'd rather go with 1), but if you don't like it - I can go with 2).
And, if 3) sounds ok, I can implement it also and try to get rid of bonding
slave list (hopefully).
Do you have any other ideas/thoughts?
^ permalink raw reply
* [PATCH] ipv4: sendto/hdrincl: don't use destination address found in header
From: Chris Clark @ 2013-08-27 18:02 UTC (permalink / raw)
To: davem; +Cc: netdev
ipv4: raw_sendmsg: don't use header's destination address
A sendto() regression was bisected and found to start with commit
f8126f1d5136be1 (ipv4: Adjust semantics of rt->rt_gateway.)
The problem is that it tries to ARP-lookup the constructed packet's
destination address rather than the explicitly provided address.
Fix this using FLOWI_FLAG_KNOWN_NH so that given nexthop is used.
cf. commit 2ad5b9e4bd314fc685086b99e90e5de3bc59e26b
Reported-by: Chris Clark <chris.clark@alcatel-lucent.com>
Bisected-by: Chris Clark <chris.clark@alcatel-lucent.com>
Tested-by: Chris Clark <chris.clark@alcatel-lucent.com>
Suggested-by: Julian Anastasov <ja@ssi.bg>
Signed-off-by: Chris Clark <chris.clark@alcatel-lucent.com>
---
net/ipv4/raw.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
index dd44e0a..61e60d6 100644
--- a/net/ipv4/raw.c
+++ b/net/ipv4/raw.c
@@ -571,7 +571,8 @@ static int raw_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
flowi4_init_output(&fl4, ipc.oif, sk->sk_mark, tos,
RT_SCOPE_UNIVERSE,
inet->hdrincl ? IPPROTO_RAW : sk->sk_protocol,
- inet_sk_flowi_flags(sk) | FLOWI_FLAG_CAN_SLEEP,
+ inet_sk_flowi_flags(sk) | FLOWI_FLAG_CAN_SLEEP |
+ (inet->hdrincl ? FLOWI_FLAG_KNOWN_NH : 0),
daddr, saddr, 0, 0);
if (!inet->hdrincl) {
^ permalink raw reply related
* Re: [PATCH net] be2net: Check for POST state in suspend-resume sequence
From: David Miller @ 2013-08-27 17:54 UTC (permalink / raw)
To: sarveshwar.bandi; +Cc: netdev
In-Reply-To: <771abba1-2664-4807-9a45-56ca9ede3c74@CMEXHTCAS2.ad.emulex.com>
From: <sarveshwar.bandi@emulex.com>
Date: Fri, 23 Aug 2013 14:59:33 +0530
> From: Sarveshwar Bandi <sarveshwar.bandi@emulex.com>
>
> In suspend-resume sequence, the OS could attempt to initialize the controller
> before it is ready, check for POST state before going ahead.
>
> Signed-off-by: Sarveshwar Bandi <sarveshwar.bandi@emulex.com>
Applied, thanks.
^ permalink raw reply
* Re: [PATCH 0/2] Rename nsproxy.pid_ns and fix a related security bug
From: David Miller @ 2013-08-27 17:53 UTC (permalink / raw)
To: luto; +Cc: ebiederm, security, linux-kernel, netdev
In-Reply-To: <cover.1377196394.git.luto@amacapital.net>
From: Andy Lutomirski <luto@amacapital.net>
Date: Thu, 22 Aug 2013 11:39:14 -0700
> Eric fell for my bogus claim that nsproxy->pid_ns was the current'
> process's pid ns. This isn't true.
>
> Let's fix the bug and rename pid_ns so that no one gets this wrong again.
>
> Signed-off-by: Andy Lutomirski <luto@amacapital.net>
Series applied, thanks.
^ permalink raw reply
* Re: [net-next RFC 6/7] i40evf: init code and hardware support
From: Ben Hutchings @ 2013-08-27 17:42 UTC (permalink / raw)
To: Jeff Kirsher; +Cc: davem, Mitch A Williams, netdev, gospo, sassmann
In-Reply-To: <1377233609-11627-7-git-send-email-jeffrey.t.kirsher@intel.com>
On Thu, 2013-08-22 at 21:53 -0700, Jeff Kirsher wrote:
[...]
> Intel does wish to maintain exclusive Copyright to these files, and will
> work with the community to implement requested changes or transfer
> Copyright for larger patches. If you do see an issue with this code
> please email us and we will address any concerns in a timely manner.
[...]
I wonder why this is thought to be necessary. I've never heard of
copyright assignment conditions being accepted in the Linux kernel.
Some Linux drivers are dual-licenced under a permissive licence and GPL,
and all contributions to them presumably also have to be dual-licenced.
It seems like that would allow you to retain the ability to reuse the
core hardware code on other operating systems and under proprietary
licences, even with copyrightable contributions from others.
Ben.
--
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
^ permalink raw reply
* Re: [net-next RFC 3/7] i40evf: core ethtool functionality
From: Ben Hutchings @ 2013-08-27 17:27 UTC (permalink / raw)
To: Jeff Kirsher; +Cc: davem, Mitch A Williams, netdev, gospo, sassmann
In-Reply-To: <1377233609-11627-4-git-send-email-jeffrey.t.kirsher@intel.com>
On Thu, 2013-08-22 at 21:53 -0700, Jeff Kirsher wrote:
[...]
> --- /dev/null
> +++ b/drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c
[...]
> +/**
> + * i40evf_get_settings - Get Link Speed and Duplex settings
> + * @netdev: network interface device structure
> + * @ecmd: ethtool command
> + *
> + * Reports speed/duplex settings. Because this is a VF, we don't know what
> + * kind of link we really have, so we fake it.
> + **/
> +static int i40evf_get_settings(struct net_device *netdev,
> + struct ethtool_cmd *ecmd)
> +{
> + ecmd->supported = SUPPORTED_10000baseT_Full;
This is silly.
> + ecmd->autoneg = AUTONEG_DISABLE;
> + ecmd->transceiver = XCVR_DUMMY1;
> + ecmd->port = -1;
PORT_NONE, I think.
> + return 0;
> +}
> +
> +/**
> + * i40evf_get_sset_count - Get length of string set
> + * @netdev: network interface device structure
> + * @sset: id of string set
> + *
> + * Reports size (in bytes) of string set.
Not in bytes.
> This driver only supports
> + * strings for statistics.
> + **/
[...]
> +/**
> + * i40evf_get_strings - Get string set
> + * @netdev: network interface device structure
> + * @sset: id of string set
> + * @data: buffer for string data
> + *
> + * Strings are concatenated into the data buffer, separated by nulls.
This looks like a description of a Windows-style double-null-terminated
string list, not an ethtool string set.
> + **/
> +static void i40evf_get_strings(struct net_device *netdev, u32 sset, u8 *data)
> +{
> + struct i40evf_adapter *adapter = netdev_priv(netdev);
> + u8 *p = data;
> + int i;
> +
> + if (sset == ETH_SS_STATS) {
> + for (i = 0; i < I40EVF_GLOBAL_STATS_LEN; i++) {
> + memcpy(p, i40evf_gstrings_stats[i].stat_string,
> + ETH_GSTRING_LEN);
> + p += ETH_GSTRING_LEN;
> + }
> + for (i = 0; i < adapter->vsi_res->num_queue_pairs; i++) {
> + snprintf(p, ETH_GSTRING_LEN, "%s.tx_queue_%u.packets",
> + netdev->name, i);
> + p += ETH_GSTRING_LEN;
> + snprintf(p, ETH_GSTRING_LEN, "%s.tx_queue_%u.bytes",
> + netdev->name, i);
> + p += ETH_GSTRING_LEN;
> + }
> + for (i = 0; i < adapter->vsi_res->num_queue_pairs; i++) {
> + snprintf(p, ETH_GSTRING_LEN, "%s.rx_queue_%u.packets",
> + netdev->name, i);
> + p += ETH_GSTRING_LEN;
> + snprintf(p, ETH_GSTRING_LEN, "%s.rx_queue_%u.bytes",
> + netdev->name, i);
> + p += ETH_GSTRING_LEN;
It is completely redundant to put the device name into statistic names,
and is liable to cause the names to be truncated. There was also a
discussion about how to name per-queue statistics a while back, which
seemed to end in agreement:
http://thread.gmane.org/gmane.linux.network/273014/focus=12205
So I think the name formats should be "tx-%u.packets" etc.
[...]
> +/**
> + * i40evf_get_drvinto - Get driver info
> + * @netdev: network interface device structure
> + * @drvinfo: ethool driver info structure
> + *
> + * Returns information about the driver and device for display to the user.
> + **/
> +static void i40evf_get_drvinfo(struct net_device *netdev,
> + struct ethtool_drvinfo *drvinfo)
> +{
> + struct i40evf_adapter *adapter = netdev_priv(netdev);
> +
> + strncpy(drvinfo->driver, i40evf_driver_name, 32);
> + strncpy(drvinfo->version, i40evf_driver_version, 32);
> +
> + strncpy(drvinfo->fw_version, "N/A", 4);
If there is no firmware version then don't set fw_version at all.
> + strncpy(drvinfo->bus_info, pci_name(adapter->pdev), 32);
Use strlcpy() not strncpy() for all of the other strings.
> + drvinfo->n_stats = I40EVF_STATS_LEN;
> + drvinfo->regdump_len = 0;
Don't set these at all, as they are initialised by the ethtool core
based on other driver operations.
[...]
> +static void i40evf_get_ringparam(struct net_device *netdev,
> + struct ethtool_ringparam *ring)
> +{
> + struct i40evf_adapter *adapter = netdev_priv(netdev);
> + struct i40e_ring *tx_ring = &adapter->tx_rings[0];
> + struct i40e_ring *rx_ring = &adapter->rx_rings[0];
> +
> + ring->rx_max_pending = I40EVF_MAX_RXD;
> + ring->tx_max_pending = I40EVF_MAX_TXD;
> + ring->rx_mini_max_pending = 0;
> + ring->rx_jumbo_max_pending = 0;
> + ring->rx_pending = rx_ring->count;
> + ring->tx_pending = tx_ring->count;
> + ring->rx_mini_pending = 0;
> + ring->rx_jumbo_pending = 0;
> +}
No need to set the unsupported fields to 0.
[...]
> +static int i40evf_get_coalesce(struct net_device *netdev,
> + struct ethtool_coalesce *ec)
> +{
> + struct i40evf_adapter *adapter = netdev_priv(netdev);
> + struct i40e_vsi *vsi = &adapter->vsi;
> +
> + ec->tx_max_coalesced_frames_irq = vsi->work_limit;
> + ec->rx_max_coalesced_frames_irq = vsi->work_limit;
Use the fields without the '_irq' suffix. The '_irq' suffixed fields
are there for some NICs that change coalescing behaviour depending on
whether the previous IRQ is still being handled.
[...]
> +static int i40evf_set_coalesce(struct net_device *netdev,
> + struct ethtool_coalesce *ec)
> +{
> + struct i40evf_adapter *adapter = netdev_priv(netdev);
> + struct i40e_hw *hw = &adapter->hw;
> + struct i40e_vsi *vsi = &adapter->vsi;
> + struct i40e_q_vector *q_vector;
> + int i;
> +
> + if (ec->tx_max_coalesced_frames_irq || ec->rx_max_coalesced_frames_irq)
> + vsi->work_limit = ec->tx_max_coalesced_frames_irq;
[...]
Again, use the fields without the '_irq' suffix.
Ben.
--
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
^ permalink raw reply
* question about drivers/net/ethernet/mellanox/mlx4/en_tx.c
From: Julia Lawall @ 2013-08-27 17:07 UTC (permalink / raw)
To: amirv, netdev
Hello,
I was wondering why in drivers/net/ethernet/mellanox/mlx4/en_tx.c there
are a number of uses of dma_sync_single_for_cpu without corresponding uses
of dma_sync_single_for_device (for example in mlx4_en_rx_skb)? In most
drivers they come together.
thanks,
julia
^ permalink raw reply
* Re: Pull request: sfc-next 2013-08-25
From: Ben Hutchings @ 2013-08-27 16:52 UTC (permalink / raw)
To: David Miller; +Cc: netdev, linux-net-drivers
In-Reply-To: <20130827.123718.732194018797657395.davem@davemloft.net>
On Tue, 2013-08-27 at 12:37 -0400, David Miller wrote:
> From: Ben Hutchings <bhutchings@solarflare.com>
> Date: Tue, 27 Aug 2013 17:26:08 +0100
>
> > On Tue, 2013-08-27 at 12:18 -0400, David Miller wrote:
> >> From: Ben Hutchings <bhutchings@solarflare.com>
> >> Date: Sun, 25 Aug 2013 23:56:03 +0100
> >>
> >> > The following changes since commit f073dde03b3e8d11050d82f52caaf75fd924e069:
> >> >
> >> > sfc: Make efx_mcdi_init() call efx_mcdi_handle_assertion() (2013-08-21 19:43:09 +0100)
> >> >
> >> > are available in the git repository at:
> >> >
> >> > git://git.kernel.org/pub/scm/linux/kernel/git/bwh/sfc-next.git for-davem
> >> >
> >> > for you to fetch changes up to f76fe120d81c96fa2a17ae41f0647c963dbb43cd:
> >> >
> >> > sfc: Update and improve kernel-doc for efx_mcdi_state & efx_mcdi_iface (2013-08-21 20:20:41 +0100)
> >> >
> >> > 1. Refactoring and cleanup in preparation for new hardware support.
> >> > 2. Some bug fixes for firmware completion handling. (They're not known
> >> > to cause real problems, otherwise I'd be submitting these for net and
> >> > stable.)
> >> > 3. Update to the firmware protocol (MCDI) definitions.
> >>
> >> Pulled, but I want to point out an existing issue which is that using
> >> an atomic_t for mcdi->state is bogus. You're only using atomic_set()
> >> and atomic_read() on the value, and that provides no "atomicity" per-se.
> >
> > Thanks. I don't know what you looked for, but there are actually two
> > atomic_cmpxchg() calls in mcdi.c.
>
> I still think atomic_t is not appropriate, you can use plain xchg() as we
> do all over the IPV4 stack, such as in the TCP metrics cache and the
> routing code.
>
> Really, if I don't see an atomic_*_and_test() or similar kind of
> operation being used, I really don't want to see an atomic_t type in
> use.
We definitely need some variant on cmpxchg() rather than xchg(), but
you're right that we don't need to use atomic_t for that.
Ben.
--
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
^ permalink raw reply
* Re: [PATCH 0/2] net/cadence/macb: add support for dt phy definition
From: David Miller @ 2013-08-27 16:41 UTC (permalink / raw)
To: b.brezillon
Cc: nicolas.ferre, rob.herring, pawel.moll, mark.rutland, swarren,
ian.campbell, linux, f.fainelli, netdev, linux-kernel,
linux-arm-kernel, devicetree
In-Reply-To: <521CD61C.8010103@overkiz.com>
From: boris brezillon <b.brezillon@overkiz.com>
Date: Tue, 27 Aug 2013 18:38:52 +0200
> On 27/08/2013 18:20, David Miller wrote:
>> From: boris brezillon <b.brezillon@overkiz.com>
>> Date: Tue, 27 Aug 2013 09:42:34 +0200
>>
>>> Could you apply, the 3rd version of this series instead ?
>> There can never be an "instead" or reverting patches I've said I've
>> applied already.
>>
>> If you want changes, you have to submit follow-on fixes.
>
> Hello David,
>
> I sent the incremental patches based on your net-next branch:
> https://lkml.org/lkml/2013/8/27/257
> https://lkml.org/lkml/2013/8/27/259
The place to check to see if your patch is queued up is here:
http://patchwork.ozlabs.org/project/netdev/list/
If it's there, it's not necessary to notify me of anything.
^ permalink raw reply
* Re: [PATCH 0/2] net/cadence/macb: add support for dt phy definition
From: boris brezillon @ 2013-08-27 16:38 UTC (permalink / raw)
To: David Miller
Cc: nicolas.ferre, rob.herring, pawel.moll, mark.rutland, swarren,
ian.campbell, linux, f.fainelli, netdev, linux-kernel,
linux-arm-kernel, devicetree
In-Reply-To: <20130827.122056.419758783951274884.davem@davemloft.net>
On 27/08/2013 18:20, David Miller wrote:
> From: boris brezillon <b.brezillon@overkiz.com>
> Date: Tue, 27 Aug 2013 09:42:34 +0200
>
>> Could you apply, the 3rd version of this series instead ?
> There can never be an "instead" or reverting patches I've said I've
> applied already.
>
> If you want changes, you have to submit follow-on fixes.
Hello David,
I sent the incremental patches based on your net-next branch:
https://lkml.org/lkml/2013/8/27/257
https://lkml.org/lkml/2013/8/27/259
Thanks.
Best Regards,
Boris
^ permalink raw reply
* Re: Pull request: sfc-next 2013-08-25
From: David Miller @ 2013-08-27 16:37 UTC (permalink / raw)
To: bhutchings; +Cc: netdev, linux-net-drivers
In-Reply-To: <1377620768.13272.3.camel@bwh-desktop.uk.level5networks.com>
From: Ben Hutchings <bhutchings@solarflare.com>
Date: Tue, 27 Aug 2013 17:26:08 +0100
> On Tue, 2013-08-27 at 12:18 -0400, David Miller wrote:
>> From: Ben Hutchings <bhutchings@solarflare.com>
>> Date: Sun, 25 Aug 2013 23:56:03 +0100
>>
>> > The following changes since commit f073dde03b3e8d11050d82f52caaf75fd924e069:
>> >
>> > sfc: Make efx_mcdi_init() call efx_mcdi_handle_assertion() (2013-08-21 19:43:09 +0100)
>> >
>> > are available in the git repository at:
>> >
>> > git://git.kernel.org/pub/scm/linux/kernel/git/bwh/sfc-next.git for-davem
>> >
>> > for you to fetch changes up to f76fe120d81c96fa2a17ae41f0647c963dbb43cd:
>> >
>> > sfc: Update and improve kernel-doc for efx_mcdi_state & efx_mcdi_iface (2013-08-21 20:20:41 +0100)
>> >
>> > 1. Refactoring and cleanup in preparation for new hardware support.
>> > 2. Some bug fixes for firmware completion handling. (They're not known
>> > to cause real problems, otherwise I'd be submitting these for net and
>> > stable.)
>> > 3. Update to the firmware protocol (MCDI) definitions.
>>
>> Pulled, but I want to point out an existing issue which is that using
>> an atomic_t for mcdi->state is bogus. You're only using atomic_set()
>> and atomic_read() on the value, and that provides no "atomicity" per-se.
>
> Thanks. I don't know what you looked for, but there are actually two
> atomic_cmpxchg() calls in mcdi.c.
I still think atomic_t is not appropriate, you can use plain xchg() as we
do all over the IPV4 stack, such as in the TCP metrics cache and the
routing code.
Really, if I don't see an atomic_*_and_test() or similar kind of
operation being used, I really don't want to see an atomic_t type in
use.
^ permalink raw reply
* Re: [PATCH] ipv6:examine the IP source address legitimacy
From: David Miller @ 2013-08-27 16:32 UTC (permalink / raw)
To: duanj.fnst; +Cc: netdev
In-Reply-To: <521C90A0.60708@cn.fujitsu.com>
From: Duan Jiong <duanj.fnst@cn.fujitsu.com>
Date: Tue, 27 Aug 2013 19:42:24 +0800
> rt = (struct rt6_info *) dst;
> - if (rt == net->ipv6.ip6_null_entry) {
> + if (rt == net->ipv6.ip6_null_entry || !ipv6_addr_equal(&rt->rt6i_gateway, &iph->saddr)) {
This line is significantly longer than 80 columns, please do not
create such long lines.
^ permalink raw reply
* Re: Pull request: sfc-next 2013-08-25
From: Ben Hutchings @ 2013-08-27 16:26 UTC (permalink / raw)
To: David Miller; +Cc: netdev, linux-net-drivers
In-Reply-To: <20130827.121826.532177208564127527.davem@davemloft.net>
On Tue, 2013-08-27 at 12:18 -0400, David Miller wrote:
> From: Ben Hutchings <bhutchings@solarflare.com>
> Date: Sun, 25 Aug 2013 23:56:03 +0100
>
> > The following changes since commit f073dde03b3e8d11050d82f52caaf75fd924e069:
> >
> > sfc: Make efx_mcdi_init() call efx_mcdi_handle_assertion() (2013-08-21 19:43:09 +0100)
> >
> > are available in the git repository at:
> >
> > git://git.kernel.org/pub/scm/linux/kernel/git/bwh/sfc-next.git for-davem
> >
> > for you to fetch changes up to f76fe120d81c96fa2a17ae41f0647c963dbb43cd:
> >
> > sfc: Update and improve kernel-doc for efx_mcdi_state & efx_mcdi_iface (2013-08-21 20:20:41 +0100)
> >
> > 1. Refactoring and cleanup in preparation for new hardware support.
> > 2. Some bug fixes for firmware completion handling. (They're not known
> > to cause real problems, otherwise I'd be submitting these for net and
> > stable.)
> > 3. Update to the firmware protocol (MCDI) definitions.
>
> Pulled, but I want to point out an existing issue which is that using
> an atomic_t for mcdi->state is bogus. You're only using atomic_set()
> and atomic_read() on the value, and that provides no "atomicity" per-se.
Thanks. I don't know what you looked for, but there are actually two
atomic_cmpxchg() calls in mcdi.c.
Ben.
--
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
^ permalink raw reply
* Re: [PATCH net-next] {ipv4,xfrm}: Introduce xfrm_tunnel_notifier for xfrm tunnel mode callback
From: David Miller @ 2013-08-27 16:23 UTC (permalink / raw)
To: steffen.klassert; +Cc: fan.du, saurabh.mohan, herbert, netdev
In-Reply-To: <20130827092856.GC7660@secunet.com>
From: Steffen Klassert <steffen.klassert@secunet.com>
Date: Tue, 27 Aug 2013 11:28:56 +0200
> I'd take this into ipsec-next and update the the ipv6 vti patch
> according to your changes if David does not mind.
This is fine.
^ permalink raw reply
* Re: [PATCH 0/2] net/cadence/macb: add support for dt phy definition
From: David Miller @ 2013-08-27 16:20 UTC (permalink / raw)
To: b.brezillon
Cc: nicolas.ferre, rob.herring, pawel.moll, mark.rutland, swarren,
ian.campbell, linux, f.fainelli, netdev, linux-kernel,
linux-arm-kernel, devicetree
In-Reply-To: <521C586A.7080604@overkiz.com>
From: boris brezillon <b.brezillon@overkiz.com>
Date: Tue, 27 Aug 2013 09:42:34 +0200
> Could you apply, the 3rd version of this series instead ?
There can never be an "instead" or reverting patches I've said I've
applied already.
If you want changes, you have to submit follow-on fixes.
^ permalink raw reply
* Re: Pull request: sfc-next 2013-08-25
From: David Miller @ 2013-08-27 16:18 UTC (permalink / raw)
To: bhutchings; +Cc: netdev, linux-net-drivers
In-Reply-To: <1377471363.2586.69.camel@deadeye.wl.decadent.org.uk>
From: Ben Hutchings <bhutchings@solarflare.com>
Date: Sun, 25 Aug 2013 23:56:03 +0100
> The following changes since commit f073dde03b3e8d11050d82f52caaf75fd924e069:
>
> sfc: Make efx_mcdi_init() call efx_mcdi_handle_assertion() (2013-08-21 19:43:09 +0100)
>
> are available in the git repository at:
>
> git://git.kernel.org/pub/scm/linux/kernel/git/bwh/sfc-next.git for-davem
>
> for you to fetch changes up to f76fe120d81c96fa2a17ae41f0647c963dbb43cd:
>
> sfc: Update and improve kernel-doc for efx_mcdi_state & efx_mcdi_iface (2013-08-21 20:20:41 +0100)
>
> 1. Refactoring and cleanup in preparation for new hardware support.
> 2. Some bug fixes for firmware completion handling. (They're not known
> to cause real problems, otherwise I'd be submitting these for net and
> stable.)
> 3. Update to the firmware protocol (MCDI) definitions.
Pulled, but I want to point out an existing issue which is that using
an atomic_t for mcdi->state is bogus. You're only using atomic_set()
and atomic_read() on the value, and that provides no "atomicity" per-se.
^ permalink raw reply
* Re: pcie_get_minimum_link returns 0 width
From: Bjorn Helgaas @ 2013-08-27 16:13 UTC (permalink / raw)
To: Yuval Mintz
Cc: jacob.e.keller@intel.com, linux-pci@vger.kernel.org,
netdev@vger.kernel.org, Jiang Liu
In-Reply-To: <CAErSpo6pCzw6Gjn+SCFhu7PnBpHkUz0oqO+tGmmOH8NxoMiH6g@mail.gmail.com>
On Tue, Aug 27, 2013 at 07:57:20AM -0600, Bjorn Helgaas wrote:
> [+cc Jiang]
>
> On Tue, Aug 27, 2013 at 1:40 AM, Yuval Mintz <yuvalmin@broadcom.com> wrote:
> >> On Mon, Aug 26, 2013 at 5:36 PM, Yuval Mintz <yuvalmin@broadcom.com>
> >> wrote:
> >> >> > Hi,
> >> >> >
> >> >> > I tried adding support for the newly added 'pcie_get_minimum_link' into
> >> >> the
> >> >> > bnx2x driver, but found out the some of my devices started showing
> >> width
> >> >> x0.
> >> >> >
> >> >> > By adding debug prints, I've found out there were devices up the chain
> >> that
> >> >> > Showed 0 when their PCI_EXP_LNKSTA was read by said function.
> >> >> > However, when I tried looking via lspci the output claimed the width was
> >> >> x4.
> >> Looking at its implementation, one obvious difference is that
> >> pcie_get_minimum_link() traverses up the hierarchy and keeps track of
> >> the minimum values it finds. lspci, on the other hand, just reads
> >> PCI_EXP_LNKSTA from a single device and decodes it.
> >>
> >> You said lspci reports x4 for every device from the Root Port all the
> >> way down to your NIC, so I would think the minimum from
> >> pcie_get_minimum_link() would be x4. But apparently it's not. Maybe
> >> there's a bug in it. Can you post the complete "lspci -vv" output
> >> along with your debug patch and output?
> >>
> >> Bjorn
> >
> > Here's the patch:
> > ---
> > drivers/pci/pci.c | 8 +++++++-
> > 1 files changed, 7 insertions(+), 1 deletions(-)
> >
> > diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> > index c71e78c..72cb87b 100644
> > --- a/drivers/pci/pci.c
> > +++ b/drivers/pci/pci.c
> > @@ -3601,13 +3601,19 @@ int pcie_get_minimum_link(struct pci_dev *dev, enum pci_bus_speed *speed,
> > enum pcie_link_width next_width;
> >
> > ret = pcie_capability_read_word(dev, PCI_EXP_LNKSTA, &lnksta);
> > - if (ret)
> > + if (ret) {
> > + printk(KERN_ERR "Failed to Read LNKSTA\n");
> > return ret;
> > + }
> >
> > next_speed = pcie_link_speed[lnksta & PCI_EXP_LNKSTA_CLS];
> > next_width = (lnksta & PCI_EXP_LNKSTA_NLW) >>
> > PCI_EXP_LNKSTA_NLW_SHIFT;
> >
> > + printk(KERN_ERR "LnkSta %04x [%04x:%02x.%02x]\n",
> > + lnksta, dev->bus->number, PCI_SLOT(dev->devfn),
> > + PCI_FUNC(dev->devfn));
>
> I think pcie_cap_has_lnkctl() is incorrect: it currently thinks only
> Root Ports, Endpoints, and Legacy Endpoints have link registers. But
> I think switch ports (Upstream Ports and Downstream Ports) also have
> link registers (PCIe spec r3.0, sec 7.8). Jiang?
Yuval, can you try the patch below?
PCI: Allow access to link-related registers for switch and bridge ports
From: Bjorn Helgaas <bhelgaas@google.com>
Every PCIe device has a link, except Root Complex Integrated Endpoints
and Root Complex Event Collectors. Previously we didn't give access
to PCIe capability link-related registers for Upstream Ports, Downstream
Ports, and bridges, so attempts to read PCI_EXP_LNKCTL returned zero.
See PCIe spec r3.0, sec 7.8 and 1.3.2.3.
Reported-by: Yuval Mintz <yuvalmin@broadcom.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
drivers/pci/access.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/pci/access.c b/drivers/pci/access.c
index 1cc2366..46dd5ad 100644
--- a/drivers/pci/access.c
+++ b/drivers/pci/access.c
@@ -485,9 +485,8 @@ static inline bool pcie_cap_has_lnkctl(const struct pci_dev *dev)
int type = pci_pcie_type(dev);
return pcie_cap_version(dev) > 1 ||
- type == PCI_EXP_TYPE_ROOT_PORT ||
- type == PCI_EXP_TYPE_ENDPOINT ||
- type == PCI_EXP_TYPE_LEG_END;
+ !(type == PCI_EXP_TYPE_RC_END ||
+ type == PCI_EXP_TYPE_RC_EC);
}
static inline bool pcie_cap_has_sltctl(const struct pci_dev *dev)
^ permalink raw reply related
* [PATCH] Add WLI-UC-G300HP's Product ID.
From: Masami Ichikawa @ 2013-08-27 15:37 UTC (permalink / raw)
To: IvDoorn, gwingerde, helmut.schaa, linville
Cc: Masami Ichikawa, linux-wireless, users, netdev, linux-kernel
Support Bufallo WLI-UC-G300HP.
Signed-off-by: Masami Ichikawa <masami256@gmail.com>
---
drivers/net/wireless/rt2x00/rt2800usb.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/net/wireless/rt2x00/rt2800usb.c b/drivers/net/wireless/rt2x00/rt2800usb.c
index 840833b..518277d 100644
--- a/drivers/net/wireless/rt2x00/rt2800usb.c
+++ b/drivers/net/wireless/rt2x00/rt2800usb.c
@@ -977,6 +977,7 @@ static struct usb_device_id rt2800usb_device_table[] = {
{ USB_DEVICE(0x0411, 0x016f) },
{ USB_DEVICE(0x0411, 0x01a2) },
{ USB_DEVICE(0x0411, 0x01ee) },
+ { USB_DEVICE(0x0411, 0x01a8) },
/* Corega */
{ USB_DEVICE(0x07aa, 0x002f) },
{ USB_DEVICE(0x07aa, 0x003c) },
--
1.8.3.1
^ permalink raw reply related
* Re: [PATCH] tipc: set sk_err correctly when connection fails
From: Erik Hugne @ 2013-08-27 15:18 UTC (permalink / raw)
To: Paul Gortmaker; +Cc: netdev, jon.maloy, ying.xue, tipc-discussion, nhan.tt.vo
In-Reply-To: <521CA797.2010109@windriver.com>
On Tue, Aug 27, 2013 at 09:20:23AM -0400, Paul Gortmaker wrote:
> What was the high level user visible symptom in this case?
> Stalled connections or ... ?
Should the connect fail, if the publication/server is unavailable or some other
error. The connect() call returns the error code directly (as a positive value).
[...]
socket(0x1e /* PF_??? */, SOCK_SEQPACKET, 0) = 3
setsockopt(3, 0x10f /* SOL_?? */, 129, [0], 4) = 0
setsockopt(3, 0x10f /* SOL_?? */, 127, [0], 4) = 0
connect(3, {sa_family=0x1e /* AF_??? */, sa_data="\2\1\322\4\0\0\322\4\0\0\0\0\0\0"}, 16) = 111
sendto(3, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 66000, 0, NULL, 0) = -1 EPIPE (Broken pipe)
In the strace above, error checking was done as:
if (connect(fd,.....) < 0)
perror("connect");
//E
^ permalink raw reply
* [PATCH] virtio-net: Set RXCSUM feature if GUEST_CSUM is available
From: Thomas Huth @ 2013-08-27 15:09 UTC (permalink / raw)
To: virtualization; +Cc: netdev, Thomas Huth
If the VIRTIO_NET_F_GUEST_CSUM virtio feature is available, the guest
does not have to calculate the checksums on all received packets. This
is pretty much the same feature as RX checksum offloading on real
network cards, so the virtio-net driver should report this by setting
the NETIF_F_RXCSUM flag. When the user now runs "ethtool -k", he or she
can see whether the virtio-net interface has to calculate RX checksums
or not.
Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
---
drivers/net/virtio_net.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index f216002..defec2b 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -1538,6 +1538,8 @@ static int virtnet_probe(struct virtio_device *vdev)
dev->features |= dev->hw_features & (NETIF_F_ALL_TSO|NETIF_F_UFO);
/* (!csum && gso) case will be fixed by register_netdev() */
}
+ if (virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_CSUM))
+ dev->features |= NETIF_F_RXCSUM;
dev->vlan_features = dev->features;
--
1.8.1.4
^ permalink raw reply related
* Re: niu lock-up (Transmit timed out, resetting) and NETDEV WATCHDOG
From: Andrew Brooks @ 2013-08-27 15:01 UTC (permalink / raw)
To: Linux Net-Dev Mailing List, Linux Kernel Mailing List
In-Reply-To: <CAHOfOo0kdByd3T0LL4tBpy-aFtJS6bRK7D=rPc6Si0iv03CLKQ@mail.gmail.com>
Hi
> On 26 March 2013 13:44, Andrew Brooks <arb@sat.dundee.ac.uk> wrote:
>> Using niu driver for this card: Oracle/SUN Multithreaded 10-Gigabit
>> Ethernet Network Controller and after a period the interface will hang
>> with errors every 5 seconds
>> "niu: xxx: eth2: Transmit timed out, resetting"
Here's more information about the problem:
When the interface hangs we see these messages from the driver:
[3408740.816032] niu: niu_interrupt() ldg[ffff8807141d16d0](18)
v0[8000000000] v1[0] v2[0]
[3408740.816036] niu 0000:09:00.0: eth2: niu_txchan_intr() cs[b860b860000c000]
[3408740.816038] niu 0000:09:00.0: eth2: niu_poll_core() v0[0000008000000000]
[3408740.816040] niu 0000:09:00.0: eth2: niu_tx_work() pkt_cnt[0] cons[119]
[3408740.816042] niu: niu_interrupt() ldg[ffff8807141d16d0](18)
v0[8000000000] v1[0] v2[0]
[3408740.820004] [sched_delayed] sched: RT throttling activated
[3408740.824021] niu 0000:09:00.0: eth2: Disable interrupts
[3408740.824044] niu 0000:09:00.0: eth2: Disable RX MAC
[3408740.824048] niu 0000:09:00.0: eth2: Disable IPP
[3408740.824054] niu 0000:09:00.0: eth2: Stop TX channels
[3408740.824641] niu 0000:09:00.0: eth2: Stop RX channels
[3408740.824652] niu 0000:09:00.0: eth2: Reset TX channels
[3408740.825212] niu 0000:09:00.0: eth2: Reset RX channels
[3408740.825999] niu 0000:09:00.0: eth2: Initialize TXC
[3408740.826002] niu 0000:09:00.0: eth2: Initialize TX channels
However the interface doesn't recover :-(
Are there any clues there?
Thanks!
^ permalink raw reply
* [PATCH net-next v3] net: sctp: sctp_verify_init: clean up mandatory checks and add comment
From: Daniel Borkmann @ 2013-08-27 14:53 UTC (permalink / raw)
To: davem; +Cc: netdev, linux-sctp
Add a comment related to RFC4960 explaning why we do not check for initial
TSN, and while at it, remove yoda notation checks and clean up code from
checks of mandatory conditions. That's probably just really minor, but makes
reviewing easier.
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
Acked-by: Neil Horman <nhorman@tuxdriver.com>
---
v1->v2: update comment as Neil suggested
v2->v3: fix stupid typo in comment in range spotted by Sergei
net/sctp/sm_make_chunk.c | 26 ++++++++++++--------------
1 file changed, 12 insertions(+), 14 deletions(-)
diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c
index 01e9783..e1c1531 100644
--- a/net/sctp/sm_make_chunk.c
+++ b/net/sctp/sm_make_chunk.c
@@ -2240,25 +2240,23 @@ int sctp_verify_init(struct net *net, const struct sctp_association *asoc,
struct sctp_chunk **errp)
{
union sctp_params param;
- int has_cookie = 0;
+ bool has_cookie = false;
int result;
- /* Verify stream values are non-zero. */
- if ((0 == peer_init->init_hdr.num_outbound_streams) ||
- (0 == peer_init->init_hdr.num_inbound_streams) ||
- (0 == peer_init->init_hdr.init_tag) ||
- (SCTP_DEFAULT_MINWINDOW > ntohl(peer_init->init_hdr.a_rwnd))) {
-
+ /* Check for missing mandatory parameters. Note: Initial TSN is
+ * also mandatory, but is not checked here since the valid range
+ * is 0..2**32-1. RFC4960, section 3.3.3.
+ */
+ if (peer_init->init_hdr.num_outbound_streams == 0 ||
+ peer_init->init_hdr.num_inbound_streams == 0 ||
+ peer_init->init_hdr.init_tag == 0 ||
+ ntohl(peer_init->init_hdr.a_rwnd) < SCTP_DEFAULT_MINWINDOW)
return sctp_process_inv_mandatory(asoc, chunk, errp);
- }
- /* Check for missing mandatory parameters. */
sctp_walk_params(param, peer_init, init_hdr.params) {
-
- if (SCTP_PARAM_STATE_COOKIE == param.p->type)
- has_cookie = 1;
-
- } /* for (loop through all parameters) */
+ if (param.p->type == SCTP_PARAM_STATE_COOKIE)
+ has_cookie = true;
+ }
/* There is a possibility that a parameter length was bad and
* in that case we would have stoped walking the parameters.
--
1.7.11.7
^ permalink raw reply related
* [PATCH 3/3] Send cgroup_path in SCM_CGROUP
From: Jan Kaluza @ 2013-08-27 14:40 UTC (permalink / raw)
To: davem; +Cc: LKML, netdev, eparis, rgb, Jan Kaluza
In-Reply-To: <1377614400-27122-1-git-send-email-jkaluza@redhat.com>
Signed-off-by: Jan Kaluza <jkaluza@redhat.com>
---
include/linux/socket.h | 1 +
include/net/af_unix.h | 1 +
include/net/scm.h | 15 +++++++++++++++
net/core/scm.c | 18 ++++++++++++++++++
net/unix/af_unix.c | 20 ++++++++++++++++++++
5 files changed, 55 insertions(+)
diff --git a/include/linux/socket.h b/include/linux/socket.h
index 6c7ace0..621fff1 100644
--- a/include/linux/socket.h
+++ b/include/linux/socket.h
@@ -133,6 +133,7 @@ static inline struct cmsghdr * cmsg_nxthdr (struct msghdr *__msg, struct cmsghdr
#define SCM_AUDIT 0x04 /* rw: struct uaudit */
#define SCM_PROCINFO 0x05 /* rw: comm + cmdline (NULL terminated
array of char *) */
+#define SCM_CGROUP 0x06 /* rw: cgroup path */
struct ucred {
__u32 pid;
diff --git a/include/net/af_unix.h b/include/net/af_unix.h
index 05c7678..c49bf35 100644
--- a/include/net/af_unix.h
+++ b/include/net/af_unix.h
@@ -32,6 +32,7 @@ struct unix_skb_parms_scm {
unsigned int sessionid;
char *procinfo;
int procinfo_len;
+ char *cgroup_path;
};
struct unix_skb_parms {
diff --git a/include/net/scm.h b/include/net/scm.h
index 3346030..5398826 100644
--- a/include/net/scm.h
+++ b/include/net/scm.h
@@ -41,6 +41,7 @@ struct scm_cookie {
struct scm_creds creds; /* Skb credentials */
struct scm_audit audit; /* Skb audit */
struct scm_procinfo procinfo; /* Skb procinfo */
+ char *cgroup_path;
#ifdef CONFIG_SECURITY_NETWORK
u32 secid; /* Passed security ID */
#endif
@@ -52,6 +53,7 @@ extern int __scm_send(struct socket *sock, struct msghdr *msg, struct scm_cookie
extern void __scm_destroy(struct scm_cookie *scm);
extern struct scm_fp_list * scm_fp_dup(struct scm_fp_list *fpl);
extern int scm_get_current_procinfo(char **procinfo);
+extern int scm_get_current_cgroup_path(char **cgroup_path);
#ifdef CONFIG_SECURITY_NETWORK
static __inline__ void unix_get_peersec_dgram(struct socket *sock, struct scm_cookie *scm)
@@ -86,6 +88,12 @@ static inline void scm_set_procinfo(struct scm_cookie *scm,
scm->procinfo.len = len;
}
+static inline void scm_set_cgroup_path(struct scm_cookie *scm,
+ char *cgroup_path)
+{
+ scm->cgroup_path = cgroup_path;
+}
+
static __inline__ void scm_destroy_cred(struct scm_cookie *scm)
{
put_pid(scm->pid);
@@ -140,6 +148,9 @@ static inline void scm_passec(struct socket *sock, struct msghdr *msg, struct sc
security_release_secctx(secdata, seclen);
}
}
+
+ kfree(scm->cgroup_path);
+ scm->cgroup_path = NULL;
}
#else
static inline void scm_passec(struct socket *sock, struct msghdr *msg, struct scm_cookie *scm)
@@ -172,6 +183,10 @@ static __inline__ void scm_recv(struct socket *sock, struct msghdr *msg,
put_cmsg(msg, SOL_SOCKET, SCM_AUDIT, sizeof(uaudits), &uaudits);
put_cmsg(msg, SOL_SOCKET, SCM_PROCINFO, scm->procinfo.len,
scm->procinfo.procinfo);
+ if (scm->cgroup_path) {
+ put_cmsg(msg, SOL_SOCKET, SCM_CGROUP,
+ strlen(scm->cgroup_path), scm->cgroup_path);
+ }
}
scm_destroy_cred(scm);
diff --git a/net/core/scm.c b/net/core/scm.c
index 09ec044..2d408b9 100644
--- a/net/core/scm.c
+++ b/net/core/scm.c
@@ -404,3 +404,21 @@ out:
return res;
}
EXPORT_SYMBOL(scm_get_current_procinfo);
+
+int scm_get_current_cgroup_path(char **cgroup_path)
+{
+ int ret = 0;
+
+ *cgroup_path = kmalloc(PAGE_SIZE, GFP_KERNEL);
+ if (!(*cgroup_path))
+ return -ENOMEM;
+
+ ret = task_cgroup_path(current, *cgroup_path, PAGE_SIZE);
+ if (ret < 0) {
+ kfree(*cgroup_path);
+ *cgroup_path = NULL;
+ }
+
+ return ret;
+}
+EXPORT_SYMBOL(scm_get_current_cgroup_path);
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index ab0be13..b638083 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -1344,6 +1344,7 @@ static void unix_destruct_scm(struct sk_buff *skb)
if (UNIXCB(skb).scm) {
scm.procinfo.procinfo = UNIXSCM(skb).procinfo;
scm.procinfo.len = UNIXSCM(skb).procinfo_len;
+ scm.cgroup_path = UNIXSCM(skb).cgroup_path;
}
if (UNIXCB(skb).fp)
unix_detach_fds(&scm, skb);
@@ -1420,6 +1421,14 @@ static int unix_scm_to_skb(struct scm_cookie *scm, struct sk_buff *skb, bool sen
return -ENOMEM;
}
+ UNIXSCM(skb).cgroup_path = NULL;
+ if (scm->cgroup_path) {
+ UNIXSCM(skb).cgroup_path = kstrdup(scm->cgroup_path,
+ GFP_KERNEL);
+ if (!UNIXSCM(skb).cgroup_path)
+ return -ENOMEM;
+ }
+
skb->destructor = unix_destruct_scm;
return err;
}
@@ -1443,6 +1452,7 @@ static void maybe_add_creds(struct sk_buff *skb, const struct socket *sock,
UNIXSCM(skb).sessionid = audit_get_sessionid(current);
UNIXSCM(skb).procinfo_len = scm_get_current_procinfo(
&UNIXSCM(skb).procinfo);
+ scm_get_current_cgroup_path(&UNIXSCM(skb).cgroup_path);
}
}
@@ -1849,6 +1859,11 @@ static int unix_dgram_recvmsg(struct kiocb *iocb, struct socket *sock,
GFP_KERNEL),
UNIXSCM(skb).procinfo_len);
}
+ if (UNIXSCM(skb).cgroup_path) {
+ scm_set_cgroup_path(siocb->scm,
+ kstrdup(UNIXSCM(skb).cgroup_path,
+ GFP_KERNEL));
+ }
}
unix_set_secdata(siocb->scm, skb);
@@ -2042,6 +2057,11 @@ again:
GFP_KERNEL),
UNIXSCM(skb).procinfo_len);
}
+ if (UNIXSCM(skb).cgroup_path) {
+ scm_set_cgroup_path(siocb->scm,
+ kstrdup(UNIXSCM(skb).cgroup_path,
+ GFP_KERNEL));
+ }
}
check_creds = 1;
}
--
1.8.3.1
^ permalink raw reply related
* [PATCH 2/3] Send comm and cmdline in SCM_PROCINFO
From: Jan Kaluza @ 2013-08-27 14:39 UTC (permalink / raw)
To: davem; +Cc: LKML, netdev, eparis, rgb, Jan Kaluza
In-Reply-To: <1377614400-27122-1-git-send-email-jkaluza@redhat.com>
Signed-off-by: Jan Kaluza <jkaluza@redhat.com>
---
include/linux/socket.h | 2 ++
include/net/af_unix.h | 11 +++++++--
include/net/scm.h | 24 +++++++++++++++++++
net/core/scm.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++
net/unix/af_unix.c | 57 +++++++++++++++++++++++++++++++++++++------
5 files changed, 150 insertions(+), 9 deletions(-)
diff --git a/include/linux/socket.h b/include/linux/socket.h
index 505047a..6c7ace0 100644
--- a/include/linux/socket.h
+++ b/include/linux/socket.h
@@ -131,6 +131,8 @@ static inline struct cmsghdr * cmsg_nxthdr (struct msghdr *__msg, struct cmsghdr
#define SCM_CREDENTIALS 0x02 /* rw: struct ucred */
#define SCM_SECURITY 0x03 /* rw: security label */
#define SCM_AUDIT 0x04 /* rw: struct uaudit */
+#define SCM_PROCINFO 0x05 /* rw: comm + cmdline (NULL terminated
+ array of char *) */
struct ucred {
__u32 pid;
diff --git a/include/net/af_unix.h b/include/net/af_unix.h
index 3b9d22a..05c7678 100644
--- a/include/net/af_unix.h
+++ b/include/net/af_unix.h
@@ -27,6 +27,13 @@ struct unix_address {
struct sockaddr_un name[0];
};
+struct unix_skb_parms_scm {
+ kuid_t loginuid;
+ unsigned int sessionid;
+ char *procinfo;
+ int procinfo_len;
+};
+
struct unix_skb_parms {
struct pid *pid; /* Skb credentials */
kuid_t uid;
@@ -36,12 +43,12 @@ struct unix_skb_parms {
u32 secid; /* Security ID */
#endif
u32 consumed;
- kuid_t loginuid;
- unsigned int sessionid;
+ struct unix_skb_parms_scm *scm;
};
#define UNIXCB(skb) (*(struct unix_skb_parms *)&((skb)->cb))
#define UNIXSID(skb) (&UNIXCB((skb)).secid)
+#define UNIXSCM(skb) (*(UNIXCB((skb)).scm))
#define unix_state_lock(s) spin_lock(&unix_sk(s)->lock)
#define unix_state_unlock(s) spin_unlock(&unix_sk(s)->lock)
diff --git a/include/net/scm.h b/include/net/scm.h
index e349a25..3346030 100644
--- a/include/net/scm.h
+++ b/include/net/scm.h
@@ -30,11 +30,17 @@ struct scm_fp_list {
struct file *fp[SCM_MAX_FD];
};
+struct scm_procinfo {
+ char *procinfo;
+ int len;
+};
+
struct scm_cookie {
struct pid *pid; /* Skb credentials */
struct scm_fp_list *fp; /* Passed files */
struct scm_creds creds; /* Skb credentials */
struct scm_audit audit; /* Skb audit */
+ struct scm_procinfo procinfo; /* Skb procinfo */
#ifdef CONFIG_SECURITY_NETWORK
u32 secid; /* Passed security ID */
#endif
@@ -45,6 +51,7 @@ extern void scm_detach_fds_compat(struct msghdr *msg, struct scm_cookie *scm);
extern int __scm_send(struct socket *sock, struct msghdr *msg, struct scm_cookie *scm);
extern void __scm_destroy(struct scm_cookie *scm);
extern struct scm_fp_list * scm_fp_dup(struct scm_fp_list *fpl);
+extern int scm_get_current_procinfo(char **procinfo);
#ifdef CONFIG_SECURITY_NETWORK
static __inline__ void unix_get_peersec_dgram(struct socket *sock, struct scm_cookie *scm)
@@ -72,10 +79,20 @@ static inline void scm_set_audit(struct scm_cookie *scm,
scm->audit.sessionid = sessionid;
}
+static inline void scm_set_procinfo(struct scm_cookie *scm,
+ char *procinfo, int len)
+{
+ scm->procinfo.procinfo = procinfo;
+ scm->procinfo.len = len;
+}
+
static __inline__ void scm_destroy_cred(struct scm_cookie *scm)
{
put_pid(scm->pid);
scm->pid = NULL;
+ kfree(scm->procinfo.procinfo);
+ scm->procinfo.procinfo = NULL;
+ scm->procinfo.len = 0;
}
static __inline__ void scm_destroy(struct scm_cookie *scm)
@@ -88,6 +105,8 @@ static __inline__ void scm_destroy(struct scm_cookie *scm)
static __inline__ int scm_send(struct socket *sock, struct msghdr *msg,
struct scm_cookie *scm, bool forcecreds)
{
+ char *procinfo;
+ int len;
memset(scm, 0, sizeof(*scm));
scm->creds.uid = INVALID_UID;
scm->creds.gid = INVALID_GID;
@@ -96,6 +115,9 @@ static __inline__ int scm_send(struct socket *sock, struct msghdr *msg,
current_gid());
scm_set_audit(scm, audit_get_loginuid(current),
audit_get_sessionid(current));
+ len = scm_get_current_procinfo(&procinfo);
+ if (len > 0)
+ scm_set_procinfo(scm, procinfo, len);
}
unix_get_peersec_dgram(sock, scm);
if (msg->msg_controllen <= 0)
@@ -148,6 +170,8 @@ static __inline__ void scm_recv(struct socket *sock, struct msghdr *msg,
};
put_cmsg(msg, SOL_SOCKET, SCM_CREDENTIALS, sizeof(ucreds), &ucreds);
put_cmsg(msg, SOL_SOCKET, SCM_AUDIT, sizeof(uaudits), &uaudits);
+ put_cmsg(msg, SOL_SOCKET, SCM_PROCINFO, scm->procinfo.len,
+ scm->procinfo.procinfo);
}
scm_destroy_cred(scm);
diff --git a/net/core/scm.c b/net/core/scm.c
index 03795d0..09ec044 100644
--- a/net/core/scm.c
+++ b/net/core/scm.c
@@ -339,3 +339,68 @@ struct scm_fp_list *scm_fp_dup(struct scm_fp_list *fpl)
return new_fpl;
}
EXPORT_SYMBOL(scm_fp_dup);
+
+int scm_get_current_procinfo(char **procinfo)
+{
+ int res = 0;
+ unsigned int len;
+ char *buffer = NULL;
+ struct mm_struct *mm;
+ int comm_len = strlen(current->comm);
+
+ *procinfo = NULL;
+
+ buffer = kmalloc(PAGE_SIZE, GFP_KERNEL);
+ if (!buffer)
+ return -ENOMEM;
+
+ mm = get_task_mm(current);
+ if (!mm)
+ goto out;
+ if (!mm->arg_end)
+ goto out_mm; /* Shh! No looking before we're done */
+
+ len = mm->arg_end - mm->arg_start;
+
+ if (len > PAGE_SIZE)
+ len = PAGE_SIZE;
+
+ res = access_process_vm(current, mm->arg_start, buffer, len, 0);
+
+ /* If the nul at the end of args has been overwritten, then
+ * assume application is using setproctitle(3).
+ */
+ if (res > 0 && buffer[res-1] != '\0' && len < PAGE_SIZE) {
+ len = strnlen(buffer, res);
+ if (len < res) {
+ res = len;
+ } else {
+ len = mm->env_end - mm->env_start;
+ if (len > PAGE_SIZE - res)
+ len = PAGE_SIZE - res;
+ res += access_process_vm(current, mm->env_start,
+ buffer+res, len, 0);
+ res = strnlen(buffer, res);
+ }
+ }
+
+ /* strlen(comm) + \0 + len of cmdline */
+ len = comm_len + 1 + res;
+ *procinfo = kmalloc(len, GFP_KERNEL);
+ if (!*procinfo) {
+ res = -ENOMEM;
+ goto out_mm;
+ }
+
+ memcpy(*procinfo, current->comm, comm_len + 1); /* include \0 */
+ if (res > 0)
+ memcpy(*procinfo + comm_len + 1, buffer, res);
+ res = len;
+
+out_mm:
+ mmput(mm);
+out:
+ kfree(buffer);
+ return res;
+}
+EXPORT_SYMBOL(scm_get_current_procinfo);
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index c410f76..ab0be13 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -1341,9 +1341,14 @@ static void unix_destruct_scm(struct sk_buff *skb)
struct scm_cookie scm;
memset(&scm, 0, sizeof(scm));
scm.pid = UNIXCB(skb).pid;
+ if (UNIXCB(skb).scm) {
+ scm.procinfo.procinfo = UNIXSCM(skb).procinfo;
+ scm.procinfo.len = UNIXSCM(skb).procinfo_len;
+ }
if (UNIXCB(skb).fp)
unix_detach_fds(&scm, skb);
+ kfree(UNIXCB(skb).scm);
/* Alas, it calls VFS */
/* So fscking what? fput() had been SMP-safe since the last Summer */
scm_destroy(&scm);
@@ -1390,15 +1395,31 @@ static int unix_scm_to_skb(struct scm_cookie *scm, struct sk_buff *skb, bool sen
{
int err = 0;
+ if (!UNIXCB(skb).scm) {
+ UNIXCB(skb).scm = kmalloc(sizeof(struct unix_skb_parms_scm),
+ GFP_KERNEL);
+ if (!UNIXCB(skb).scm)
+ return -ENOMEM;
+ }
+
UNIXCB(skb).pid = get_pid(scm->pid);
UNIXCB(skb).uid = scm->creds.uid;
UNIXCB(skb).gid = scm->creds.gid;
- UNIXCB(skb).loginuid = scm->audit.loginuid;
- UNIXCB(skb).sessionid = scm->audit.sessionid;
+ UNIXSCM(skb).loginuid = scm->audit.loginuid;
+ UNIXSCM(skb).sessionid = scm->audit.sessionid;
UNIXCB(skb).fp = NULL;
if (scm->fp && send_fds)
err = unix_attach_fds(scm, skb);
+ UNIXSCM(skb).procinfo = NULL;
+ if (scm->procinfo.procinfo) {
+ UNIXSCM(skb).procinfo_len = scm->procinfo.len;
+ UNIXSCM(skb).procinfo = kmemdup(scm->procinfo.procinfo,
+ scm->procinfo.len, GFP_KERNEL);
+ if (!UNIXSCM(skb).procinfo)
+ return -ENOMEM;
+ }
+
skb->destructor = unix_destruct_scm;
return err;
}
@@ -1418,8 +1439,10 @@ static void maybe_add_creds(struct sk_buff *skb, const struct socket *sock,
test_bit(SOCK_PASSCRED, &other->sk_socket->flags)) {
UNIXCB(skb).pid = get_pid(task_tgid(current));
current_uid_gid(&UNIXCB(skb).uid, &UNIXCB(skb).gid);
- UNIXCB(skb).loginuid = audit_get_loginuid(current);
- UNIXCB(skb).sessionid = audit_get_sessionid(current);
+ UNIXSCM(skb).loginuid = audit_get_loginuid(current);
+ UNIXSCM(skb).sessionid = audit_get_sessionid(current);
+ UNIXSCM(skb).procinfo_len = scm_get_current_procinfo(
+ &UNIXSCM(skb).procinfo);
}
}
@@ -1816,7 +1839,17 @@ static int unix_dgram_recvmsg(struct kiocb *iocb, struct socket *sock,
memset(&tmp_scm, 0, sizeof(tmp_scm));
}
scm_set_cred(siocb->scm, UNIXCB(skb).pid, UNIXCB(skb).uid, UNIXCB(skb).gid);
- scm_set_audit(siocb->scm, UNIXCB(skb).loginuid, UNIXCB(skb).sessionid);
+ if (UNIXCB(skb).scm) {
+ scm_set_audit(siocb->scm, UNIXSCM(skb).loginuid,
+ UNIXSCM(skb).sessionid);
+ if (UNIXSCM(skb).procinfo) {
+ scm_set_procinfo(siocb->scm,
+ kmemdup(UNIXSCM(skb).procinfo,
+ UNIXSCM(skb).procinfo_len,
+ GFP_KERNEL),
+ UNIXSCM(skb).procinfo_len);
+ }
+ }
unix_set_secdata(siocb->scm, skb);
if (!(flags & MSG_PEEK)) {
@@ -1998,8 +2031,18 @@ again:
} else if (test_bit(SOCK_PASSCRED, &sock->flags)) {
/* Copy credentials */
scm_set_cred(siocb->scm, UNIXCB(skb).pid, UNIXCB(skb).uid, UNIXCB(skb).gid);
- scm_set_audit(siocb->scm, UNIXCB(skb).loginuid,
- UNIXCB(skb).sessionid);
+ if (UNIXCB(skb).scm) {
+ scm_set_audit(siocb->scm,
+ UNIXSCM(skb).loginuid,
+ UNIXSCM(skb).sessionid);
+ if (UNIXSCM(skb).procinfo) {
+ scm_set_procinfo(siocb->scm,
+ kmemdup(UNIXSCM(skb).procinfo,
+ UNIXSCM(skb).procinfo_len,
+ GFP_KERNEL),
+ UNIXSCM(skb).procinfo_len);
+ }
+ }
check_creds = 1;
}
--
1.8.3.1
^ 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