Netdev List
 help / color / mirror / Atom feed
* [PATCH 1/26] rdma/cm: define native IB address
From: Sean Hefty @ 2010-04-01 17:08 UTC (permalink / raw)
  To: linux-rdma, 'Linux Netdev List'

Define AF_IB and sockaddr_ib to allow the rdma_cm to use native IB
addressing.

Signed-off-by: Sean Hefty <sean.hefty@intel.com>
---

 include/linux/socket.h |    2 +
 include/rdma/ib.h      |   89 ++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 91 insertions(+), 0 deletions(-)

diff --git a/include/linux/socket.h b/include/linux/socket.h
index 7b3aae2..966e268 100644
--- a/include/linux/socket.h
+++ b/include/linux/socket.h
@@ -181,6 +181,7 @@ struct ucred {
 #define AF_PPPOX	24	/* PPPoX sockets		*/
 #define AF_WANPIPE	25	/* Wanpipe API Sockets */
 #define AF_LLC		26	/* Linux LLC			*/
+#define AF_IB		27	/* Native InfiniBand address	*/
 #define AF_CAN		29	/* Controller Area Network      */
 #define AF_TIPC		30	/* TIPC sockets			*/
 #define AF_BLUETOOTH	31	/* Bluetooth sockets 		*/
@@ -221,6 +222,7 @@ struct ucred {
 #define PF_PPPOX	AF_PPPOX
 #define PF_WANPIPE	AF_WANPIPE
 #define PF_LLC		AF_LLC
+#define PF_IB		AF_IB
 #define PF_CAN		AF_CAN
 #define PF_TIPC		AF_TIPC
 #define PF_BLUETOOTH	AF_BLUETOOTH
diff --git a/include/rdma/ib.h b/include/rdma/ib.h
new file mode 100644
index 0000000..cf8f9e7
--- /dev/null
+++ b/include/rdma/ib.h
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2010 Intel Corporation.  All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses.  You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ *     Redistribution and use in source and binary forms, with or
+ *     without modification, are permitted provided that the following
+ *     conditions are met:
+ *
+ *      - Redistributions of source code must retain the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer.
+ *
+ *      - Redistributions in binary form must reproduce the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer in the documentation and/or other materials
+ *        provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#if !defined(_RDMA_IB_H)
+#define _RDMA_IB_H
+
+#include <linux/types.h>
+
+struct ib_addr {
+	union {
+		__u8		uib_addr8[16];
+		__be16		uib_addr16[8];
+		__be32		uib_addr32[4];
+		__be64		uib_addr64[2];
+	} ib_u;
+#define sib_addr8		ib_u.uib_addr8
+#define sib_addr16		ib_u.uib_addr16
+#define sib_addr32		ib_u.uib_addr32
+#define sib_addr64		ib_u.uib_addr64
+#define sib_raw			ib_u.uib_addr8
+#define sib_subnet_prefix	ib_u.uib_addr64[0]
+#define sib_interface_id	ib_u.uib_addr64[1]
+};
+
+static inline int ib_addr_any(const struct ib_addr *a)
+{
+	return ((a->sib_addr64[0] | a->sib_addr64[1]) == 0);
+}
+
+static inline int ib_addr_loopback(const struct ib_addr *a)
+{
+	return ((a->sib_addr32[0] | a->sib_addr32[1] |
+		 a->sib_addr32[2] | (a->sib_addr32[3] ^ htonl(1))) == 0);
+}
+
+static inline void ib_addr_set(struct ib_addr *addr,
+			       __be32 w1, __be32 w2, __be32 w3, __be32 w4)
+{
+	addr->sib_addr32[0] = w1;
+	addr->sib_addr32[1] = w2;
+	addr->sib_addr32[2] = w3;
+	addr->sib_addr32[3] = w4;
+}
+
+static inline int ib_addr_cmp(const struct ib_addr *a1, const struct ib_addr *a2)
+{
+	return memcmp(a1, a2, sizeof(struct ib_addr));
+}
+
+struct sockaddr_ib {
+	unsigned short int	sib_family;	/* AF_IB */
+	__be16			sib_pkey;
+	__be32			sib_flowinfo;
+	struct ib_addr		sib_addr;
+	__be64			sib_sid;
+	__be64			sib_sid_mask;
+	__u64			sib_scope_id;
+};
+
+#endif /* _RDMA_IB_H */




^ permalink raw reply related

* Re: [netfilter / iptables] question
From: thomas yang @ 2010-04-01 17:11 UTC (permalink / raw)
  To: Jan Engelhardt; +Cc: netdev, Patrick McHardy
In-Reply-To: <alpine.LSU.2.01.1004011857440.788@obet.zrqbmnf.qr>

2010/4/2 Jan Engelhardt <jengelh@medozas.de>:
> On Thursday 2010-04-01 18:44, thomas yang wrote:
>
>>Hi,
>>
>>I want to copy/ clone a  sk_buff  *skb  to  *skb2  on my Linux router,
>>  then transmit both  skb2   and  skb  .
>>
>>How to do this with   netfilter hook function  / iptables  ?
>>
> Wait for xt_TEE to be merged.
>

I want to route skb to 'path 1' , route the copied/cloned skb2 to
'path 2'    simultaneously,
if one of them lose , it will not be a problem.

What's the function of xt_TEE ?


--
Tom

^ permalink raw reply

* Re: [PATCH] r8169: clean up my printk uglyness
From: Neil Horman @ 2010-04-01 17:30 UTC (permalink / raw)
  To: netdev; +Cc: davem, romieu, brandon
In-Reply-To: <20100401145356.GB14069@shamino.rdu.redhat.com>

On Thu, Apr 01, 2010 at 10:53:56AM -0400, Neil Horman wrote:
> Fix formatting on r8169 printk
> 
> Brandon Philips noted that I had a spacing issue in my printk for the last r8169
> patch that made it quite ugly.  Fix that up and add the PFX macro to it as well
> so it looks like the other r8169 printks
> 
> Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
> 
> 
Grr, yes thanks, V2, fixing my idiocy :)

Signed-off-by: Neil Horman <nhorman@tuxdriver.com>

 r8169.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c
index 9674005..a119885 100644
--- a/drivers/net/r8169.c
+++ b/drivers/net/r8169.c
@@ -3227,8 +3227,8 @@ static void rtl8169_set_rxbufsize(struct rtl8169_private *tp,
 	unsigned int max_frame = mtu + VLAN_ETH_HLEN + ETH_FCS_LEN;
 
 	if (max_frame != 16383)
-		printk(KERN_WARNING "WARNING! Changing of MTU on this NIC"
-			"May lead to frame reception errors!\n");
+		printk(KERN_WARNING PFX "WARNING! Changing of MTU on this "
+			"NIC may lead to frame reception errors!\n");
 
 	tp->rx_buf_sz = (max_frame > RX_BUF_SIZE) ? max_frame : RX_BUF_SIZE;
 }


^ permalink raw reply related

* Re: [PATCH 1/2] phylib: Support phy module autoloading
From: Ben Hutchings @ 2010-04-01 18:05 UTC (permalink / raw)
  To: David Woodhouse; +Cc: davem, netdev, 553024
In-Reply-To: <1270141428.3101.399.camel@macbook.infradead.org>

On Thu, Apr 01, 2010 at 06:03:48PM +0100, David Woodhouse wrote:
> On Thu, 2010-04-01 at 05:34 +0100, Ben Hutchings wrote:
[...]
> > Since you've dealt with (a), and (b) is not really as important, I would
> > just like to suggest some minor changes to your patch 1 (see below).
> > Feel free to fold them in.  Your patch 2 would then need the
> > substitutions s/phy_device_id/mdio_device_id/; s/TABLE(phy/TABLE(mdio/.
> 
> I'll tolerate the silly __u32 crap if I must for consistency, but
> normally I prefer to write in C.
> 
> I did think about 'mdio:' for the module alias, but I decided that
> 'phy:' probably made more sense since these are PHY driver modules and
> the number is the phy_id.
[...]

Many multi-layered communication standards have distinct PHY devices,
and they presumably have their own ID spaces.  phylib deals only with
management of Ethernet PHYs over an MDIO bus, identified using MDIO
ID registers.

Ben.

-- 
Ben Hutchings
We get into the habit of living before acquiring the habit of thinking.
                                                              - Albert Camus

^ permalink raw reply

* Any ideas about a crash on reboot with igb and intel_iommu?
From: Roland Dreier @ 2010-04-01 18:13 UTC (permalink / raw)
  To: netdev, iommu; +Cc: David Woodhouse

Hi everyone,

I've been asked to help debug a strange crash, and I'm wondering if
anyone has seen something similar.  The setup is a bit awkward because
this is happening in manufacturing burn-in and we have not reproduced it
in the lab yet, so my ability to do specific experiments is still
limited.

Anyway, we have a fairly standard two-socket Xeon server product that
passes all tests with Nehalem CPUs.  However, when we use Westmere CPUs
(which also requires a new BIOS of course), some fraction of the systems
are crashing during burn-in, which basically runs a cycle where it runs
CPU and memory stress tests and then reboots the system for the next
round of tests.  The crash is happening on reboot, and unfortunately I
only have a bunch of pictures of the traceback output, but we've seen
multiple cases where the system is crashing with a traceback like:

  rb_erase
  __free_iova
  flush_unmaps
  intel_unmap_page
  igb_clean_rx_ring
  igb_down
  igb_close
  __igb_shutdown
  igb_shutdown
  pci_device_shutdown
  device_shutdown
  kernel_restart_prepare
  kernel_restart
  sys_reboot

The newest kernel they've been able to try is 2.6.30.9, but from looking
at the kernel changelogs for igb and intel_iommu at least, I don't see
anything particularly promising that was fixed since then.

One other data point is that enabling the BIOS option "maximize memory
under 4GB" (which apparently just allocates less space for PCI BARs
below 4GB) seems to make this crash go away again.

Anyway, does this tickle anyone's memory?  I'm trying to get a better
handle on things, but if this has been seen before, I'd sure love to
skip some of the pain of debugging this.

Thanks,
  Roland
-- 
Roland Dreier <rolandd@cisco.com> || For corporate legal information go to:
http://www.cisco.com/web/about/doing_business/legal/cri/index.html

^ permalink raw reply

* Re: [PATCH v2] Add Mergeable RX buffer feature to vhost_net
From: David Stevens @ 2010-04-01 18:22 UTC (permalink / raw)
  To: Michael S. Tsirkin; +Cc: kvm, kvm-owner, netdev, rusty, virtualization
In-Reply-To: <20100401105415.GA3323@redhat.com>

kvm-owner@vger.kernel.org wrote on 04/01/2010 03:54:15 AM:

> On Wed, Mar 31, 2010 at 03:04:43PM -0700, David Stevens wrote:

> > 
> > > > +               head.iov_base = (void 
*)vhost_get_vq_desc(&net->dev, 
> > vq,
> > > > +                       vq->iov, ARRAY_SIZE(vq->iov), &out, &in, 
NULL, 
> > 
> > > > NULL);
> > > 
> > > I this casting confusing.
> > > Is it really expensive to add an array of heads so that
> > > we do not need to cast?
> > 
> >         It needs the heads and the lengths, which looks a lot
> > like an iovec. I was trying to resist adding a new
> > struct XXX { unsigned head; unsigned len; } just for this,
> > but I could make these parallel arrays, one with head index and
> > the other with length.

        Michael, on this one, if I add vq->heads as an argument to
vhost_get_heads (aka vhost_get_desc_n), I'd need the length too.
Would you rather this 1) remain an iovec (and a single arg added) but
cast still there, 2) 2 arrays (head and length) and 2 args added, or
3) a new struct type of {unsigned,int} to carry for the heads+len
instead of iovec?
        My preference would be 1). I agree the casts are ugly, but
it is essentially an iovec the way we use it; it's just that the
base isn't a pointer but a descriptor index instead.

> > 
> >         EAGAIN is not possible after the change, because we don't
> > even enter the loop unless we have an skb on the read queue; the
> > other cases bomb out, so I figured the comment for future work is
> > now done. :-)
> 
> Guest could be buggy so we'll get EFAULT.
> If skb is taken off the rx queue (as below), we might get EAGAIN.

        We break on any error. If we get EAGAIN because someone read
on the socket, this code would break the loop, but EAGAIN is a more
serious problem if it changed since we peeked (because it means
someone else is reading the socket).
        But I don't understand -- are you suggesting that the error
handling be different than that, or that the comment is still
relevant? My intention here is to do the "TODO" from the comment
so that it can be removed, by handling all error cases. I think
because of the peek, EAGAIN isn't something to be ignored anymore,
but the effect is the same whether we break out of the loop or
not, since we retry the packet next time around. Essentially, we
ignore every error since we will redo it with the same packet the
next time around. Maybe we should print something here, but since
we'll be retrying the packet that's still on the socket, a permanent
error would spew continuously. Maybe we should shut down entirely
if we get any negative return value here (including EAGAIN, since
that tells us someone messed with the socket when we don't want them
to).
        If you want the comment still there, ok, but I do think EAGAIN
isn't a special case per the comment anymore, and is handled as all
other errors are: by exiting the loop and retrying next time.

                                                                +-DLS


^ permalink raw reply

* Re: [netfilter / iptables] question
From: Jan Engelhardt @ 2010-04-01 18:35 UTC (permalink / raw)
  To: thomas yang; +Cc: netdev, Patrick McHardy
In-Reply-To: <n2if4f837ab1004011011gf3d82d3fzfd1423a812f98520@mail.gmail.com>

On Thursday 2010-04-01 19:11, thomas yang wrote:

>2010/4/2 Jan Engelhardt <jengelh@medozas.de>:
>> On Thursday 2010-04-01 18:44, thomas yang wrote:
>>
>>>Hi,
>>>
>>>I want to copy/ clone a  sk_buff  *skb  to  *skb2  on my Linux router,
>>>  then transmit both  skb2   and  skb  .
>>>
>>>How to do this with   netfilter hook function  / iptables  ?
>>>
>> Wait for xt_TEE to be merged.
>>
>
>I want to route skb to 'path 1' , route the copied/cloned skb2 to
>'path 2'    simultaneously,
>if one of them lose , it will not be a problem.
>
>What's the function of xt_TEE ?

Follow the mailing list.
http://marc.info/?t=127003152600006&r=1&w=2

^ permalink raw reply

* Increased Latencies when upgrading kernel version
From: Taylor Lewick @ 2010-04-01 19:12 UTC (permalink / raw)
  To: netdev, linux-kernel

For some time now we've been running an older kernel, 2.6.16.60.  When
we tried to upgrade, first going to 2.6.27.19 and then to 2.6.32.1 and
2.6.33.1 we noticed that latencies increased.  At first we noticed it
by doing network tests via udpping, netperf, etc.  We made some
tweaks, and were able to get network latency to within 1 to 2
microseconds of where we were previously on 2.6.16.60.  Then we did
some more testing, and noticed that system latency also seems higher.

We've done our tests on identical hardware servers, same NICs,
connected through same network gear.  Basically, we've tried to keep
everything identical except the kernel versions, and we are unable to
achieve the same performance for system latency on the newer kernels,
despite adjusting various kernel settings and recompiling.

The latency differences are about 15 microseconds per transaction.

At this point, I don't know what else to try.  I haven't played around
with the /proc/sys/kernel/sched_* paramaters under the newer kernels
yet.  Have tried changing pre-emption modes with little effect, in
fact, voluntary preemption seems to be peforming the best for us.

At this time the realtime patch isn't really an option for us to
consider, at least not yet.

Any suggestions?  Is this a known issue when upgrading to more recent
kernel versions?

Thanks,
Taylor

^ permalink raw reply

* Re: [PATCH 2/3] can: add support for Janz VMOD-ICAN3 Intelligent CAN module
From: Andrew Morton @ 2010-04-01 20:03 UTC (permalink / raw)
  To: Ira W. Snyder; +Cc: linux-kernel, socketcan-core, netdev, sameo
In-Reply-To: <1269881932-3803-3-git-send-email-iws@ovro.caltech.edu>

On Mon, 29 Mar 2010 09:58:51 -0700
"Ira W. Snyder" <iws@ovro.caltech.edu> wrote:

> The Janz VMOD-ICAN3 is a MODULbus daughterboard which fits onto any
> MODULbus carrier board. It is an intelligent CAN controller with a
> microcontroller and associated firmware.
> 

A neat-looking driver.

> ...
>
> +	spin_lock_irqsave(&mod->lock, flags);
>
> ...

It does this rather a lot.  it seems to be doing quite a lot of work
under that lock, too - quite a lot of memcpy_toio(), other stuff.

Is there potential here to disable interrupt for too long?  Not
possible to use spin_lock_bh() here?

^ permalink raw reply

* [PATCH net-next-2.6] net: add support for htonb and ntohb
From: Andy Gospodarek @ 2010-04-01 20:32 UTC (permalink / raw)
  To: netdev


After my recent post to net-2.6 this week to accidentally run htons to a
u8, it is clear to me we _must_ add some infrastructure to make sure
single bytes are in the correct network and host order on big and little
endian systems.  Today seemed like the perfect day to post this.

This patch adds basic support for htonb and ntohb.  Patches to add this
in the entire networking tree in _every_ case where a single byte is
accessed will be posted next week -- I'm almost done with them!

Signed-off-by: Andy Gospodarek <andy@greyhouse.net>
---

 byteorder/big_endian.h    |   30 ++++++++++++++++++++++++++
 byteorder/generic.h       |    6 +++++
 byteorder/little_endian.h |   30 ++++++++++++++++++++++++++
 swab.h                    |   53 ++++++++++++++++++++++++++++++++++++++++++++--
 types.h                   |    2 +
 5 files changed, 119 insertions(+), 2 deletions(-)

diff --git a/include/linux/byteorder/big_endian.h b/include/linux/byteorder/big_endian.h
index 3c80fd7..87f1089 100644
--- a/include/linux/byteorder/big_endian.h
+++ b/include/linux/byteorder/big_endian.h
@@ -15,30 +15,40 @@
 #define __constant_ntohl(x) ((__force __u32)(__be32)(x))
 #define __constant_htons(x) ((__force __be16)(__u16)(x))
 #define __constant_ntohs(x) ((__force __u16)(__be16)(x))
+#define __constant_htonb(x) ((__force __be8)(__u8)(x))
+#define __constant_ntohb(x) ((__force __u8)(__be8)(x))
 #define __constant_cpu_to_le64(x) ((__force __le64)___constant_swab64((x)))
 #define __constant_le64_to_cpu(x) ___constant_swab64((__force __u64)(__le64)(x))
 #define __constant_cpu_to_le32(x) ((__force __le32)___constant_swab32((x)))
 #define __constant_le32_to_cpu(x) ___constant_swab32((__force __u32)(__le32)(x))
 #define __constant_cpu_to_le16(x) ((__force __le16)___constant_swab16((x)))
 #define __constant_le16_to_cpu(x) ___constant_swab16((__force __u16)(__le16)(x))
+#define __constant_cpu_to_le8(x) ((__force __le8)___constant_swab8((x)))
+#define __constant_le8_to_cpu(x) ___constant_swab8((__force __u8)(__le8)(x))
 #define __constant_cpu_to_be64(x) ((__force __be64)(__u64)(x))
 #define __constant_be64_to_cpu(x) ((__force __u64)(__be64)(x))
 #define __constant_cpu_to_be32(x) ((__force __be32)(__u32)(x))
 #define __constant_be32_to_cpu(x) ((__force __u32)(__be32)(x))
 #define __constant_cpu_to_be16(x) ((__force __be16)(__u16)(x))
 #define __constant_be16_to_cpu(x) ((__force __u16)(__be16)(x))
+#define __constant_cpu_to_be8(x) ((__force __be8)(__u8)(x))
+#define __constant_be8_to_cpu(x) ((__force __u8)(__be8)(x))
 #define __cpu_to_le64(x) ((__force __le64)__swab64((x)))
 #define __le64_to_cpu(x) __swab64((__force __u64)(__le64)(x))
 #define __cpu_to_le32(x) ((__force __le32)__swab32((x)))
 #define __le32_to_cpu(x) __swab32((__force __u32)(__le32)(x))
 #define __cpu_to_le16(x) ((__force __le16)__swab16((x)))
 #define __le16_to_cpu(x) __swab16((__force __u16)(__le16)(x))
+#define __cpu_to_le8(x) ((__force __le8)__swab8((x)))
+#define __le8_to_cpu(x) __swab8((__force __u8)(__le8)(x))
 #define __cpu_to_be64(x) ((__force __be64)(__u64)(x))
 #define __be64_to_cpu(x) ((__force __u64)(__be64)(x))
 #define __cpu_to_be32(x) ((__force __be32)(__u32)(x))
 #define __be32_to_cpu(x) ((__force __u32)(__be32)(x))
 #define __cpu_to_be16(x) ((__force __be16)(__u16)(x))
 #define __be16_to_cpu(x) ((__force __u16)(__be16)(x))
+#define __cpu_to_be8(x) ((__force __be8)(__u8)(x))
+#define __be8_to_cpu(x) ((__force __u8)(__be8)(x))
 
 static inline __le64 __cpu_to_le64p(const __u64 *p)
 {
@@ -64,6 +74,14 @@ static inline __u16 __le16_to_cpup(const __le16 *p)
 {
 	return __swab16p((__u16 *)p);
 }
+static inline __le8 __cpu_to_le8p(const __u8 *p)
+{
+	return (__force __le8)__swab8p(p);
+}
+static inline __u8 __le8_to_cpup(const __le8 *p)
+{
+	return __swab8p((__u8 *)p);
+}
 static inline __be64 __cpu_to_be64p(const __u64 *p)
 {
 	return (__force __be64)*p;
@@ -88,18 +106,30 @@ static inline __u16 __be16_to_cpup(const __be16 *p)
 {
 	return (__force __u16)*p;
 }
+static inline __be8 __cpu_to_be8p(const __u8 *p)
+{
+	return (__force __be8)*p;
+}
+static inline __u8 __be8_to_cpup(const __be8 *p)
+{
+	return (__force __u8)*p;
+}
 #define __cpu_to_le64s(x) __swab64s((x))
 #define __le64_to_cpus(x) __swab64s((x))
 #define __cpu_to_le32s(x) __swab32s((x))
 #define __le32_to_cpus(x) __swab32s((x))
 #define __cpu_to_le16s(x) __swab16s((x))
 #define __le16_to_cpus(x) __swab16s((x))
+#define __cpu_to_le8s(x) __swab8s((x))
+#define __le8_to_cpus(x) __swab8s((x))
 #define __cpu_to_be64s(x) do { (void)(x); } while (0)
 #define __be64_to_cpus(x) do { (void)(x); } while (0)
 #define __cpu_to_be32s(x) do { (void)(x); } while (0)
 #define __be32_to_cpus(x) do { (void)(x); } while (0)
 #define __cpu_to_be16s(x) do { (void)(x); } while (0)
 #define __be16_to_cpus(x) do { (void)(x); } while (0)
+#define __cpu_to_be8s(x) do { (void)(x); } while (0)
+#define __be8_to_cpus(x) do { (void)(x); } while (0)
 
 #ifdef __KERNEL__
 #include <linux/byteorder/generic.h>
diff --git a/include/linux/byteorder/generic.h b/include/linux/byteorder/generic.h
index 0846e6b..11c9f36 100644
--- a/include/linux/byteorder/generic.h
+++ b/include/linux/byteorder/generic.h
@@ -127,18 +127,24 @@
 
 #undef ntohl
 #undef ntohs
+#undef ntohb
 #undef htonl
 #undef htons
+#undef htonb
 
 #define ___htonl(x) __cpu_to_be32(x)
 #define ___htons(x) __cpu_to_be16(x)
+#define ___htonb(x) __cpu_to_be8(x)
 #define ___ntohl(x) __be32_to_cpu(x)
 #define ___ntohs(x) __be16_to_cpu(x)
+#define ___ntohb(x) __be8_to_cpu(x)
 
 #define htonl(x) ___htonl(x)
 #define ntohl(x) ___ntohl(x)
 #define htons(x) ___htons(x)
 #define ntohs(x) ___ntohs(x)
+#define htonb(x) ___htonb(x)
+#define ntohb(x) ___ntohb(x)
 
 static inline void le16_add_cpu(__le16 *var, u16 val)
 {
diff --git a/include/linux/byteorder/little_endian.h b/include/linux/byteorder/little_endian.h
index 83195fb..ef862db 100644
--- a/include/linux/byteorder/little_endian.h
+++ b/include/linux/byteorder/little_endian.h
@@ -15,30 +15,40 @@
 #define __constant_ntohl(x) ___constant_swab32((__force __be32)(x))
 #define __constant_htons(x) ((__force __be16)___constant_swab16((x)))
 #define __constant_ntohs(x) ___constant_swab16((__force __be16)(x))
+#define __constant_htonb(x) ((__force __be8)___constant_swab8((x)))
+#define __constant_ntohb(x) ___constant_swab8((__force __be8)(x))
 #define __constant_cpu_to_le64(x) ((__force __le64)(__u64)(x))
 #define __constant_le64_to_cpu(x) ((__force __u64)(__le64)(x))
 #define __constant_cpu_to_le32(x) ((__force __le32)(__u32)(x))
 #define __constant_le32_to_cpu(x) ((__force __u32)(__le32)(x))
 #define __constant_cpu_to_le16(x) ((__force __le16)(__u16)(x))
 #define __constant_le16_to_cpu(x) ((__force __u16)(__le16)(x))
+#define __constant_cpu_to_le8(x) ((__force __le8)(__u8)(x))
+#define __constant_le8_to_cpu(x) ((__force __u8)(__le8)(x))
 #define __constant_cpu_to_be64(x) ((__force __be64)___constant_swab64((x)))
 #define __constant_be64_to_cpu(x) ___constant_swab64((__force __u64)(__be64)(x))
 #define __constant_cpu_to_be32(x) ((__force __be32)___constant_swab32((x)))
 #define __constant_be32_to_cpu(x) ___constant_swab32((__force __u32)(__be32)(x))
 #define __constant_cpu_to_be16(x) ((__force __be16)___constant_swab16((x)))
 #define __constant_be16_to_cpu(x) ___constant_swab16((__force __u16)(__be16)(x))
+#define __constant_cpu_to_be8(x) ((__force __be8)___constant_swab8((x)))
+#define __constant_be8_to_cpu(x) ___constant_swab8((__force __u8)(__be8)(x))
 #define __cpu_to_le64(x) ((__force __le64)(__u64)(x))
 #define __le64_to_cpu(x) ((__force __u64)(__le64)(x))
 #define __cpu_to_le32(x) ((__force __le32)(__u32)(x))
 #define __le32_to_cpu(x) ((__force __u32)(__le32)(x))
 #define __cpu_to_le16(x) ((__force __le16)(__u16)(x))
 #define __le16_to_cpu(x) ((__force __u16)(__le16)(x))
+#define __cpu_to_le8(x) ((__force __le8)(__u8)(x))
+#define __le8_to_cpu(x) ((__force __u8)(__le8)(x))
 #define __cpu_to_be64(x) ((__force __be64)__swab64((x)))
 #define __be64_to_cpu(x) __swab64((__force __u64)(__be64)(x))
 #define __cpu_to_be32(x) ((__force __be32)__swab32((x)))
 #define __be32_to_cpu(x) __swab32((__force __u32)(__be32)(x))
 #define __cpu_to_be16(x) ((__force __be16)__swab16((x)))
 #define __be16_to_cpu(x) __swab16((__force __u16)(__be16)(x))
+#define __cpu_to_be8(x) ((__force __be8)__swab8((x)))
+#define __be8_to_cpu(x) __swab8((__force __u8)(__be8)(x))
 
 static inline __le64 __cpu_to_le64p(const __u64 *p)
 {
@@ -64,6 +74,14 @@ static inline __u16 __le16_to_cpup(const __le16 *p)
 {
 	return (__force __u16)*p;
 }
+static inline __le8 __cpu_to_le8p(const __u8 *p)
+{
+	return (__force __le8)*p;
+}
+static inline __u8 __le8_to_cpup(const __le8 *p)
+{
+	return (__force __u8)*p;
+}
 static inline __be64 __cpu_to_be64p(const __u64 *p)
 {
 	return (__force __be64)__swab64p(p);
@@ -88,18 +106,30 @@ static inline __u16 __be16_to_cpup(const __be16 *p)
 {
 	return __swab16p((__u16 *)p);
 }
+static inline __be8 __cpu_to_be8p(const __u8 *p)
+{
+	return (__force __be8)__swab8p(p);
+}
+static inline __u8 __be8_to_cpup(const __be8 *p)
+{
+	return __swab8p((__u8 *)p);
+}
 #define __cpu_to_le64s(x) do { (void)(x); } while (0)
 #define __le64_to_cpus(x) do { (void)(x); } while (0)
 #define __cpu_to_le32s(x) do { (void)(x); } while (0)
 #define __le32_to_cpus(x) do { (void)(x); } while (0)
 #define __cpu_to_le16s(x) do { (void)(x); } while (0)
 #define __le16_to_cpus(x) do { (void)(x); } while (0)
+#define __cpu_to_le8s(x) do { (void)(x); } while (0)
+#define __le8_to_cpus(x) do { (void)(x); } while (0)
 #define __cpu_to_be64s(x) __swab64s((x))
 #define __be64_to_cpus(x) __swab64s((x))
 #define __cpu_to_be32s(x) __swab32s((x))
 #define __be32_to_cpus(x) __swab32s((x))
 #define __cpu_to_be16s(x) __swab16s((x))
 #define __be16_to_cpus(x) __swab16s((x))
+#define __cpu_to_be8s(x) __swab8s((x))
+#define __be8_to_cpus(x) __swab8s((x))
 
 #ifdef __KERNEL__
 #include <linux/byteorder/generic.h>
diff --git a/include/linux/swab.h b/include/linux/swab.h
index ea0c02f..043d9a6 100644
--- a/include/linux/swab.h
+++ b/include/linux/swab.h
@@ -7,8 +7,11 @@
 
 /*
  * casts are necessary for constants, because we never know how for sure
- * how U/UL/ULL map to __u16, __u32, __u64. At least not in a portable way.
+ * how U/UL/ULL map to __u8, __u16, __u32, __u64. At least not in a portable way.
  */
+#define ___constant_swab8(x) ((__u8)(				\
+	(((__u8)(x) & (__u8)0xffU) << 8)))
+
 #define ___constant_swab16(x) ((__u16)(				\
 	(((__u16)(x) & (__u16)0x00ffU) << 8) |			\
 	(((__u16)(x) & (__u16)0xff00U) >> 8)))
@@ -40,9 +43,18 @@
 /*
  * Implement the following as inlines, but define the interface using
  * macros to allow constant folding when possible:
- * ___swab16, ___swab32, ___swab64, ___swahw32, ___swahb32
+ * ___swab8, ___swab16, ___swab32, ___swab64, ___swahw32, ___swahb32
  */
 
+static inline __attribute_const__ __u8 __fswab8(__u8 val)
+{
+#ifdef __arch_swab8
+	return __arch_swab8(val);
+#else
+	return ___constant_swab8(val);
+#endif
+}
+
 static inline __attribute_const__ __u16 __fswab16(__u16 val)
 {
 #ifdef __arch_swab16
@@ -93,6 +105,15 @@ static inline __attribute_const__ __u32 __fswahb32(__u32 val)
 }
 
 /**
+ * __swab8 - return an 8-bit value
+ * @x: value to not byteswap
+ */
+#define __swab8(x)				\
+	(__builtin_constant_p((__u8)(x)) ?	\
+	___constant_swab8(x) :			\
+	__fswab8(x))
+
+/**
  * __swab16 - return a byteswapped 16-bit value
  * @x: value to byteswap
  */
@@ -142,6 +163,19 @@ static inline __attribute_const__ __u32 __fswahb32(__u32 val)
 	__fswahb32(x))
 
 /**
+ * __swab8p - return an 8-bit value from a pointer
+ * @p: pointer to a naturally-aligned 8-bit value
+ */
+static inline __u8 __swab8p(const __u8 *p)
+{
+#ifdef __arch_swab8p
+	return __arch_swab8p(p);
+#else
+	return __swab8(*p);
+#endif
+}
+
+/**
  * __swab16p - return a byteswapped 16-bit value from a pointer
  * @p: pointer to a naturally-aligned 16-bit value
  */
@@ -211,6 +245,18 @@ static inline __u32 __swahb32p(const __u32 *p)
 }
 
 /**
+ * __swab8s - do not byteswap an 8-bit value in-place
+ * @p: pointer to a naturally-aligned 8-bit value
+ */
+static inline void __swab8s(__u8 *p)
+{
+#ifdef __arch_swab8s
+	__arch_swab8s(p);
+#else
+	*p = __swab8p(p);
+#endif
+}
+/**
  * __swab16s - byteswap a 16-bit value in-place
  * @p: pointer to a naturally-aligned 16-bit value
  */
@@ -279,16 +325,19 @@ static inline void __swahb32s(__u32 *p)
 }
 
 #ifdef __KERNEL__
+# define swab8 __swab8
 # define swab16 __swab16
 # define swab32 __swab32
 # define swab64 __swab64
 # define swahw32 __swahw32
 # define swahb32 __swahb32
+# define swab8p __swab8p
 # define swab16p __swab16p
 # define swab32p __swab32p
 # define swab64p __swab64p
 # define swahw32p __swahw32p
 # define swahb32p __swahb32p
+# define swab8s __swab8s
 # define swab16s __swab16s
 # define swab32s __swab32s
 # define swab64s __swab64s
diff --git a/include/linux/types.h b/include/linux/types.h
index c42724f..f8a0a0f 100644
--- a/include/linux/types.h
+++ b/include/linux/types.h
@@ -165,6 +165,8 @@ typedef unsigned long blkcnt_t;
 #define __bitwise
 #endif
 
+typedef __u8 __bitwise __le8;
+typedef __u8 __bitwise __be8;
 typedef __u16 __bitwise __le16;
 typedef __u16 __bitwise __be16;
 typedef __u32 __bitwise __le32;

^ permalink raw reply related

* [PATCH] netlabel: Fix several rcu_dereference() calls used without RCU read locks
From: Paul Moore @ 2010-04-01 20:43 UTC (permalink / raw)
  To: netdev

The recent changes to add RCU lock verification to rcu_dereference() calls
caught out a problem with netlbl_unlhsh_hash(), see below.

 ===================================================
 [ INFO: suspicious rcu_dereference_check() usage. ]
 ---------------------------------------------------
 net/netlabel/netlabel_unlabeled.c:246 invoked rcu_dereference_check()
 without protection!

This patch fixes this problem as well as others like it in the NetLabel
code.  Also included in this patch is the identification of future work
to eliminate the RCU read lock in netlbl_domhsh_add(), but in the interest
of getting this patch out quickly that work will happen in another patch
to be finished later.

Thanks to Eric Dumazet and Paul McKenney for their help in understanding
the recent RCU changes.

Signed-off-by: Paul Moore <paul.moore@hp.com>
Reported-by: David Howells <dhowells@redhat.com>
CC: Eric Dumazet <eric.dumazet@gmail.com>
CC: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
---
 net/netlabel/netlabel_domainhash.c |   28 ++++++++++-----
 net/netlabel/netlabel_unlabeled.c  |   66 ++++++++++--------------------------
 2 files changed, 37 insertions(+), 57 deletions(-)

diff --git a/net/netlabel/netlabel_domainhash.c b/net/netlabel/netlabel_domainhash.c
index 0bfeaab..06ab41b 100644
--- a/net/netlabel/netlabel_domainhash.c
+++ b/net/netlabel/netlabel_domainhash.c
@@ -50,9 +50,12 @@ struct netlbl_domhsh_tbl {
 };
 
 /* Domain hash table */
-/* XXX - updates should be so rare that having one spinlock for the entire
- * hash table should be okay */
+/* updates should be so rare that having one spinlock for the entire hash table
+ * should be okay */
 static DEFINE_SPINLOCK(netlbl_domhsh_lock);
+#define netlbl_domhsh_rcu_deref(p) \
+	rcu_dereference_check(p, rcu_read_lock_held() || \
+				 lockdep_is_held(&netlbl_domhsh_lock))
 static struct netlbl_domhsh_tbl *netlbl_domhsh = NULL;
 static struct netlbl_dom_map *netlbl_domhsh_def = NULL;
 
@@ -106,7 +109,8 @@ static void netlbl_domhsh_free_entry(struct rcu_head *entry)
  * Description:
  * This is the hashing function for the domain hash table, it returns the
  * correct bucket number for the domain.  The caller is responsibile for
- * calling the rcu_read_[un]lock() functions.
+ * ensuring that the hash table is protected with either a RCU read lock or the
+ * hash table lock.
  *
  */
 static u32 netlbl_domhsh_hash(const char *key)
@@ -120,7 +124,7 @@ static u32 netlbl_domhsh_hash(const char *key)
 
 	for (iter = 0, val = 0, len = strlen(key); iter < len; iter++)
 		val = (val << 4 | (val >> (8 * sizeof(u32) - 4))) ^ key[iter];
-	return val & (rcu_dereference(netlbl_domhsh)->size - 1);
+	return val & (netlbl_domhsh_rcu_deref(netlbl_domhsh)->size - 1);
 }
 
 /**
@@ -130,7 +134,8 @@ static u32 netlbl_domhsh_hash(const char *key)
  * Description:
  * Searches the domain hash table and returns a pointer to the hash table
  * entry if found, otherwise NULL is returned.  The caller is responsibile for
- * the rcu hash table locks (i.e. the caller much call rcu_read_[un]lock()).
+ * ensuring that the hash table is protected with either a RCU read lock or the
+ * hash table lock.
  *
  */
 static struct netlbl_dom_map *netlbl_domhsh_search(const char *domain)
@@ -141,7 +146,7 @@ static struct netlbl_dom_map *netlbl_domhsh_search(const char *domain)
 
 	if (domain != NULL) {
 		bkt = netlbl_domhsh_hash(domain);
-		bkt_list = &rcu_dereference(netlbl_domhsh)->tbl[bkt];
+		bkt_list = &netlbl_domhsh_rcu_deref(netlbl_domhsh)->tbl[bkt];
 		list_for_each_entry_rcu(iter, bkt_list, list)
 			if (iter->valid && strcmp(iter->domain, domain) == 0)
 				return iter;
@@ -159,8 +164,8 @@ static struct netlbl_dom_map *netlbl_domhsh_search(const char *domain)
  * Searches the domain hash table and returns a pointer to the hash table
  * entry if an exact match is found, if an exact match is not present in the
  * hash table then the default entry is returned if valid otherwise NULL is
- * returned.  The caller is responsibile for the rcu hash table locks
- * (i.e. the caller much call rcu_read_[un]lock()).
+ * returned.  The caller is responsibile ensuring that the hash table is
+ * protected with either a RCU read lock or the hash table lock.
  *
  */
 static struct netlbl_dom_map *netlbl_domhsh_search_def(const char *domain)
@@ -169,7 +174,7 @@ static struct netlbl_dom_map *netlbl_domhsh_search_def(const char *domain)
 
 	entry = netlbl_domhsh_search(domain);
 	if (entry == NULL) {
-		entry = rcu_dereference(netlbl_domhsh_def);
+		entry = netlbl_domhsh_rcu_deref(netlbl_domhsh_def);
 		if (entry != NULL && !entry->valid)
 			entry = NULL;
 	}
@@ -306,8 +311,11 @@ int netlbl_domhsh_add(struct netlbl_dom_map *entry,
 	struct netlbl_af6list *tmp6;
 #endif /* IPv6 */
 
+	/* XXX - we can remove this RCU read lock as the spinlock protects the
+	 *       entire function, but before we do we need to fixup the
+	 *       netlbl_af[4,6]list RCU functions to do "the right thing" with
+	 *       respect to rcu_dereference() when only a spinlock is held. */
 	rcu_read_lock();
-
 	spin_lock(&netlbl_domhsh_lock);
 	if (entry->domain != NULL)
 		entry_old = netlbl_domhsh_search(entry->domain);
diff --git a/net/netlabel/netlabel_unlabeled.c b/net/netlabel/netlabel_unlabeled.c
index 852d9d7..3b4fde7 100644
--- a/net/netlabel/netlabel_unlabeled.c
+++ b/net/netlabel/netlabel_unlabeled.c
@@ -114,6 +114,9 @@ struct netlbl_unlhsh_walk_arg {
 /* updates should be so rare that having one spinlock for the entire
  * hash table should be okay */
 static DEFINE_SPINLOCK(netlbl_unlhsh_lock);
+#define netlbl_unlhsh_rcu_deref(p) \
+	rcu_dereference_check(p, rcu_read_lock_held() || \
+				 lockdep_is_held(&netlbl_unlhsh_lock))
 static struct netlbl_unlhsh_tbl *netlbl_unlhsh = NULL;
 static struct netlbl_unlhsh_iface *netlbl_unlhsh_def = NULL;
 
@@ -235,15 +238,13 @@ static void netlbl_unlhsh_free_iface(struct rcu_head *entry)
  * Description:
  * This is the hashing function for the unlabeled hash table, it returns the
  * bucket number for the given device/interface.  The caller is responsible for
- * calling the rcu_read_[un]lock() functions.
+ * ensuring that the hash table is protected with either a RCU read lock or
+ * the hash table lock.
  *
  */
 static u32 netlbl_unlhsh_hash(int ifindex)
 {
-	/* this is taken _almost_ directly from
-	 * security/selinux/netif.c:sel_netif_hasfn() as they do pretty much
-	 * the same thing */
-	return ifindex & (rcu_dereference(netlbl_unlhsh)->size - 1);
+	return ifindex & (netlbl_unlhsh_rcu_deref(netlbl_unlhsh)->size - 1);
 }
 
 /**
@@ -253,7 +254,8 @@ static u32 netlbl_unlhsh_hash(int ifindex)
  * Description:
  * Searches the unlabeled connection hash table and returns a pointer to the
  * interface entry which matches @ifindex, otherwise NULL is returned.  The
- * caller is responsible for calling the rcu_read_[un]lock() functions.
+ * caller is responsible for ensuring that the hash table is protected with
+ * either a RCU read lock or the hash table lock.
  *
  */
 static struct netlbl_unlhsh_iface *netlbl_unlhsh_search_iface(int ifindex)
@@ -263,7 +265,7 @@ static struct netlbl_unlhsh_iface *netlbl_unlhsh_search_iface(int ifindex)
 	struct netlbl_unlhsh_iface *iter;
 
 	bkt = netlbl_unlhsh_hash(ifindex);
-	bkt_list = &rcu_dereference(netlbl_unlhsh)->tbl[bkt];
+	bkt_list = &netlbl_unlhsh_rcu_deref(netlbl_unlhsh)->tbl[bkt];
 	list_for_each_entry_rcu(iter, bkt_list, list)
 		if (iter->valid && iter->ifindex == ifindex)
 			return iter;
@@ -272,33 +274,6 @@ static struct netlbl_unlhsh_iface *netlbl_unlhsh_search_iface(int ifindex)
 }
 
 /**
- * netlbl_unlhsh_search_iface_def - Search for a matching interface entry
- * @ifindex: the network interface
- *
- * Description:
- * Searches the unlabeled connection hash table and returns a pointer to the
- * interface entry which matches @ifindex.  If an exact match can not be found
- * and there is a valid default entry, the default entry is returned, otherwise
- * NULL is returned.  The caller is responsible for calling the
- * rcu_read_[un]lock() functions.
- *
- */
-static struct netlbl_unlhsh_iface *netlbl_unlhsh_search_iface_def(int ifindex)
-{
-	struct netlbl_unlhsh_iface *entry;
-
-	entry = netlbl_unlhsh_search_iface(ifindex);
-	if (entry != NULL)
-		return entry;
-
-	entry = rcu_dereference(netlbl_unlhsh_def);
-	if (entry != NULL && entry->valid)
-		return entry;
-
-	return NULL;
-}
-
-/**
  * netlbl_unlhsh_add_addr4 - Add a new IPv4 address entry to the hash table
  * @iface: the associated interface entry
  * @addr: IPv4 address in network byte order
@@ -308,8 +283,7 @@ static struct netlbl_unlhsh_iface *netlbl_unlhsh_search_iface_def(int ifindex)
  * Description:
  * Add a new address entry into the unlabeled connection hash table using the
  * interface entry specified by @iface.  On success zero is returned, otherwise
- * a negative value is returned.  The caller is responsible for calling the
- * rcu_read_[un]lock() functions.
+ * a negative value is returned.
  *
  */
 static int netlbl_unlhsh_add_addr4(struct netlbl_unlhsh_iface *iface,
@@ -349,8 +323,7 @@ static int netlbl_unlhsh_add_addr4(struct netlbl_unlhsh_iface *iface,
  * Description:
  * Add a new address entry into the unlabeled connection hash table using the
  * interface entry specified by @iface.  On success zero is returned, otherwise
- * a negative value is returned.  The caller is responsible for calling the
- * rcu_read_[un]lock() functions.
+ * a negative value is returned.
  *
  */
 static int netlbl_unlhsh_add_addr6(struct netlbl_unlhsh_iface *iface,
@@ -391,8 +364,7 @@ static int netlbl_unlhsh_add_addr6(struct netlbl_unlhsh_iface *iface,
  * Description:
  * Add a new, empty, interface entry into the unlabeled connection hash table.
  * On success a pointer to the new interface entry is returned, on failure NULL
- * is returned.  The caller is responsible for calling the rcu_read_[un]lock()
- * functions.
+ * is returned.
  *
  */
 static struct netlbl_unlhsh_iface *netlbl_unlhsh_add_iface(int ifindex)
@@ -415,10 +387,10 @@ static struct netlbl_unlhsh_iface *netlbl_unlhsh_add_iface(int ifindex)
 		if (netlbl_unlhsh_search_iface(ifindex) != NULL)
 			goto add_iface_failure;
 		list_add_tail_rcu(&iface->list,
-				  &rcu_dereference(netlbl_unlhsh)->tbl[bkt]);
+			     &netlbl_unlhsh_rcu_deref(netlbl_unlhsh)->tbl[bkt]);
 	} else {
 		INIT_LIST_HEAD(&iface->list);
-		if (rcu_dereference(netlbl_unlhsh_def) != NULL)
+		if (netlbl_unlhsh_rcu_deref(netlbl_unlhsh_def) != NULL)
 			goto add_iface_failure;
 		rcu_assign_pointer(netlbl_unlhsh_def, iface);
 	}
@@ -548,8 +520,7 @@ unlhsh_add_return:
  *
  * Description:
  * Remove an IP address entry from the unlabeled connection hash table.
- * Returns zero on success, negative values on failure.  The caller is
- * responsible for calling the rcu_read_[un]lock() functions.
+ * Returns zero on success, negative values on failure.
  *
  */
 static int netlbl_unlhsh_remove_addr4(struct net *net,
@@ -611,8 +582,7 @@ static int netlbl_unlhsh_remove_addr4(struct net *net,
  *
  * Description:
  * Remove an IP address entry from the unlabeled connection hash table.
- * Returns zero on success, negative values on failure.  The caller is
- * responsible for calling the rcu_read_[un]lock() functions.
+ * Returns zero on success, negative values on failure.
  *
  */
 static int netlbl_unlhsh_remove_addr6(struct net *net,
@@ -1547,8 +1517,10 @@ int netlbl_unlabel_getattr(const struct sk_buff *skb,
 	struct netlbl_unlhsh_iface *iface;
 
 	rcu_read_lock();
-	iface = netlbl_unlhsh_search_iface_def(skb->skb_iif);
+	iface = netlbl_unlhsh_search_iface(skb->skb_iif);
 	if (iface == NULL)
+		iface = rcu_dereference(netlbl_unlhsh_def);
+	if (iface == NULL || !iface->valid)
 		goto unlabel_getattr_nolabel;
 	switch (family) {
 	case PF_INET: {


^ permalink raw reply related

* Re: [PATCH net-next-2.6] net: add support for htonb and ntohb
From: Eric Dumazet @ 2010-04-01 20:47 UTC (permalink / raw)
  To: Andy Gospodarek; +Cc: netdev
In-Reply-To: <20100401203209.GC28741@gospo.rdu.redhat.com>

Le jeudi 01 avril 2010 à 16:32 -0400, Andy Gospodarek a écrit :
> After my recent post to net-2.6 this week to accidentally run htons to a
> u8, it is clear to me we _must_ add some infrastructure to make sure
> single bytes are in the correct network and host order on big and little
> endian systems.  Today seemed like the perfect day to post this.
> 
> This patch adds basic support for htonb and ntohb.  Patches to add this
> in the entire networking tree in _every_ case where a single byte is
> accessed will be posted next week -- I'm almost done with them!
> 
> Signed-off-by: Andy Gospodarek <andy@greyhouse.net>
> ---

Seems fine, thanks a lot Andy.

Hmm, I notice this doesnt handle yet arches where a byte is 9 bits long.

Do you have any plan, to finally support PDP-6/10 ?




^ permalink raw reply

* Re: [PATCH] netlabel: Fix several rcu_dereference() calls used without RCU read locks
From: Eric Dumazet @ 2010-04-01 20:56 UTC (permalink / raw)
  To: Paul Moore; +Cc: netdev, Paul E. McKenney
In-Reply-To: <20100401204357.9795.80383.stgit@flek.lan>

Le jeudi 01 avril 2010 à 16:43 -0400, Paul Moore a écrit :
> The recent changes to add RCU lock verification to rcu_dereference() calls
> caught out a problem with netlbl_unlhsh_hash(), see below.
> 
>  ===================================================
>  [ INFO: suspicious rcu_dereference_check() usage. ]
>  ---------------------------------------------------
>  net/netlabel/netlabel_unlabeled.c:246 invoked rcu_dereference_check()
>  without protection!
> 
> This patch fixes this problem as well as others like it in the NetLabel
> code.  Also included in this patch is the identification of future work
> to eliminate the RCU read lock in netlbl_domhsh_add(), but in the interest
> of getting this patch out quickly that work will happen in another patch
> to be finished later.
> 
> Thanks to Eric Dumazet and Paul McKenney for their help in understanding
> the recent RCU changes.
> 
> Signed-off-by: Paul Moore <paul.moore@hp.com>
> Reported-by: David Howells <dhowells@redhat.com>
> CC: Eric Dumazet <eric.dumazet@gmail.com>
> CC: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
> ---
>  net/netlabel/netlabel_domainhash.c |   28 ++++++++++-----
>  net/netlabel/netlabel_unlabeled.c  |   66 ++++++++++--------------------------
>  2 files changed, 37 insertions(+), 57 deletions(-)
> 

Acked-by: Eric Dumazet <eric.dumazet@gmail.com>

Thanks Paul



^ permalink raw reply

* Re: Increased Latencies when upgrading kernel version
From: Eric Dumazet @ 2010-04-01 21:19 UTC (permalink / raw)
  To: Taylor Lewick; +Cc: netdev, linux-kernel
In-Reply-To: <o2vd585dc4f1004011212s65cc2beewed2f19321210a249@mail.gmail.com>

Le jeudi 01 avril 2010 à 14:12 -0500, Taylor Lewick a écrit :
> For some time now we've been running an older kernel, 2.6.16.60.  When
> we tried to upgrade, first going to 2.6.27.19 and then to 2.6.32.1 and
> 2.6.33.1 we noticed that latencies increased.  At first we noticed it
> by doing network tests via udpping, netperf, etc.  We made some
> tweaks, and were able to get network latency to within 1 to 2
> microseconds of where we were previously on 2.6.16.60.  Then we did
> some more testing, and noticed that system latency also seems higher.
> 
> We've done our tests on identical hardware servers, same NICs,
> connected through same network gear.  Basically, we've tried to keep
> everything identical except the kernel versions, and we are unable to
> achieve the same performance for system latency on the newer kernels,
> despite adjusting various kernel settings and recompiling.
> 
> The latency differences are about 15 microseconds per transaction.
> 
> At this point, I don't know what else to try.  I haven't played around
> with the /proc/sys/kernel/sched_* paramaters under the newer kernels
> yet.  Have tried changing pre-emption modes with little effect, in
> fact, voluntary preemption seems to be peforming the best for us.
> 
> At this time the realtime patch isn't really an option for us to
> consider, at least not yet.
> 
> Any suggestions?  Is this a known issue when upgrading to more recent
> kernel versions?
> 

Hi Taylor

Well, this is bit difficult to generically answer to your generic
question. 15 us more latency per transaction seems pretty bad.

Some inputs would be nice, describing your workload and
software/hardware architecture.

lspci
cat /proc/cpuinfo
cat /proc/interrupts
dmesg
ethtool -S eth0
ethtool -c eth0




^ permalink raw reply

* RE: [net-next-2.6 PATCH 3/8] vxge: Align the memory only if it is misaligned.
From: Ramkrishna Vepa @ 2010-04-01 22:05 UTC (permalink / raw)
  To: David Miller, Sreenivasa Honnur; +Cc: netdev
In-Reply-To: <20100329.165945.157920838.davem@davemloft.net>

> If you want to allocate 4K chunks and make sure they are at least 128
> byte aligned, you can allocated pages (which are always PAGE_SIZE
> aligned) and chop them up into the appropriate block size as needed.
> 
> This is exactly how drivers/net/niu.c handles this situation.
> 
> See drivers/net/niu.c:niu_rbr_add_page()
Thanks Dave! There's quite a bit of change required in the driver for
this. We'll submit the current set of patches we are working on and then
look into submitting this change.

Ram

^ permalink raw reply

* Re: Any ideas about a crash on reboot with igb and intel_iommu?
From: Roland Dreier @ 2010-04-01 22:45 UTC (permalink / raw)
  To: netdev; +Cc: iommu, David Woodhouse
In-Reply-To: <adabpe3f3c4.fsf@roland-alpha.cisco.com>

 > One other data point is that enabling the BIOS option "maximize memory
 > under 4GB" (which apparently just allocates less space for PCI BARs
 > below 4GB) seems to make this crash go away again.

Never mind about this, apparently the crashes do actually happen even
after changing the BIOS config.
-- 
Roland Dreier <rolandd@cisco.com> || For corporate legal information go to:
http://www.cisco.com/web/about/doing_business/legal/cri/index.html

^ permalink raw reply

* Re: [PATCH NEXT 6/8] qlcnic: add driver debug support
From: David Miller @ 2010-04-01 23:02 UTC (permalink / raw)
  To: amit.salecha; +Cc: netdev, ameen.rahman
In-Reply-To: <1270037026-9062-7-git-send-email-amit.salecha@qlogic.com>

From: Amit Kumar Salecha <amit.salecha@qlogic.com>
Date: Wed, 31 Mar 2010 05:03:44 -0700

> @@ -998,6 +998,20 @@ static int qlcnic_set_flags(struct net_device *netdev, u32 data)
>  	return 0;
>  }
>  
> +static u32 qlcnic_get_msglevel(struct net_device *netdev)
> +{
> +	struct qlcnic_adapter *adapter = netdev_priv(netdev);
> +
> +	return adapter->msglvl;
> +}
> +
> +static void qlcnic_set_msglevel(struct net_device *netdev, u32 msglvl)
> +{
> +	struct qlcnic_adapter *adapter = netdev_priv(netdev);
> +
> +	adapter->msglvl = !!msglvl;
> +}
> +

The values used by these interfaces are not something you
can interpret any way you want.

They have defined values (from linux/netdevice.h):

enum {
	NETIF_MSG_DRV		= 0x0001,
	NETIF_MSG_PROBE		= 0x0002,
	NETIF_MSG_LINK		= 0x0004,
	NETIF_MSG_TIMER		= 0x0008,
	NETIF_MSG_IFDOWN	= 0x0010,
	NETIF_MSG_IFUP		= 0x0020,
	NETIF_MSG_RX_ERR	= 0x0040,
	NETIF_MSG_TX_ERR	= 0x0080,
	NETIF_MSG_TX_QUEUED	= 0x0100,
	NETIF_MSG_INTR		= 0x0200,
	NETIF_MSG_TX_DONE	= 0x0400,
	NETIF_MSG_RX_STATUS	= 0x0800,
	NETIF_MSG_PKTDATA	= 0x1000,
	NETIF_MSG_HW		= 0x2000,
	NETIF_MSG_WOL		= 0x4000,
};

And you must respect them in your debug logging macros.

You should also use netdev->msg_enable which is there exactly
for this purpose, and then you can use the netif_msg_*()
helper macros.

Look at how any other driver implements these interfaces.  It's always
better to look at the most popular drivers to see how interfaces are
meant to be used, rather than looking at an interface and trying
to figure out what clever things specific to your driver you can
do with it. :-)

Please either fix this up or eliminate this patch from your
patch set.  Please resubmit this entire set once you've
fixed this problem.

Thanks.

^ permalink raw reply

* Re: [PATCH net-next-2.6] net: add support for htonb and ntohb
From: Neil Horman @ 2010-04-02  0:03 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: Andy Gospodarek, netdev
In-Reply-To: <1270154854.2192.3.camel@edumazet-laptop>

On Thu, Apr 01, 2010 at 10:47:34PM +0200, Eric Dumazet wrote:
> Le jeudi 01 avril 2010 à 16:32 -0400, Andy Gospodarek a écrit :
> > After my recent post to net-2.6 this week to accidentally run htons to a
> > u8, it is clear to me we _must_ add some infrastructure to make sure
> > single bytes are in the correct network and host order on big and little
> > endian systems.  Today seemed like the perfect day to post this.
> > 
> > This patch adds basic support for htonb and ntohb.  Patches to add this
> > in the entire networking tree in _every_ case where a single byte is
> > accessed will be posted next week -- I'm almost done with them!
> > 
> > Signed-off-by: Andy Gospodarek <andy@greyhouse.net>
> > ---
> 
> Seems fine, thanks a lot Andy.
> 
> Hmm, I notice this doesnt handle yet arches where a byte is 9 bits long.
> 
> Do you have any plan, to finally support PDP-6/10 ?
> 

definately, and while your at it, I could really use some conversion routines
for the more complex types just to save time.  htonstr and ntohstr in particular




> 
> 
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

^ permalink raw reply

* Re: [PATCH 1/3] be2net: fix a bug in flashing the redboot section
From: David Miller @ 2010-04-02  0:26 UTC (permalink / raw)
  To: ajitk; +Cc: netdev
In-Reply-To: <20100331114735.GA9068@serverengines.com>

From: Ajit Khaparde <ajitk@serverengines.com>
Date: Wed, 31 Mar 2010 17:17:45 +0530

> 
> Signed-off-by: Ajit Khaparde <ajitk@serverengines.com>

Applied.

^ permalink raw reply

* Re: [PATCH 2/3] be2net: fix flashing on big endian architectures
From: David Miller @ 2010-04-02  0:26 UTC (permalink / raw)
  To: ajitk; +Cc: netdev
In-Reply-To: <20100331115709.GA9200@serverengines.com>

From: Ajit Khaparde <ajitk@serverengines.com>
Date: Wed, 31 Mar 2010 17:27:10 +0530

> Flashing is broken on big endian architectures like ppc.
> This patch fixes it.
> 
> From: Naresh G <nareshg@serverengines.com>
> Signed-off-by: Ajit Khaparde <ajitk@serverengines.com>

Applied.

^ permalink raw reply

* Re: [PATCH 3/3] be2net: fix bug in vlan rx path for big endian architecture
From: David Miller @ 2010-04-02  0:26 UTC (permalink / raw)
  To: ajitk; +Cc: netdev
In-Reply-To: <20100331120021.GA9185@serverengines.com>

From: Ajit Khaparde <ajitk@serverengines.com>
Date: Wed, 31 Mar 2010 17:30:32 +0530

> vlan traffic on big endian architecture is broken.
> Need to swap the vid before giving packet to stack.
> This patch fixes it.
> 
> Signed-off-by: Ajit Khaparde <ajitk@serverengines.com>

Applied

^ permalink raw reply

* Re: [Patch V3] bonding: fix potential deadlock in bond_uninit()
From: David Miller @ 2010-04-02  0:26 UTC (permalink / raw)
  To: amwang
  Cc: ebiederm, linux-kernel, jpirko, shemminger, netdev, bonding-devel,
	fubar
In-Reply-To: <4BB44BAC.2070304@redhat.com>

From: Cong Wang <amwang@redhat.com>
Date: Thu, 01 Apr 2010 15:30:52 +0800

> Eric W. Biederman wrote:
>> Amerigo Wang <amwang@redhat.com> writes:
>> 
>>> bond_uninit() is invoked with rtnl_lock held, when it does
>>> destroy_workqueue()
>>> which will potentially flush all works in this workqueue, if we hold
>>> rtnl_lock
>>> again in the work function, it will deadlock.
>>>
>>> So move destroy_workqueue() to destructor where rtnl_lock is not held
>>> any more,
>>> suggested by Eric.
>> The error handling on creating a bond device needs to be updated as
>> well.
>> 
> 
> Done.

Applied, thanks.

^ permalink raw reply

* Re: [PATCH] stmmac: fix kconfig for crc32 build error
From: David Miller @ 2010-04-02  0:26 UTC (permalink / raw)
  To: peppe.cavallaro; +Cc: netdev, carmelo.amoroso
In-Reply-To: <1270107844-23457-1-git-send-email-peppe.cavallaro@st.com>

From: Giuseppe CAVALLARO <peppe.cavallaro@st.com>
Date: Thu,  1 Apr 2010 09:44:03 +0200

> From: Carmelo AMOROSO <carmelo.amoroso@st.com>
> 
> stmmac uses crc32 functions so it needs to select CRC32.
> 
> Fixes build error:
> drivers/built-in.o: In function `dwmac1000_set_filter':
> dwmac1000_core.c:(.text+0x3c380): undefined reference to `crc32_le'
> dwmac1000_core.c:(.text+0x3c384): undefined reference to `bitrev32'
> 
> Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>
> Signed-off-by: Giuseppe Cavallaro <peppe.cavallaro@st.com>

Applied.

^ permalink raw reply

* Re: [PATCH] stmmac: add documentation for the driver.
From: David Miller @ 2010-04-02  0:26 UTC (permalink / raw)
  To: peppe.cavallaro; +Cc: netdev
In-Reply-To: <1270107844-23457-2-git-send-email-peppe.cavallaro@st.com>

From: Giuseppe CAVALLARO <peppe.cavallaro@st.com>
Date: Thu,  1 Apr 2010 09:44:04 +0200

> Add Documentation/networking/stmmac.txt for the
> stmmac network driver.
> 
> Signed-off-by: Giuseppe Cavallaro <peppe.cavallaro@st.com>

Applied.

^ permalink raw reply

* Re: [PATCH] net: check the length of the socket address passed to connect(2)
From: David Miller @ 2010-04-02  0:26 UTC (permalink / raw)
  To: xiaosuo; +Cc: netdev
In-Reply-To: <4BB46032.7030500@gmail.com>

From: Changli Gao <xiaosuo@gmail.com>
Date: Thu, 01 Apr 2010 16:58:26 +0800

> check the length of the socket address passed to connect(2).
> 
> Check the length of the socket address passed to connect(2). If the
> length is invalid, -EINVAL will be returned.
> 
> Signed-off-by: Changli Gao <xiaosuo@gmail.com>

Applied.

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox