Netdev List
 help / color / mirror / Atom feed
* [PATCH 6/7] net: qrtr: Use sk_buff->cb in receive path
From: Bjorn Andersson @ 2017-09-07  6:03 UTC (permalink / raw)
  To: David S. Miller; +Cc: netdev, linux-kernel, linux-arm-msm, Chris Lew
In-Reply-To: <20170907060329.32402-1-bjorn.andersson@linaro.org>

Rather than parsing the header of incoming messages throughout the
implementation do it once when we retrieve the message and store the
relevant information in the "cb" member of the sk_buff.

This allows us to, in a later commit, decode version 2 messages into
this same structure.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
---
 net/qrtr/qrtr.c | 70 ++++++++++++++++++++++++++++++++-------------------------
 1 file changed, 40 insertions(+), 30 deletions(-)

diff --git a/net/qrtr/qrtr.c b/net/qrtr/qrtr.c
index f28ecd7d735b..5042999756ce 100644
--- a/net/qrtr/qrtr.c
+++ b/net/qrtr/qrtr.c
@@ -48,6 +48,16 @@ struct qrtr_hdr {
 	__le32 dst_port_id;
 } __packed;
 
+struct qrtr_cb {
+	u32 src_node;
+	u32 src_port;
+	u32 dst_node;
+	u32 dst_port;
+
+	u8 type;
+	u8 confirm_rx;
+};
+
 #define QRTR_HDR_SIZE sizeof(struct qrtr_hdr)
 
 struct qrtr_sock {
@@ -216,6 +226,7 @@ int qrtr_endpoint_post(struct qrtr_endpoint *ep, const void *data, size_t len)
 	struct qrtr_node *node = ep->node;
 	const struct qrtr_hdr *phdr = data;
 	struct sk_buff *skb;
+	struct qrtr_cb *cb;
 	unsigned int psize;
 	unsigned int size;
 	unsigned int type;
@@ -245,8 +256,15 @@ int qrtr_endpoint_post(struct qrtr_endpoint *ep, const void *data, size_t len)
 	if (!skb)
 		return -ENOMEM;
 
-	skb_reset_transport_header(skb);
-	skb_put_data(skb, data, len);
+	cb = (struct qrtr_cb *)skb->cb;
+	cb->src_node = le32_to_cpu(phdr->src_node_id);
+	cb->src_port = le32_to_cpu(phdr->src_port_id);
+	cb->dst_node = le32_to_cpu(phdr->dst_node_id);
+	cb->dst_port = le32_to_cpu(phdr->dst_port_id);
+	cb->type = type;
+	cb->confirm_rx = !!phdr->confirm_rx;
+
+	skb_put_data(skb, data + QRTR_HDR_SIZE, size);
 
 	skb_queue_tail(&node->rx_queue, skb);
 	schedule_work(&node->work);
@@ -295,26 +313,20 @@ static void qrtr_node_rx_work(struct work_struct *work)
 	struct sk_buff *skb;
 
 	while ((skb = skb_dequeue(&node->rx_queue)) != NULL) {
-		const struct qrtr_hdr *phdr;
-		u32 dst_node, dst_port;
 		struct qrtr_sock *ipc;
-		u32 src_node;
+		struct qrtr_cb *cb;
 		int confirm;
 
-		phdr = (const struct qrtr_hdr *)skb_transport_header(skb);
-		src_node = le32_to_cpu(phdr->src_node_id);
-		dst_node = le32_to_cpu(phdr->dst_node_id);
-		dst_port = le32_to_cpu(phdr->dst_port_id);
-		confirm = !!phdr->confirm_rx;
+		cb = (struct qrtr_cb *)skb->cb;
+		src.sq_node = cb->src_node;
+		src.sq_port = cb->src_port;
+		dst.sq_node = cb->dst_node;
+		dst.sq_port = cb->dst_port;
+		confirm = !!cb->confirm_rx;
 
-		src.sq_node = src_node;
-		src.sq_port = le32_to_cpu(phdr->src_port_id);
-		dst.sq_node = dst_node;
-		dst.sq_port = dst_port;
+		qrtr_node_assign(node, cb->src_node);
 
-		qrtr_node_assign(node, src_node);
-
-		ipc = qrtr_port_lookup(dst_port);
+		ipc = qrtr_port_lookup(cb->dst_port);
 		if (!ipc) {
 			kfree_skb(skb);
 		} else {
@@ -604,7 +616,7 @@ static int qrtr_local_enqueue(struct qrtr_node *node, struct sk_buff *skb,
 			      struct sockaddr_qrtr *to)
 {
 	struct qrtr_sock *ipc;
-	struct qrtr_hdr *phdr;
+	struct qrtr_cb *cb;
 
 	ipc = qrtr_port_lookup(to->sq_port);
 	if (!ipc || &ipc->sk == skb->sk) { /* do not send to self */
@@ -612,11 +624,9 @@ static int qrtr_local_enqueue(struct qrtr_node *node, struct sk_buff *skb,
 		return -ENODEV;
 	}
 
-	phdr = skb_push(skb, QRTR_HDR_SIZE);
-	skb_reset_transport_header(skb);
-
-	phdr->src_node_id = cpu_to_le32(from->sq_node);
-	phdr->src_port_id = cpu_to_le32(from->sq_port);
+	cb = (struct qrtr_cb *)skb->cb;
+	cb->src_node = from->sq_node;
+	cb->src_port = from->sq_port;
 
 	if (sock_queue_rcv_skb(&ipc->sk, skb)) {
 		qrtr_port_put(ipc);
@@ -750,9 +760,9 @@ static int qrtr_recvmsg(struct socket *sock, struct msghdr *msg,
 			size_t size, int flags)
 {
 	DECLARE_SOCKADDR(struct sockaddr_qrtr *, addr, msg->msg_name);
-	const struct qrtr_hdr *phdr;
 	struct sock *sk = sock->sk;
 	struct sk_buff *skb;
+	struct qrtr_cb *cb;
 	int copied, rc;
 
 	lock_sock(sk);
@@ -769,22 +779,22 @@ static int qrtr_recvmsg(struct socket *sock, struct msghdr *msg,
 		return rc;
 	}
 
-	phdr = (const struct qrtr_hdr *)skb_transport_header(skb);
-	copied = le32_to_cpu(phdr->size);
+	copied = skb->len;
 	if (copied > size) {
 		copied = size;
 		msg->msg_flags |= MSG_TRUNC;
 	}
 
-	rc = skb_copy_datagram_msg(skb, QRTR_HDR_SIZE, msg, copied);
+	rc = skb_copy_datagram_msg(skb, 0, msg, copied);
 	if (rc < 0)
 		goto out;
 	rc = copied;
 
 	if (addr) {
+		cb = (struct qrtr_cb *)skb->cb;
 		addr->sq_family = AF_QIPCRTR;
-		addr->sq_node = le32_to_cpu(phdr->src_node_id);
-		addr->sq_port = le32_to_cpu(phdr->src_port_id);
+		addr->sq_node = cb->src_node;
+		addr->sq_port = cb->src_port;
 		msg->msg_namelen = sizeof(*addr);
 	}
 
@@ -877,7 +887,7 @@ static int qrtr_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
 	case TIOCINQ:
 		skb = skb_peek(&sk->sk_receive_queue);
 		if (skb)
-			len = skb->len - QRTR_HDR_SIZE;
+			len = skb->len;
 		rc = put_user(len, (int __user *)argp);
 		break;
 	case SIOCGIFADDR:
-- 
2.12.0

^ permalink raw reply related

* [PATCH 7/7] net: qrtr: Support decoding incoming v2 packets
From: Bjorn Andersson @ 2017-09-07  6:03 UTC (permalink / raw)
  To: David S. Miller; +Cc: netdev, linux-kernel, linux-arm-msm, Chris Lew
In-Reply-To: <20170907060329.32402-1-bjorn.andersson@linaro.org>

Add the necessary logic for decoding incoming messages of version 2 as
well. Also make sure there's room for the bigger of version 1 and 2
headers in the code allocating skbs for outgoing messages.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
---
 net/qrtr/qrtr.c | 132 ++++++++++++++++++++++++++++++++++++++++----------------
 1 file changed, 94 insertions(+), 38 deletions(-)

diff --git a/net/qrtr/qrtr.c b/net/qrtr/qrtr.c
index 5042999756ce..5f397fa1c109 100644
--- a/net/qrtr/qrtr.c
+++ b/net/qrtr/qrtr.c
@@ -20,14 +20,15 @@
 
 #include "qrtr.h"
 
-#define QRTR_PROTO_VER 1
+#define QRTR_PROTO_VER_1 1
+#define QRTR_PROTO_VER_2 3
 
 /* auto-bind range */
 #define QRTR_MIN_EPH_SOCKET 0x4000
 #define QRTR_MAX_EPH_SOCKET 0x7fff
 
 /**
- * struct qrtr_hdr - (I|R)PCrouter packet header
+ * struct qrtr_hdr_v1 - (I|R)PCrouter packet header version 1
  * @version: protocol version
  * @type: packet type; one of QRTR_TYPE_*
  * @src_node_id: source node
@@ -37,7 +38,7 @@
  * @dst_node_id: destination node
  * @dst_port_id: destination port
  */
-struct qrtr_hdr {
+struct qrtr_hdr_v1 {
 	__le32 version;
 	__le32 type;
 	__le32 src_node_id;
@@ -48,6 +49,32 @@ struct qrtr_hdr {
 	__le32 dst_port_id;
 } __packed;
 
+/**
+ * struct qrtr_hdr_v2 - (I|R)PCrouter packet header later versions
+ * @version: protocol version
+ * @type: packet type; one of QRTR_TYPE_*
+ * @flags: bitmask of QRTR_FLAGS_*
+ * @optlen: length of optional header data
+ * @size: length of packet, excluding this header and optlen
+ * @src_node_id: source node
+ * @src_port_id: source port
+ * @dst_node_id: destination node
+ * @dst_port_id: destination port
+ */
+struct qrtr_hdr_v2 {
+	u8 version;
+	u8 type;
+	u8 flags;
+	u8 optlen;
+	__le32 size;
+	__le16 src_node_id;
+	__le16 src_port_id;
+	__le16 dst_node_id;
+	__le16 dst_port_id;
+} __packed;
+
+#define QRTR_FLAGS_CONFIRM_RX	BIT(0)
+
 struct qrtr_cb {
 	u32 src_node;
 	u32 src_port;
@@ -58,7 +85,8 @@ struct qrtr_cb {
 	u8 confirm_rx;
 };
 
-#define QRTR_HDR_SIZE sizeof(struct qrtr_hdr)
+#define QRTR_HDR_MAX_SIZE max_t(size_t, sizeof(struct qrtr_hdr_v1), \
+					sizeof(struct qrtr_hdr_v2))
 
 struct qrtr_sock {
 	/* WARNING: sk must be the first member */
@@ -154,12 +182,12 @@ static int qrtr_node_enqueue(struct qrtr_node *node, struct sk_buff *skb,
 			     int type, struct sockaddr_qrtr *from,
 			     struct sockaddr_qrtr *to)
 {
-	struct qrtr_hdr *hdr;
+	struct qrtr_hdr_v1 *hdr;
 	size_t len = skb->len;
 	int rc = -ENODEV;
 
-	hdr = skb_push(skb, QRTR_HDR_SIZE);
-	hdr->version = cpu_to_le32(QRTR_PROTO_VER);
+	hdr = skb_push(skb, sizeof(*hdr));
+	hdr->version = cpu_to_le32(QRTR_PROTO_VER_1);
 	hdr->type = cpu_to_le32(type);
 	hdr->src_node_id = cpu_to_le32(from->sq_node);
 	hdr->src_port_id = cpu_to_le32(from->sq_port);
@@ -224,52 +252,80 @@ static void qrtr_node_assign(struct qrtr_node *node, unsigned int nid)
 int qrtr_endpoint_post(struct qrtr_endpoint *ep, const void *data, size_t len)
 {
 	struct qrtr_node *node = ep->node;
-	const struct qrtr_hdr *phdr = data;
+	const struct qrtr_hdr_v1 *v1;
+	const struct qrtr_hdr_v2 *v2;
 	struct sk_buff *skb;
 	struct qrtr_cb *cb;
-	unsigned int psize;
 	unsigned int size;
-	unsigned int type;
 	unsigned int ver;
-	unsigned int dst;
+	size_t hdrlen;
 
-	if (len < QRTR_HDR_SIZE || len & 3)
+	if (len & 3)
 		return -EINVAL;
 
-	ver = le32_to_cpu(phdr->version);
-	size = le32_to_cpu(phdr->size);
-	type = le32_to_cpu(phdr->type);
-	dst = le32_to_cpu(phdr->dst_port_id);
+	skb = netdev_alloc_skb(NULL, len);
+	if (!skb)
+		return -ENOMEM;
 
-	psize = (size + 3) & ~3;
+	cb = (struct qrtr_cb *)skb->cb;
 
-	if (ver != QRTR_PROTO_VER)
-		return -EINVAL;
+	/* Version field in v1 is little endian, so this works for both cases */
+	ver = *(u8 *)data;
 
-	if (len != psize + QRTR_HDR_SIZE)
-		return -EINVAL;
+	switch (ver) {
+	case QRTR_PROTO_VER_1:
+		v1 = data;
+		hdrlen = sizeof(*v1);
 
-	if (dst != QRTR_PORT_CTRL && type != QRTR_TYPE_DATA)
-		return -EINVAL;
+		cb->type = le32_to_cpu(v1->type);
+		cb->src_node = le32_to_cpu(v1->src_node_id);
+		cb->src_port = le32_to_cpu(v1->src_port_id);
+		cb->confirm_rx = !!v1->confirm_rx;
+		cb->dst_node = le32_to_cpu(v1->dst_node_id);
+		cb->dst_port = le32_to_cpu(v1->dst_port_id);
 
-	skb = netdev_alloc_skb(NULL, len);
-	if (!skb)
-		return -ENOMEM;
+		size = le32_to_cpu(v1->size);
+		break;
+	case QRTR_PROTO_VER_2:
+		v2 = data;
+		hdrlen = sizeof(*v2) + v2->optlen;
+
+		cb->type = v2->type;
+		cb->confirm_rx = !!(v2->flags & QRTR_FLAGS_CONFIRM_RX);
+		cb->src_node = le16_to_cpu(v2->src_node_id);
+		cb->src_port = le16_to_cpu(v2->src_port_id);
+		cb->dst_node = le16_to_cpu(v2->dst_node_id);
+		cb->dst_port = le16_to_cpu(v2->dst_port_id);
+
+		if (cb->src_port == (u16)QRTR_PORT_CTRL)
+			cb->src_port = QRTR_PORT_CTRL;
+		if (cb->dst_port == (u16)QRTR_PORT_CTRL)
+			cb->dst_port = QRTR_PORT_CTRL;
+
+		size = le32_to_cpu(v2->size);
+		break;
+	default:
+		pr_err("qrtr: Invalid version %d\n", ver);
+		goto err;
+	}
 
-	cb = (struct qrtr_cb *)skb->cb;
-	cb->src_node = le32_to_cpu(phdr->src_node_id);
-	cb->src_port = le32_to_cpu(phdr->src_port_id);
-	cb->dst_node = le32_to_cpu(phdr->dst_node_id);
-	cb->dst_port = le32_to_cpu(phdr->dst_port_id);
-	cb->type = type;
-	cb->confirm_rx = !!phdr->confirm_rx;
+	if (len != ALIGN(size, 4) + hdrlen)
+		goto err;
 
-	skb_put_data(skb, data + QRTR_HDR_SIZE, size);
+	if (cb->dst_port != QRTR_PORT_CTRL && cb->type != QRTR_TYPE_DATA)
+		goto err;
+
+	skb_put_data(skb, data + hdrlen, size);
 
 	skb_queue_tail(&node->rx_queue, skb);
 	schedule_work(&node->work);
 
 	return 0;
+
+err:
+	kfree_skb(skb);
+	return -EINVAL;
+
 }
 EXPORT_SYMBOL_GPL(qrtr_endpoint_post);
 
@@ -287,11 +343,11 @@ static struct sk_buff *qrtr_alloc_ctrl_packet(struct qrtr_ctrl_pkt **pkt)
 	const int pkt_len = sizeof(struct qrtr_ctrl_pkt);
 	struct sk_buff *skb;
 
-	skb = alloc_skb(QRTR_HDR_SIZE + pkt_len, GFP_KERNEL);
+	skb = alloc_skb(QRTR_HDR_MAX_SIZE + pkt_len, GFP_KERNEL);
 	if (!skb)
 		return NULL;
 
-	skb_reserve(skb, QRTR_HDR_SIZE);
+	skb_reserve(skb, QRTR_HDR_MAX_SIZE);
 	*pkt = skb_put_zero(skb, pkt_len);
 
 	return skb;
@@ -720,12 +776,12 @@ static int qrtr_sendmsg(struct socket *sock, struct msghdr *msg, size_t len)
 	}
 
 	plen = (len + 3) & ~3;
-	skb = sock_alloc_send_skb(sk, plen + QRTR_HDR_SIZE,
+	skb = sock_alloc_send_skb(sk, plen + QRTR_HDR_MAX_SIZE,
 				  msg->msg_flags & MSG_DONTWAIT, &rc);
 	if (!skb)
 		goto out_node;
 
-	skb_reserve(skb, QRTR_HDR_SIZE);
+	skb_reserve(skb, QRTR_HDR_MAX_SIZE);
 
 	rc = memcpy_from_msg(skb_put(skb, len), msg, len);
 	if (rc) {
-- 
2.12.0

^ permalink raw reply related

* [PATCH 1/7] net: qrtr: Invoke sk_error_report() after setting sk_err
From: Bjorn Andersson @ 2017-09-07  6:03 UTC (permalink / raw)
  To: David S. Miller; +Cc: netdev, linux-kernel, linux-arm-msm, Chris Lew
In-Reply-To: <20170907060329.32402-1-bjorn.andersson@linaro.org>

Rather than manually waking up any context sleeping on the sock to
signal an error we should call sk_error_report(). This has the added
benefit that in-kernel consumers can override this notificatino with
its own callback.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
---
 net/qrtr/qrtr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/qrtr/qrtr.c b/net/qrtr/qrtr.c
index 5586609afa27..2058b27821a4 100644
--- a/net/qrtr/qrtr.c
+++ b/net/qrtr/qrtr.c
@@ -541,7 +541,7 @@ static void qrtr_reset_ports(void)
 
 		sock_hold(&ipc->sk);
 		ipc->sk.sk_err = ENETRESET;
-		wake_up_interruptible(sk_sleep(&ipc->sk));
+		ipc->sk.sk_error_report(&ipc->sk);
 		sock_put(&ipc->sk);
 	}
 	mutex_unlock(&qrtr_port_lock);
-- 
2.12.0

^ permalink raw reply related

* [PATCH 2/7] net: qrtr: Move constants to header file
From: Bjorn Andersson @ 2017-09-07  6:03 UTC (permalink / raw)
  To: David S. Miller; +Cc: netdev, linux-kernel, linux-arm-msm, Chris Lew
In-Reply-To: <20170907060329.32402-1-bjorn.andersson@linaro.org>

The constants are used by both the name server and clients, so clarify
their value and move them to the uapi header.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
---
 include/uapi/linux/qrtr.h | 3 +++
 net/qrtr/qrtr.c           | 2 --
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/include/uapi/linux/qrtr.h b/include/uapi/linux/qrtr.h
index 9d76c566f66e..63e8803e4d90 100644
--- a/include/uapi/linux/qrtr.h
+++ b/include/uapi/linux/qrtr.h
@@ -4,6 +4,9 @@
 #include <linux/socket.h>
 #include <linux/types.h>
 
+#define QRTR_NODE_BCAST	0xffffffffu
+#define QRTR_PORT_CTRL	0xfffffffeu
+
 struct sockaddr_qrtr {
 	__kernel_sa_family_t sq_family;
 	__u32 sq_node;
diff --git a/net/qrtr/qrtr.c b/net/qrtr/qrtr.c
index 2058b27821a4..0d7d3968414e 100644
--- a/net/qrtr/qrtr.c
+++ b/net/qrtr/qrtr.c
@@ -61,8 +61,6 @@ struct qrtr_hdr {
 } __packed;
 
 #define QRTR_HDR_SIZE sizeof(struct qrtr_hdr)
-#define QRTR_NODE_BCAST ((unsigned int)-1)
-#define QRTR_PORT_CTRL ((unsigned int)-2)
 
 struct qrtr_sock {
 	/* WARNING: sk must be the first member */
-- 
2.12.0

^ permalink raw reply related

* Re: [patch net] net: sched: fix memleak for chain zero
From: Jiri Pirko @ 2017-09-07  6:07 UTC (permalink / raw)
  To: Cong Wang
  Cc: Linux Kernel Network Developers, David Miller, Jamal Hadi Salim,
	Jakub Kicinski, mlxsw
In-Reply-To: <CAM_iQpX8q8A-J+7w0rzxuZBrTYLmmgLgU1K=cH9-9f0ikkSaPw@mail.gmail.com>

Thu, Sep 07, 2017 at 01:37:59AM CEST, xiyou.wangcong@gmail.com wrote:
>On Wed, Sep 6, 2017 at 1:33 PM, Jiri Pirko <jiri@resnulli.us> wrote:
>> Wed, Sep 06, 2017 at 07:40:02PM CEST, xiyou.wangcong@gmail.com wrote:
>>>On Wed, Sep 6, 2017 at 4:14 AM, Jiri Pirko <jiri@resnulli.us> wrote:
>>>> From: Jiri Pirko <jiri@mellanox.com>
>>>>
>>>> There's a memleak happening for chain 0. The thing is, chain 0 needs to
>>>> be always present, not created on demand. Therefore tcf_block_get upon
>>>> creation of block calls the tcf_chain_create function directly. The
>>>> chain is created with refcnt == 1, which is not correct in this case and
>>>> causes the memleak. So move the refcnt increment into tcf_chain_get
>>>> function even for the case when chain needs to be created.
>>>>
>>>
>>>Your approach could work but you just make the code even
>>>uglier than it is now:
>>>
>>>1. The current code is already ugly for special-casing chain 0:
>>>
>>>        if (--chain->refcnt == 0 && !chain->filter_chain && chain->index != 0)
>>>                tcf_chain_destroy(chain);
>>>
>>>2. With your patch, chain 0 has a different _initial_ refcnt with others.
>>
>> No. Initial refcnt is the same. ! for every action that holds the chain.
>> So actually, it returns it back where it should be.
>
>Not all all.
>
>tcf_block_get() calls tcf_chain_create(, 0), after your patch
>chain 0 has refcnt==0 initially.
>
>Non-0 chain? They are created via tcf_chain_get(), aka,
>refcnt==0 initially.

And if they are created on insertion of the filter, put is caller right
away which returns the ref back to 0. As I said, Non-0 refcnt means
either rule is being inserted/removed of there is an action that holds
reference to this chain. So my patch actually fixes the behaviour making
chain 0 and other chains to behave the same.


>
>
>>
>>
>>>
>>>3. Allowing an object (chain 0) exists with refcnt==0
>>
>> So? That is for every chain that does not have goto_chain action
>> pointing at. Please read the code.
>
>So you are pretending to be GC but you are apparently not.
>
>You create all the troubles by setting yourself to believe chain 0
>is special and refcnt==0 is okay. Both are wrong.
>
>Actually the !list_empty() check is totally unnecessary too,
>it is yet another place you get it wrong, you hide the race
>condition in commit 744a4cf63e52 which makes it harder
>to expose.
>
>I understand you don't trust me. Look at DaveM's reaction
>to your refcnt==0 madness.
>
>Remember, refcnt can be very simple, you just want to
>make it harder by abusing it or attempting to invent a GC.
>
>I am going to update my patch (to remove all your madness)
>since this is horribly wrong to me. Sorry.

It is not so easy to use the refcnt also for filters, I had good reason
to relend on filter_chain list to find out if there is a rule. If you
figure out how to do it better, be my guest. I suggest you do that for
net-next and let's fix the net in the easiest way possible.

^ permalink raw reply

* [PATCH 1/2] ip_tunnel: fix setting ttl and tos value in collect_md mode
From: Haishuang Yan @ 2017-09-07  6:08 UTC (permalink / raw)
  To: David S. Miller, Alexey Kuznetsov, Hideaki YOSHIFUJI
  Cc: netdev, linux-kernel, Haishuang Yan, Alexei Starovoitov

ttl and tos variables are declared and assigned, but are not used in
iptunnel_xmit() function.

Fixes: cfc7381b3002 ("ip_tunnel: add collect_md mode to IPIP tunnel")
Cc: Alexei Starovoitov <ast@fb.com>
Signed-off-by: Haishuang Yan <yanhaishuang@cmss.chinamobile.com>
---
 net/ipv4/ip_tunnel.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/ipv4/ip_tunnel.c b/net/ipv4/ip_tunnel.c
index 129d1a3..e1856bf 100644
--- a/net/ipv4/ip_tunnel.c
+++ b/net/ipv4/ip_tunnel.c
@@ -618,8 +618,8 @@ void ip_md_tunnel_xmit(struct sk_buff *skb, struct net_device *dev, u8 proto)
 		ip_rt_put(rt);
 		goto tx_dropped;
 	}
-	iptunnel_xmit(NULL, rt, skb, fl4.saddr, fl4.daddr, proto, key->tos,
-		      key->ttl, df, !net_eq(tunnel->net, dev_net(dev)));
+	iptunnel_xmit(NULL, rt, skb, fl4.saddr, fl4.daddr, proto, tos, ttl,
+		      df, !net_eq(tunnel->net, dev_net(dev)));
 	return;
 tx_error:
 	dev->stats.tx_errors++;
-- 
1.8.3.1

^ permalink raw reply related

* [PATCH 2/2] ip6_tunnel: fix setting hop_limit value for ipv6 tunnel
From: Haishuang Yan @ 2017-09-07  6:08 UTC (permalink / raw)
  To: David S. Miller, Alexey Kuznetsov, Hideaki YOSHIFUJI
  Cc: netdev, linux-kernel, Haishuang Yan
In-Reply-To: <1504764515-13536-1-git-send-email-yanhaishuang@cmss.chinamobile.com>

Similar to vxlan/geneve tunnel, if hop_limit is zero, it should fall
back to ip6_dst_hoplimt().

Signed-off-by: Haishuang Yan <yanhaishuang@cmss.chinamobile.com>
---
 net/ipv6/ip6_tunnel.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
index 3a0ba2a..10a693a 100644
--- a/net/ipv6/ip6_tunnel.c
+++ b/net/ipv6/ip6_tunnel.c
@@ -1184,6 +1184,7 @@ int ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev, __u8 dsfield,
 		init_tel_txopt(&opt, encap_limit);
 		ipv6_push_frag_opts(skb, &opt.ops, &proto);
 	}
+	hop_limit = hop_limit ? : ip6_dst_hoplimit(dst);
 
 	/* Calculate max headroom for all the headers and adjust
 	 * needed_headroom if necessary.
-- 
1.8.3.1

^ permalink raw reply related

* Re: [Patch net v2 2/2] net_sched: fix all the madness of tc filter chain
From: Jiri Pirko @ 2017-09-07  6:32 UTC (permalink / raw)
  To: Cong Wang; +Cc: netdev, jakub.kicinski, Jiri Pirko
In-Reply-To: <20170907042607.24413-2-xiyou.wangcong@gmail.com>

Thu, Sep 07, 2017 at 06:26:07AM CEST, xiyou.wangcong@gmail.com wrote:
>This patch fixes the following madness of tc filter chain:

Could you avoid expressive words like "madness" and such?
Please be technical.


>
>1) tcf_chain_destroy() is called by both tcf_block_put() and
>   tcf_chain_put().  tcf_chain_put() is correctly refcnt'ed and paired
>   with tcf_chain_get(), but tcf_block_put() is not, it should be paired
>   with tcf_block_get() which means we still need to decrease the refcnt.
>   Think it in another way: if we call tcf_bock_put() immediately after
>   tcf_block_get(), could we get effectively a nop? This causes a memory
>   leak as reported by Jakub.
>
>2) tp proto should hold a refcnt to the chain too. This significantly
>   simplifies the logic:
>
>2a) Chain 0 is no longer special, it is created and refcnted by tp
>    like any other chains. All the ugliness in tcf_chain_put() can be
>    gone!
>
>2b) No need to handle the flushing oddly, because block still holds
>    chain 0, it can not be released, this guarantees block is the last
>    user.
>
>2c) The race condition with RCU callbacks is easier to handle with just
>    a rcu_barrier()! Much easier to understand, nothing to hide! Thanks
>    to the previous patch. Please see also the comments in code.
>
>2d) Make the code understandable by humans, much less error-prone.
>
>Fixes: 744a4cf63e52 ("net: sched: fix use after free when tcf_chain_destroy is called multiple times")
>Fixes: 5bc1701881e3 ("net: sched: introduce multichain support for filters")
>Reported-by: Jakub Kicinski <jakub.kicinski@netronome.com>
>Cc: Jiri Pirko <jiri@mellanox.com>
>Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
>---
> net/sched/cls_api.c | 38 ++++++++++++++++++++++----------------
> 1 file changed, 22 insertions(+), 16 deletions(-)
>
>diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c
>index 6c5ea84d2682..e9060dc36519 100644
>--- a/net/sched/cls_api.c
>+++ b/net/sched/cls_api.c
>@@ -209,21 +209,20 @@ static void tcf_chain_flush(struct tcf_chain *chain)
> 		RCU_INIT_POINTER(*chain->p_filter_chain, NULL);
> 	while ((tp = rtnl_dereference(chain->filter_chain)) != NULL) {
> 		RCU_INIT_POINTER(chain->filter_chain, tp->next);
>+		tcf_chain_put(chain);
> 		tcf_proto_destroy(tp);
> 	}
> }
> 
> static void tcf_chain_destroy(struct tcf_chain *chain)
> {
>-	/* May be already removed from the list by the previous call. */
>-	if (!list_empty(&chain->list))
>-		list_del_init(&chain->list);
>+	list_del(&chain->list);
>+	kfree(chain);
>+}
> 
>-	/* There might still be a reference held when we got here from
>-	 * tcf_block_put. Wait for the user to drop reference before free.
>-	 */
>-	if (!chain->refcnt)
>-		kfree(chain);
>+static void tcf_chain_hold(struct tcf_chain *chain)
>+{
>+	++chain->refcnt;
> }
> 
> struct tcf_chain *tcf_chain_get(struct tcf_block *block, u32 chain_index,
>@@ -233,7 +232,7 @@ struct tcf_chain *tcf_chain_get(struct tcf_block *block, u32 chain_index,
> 
> 	list_for_each_entry(chain, &block->chain_list, list) {
> 		if (chain->index == chain_index) {
>-			chain->refcnt++;
>+			tcf_chain_hold(chain);
> 			return chain;
> 		}
> 	}
>@@ -246,10 +245,7 @@ EXPORT_SYMBOL(tcf_chain_get);
> 
> void tcf_chain_put(struct tcf_chain *chain)
> {
>-	/* Destroy unused chain, with exception of chain 0, which is the
>-	 * default one and has to be always present.
>-	 */
>-	if (--chain->refcnt == 0 && !chain->filter_chain && chain->index != 0)
>+	if (--chain->refcnt == 0)

Okay, so you take the reference for every goto_chain action and every
tp, right? Note that for chain 0, you hold one more reference (due to
the creation). That is probably ok as we need chain 0 not to go away
even if all tps and goto_chain actions are gone.


> 		tcf_chain_destroy(chain);
> }
> EXPORT_SYMBOL(tcf_chain_put);
>@@ -294,10 +290,18 @@ void tcf_block_put(struct tcf_block *block)
> 	if (!block)
> 		return;
> 
>-	list_for_each_entry_safe(chain, tmp, &block->chain_list, list) {
>+	/* Standalone actions are not allowed to jump to any chain, and
>+	 * bound actions should be all removed after flushing. However,
>+	 * filters are destroyed in RCU callbacks, we have to flush and wait
>+	 * for them before releasing this refcnt, otherwise we race with RCU
>+	 * callbacks!!!

Why the "!!!"? Please avoid that. Not necessary at all.


>+	 */
>+	list_for_each_entry(chain, &block->chain_list, list)
> 		tcf_chain_flush(chain);
>-		tcf_chain_destroy(chain);
>-	}
>+	rcu_barrier();

This actually tries to fix another bug I discovered yesterday. Good.


>+
>+	list_for_each_entry_safe(chain, tmp, &block->chain_list, list)
>+		tcf_chain_put(chain);

Which reference are you putting here? For chain 0, that is the original
reference due to creation from block_get. But how about the other
chains? If you do flush all in the previous list iteration, they are
removed there. Also note that they are removed from the list while
iterating it. 

I believe that you need to add tcf_chain_hold(chain) to the start of the
previous list iteration to ensure all existing chains will stay, then
you can put them here.

Did you test this? I believe we need some simple test script.


> 	kfree(block);
> }
> EXPORT_SYMBOL(tcf_block_put);
>@@ -375,6 +379,7 @@ static void tcf_chain_tp_insert(struct tcf_chain *chain,
> 		rcu_assign_pointer(*chain->p_filter_chain, tp);
> 	RCU_INIT_POINTER(tp->next, tcf_chain_tp_prev(chain_info));
> 	rcu_assign_pointer(*chain_info->pprev, tp);
>+	tcf_chain_hold(chain);
> }
> 
> static void tcf_chain_tp_remove(struct tcf_chain *chain,
>@@ -386,6 +391,7 @@ static void tcf_chain_tp_remove(struct tcf_chain *chain,
> 	if (chain->p_filter_chain && tp == chain->filter_chain)
> 		RCU_INIT_POINTER(*chain->p_filter_chain, next);
> 	RCU_INIT_POINTER(*chain_info->pprev, next);
>+	tcf_chain_put(chain);
> }
> 
> static struct tcf_proto *tcf_chain_tp_find(struct tcf_chain *chain,
>-- 
>2.13.0
>

^ permalink raw reply

* Re: VLAN/bridge "compression" in wifi (was: Re: [PATCH 3/8] qtnfmac: implement AP_VLAN iftype support)
From: Johannes Berg @ 2017-09-07  6:45 UTC (permalink / raw)
  To: Sergey Matyukevich; +Cc: linux-wireless, netdev, Igor Mitsyanko, Avinash Patil
In-Reply-To: <20170906154522.twtesbo2rxbrhekf@bars>

Hi,

> > To clarify, I think what you - conceptually - want is the following
> > topology:
> > 
> >         +--- eth0.1  ---  br.1  ---  wlan0.1
> >         |
> > eth0 ---+--- eth0.2  ---  br.2  ---  wlan0.2
> >         |
> >         +--- eth0.3  ---  br.3  ---  wlan0.3
[...]
> That's right. In fact, hostapd is able to create this kind of network
> bridge infrastructure automatically when it is built
> with CONFIG_FULL_DYNAMIC_VLAN option enabled.

Cool, I was unaware of the exact functionality of this build-time
option. :)

> > Now, you seem to want to compress this to
> > 
> >                   +---  wlan0.1
> >                   |
> > eth0  ---  br  ---+---  wlan0.2
> >                   |
> >                   +---  wlan0.3

[...]

> Exactly. And yes, the only purpose of this 'non-conventional' mode
> was to have 802.1Q acceleration on the ethernet port.

Right. You can still have acceleration in the top picture by placing
the feature into the Ethernet hardware, so that tagging/untagging
doesn't have to touch the packet data but just touches (skb) metadata.
But obviously that's something that happens on the other side and you
don't have control over it.

Anyway, I'm happy we cleared up what was going on and also that you
decided to leave it for now and work with the regular Linux topology
model.

Thanks,
johannes

^ permalink raw reply

* [PATCH net] smsc95xx: Configure pause time to 0xffff when tx flow control enabled
From: Nisar.Sayed @ 2017-09-07  6:51 UTC (permalink / raw)
  To: davem; +Cc: UNGLinuxDriver, netdev, steve.glendinning

From: Nisar Sayed <Nisar.Sayed@microchip.com>

Configure pause time to 0xffff when tx flow control enabled

Signed-off-by: Nisar Sayed <Nisar.Sayed@microchip.com>
---
 drivers/net/usb/smsc95xx.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c
index 340c134..309b88a 100644
--- a/drivers/net/usb/smsc95xx.c
+++ b/drivers/net/usb/smsc95xx.c
@@ -526,7 +526,7 @@ static void smsc95xx_set_multicast(struct net_device *netdev)
 static int smsc95xx_phy_update_flowcontrol(struct usbnet *dev, u8 duplex,
 					   u16 lcladv, u16 rmtadv)
 {
-	u32 flow, afc_cfg = 0;
+	u32 flow = 0, afc_cfg;
 
 	int ret = smsc95xx_read_reg(dev, AFC_CFG, &afc_cfg);
 	if (ret < 0)
@@ -537,20 +537,19 @@ static int smsc95xx_phy_update_flowcontrol(struct usbnet *dev, u8 duplex,
 
 		if (cap & FLOW_CTRL_RX)
 			flow = 0xFFFF0002;
-		else
-			flow = 0;
 
-		if (cap & FLOW_CTRL_TX)
+		if (cap & FLOW_CTRL_TX) {
 			afc_cfg |= 0xF;
-		else
+			flow |= 0xFFFF0000;
+		} else {
 			afc_cfg &= ~0xF;
+		}
 
 		netif_dbg(dev, link, dev->net, "rx pause %s, tx pause %s\n",
 				   cap & FLOW_CTRL_RX ? "enabled" : "disabled",
 				   cap & FLOW_CTRL_TX ? "enabled" : "disabled");
 	} else {
 		netif_dbg(dev, link, dev->net, "half duplex\n");
-		flow = 0;
 		afc_cfg |= 0xF;
 	}
 
-- 
1.9.1

^ permalink raw reply related

* pull-request: mac80211 2017-09-07
From: Johannes Berg @ 2017-09-07  7:09 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, linux-wireless

Hi Dave,

During my long absence some things have accumulated, but there wasn't
actually all that much that could've gone into the last cycle, and a
fix or two was taken care of by others.

The most important thing here is probably the deadlock fix that a few
people have run into on 4.13, but that was only identified now, and
perhaps the 40 MHz fix from Emmanuel that helps avoid iwlwifi firmware
crashes.

Please pull and let me know if there's any problem.

Thanks,
johannes



The following changes since commit 6d9c153a0b84392406bc77600aa7d3ea365de041:

  net: dsa: loop: Do not unregister invalid fixed PHY (2017-09-03 20:18:25 -0700)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/jberg/mac80211.git tags/mac80211-for-davem-2017-09-07

for you to fetch changes up to bde59c475e0883e4c4294bcd9b9c7e08ae18c828:

  mac80211: fix deadlock in driver-managed RX BA session start (2017-09-06 15:22:02 +0200)

----------------------------------------------------------------
Back from a long absence, so we have a number of things:
 * a remain-on-channel fix from Avi
 * hwsim TX power fix from Beni
 * null-PTR dereference with iTXQ in some rare configurations (Chunho)
 * 40 MHz custom regdomain fixes (Emmanuel)
 * look at right place in HT/VHT capability parsing (Igor)
 * complete A-MPDU teardown properly (Ilan)
 * Mesh ID Element ordering fix (Liad)
 * avoid tracing warning in ht_dbg() (Sharon)
 * fix print of assoc/reassoc (Simon)
 * fix encrypted VLAN with iTXQ (myself)
 * fix calling context of TX queue wake (myself)
 * fix a deadlock with ath10k aggregation (myself)

----------------------------------------------------------------
Avraham Stern (1):
      mac80211: flush hw_roc_start work before cancelling the ROC

Beni Lev (1):
      mac80211_hwsim: Use proper TX power

Chunho Lee (1):
      mac80211: Fix null pointer dereference with iTXQ support

Emmanuel Grumbach (1):
      cfg80211: honor NL80211_RRF_NO_HT40{MINUS,PLUS}

Igor Mitsyanko (1):
      nl80211: look for HT/VHT capabilities in beacon's tail

Ilan peer (1):
      mac80211: Complete ampdu work schedule during session tear down

Johannes Berg (3):
      mac80211: fix VLAN handling with TXQs
      mac80211: agg-tx: call drv_wake_tx_queue in proper context
      mac80211: fix deadlock in driver-managed RX BA session start

Liad Kaufman (1):
      mac80211: add MESH IE in the correct order

Sharon Dvir (1):
      mac80211: shorten debug prints using ht_dbg() to avoid warning

Simon Dinkin (1):
      mac80211: fix incorrect assignment of reassoc value

 drivers/net/wireless/mac80211_hwsim.c |  2 --
 include/net/mac80211.h                | 15 ++-------------
 net/mac80211/agg-rx.c                 | 32 ++++++++++++++++++++-----------
 net/mac80211/agg-tx.c                 |  8 ++++++--
 net/mac80211/ht.c                     | 24 ++++++++++++++++++++---
 net/mac80211/ieee80211_i.h            |  4 ++++
 net/mac80211/iface.c                  | 20 ++++++++++++++++---
 net/mac80211/mlme.c                   |  2 +-
 net/mac80211/offchannel.c             |  2 ++
 net/mac80211/tx.c                     | 36 ++++++++++++++++++++++++++++-------
 net/mac80211/util.c                   |  2 +-
 net/wireless/nl80211.c                |  4 ++--
 net/wireless/reg.c                    | 20 +++++++++++++++++--
 13 files changed, 124 insertions(+), 47 deletions(-)

^ permalink raw reply

* [PATCH net 1/3] lan78xx: Fix for eeprom read/write when device autosuspend
From: Nisar.Sayed @ 2017-09-07  7:11 UTC (permalink / raw)
  To: davem; +Cc: UNGLinuxDriver, netdev

From: Nisar Sayed <Nisar.Sayed@microchip.com>

Fix for eeprom read/write when device autosuspend

Signed-off-by: Nisar Sayed <Nisar.Sayed@microchip.com>
---
 drivers/net/usb/lan78xx.c | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c
index b99a7fb..baf91c7 100644
--- a/drivers/net/usb/lan78xx.c
+++ b/drivers/net/usb/lan78xx.c
@@ -1265,30 +1265,44 @@ static int lan78xx_ethtool_get_eeprom(struct net_device *netdev,
 				      struct ethtool_eeprom *ee, u8 *data)
 {
 	struct lan78xx_net *dev = netdev_priv(netdev);
+	int ret = -EINVAL;
+
+	if (usb_autopm_get_interface(dev->intf) < 0)
+		return ret;
 
 	ee->magic = LAN78XX_EEPROM_MAGIC;
 
-	return lan78xx_read_raw_eeprom(dev, ee->offset, ee->len, data);
+	ret = lan78xx_read_raw_eeprom(dev, ee->offset, ee->len, data);
+
+	usb_autopm_put_interface(dev->intf);
+
+	return ret;
 }
 
 static int lan78xx_ethtool_set_eeprom(struct net_device *netdev,
 				      struct ethtool_eeprom *ee, u8 *data)
 {
 	struct lan78xx_net *dev = netdev_priv(netdev);
+	int ret = -EINVAL;
+
+	if (usb_autopm_get_interface(dev->intf) < 0)
+		return ret;
 
 	/* Allow entire eeprom update only */
 	if ((ee->magic == LAN78XX_EEPROM_MAGIC) &&
 	    (ee->offset == 0) &&
 	    (ee->len == 512) &&
 	    (data[0] == EEPROM_INDICATOR))
-		return lan78xx_write_raw_eeprom(dev, ee->offset, ee->len, data);
+		ret = lan78xx_write_raw_eeprom(dev, ee->offset, ee->len, data);
 	else if ((ee->magic == LAN78XX_OTP_MAGIC) &&
 		 (ee->offset == 0) &&
 		 (ee->len == 512) &&
 		 (data[0] == OTP_INDICATOR_1))
-		return lan78xx_write_raw_otp(dev, ee->offset, ee->len, data);
+		ret = lan78xx_write_raw_otp(dev, ee->offset, ee->len, data);
 
-	return -EINVAL;
+	usb_autopm_put_interface(dev->intf);
+
+	return ret;
 }
 
 static void lan78xx_get_strings(struct net_device *netdev, u32 stringset,
-- 
1.9.1

^ permalink raw reply related

* [PATCH net 0/3] lan78xx: Fixes to lan78xx driver
From: Nisar.Sayed @ 2017-09-07  7:10 UTC (permalink / raw)
  To: davem; +Cc: UNGLinuxDriver, netdev

From: Nisar Sayed <Nisar.Sayed@microchip.com>

This series of patches are for lan78xx driver.

These patches fixes potential issues associated with lan78xx driver

Nisar Sayed (3):
  Fix for eeprom read/write when device autosuspend
  Allow EEPROM write for less than MAX_EEPROM_SIZE
  Use default value loaded from EEPROM/OTP when resetting

 drivers/net/usb/lan78xx.c | 27 ++++++++++++++++++++++-----
 1 file changed, 22 insertions(+), 5 deletions(-)

-- 
1.9.1

^ permalink raw reply

* [PATCH net 2/3] lan78xx: Allow EEPROM write for less than MAX_EEPROM_SIZE
From: Nisar.Sayed @ 2017-09-07  7:11 UTC (permalink / raw)
  To: davem; +Cc: UNGLinuxDriver, netdev

From: Nisar Sayed <Nisar.Sayed@microchip.com>

Allow EEPROM write for less than MAX_EEPROM_SIZE

Signed-off-by: Nisar Sayed <Nisar.Sayed@microchip.com>
---
 drivers/net/usb/lan78xx.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c
index baf91c7..94ef943 100644
--- a/drivers/net/usb/lan78xx.c
+++ b/drivers/net/usb/lan78xx.c
@@ -1299,6 +1299,10 @@ static int lan78xx_ethtool_set_eeprom(struct net_device *netdev,
 		 (ee->len == 512) &&
 		 (data[0] == OTP_INDICATOR_1))
 		ret = lan78xx_write_raw_otp(dev, ee->offset, ee->len, data);
+	else if ((ee->magic == LAN78XX_EEPROM_MAGIC) &&
+		 (ee->offset >= 0 && ee->offset < MAX_EEPROM_SIZE) &&
+		 (ee->len > 0 && (ee->offset + ee->len) <= MAX_EEPROM_SIZE))
+		ret = lan78xx_write_raw_eeprom(dev, ee->offset, ee->len, data);
 
 	usb_autopm_put_interface(dev->intf);
 
-- 
1.9.1

^ permalink raw reply related

* [PATCH 3/3] lan78xx: Use default value loaded from EEPROM/OTP when resetting
From: Nisar.Sayed @ 2017-09-07  7:11 UTC (permalink / raw)
  To: davem; +Cc: UNGLinuxDriver, netdev

From: Nisar Sayed <Nisar.Sayed@microchip.com>

Use default value loaded from EEPROM/OTP when resetting

Signed-off-by: Nisar Sayed <Nisar.Sayed@microchip.com>
---
 drivers/net/usb/lan78xx.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c
index 94ef943..8fd7c2f 100644
--- a/drivers/net/usb/lan78xx.c
+++ b/drivers/net/usb/lan78xx.c
@@ -2452,7 +2452,6 @@ static int lan78xx_reset(struct lan78xx_net *dev)
 	/* LAN7801 only has RGMII mode */
 	if (dev->chipid == ID_REV_CHIP_ID_7801_)
 		buf &= ~MAC_CR_GMII_EN_;
-	buf |= MAC_CR_AUTO_DUPLEX_ | MAC_CR_AUTO_SPEED_;
 	ret = lan78xx_write_reg(dev, MAC_CR, buf);
 
 	ret = lan78xx_read_reg(dev, MAC_TX, &buf);
-- 
1.9.1

^ permalink raw reply related

* RE: [PATCH] fsl/fman: make arrays port_ids static, reduces object code size
From: Madalin-cristian Bucur @ 2017-09-07  7:14 UTC (permalink / raw)
  To: Colin King, netdev@vger.kernel.org
  Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org
In-Reply-To: <20170831132449.27600-1-colin.king@canonical.com>

> -----Original Message-----
> From: Colin King [mailto:colin.king@canonical.com]
> Sent: Thursday, August 31, 2017 4:25 PM
> Subject: [PATCH] fsl/fman: make arrays port_ids static, reduces object
> code size
> 
> From: Colin Ian King <colin.king@canonical.com>
> 
> Don't populate the arrays port_ids on the stack, instead make them static.
> Makes the object code smaller by over 700 bytes:
> 
> Before:
>    text	   data	    bss	    dec	    hex	filename
>   28785	   5832	    192	  34809	   87f9	fman.o
> 
> After:
>    text	   data	    bss	    dec	    hex	filename
>   27921	   5992	    192	  34105	   8539	fman.o
> 
> Signed-off-by: Colin Ian King <colin.king@canonical.com>

Thanks,
Madalin

^ permalink raw reply

* Re: WARNING: at net/netfilter/core.c:218 __nf_hook_entries_try_shrink+0xf7/0x110
From: Florian Westphal @ 2017-09-07  7:13 UTC (permalink / raw)
  To: Mike Galbraith; +Cc: netdev
In-Reply-To: <1504761109.6518.10.camel@gmx.de>

Mike Galbraith <efault@gmx.de> wrote:
> [   21.219604] ip6_tables: (C) 2000-2006 Netfilter Core Team
> [   21.433091] nf_conntrack version 0.5.0 (65536 buckets, 262144 max)
> [   21.495849] ip_tables: (C) 2000-2006 Netfilter Core Team
> [   22.404040] ------------[ cut here ]------------
> [   22.404267] WARNING: CPU: 2 PID: 1379 at net/netfilter/core.c:218 __nf_hook_entries_try_shrink+0xf7/0x110

The WARN_ON is bogus, I sent a patch to remove it.

> Met 10 of those during this boot.  The first time I booted, the
> warnings were followed by the explosion below, but that kernel was not
> entirely virgin, so add a pinch of salt.
> 
> [   48.592298] Ebtables v2.0 registered
> [   48.730755] BUG: unable to handle kernel NULL pointer dereference at 000000000000003c
> [   48.732723] IP: _raw_read_lock_bh+0x15/0x30
> [   48.734526] PGD 0 P4D 0 
> [   48.736482] Oops: 0002 [#1] SMP
> [   48.738317] Dumping ftrace buffer:
> [   48.740260]    (ftrace buffer empty)
> [   48.775370] RIP: 0010:_raw_read_lock_bh+0x15/0x30
> [   48.776496] RSP: 0018:ffff88041ec83bd0 EFLAGS: 00010286
> [   48.777414] RAX: 0000000000000100 RBX: 0000000000000001 RCX: 0000000000000000
> [   48.778302] RDX: 0000000000000000 RSI: ffff88041ec83ca8 RDI: 000000000000003c
> [   48.779189] RBP: 0000000000000000 R08: 0000000000000001 R09: 00000000088a0c8d
> [   48.780072] R10: 0000000000000000 R11: 0000000000007b00 R12: ffff8803cdcc1300
> [   48.780950] R13: ffff8803cdcc1300 R14: 0000000000000000 R15: ffff8803f1b8b000
> [   48.781845] FS:  0000000000000000(0000) GS:ffff88041ec80000(0000) knlGS:0000000000000000
> [   48.782727] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> [   48.783533] CR2: 000000000000003c CR3: 00000003f19fa001 CR4: 00000000001606e0
> [   48.784348] Call Trace:
> [   48.785160]  <IRQ>
> [   48.786004]  ebt_do_table+0x3b/0x6ca [ebtables]
> [   48.786900]  ? dequeue_rt_stack+0x4c/0x290
> [   48.787792]  ? enqueue_task_rt+0x1da/0x300
> [   48.789001]  nf_hook_slow+0x37/0xb0
> [   48.790662]  br_pass_frame_up+0xbe/0xd0 [bridge]

Haven't seen that before, I will investigate.

^ permalink raw reply

* [PATCH] iwlwifi: mvm: only send LEDS_CMD when the FW supports it
From: Luca Coelho @ 2017-09-07  7:51 UTC (permalink / raw)
  To: torvalds
  Cc: linux-wireless, johannes, linux-kernel, akpm, kvalo, netdev,
	davem, emmanuel.grumbach, Luca Coelho
In-Reply-To: <CA+55aFxjHSW7v4Ttu7mGPkxdGpR-WtVoxDT5qtwxUC-Dge5a5A@mail.gmail.com>

From: Luca Coelho <luciano.coelho@intel.com>

The LEDS_CMD command is only supported in some newer FW versions
(e.g. iwlwifi-8000C-31.ucode), so we can't send it to older versions
(such as iwlwifi-8000C-27.ucode).

To fix this, check for a new bit in the FW capabilities TLV that tells
when the command is supported.

Note that the current version of -31.ucode in linux-firmware.git
(31.532993.0) does not have this capability bit set, so the LED won't
work, even though this version should support it.  But we will update
this firmware soon, so it won't be a problem anymore.

Fixes: 7089ae634c50 ("iwlwifi: mvm: use firmware LED command where applicable")
Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
---
 drivers/net/wireless/intel/iwlwifi/fw/file.h | 1 +
 drivers/net/wireless/intel/iwlwifi/mvm/led.c | 3 ++-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/fw/file.h b/drivers/net/wireless/intel/iwlwifi/fw/file.h
index 887f6d8fc8a7..279248cd9cfb 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/file.h
+++ b/drivers/net/wireless/intel/iwlwifi/fw/file.h
@@ -378,6 +378,7 @@ enum iwl_ucode_tlv_capa {
 	IWL_UCODE_TLV_CAPA_EXTEND_SHARED_MEM_CFG	= (__force iwl_ucode_tlv_capa_t)80,
 	IWL_UCODE_TLV_CAPA_LQM_SUPPORT			= (__force iwl_ucode_tlv_capa_t)81,
 	IWL_UCODE_TLV_CAPA_TX_POWER_ACK			= (__force iwl_ucode_tlv_capa_t)84,
+	IWL_UCODE_TLV_CAPA_LED_CMD_SUPPORT		= (__force iwl_ucode_tlv_capa_t)86,
 	IWL_UCODE_TLV_CAPA_MLME_OFFLOAD			= (__force iwl_ucode_tlv_capa_t)96,
 
 	NUM_IWL_UCODE_TLV_CAPA
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/led.c b/drivers/net/wireless/intel/iwlwifi/mvm/led.c
index 005e2e7278a5..b27269504a62 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/led.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/led.c
@@ -92,7 +92,8 @@ static void iwl_mvm_send_led_fw_cmd(struct iwl_mvm *mvm, bool on)
 
 static void iwl_mvm_led_set(struct iwl_mvm *mvm, bool on)
 {
-	if (mvm->cfg->device_family >= IWL_DEVICE_FAMILY_8000) {
+	if (fw_has_capa(&mvm->fw->ucode_capa,
+			IWL_UCODE_TLV_CAPA_LED_CMD_SUPPORT)) {
 		iwl_mvm_send_led_fw_cmd(mvm, on);
 		return;
 	}
-- 
2.14.1

^ permalink raw reply related

* [PATCH] dt-bindings: net: don't confuse with generic PHY property
From: Baruch Siach @ 2017-09-07  8:09 UTC (permalink / raw)
  To: David S. Miller, Rob Herring, Mark Rutland
  Cc: netdev, devicetree, Baruch Siach

This complements commit 9a94b3a4bd (dt-binding: phy: don't confuse with
Ethernet phy properties).

The generic PHY 'phys' property sometime appears in the same node with
the Ethernet PHY 'phy' or 'phy-handle' properties. Add a warning in
ethernet.txt to reduce confusion.

Signed-off-by: Baruch Siach <baruch@tkos.co.il>
---
 Documentation/devicetree/bindings/net/ethernet.txt | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/Documentation/devicetree/bindings/net/ethernet.txt b/Documentation/devicetree/bindings/net/ethernet.txt
index 7da86f22a13b..2974e63ba311 100644
--- a/Documentation/devicetree/bindings/net/ethernet.txt
+++ b/Documentation/devicetree/bindings/net/ethernet.txt
@@ -1,5 +1,9 @@
 The following properties are common to the Ethernet controllers:
 
+NOTE: All 'phy*' properties documented below are Ethernet specific. For the
+generic PHY 'phys' property, see
+Documentation/devicetree/bindings/phy/phy-bindings.txt.
+
 - local-mac-address: array of 6 bytes, specifies the MAC address that was
   assigned to the network device;
 - mac-address: array of 6 bytes, specifies the MAC address that was last used by
-- 
2.14.1

^ permalink raw reply related

* Re: Fwd: DA850-evm MAC Address is random
From: Sekhar Nori @ 2017-09-07  8:36 UTC (permalink / raw)
  To: Adam Ford; +Cc: Tony Lindgren, Grygorii Strashko, linux-omap, netdev
In-Reply-To: <CAHCN7xLTfELMtcMLx=mKAsJrkuvH4Ubd-8rTGswUWC5nofU7mg@mail.gmail.com>

On Thursday 07 September 2017 03:11 AM, Adam Ford wrote:
> On Mon, Sep 4, 2017 at 11:42 PM, Sekhar Nori <nsekhar@ti.com> wrote:
>> Hi Adam,
>>
>> On Wednesday 30 August 2017 11:08 AM, Sekhar Nori wrote:
>>>> I wonder if U-Boot isn't pushing something to Linux because it doesn't
>>>> appear to be running some of the da850 specific code even when I run
>>>> linux-next.  Can you tell me what verision of U-Boot you're using?
>>>> Other than using davinci_all_defconfig, did you change the
>>>> configuration at all?
>>
>>> I am using U-Boot 2017.01. Yes, the kernel was built using
>>> davinci_all_defconfig and no other config change. Before booting kernel,
>>> can you confirm that ethaddr is set in U-Boot environment? This is what
>>> fdt_fixup_ethernet() reads to fixup the FDT before boot.
>>>
>>> Here is my complete boot log with environment variable dump.
>>>
>>> http://pastebin.ubuntu.com/25430265/
>>
>> Were you able to get rid of the random mac address problem?
> 
> Not yet.  I haven't been able to rebuild Arago using TI's instructions
> on the Wiki.  I am not sure if it's a dependency issue or something
> else.  When I run Linux 4.13 using Buildroot as the rootfs, it does
> not appear to run da850_evm_m25p80_notify_add().  I am going to
> investigate whether or not da850_evm_init() is getting called.  I was
> wondering if you had some insight as to what calls that function?  It
> looks like it's defined as part of MACHINE_START(DAVINCI_DA850_EVM,
> "DaVinci DA850/OMAP-L138/AM18x EVM"), but I don't know how it gets
> called.

These functions are called only when booting using the legacy board file
method. From your logs before, you are booting using device tree. So
these functions are irrelevant.

Can you check if the mac address has been populated in the device-tree
by dumping it from /proc/device-tree/.../local-mac-address? That will
tell us if U-Boot is updating the mac address or not.

Thanks,
Sekhar

^ permalink raw reply

* Re: ipset losing entries on its own
From: Akshat Kakkar @ 2017-09-07  8:41 UTC (permalink / raw)
  To: Denys Fedoryshchenko; +Cc: netdev, netdev-owner
In-Reply-To: <CAA5aLPiENU+k0=tH1jPvSdmdEcMDFfgk0FQcHxWvz8tYCaNZzg@mail.gmail.com>

Another observation :
At times rehashing happens (v6.32) and hashsize increases to 2048 from
1024. But this is at times and not always. Needless to mention, it is
for exactly same IPs added to the ipset in exactly same order.

^ permalink raw reply

* nfp bpf offload add/replace
From: Jiri Pirko @ 2017-09-07  9:10 UTC (permalink / raw)
  To: kubakici; +Cc: netdev, mlxsw

Hi Kuba.

I'm looking into cls_bpf code and nfp_net_bpf_offload function in your
driver. Why do you need TC_CLSBPF_ADD? Seems like TC_CLSBPF_REPLACE
should be enough. It would make the cls_bpf code easier.

Note that other cls just have replace/destroy (u32 too, as drivers
handle NEW/REPLACE in one switch-case - will patch this).

Thanks!

Jiri

^ permalink raw reply

* Re: [PATCH v2 1/2] selftests: bpf: test_kmod.sh: check if module is present in the path before insert
From: Daniel Borkmann @ 2017-09-07  9:16 UTC (permalink / raw)
  To: naresh.kamboju, shuahkh, linux-kselftest
  Cc: linux-kernel, davem, alexei.starovoitov, netdev
In-Reply-To: <1504772342-21878-1-git-send-email-naresh.kamboju@linaro.org>

On 09/07/2017 10:19 AM, naresh.kamboju@linaro.org wrote:
> From: Naresh Kamboju <naresh.kamboju@linaro.org>
>
> The test script works when kernel source and build module test_bpf.ko
> present on the machine. This patch will check if module is present in
> the path.
>
> Signed-off-by: Naresh Kamboju <naresh.kamboju@linaro.org>

Looks good, what changed between v1 and v2? Didn't get the cover
letter in case there was one. ;)

Which tree are you targeting? There are usually a lot of changes
in BPF selftests going the usual route via net and net-next tree
as we often require to put test cases along the BPF patches. Given
the merge window now and given one can regard it as a fix, it's
net tree. I'm also ok if Shuah wants to pick it up this window as
test_kmod.sh hasn't been changed in quite a while, so no merge
conflicts expected.

Anyway, for the patch:

Acked-by: Daniel Borkmann <daniel@iogearbox.net>

Thanks!

> ---
>   tools/testing/selftests/bpf/test_kmod.sh | 8 +++++---
>   1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/tools/testing/selftests/bpf/test_kmod.sh b/tools/testing/selftests/bpf/test_kmod.sh
> index 6d58cca8e235..a53eb1cb54ef 100755
> --- a/tools/testing/selftests/bpf/test_kmod.sh
> +++ b/tools/testing/selftests/bpf/test_kmod.sh
> @@ -9,9 +9,11 @@ test_run()
>
>   	echo "[ JIT enabled:$1 hardened:$2 ]"
>   	dmesg -C
> -	insmod $SRC_TREE/lib/test_bpf.ko 2> /dev/null
> -	if [ $? -ne 0 ]; then
> -		rc=1
> +	if [ -f $SRC_TREE/lib/test_bpf.ko ]; then
> +		insmod $SRC_TREE/lib/test_bpf.ko 2> /dev/null
> +		if [ $? -ne 0 ]; then
> +			rc=1
> +		fi
>   	fi
>   	rmmod  test_bpf 2> /dev/null
>   	dmesg | grep FAIL
>

^ permalink raw reply

* Re: [PATCH v2 2/2] selftests: bpf: test_kmod.sh: use modprobe on target device
From: Daniel Borkmann @ 2017-09-07  9:20 UTC (permalink / raw)
  To: naresh.kamboju, shuahkh, linux-kselftest
  Cc: linux-kernel, davem, alexei.starovoitov, netdev
In-Reply-To: <1504772342-21878-2-git-send-email-naresh.kamboju@linaro.org>

On 09/07/2017 10:19 AM, naresh.kamboju@linaro.org wrote:
> From: Naresh Kamboju <naresh.kamboju@linaro.org>
>
> on ARM and ARM64 devices kernel source tree is not available so
> insmod "$SRC_TREE/lib/test_bpf.ko" is not working.
>
> on these target devices the test_bpf.ko is installed under
> /lib/modules/`uname -r`/kernel/lib/
> so use modprobe dry run to check for missing test_bpf.ko module and
> insert for testing.
>
> Signed-off-by: Naresh Kamboju <naresh.kamboju@linaro.org>

Acked-by: Daniel Borkmann <daniel@iogearbox.net>

One really small nit that could probably be fixed up along the
way when applying:

> ---
>   tools/testing/selftests/bpf/test_kmod.sh | 10 ++++++++++
>   1 file changed, 10 insertions(+)
>
> diff --git a/tools/testing/selftests/bpf/test_kmod.sh b/tools/testing/selftests/bpf/test_kmod.sh
> index a53eb1cb54ef..eab9a970d742 100755
> --- a/tools/testing/selftests/bpf/test_kmod.sh
> +++ b/tools/testing/selftests/bpf/test_kmod.sh
> @@ -14,6 +14,16 @@ test_run()
>   		if [ $? -ne 0 ]; then
>   			rc=1
>   		fi
> +	 else

Looks like a whitespace slipped in right before the "else",
so should be removed to only habe the tab indent.

> +		# Use modprobe dry run to check for missing test_bpf module
> +		if ! /sbin/modprobe -q -n test_bpf; then
> +			echo "test_bpf: [SKIP]"
> +		elif /sbin/modprobe -q test_bpf; then
> +			echo "test_bpf: ok"
> +		else
> +			echo "test_bpf: [FAIL]"
> +			rc=1
> +		fi
>   	fi
>   	rmmod  test_bpf 2> /dev/null
>   	dmesg | grep FAIL
>

^ permalink raw reply

* [PATCH net v4 2/3] dt-binding: net: sfp binding documentation
From: Baruch Siach @ 2017-09-07  9:25 UTC (permalink / raw)
  To: Rob Herring, Mark Rutland, Andrew Lunn, Florian Fainelli,
	David S. Miller, Russell King
  Cc: netdev-u79uwXL29TY76Z2rM5mHXA, devicetree-u79uwXL29TY76Z2rM5mHXA,
	Sergei Shtylyov, Antoine Tenart, Baruch Siach
In-Reply-To: <b98ac3e8cde5c99489e8dcee9a1d5b8a19face8d.1504776350.git.baruch-NswTu9S1W3P6gbPvEgmw2w@public.gmane.org>

Add device-tree binding documentation SFP transceivers. Support for SFP
transceivers has been recently introduced (drivers/net/phy/sfp.c).

Signed-off-by: Baruch Siach <baruch-NswTu9S1W3P6gbPvEgmw2w@public.gmane.org>
---
v4:
  Remove redundant 'single' from the gpio specifier
  Rename 'moddef0-gpios' property to 'mod-def0-gpios'
  Remove 'phy-mode' property from the example; SFP determines the mode

v3:
  Mention gpios phandle and specifier
  Mention the polarity of each gpio
  Fix example property names

v2:
  Rename -gpio properties to -gpios
  Rename the rate-select-gpio property to rate-select0-gpios
  Add the rate-select1-gpios property
  Add examples
---
 Documentation/devicetree/bindings/net/sff,sfp.txt | 76 +++++++++++++++++++++++
 1 file changed, 76 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/sff,sfp.txt

diff --git a/Documentation/devicetree/bindings/net/sff,sfp.txt b/Documentation/devicetree/bindings/net/sff,sfp.txt
new file mode 100644
index 000000000000..60e970ce10ee
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/sff,sfp.txt
@@ -0,0 +1,76 @@
+Small Form Factor (SFF) Committee Small Form-factor Pluggable (SFP)
+Transceiver
+
+Required properties:
+
+- compatible : must be "sff,sfp"
+
+Optional Properties:
+
+- i2c-bus : phandle of an I2C bus controller for the SFP two wire serial
+  interface
+
+- mod-def0-gpios : GPIO phandle and a specifier of the MOD-DEF0 (AKA Mod_ABS)
+  module presence input gpio signal, active (module absent) high
+
+- los-gpios : GPIO phandle and a specifier of the Receiver Loss of Signal
+  Indication input gpio signal, active (signal lost) high
+
+- tx-fault-gpios : GPIO phandle and a specifier of the Module Transmitter
+  Fault input gpio signal, active (fault condition) high
+
+- tx-disable-gpios : GPIO phandle and a specifier of the Transmitter Disable
+  output gpio signal, active (Tx disable) high
+
+- rate-select0-gpios : GPIO phandle and a specifier of the Rx Signaling Rate
+  Select (AKA RS0) output gpio signal, low: low Rx rate, high: high Rx rate
+
+- rate-select1-gpios : GPIO phandle and a specifier of the Tx Signaling Rate
+  Select (AKA RS1) output gpio signal (SFP+ only), low: low Tx rate, high:
+  high Tx rate
+
+Example #1: Direct serdes to SFP connection
+
+sfp_eth3: sfp-eth3 {
+	compatible = "sff,sfp";
+	i2c-bus = <&sfp_1g_i2c>;
+	los-gpios = <&cpm_gpio2 22 GPIO_ACTIVE_HIGH>;
+	mod-def0-gpios = <&cpm_gpio2 21 GPIO_ACTIVE_LOW>;
+	pinctrl-names = "default";
+	pinctrl-0 = <&cpm_sfp_1g_pins &cps_sfp_1g_pins>;
+	tx-disable-gpios = <&cps_gpio1 24 GPIO_ACTIVE_HIGH>;
+	tx-fault-gpios = <&cpm_gpio2 19 GPIO_ACTIVE_HIGH>;
+};
+
+&cps_emac3 {
+	phy-names = "comphy";
+	phys = <&cps_comphy5 0>;
+	sfp = <&sfp_eth3>;
+};
+
+Example #2: Serdes to PHY to SFP connection
+
+sfp_eth0: sfp-eth0 {
+	compatible = "sff,sfp";
+	i2c-bus = <&sfpp0_i2c>;
+	los-gpios = <&cps_gpio1 28 GPIO_ACTIVE_HIGH>;
+	mod-def0-gpios = <&cps_gpio1 27 GPIO_ACTIVE_LOW>;
+	pinctrl-names = "default";
+	pinctrl-0 = <&cps_sfpp0_pins>;
+	tx-disable-gpios = <&cps_gpio1 29 GPIO_ACTIVE_HIGH>;
+	tx-fault-gpios  = <&cps_gpio1 26 GPIO_ACTIVE_HIGH>;
+};
+
+p0_phy: ethernet-phy@0 {
+	compatible = "ethernet-phy-ieee802.3-c45";
+	pinctrl-names = "default";
+	pinctrl-0 = <&cpm_phy0_pins &cps_phy0_pins>;
+	reg = <0>;
+	interrupt = <&cpm_gpio2 18 IRQ_TYPE_EDGE_FALLING>;
+	sfp = <&sfp_eth0>;
+};
+
+&cpm_eth0 {
+	phy = <&p0_phy>;
+	phy-mode = "10gbase-kr";
+};
-- 
2.14.1

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

^ permalink raw reply related


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