Netdev List
 help / color / mirror / Atom feed
* Re: [PATCH next-next 0/2] can: cc770: add support for the Bosch CC770 and Intel AN82527
From: David Miller @ 2011-11-30 21:07 UTC (permalink / raw)
  To: socketcan; +Cc: wg, netdev, linux-can, socketcan-users, boir1, stanislavelensky
In-Reply-To: <4ED5CF14.4020502@hartkopp.net>

From: Oliver Hartkopp <socketcan@hartkopp.net>
Date: Wed, 30 Nov 2011 07:37:08 +0100

> On 30.11.2011 00:39, David Miller wrote:
> 
>> From: Wolfgang Grandegger <wg@grandegger.com>
>> Date: Thu, 24 Nov 2011 13:07:26 +0100
>> 
>>> Already since a while we have support for the Bosch CC770 and Intel
>>> AN82527 CAN controllers in our out-of-tree Socket-CAN repository.
>>> It would be nice if somebody could test the driver. Unfortunately,
>>> I currently do not have hardware at hand. I have not yet ported the
>>> OF platform driver as it needs further attaention due to the merge
>>> of the platform and OF platform interface.
>>>
>>> Wolfgang Grandegger (2):
>>>   can: cc770: add driver core for the Bosch CC770 and Intel AN82527
>>>   can: cc770: legacy CC770 ISA bus driver
>> 
>> All applied, thank you.
> 
> 
> Hello Dave,
> 
> this patchset was superseded for some time.
> 
> We're currently in the v4 patchset (dated 2011-11-29).
> 
> See http://patchwork.ozlabs.org/patch/128244/
> 
> Do you want to revert the commit or should Wolfgang post a diff patch to get
> to v4 ??

A not very good job was done here communicating to me what is happening.
Endless revisions, and not clear indication to me what should or should
not be applied as a result.

I want you guys to appoint someone to be the defacto CAN driver and
subsystem maintainer who collects and merges all the driver and
protocol patches into his tree, and acts as the one and only interface
for me when changes are ready to be included.

I sorted this out by reverting the older changes and applying V5.

But I had to fix things up, when applying patch #3 there are empty
trailing lines in some of the new files generated, and that causes
git to complain.

^ permalink raw reply

* Re: [net-next-2.6 PATCH 0/6 v4] macvlan: MAC Address filtering support for passthru mode
From: Chris Wright @ 2011-11-30 21:04 UTC (permalink / raw)
  To: Ben Hutchings
  Cc: Greg Rose, Roopa Prabhu, netdev@vger.kernel.org,
	davem@davemloft.net, chrisw@redhat.com, sri@us.ibm.com,
	dragos.tatulea@gmail.com, kvm@vger.kernel.org, arnd@arndb.de,
	mst@redhat.com, mchan@broadcom.com, dwang2@cisco.com,
	shemminger@vyatta.com, eric.dumazet@gmail.com, kaber@trash.net,
	benve@cisco.com
In-Reply-To: <1322678890.2762.26.camel@bwh-desktop>

* Ben Hutchings (bhutchings@solarflare.com) wrote:
> On Wed, 2011-11-30 at 09:34 -0800, Greg Rose wrote:
> > On 11/29/2011 9:19 AM, Ben Hutchings wrote:
> > > On Tue, 2011-11-29 at 16:35 +0000, Ben Hutchings wrote:
> > >>
> > >> Maybe I missed something!
> [...]
> > >> If not, please explain what the new model *is*.
> > 
> > The new model is to incorporate a VEB into the NIC.  The current model 
> > doesn't address any of the requirements of a VEB in the NIC and this 
> > proposed set of patches allow us to set MAC filters for the *ports* on 
> > the internal NIC VEB.  Consider the PF and each of the VFs as just a 
> > port on the VEB.  We need the ability to set L2 filters (MAC, MC and 
> > VLAN) for each of the ports on that VEB.  There is no currently 
> > supported method for doing this.  So yes, this is a new model although 
> > it's a fairly simple one.
> 
> Explain precisely how the VEB changes the existing model.  Explain how
> the existing MAC filter and VF filter APIs interact with port filters on
> the VEB.  Refer to any relevant standards.

I agree that it's confusing.  Couldn't you simplify your ascii art
(hopefully removing hw assumptions about receive processing, and
completely ignoring vlans for the moment) to something like:

             |RX
             v
+------------+-------------+
|     +------+--------+    |
|     | RX MAC filter |    |
|     |and port select|    |
|     +---------------+    |
|            /|\           |
|           / | \   match 2|
|          /  v  \         |
|         /match  \        |
|        /  1 |    \       |
|       /     |     \      |
|match /      |      \     |
|  0  /       |       \    |
|    v        |        v   |
|    |        |        |   |
+----+--------+--------+---+
     |        |        |
    PF       VF 1     VF 2

And there's an unclear number of ways to update "RX MAC filter and port
select" table.

1) PF ndo_set_mac_addr
I expect that to be implicit to match 0.

2) PF ndo_set_rx_mode
Less clear, but I'd still expect these to implicitly match 0

3) PF ndo_set_vf_mac
I expect these to be an explicit match to VF N (given the interface
specifices which VF's MAC is being programmed).

4) VF ndo_set_mac_addr
This one may or may not be allowed (setting MAC+port if the VF is owned
by a guest is likely not allowed), but would expect an implicit VF N.

5) VF ndo_set_rx_mode
Same as 4) above.

6) PF or VF? ndo_set_rx_filter_addr
The new proposal, which has an explicit VF, although when it's VF_SELF
I'm not clear if this is just the same as 5) above?

Have I missed anything?

thanks,
chris

^ permalink raw reply

* [RFC 3/3] caif: Add support for CAIF over CDC NCM USB interface
From: Sjur Br��ndeland @ 2011-11-30 20:44 UTC (permalink / raw)
  To: netdev; +Cc: David Miller, Alexey Orishko, Sjur Brændeland
In-Reply-To: <1322685846-7790-1-git-send-email-sjur.brandeland@stericsson.com>

From: Sjur Brændeland <sjur.brandeland@stericsson.com>

NCM 1.0 does not support anything but Ethernet framing, hence
CAIF payload will be put into Ethernet frames.

Discovery is based on fixed USB vendor 0x04cc (ST-Ericsson),
product-id 0x230f (NCM). In this variant only CAIF payload is sent over
the NCM interface.

The CAIF stack (cfusbl.c) will when USB registers first check if
we got a CDC NCM USB interface with the right VID, PID.
It will then read the device's Ethernet address and create a 'template'
Ethernet TX header, using a broadcast address as the destination address,
and EthType 0x88b5 (802.1 Local Experimental - vendor specific).

A protocol handler for 0x88b5 is setup for reception of CAIF frames from
the CDC NCM USB interface.

Signed-off-by: Sjur Brændeland <sjur.brandeland@stericsson.com>
---
 include/net/caif/cfusbl.h |   13 +++
 net/caif/Kconfig          |   11 +++
 net/caif/Makefile         |    4 +-
 net/caif/caif_dev.c       |    7 ++
 net/caif/cfusbl.c         |  199 +++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 233 insertions(+), 1 deletions(-)
 create mode 100644 include/net/caif/cfusbl.h
 create mode 100644 net/caif/cfusbl.c

diff --git a/include/net/caif/cfusbl.h b/include/net/caif/cfusbl.h
new file mode 100644
index 0000000..7ef2499
--- /dev/null
+++ b/include/net/caif/cfusbl.h
@@ -0,0 +1,13 @@
+/*
+ * Copyright (C) ST-Ericsson AB 2010
+ * Author:	Sjur Brendeland/sjur.brandeland@stericsson.com
+ * License terms: GNU General Public License (GPL) version 2
+ */
+
+#ifndef CFUSBL_H_
+#define CFUSBL_H_
+
+void cfusbl_init(void);
+void cfusbl_exit(void);
+
+#endif				/* CFUSBL_H_ */
diff --git a/net/caif/Kconfig b/net/caif/Kconfig
index 529750d..43cd844 100644
--- a/net/caif/Kconfig
+++ b/net/caif/Kconfig
@@ -40,3 +40,14 @@ config CAIF_NETDEV
 	If you select to build it as a built-in then the main CAIF device must
 	also be a built-in.
 	If unsure say Y.
+
+config CAIF_USB
+	bool "CAIF USB support"
+	depends on CAIF
+	default CAIF
+	---help---
+	Say Y if you are using CAIF over USB CDC NCM.
+	This can be either built-in or a loadable module,
+	If you select to build it as a built-in then the main CAIF device must
+	also be a built-in.
+	If unsure say N.
diff --git a/net/caif/Makefile b/net/caif/Makefile
index ebcd4e7..3965f73 100644
--- a/net/caif/Makefile
+++ b/net/caif/Makefile
@@ -1,4 +1,5 @@
-ccflags-$(CONFIG_CAIF_DEBUG)     :=      -DDEBUG
+ccflags-$(CONFIG_CAIF_DEBUG) += -DDEBUG
+ccflags-$(CONFIG_CAIF_USB) += -DCAIF_USB
 
 caif-y := caif_dev.o \
 	cfcnfg.o cfmuxl.o cfctrl.o  \
@@ -6,6 +7,7 @@ caif-y := caif_dev.o \
 	cfserl.o cfdgml.o  \
 	cfrfml.o cfvidl.o cfutill.o \
 	cfsrvl.o cfpkt_skbuff.o
+caif-$(CONFIG_CAIF_USB) += cfusbl.o
 
 obj-$(CONFIG_CAIF) += caif.o
 obj-$(CONFIG_CAIF_NETDEV) += chnl_net.o
diff --git a/net/caif/caif_dev.c b/net/caif/caif_dev.c
index 415353e..6ef0e90 100644
--- a/net/caif/caif_dev.c
+++ b/net/caif/caif_dev.c
@@ -25,6 +25,7 @@
 #include <net/caif/cfpkt.h>
 #include <net/caif/cfcnfg.h>
 #include <net/caif/cfserl.h>
+#include <net/caif/cfusbl.h>
 
 MODULE_LICENSE("GPL");
 
@@ -506,6 +507,9 @@ static int __init caif_device_init(void)
 	if (result)
 		return result;
 
+#ifdef CAIF_USB
+	cfusbl_init();
+#endif
 	register_netdevice_notifier(&caif_device_notifier);
 	dev_add_pack(&caif_packet_type);
 
@@ -517,6 +521,9 @@ static void __exit caif_device_exit(void)
 	unregister_pernet_device(&caif_net_ops);
 	unregister_netdevice_notifier(&caif_device_notifier);
 	dev_remove_pack(&caif_packet_type);
+#ifdef CAIF_USB
+	cfusbl_exit();
+#endif
 }
 
 module_init(caif_device_init);
diff --git a/net/caif/cfusbl.c b/net/caif/cfusbl.c
new file mode 100644
index 0000000..8353a55
--- /dev/null
+++ b/net/caif/cfusbl.c
@@ -0,0 +1,199 @@
+/*
+ * CAIF USB handler
+ * Copyright (C) ST-Ericsson AB 2011
+ * Author:	Sjur Brendeland/sjur.brandeland@stericsson.com
+ * License terms: GNU General Public License (GPL) version 2
+ *
+ */
+
+#define pr_fmt(fmt) KBUILD_MODNAME ":%s(): " fmt, __func__
+
+#include <linux/netdevice.h>
+#include <linux/slab.h>
+#include <linux/netdevice.h>
+#include <linux/mii.h>
+#include <linux/usb.h>
+#include <linux/usb/usbnet.h>
+#include <net/netns/generic.h>
+#include <net/caif/caif_dev.h>
+#include <net/caif/caif_layer.h>
+#include <net/caif/cfpkt.h>
+#include <net/caif/cfcnfg.h>
+
+MODULE_LICENSE("GPL");
+
+#define CFUSB_PAD_DESCR_SZ 1	/* Alignment descriptor length */
+#define CFUSB_ALIGNMENT 4	/* Number of bytes to align. */
+#define CFUSB_MAX_HEADLEN (CFUSB_PAD_DESCR_SZ + CFUSB_ALIGNMENT-1)
+#define STE_USB_VID 0x04cc	/* USB Product ID for ST-Ericsson */
+#define STE_USB_PID_CAIF 0x2306	/* Product id for CAIF Modems */
+
+struct cfusbl {
+	struct cflayer layer;
+	u8 tx_eth_hdr[ETH_HLEN];
+};
+
+static bool pack_added;
+
+static int cfusbl_receive(struct cflayer *layr, struct cfpkt *pkt)
+{
+	u8 hpad;
+
+	/* Remove padding. */
+	cfpkt_extr_head(pkt, &hpad, 1);
+	cfpkt_extr_head(pkt, NULL, hpad);
+	return layr->up->receive(layr->up, pkt);
+}
+
+static int cfusbl_transmit(struct cflayer *layr, struct cfpkt *pkt)
+{
+	struct caif_payload_info *info;
+	u8 hpad;
+	u8 zeros[CFUSB_ALIGNMENT];
+	struct sk_buff *skb;
+	struct cfusbl *usbl = container_of(layr, struct cfusbl, layer);
+
+	skb = cfpkt_tonative(pkt);
+
+	skb_reset_network_header(skb);
+	skb->protocol = htons(ETH_P_IP);
+
+	info = cfpkt_info(pkt);
+	hpad = (info->hdr_len + CFUSB_PAD_DESCR_SZ) & (CFUSB_ALIGNMENT - 1);
+
+	if (skb_headroom(skb) < ETH_HLEN + CFUSB_PAD_DESCR_SZ + hpad) {
+		pr_warn("Headroom to small\n");
+		kfree_skb(skb);
+		return -EIO;
+	}
+	memset(zeros, 0, hpad);
+
+	cfpkt_add_head(pkt, zeros, hpad);
+	cfpkt_add_head(pkt, &hpad, 1);
+	cfpkt_add_head(pkt, usbl->tx_eth_hdr, sizeof(usbl->tx_eth_hdr));
+	return layr->dn->transmit(layr->dn, pkt);
+}
+
+static void cfusbl_ctrlcmd(struct cflayer *layr, enum caif_ctrlcmd ctrl,
+					int phyid)
+{
+	if (layr->up && layr->up->ctrlcmd)
+		layr->up->ctrlcmd(layr->up, ctrl, layr->id);
+}
+
+struct cflayer *cfusbl_create(int phyid, u8 ethaddr[ETH_ALEN],
+					u8 braddr[ETH_ALEN])
+{
+	struct cfusbl *this = kmalloc(sizeof(struct cfusbl), GFP_ATOMIC);
+
+	if (!this) {
+		pr_warn("Out of memory\n");
+		return NULL;
+	}
+	caif_assert(offsetof(struct cfusbl, layer) == 0);
+
+	memset(this, 0, sizeof(struct cflayer));
+	this->layer.receive = cfusbl_receive;
+	this->layer.transmit = cfusbl_transmit;
+	this->layer.ctrlcmd = cfusbl_ctrlcmd;
+	snprintf(this->layer.name, CAIF_LAYER_NAME_SZ, "usb%d", phyid);
+	this->layer.id = phyid;
+
+	/*
+	 * Construct TX ethernet header:
+	 *	0-5	destination address
+	 *	5-11	source address
+	 *	12-13	protocol type
+	 */
+	memcpy(&this->tx_eth_hdr[ETH_ALEN], braddr, ETH_ALEN);
+	memcpy(&this->tx_eth_hdr[ETH_ALEN], ethaddr, ETH_ALEN);
+	this->tx_eth_hdr[12] = cpu_to_be16(ETH_P_802_EX1) & 0xff;
+	this->tx_eth_hdr[13] = (cpu_to_be16(ETH_P_802_EX1) >> 8) & 0xff;
+	pr_debug("caif ethernet TX-header dst:%pM src:%pM type:%02x%02x\n",
+			this->tx_eth_hdr, this->tx_eth_hdr + ETH_ALEN,
+			this->tx_eth_hdr[12], this->tx_eth_hdr[13]);
+
+	return (struct cflayer *) this;
+}
+
+static struct packet_type caif_usb_type __read_mostly = {
+	.type = cpu_to_be16(ETH_P_802_EX1),
+};
+
+static int cfusbl_device_notify(struct notifier_block *me, unsigned long what,
+			      void *arg)
+{
+	struct net_device *dev = arg;
+	struct caif_dev_common common;
+	struct cflayer *layer, *link_support;
+	struct usbnet	*usbnet = netdev_priv(dev);
+	struct usb_device	*usbdev = usbnet->udev;
+	struct ethtool_drvinfo drvinfo;
+
+	if (what != NETDEV_REGISTER)
+		return 0;
+	/*
+	 * Quirks: High-jack ethtool to find if we have a NCM device,
+	 * and find it's VID/PID.
+	 */
+	if (dev->ethtool_ops == NULL || dev->ethtool_ops->get_drvinfo == NULL)
+		return 0;
+
+	dev->ethtool_ops->get_drvinfo(dev, &drvinfo);
+	if (strncmp(drvinfo.driver, "cdc_ncm", 7) != 0)
+		return 0;
+
+	pr_debug("USB CDC NCM device VID:0x%4x PID:0x%4x\n",
+		le16_to_cpu(usbdev->descriptor.idVendor),
+		le16_to_cpu(usbdev->descriptor.idProduct));
+
+	/* Check for VID/PID that supports CAIF */
+	if (!(le16_to_cpu(usbdev->descriptor.idVendor) == STE_USB_VID &&
+		le16_to_cpu(usbdev->descriptor.idProduct) == STE_USB_PID_CAIF))
+		return 0;
+
+	memset(&common, 0, sizeof(common));
+	common.use_frag = false;
+	common.use_fcs = false;
+	common.use_stx = false;
+	common.link_select = CAIF_LINK_HIGH_BANDW;
+	common.flowctrl = NULL;
+
+	link_support = cfusbl_create(dev->ifindex, dev->dev_addr,
+					dev->broadcast);
+	if (!link_support) {
+		pr_warn("Out of memory\n");
+		return -ENOMEM;
+	}
+
+	if (dev->num_tx_queues > 1)
+		pr_warn("USB device uses more than one tx queue\n");
+
+	caif_enroll_dev(dev, &common, link_support, CFUSB_MAX_HEADLEN,
+			&layer, &caif_usb_type.func);
+	if (!pack_added)
+		dev_add_pack(&caif_usb_type);
+	pack_added = 1;
+
+	strncpy(layer->name, dev->name,
+			sizeof(layer->name) - 1);
+	layer->name[sizeof(layer->name) - 1] = 0;
+
+	return 0;
+}
+
+static struct notifier_block caif_device_notifier = {
+	.notifier_call = cfusbl_device_notify,
+	.priority = 0,
+};
+
+void cfusbl_init(void)
+{
+	register_netdevice_notifier(&caif_device_notifier);
+}
+
+void cfusbl_exit(void)
+{
+	unregister_netdevice_notifier(&caif_device_notifier);
+	dev_remove_pack(&caif_usb_type);
+}
-- 
1.7.0.4

^ permalink raw reply related

* [RFC 2/3] if_ether.h: Add IEEE 802.1 Local Experimental Ethertype 1.
From: Sjur Br��ndeland @ 2011-11-30 20:44 UTC (permalink / raw)
  To: netdev; +Cc: David Miller, Alexey Orishko, Sjur Brændeland
In-Reply-To: <1322685846-7790-1-git-send-email-sjur.brandeland@stericsson.com>

From: Sjur Brændeland <sjur.brandeland@stericsson.com>

Add EthType 0x88b5.
This Ethertype value is available for public use for prototype and
vendor-specific protocol development,as defined in Amendment 802a
to IEEE Std 802.

Signed-off-by: Sjur Brændeland <sjur.brandeland@stericsson.com>
---
 include/linux/if_ether.h |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/include/linux/if_ether.h b/include/linux/if_ether.h
index e473003..56d907a 100644
--- a/include/linux/if_ether.h
+++ b/include/linux/if_ether.h
@@ -79,6 +79,7 @@
 #define ETH_P_PAE	0x888E		/* Port Access Entity (IEEE 802.1X) */
 #define ETH_P_AOE	0x88A2		/* ATA over Ethernet		*/
 #define ETH_P_8021AD	0x88A8          /* 802.1ad Service VLAN		*/
+#define ETH_P_802_EX1	0x88B5		/* 802.1 Local Experimental 1.  */
 #define ETH_P_TIPC	0x88CA		/* TIPC 			*/
 #define ETH_P_8021AH	0x88E7          /* 802.1ah Backbone Service Tag */
 #define ETH_P_1588	0x88F7		/* IEEE 1588 Timesync */
-- 
1.7.0.4

^ permalink raw reply related

* [RFC 1/3] caif: Add support for flow-control on device's tx-queue
From: Sjur Br��ndeland @ 2011-11-30 20:44 UTC (permalink / raw)
  To: netdev; +Cc: David Miller, Alexey Orishko, Sjur Brændeland
In-Reply-To: <1322685846-7790-1-git-send-email-sjur.brandeland@stericsson.com>

From: Sjur Brændeland <sjur.brandeland@stericsson.com>

Flow control is implemented by inspecting the qdisc queue length
in order to detect potential overflow on the TX queue. When a threshold
is reached flow-off is sent upwards in the CAIF stack. At the same time
the skb->destructor is hi-jacked in order to detect when the last packet
put on queue is consumed. When this "hi-jacked" packet is consumed, flow-on
is sent upwards in the CAIF stack.

Signed-off-by: Sjur Brændeland <sjur.brandeland@stericsson.com>
---
 net/caif/caif_dev.c |   48 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 48 insertions(+), 0 deletions(-)

diff --git a/net/caif/caif_dev.c b/net/caif/caif_dev.c
index f7e8c70..415353e 100644
--- a/net/caif/caif_dev.c
+++ b/net/caif/caif_dev.c
@@ -34,6 +34,7 @@ struct caif_device_entry {
 	struct list_head list;
 	struct net_device *netdev;
 	int __percpu *pcpu_refcnt;
+	bool xoff;
 };
 
 struct caif_device_entry_list {
@@ -48,6 +49,7 @@ struct caif_net {
 };
 
 static int caif_net_id;
+static int q_high = 50; /* Percent */
 
 struct cfcnfg *get_cfcnfg(struct net *net)
 {
@@ -126,9 +128,28 @@ static struct caif_device_entry *caif_get(struct net_device *dev)
 	return NULL;
 }
 
+void caif_flow_cb(struct sk_buff *skb)
+{
+	struct caif_device_entry *caifd;
+	WARN_ON(skb->dev == NULL);
+
+	rcu_read_lock();
+	caifd = caif_get(skb->dev);
+	caifd->xoff = 0;
+	caifd_hold(caifd);
+	rcu_read_unlock();
+
+	caifd->layer.up->
+		ctrlcmd(caifd->layer.up,
+			_CAIF_CTRLCMD_PHYIF_FLOW_ON_IND,
+			caifd->layer.id);
+	caifd_put(caifd);
+}
+
 static int transmit(struct cflayer *layer, struct cfpkt *pkt)
 {
 	int err;
+	struct caif_dev_common *caifdev;
 	struct caif_device_entry *caifd =
 	    container_of(layer, struct caif_device_entry, layer);
 	struct sk_buff *skb;
@@ -137,6 +158,33 @@ static int transmit(struct cflayer *layer, struct cfpkt *pkt)
 	skb->dev = caifd->netdev;
 	skb_reset_network_header(skb);
 	skb->protocol = htons(ETH_P_CAIF);
+	caifdev = netdev_priv(caifd->netdev);
+
+	if (caifdev->flowctrl == NULL && caifd->netdev->tx_queue_len > 0 &&
+			!caifd->xoff) {
+		struct netdev_queue *txq;
+		int high;
+
+		txq = netdev_get_tx_queue(skb->dev, 0);
+		high = (caifd->netdev->tx_queue_len * q_high) / 100;
+
+		/* If we run with a TX queue, check if the queue is too long*/
+		if (netif_queue_stopped(caifd->netdev) ||
+			qdisc_qlen(txq->qdisc) > high) {
+
+			pr_debug("queue stop(%d) or full (%d>%d) - XOFF\n",
+					netif_queue_stopped(caifd->netdev),
+					qdisc_qlen(txq->qdisc), high);
+			caifd->xoff = 1;
+			/* Hijack this skb free callback function. */
+			skb_orphan(skb);
+			skb->destructor = caif_flow_cb;
+			caifd->layer.up->
+				ctrlcmd(caifd->layer.up,
+					_CAIF_CTRLCMD_PHYIF_FLOW_OFF_IND,
+					caifd->layer.id);
+		}
+	}
 
 	err = dev_queue_xmit(skb);
 	if (err > 0)
-- 
1.7.0.4

^ permalink raw reply related

* [RFC 0/3] caif: Add support for CAIF over CDC NCM USB interface
From: Sjur Br��ndeland @ 2011-11-30 20:44 UTC (permalink / raw)
  To: netdev; +Cc: David Miller, Alexey Orishko, Sjur Brændeland

From: Sjur Brændeland <sjur.brandeland@stericsson.com>

The following patches enables sending and receive CAIF packets
over a cdc_ncm usb interface.

The patches has been tested on real HW and we have been running with this
for more than 6 months now.

NCM 1.0 does not support anything but Ethernet framing, hence
CAIF payload will be put into Ethernet frames. This it's a little
quirky, the long term solution for NCM should be based on
MBIM 1.0 specification.

These patches applies on top of previous patch-set:
commit 1014df0d3589ffc5dc881d0ca45164a482a55574
"Remove unused enum cfcnfg_phy_type and the parameter to cfserl_create."

Review comments and feedback is welcome.

Thanks,
Sjur Brændeland

Sjur Brændeland (3):
  caif: Add support for flow-control on device's tx-queue
  if_ether.h: Add IEEE 802.1 Local Experimental Ethertype 1.
  caif: Add support for CAIF over CDC NCM USB interface

 include/linux/if_ether.h  |    1 +
 include/net/caif/cfusbl.h |   13 +++
 net/caif/Kconfig          |   11 +++
 net/caif/Makefile         |    4 +-
 net/caif/caif_dev.c       |   55 +++++++++++++
 net/caif/cfusbl.c         |  199 +++++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 282 insertions(+), 1 deletions(-)
 create mode 100644 include/net/caif/cfusbl.h
 create mode 100644 net/caif/cfusbl.c

^ permalink raw reply

* [RFC iproute2] sch_red: TC_RED_HARDDROP
From: Eric Dumazet @ 2011-11-30 20:25 UTC (permalink / raw)
  To: Thomas Graf; +Cc: netdev, Stephen Hemminger

Hi Thomas

In 2005, TC_RED_HARDDROP kernel support was added to RED and GRED
(commit bdc450a0bb1 [PKT_SCHED]: (G)RED: Introduce hard dropping), but
current iproute2 doesnt have user land support.

Is there some patch waiting somewhere, or should we :

- Remove kernel support, since nobody uses it.

- Add iproute2 support.

Thanks

^ permalink raw reply

* pull request: wireless 2011-11-30
From: John W. Linville @ 2011-11-30 19:39 UTC (permalink / raw)
  To: davem; +Cc: linux-wireless, netdev, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 8173 bytes --]

commit 3b95e9c089d932c11f9ec03f7493f02cceff04ba

Dave,

This is a batch of fixes intended for 3.2.

There is an nl80211 fix for validating user input to prevent a buffer
underrun, a mac80211 race fix to prevent a WARN_ON, a mac80211 fix to
avoid trying to stop a single aggregation session twice, a mac80211 fix
for a race condition that could cause a crash when an addBA response
came late, the partial reversion of an ath9k change that broke wireless
on Ferrari One laptops, and a fix for an rtlwifi deadlock.

Please let me know if there are problems!

Thanks,

John

---

The following changes since commit 5dc5503f5a400be5a7dc611745a034f04b0679b8:

  isdn: avoid copying too long drvid (2011-11-29 18:39:37 -0500)

are available in the git repository at:
  git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless.git for-davem

Eliad Peller (1):
      nl80211: fix MAC address validation

Emmanuel Grumbach (1):
      mac80211: fix race between the AGG SM and the Tx data path

Johannes Berg (1):
      mac80211: don't stop a single aggregation session twice

John W. Linville (1):
      Merge branch 'master' of git://git.kernel.org/.../linville/wireless into for-davem

Nikolay Martynov (1):
      mac80211: fix race condition caused by late addBA response

Rafael J. Wysocki (1):
      ath9k: Revert change that broke AR928X on Acer Ferrari One

Stanislaw Gruszka (1):
      rtlwifi: fix lps_lock deadlock

 drivers/net/wireless/ath/ath9k/hw.c |    3 +-
 drivers/net/wireless/rtlwifi/ps.c   |   17 +++++++------
 net/mac80211/agg-tx.c               |   42 ++++++++++++++++++++++++++++++++--
 net/wireless/nl80211.c              |    4 +-
 4 files changed, 52 insertions(+), 14 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c
index 2f91acc..8873c6e 100644
--- a/drivers/net/wireless/ath/ath9k/hw.c
+++ b/drivers/net/wireless/ath/ath9k/hw.c
@@ -1827,7 +1827,8 @@ static void ath9k_set_power_sleep(struct ath_hw *ah, int setChip)
 	}
 
 	/* Clear Bit 14 of AR_WA after putting chip into Full Sleep mode. */
-	REG_WRITE(ah, AR_WA, ah->WARegVal & ~AR_WA_D3_L1_DISABLE);
+	if (AR_SREV_9300_20_OR_LATER(ah))
+		REG_WRITE(ah, AR_WA, ah->WARegVal & ~AR_WA_D3_L1_DISABLE);
 }
 
 /*
diff --git a/drivers/net/wireless/rtlwifi/ps.c b/drivers/net/wireless/rtlwifi/ps.c
index db52628..55c8e50 100644
--- a/drivers/net/wireless/rtlwifi/ps.c
+++ b/drivers/net/wireless/rtlwifi/ps.c
@@ -395,7 +395,7 @@ void rtl_lps_enter(struct ieee80211_hw *hw)
 	if (mac->link_state != MAC80211_LINKED)
 		return;
 
-	spin_lock(&rtlpriv->locks.lps_lock);
+	spin_lock_irq(&rtlpriv->locks.lps_lock);
 
 	/* Idle for a while if we connect to AP a while ago. */
 	if (mac->cnt_after_linked >= 2) {
@@ -407,7 +407,7 @@ void rtl_lps_enter(struct ieee80211_hw *hw)
 		}
 	}
 
-	spin_unlock(&rtlpriv->locks.lps_lock);
+	spin_unlock_irq(&rtlpriv->locks.lps_lock);
 }
 
 /*Leave the leisure power save mode.*/
@@ -416,8 +416,9 @@ void rtl_lps_leave(struct ieee80211_hw *hw)
 	struct rtl_priv *rtlpriv = rtl_priv(hw);
 	struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
 	struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
+	unsigned long flags;
 
-	spin_lock(&rtlpriv->locks.lps_lock);
+	spin_lock_irqsave(&rtlpriv->locks.lps_lock, flags);
 
 	if (ppsc->fwctrl_lps) {
 		if (ppsc->dot11_psmode != EACTIVE) {
@@ -438,7 +439,7 @@ void rtl_lps_leave(struct ieee80211_hw *hw)
 			rtl_lps_set_psmode(hw, EACTIVE);
 		}
 	}
-	spin_unlock(&rtlpriv->locks.lps_lock);
+	spin_unlock_irqrestore(&rtlpriv->locks.lps_lock, flags);
 }
 
 /* For sw LPS*/
@@ -539,9 +540,9 @@ void rtl_swlps_rf_awake(struct ieee80211_hw *hw)
 		RT_CLEAR_PS_LEVEL(ppsc, RT_PS_LEVEL_ASPM);
 	}
 
-	spin_lock(&rtlpriv->locks.lps_lock);
+	spin_lock_irq(&rtlpriv->locks.lps_lock);
 	rtl_ps_set_rf_state(hw, ERFON, RF_CHANGE_BY_PS);
-	spin_unlock(&rtlpriv->locks.lps_lock);
+	spin_unlock_irq(&rtlpriv->locks.lps_lock);
 }
 
 void rtl_swlps_rfon_wq_callback(void *data)
@@ -574,9 +575,9 @@ void rtl_swlps_rf_sleep(struct ieee80211_hw *hw)
 	if (rtlpriv->link_info.busytraffic)
 		return;
 
-	spin_lock(&rtlpriv->locks.lps_lock);
+	spin_lock_irq(&rtlpriv->locks.lps_lock);
 	rtl_ps_set_rf_state(hw, ERFSLEEP, RF_CHANGE_BY_PS);
-	spin_unlock(&rtlpriv->locks.lps_lock);
+	spin_unlock_irq(&rtlpriv->locks.lps_lock);
 
 	if (ppsc->reg_rfps_level & RT_RF_OFF_LEVL_ASPM &&
 		!RT_IN_PS_LEVEL(ppsc, RT_PS_LEVEL_ASPM)) {
diff --git a/net/mac80211/agg-tx.c b/net/mac80211/agg-tx.c
index b3f6552..b064e4d 100644
--- a/net/mac80211/agg-tx.c
+++ b/net/mac80211/agg-tx.c
@@ -161,6 +161,12 @@ int ___ieee80211_stop_tx_ba_session(struct sta_info *sta, u16 tid,
 		return -ENOENT;
 	}
 
+	/* if we're already stopping ignore any new requests to stop */
+	if (test_bit(HT_AGG_STATE_STOPPING, &tid_tx->state)) {
+		spin_unlock_bh(&sta->lock);
+		return -EALREADY;
+	}
+
 	if (test_bit(HT_AGG_STATE_WANT_START, &tid_tx->state)) {
 		/* not even started yet! */
 		ieee80211_assign_tid_tx(sta, tid, NULL);
@@ -169,6 +175,8 @@ int ___ieee80211_stop_tx_ba_session(struct sta_info *sta, u16 tid,
 		return 0;
 	}
 
+	set_bit(HT_AGG_STATE_STOPPING, &tid_tx->state);
+
 	spin_unlock_bh(&sta->lock);
 
 #ifdef CONFIG_MAC80211_HT_DEBUG
@@ -176,8 +184,6 @@ int ___ieee80211_stop_tx_ba_session(struct sta_info *sta, u16 tid,
 	       sta->sta.addr, tid);
 #endif /* CONFIG_MAC80211_HT_DEBUG */
 
-	set_bit(HT_AGG_STATE_STOPPING, &tid_tx->state);
-
 	del_timer_sync(&tid_tx->addba_resp_timer);
 
 	/*
@@ -187,6 +193,20 @@ int ___ieee80211_stop_tx_ba_session(struct sta_info *sta, u16 tid,
 	 */
 	clear_bit(HT_AGG_STATE_OPERATIONAL, &tid_tx->state);
 
+	/*
+	 * There might be a few packets being processed right now (on
+	 * another CPU) that have already gotten past the aggregation
+	 * check when it was still OPERATIONAL and consequently have
+	 * IEEE80211_TX_CTL_AMPDU set. In that case, this code might
+	 * call into the driver at the same time or even before the
+	 * TX paths calls into it, which could confuse the driver.
+	 *
+	 * Wait for all currently running TX paths to finish before
+	 * telling the driver. New packets will not go through since
+	 * the aggregation session is no longer OPERATIONAL.
+	 */
+	synchronize_net();
+
 	tid_tx->stop_initiator = initiator;
 	tid_tx->tx_stop = tx;
 
@@ -757,11 +777,27 @@ void ieee80211_process_addba_resp(struct ieee80211_local *local,
 		goto out;
 	}
 
-	del_timer(&tid_tx->addba_resp_timer);
+	del_timer_sync(&tid_tx->addba_resp_timer);
 
 #ifdef CONFIG_MAC80211_HT_DEBUG
 	printk(KERN_DEBUG "switched off addBA timer for tid %d\n", tid);
 #endif
+
+	/*
+	 * addba_resp_timer may have fired before we got here, and
+	 * caused WANT_STOP to be set. If the stop then was already
+	 * processed further, STOPPING might be set.
+	 */
+	if (test_bit(HT_AGG_STATE_WANT_STOP, &tid_tx->state) ||
+	    test_bit(HT_AGG_STATE_STOPPING, &tid_tx->state)) {
+#ifdef CONFIG_MAC80211_HT_DEBUG
+		printk(KERN_DEBUG
+		       "got addBA resp for tid %d but we already gave up\n",
+		       tid);
+#endif
+		goto out;
+	}
+
 	/*
 	 * IEEE 802.11-2007 7.3.1.14:
 	 * In an ADDBA Response frame, when the Status Code field
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index b3a476f..ffafda5 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -89,8 +89,8 @@ static const struct nla_policy nl80211_policy[NL80211_ATTR_MAX+1] = {
 	[NL80211_ATTR_IFINDEX] = { .type = NLA_U32 },
 	[NL80211_ATTR_IFNAME] = { .type = NLA_NUL_STRING, .len = IFNAMSIZ-1 },
 
-	[NL80211_ATTR_MAC] = { .type = NLA_BINARY, .len = ETH_ALEN },
-	[NL80211_ATTR_PREV_BSSID] = { .type = NLA_BINARY, .len = ETH_ALEN },
+	[NL80211_ATTR_MAC] = { .len = ETH_ALEN },
+	[NL80211_ATTR_PREV_BSSID] = { .len = ETH_ALEN },
 
 	[NL80211_ATTR_KEY] = { .type = NLA_NESTED, },
 	[NL80211_ATTR_KEY_DATA] = { .type = NLA_BINARY,
-- 
John W. Linville		Someday the world will need a hero, and you
linville@tuxdriver.com			might be all we have.  Be ready.

[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply related

* [PATCH net-next 3/3] caif: Remove unused enum and parameter in cfserl
From: Sjur Brændeland @ 2011-11-30 19:22 UTC (permalink / raw)
  To: netdev; +Cc: David Miller, Sjur Brændeland
In-Reply-To: <1322680968-6470-1-git-send-email-sjur.brandeland@stericsson.com>

Remove unused enum cfcnfg_phy_type and the parameter to cfserl_create.

Signed-off-by: Sjur Brændeland <sjur.brandeland@stericsson.com>
---
 include/net/caif/cfcnfg.h |   14 --------------
 include/net/caif/cfserl.h |    4 ++--
 net/caif/caif_dev.c       |    2 +-
 net/caif/cfserl.c         |    3 +--
 4 files changed, 4 insertions(+), 19 deletions(-)

diff --git a/include/net/caif/cfcnfg.h b/include/net/caif/cfcnfg.h
index a421723..90b4ff8 100644
--- a/include/net/caif/cfcnfg.h
+++ b/include/net/caif/cfcnfg.h
@@ -14,18 +14,6 @@
 struct cfcnfg;
 
 /**
- * enum cfcnfg_phy_type -  Types of physical layers defined in CAIF Stack
- *
- * @CFPHYTYPE_FRAG:	Fragmented frames physical interface.
- * @CFPHYTYPE_CAIF:	Generic CAIF physical interface
- */
-enum cfcnfg_phy_type {
-	CFPHYTYPE_FRAG = 1,
-	CFPHYTYPE_CAIF,
-	CFPHYTYPE_MAX
-};
-
-/**
  * enum cfcnfg_phy_preference - Physical preference HW Abstraction
  *
  * @CFPHYPREF_UNSPECIFIED:	Default physical interface
@@ -66,8 +54,6 @@ void cfcnfg_remove(struct cfcnfg *cfg);
  * cfcnfg_add_phy_layer() - Adds a physical layer to the CAIF stack.
  * @cnfg:	Pointer to a CAIF configuration object, created by
  *		cfcnfg_create().
- * @phy_type:	Specifies the type of physical interface, e.g.
- *			CFPHYTYPE_FRAG.
  * @dev:	Pointer to link layer device
  * @phy_layer:	Specify the physical layer. The transmit function
  *		MUST be set in the structure.
diff --git a/include/net/caif/cfserl.h b/include/net/caif/cfserl.h
index b837432..f121299 100644
--- a/include/net/caif/cfserl.h
+++ b/include/net/caif/cfserl.h
@@ -8,5 +8,5 @@
 #define CFSERL_H_
 #include <net/caif/caif_layer.h>
 
-struct cflayer *cfserl_create(int type, int instance, bool use_stx);
-#endif				/* CFSERL_H_ */
+struct cflayer *cfserl_create(int instance, bool use_stx);
+#endif
diff --git a/net/caif/caif_dev.c b/net/caif/caif_dev.c
index 70034c0..f7e8c70 100644
--- a/net/caif/caif_dev.c
+++ b/net/caif/caif_dev.c
@@ -295,7 +295,7 @@ static int caif_device_notify(struct notifier_block *me, unsigned long what,
 		if (caifdev->use_frag) {
 			head_room = 1;
 			link_support = cfserl_create(dev->ifindex,
-					CFPHYTYPE_FRAG, caifdev->use_stx);
+							caifdev->use_stx);
 			if (!link_support) {
 				pr_warn("Out of memory\n");
 				break;
diff --git a/net/caif/cfserl.c b/net/caif/cfserl.c
index 797c8d1..8e68b97 100644
--- a/net/caif/cfserl.c
+++ b/net/caif/cfserl.c
@@ -31,7 +31,7 @@ static int cfserl_transmit(struct cflayer *layr, struct cfpkt *pkt);
 static void cfserl_ctrlcmd(struct cflayer *layr, enum caif_ctrlcmd ctrl,
 				int phyid);
 
-struct cflayer *cfserl_create(int type, int instance, bool use_stx)
+struct cflayer *cfserl_create(int instance, bool use_stx)
 {
 	struct cfserl *this = kzalloc(sizeof(struct cfserl), GFP_ATOMIC);
 	if (!this)
@@ -40,7 +40,6 @@ struct cflayer *cfserl_create(int type, int instance, bool use_stx)
 	this->layer.receive = cfserl_receive;
 	this->layer.transmit = cfserl_transmit;
 	this->layer.ctrlcmd = cfserl_ctrlcmd;
-	this->layer.type = type;
 	this->usestx = use_stx;
 	spin_lock_init(&this->sync);
 	snprintf(this->layer.name, CAIF_LAYER_NAME_SZ, "ser1");
-- 
1.7.0.4

^ permalink raw reply related

* [PATCH net-next 2/3] caif: Restructure how link caif link layer enroll
From: Sjur Brændeland @ 2011-11-30 19:22 UTC (permalink / raw)
  To: netdev; +Cc: David Miller, Sjur Brændeland
In-Reply-To: <1322680968-6470-1-git-send-email-sjur.brandeland@stericsson.com>

Enrolling CAIF link layers are refactored.

Signed-off-by: Sjur Brændeland <sjur.brandeland@stericsson.com>
---
 include/net/caif/caif_dev.h |   21 ++++++
 include/net/caif/cfcnfg.h   |    9 ++-
 net/caif/caif_dev.c         |  145 ++++++++++++++++++++++++++----------------
 net/caif/cfcnfg.c           |   47 +++++---------
 4 files changed, 132 insertions(+), 90 deletions(-)

diff --git a/include/net/caif/caif_dev.h b/include/net/caif/caif_dev.h
index c011281..ef2dd94 100644
--- a/include/net/caif/caif_dev.h
+++ b/include/net/caif/caif_dev.h
@@ -9,6 +9,7 @@
 
 #include <net/caif/caif_layer.h>
 #include <net/caif/cfcnfg.h>
+#include <net/caif/caif_device.h>
 #include <linux/caif/caif_socket.h>
 #include <linux/if.h>
 #include <linux/net.h>
@@ -104,4 +105,24 @@ void caif_client_register_refcnt(struct cflayer *adapt_layer,
  */
 void caif_free_client(struct cflayer *adap_layer);
 
+/**
+ * struct caif_enroll_dev - Enroll a net-device as a CAIF Link layer
+ * @dev:		Network device to enroll.
+ * @caifdev:		Configuration information from CAIF Link Layer
+ * @link_support:	Link layer support layer
+ * @head_room:		Head room needed by link support layer
+ * @layer:		Lowest layer in CAIF stack
+ * @rcv_fun:		Receive function for CAIF stack.
+ *
+ * This function enroll a CAIF link layer into CAIF Stack and
+ * expects the interface to be able to handle CAIF payload.
+ * The link_support layer is used to add any Link Layer specific
+ * framing.
+ */
+void caif_enroll_dev(struct net_device *dev, struct caif_dev_common *caifdev,
+			struct cflayer *link_support, int head_room,
+			struct cflayer **layer, int (**rcv_func)(
+				struct sk_buff *, struct net_device *,
+				struct packet_type *, struct net_device *));
+
 #endif /* CAIF_DEV_H_ */
diff --git a/include/net/caif/cfcnfg.h b/include/net/caif/cfcnfg.h
index 3e93a4a..a421723 100644
--- a/include/net/caif/cfcnfg.h
+++ b/include/net/caif/cfcnfg.h
@@ -72,15 +72,16 @@ void cfcnfg_remove(struct cfcnfg *cfg);
  * @phy_layer:	Specify the physical layer. The transmit function
  *		MUST be set in the structure.
  * @pref:	The phy (link layer) preference.
+ * @link_support: Protocol implementation for link layer specific protocol.
  * @fcs:	Specify if checksum is used in CAIF Framing Layer.
- * @stx:	Specify if Start Of Frame eXtention is used.
+ * @head_room:	Head space needed by link specific protocol.
  */
-
 void
-cfcnfg_add_phy_layer(struct cfcnfg *cnfg, enum cfcnfg_phy_type phy_type,
+cfcnfg_add_phy_layer(struct cfcnfg *cnfg,
 		     struct net_device *dev, struct cflayer *phy_layer,
 		     enum cfcnfg_phy_preference pref,
-		     bool fcs, bool stx);
+		     struct cflayer *link_support,
+		     bool fcs, int head_room);
 
 /**
  * cfcnfg_del_phy_layer - Deletes an phy layer from the CAIF stack.
diff --git a/net/caif/caif_dev.c b/net/caif/caif_dev.c
index f1fa1f6..70034c0 100644
--- a/net/caif/caif_dev.c
+++ b/net/caif/caif_dev.c
@@ -24,6 +24,7 @@
 #include <net/caif/caif_layer.h>
 #include <net/caif/cfpkt.h>
 #include <net/caif/cfcnfg.h>
+#include <net/caif/cfserl.h>
 
 MODULE_LICENSE("GPL");
 
@@ -53,7 +54,8 @@ struct cfcnfg *get_cfcnfg(struct net *net)
 	struct caif_net *caifn;
 	BUG_ON(!net);
 	caifn = net_generic(net, caif_net_id);
-	BUG_ON(!caifn);
+	if (!caifn)
+		return NULL;
 	return caifn->cfg;
 }
 EXPORT_SYMBOL(get_cfcnfg);
@@ -63,7 +65,8 @@ static struct caif_device_entry_list *caif_device_list(struct net *net)
 	struct caif_net *caifn;
 	BUG_ON(!net);
 	caifn = net_generic(net, caif_net_id);
-	BUG_ON(!caifn);
+	if (!caifn)
+		return NULL;
 	return &caifn->caifdevs;
 }
 
@@ -92,7 +95,8 @@ static struct caif_device_entry *caif_device_alloc(struct net_device *dev)
 	struct caif_device_entry *caifd;
 
 	caifdevs = caif_device_list(dev_net(dev));
-	BUG_ON(!caifdevs);
+	if (!caifdevs)
+		return NULL;
 
 	caifd = kzalloc(sizeof(*caifd), GFP_KERNEL);
 	if (!caifd)
@@ -112,7 +116,9 @@ static struct caif_device_entry *caif_get(struct net_device *dev)
 	struct caif_device_entry_list *caifdevs =
 	    caif_device_list(dev_net(dev));
 	struct caif_device_entry *caifd;
-	BUG_ON(!caifdevs);
+	if (!caifdevs)
+		return NULL;
+
 	list_for_each_entry_rcu(caifd, &caifdevs->list, list) {
 		if (caifd->netdev == dev)
 			return caifd;
@@ -129,6 +135,8 @@ static int transmit(struct cflayer *layer, struct cfpkt *pkt)
 
 	skb = cfpkt_tonative(pkt);
 	skb->dev = caifd->netdev;
+	skb_reset_network_header(skb);
+	skb->protocol = htons(ETH_P_CAIF);
 
 	err = dev_queue_xmit(skb);
 	if (err > 0)
@@ -172,7 +180,10 @@ static int receive(struct sk_buff *skb, struct net_device *dev,
 
 	/* Release reference to stack upwards */
 	caifd_put(caifd);
-	return 0;
+
+	if (err != 0)
+		err = NET_RX_DROP;
+	return err;
 }
 
 static struct packet_type caif_packet_type __read_mostly = {
@@ -203,6 +214,55 @@ static void dev_flowctrl(struct net_device *dev, int on)
 	caifd_put(caifd);
 }
 
+void caif_enroll_dev(struct net_device *dev, struct caif_dev_common *caifdev,
+			struct cflayer *link_support, int head_room,
+			struct cflayer **layer, int (**rcv_func)(
+				struct sk_buff *, struct net_device *,
+				struct packet_type *, struct net_device *))
+{
+	struct caif_device_entry *caifd;
+	enum cfcnfg_phy_preference pref;
+	struct cfcnfg *cfg = get_cfcnfg(dev_net(dev));
+	struct caif_device_entry_list *caifdevs;
+
+	caifdevs = caif_device_list(dev_net(dev));
+	if (!cfg || !caifdevs)
+		return;
+	caifd = caif_device_alloc(dev);
+	if (!caifd)
+		return;
+	*layer = &caifd->layer;
+
+	switch (caifdev->link_select) {
+	case CAIF_LINK_HIGH_BANDW:
+		pref = CFPHYPREF_HIGH_BW;
+		break;
+	case CAIF_LINK_LOW_LATENCY:
+		pref = CFPHYPREF_LOW_LAT;
+		break;
+	default:
+		pref = CFPHYPREF_HIGH_BW;
+		break;
+	}
+	mutex_lock(&caifdevs->lock);
+	list_add_rcu(&caifd->list, &caifdevs->list);
+
+	strncpy(caifd->layer.name, dev->name,
+		sizeof(caifd->layer.name) - 1);
+	caifd->layer.name[sizeof(caifd->layer.name) - 1] = 0;
+	caifd->layer.transmit = transmit;
+	cfcnfg_add_phy_layer(cfg,
+				dev,
+				&caifd->layer,
+				pref,
+				link_support,
+				caifdev->use_fcs,
+				head_room);
+	mutex_unlock(&caifdevs->lock);
+	if (rcv_func)
+		*rcv_func = receive;
+}
+
 /* notify Caif of device events */
 static int caif_device_notify(struct notifier_block *me, unsigned long what,
 			      void *arg)
@@ -210,62 +270,40 @@ static int caif_device_notify(struct notifier_block *me, unsigned long what,
 	struct net_device *dev = arg;
 	struct caif_device_entry *caifd = NULL;
 	struct caif_dev_common *caifdev;
-	enum cfcnfg_phy_preference pref;
-	enum cfcnfg_phy_type phy_type;
 	struct cfcnfg *cfg;
+	struct cflayer *layer, *link_support;
+	int head_room = 0;
 	struct caif_device_entry_list *caifdevs;
 
-	if (dev->type != ARPHRD_CAIF)
-		return 0;
-
 	cfg = get_cfcnfg(dev_net(dev));
-	if (cfg == NULL)
+	caifdevs = caif_device_list(dev_net(dev));
+	if (!cfg || !caifdevs)
 		return 0;
 
-	caifdevs = caif_device_list(dev_net(dev));
+	caifd = caif_get(dev);
+	if (caifd == NULL && dev->type != ARPHRD_CAIF)
+		return 0;
 
 	switch (what) {
 	case NETDEV_REGISTER:
-		caifd = caif_device_alloc(dev);
-		if (!caifd)
-			return 0;
+		if (caifd != NULL)
+			break;
 
 		caifdev = netdev_priv(dev);
-		caifdev->flowctrl = dev_flowctrl;
 
-		caifd->layer.transmit = transmit;
-
-		if (caifdev->use_frag)
-			phy_type = CFPHYTYPE_FRAG;
-		else
-			phy_type = CFPHYTYPE_CAIF;
-
-		switch (caifdev->link_select) {
-		case CAIF_LINK_HIGH_BANDW:
-			pref = CFPHYPREF_HIGH_BW;
-			break;
-		case CAIF_LINK_LOW_LATENCY:
-			pref = CFPHYPREF_LOW_LAT;
-			break;
-		default:
-			pref = CFPHYPREF_HIGH_BW;
-			break;
+		link_support = NULL;
+		if (caifdev->use_frag) {
+			head_room = 1;
+			link_support = cfserl_create(dev->ifindex,
+					CFPHYTYPE_FRAG, caifdev->use_stx);
+			if (!link_support) {
+				pr_warn("Out of memory\n");
+				break;
+			}
 		}
-		strncpy(caifd->layer.name, dev->name,
-			sizeof(caifd->layer.name) - 1);
-		caifd->layer.name[sizeof(caifd->layer.name) - 1] = 0;
-
-		mutex_lock(&caifdevs->lock);
-		list_add_rcu(&caifd->list, &caifdevs->list);
-
-		cfcnfg_add_phy_layer(cfg,
-				     phy_type,
-				     dev,
-				     &caifd->layer,
-				     pref,
-				     caifdev->use_fcs,
-				     caifdev->use_stx);
-		mutex_unlock(&caifdevs->lock);
+		caif_enroll_dev(dev, caifdev, link_support, head_room,
+				&layer, NULL);
+		caifdev->flowctrl = dev_flowctrl;
 		break;
 
 	case NETDEV_UP:
@@ -371,17 +409,14 @@ static void caif_exit_net(struct net *net)
 	struct caif_device_entry *caifd, *tmp;
 	struct caif_device_entry_list *caifdevs =
 	    caif_device_list(net);
-	struct cfcnfg *cfg;
+	struct cfcnfg *cfg =  get_cfcnfg(net);
+
+	if (!cfg || !caifdevs)
+		return;
 
 	rtnl_lock();
 	mutex_lock(&caifdevs->lock);
 
-	cfg = get_cfcnfg(net);
-	if (cfg == NULL) {
-		mutex_unlock(&caifdevs->lock);
-		return;
-	}
-
 	list_for_each_entry_safe(caifd, tmp, &caifdevs->list, list) {
 		int i = 0;
 		list_del_rcu(&caifd->list);
diff --git a/net/caif/cfcnfg.c b/net/caif/cfcnfg.c
index 00523ec..598aafb 100644
--- a/net/caif/cfcnfg.c
+++ b/net/caif/cfcnfg.c
@@ -45,8 +45,8 @@ struct cfcnfg_phyinfo {
 	/* Interface index */
 	int ifindex;
 
-	/* Use Start of frame extension */
-	bool use_stx;
+	/* Protocol head room added for CAIF link layer */
+	int head_room;
 
 	/* Use Start of frame checksum */
 	bool use_fcs;
@@ -187,11 +187,11 @@ int caif_disconnect_client(struct net *net, struct cflayer *adap_layer)
 	if (channel_id != 0) {
 		struct cflayer *servl;
 		servl = cfmuxl_remove_uplayer(cfg->mux, channel_id);
+		cfctrl_linkdown_req(cfg->ctrl, channel_id, adap_layer);
 		if (servl != NULL)
 			layer_set_up(servl, NULL);
 	} else
 		pr_debug("nothing to disconnect\n");
-	cfctrl_linkdown_req(cfg->ctrl, channel_id, adap_layer);
 
 	/* Do RCU sync before initiating cleanup */
 	synchronize_rcu();
@@ -350,9 +350,7 @@ int caif_connect_client(struct net *net, struct caif_connect_request *conn_req,
 
 	*ifindex = phy->ifindex;
 	*proto_tail = 2;
-	*proto_head =
-
-	protohead[param.linktype] + (phy->use_stx ? 1 : 0);
+	*proto_head = protohead[param.linktype] + phy->head_room;
 
 	rcu_read_unlock();
 
@@ -460,13 +458,13 @@ unlock:
 }
 
 void
-cfcnfg_add_phy_layer(struct cfcnfg *cnfg, enum cfcnfg_phy_type phy_type,
+cfcnfg_add_phy_layer(struct cfcnfg *cnfg,
 		     struct net_device *dev, struct cflayer *phy_layer,
 		     enum cfcnfg_phy_preference pref,
-		     bool fcs, bool stx)
+		     struct cflayer *link_support,
+		     bool fcs, int head_room)
 {
 	struct cflayer *frml;
-	struct cflayer *phy_driver = NULL;
 	struct cfcnfg_phyinfo *phyinfo = NULL;
 	int i;
 	u8 phyid;
@@ -482,26 +480,13 @@ cfcnfg_add_phy_layer(struct cfcnfg *cnfg, enum cfcnfg_phy_type phy_type,
 			goto got_phyid;
 	}
 	pr_warn("Too many CAIF Link Layers (max 6)\n");
-	goto out_err;
+	goto out;
 
 got_phyid:
 	phyinfo = kzalloc(sizeof(struct cfcnfg_phyinfo), GFP_ATOMIC);
 	if (!phyinfo)
 		goto out_err;
 
-	switch (phy_type) {
-	case CFPHYTYPE_FRAG:
-		phy_driver =
-		    cfserl_create(CFPHYTYPE_FRAG, phyid, stx);
-		if (!phy_driver)
-			goto out_err;
-		break;
-	case CFPHYTYPE_CAIF:
-		phy_driver = NULL;
-		break;
-	default:
-		goto out_err;
-	}
 	phy_layer->id = phyid;
 	phyinfo->pref = pref;
 	phyinfo->id = phyid;
@@ -509,7 +494,7 @@ got_phyid:
 	phyinfo->dev_info.dev = dev;
 	phyinfo->phy_layer = phy_layer;
 	phyinfo->ifindex = dev->ifindex;
-	phyinfo->use_stx = stx;
+	phyinfo->head_room = head_room;
 	phyinfo->use_fcs = fcs;
 
 	frml = cffrml_create(phyid, fcs);
@@ -519,23 +504,23 @@ got_phyid:
 	phyinfo->frm_layer = frml;
 	layer_set_up(frml, cnfg->mux);
 
-	if (phy_driver != NULL) {
-		phy_driver->id = phyid;
-		layer_set_dn(frml, phy_driver);
-		layer_set_up(phy_driver, frml);
-		layer_set_dn(phy_driver, phy_layer);
-		layer_set_up(phy_layer, phy_driver);
+	if (link_support != NULL) {
+		link_support->id = phyid;
+		layer_set_dn(frml, link_support);
+		layer_set_up(link_support, frml);
+		layer_set_dn(link_support, phy_layer);
+		layer_set_up(phy_layer, link_support);
 	} else {
 		layer_set_dn(frml, phy_layer);
 		layer_set_up(phy_layer, frml);
 	}
 
 	list_add_rcu(&phyinfo->node, &cnfg->phys);
+out:
 	mutex_unlock(&cnfg->lock);
 	return;
 
 out_err:
-	kfree(phy_driver);
 	kfree(phyinfo);
 	mutex_unlock(&cnfg->lock);
 }
-- 
1.7.0.4

^ permalink raw reply related

* [PATCH net-next 1/3] caif: Allow cfpkt_extr_head to process empty message
From: Sjur Brændeland @ 2011-11-30 19:22 UTC (permalink / raw)
  To: netdev; +Cc: David Miller, Sjur Brændeland

Allow NULL pointer in cfpkt_extr_head in order to
skip past header data.

Signed-off-by: Sjur Brændeland <sjur.brandeland@stericsson.com>
---
 net/caif/cfpkt_skbuff.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/net/caif/cfpkt_skbuff.c b/net/caif/cfpkt_skbuff.c
index df08c47..de53907 100644
--- a/net/caif/cfpkt_skbuff.c
+++ b/net/caif/cfpkt_skbuff.c
@@ -144,7 +144,8 @@ int cfpkt_extr_head(struct cfpkt *pkt, void *data, u16 len)
 	}
 	from = skb_pull(skb, len);
 	from -= len;
-	memcpy(data, from, len);
+	if (data)
+		memcpy(data, from, len);
 	return 0;
 }
 
-- 
1.7.0.4

^ permalink raw reply related

* RE: [PATCH 1/2] net/hyperv: Fix long lines in netvsc.c
From: Haiyang Zhang @ 2011-11-30 19:13 UTC (permalink / raw)
  To: David Miller
  Cc: KY Srinivasan, gregkh@suse.de, linux-kernel@vger.kernel.org,
	netdev@vger.kernel.org, devel@linuxdriverproject.org
In-Reply-To: <20111130.123626.308237192773284976.davem@davemloft.net>

> -----Original Message-----
> From: David Miller [mailto:davem@davemloft.net]
> Sent: Wednesday, November 30, 2011 12:36 PM
> To: Haiyang Zhang
> Cc: KY Srinivasan; gregkh@suse.de; linux-kernel@vger.kernel.org;
> netdev@vger.kernel.org; devel@linuxdriverproject.org
> Subject: Re: [PATCH 1/2] net/hyperv: Fix long lines in netvsc.c
> 
> 
> Well, since Greg's tree is where the staging move happened, he'll have
> to take any patches to this driver that happen now, rather than me.

Sounds good. And, these patches were sent to devel@linuxdriverproject.org
too.

Greg, could you consider these patches for your tree?

Thanks,
- Haiyang

^ permalink raw reply

* Re: [net-next-2.6 PATCH 0/6 v4] macvlan: MAC Address filtering support for passthru mode
From: Ben Hutchings @ 2011-11-30 18:48 UTC (permalink / raw)
  To: Greg Rose
  Cc: Roopa Prabhu, netdev@vger.kernel.org, davem@davemloft.net,
	chrisw@redhat.com, sri@us.ibm.com, dragos.tatulea@gmail.com,
	kvm@vger.kernel.org, arnd@arndb.de, mst@redhat.com,
	mchan@broadcom.com, dwang2@cisco.com, shemminger@vyatta.com,
	eric.dumazet@gmail.com, kaber@trash.net, benve@cisco.com
In-Reply-To: <4ED6691D.9070606@intel.com>

On Wed, 2011-11-30 at 09:34 -0800, Greg Rose wrote:
> On 11/29/2011 9:19 AM, Ben Hutchings wrote:
> > On Tue, 2011-11-29 at 16:35 +0000, Ben Hutchings wrote:
> >>
> >> Maybe I missed something!
[...]
> >> If not, please explain what the new model *is*.
> 
> The new model is to incorporate a VEB into the NIC.  The current model 
> doesn't address any of the requirements of a VEB in the NIC and this 
> proposed set of patches allow us to set MAC filters for the *ports* on 
> the internal NIC VEB.  Consider the PF and each of the VFs as just a 
> port on the VEB.  We need the ability to set L2 filters (MAC, MC and 
> VLAN) for each of the ports on that VEB.  There is no currently 
> supported method for doing this.  So yes, this is a new model although 
> it's a fairly simple one.

Explain precisely how the VEB changes the existing model.  Explain how
the existing MAC filter and VF filter APIs interact with port filters on
the VEB.  Refer to any relevant standards.

(I have really had enough of net driver API proposals where all the
difficult questions are punted to the implementation.  Either
implementations diverge and users and userspace developers are left
horribly confused, or else the second and subsequent implementations
have to follow whatever quirks the first implementation had.  It's an
essential part of the review process that such questions are asked and
answered.)

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: [v4 PATCH 1/2] NETFILTER module xt_hmark, new target for HASH based fwmark
From: Pablo Neira Ayuso @ 2011-11-30 18:28 UTC (permalink / raw)
  To: Patrick McHardy
  Cc: Hans Schillstrom, jengelh, netfilter-devel, netdev,
	hans.schillstrom
In-Reply-To: <4ED64B5E.2030705@trash.net>

On Wed, Nov 30, 2011 at 04:27:26PM +0100, Patrick McHardy wrote:
> On 11/28/2011 10:36 AM, Hans Schillstrom wrote:
> >>If you don't want to use conntrack in your setup and you want to handle
> >>fragments, then you have to configure HMARK to calculate the hashing
> >>based on the network addresses. If you want to fully support fragments,
> >>then enable conntrack and you can configure HMARK to calculate the
> >>hashing based on network address + transport bits.
> >>
> >>Fix this by removing the fragmentation handling, then assume that
> >>people can select between two hashing configuration for HMARK. One
> >>based for network address which is fragment-safe, one that uses the
> >>transport layer information, that requires conntrack. Otherwise, I
> >>don't see a sane way to handle this situation.
> >Correct me if I'm wrong here,
> >If conntrack is enabled hmark don't see the packet until it is reassembled and
> >in that case the fragmentation header is removed.
> >
> >So, with conntrack HMARK will operate on full packets not fragments
> >without conntrack ports will not be used on any fragment
> 
> Correct.

To complete what Patrick said. They are collected but not linearized.
That's why you have to use skb_header_pointer.

> You don't necessarily need conntrack for defragmentation though,
> we've moved defragmentation to a seperate module for TPROXY. You
> can depend on that and get defragmentation without full
> connection tracking.

Indeed, I missed this. That way you can skip conntrack but solving the
broken fragments handling.

^ permalink raw reply

* Re: [PATCH] can: Update logging style
From: Joe Perches @ 2011-11-30 18:23 UTC (permalink / raw)
  To: Oliver Hartkopp
  Cc: Marc Kleine-Budde, Urs Thuermann, David S. Miller, linux-can,
	netdev, linux-kernel
In-Reply-To: <4ED6331E.6020005@hartkopp.net>

Use pr_fmt, pr_<level> and pr_<level>_ratelimited.
Coalesce format strings.

V2: Appease Oliver Hartkopp by adding "can" to the banner output.

Signed-off-by: Joe Perches <joe@perches.com>

---

> IMO if you want to use pr_fmt() it should at least look like this:
> can: controller area network core (rev 20090105 abi 8)
> NET: Registered protocol family 29
> can_raw: can raw protocol (rev 20090105)
> can_gw: can netlink gateway (rev 20101209)
> can_bcm: can broadcast manager protocol (rev 20090105 t)
> 
> I'm fine with using pr_fmt() for error/warning output but not for the banner
> in the currently suggested way.

I think it's duplicative, but it's not my code.

 net/can/af_can.c |   31 ++++++++++++++-----------------
 net/can/bcm.c    |   14 ++++++++------
 net/can/gw.c     |    6 ++++--
 net/can/proc.c   |    8 ++++----
 net/can/raw.c    |    8 +++++---
 5 files changed, 35 insertions(+), 32 deletions(-)

diff --git a/net/can/af_can.c b/net/can/af_can.c
index 0ce2ad0..c4f0da5 100644
--- a/net/can/af_can.c
+++ b/net/can/af_can.c
@@ -40,6 +40,8 @@
  *
  */
 
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/kmod.h>
@@ -62,8 +64,8 @@
 
 #include "af_can.h"
 
-static __initdata const char banner[] = KERN_INFO
-	"can: controller area network core (" CAN_VERSION_STRING ")\n";
+static __initdata const char banner[] =
+	"controller area network core (" CAN_VERSION_STRING ")";
 
 MODULE_DESCRIPTION("Controller Area Network PF_CAN core");
 MODULE_LICENSE("Dual BSD/GPL");
@@ -161,8 +163,8 @@ static int can_create(struct net *net, struct socket *sock, int protocol,
 		 * return -EPROTONOSUPPORT
 		 */
 		if (err)
-			printk_ratelimited(KERN_ERR "can: request_module "
-			       "(can-proto-%d) failed.\n", protocol);
+			pr_err_ratelimited("request_module (can-proto-%d) failed\n",
+					   protocol);
 
 		cp = can_get_proto(protocol);
 	}
@@ -505,8 +507,7 @@ void can_rx_unregister(struct net_device *dev, canid_t can_id, canid_t mask,
 
 	d = find_dev_rcv_lists(dev);
 	if (!d) {
-		printk(KERN_ERR "BUG: receive list not found for "
-		       "dev %s, id %03X, mask %03X\n",
+		pr_err("BUG: receive list not found for dev %s, id %03X, mask %03X\n",
 		       DNAME(dev), can_id, mask);
 		goto out;
 	}
@@ -532,8 +533,7 @@ void can_rx_unregister(struct net_device *dev, canid_t can_id, canid_t mask,
 	 */
 
 	if (!next) {
-		printk(KERN_ERR "BUG: receive list entry not found for "
-		       "dev %s, id %03X, mask %03X\n",
+		pr_err("BUG: receive list entry not found for dev %s, id %03X, mask %03X\n",
 		       DNAME(dev), can_id, mask);
 		r = NULL;
 		goto out;
@@ -701,8 +701,7 @@ int can_proto_register(const struct can_proto *cp)
 	int err = 0;
 
 	if (proto < 0 || proto >= CAN_NPROTO) {
-		printk(KERN_ERR "can: protocol number %d out of range\n",
-		       proto);
+		pr_err("protocol number %d out of range\n", proto);
 		return -EINVAL;
 	}
 
@@ -713,8 +712,7 @@ int can_proto_register(const struct can_proto *cp)
 	mutex_lock(&proto_tab_lock);
 
 	if (proto_tab[proto]) {
-		printk(KERN_ERR "can: protocol %d already registered\n",
-		       proto);
+		pr_err("protocol %d already registered\n", proto);
 		err = -EBUSY;
 	} else
 		RCU_INIT_POINTER(proto_tab[proto], cp);
@@ -769,8 +767,7 @@ static int can_notifier(struct notifier_block *nb, unsigned long msg,
 		/* create new dev_rcv_lists for this device */
 		d = kzalloc(sizeof(*d), GFP_KERNEL);
 		if (!d) {
-			printk(KERN_ERR
-			       "can: allocation of receive list failed\n");
+			pr_err("allocation of receive list failed\n");
 			return NOTIFY_DONE;
 		}
 		BUG_ON(dev->ml_priv);
@@ -790,8 +787,8 @@ static int can_notifier(struct notifier_block *nb, unsigned long msg,
 				dev->ml_priv = NULL;
 			}
 		} else
-			printk(KERN_ERR "can: notifier: receive list not "
-			       "found for dev %s\n", dev->name);
+			pr_err("notifier: receive list not found for dev %s\n",
+			       dev->name);
 
 		spin_unlock(&can_rcvlists_lock);
 
@@ -824,7 +821,7 @@ static struct notifier_block can_netdev_notifier __read_mostly = {
 
 static __init int can_init(void)
 {
-	printk(banner);
+	pr_info("%s\n", banner);
 
 	memset(&can_rx_alldev_list, 0, sizeof(can_rx_alldev_list));
 
diff --git a/net/can/bcm.c b/net/can/bcm.c
index 151b773..540c804 100644
--- a/net/can/bcm.c
+++ b/net/can/bcm.c
@@ -39,6 +39,8 @@
  *
  */
 
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
@@ -77,8 +79,8 @@
 		     (CAN_SFF_MASK | CAN_EFF_FLAG | CAN_RTR_FLAG))
 
 #define CAN_BCM_VERSION CAN_VERSION
-static __initdata const char banner[] = KERN_INFO
-	"can: broadcast manager protocol (rev " CAN_BCM_VERSION " t)\n";
+static __initdata const char banner[] =
+	"can broadcast manager protocol (rev " CAN_BCM_VERSION " t)";
 
 MODULE_DESCRIPTION("PF_CAN broadcast manager protocol");
 MODULE_LICENSE("Dual BSD/GPL");
@@ -729,8 +731,8 @@ static void bcm_rx_unreg(struct net_device *dev, struct bcm_op *op)
 		/* mark as removed subscription */
 		op->rx_reg_dev = NULL;
 	} else
-		printk(KERN_ERR "can-bcm: bcm_rx_unreg: registered device "
-		       "mismatch %p %p\n", op->rx_reg_dev, dev);
+		pr_err("%s: registered device mismatch %p %p\n",
+		       __func__, op->rx_reg_dev, dev);
 }
 
 /*
@@ -1606,11 +1608,11 @@ static int __init bcm_module_init(void)
 {
 	int err;
 
-	printk(banner);
+	pr_info("%s\n", banner);
 
 	err = can_proto_register(&bcm_can_proto);
 	if (err < 0) {
-		printk(KERN_ERR "can: registration of bcm protocol failed\n");
+		pr_err("registration of bcm protocol failed\n");
 		return err;
 	}
 
diff --git a/net/can/gw.c b/net/can/gw.c
index 3d79b12..e17253f 100644
--- a/net/can/gw.c
+++ b/net/can/gw.c
@@ -39,6 +39,8 @@
  *
  */
 
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/types.h>
@@ -59,7 +61,7 @@
 
 #define CAN_GW_VERSION "20101209"
 static __initdata const char banner[] =
-	KERN_INFO "can: netlink gateway (rev " CAN_GW_VERSION ")\n";
+	"can netlink gateway (rev " CAN_GW_VERSION ")";
 
 MODULE_DESCRIPTION("PF_CAN netlink gateway");
 MODULE_LICENSE("Dual BSD/GPL");
@@ -913,7 +915,7 @@ static int cgw_remove_job(struct sk_buff *skb,  struct nlmsghdr *nlh, void *arg)
 
 static __init int cgw_module_init(void)
 {
-	printk(banner);
+	pr_info("%s\n", banner);
 
 	cgw_cache = kmem_cache_create("can_gw", sizeof(struct cgw_job),
 				      0, 0, NULL);
diff --git a/net/can/proc.c b/net/can/proc.c
index ba873c3..c3aedf5 100644
--- a/net/can/proc.c
+++ b/net/can/proc.c
@@ -39,6 +39,8 @@
  *
  */
 
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/module.h>
 #include <linux/proc_fs.h>
 #include <linux/list.h>
@@ -118,8 +120,7 @@ static unsigned long calc_rate(unsigned long oldjif, unsigned long newjif,
 
 	/* see can_stat_update() - this should NEVER happen! */
 	if (count > (ULONG_MAX / HZ)) {
-		printk(KERN_ERR "can: calc_rate: count exceeded! %ld\n",
-		       count);
+		pr_err("%s: count exceeded! %ld\n", __func__, count);
 		return 99999999;
 	}
 
@@ -475,8 +476,7 @@ void can_init_proc(void)
 	can_dir = proc_mkdir("can", init_net.proc_net);
 
 	if (!can_dir) {
-		printk(KERN_INFO "can: failed to create /proc/net/can . "
-		       "CONFIG_PROC_FS missing?\n");
+		pr_info("failed to create /proc/net/can . CONFIG_PROC_FS missing?\n");
 		return;
 	}
 
diff --git a/net/can/raw.c b/net/can/raw.c
index cde1b4a..2875c55 100644
--- a/net/can/raw.c
+++ b/net/can/raw.c
@@ -39,6 +39,8 @@
  *
  */
 
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/uio.h>
@@ -56,7 +58,7 @@
 
 #define CAN_RAW_VERSION CAN_VERSION
 static __initdata const char banner[] =
-	KERN_INFO "can: raw protocol (rev " CAN_RAW_VERSION ")\n";
+	"can raw protocol (rev " CAN_RAW_VERSION ")";
 
 MODULE_DESCRIPTION("PF_CAN raw protocol");
 MODULE_LICENSE("Dual BSD/GPL");
@@ -783,11 +785,11 @@ static __init int raw_module_init(void)
 {
 	int err;
 
-	printk(banner);
+	pr_info("%s\n", banner);
 
 	err = can_proto_register(&raw_can_proto);
 	if (err < 0)
-		printk(KERN_ERR "can: registration of raw protocol failed\n");
+		pr_err("registration of raw protocol failed\n");
 
 	return err;
 }





^ permalink raw reply related

* Re: 3.2-rc2+: Reported regressions from 3.0 and 3.1
From: Konrad Rzeszutek Wilk @ 2011-11-30 17:59 UTC (permalink / raw)
  To: Borislav Petkov
  Cc: Linux SCSI List, Florian Mickler, Network Development,
	Linux PM List, x86, Linux Wireless List,
	Linux Kernel Mailing List, DRI, Linux ACPI, mingo, hpa, tglx,
	Kernel Testers List, Linus Torvalds, Andrew Morton,
	Maciej Rutecki
In-Reply-To: <20111129183428.GE8200@aftab>

On Tue, Nov 29, 2011 at 07:34:28PM +0100, Borislav Petkov wrote:
> On Tue, Nov 29, 2011 at 01:04:14PM -0500, Konrad Rzeszutek Wilk wrote:
> > This patch:


Borislav,

Thanks for your review comments. How does this patch look? I believe
I touched upon all of the things you mentioned.

>From eb6dbd80078312c428dde69e9313606b7513a2e6 Mon Sep 17 00:00:00 2001
From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Date: Mon, 21 Nov 2011 18:02:02 -0500
Subject: [PATCH] xen/pm_idle: Make pm_idle be default_idle under Xen.

This patch:

commit d91ee5863b71e8c90eaf6035bff3078a85e2e7b5
Author: Len Brown <len.brown@intel.com>
Date:   Fri Apr 1 18:28:35 2011 -0400

    cpuidle: replace xen access to x86 pm_idle and default_idle

    ..scribble on pm_idle and access default_idle,
   have it simply disable_cpuidle() so acpi_idle will not load and
   architecture default HLT will be used.

idea was to have one call - disable_cpuidle() which would make
pm_idle not be molested by other code. It disallows cpuidle_idle_call
to be set to pm_idle (which is excellent). But in the select_idle_routine()
and idle_setup(), the pm_idle can still be set to either:
amd_e400_idle, mwait_idle or default_idle. This depends on some
CPU flags (MWAIT) and in AMD case on the type of CPU.

In case of mwait_idle we can hit some instances where the hypervisor
(Amazon EC2 specifically) sets the MWAIT and we get:

Brought up 2 CPUs
invalid opcode: 0000 [#1] SMP
CPU 1
Modules linked in:

Pid: 0, comm: swapper Not tainted 3.1.0-0.rc6.git0.3.fc16.x86_64 #1
RIP: e030:[<ffffffff81015d1d>]  [<ffffffff81015d1d>] mwait_idle+0x6f/0xb4
RSP: e02b:ffff8801d28ddf10  EFLAGS: 00010082
RAX: ffff8801d28dc010 RBX: ffff8801d28ddfd8 RCX: 0000000000000000
RDX: 0000000000000000 RSI: 0000000000000001 RDI: 0000000000000001
RBP: ffff8801d28ddf10 R08: 0000000000000000 R09: 0000000000000001
R10: 0000000000000001 R11: ffff8801d28ddfd8 R12: ffffffff81b590d0
R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000
FS:  0000000000000000(0000) GS:ffff8801dff81000(0000) knlGS:0000000000000000
CS:  e033 DS: 002b ES: 002b CR0: 000000008005003b
CR2: 0000000000000000 CR3: 0000000001a05000 CR4: 0000000000002660
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000000
Process swapper (pid: 0, threadinfo ffff8801d28dc000, task ffff8801d28cae60)
Stack:
 ffff8801d28ddf40 ffffffff8100e2ed ffff8801dff8e390 c136dfe72feab515
 0000000000000000 0000000000000000 ffff8801d28ddf50 ffffffff8149ee78
 0000000000000000 0000000000000000 0000000000000000 0000000000000000
Call Trace:
 [<ffffffff8100e2ed>] cpu_idle+0xae/0xe8
 [<ffffffff8149ee78>] cpu_bringup_and_idle+0xe/0x10
RIP  [<ffffffff81015d1d>] mwait_idle+0x6f/0xb4
 RSP <ffff8801d28ddf10>

In case of amd_e400_idle we don't get so spectacular crashes, but
we do end up making an MSR which is trapped in the hypervisor,
and then follow it up with a yield hypercall. Meaning we end up
going to hypervisor twice instead of just once.

The previous behavior before v3.0 was that pm_idle was set
to default_idle irregardless of select_idle_routine/idle_setup.

We want to do that, but only for one specific case: Xen.
This patch does that.

Fixes RH BZ #739499 and Ubuntu #881076
Reported-by: Stefan Bader <stefan.bader@canonical.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
---
 arch/x86/include/asm/system.h |    1 +
 arch/x86/kernel/process.c     |    8 ++++++++
 arch/x86/xen/setup.c          |    2 +-
 3 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/arch/x86/include/asm/system.h b/arch/x86/include/asm/system.h
index c2ff2a1..2d2f01c 100644
--- a/arch/x86/include/asm/system.h
+++ b/arch/x86/include/asm/system.h
@@ -401,6 +401,7 @@ extern unsigned long arch_align_stack(unsigned long sp);
 extern void free_init_pages(char *what, unsigned long begin, unsigned long end);
 
 void default_idle(void);
+bool set_pm_idle_to_default(void);
 
 void stop_this_cpu(void *dummy);
 
diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
index 1f7f8c8..31f47ba 100644
--- a/arch/x86/kernel/process.c
+++ b/arch/x86/kernel/process.c
@@ -404,6 +404,14 @@ void default_idle(void)
 EXPORT_SYMBOL(default_idle);
 #endif
 
+bool set_pm_idle_to_default(void)
+{
+	bool ret = !!pm_idle;
+
+	pm_idle = default_idle;
+
+	return ret;
+}
 void stop_this_cpu(void *dummy)
 {
 	local_irq_disable();
diff --git a/arch/x86/xen/setup.c b/arch/x86/xen/setup.c
index 46d6d21..79dfb57 100644
--- a/arch/x86/xen/setup.c
+++ b/arch/x86/xen/setup.c
@@ -448,6 +448,6 @@ void __init xen_arch_setup(void)
 #endif
 	disable_cpuidle();
 	boot_option_idle_override = IDLE_HALT;
-
+	WARN_ON(set_pm_idle_to_default());
 	fiddle_vdso();
 }
-- 
1.7.7.3

^ permalink raw reply related

* Re: [PATCH 1/3] xfrm: add incoming interface to selector
From: David Miller @ 2011-11-30 17:47 UTC (permalink / raw)
  To: ulrich.weber; +Cc: netdev
In-Reply-To: <4ED66902.7060507@sophos.com>

From: Ulrich Weber <ulrich.weber@Sophos.com>
Date: Wed, 30 Nov 2011 18:33:54 +0100

> On 30.11.2011 01:00, David Miller wrote:
>>
>> This isn't safe, because we have no idea if existing users are putting
>> garbage there.  So your change can break things.
>>
>> You'll have to add a netlink attribute or similar.
> But a implementation matching xfrm against UID would break
> existing programs too, where sel->user is set to garbage.

Such a program would have to be used with other agents which are known
to not modify the sel->user of existing entries.

I'm not letting you reassign this existing structure member for another
use, it's been exposed to userspace for nearly 10 years.

^ permalink raw reply

* Re: [PATCH 1/2] net/hyperv: Fix long lines in netvsc.c
From: David Miller @ 2011-11-30 17:36 UTC (permalink / raw)
  To: haiyangz; +Cc: kys, gregkh, linux-kernel, netdev, devel
In-Reply-To: <1322666348-6554-1-git-send-email-haiyangz@microsoft.com>


Well, since Greg's tree is where the staging move happened, he'll have
to take any patches to this driver that happen now, rather than me.

^ permalink raw reply

* Re: [net-next-2.6 PATCH 0/6 v4] macvlan: MAC Address filtering support for passthru mode
From: Greg Rose @ 2011-11-30 17:34 UTC (permalink / raw)
  To: Ben Hutchings
  Cc: Roopa Prabhu, netdev@vger.kernel.org, davem@davemloft.net,
	chrisw@redhat.com, sri@us.ibm.com, dragos.tatulea@gmail.com,
	kvm@vger.kernel.org, arnd@arndb.de, mst@redhat.com,
	mchan@broadcom.com, dwang2@cisco.com, shemminger@vyatta.com,
	eric.dumazet@gmail.com, kaber@trash.net, benve@cisco.com
In-Reply-To: <1322587170.2684.26.camel@bwh-desktop>


On 11/29/2011 9:19 AM, Ben Hutchings wrote:
> On Tue, 2011-11-29 at 16:35 +0000, Ben Hutchings wrote:
>>
>> Maybe I missed something!
>>
>> Let's be clear on what our models are for filtering.  At the moment we
>> have MAC filters set through ndo_set_rx_mode and VF filters set through
>> ndo_set_vf_{mac,vlan}.
>>
>> Ignoring anti-spoofing for the moment, should the currently defined
>> filters look like this (a):
>>
>>                  TX ^   | RX
>>                     |   v
>> +------------------+---+-----------------+
>> |                  |  ++------------+    |
>> |                  |  |RX MAC filter|    |
>> |                  |  ++------------+    |
>> |                  |   |match            |
>> |                  ^   v                 |
>> |                  |  ++------------+    |
>> |                  |  |RX VF filters|    |
>> |                  |  +-------+-----+    |
>> |                 /|\     no /|\         |
>> |                | | \ match/ | |match 2 |
>> |                | ^  \    /  v |        |
>> |                | |   \  /match|        |
>> |                |  \   \/  1/  |        |
>> |                |   \  /\  /   |        |
>> |                ^    \/  \/    v        |
>> |                |    /\  /\    |        |
>> |                |   /  ||  \   |        |
>> |                |  /   ||   \  |        |
>> |                | /    ||    \ |        |
>> |                ||     ||     ||        |
>> +----------------++-----++-----++--------+
>>                   ||     ||     ||
>>                   PF    VF 1   VF 2
>>
>> or like this (b):
>>
>>                  TX ^   | RX
>>                     |   v
>> +------------------+---+-----------------+
>> |                  |  ++------------+    |
>> |                  |  |RX VF filters|    |
>> |                  |  ++--------+---+    |
>> |                  | no|match  /|        |
>> |                  ^   v      | |        |
>> |                  | +-+----+ | |        |
>> |                  | |RX MAC| | |        |
>> |                  | |filter| | |        |
>> |                  | +------+ | |        |
>> |                  |   |match | |        |
>> |                 /|\  |      | |        |
>> |                | | \ | match| |match 2 |
>> |                | ^  \/    1 v |        |
>> |                | |  /\      | |        |
>> |                |  \/  \    /  |        |
>> |                |  /\   \  /   |        |
>> |                ^ /  \   \/    v        |
>> |                ||    \  /\    |        |
>> |                ||     ||  \   |        |
>> |                ||     ||   \  |        |
>> |                ||     ||    \ |        |
>> |                ||     ||     ||        |
>> +----------------++-----++-----++--------+
>>                   ||     ||     ||
>>                   PF    VF 1   VF 2
>>
>> I think the current model is (a); do you agree?
>>
>> So is the proposed new model something like this (c):
>
> Corrected diagram:
>
>                  TX ^   | RX
>                     |   v
> +------------------+---+-----------------+
> |                  |  ++------------+    |
> |                  |  |RX MAC filter|    |
> |                  ^  ++------------+    |
> |                  |   |match            |
> |          no match|   v                 |
> |  +----------------+ ++------------+    |
> |  |loopback filters| |RX VF filters|    |
> |  +---------+-----++ +-------+-----+    |
> |           /|\   /|\ match  /|\         |
> |          v | `-+>+-+-.2   / | |        |
> |           \ \  | |m \ \   / | |        |
> |     match 0\ `-+-+.a \ \ /  v |        |
> |             \  | | \t \ X   / |        |
> |              \ |  \ \c X \ /  |        |
> |               \|   \ \h \ X   |        |
> |                \    \/\1 X \  v        |
> |                ||   /\ |/ \ \ |        |
> |                |v  /  ||   \ \|        |
> |                || /   ^|    \ |        |
> |                ||/    |v     ||        |
> |                ||     ||     ||        |
> +----------------++-----++-----++--------+
>                   ||     ||     ||
>                   PF    VF 1   VF 2
>
>> (I've labelled the new filters as loopback filters here, and I'm still
>> leaving out anti-spoofing.)
>>
>> If not, please explain what the new model *is*.

The new model is to incorporate a VEB into the NIC.  The current model 
doesn't address any of the requirements of a VEB in the NIC and this 
proposed set of patches allow us to set MAC filters for the *ports* on 
the internal NIC VEB.  Consider the PF and each of the VFs as just a 
port on the VEB.  We need the ability to set L2 filters (MAC, MC and 
VLAN) for each of the ports on that VEB.  There is no currently 
supported method for doing this.  So yes, this is a new model although 
it's a fairly simple one.

If you have an alternative proposal for allowing us to set L2 filters 
for the ports on our NIC VEB then I'm all ears (or eyes as the case may be).

- Greg

^ permalink raw reply

* Re: [PATCH net-next] tcp: inherit listener congestion control for passive cnx
From: Rick Jones @ 2011-11-30 17:33 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: Rick Jones, David Miller, netdev, Yuchung Cheng,
	Stephen Hemminger
In-Reply-To: <1322650961.2403.13.camel@edumazet-HP-Compaq-6005-Pro-SFF-PC>

On 11/30/2011 03:02 AM, Eric Dumazet wrote:
> Le mercredi 30 novembre 2011 à 06:40 +0100, Eric Dumazet a écrit :
>> Le mercredi 30 novembre 2011 à 06:21 +0100, Eric Dumazet a écrit :
>>
>>> So my suggestion would be to use this two lines patch instead :
>>>
>>> diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
>>> index 945efff..6b066e2 100644
>>> --- a/net/ipv4/tcp_minisocks.c
>>> +++ b/net/ipv4/tcp_minisocks.c
>>> @@ -495,8 +495,6 @@ struct sock *tcp_create_openreq_child(struct sock *sk, struct request_sock *req,
>>>   		newtp->frto_counter = 0;
>>>   		newtp->frto_highmark = 0;
>>>
>>> -		newicsk->icsk_ca_ops =&tcp_init_congestion_ops;
>>> -
>>>   		tcp_set_ca_state(newsk, TCP_CA_Open);
>>>   		tcp_init_xmit_timers(newsk);
>>>   		skb_queue_head_init(&newtp->out_of_order_queue);
>>>
>>
>> Please test this change and if its OK, resubmit your patch, with
>> appropriate Documentation change, as pointed out by Yuchung Cheng
>
> Hmm, after taking more time on this, we have to take care of module
> refcounting and proper cleanup. I hope you dont mind I submit my final
> version of this patch.

I do not mind at all.

rick

^ permalink raw reply

* Re: [PATCH 1/3] xfrm: add incoming interface to selector
From: Ulrich Weber @ 2011-11-30 17:33 UTC (permalink / raw)
  To: David Miller; +Cc: netdev@vger.kernel.org
In-Reply-To: <20111129.190037.1527680744377783412.davem@davemloft.net>

On 30.11.2011 01:00, David Miller wrote:
>
> This isn't safe, because we have no idea if existing users are putting
> garbage there.  So your change can break things.
>
> You'll have to add a netlink attribute or similar.
But a implementation matching xfrm against UID would break
existing programs too, where sel->user is set to garbage.

I checked all common programs, they set sel->user to zero:

iproute 3.1.0: sel->user is shown if set, but its not possible to set it
openswan 2.6.37: xfrm_selector memset to zero
strongswan 4.6.1: ifindex and user set to zero
ipsec-tools 0.8.0: PF_KEY only (memset to zero in net/key/af_key.c)
ike 2.1.7: PF_KEY only
isakmpd 20041012: PF_KEY only

Cheers
Ulrich

-- 
Ulrich Weber | ulrich.weber@sophos.com | Senior Software Engineer
Astaro - a Sophos company | Amalienbadstr 41 | 76227 Karlsruhe | Germany
Phone +49-721-25516-0 | Fax –200 | www.astaro.com

^ permalink raw reply

* Re: [PATCH 2/3] route: set iif and oif information in flowi struct
From: Ulrich Weber @ 2011-11-30 17:21 UTC (permalink / raw)
  To: Julian Anastasov; +Cc: netdev@vger.kernel.org, davem@davemloft.net
In-Reply-To: <alpine.LFD.2.00.1111290051240.2497@ja.ssi.bg>

On 29.11.2011 00:53, Julian Anastasov wrote:
>
> 	May be setting flowi4_oif unconditionally here is more
> correct because ip_route_output_slow fills flowi4_oif with
> the selected oif, it can even change the provided original
> oif in flowi4_oif. What about this?:
>
> 			flp4->flowi4_oif = rth->dst.dev->ifindex;
>
> 	OTOH, rt_iif has some complex semantic: original oif
> or the selected oif. May be you prefer flowi4_oif to hold
> the selected oif, right?
I wasn't aware the ip_route_output_slow() might change the original oif.
You know why this might happen? Shouldn't fib_lookup only return
a route matching the given oif?

Anyway, if thats the case your code above is more correct. The packet
should always match the xfrm policy where it was originally routed.

> 	I see one dangerous place that must be checked:
> icmp_route_lookup. Before now __ip_route_output_key was
> called after xfrm_decode_session_reverse with 0 in
> flowi4_oif, i.e. no oif binding was used. But now when
> decode_session sets flowi4_oif we will restrict the route
> via this interface?
Thanks for the hint! Yes the current patch will force the ICMP packet
over the received interface.

Will add "fl4_dec.flowi4_oif = 0;" in case the saddr is local, so the
behavior will be the same. fl4_dec.flowi4_oif will then be set in
_ip_route_output_key() again.

Cheers
Ulrich

-- 
Ulrich Weber | ulrich.weber@sophos.com | Senior Software Engineer
Astaro - a Sophos company | Amalienbadstr 41 | 76227 Karlsruhe | Germany
Phone +49-721-25516-0 | Fax –200 | www.astaro.com

^ permalink raw reply

* Re: [RFC net-next] Include selection of congestion control algorithm in that which is inherited across an accept() call
From: Rick Jones @ 2011-11-30 17:21 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: Rick Jones, netdev
In-Reply-To: <1322630461.2596.61.camel@edumazet-laptop>

The only reason I did it the way I did was I'd not yet gotten that far 
though the maze :)   I like your two-line *much* better and will test it 
today.

rick

^ permalink raw reply

* Re: [MAC802154] DRAFT: IEEE 802.15.4 MAC layer basic implementation
From: Dmitry Eremin-Solenikov @ 2011-11-30 17:17 UTC (permalink / raw)
  To: Alexander Smirnov; +Cc: Jon Smirl, linux-zigbee-devel, netdev, davem
In-Reply-To: <CAJmB2rAPFWtP1qMqNfgN-Xb154E1=QwXWc4XgKxrGdmKxUqANQ@mail.gmail.com>

Hello,

On Wed, Nov 30, 2011 at 8:54 PM, Alexander Smirnov
<alex.bluesman.smirnov@gmail.com> wrote:
> 2011/11/30 Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>:
>> On Wed, Nov 30, 2011 at 6:18 PM, Alexander Smirnov
>> <alex.bluesman.smirnov@gmail.com> wrote:
>>
>> [skipped]
>>
>>> This stack has working implementation in 'linux-zigbee.sourceforge.net'
>>> project, but unfortunately all the development was freezed according to
>>> unknown issue and it hasn't been merged to mailnline.
>>>
>>> Currently I'm the one engineer who continue working on them. So the
>>> following patch series is based on the project mentioned above, and I just
>>> cut code into roudimentary pieces with minor fixes.
>>
>> Alexander, thank you for continuing the work on the project! I'm glad to see
>> those patches being submitted to the mainline kernel.
>>
>>> The code in the following patches was tested by 6LowPAN module. I took at230
>>> transciever driver from 'linux-zigbee' and brought up IPv6 network, it worked.
>>>
>>> Could please anyone review patches and let me know what do you think?
>>
>> Several global notes:
>>
>> 1) Could you please include any (virtual or real) device driver
>> implementing the stack.
>> There was a "virtual radio" driver written for SoftMAC devices. The
>> driver had some small
>> design problems, but I think the stripped down version can be included
>> in the patchset.
>
> do you think that's a good idea to mix several layers in one patch series?
> Won't it be better to push some basic MAC support and only after the drivers?
> I see that way a little bit easier for code review.
>
> But if you don't think so, it's not a problem.

I think it's a good thing to include at least one sample driver (event
if it's a fake one).

>>
>> 2) Could you please rearrange the patches a little bit:
>> I'd really like to see the "monitor" devices interface pushed in the
>> first round of the patches.
>> It depends only on "simple mlme" and "RX/TX datapath" patches IIRC. It
>> would be really
>> good to merge those things first as it would then allow one to
>> implement their drivers,
>> check the radio, capture radio frames, etc.
>>
>
> Hmm, sounds good. I agree with this roadmap. :)

You might be interested in checking a MiWi protocols (from Microchip
IIRC). One of them was an IEEE 802.15.4 based protocol with lot's of
features stirpped out (I think you can find documentation in some of
the Microchip applicaiton notes, I either left the docs in Siemens, or I
have them in my home, I'll check later). That not-so-standard might
be a good 'second step' on the path to full IEEE 802.15.4 compliance.

>
>> I'll try reviewing patches really soon (as the time permits). However
>> could you please specify,
>> your changes over the last state I pushed to sf.net git repos (devel
>> or devel-30 branches)
>> to ease review?
>>
>
> The changes are really small and they don't affect the code
> structure/logic: using of common style in debug output, rewrite
> 'fetch_skb' functions, remove several unused lines etc...

Fine with me then.

-- 
With best wishes
Dmitry

^ permalink raw reply

* Re: ipv4: broadcast sometimes leaves wrong interface (since commit e066008b38ca9ace1b6de8dbbac8ed460640791d)
From: Jeroen van Ingen @ 2011-11-30 17:05 UTC (permalink / raw)
  To: Julian Anastasov; +Cc: netdev
In-Reply-To: <alpine.LFD.2.00.1111300010150.2020@ja.ssi.bg>

Hi Julian,

Thanks for your assistance, it's very much appreciated.

> 	__ip_dev_find can cause problem if same IP is added on many
> interfaces because it uses hash table implemented with hlist.
> Old versions used only routing lookup and the routing returns
> the first created local route, i.e. the first device where this
> IP was added is returned.

Right, and all ppp interfaces get the same IP as the interface that the
clients use to connect to, which in our case is the "main" IP for the
server.

> 	And now it is risky to use __ip_dev_find in
> ip_route_output_slow when:
> 
> - saddr is provided
> - desired oif is 0
> - daddr is multicast/lbcast
> 
> 	We select oif by ignoring route ordering. May be some
> ppp device wins here because it has this saddr added last but
> is first in hlist.
> 
> 	What is the case after first client is connected, can
> you show output from:
> 
> ip addr show

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP
qlen 1000
    link/ether 00:08:02:91:c9:1f brd ff:ff:ff:ff:ff:ff
    inet 130.89.254.233/27 brd 130.89.254.255 scope global eth0
    inet 130.89.254.234/27 brd 130.89.254.255 scope global secondary
eth0:1
    inet 130.89.254.235/27 brd 130.89.254.255 scope global secondary
eth0:2
    inet 130.89.254.236/27 brd 130.89.254.255 scope global secondary
eth0:3
    inet6 fe80::208:2ff:fe91:c91f/64 scope link
       valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,PROMISC,UP,LOWER_UP> mtu 1500 qdisc mq
state UP qlen 1000
    link/ether 00:1e:0b:76:83:d6 brd ff:ff:ff:ff:ff:ff
    inet6 fe80::21e:bff:fe76:83d6/64 scope link
       valid_lft forever preferred_lft forever
4: tap0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast
master br0 state UP qlen 100
    link/ether 42:a7:29:fa:de:4a brd ff:ff:ff:ff:ff:ff
    inet6 fe80::40a7:29ff:fefa:de4a/64 scope link
       valid_lft forever preferred_lft forever
5: tap1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast
master br0 state UP qlen 100
    link/ether 3e:1c:6f:5f:a2:a0 brd ff:ff:ff:ff:ff:ff
    inet6 fe80::3c1c:6fff:fe5f:a2a0/64 scope link
       valid_lft forever preferred_lft forever
6: tap2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast
master br0 state UP qlen 100
    link/ether 6a:17:16:92:93:35 brd ff:ff:ff:ff:ff:ff
    inet6 fe80::6817:16ff:fe92:9335/64 scope link
       valid_lft forever preferred_lft forever
7: tap3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast
master br0 state UP qlen 100
    link/ether ce:99:a3:e6:32:cd brd ff:ff:ff:ff:ff:ff
    inet6 fe80::cc99:a3ff:fee6:32cd/64 scope link
       valid_lft forever preferred_lft forever
8: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state
UP
    link/ether 00:1e:0b:76:83:d6 brd ff:ff:ff:ff:ff:ff
    inet6 fe80::21e:bff:fe76:83d6/64 scope link
       valid_lft forever preferred_lft forever
9: eth2: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000
    link/ether 00:1e:0b:76:83:d4 brd ff:ff:ff:ff:ff:ff
10: eth1.183@eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc
noqueue master br0 state UP
    link/ether 00:1e:0b:76:83:d6 brd ff:ff:ff:ff:ff:ff
    inet6 fe80::21e:bff:fe76:83d6/64 scope link
       valid_lft forever preferred_lft forever
11: eth1.184@eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc
noqueue state UP
    link/ether 00:1e:0b:76:83:d6 brd ff:ff:ff:ff:ff:ff
    inet 130.89.96.8/21 brd 130.89.103.255 scope global eth1.184
    inet6 fe80::21e:bff:fe76:83d6/64 scope link
       valid_lft forever preferred_lft forever
14: ppp0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1400 qdisc
pfifo_fast state UNKNOWN qlen 3
    link/ppp
    inet 130.89.254.233 peer 130.89.100.119/32 scope global ppp0


> ip route list table local

broadcast 127.0.0.0 dev lo  proto kernel  scope link  src 127.0.0.1
local 127.0.0.0/8 dev lo  proto kernel  scope host  src 127.0.0.1
local 127.0.0.1 dev lo  proto kernel  scope host  src 127.0.0.1
broadcast 127.255.255.255 dev lo  proto kernel  scope link  src
127.0.0.1
broadcast 130.89.96.0 dev eth1.184  proto kernel  scope link  src
130.89.96.8
local 130.89.96.8 dev eth1.184  proto kernel  scope host  src
130.89.96.8
broadcast 130.89.103.255 dev eth1.184  proto kernel  scope link  src
130.89.96.8
broadcast 130.89.254.224 dev eth0  proto kernel  scope link  src
130.89.254.233
local 130.89.254.233 dev eth0  proto kernel  scope host  src
130.89.254.233
local 130.89.254.233 dev ppp0  proto kernel  scope host  src
130.89.254.233
local 130.89.254.234 dev eth0  proto kernel  scope host  src
130.89.254.233
local 130.89.254.235 dev eth0  proto kernel  scope host  src
130.89.254.233
local 130.89.254.236 dev eth0  proto kernel  scope host  src
130.89.254.233
broadcast 130.89.254.255 dev eth0  proto kernel  scope link  src
130.89.254.233


> 	If the above is true may be we have to find a
> way to return the first device where the IP is added.
> May be this is the main rule that is used when one adds
> same IP on many interfaces.
> 
> 	May be the solution is to convert inet_addr_lst
> from hlist to normal list, so that we can append new
> addresses at tail and __ip_dev_find to find the first
> device where IP was added.

Perhaps the solution in our case is indeed to have all PPTP clients
connect to a secondary IP on the server; then all PPP interfaces still
share the same address, but it probably won't be the address that our
server selects as source for broadcast traffic (DHCP or otherwise). We
already have a couple of secondaries on the interface in question (as
you can see in "ip addr show"). We'll try this tomorrow, it's also in
line with your later suggestion in reply to David.

Another workaround for us might be to tell Radius to use a different
source IP for the DHCP address allocation when a client connects. Just
tested with a second client, this seems to work.

I'll let you know the results tomorrow.


Regards,

Jeroen van Ingen
ICT Service Centre
University of Twente, P.O.Box 217, 7500 AE Enschede, The Netherlands

^ 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