Netdev List
 help / color / mirror / Atom feed
* [PATCH] net: dsa: add error handling for pskb_trim_rcsum
From: Zhouyang Jia @ 2018-06-11  5:26 UTC (permalink / raw)
  Cc: Zhouyang Jia, Andrew Lunn, Vivien Didelot, Florian Fainelli,
	David S. Miller, netdev, linux-kernel

When pskb_trim_rcsum fails, the lack of error-handling code may
cause unexpected results.

This patch adds error-handling code after calling pskb_trim_rcsum.

Signed-off-by: Zhouyang Jia <jiazhouyang09@gmail.com>
---
 net/dsa/tag_trailer.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/dsa/tag_trailer.c b/net/dsa/tag_trailer.c
index 7d20e1f..56197f0 100644
--- a/net/dsa/tag_trailer.c
+++ b/net/dsa/tag_trailer.c
@@ -75,7 +75,8 @@ static struct sk_buff *trailer_rcv(struct sk_buff *skb, struct net_device *dev,
 	if (!skb->dev)
 		return NULL;
 
-	pskb_trim_rcsum(skb, skb->len - 4);
+	if (pskb_trim_rcsum(skb, skb->len - 4))
+		return NULL;
 
 	return skb;
 }
-- 
2.7.4

^ permalink raw reply related

* Re: [PATCH 0/5] can: enable multi-queue for SocketCAN devices
From: Oleksij Rempel @ 2018-06-11  4:41 UTC (permalink / raw)
  To: Jonas Mark (BT-FIR/ENG1), Andy Shevchenko
  Cc: Wolfgang Grandegger, Marc Kleine-Budde, linux-can@vger.kernel.org,
	netdev, Linux Kernel Mailing List, Heiko Schocher,
	ZHU Yi (BT-FIR/ENG1-Zhu)
In-Reply-To: <b7f078ad43104de9bf2e7dbbe6a2a463@de.bosch.com>


[-- Attachment #1.1: Type: text/plain, Size: 2007 bytes --]

Hi,


On 07.06.2018 17:14, Jonas Mark (BT-FIR/ENG1) wrote:
> Hi Andy,
> 
>>> The functionality bases on an external peripheral chip named Companion.
>>> It offers two CAN interfaces, each has 8 prioritized transmit FIFOs as
>>> well as one receive FIFO. Besides CAN, undisclosed additional functions
>>> can be accessed through the char device.
>>>
>>> A standard SPI interface with two additional lines for flow control is
>>> used. The Companion chip is the SPI slave.
>>
>> Can remoteproc API be utilized here?
> 
> So far I wasn't aware of the remoteproc API. It appears to me that is
> limited to power on/off and loading firmware in an AMP scenario. Here,
> the Companion has a fixed firmware in it. It must already be running
> quickly after power-up, even before the boot loader.

yes, remoteproc is not quite suitable for this task.

> Does remoteproc also contain a communication framework?

it is using VirtIO

> Do you mean rpmsg? Here, I do not see how we could benefit from it.

using same message format instead of inventing new one will be really
good step:
https://github.com/OpenAMP/open-amp/wiki/RPMsg-Messaging-Protocol
(less code duplicating same functionality)

Looks like every company trying to solve the same problem over and over
again. We have point to point link between two systems. Each system has
multiple functionalities/applications so we should be able to address
this functionality. So we end to some thing with source address and
destination address. In all protocols used for inter processor/chip
communication, the difference is only the layout of 3 common fields:
source, destination and size. In many cases the ISO/OSI layer model is
badly broken and

> Can you point me to an example where rpmsg is used over SPI?

RPMsg is just transport layer, 5 or 6 wire SPI is in this case Physical
layer with flow control support. Currently i'm not sure if VirtIO with
queue support do make sense here.

> Greetings,
> Mark


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply

* Re: [PATCH net] vhost_net: remove VHOST_NET_F_VIRTIO_NET_HDR support
From: Michael S. Tsirkin @ 2018-06-11  3:08 UTC (permalink / raw)
  To: Jason Wang; +Cc: netdev, linux-kernel, kvm, virtualization
In-Reply-To: <90e9b3ea-e9d2-d60d-8355-42d447c67452@redhat.com>

On Mon, Jun 11, 2018 at 10:29:36AM +0800, Jason Wang wrote:
> 
> 
> On 2018年06月11日 10:12, Michael S. Tsirkin wrote:
> > On Fri, Jun 08, 2018 at 01:07:09PM +0800, Jason Wang wrote:
> > > 
> > > On 2018年06月08日 12:46, Michael S. Tsirkin wrote:
> > > > On Fri, Jun 08, 2018 at 11:50:42AM +0800, Jason Wang wrote:
> > > > > This feature bit is duplicated with VIRTIO_F_ANY_LAYOUT, this means if
> > > > > a userpsace want to enable VRITIO_F_ANY_LAYOUT,
> > > > > VHOST_NET_F_VIRTIO_NET_HDR will be implied too. This is wrong and will
> > > > > break networking.
> > > > What breaks networking exactly? VHOST_NET supported ANY_LAYOUT
> > > > from day one. For this reason it does not need to know about
> > > > VRITIO_F_ANY_LAYOUT and we reused the bit for other purposes.
> > > It's the knowledge of vhost_net code it self but not userspace. For
> > > userspace, it should depends on the value of returned by VHOST_GET_FEATURES.
> > > So when userspace can set_features with ANY_LAYOUT, vhost may think it wants
> > > VHOST_NET_F_VIRTIO_NET_HDR.
> > Yes but that's the admittedly ugly API that we have now.
> > userspace is supposed to know VRITIO_F_ANY_LAYOUT does
> > not make sense for vhost.
> 
> Ok.
> 
> > 
> > 
> > 
> > > > 
> > > > 
> > > > > Fixing this by safely removing
> > > > > VHOST_NET_F_VIRTIO_NET_HDR support. There should be very few or even
> > > > > no userspace can use this.
> > > > Quite possibly, but it is hard to be sure. It seems safer to
> > > > maintain it unless there's an actual reason something's broken.
> > > I think not since the feature is negotiated not mandatory?
> > That doesn't mean much.
> > 
> > > > > Further cleanups could be done for
> > > > > -net-next for safety.
> > > > > 
> > > > > In the future, we need a vhost dedicated feature set/get ioctl()
> > > > > instead of reusing virtio ones.
> > > > Not just in the future, we might want to switch iommu
> > > > to a sane structure without the 64 bit padding bug
> > > > right now.
> > > Yes, I hit this bug when introducing V2 of msg IOTLB message.
> > Sounds good, so if you like, reserve a bit for
> > VHOST_NET_F_VIRTIO_NET_HDR in the new ioctl mask and
> > do not enable it there.
> 
> Ok, and maybe VHOST_F_LOG_ALL.
> 
> > 
> > > > > Fixes: 4e9fa50c6ccbe ("vhost: move features to core")
> > > > This tag makes no sense here IMHO. Looks like people are using some tool
> > > > that just looks at the earliest version where patch won't apply. The
> > > > commit in question just moved some code around.
> > > Looks not, before this commit, vhost_net won't return ANY_LAYOUT.
> > > 
> > > Thanks
> > Well ANY_LAYOUT just happens to be same as VHOST_NET_F_VIRTIO_NET_HDR
> > and that has been set since forever.
> 
> So do you still want this patch? If not we need to document that ANY_LAYOUT
> could not be passed through SET_FEATURES somewhere.
> 
> Thanks

Let's document this, yes. I don't think we should drop
VHOST_NET_F_VIRTIO_NET_HDR now.

> > 
> > > > > Signed-off-by: Jason Wang <jasowang@redhat.com>
> > > > > ---
> > > > >    drivers/vhost/net.c | 15 +++++----------
> > > > >    1 file changed, 5 insertions(+), 10 deletions(-)
> > > > > 
> > > > > diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
> > > > > index 986058a..83eef52 100644
> > > > > --- a/drivers/vhost/net.c
> > > > > +++ b/drivers/vhost/net.c
> > > > > @@ -69,7 +69,6 @@ MODULE_PARM_DESC(experimental_zcopytx, "Enable Zero Copy TX;"
> > > > >    enum {
> > > > >    	VHOST_NET_FEATURES = VHOST_FEATURES |
> > > > > -			 (1ULL << VHOST_NET_F_VIRTIO_NET_HDR) |
> > > > >    			 (1ULL << VIRTIO_NET_F_MRG_RXBUF) |
> > > > >    			 (1ULL << VIRTIO_F_IOMMU_PLATFORM)
> > > > >    };
> > > > > @@ -1255,15 +1254,11 @@ static int vhost_net_set_features(struct vhost_net *n, u64 features)
> > > > >    			       (1ULL << VIRTIO_F_VERSION_1))) ?
> > > > >    			sizeof(struct virtio_net_hdr_mrg_rxbuf) :
> > > > >    			sizeof(struct virtio_net_hdr);
> > > > > -	if (features & (1 << VHOST_NET_F_VIRTIO_NET_HDR)) {
> > > > > -		/* vhost provides vnet_hdr */
> > > > > -		vhost_hlen = hdr_len;
> > > > > -		sock_hlen = 0;
> > > > > -	} else {
> > > > > -		/* socket provides vnet_hdr */
> > > > > -		vhost_hlen = 0;
> > > > > -		sock_hlen = hdr_len;
> > > > > -	}
> > > > > +
> > > > > +        /* socket provides vnet_hdr */
> > > > > +	vhost_hlen = 0;
> > > > > +	sock_hlen = hdr_len;
> > > > > +
> > > > >    	mutex_lock(&n->dev.mutex);
> > > > >    	if ((features & (1 << VHOST_F_LOG_ALL)) &&
> > > > >    	    !vhost_log_access_ok(&n->dev))
> > > > > -- 
> > > > > 2.7.4
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

^ permalink raw reply

* Re: [PATCH net] vhost_net: remove VHOST_NET_F_VIRTIO_NET_HDR support
From: Jason Wang @ 2018-06-11  2:29 UTC (permalink / raw)
  To: Michael S. Tsirkin; +Cc: netdev, linux-kernel, kvm, virtualization
In-Reply-To: <20180611050741-mutt-send-email-mst@kernel.org>



On 2018年06月11日 10:12, Michael S. Tsirkin wrote:
> On Fri, Jun 08, 2018 at 01:07:09PM +0800, Jason Wang wrote:
>>
>> On 2018年06月08日 12:46, Michael S. Tsirkin wrote:
>>> On Fri, Jun 08, 2018 at 11:50:42AM +0800, Jason Wang wrote:
>>>> This feature bit is duplicated with VIRTIO_F_ANY_LAYOUT, this means if
>>>> a userpsace want to enable VRITIO_F_ANY_LAYOUT,
>>>> VHOST_NET_F_VIRTIO_NET_HDR will be implied too. This is wrong and will
>>>> break networking.
>>> What breaks networking exactly? VHOST_NET supported ANY_LAYOUT
>>> from day one. For this reason it does not need to know about
>>> VRITIO_F_ANY_LAYOUT and we reused the bit for other purposes.
>> It's the knowledge of vhost_net code it self but not userspace. For
>> userspace, it should depends on the value of returned by VHOST_GET_FEATURES.
>> So when userspace can set_features with ANY_LAYOUT, vhost may think it wants
>> VHOST_NET_F_VIRTIO_NET_HDR.
> Yes but that's the admittedly ugly API that we have now.
> userspace is supposed to know VRITIO_F_ANY_LAYOUT does
> not make sense for vhost.

Ok.

>
>
>
>>>
>>>
>>>> Fixing this by safely removing
>>>> VHOST_NET_F_VIRTIO_NET_HDR support. There should be very few or even
>>>> no userspace can use this.
>>> Quite possibly, but it is hard to be sure. It seems safer to
>>> maintain it unless there's an actual reason something's broken.
>> I think not since the feature is negotiated not mandatory?
> That doesn't mean much.
>
>>>> Further cleanups could be done for
>>>> -net-next for safety.
>>>>
>>>> In the future, we need a vhost dedicated feature set/get ioctl()
>>>> instead of reusing virtio ones.
>>> Not just in the future, we might want to switch iommu
>>> to a sane structure without the 64 bit padding bug
>>> right now.
>> Yes, I hit this bug when introducing V2 of msg IOTLB message.
> Sounds good, so if you like, reserve a bit for
> VHOST_NET_F_VIRTIO_NET_HDR in the new ioctl mask and
> do not enable it there.

Ok, and maybe VHOST_F_LOG_ALL.

>
>>>> Fixes: 4e9fa50c6ccbe ("vhost: move features to core")
>>> This tag makes no sense here IMHO. Looks like people are using some tool
>>> that just looks at the earliest version where patch won't apply. The
>>> commit in question just moved some code around.
>> Looks not, before this commit, vhost_net won't return ANY_LAYOUT.
>>
>> Thanks
> Well ANY_LAYOUT just happens to be same as VHOST_NET_F_VIRTIO_NET_HDR
> and that has been set since forever.

So do you still want this patch? If not we need to document that 
ANY_LAYOUT could not be passed through SET_FEATURES somewhere.

Thanks

>
>>>> Signed-off-by: Jason Wang <jasowang@redhat.com>
>>>> ---
>>>>    drivers/vhost/net.c | 15 +++++----------
>>>>    1 file changed, 5 insertions(+), 10 deletions(-)
>>>>
>>>> diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
>>>> index 986058a..83eef52 100644
>>>> --- a/drivers/vhost/net.c
>>>> +++ b/drivers/vhost/net.c
>>>> @@ -69,7 +69,6 @@ MODULE_PARM_DESC(experimental_zcopytx, "Enable Zero Copy TX;"
>>>>    enum {
>>>>    	VHOST_NET_FEATURES = VHOST_FEATURES |
>>>> -			 (1ULL << VHOST_NET_F_VIRTIO_NET_HDR) |
>>>>    			 (1ULL << VIRTIO_NET_F_MRG_RXBUF) |
>>>>    			 (1ULL << VIRTIO_F_IOMMU_PLATFORM)
>>>>    };
>>>> @@ -1255,15 +1254,11 @@ static int vhost_net_set_features(struct vhost_net *n, u64 features)
>>>>    			       (1ULL << VIRTIO_F_VERSION_1))) ?
>>>>    			sizeof(struct virtio_net_hdr_mrg_rxbuf) :
>>>>    			sizeof(struct virtio_net_hdr);
>>>> -	if (features & (1 << VHOST_NET_F_VIRTIO_NET_HDR)) {
>>>> -		/* vhost provides vnet_hdr */
>>>> -		vhost_hlen = hdr_len;
>>>> -		sock_hlen = 0;
>>>> -	} else {
>>>> -		/* socket provides vnet_hdr */
>>>> -		vhost_hlen = 0;
>>>> -		sock_hlen = hdr_len;
>>>> -	}
>>>> +
>>>> +        /* socket provides vnet_hdr */
>>>> +	vhost_hlen = 0;
>>>> +	sock_hlen = hdr_len;
>>>> +
>>>>    	mutex_lock(&n->dev.mutex);
>>>>    	if ((features & (1 << VHOST_F_LOG_ALL)) &&
>>>>    	    !vhost_log_access_ok(&n->dev))
>>>> -- 
>>>> 2.7.4

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

^ permalink raw reply

* [iproute2-next v2 1/2] tipc: JSON support for showing nametable
From: Hoang Le @ 2018-06-11  2:16 UTC (permalink / raw)
  To: netdev, tipc-discussion

Add json output support for nametable show

Example output:
$tipc -j -p nametable show

[ {
        "type": 0,
        "lower": 16781313,
        "upper": 16781313,
        "scope": "zone",
        "port": 0,
        "node": ""
    },{
        "type": 0,
        "lower": 16781416,
        "upper": 16781416,
        "scope": "cluster",
        "port": 0,
        "node": ""
    } ]

v2:
    Replace variable 'json_flag' by 'json' declared in include/utils.h
    Add new parameter '-pretty' to support pretty output

Acked-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: Hoang Le <hoang.h.le@dektech.com.au>
---
 tipc/nametable.c | 31 ++++++++++++++++++++++---------
 tipc/tipc.c      | 20 +++++++++++++++++++-
 2 files changed, 41 insertions(+), 10 deletions(-)

diff --git a/tipc/nametable.c b/tipc/nametable.c
index ae73dfa5f8b9..eb4bd0bda835 100644
--- a/tipc/nametable.c
+++ b/tipc/nametable.c
@@ -21,6 +21,7 @@
 #include "msg.h"
 #include "nametable.h"
 #include "misc.h"
+#include "utils.h"
 
 #define PORTID_STR_LEN 45 /* Four u32 and five delimiter chars */
 
@@ -46,7 +47,7 @@ static int nametable_show_cb(const struct nlmsghdr *nlh, void *data)
 	if (!publ[TIPC_NLA_NAME_TABLE_PUBL])
 		return MNL_CB_ERROR;
 
-	if (!*iteration)
+	if (!*iteration && !is_json_context())
 		printf("%-10s %-10s %-10s %-8s %-10s %-33s\n",
 		       "Type", "Lower", "Upper", "Scope", "Port",
 		       "Node");
@@ -54,13 +55,20 @@ static int nametable_show_cb(const struct nlmsghdr *nlh, void *data)
 
 	hash2nodestr(mnl_attr_get_u32(publ[TIPC_NLA_PUBL_NODE]), str);
 
-	printf("%-10u %-10u %-10u %-8s %-10u %s\n",
-	       mnl_attr_get_u32(publ[TIPC_NLA_PUBL_TYPE]),
-	       mnl_attr_get_u32(publ[TIPC_NLA_PUBL_LOWER]),
-	       mnl_attr_get_u32(publ[TIPC_NLA_PUBL_UPPER]),
-	       scope[mnl_attr_get_u32(publ[TIPC_NLA_PUBL_SCOPE])],
-	       mnl_attr_get_u32(publ[TIPC_NLA_PUBL_REF]),
-	       str);
+	open_json_object(NULL);
+	print_uint(PRINT_ANY, "type", "%-10u",
+			   mnl_attr_get_u32(publ[TIPC_NLA_PUBL_TYPE]));
+	print_uint(PRINT_ANY, "lower", "%-10u",
+			   mnl_attr_get_u32(publ[TIPC_NLA_PUBL_LOWER]));
+	print_uint(PRINT_ANY, "upper", "%-10u",
+			   mnl_attr_get_u32(publ[TIPC_NLA_PUBL_UPPER]));
+	print_string(PRINT_ANY, "scope", "%-8s",
+			     scope[mnl_attr_get_u32(publ[TIPC_NLA_PUBL_SCOPE])]);
+	print_uint(PRINT_ANY, "port", "%-10u",
+			   mnl_attr_get_u32(publ[TIPC_NLA_PUBL_REF]));
+	print_string(PRINT_ANY, "node", "%s", str);
+	print_string(PRINT_FP, NULL, "\n", "");
+	close_json_object();
 
 	return MNL_CB_OK;
 }
@@ -70,6 +78,7 @@ static int cmd_nametable_show(struct nlmsghdr *nlh, const struct cmd *cmd,
 {
 	int iteration = 0;
 	char buf[MNL_SOCKET_BUFFER_SIZE];
+	int rc = 0;
 
 	if (help_flag) {
 		fprintf(stderr, "Usage: %s nametable show\n", cmdl->argv[0]);
@@ -81,7 +90,11 @@ static int cmd_nametable_show(struct nlmsghdr *nlh, const struct cmd *cmd,
 		return -1;
 	}
 
-	return msg_dumpit(nlh, nametable_show_cb, &iteration);
+	new_json_obj(json);
+	rc = msg_dumpit(nlh, nametable_show_cb, &iteration);
+	delete_json_obj();
+
+	return rc;
 }
 
 void cmd_nametable_help(struct cmdl *cmdl)
diff --git a/tipc/tipc.c b/tipc/tipc.c
index 600d5e2a160f..f85ddee0e278 100644
--- a/tipc/tipc.c
+++ b/tipc/tipc.c
@@ -24,6 +24,8 @@
 #include "cmdl.h"
 
 int help_flag;
+int json;
+int pretty;
 
 static void about(struct cmdl *cmdl)
 {
@@ -33,6 +35,8 @@ static void about(struct cmdl *cmdl)
 		"\n"
 		"Options:\n"
 		" -h, --help \t\tPrint help for last given command\n"
+		" -j, --json \t\tJson format printouts\n"
+		" -p, --pretty \t\tpretty print\n"
 		"\n"
 		"Commands:\n"
 		" bearer                - Show or modify bearers\n"
@@ -53,6 +57,8 @@ int main(int argc, char *argv[])
 	const struct cmd cmd = {"tipc", NULL, about};
 	struct option long_options[] = {
 		{"help", no_argument, 0, 'h'},
+		{"json", no_argument, 0, 'j'},
+		{"pretty", no_argument, 0, 'p'},
 		{0, 0, 0, 0}
 	};
 	const struct cmd cmds[] = {
@@ -69,7 +75,7 @@ int main(int argc, char *argv[])
 	do {
 		int option_index = 0;
 
-		i = getopt_long(argc, argv, "h", long_options, &option_index);
+		i = getopt_long(argc, argv, "hjp", long_options, &option_index);
 
 		switch (i) {
 		case 'h':
@@ -79,6 +85,18 @@ int main(int argc, char *argv[])
 			 */
 			help_flag = 1;
 			break;
+		case 'j':
+			/*
+			 * Enable json format printouts
+			 */
+			json = 1;
+			break;
+		case 'p':
+			/*
+			 * Enable json pretty output
+			 */
+			pretty = 1;
+			break;
 		case -1:
 			/* End of options */
 			break;
-- 
2.7.4

^ permalink raw reply related

* [iproute2-next v2 2/2] tipc: JSON support for tipc link printouts
From: Hoang Le @ 2018-06-11  2:17 UTC (permalink / raw)
  To: netdev, tipc-discussion
In-Reply-To: <1528683420-15006-1-git-send-email-hoang.h.le@dektech.com.au>

Add json output support for tipc link command

Example output:
$tipc -j -p link list

[ {
        "broadcast-link": "up",
        "1.1.1:bridge-1.1.104:eth0": "up",
        "1.1.1:bridge-1.1.105:eth0": "up",
        "1.1.1:bridge-1.1.106:eth0": "up"
    } ]

--------------------
$tipc -j -p link stat show link broadcast-link

[ {
        "link": "broadcast-link",
        "window": 50,
        "rx packets": {
            "rx packets": 0,
            "fragments": 0,
            "fragmented": 0,
            "bundles": 0,
            "bundled": 0
        },
        "tx packets": {
            "tx packets": 0,
            "fragments": 0,
            "fragmented": 0,
            "bundles": 0,
            "bundled": 0
        },
        "rx naks": {
            "rx naks": 0,
            "defs": 0,
            "dups": 0
        },
        "tx naks": {
            "tx naks": 0,
            "acks": 0,
            "retrans": 0
        },
        "congestion link": 0,
        "send queue max": 0,
        "avg": 0
    } ]

v2:
    Replace variable 'json_flag' by 'json' declared in include/utils.h

Acked-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: Hoang Le <hoang.h.le@dektech.com.au>
---
 tipc/link.c | 414 +++++++++++++++++++++++++++++++++++++++---------------------
 1 file changed, 272 insertions(+), 142 deletions(-)

diff --git a/tipc/link.c b/tipc/link.c
index 02f14aadefa6..26d1293f121a 100644
--- a/tipc/link.c
+++ b/tipc/link.c
@@ -23,6 +23,11 @@
 #include "msg.h"
 #include "link.h"
 #include "bearer.h"
+#include "utils.h"
+
+#define PRIORITY_STR "priority"
+#define TOLERANCE_STR "tolerance"
+#define WINDOW_STR "window"
 
 static int link_list_cb(const struct nlmsghdr *nlh, void *data)
 {
@@ -38,13 +43,14 @@ static int link_list_cb(const struct nlmsghdr *nlh, void *data)
 	if (!attrs[TIPC_NLA_LINK_NAME])
 		return MNL_CB_ERROR;
 
-	printf("%s: ", mnl_attr_get_str(attrs[TIPC_NLA_LINK_NAME]));
-
+	print_string(PRINT_FP, NULL, "%s: ",
+			     mnl_attr_get_str(attrs[TIPC_NLA_LINK_NAME]));
 	if (attrs[TIPC_NLA_LINK_UP])
-		printf("up\n");
+		print_string(PRINT_ANY,
+			 mnl_attr_get_str(attrs[TIPC_NLA_LINK_NAME]),"%s\n", "up");
 	else
-		printf("down\n");
-
+		print_string(PRINT_ANY,
+			 mnl_attr_get_str(attrs[TIPC_NLA_LINK_NAME]), "%s\n", "down");
 	return MNL_CB_OK;
 }
 
@@ -52,6 +58,7 @@ static int cmd_link_list(struct nlmsghdr *nlh, const struct cmd *cmd,
 			 struct cmdl *cmdl, void *data)
 {
 	char buf[MNL_SOCKET_BUFFER_SIZE];
+	int err = 0;
 
 	if (help_flag) {
 		fprintf(stderr, "Usage: %s link list\n", cmdl->argv[0]);
@@ -64,7 +71,12 @@ static int cmd_link_list(struct nlmsghdr *nlh, const struct cmd *cmd,
 		return -1;
 	}
 
-	return msg_dumpit(nlh, link_list_cb, NULL);
+	new_json_obj(json);
+	open_json_object(NULL);
+	err = msg_dumpit(nlh, link_list_cb, NULL);
+	close_json_object();
+	delete_json_obj();
+	return err;
 }
 
 static int link_get_cb(const struct nlmsghdr *nlh, void *data)
@@ -87,8 +99,23 @@ static int link_get_cb(const struct nlmsghdr *nlh, void *data)
 	if (!props[*prop])
 		return MNL_CB_ERROR;
 
-	printf("%u\n", mnl_attr_get_u32(props[*prop]));
-
+	new_json_obj(json);
+	open_json_object(NULL);
+	switch (*prop) {
+		case TIPC_NLA_PROP_PRIO:
+			print_uint(PRINT_ANY, PRIORITY_STR, "%u\n", mnl_attr_get_u32(props[*prop]));
+		break;
+		case TIPC_NLA_PROP_TOL:
+			print_uint(PRINT_ANY, TOLERANCE_STR, "%u\n", mnl_attr_get_u32(props[*prop]));
+		break;
+		case TIPC_NLA_PROP_WIN:
+			print_uint(PRINT_ANY, WINDOW_STR, "%u\n", mnl_attr_get_u32(props[*prop]));
+		break;
+		default:
+			break;
+	}
+	close_json_object();
+	delete_json_obj();
 	return MNL_CB_OK;
 }
 
@@ -103,11 +130,11 @@ static int cmd_link_get_prop(struct nlmsghdr *nlh, const struct cmd *cmd,
 		{ NULL }
 	};
 
-	if (strcmp(cmd->cmd, "priority") == 0)
+	if (strcmp(cmd->cmd, PRIORITY_STR) == 0)
 		prop = TIPC_NLA_PROP_PRIO;
-	else if ((strcmp(cmd->cmd, "tolerance") == 0))
+	else if ((strcmp(cmd->cmd, TOLERANCE_STR) == 0))
 		prop = TIPC_NLA_PROP_TOL;
-	else if ((strcmp(cmd->cmd, "window") == 0))
+	else if ((strcmp(cmd->cmd, WINDOW_STR) == 0))
 		prop = TIPC_NLA_PROP_WIN;
 	else
 		return -EINVAL;
@@ -150,9 +177,9 @@ static int cmd_link_get(struct nlmsghdr *nlh, const struct cmd *cmd,
 			struct cmdl *cmdl, void *data)
 {
 	const struct cmd cmds[] = {
-		{ "priority",	cmd_link_get_prop,	cmd_link_get_help },
-		{ "tolerance",	cmd_link_get_prop,	cmd_link_get_help },
-		{ "window",	cmd_link_get_prop,	cmd_link_get_help },
+		{ PRIORITY_STR,	cmd_link_get_prop,	cmd_link_get_help },
+		{ TOLERANCE_STR,	cmd_link_get_prop,	cmd_link_get_help },
+		{ WINDOW_STR,	cmd_link_get_prop,	cmd_link_get_help },
 		{ NULL }
 	};
 
@@ -211,109 +238,178 @@ static uint32_t perc(uint32_t count, uint32_t total)
 	return (count * 100 + (total / 2)) / total;
 }
 
-static int _show_link_stat(struct nlattr *attrs[], struct nlattr *prop[],
-			   struct nlattr *stats[])
+static int _show_link_stat(const char *name, struct nlattr *attrs[],
+			   struct nlattr *prop[], struct nlattr *stats[])
 {
 	uint32_t proft;
 
+	open_json_object(NULL);
+
+	print_string(PRINT_ANY, "link", "\nLink <%s>\n", name);
+	print_string(PRINT_JSON, "state", "", NULL);
+	open_json_array(PRINT_JSON, NULL);
 	if (attrs[TIPC_NLA_LINK_ACTIVE])
-		printf("  ACTIVE");
+		print_string(PRINT_ANY, NULL, "  %s", "ACTIVE");
 	else if (attrs[TIPC_NLA_LINK_UP])
-		printf("  STANDBY");
+		print_string(PRINT_ANY, NULL, "  %s", "STANDBY");
 	else
-		printf("  DEFUNCT");
-
-	printf("  MTU:%u  Priority:%u  Tolerance:%u ms  Window:%u packets\n",
-	       mnl_attr_get_u32(attrs[TIPC_NLA_LINK_MTU]),
-	       mnl_attr_get_u32(prop[TIPC_NLA_PROP_PRIO]),
-	       mnl_attr_get_u32(prop[TIPC_NLA_PROP_TOL]),
-	       mnl_attr_get_u32(prop[TIPC_NLA_PROP_WIN]));
-
-	printf("  RX packets:%u fragments:%u/%u bundles:%u/%u\n",
-	       mnl_attr_get_u32(attrs[TIPC_NLA_LINK_RX]) -
-	       mnl_attr_get_u32(stats[TIPC_NLA_STATS_RX_INFO]),
-	       mnl_attr_get_u32(stats[TIPC_NLA_STATS_RX_FRAGMENTS]),
-	       mnl_attr_get_u32(stats[TIPC_NLA_STATS_RX_FRAGMENTED]),
-	       mnl_attr_get_u32(stats[TIPC_NLA_STATS_RX_BUNDLES]),
-	       mnl_attr_get_u32(stats[TIPC_NLA_STATS_RX_BUNDLED]));
-
-	printf("  TX packets:%u fragments:%u/%u bundles:%u/%u\n",
-	       mnl_attr_get_u32(attrs[TIPC_NLA_LINK_TX]) -
-	       mnl_attr_get_u32(stats[TIPC_NLA_STATS_TX_INFO]),
-	       mnl_attr_get_u32(stats[TIPC_NLA_STATS_TX_FRAGMENTS]),
-	       mnl_attr_get_u32(stats[TIPC_NLA_STATS_TX_FRAGMENTED]),
-	       mnl_attr_get_u32(stats[TIPC_NLA_STATS_TX_BUNDLES]),
-	       mnl_attr_get_u32(stats[TIPC_NLA_STATS_TX_BUNDLED]));
+		print_string(PRINT_ANY, NULL, "  %s", "DEFUNCT");
+	close_json_array(PRINT_JSON, NULL);
+
+	print_uint(PRINT_ANY, "mtu", "  MTU:%u",
+			   mnl_attr_get_u32(attrs[TIPC_NLA_LINK_MTU]));
+	print_uint(PRINT_ANY, PRIORITY_STR, "  Priority:%u",
+			   mnl_attr_get_u32(prop[TIPC_NLA_PROP_PRIO]));
+	print_uint(PRINT_ANY, TOLERANCE_STR, "  Tolerance:%u ms",
+			   mnl_attr_get_u32(prop[TIPC_NLA_PROP_TOL]));
+	print_uint(PRINT_ANY, WINDOW_STR, "  Window:%u packets\n",
+			   mnl_attr_get_u32(prop[TIPC_NLA_PROP_WIN]));
+
+	open_json_object("rx packets");
+	print_uint(PRINT_ANY, "rx packets", "  RX packets:%u",
+			   mnl_attr_get_u32(attrs[TIPC_NLA_LINK_RX]) -
+			   mnl_attr_get_u32(stats[TIPC_NLA_STATS_RX_INFO]));
+	print_uint(PRINT_ANY, "fragments", " fragments:%u",
+			   mnl_attr_get_u32(stats[TIPC_NLA_STATS_RX_FRAGMENTS]));
+	print_uint(PRINT_ANY, "fragmented", "/%u",
+			   mnl_attr_get_u32(stats[TIPC_NLA_STATS_RX_FRAGMENTED]));
+	print_uint(PRINT_ANY, "bundles", " bundles:%u",
+			   mnl_attr_get_u32(stats[TIPC_NLA_STATS_RX_BUNDLES]));
+	print_uint(PRINT_ANY, "bundled", "/%u\n",
+			   mnl_attr_get_u32(stats[TIPC_NLA_STATS_RX_BUNDLED]));
+	close_json_object();
+
+	open_json_object("tx packets");
+	print_uint(PRINT_ANY, "tx packets", "  TX packets:%u",
+			   mnl_attr_get_u32(attrs[TIPC_NLA_LINK_TX]) -
+			   mnl_attr_get_u32(stats[TIPC_NLA_STATS_TX_INFO]));
+	print_uint(PRINT_ANY, "fragments", " fragments:%u",
+			   mnl_attr_get_u32(stats[TIPC_NLA_STATS_TX_FRAGMENTS]));
+	print_uint(PRINT_ANY, "fragmented", "/%u",
+			   mnl_attr_get_u32(stats[TIPC_NLA_STATS_TX_FRAGMENTED]));
+	print_uint(PRINT_ANY, "bundles", " bundles:%u",
+			   mnl_attr_get_u32(stats[TIPC_NLA_STATS_TX_BUNDLES]));
+	print_uint(PRINT_ANY, "bundled", "/%u\n",
+			   mnl_attr_get_u32(stats[TIPC_NLA_STATS_TX_BUNDLED]));
+	close_json_object();
 
 	proft = mnl_attr_get_u32(stats[TIPC_NLA_STATS_MSG_PROF_TOT]);
-	printf("  TX profile sample:%u packets  average:%u octets\n",
-	       mnl_attr_get_u32(stats[TIPC_NLA_STATS_MSG_LEN_CNT]),
-	       mnl_attr_get_u32(stats[TIPC_NLA_STATS_MSG_LEN_TOT]) / proft);
-
-	printf("  0-64:%u%% -256:%u%% -1024:%u%% -4096:%u%% -16384:%u%% -32768:%u%% -66000:%u%%\n",
-	       perc(mnl_attr_get_u32(stats[TIPC_NLA_STATS_MSG_LEN_P0]), proft),
-	       perc(mnl_attr_get_u32(stats[TIPC_NLA_STATS_MSG_LEN_P1]), proft),
-	       perc(mnl_attr_get_u32(stats[TIPC_NLA_STATS_MSG_LEN_P2]), proft),
-	       perc(mnl_attr_get_u32(stats[TIPC_NLA_STATS_MSG_LEN_P3]), proft),
-	       perc(mnl_attr_get_u32(stats[TIPC_NLA_STATS_MSG_LEN_P4]), proft),
-	       perc(mnl_attr_get_u32(stats[TIPC_NLA_STATS_MSG_LEN_P5]), proft),
-	       perc(mnl_attr_get_u32(stats[TIPC_NLA_STATS_MSG_LEN_P6]), proft));
-
-	printf("  RX states:%u probes:%u naks:%u defs:%u dups:%u\n",
-	       mnl_attr_get_u32(stats[TIPC_NLA_STATS_RX_STATES]),
-	       mnl_attr_get_u32(stats[TIPC_NLA_STATS_RX_PROBES]),
-	       mnl_attr_get_u32(stats[TIPC_NLA_STATS_RX_NACKS]),
-	       mnl_attr_get_u32(stats[TIPC_NLA_STATS_RX_DEFERRED]),
-	       mnl_attr_get_u32(stats[TIPC_NLA_STATS_DUPLICATES]));
-
-	printf("  TX states:%u probes:%u naks:%u acks:%u dups:%u\n",
-	       mnl_attr_get_u32(stats[TIPC_NLA_STATS_TX_STATES]),
-	       mnl_attr_get_u32(stats[TIPC_NLA_STATS_TX_PROBES]),
-	       mnl_attr_get_u32(stats[TIPC_NLA_STATS_TX_NACKS]),
-	       mnl_attr_get_u32(stats[TIPC_NLA_STATS_TX_ACKS]),
-	       mnl_attr_get_u32(stats[TIPC_NLA_STATS_RETRANSMITTED]));
-
-	printf("  Congestion link:%u  Send queue max:%u avg:%u\n",
-	       mnl_attr_get_u32(stats[TIPC_NLA_STATS_LINK_CONGS]),
-	       mnl_attr_get_u32(stats[TIPC_NLA_STATS_MAX_QUEUE]),
-	       mnl_attr_get_u32(stats[TIPC_NLA_STATS_AVG_QUEUE]));
-
+	print_uint(PRINT_ANY, "tx profile sample", "  TX profile sample:%u",
+			   mnl_attr_get_u32(stats[TIPC_NLA_STATS_MSG_LEN_CNT]));
+	print_uint(PRINT_ANY, "packets average", " packets average:%u octets\n",
+			   mnl_attr_get_u32(stats[TIPC_NLA_STATS_MSG_LEN_TOT]) / proft);
+
+	print_uint(PRINT_ANY, "0-64", "  0-64:%u%%",
+			   perc(mnl_attr_get_u32(stats[TIPC_NLA_STATS_MSG_LEN_P0]), proft));
+	print_uint(PRINT_ANY, "-256", " -256:%u%%",
+			   perc(mnl_attr_get_u32(stats[TIPC_NLA_STATS_MSG_LEN_P1]), proft));
+	print_uint(PRINT_ANY, "-1024", " -1024:%u%%",
+			   perc(mnl_attr_get_u32(stats[TIPC_NLA_STATS_MSG_LEN_P2]), proft));
+	print_uint(PRINT_ANY, "-4096", " -4096:%u%%",
+			   perc(mnl_attr_get_u32(stats[TIPC_NLA_STATS_MSG_LEN_P3]), proft));
+	print_uint(PRINT_ANY, "-16384", " -16384:%u%%",
+			   perc(mnl_attr_get_u32(stats[TIPC_NLA_STATS_MSG_LEN_P4]), proft));
+	print_uint(PRINT_ANY, "-32768", " -32768:%u%%",
+			   perc(mnl_attr_get_u32(stats[TIPC_NLA_STATS_MSG_LEN_P5]), proft));
+	print_uint(PRINT_ANY, "-66000", " -66000:%u%%\n",
+			   perc(mnl_attr_get_u32(stats[TIPC_NLA_STATS_MSG_LEN_P6]), proft));
+
+	open_json_object("rx states");
+	print_uint(PRINT_ANY, "rx states", "  RX states:%u",
+			   mnl_attr_get_u32(stats[TIPC_NLA_STATS_RX_STATES]));
+	print_uint(PRINT_ANY, "probes", " probes:%u",
+			   mnl_attr_get_u32(stats[TIPC_NLA_STATS_RX_PROBES]));
+	print_uint(PRINT_ANY, "naks", " naks:%u",
+			   mnl_attr_get_u32(stats[TIPC_NLA_STATS_RX_NACKS]));
+	print_uint(PRINT_ANY, "defs", " defs:%u",
+			   mnl_attr_get_u32(stats[TIPC_NLA_STATS_RX_DEFERRED]));
+	print_uint(PRINT_ANY, "dups", " dups:%u\n",
+			   mnl_attr_get_u32(stats[TIPC_NLA_STATS_DUPLICATES]));
+	close_json_object();
+
+	open_json_object("tx states");
+	print_uint(PRINT_ANY, "tx states", "  TX states:%u",
+			   mnl_attr_get_u32(stats[TIPC_NLA_STATS_TX_STATES]));
+	print_uint(PRINT_ANY, "probes", " probes:%u",
+			   mnl_attr_get_u32(stats[TIPC_NLA_STATS_TX_PROBES]));
+	print_uint(PRINT_ANY, "naks", " naks:%u",
+			   mnl_attr_get_u32(stats[TIPC_NLA_STATS_TX_NACKS]));
+	print_uint(PRINT_ANY, "acks", " acks:%u",
+			   mnl_attr_get_u32(stats[TIPC_NLA_STATS_TX_ACKS]));
+	print_uint(PRINT_ANY, "retrans", " retrans:%u\n",
+			   mnl_attr_get_u32(stats[TIPC_NLA_STATS_RETRANSMITTED]));
+	close_json_object();
+
+	print_uint(PRINT_ANY, "congestion link", "  Congestion link:%u",
+			   mnl_attr_get_u32(stats[TIPC_NLA_STATS_LINK_CONGS]));
+	print_uint(PRINT_ANY, "send queue max", "  Send queue max:%u",
+			   mnl_attr_get_u32(stats[TIPC_NLA_STATS_MAX_QUEUE]));
+	print_uint(PRINT_ANY, "avg", " avg:%u\n",
+			   mnl_attr_get_u32(stats[TIPC_NLA_STATS_AVG_QUEUE]));
+
+	close_json_object();
 	return MNL_CB_OK;
 }
 
-static int _show_bc_link_stat(struct nlattr *prop[], struct nlattr *stats[])
+static int _show_bc_link_stat(const char *name, struct nlattr *prop[],
+			   struct nlattr *stats[])
 {
-	printf("  Window:%u packets\n",
-	       mnl_attr_get_u32(prop[TIPC_NLA_PROP_WIN]));
-
-	printf("  RX packets:%u fragments:%u/%u bundles:%u/%u\n",
-	       mnl_attr_get_u32(stats[TIPC_NLA_STATS_RX_INFO]),
-	       mnl_attr_get_u32(stats[TIPC_NLA_STATS_RX_FRAGMENTS]),
-	       mnl_attr_get_u32(stats[TIPC_NLA_STATS_RX_FRAGMENTED]),
-	       mnl_attr_get_u32(stats[TIPC_NLA_STATS_RX_BUNDLES]),
-	       mnl_attr_get_u32(stats[TIPC_NLA_STATS_RX_BUNDLED]));
-
-	printf("  TX packets:%u fragments:%u/%u bundles:%u/%u\n",
-	       mnl_attr_get_u32(stats[TIPC_NLA_STATS_TX_INFO]),
-	       mnl_attr_get_u32(stats[TIPC_NLA_STATS_TX_FRAGMENTS]),
-	       mnl_attr_get_u32(stats[TIPC_NLA_STATS_TX_FRAGMENTED]),
-	       mnl_attr_get_u32(stats[TIPC_NLA_STATS_TX_BUNDLES]),
-	       mnl_attr_get_u32(stats[TIPC_NLA_STATS_TX_BUNDLED]));
-
-	printf("  RX naks:%u defs:%u dups:%u\n",
-	       mnl_attr_get_u32(stats[TIPC_NLA_STATS_RX_NACKS]),
-	       mnl_attr_get_u32(stats[TIPC_NLA_STATS_RX_DEFERRED]),
-	       mnl_attr_get_u32(stats[TIPC_NLA_STATS_DUPLICATES]));
-
-	printf("  TX naks:%u acks:%u dups:%u\n",
-	       mnl_attr_get_u32(stats[TIPC_NLA_STATS_TX_NACKS]),
-	       mnl_attr_get_u32(stats[TIPC_NLA_STATS_TX_ACKS]),
-	       mnl_attr_get_u32(stats[TIPC_NLA_STATS_RETRANSMITTED]));
-
-	printf("  Congestion link:%u  Send queue max:%u avg:%u\n",
-	       mnl_attr_get_u32(stats[TIPC_NLA_STATS_LINK_CONGS]),
-	       mnl_attr_get_u32(stats[TIPC_NLA_STATS_MAX_QUEUE]),
-	       mnl_attr_get_u32(stats[TIPC_NLA_STATS_AVG_QUEUE]));
+	open_json_object(NULL);
+	print_string(PRINT_ANY, "link", "Link <%s>\n", name);
+	print_uint(PRINT_ANY, WINDOW_STR, "  Window:%u packets\n",
+			   mnl_attr_get_u32(prop[TIPC_NLA_PROP_WIN]));
+
+	open_json_object("rx packets");
+	print_uint(PRINT_ANY, "rx packets", "  RX packets:%u",
+			   mnl_attr_get_u32(stats[TIPC_NLA_STATS_RX_INFO]));
+	print_uint(PRINT_ANY, "fragments", " fragments:%u",
+			   mnl_attr_get_u32(stats[TIPC_NLA_STATS_RX_FRAGMENTS]));
+	print_uint(PRINT_ANY, "fragmented", "/%u",
+			   mnl_attr_get_u32(stats[TIPC_NLA_STATS_RX_FRAGMENTED]));
+	print_uint(PRINT_ANY, "bundles", " bundles:%u",
+			   mnl_attr_get_u32(stats[TIPC_NLA_STATS_RX_BUNDLES]));
+	print_uint(PRINT_ANY, "bundled", "/%u\n",
+			   mnl_attr_get_u32(stats[TIPC_NLA_STATS_RX_BUNDLED]));
+	close_json_object();
+
+	open_json_object("tx packets");
+	print_uint(PRINT_ANY, "tx packets", "  TX packets:%u",
+			   mnl_attr_get_u32(stats[TIPC_NLA_STATS_TX_INFO]));
+	print_uint(PRINT_ANY, "fragments", " fragments:%u",
+			   mnl_attr_get_u32(stats[TIPC_NLA_STATS_TX_FRAGMENTS]));
+	print_uint(PRINT_ANY, "fragmented", "/%u",
+			   mnl_attr_get_u32(stats[TIPC_NLA_STATS_TX_FRAGMENTED]));
+	print_uint(PRINT_ANY, "bundles", " bundles:%u",
+			   mnl_attr_get_u32(stats[TIPC_NLA_STATS_TX_BUNDLES]));
+	print_uint(PRINT_ANY, "bundled", "/%u\n",
+			   mnl_attr_get_u32(stats[TIPC_NLA_STATS_TX_BUNDLED]));
+	close_json_object();
+
+	open_json_object("rx naks");
+	print_uint(PRINT_ANY, "rx naks", "  RX naks:%u",
+			   mnl_attr_get_u32(stats[TIPC_NLA_STATS_RX_NACKS]));
+	print_uint(PRINT_ANY, "defs",  " defs:%u",
+			   mnl_attr_get_u32(stats[TIPC_NLA_STATS_RX_DEFERRED]));
+	print_uint(PRINT_ANY, "dups",  " dups:%u\n",
+		   mnl_attr_get_u32(stats[TIPC_NLA_STATS_DUPLICATES]));
+	close_json_object();
+
+	open_json_object("tx naks");
+	print_uint(PRINT_ANY, "tx naks", "  TX naks:%u",
+			   mnl_attr_get_u32(stats[TIPC_NLA_STATS_TX_NACKS]));
+	print_uint(PRINT_ANY, "acks",  " acks:%u",
+			   mnl_attr_get_u32(stats[TIPC_NLA_STATS_TX_ACKS]));
+	print_uint(PRINT_ANY, "retrans",  " retrans:%u\n",
+		   mnl_attr_get_u32(stats[TIPC_NLA_STATS_RETRANSMITTED]));
+	close_json_object();
+
+	print_uint(PRINT_ANY, "congestion link", "  Congestion link:%u",
+			   mnl_attr_get_u32(stats[TIPC_NLA_STATS_LINK_CONGS]));
+	print_uint(PRINT_ANY, "send queue max", "  Send queue max:%u",
+			   mnl_attr_get_u32(stats[TIPC_NLA_STATS_MAX_QUEUE]));
+	print_uint(PRINT_ANY, "avg", " avg:%u\n",
+			   mnl_attr_get_u32(stats[TIPC_NLA_STATS_AVG_QUEUE]));
+	close_json_object();
 
 	return MNL_CB_OK;
 }
@@ -347,13 +443,10 @@ static int link_stat_show_cb(const struct nlmsghdr *nlh, void *data)
 		return MNL_CB_OK;
 
 	if (attrs[TIPC_NLA_LINK_BROADCAST]) {
-		printf("Link <%s>\n", name);
-		return _show_bc_link_stat(prop, stats);
+		return _show_bc_link_stat(name, prop, stats);
 	}
 
-	printf("\nLink <%s>\n", name);
-
-	return _show_link_stat(attrs, prop, stats);
+	return _show_link_stat(name, attrs, prop, stats);
 }
 
 static void cmd_link_stat_show_help(struct cmdl *cmdl)
@@ -372,6 +465,7 @@ static int cmd_link_stat_show(struct nlmsghdr *nlh, const struct cmd *cmd,
 		{ "link",		OPT_KEYVAL,	NULL },
 		{ NULL }
 	};
+	int err = 0;
 
 	if (help_flag) {
 		(cmd->help)(cmdl);
@@ -391,7 +485,10 @@ static int cmd_link_stat_show(struct nlmsghdr *nlh, const struct cmd *cmd,
 	if (opt)
 		link = opt->val;
 
-	return msg_dumpit(nlh, link_stat_show_cb, link);
+	new_json_obj(json);
+	err = msg_dumpit(nlh, link_stat_show_cb, link);
+	delete_json_obj();
+	return err;
 }
 
 static void cmd_link_stat_help(struct cmdl *cmdl)
@@ -439,11 +536,11 @@ static int cmd_link_set_prop(struct nlmsghdr *nlh, const struct cmd *cmd,
 		{ NULL }
 	};
 
-	if (strcmp(cmd->cmd, "priority") == 0)
+	if (strcmp(cmd->cmd, PRIORITY_STR) == 0)
 		prop = TIPC_NLA_PROP_PRIO;
-	else if ((strcmp(cmd->cmd, "tolerance") == 0))
+	else if ((strcmp(cmd->cmd, TOLERANCE_STR) == 0))
 		prop = TIPC_NLA_PROP_TOL;
-	else if ((strcmp(cmd->cmd, "window") == 0))
+	else if ((strcmp(cmd->cmd, WINDOW_STR) == 0))
 		prop = TIPC_NLA_PROP_WIN;
 	else
 		return -EINVAL;
@@ -489,9 +586,9 @@ static int cmd_link_set(struct nlmsghdr *nlh, const struct cmd *cmd,
 			struct cmdl *cmdl, void *data)
 {
 	const struct cmd cmds[] = {
-		{ "priority",	cmd_link_set_prop,	cmd_link_set_help },
-		{ "tolerance",	cmd_link_set_prop,	cmd_link_set_help },
-		{ "window",	cmd_link_set_prop,	cmd_link_set_help },
+		{ PRIORITY_STR,	cmd_link_set_prop,	cmd_link_set_help },
+		{ TOLERANCE_STR,	cmd_link_set_prop,	cmd_link_set_help },
+		{ WINDOW_STR,	cmd_link_set_prop,	cmd_link_set_help },
 		{ NULL }
 	};
 
@@ -537,15 +634,17 @@ static int link_mon_summary_cb(const struct nlmsghdr *nlh, void *data)
 
 	mnl_attr_parse_nested(info[TIPC_NLA_MON], parse_attrs, attrs);
 
-	printf("\nbearer %s\n",
+	open_json_object(NULL);
+	print_string(PRINT_ANY, "bearer", "\nbearer %s\n",
 		mnl_attr_get_str(attrs[TIPC_NLA_MON_BEARER_NAME]));
 
-	printf("    table_generation %u\n",
+	print_uint(PRINT_ANY, "table_generation", "    table_generation %u\n",
 	       mnl_attr_get_u32(attrs[TIPC_NLA_MON_LISTGEN]));
-	printf("    cluster_size %u\n",
+	print_uint(PRINT_ANY, "cluster_size", "    cluster_size %u\n",
 		mnl_attr_get_u32(attrs[TIPC_NLA_MON_PEERCNT]));
-	printf("    algorithm %s\n",
+	print_string(PRINT_ANY, "algorithm", "    algorithm %s\n",
 		attrs[TIPC_NLA_MON_ACTIVE] ? "overlapping-ring" : "full-mesh");
+	close_json_object();
 
 	return MNL_CB_OK;
 }
@@ -554,6 +653,7 @@ static int cmd_link_mon_summary(struct nlmsghdr *nlh, const struct cmd *cmd,
 				struct cmdl *cmdl, void *data)
 {
 	char buf[MNL_SOCKET_BUFFER_SIZE];
+	int err = 0;
 
 	if (help_flag) {
 		fprintf(stderr,	"Usage: %s monitor summary\n", cmdl->argv[0]);
@@ -566,7 +666,11 @@ static int cmd_link_mon_summary(struct nlmsghdr *nlh, const struct cmd *cmd,
 		return -1;
 	}
 
-	return msg_dumpit(nlh, link_mon_summary_cb, NULL);
+	new_json_obj(json);
+	err = msg_dumpit(nlh, link_mon_summary_cb, NULL);
+	delete_json_obj();
+
+	return err;
 }
 
 #define STATUS_WIDTH 7
@@ -587,16 +691,19 @@ static int map_get(uint64_t up_map, int i)
 static void link_mon_print_applied(uint16_t applied, uint64_t up_map)
 {
 	int i;
-	char state;
 
+	open_json_array(PRINT_JSON, "applied_node_status");
 	for (i = 0; i < applied; i++) {
+		char state_str[2] = {0};
+
 		/* print the delimiter for every -n- entry */
 		if (i && !(i % APPL_NODE_STATUS_WIDTH))
-			printf(",");
+			print_string(PRINT_FP, NULL, "%s", ",");
 
-		state = map_get(up_map, i) ? 'U' : 'D';
-		printf("%c", state);
+		sprintf(state_str, "%c", map_get(up_map, i) ? 'U' : 'D');
+		print_string(PRINT_ANY, NULL, "%s", state_str);
 	}
+	close_json_array(PRINT_JSON, "applied_node_status");
 }
 
 /* print the non applied members, since we dont know
@@ -608,19 +715,23 @@ static void link_mon_print_non_applied(uint16_t applied, uint16_t member_cnt,
 	int i;
 	char state;
 
-	printf(" [");
+	open_json_array(PRINT_JSON, "[non_applied_node:status]");
+	print_string(PRINT_FP, NULL, " %s", "[");
 	for (i = applied; i < member_cnt; i++) {
 		char addr_str[16];
+		char full_state[17] = {0};
 
 		/* print the delimiter for every entry */
 		if (i != applied)
-			printf(",");
+			print_string(PRINT_FP, NULL, "%s", ",");
 
 		sprintf(addr_str, "%x:", members[i]);
 		state = map_get(up_map, i) ? 'U' : 'D';
-		printf("%s%c", addr_str, state);
+		sprintf(full_state, "%s%c", addr_str, state);
+		print_string(PRINT_ANY, NULL, "%s", full_state);
 	}
-	printf("]");
+	print_string(PRINT_FP, NULL, "%s", "]");
+	close_json_array(PRINT_JSON, "[non_applied_node:status]");
 }
 
 static void link_mon_print_peer_state(const uint32_t addr, const char *status,
@@ -631,11 +742,17 @@ static void link_mon_print_peer_state(const uint32_t addr, const char *status,
 
 	sprintf(addr_str, "%u.%u.%u", tipc_zone(addr), tipc_cluster(addr),
 		tipc_node(addr));
-
-	printf("%-*s", MAX_NODE_WIDTH, addr_str);
-	printf("%-*s", STATUS_WIDTH, status);
-	printf("%-*s", DIRECTLY_MON_WIDTH, monitored);
-	printf("%-*u", MAX_DOM_GEN_WIDTH, dom_gen);
+	if (is_json_context()) {
+		print_string(PRINT_JSON, "node", NULL, addr_str);
+		print_string(PRINT_JSON, "status", NULL, status);
+		print_string(PRINT_JSON, "monitored", NULL, monitored);
+		print_uint(PRINT_JSON, "generation", NULL, dom_gen);
+	} else {
+		printf("%-*s", MAX_NODE_WIDTH, addr_str);
+		printf("%-*s", STATUS_WIDTH, status);
+		printf("%-*s", DIRECTLY_MON_WIDTH, monitored);
+		printf("%-*u", MAX_DOM_GEN_WIDTH, dom_gen);
+	}
 }
 
 static int link_mon_peer_list_cb(const struct nlmsghdr *nlh, void *data)
@@ -654,6 +771,7 @@ static int link_mon_peer_list_cb(const struct nlmsghdr *nlh, void *data)
 	if (!info[TIPC_NLA_MON_PEER])
 		return MNL_CB_ERROR;
 
+	open_json_object(NULL);
 	mnl_attr_parse_nested(info[TIPC_NLA_MON_PEER], parse_attrs, attrs);
 
 	(attrs[TIPC_NLA_MON_PEER_LOCAL] || attrs[TIPC_NLA_MON_PEER_HEAD]) ?
@@ -688,8 +806,9 @@ static int link_mon_peer_list_cb(const struct nlmsghdr *nlh, void *data)
 				   mnl_attr_get_payload(attrs[TIPC_NLA_MON_PEER_MEMBERS]));
 
 exit:
-	printf("\n");
+	print_string(PRINT_FP, NULL, "\n", "");
 
+	close_json_object();
 	return MNL_CB_OK;
 }
 
@@ -698,6 +817,7 @@ static int link_mon_peer_list(uint32_t mon_ref)
 	struct nlmsghdr *nlh;
 	char buf[MNL_SOCKET_BUFFER_SIZE];
 	struct nlattr *nest;
+	int err = 0;
 
 	nlh = msg_init(buf, TIPC_NL_MON_PEER_GET);
 	if (!nlh) {
@@ -709,7 +829,8 @@ static int link_mon_peer_list(uint32_t mon_ref)
 	mnl_attr_put_u32(nlh, TIPC_NLA_MON_REF, mon_ref);
 	mnl_attr_nest_end(nlh, nest);
 
-	return msg_dumpit(nlh, link_mon_peer_list_cb, NULL);
+	err = msg_dumpit(nlh, link_mon_peer_list_cb, NULL);
+	return err;
 }
 
 static int link_mon_list_cb(const struct nlmsghdr *nlh, void *data)
@@ -733,12 +854,16 @@ static int link_mon_list_cb(const struct nlmsghdr *nlh, void *data)
 	if (*req_bearer && (strcmp(req_bearer, bname) != 0))
 		return MNL_CB_OK;
 
-	printf("\nbearer %s\n", bname);
-	printf("%s\n", title);
+	open_json_object(NULL);
+	print_string(PRINT_ANY, "bearer", "\nbearer %s\n", bname);
+	print_string(PRINT_FP, NULL, "%s\n", title);
 
+	open_json_array(PRINT_JSON, bname);
 	if (mnl_attr_get_u32(attrs[TIPC_NLA_MON_PEERCNT]))
 		link_mon_peer_list(mnl_attr_get_u32(attrs[TIPC_NLA_MON_REF]));
+	close_json_array(PRINT_JSON, bname);
 
+	close_json_object();
 	return MNL_CB_OK;
 }
 
@@ -804,7 +929,10 @@ static int cmd_link_mon_list(struct nlmsghdr *nlh, const struct cmd *cmd,
 		return -1;
 	}
 
-	return msg_dumpit(nlh, link_mon_list_cb, bname);
+	new_json_obj(json);
+	err = msg_dumpit(nlh, link_mon_list_cb, bname);
+	delete_json_obj();
+	return err;
 }
 
 static void cmd_link_mon_set_help(struct cmdl *cmdl)
@@ -848,8 +976,10 @@ static int link_mon_get_cb(const struct nlmsghdr *nlh, void *data)
 	if (!attrs[TIPC_NLA_MON_ACTIVATION_THRESHOLD])
 		return MNL_CB_ERROR;
 
-	printf("%u\n",
-	       mnl_attr_get_u32(attrs[TIPC_NLA_MON_ACTIVATION_THRESHOLD]));
+	new_json_obj(json);
+	print_uint(PRINT_ANY, "threshold", "%u\n",
+			   mnl_attr_get_u32(attrs[TIPC_NLA_MON_ACTIVATION_THRESHOLD]));
+	delete_json_obj();
 
 	return MNL_CB_OK;
 }
-- 
2.7.4

^ permalink raw reply related

* Re: netdevice notifier and device private data
From: Michael Richardson @ 2018-06-11  2:09 UTC (permalink / raw)
  To: Alexander Aring; +Cc: netdev, linux-wpan, linux-bluetooth
In-Reply-To: <20180610153956.mgzigzfne6shjb4s@x220t>

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


Alexander Aring <aring@mojatatu.com> wrote:
    >> It totally seems like broken behaviour.  Maybe it's not even
    >> intentional.  Maybe they are just foobar.

    > They simple don't know what they doing... somebody thought 6LoWPAN need
    > to be 6LoWPAN, but they actually don't use the 6LoWPAN handling inside
    > the kernel. _Except_ they doing out of tree stuff which I don't
    > believe.

So, it seems like this ioctl() should be disabled, or restricted to cases
that actually work.  hate to break their code, but if it's broken anyway, at
least the kernel won't crash under them.

    > According to [0] it also works with tun default (I suppsoe raw IPv6),
    > because ifdef. And they should not change it because they don't use
    > in-kernel 6LoWPAN functionality.

    > I really think that this tun/tap feature makes a lot of trouble for
    > some type changes. I probably introduce lowpan_dev pointer to netdevice
    > and then check if it's really a 6LoPWAN interface, a dev->type will not
    > garantuee anymore you have a 6LoWPAN interface. At least in user space
    > it's not possible to have a check if you really have a 6LoWPAN
    > interface.

    > - Alex

    > [0]
    > https://github.com/openthread/wpantund/blob/master/src/util/tunnel.c#L180
    > [1] https://github.com/reubenhwk/radvd/blob/master/device-linux.c#L75

-- 
Michael Richardson <mcr+IETF@sandelman.ca>, Sandelman Software Works
 -= IPv6 IoT consulting =-




[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 464 bytes --]

^ permalink raw reply

* Re: [PATCH net] vhost_net: remove VHOST_NET_F_VIRTIO_NET_HDR support
From: Michael S. Tsirkin @ 2018-06-11  2:12 UTC (permalink / raw)
  To: Jason Wang; +Cc: netdev, linux-kernel, kvm, virtualization
In-Reply-To: <23efe110-f61a-5aee-c0b4-bd3dc5426438@redhat.com>

On Fri, Jun 08, 2018 at 01:07:09PM +0800, Jason Wang wrote:
> 
> 
> On 2018年06月08日 12:46, Michael S. Tsirkin wrote:
> > On Fri, Jun 08, 2018 at 11:50:42AM +0800, Jason Wang wrote:
> > > This feature bit is duplicated with VIRTIO_F_ANY_LAYOUT, this means if
> > > a userpsace want to enable VRITIO_F_ANY_LAYOUT,
> > > VHOST_NET_F_VIRTIO_NET_HDR will be implied too. This is wrong and will
> > > break networking.
> > What breaks networking exactly? VHOST_NET supported ANY_LAYOUT
> > from day one. For this reason it does not need to know about
> > VRITIO_F_ANY_LAYOUT and we reused the bit for other purposes.
> 
> It's the knowledge of vhost_net code it self but not userspace. For
> userspace, it should depends on the value of returned by VHOST_GET_FEATURES.
> So when userspace can set_features with ANY_LAYOUT, vhost may think it wants
> VHOST_NET_F_VIRTIO_NET_HDR.

Yes but that's the admittedly ugly API that we have now.
userspace is supposed to know VRITIO_F_ANY_LAYOUT does
not make sense for vhost.



> > 
> > 
> > 
> > > Fixing this by safely removing
> > > VHOST_NET_F_VIRTIO_NET_HDR support. There should be very few or even
> > > no userspace can use this.
> > Quite possibly, but it is hard to be sure. It seems safer to
> > maintain it unless there's an actual reason something's broken.
> 
> I think not since the feature is negotiated not mandatory?

That doesn't mean much.

> > 
> > > Further cleanups could be done for
> > > -net-next for safety.
> > > 
> > > In the future, we need a vhost dedicated feature set/get ioctl()
> > > instead of reusing virtio ones.
> > Not just in the future, we might want to switch iommu
> > to a sane structure without the 64 bit padding bug
> > right now.
> 
> Yes, I hit this bug when introducing V2 of msg IOTLB message.

Sounds good, so if you like, reserve a bit for
VHOST_NET_F_VIRTIO_NET_HDR in the new ioctl mask and
do not enable it there.

> > 
> > > Fixes: 4e9fa50c6ccbe ("vhost: move features to core")
> > This tag makes no sense here IMHO. Looks like people are using some tool
> > that just looks at the earliest version where patch won't apply. The
> > commit in question just moved some code around.
> 
> Looks not, before this commit, vhost_net won't return ANY_LAYOUT.
> 
> Thanks

Well ANY_LAYOUT just happens to be same as VHOST_NET_F_VIRTIO_NET_HDR
and that has been set since forever.

> > 
> > > Signed-off-by: Jason Wang <jasowang@redhat.com>
> > > ---
> > >   drivers/vhost/net.c | 15 +++++----------
> > >   1 file changed, 5 insertions(+), 10 deletions(-)
> > > 
> > > diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
> > > index 986058a..83eef52 100644
> > > --- a/drivers/vhost/net.c
> > > +++ b/drivers/vhost/net.c
> > > @@ -69,7 +69,6 @@ MODULE_PARM_DESC(experimental_zcopytx, "Enable Zero Copy TX;"
> > >   enum {
> > >   	VHOST_NET_FEATURES = VHOST_FEATURES |
> > > -			 (1ULL << VHOST_NET_F_VIRTIO_NET_HDR) |
> > >   			 (1ULL << VIRTIO_NET_F_MRG_RXBUF) |
> > >   			 (1ULL << VIRTIO_F_IOMMU_PLATFORM)
> > >   };
> > > @@ -1255,15 +1254,11 @@ static int vhost_net_set_features(struct vhost_net *n, u64 features)
> > >   			       (1ULL << VIRTIO_F_VERSION_1))) ?
> > >   			sizeof(struct virtio_net_hdr_mrg_rxbuf) :
> > >   			sizeof(struct virtio_net_hdr);
> > > -	if (features & (1 << VHOST_NET_F_VIRTIO_NET_HDR)) {
> > > -		/* vhost provides vnet_hdr */
> > > -		vhost_hlen = hdr_len;
> > > -		sock_hlen = 0;
> > > -	} else {
> > > -		/* socket provides vnet_hdr */
> > > -		vhost_hlen = 0;
> > > -		sock_hlen = hdr_len;
> > > -	}
> > > +
> > > +        /* socket provides vnet_hdr */
> > > +	vhost_hlen = 0;
> > > +	sock_hlen = hdr_len;
> > > +
> > >   	mutex_lock(&n->dev.mutex);
> > >   	if ((features & (1 << VHOST_F_LOG_ALL)) &&
> > >   	    !vhost_log_access_ok(&n->dev))
> > > -- 
> > > 2.7.4
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

^ permalink raw reply

* Re: Grant-
From: M. M. Fridman @ 2018-06-09 14:04 UTC (permalink / raw)
  To: Recipients

I Mikhail Fridman. has selected you specially as one of my beneficiaries
for my Charitable Donation, Just as I have declared on May 23, 2016 to give
my fortune as charity.

Check the link below for confirmation:

http://www.ibtimes.co.uk/russias-second-wealthiest-man-mikhail-fridman-plans-leaving-14-2bn-fortune-charity-1561604

Reply as soon as possible with further directives.

Best Regards,
Mikhail Fridman.

^ permalink raw reply

* Re: [PATCH v6 net] stmmac: strip all VLAN tag types when kernel 802.1Q support is selected
From: Toshiaki Makita @ 2018-06-11  0:50 UTC (permalink / raw)
  To: David Miller, eladv6
  Cc: Jose.Abreu, f.fainelli, netdev, peppe.cavallaro, alexandre.torgue
In-Reply-To: <20180610.122918.824988605265684146.davem@davemloft.net>

On 2018/06/11 4:29, David Miller wrote:
> From: Elad Nachman <eladv6@gmail.com>
> Date: Fri, 8 Jun 2018 12:19:29 +0300
> 
>> stmmac reception handler calls stmmac_rx_vlan() to strip the vlan before 
>> calling napi_gro_receive().
>>
>> The function assumes VLAN tagged frames are always tagged with 
>> 802.1Q protocol, and assigns ETH_P_8021Q to the skb by hard-coding
>> the parameter on call to __vlan_hwaccel_put_tag() .
>>
>> This causes packets not to be passed to the VLAN slave if it was created 
>> with 802.1AD protocol
>> (ip link add link eth0 eth0.100 type vlan proto 802.1ad id 100).
>>
>> This fix passes the protocol from the VLAN header into 
>> __vlan_hwaccel_put_tag() instead of using the hard-coded value of
>> ETH_P_8021Q.
>>
>> NETIF_F_HW_VLAN_CTAG_RX check was removed and instead the strip action 
>> is dependent upon a preprocessor define which is defined when 802.1Q 
>> support is selected in the kernel config. 
>>
>> NETIF_F_HW_VLAN_STAG_RX feature was added to be in line with the driver 
>> actual abilities.
>>
>> Signed-off-by: Elad Nachman <eladn@gilat.com>
> 
> You can't remove the NETIF_F_* checks.
> 
> If the user doesn't have VLAN offloading enabled, the VLAN tags should
> be left in the packet as-is.
> 
> It can't be controlled by a CPP check.

David, NETIF_F_HW_VALN_*_RX is not user-controllable in this driver
because hw_features does not include them.

But this can break when those features are added to hw_features so if
David does not like this situation I think we need the condition anyway.

-- 
Toshiaki Makita

^ permalink raw reply

* [GIT] Networking
From: David Miller @ 2018-06-11  0:42 UTC (permalink / raw)
  To: torvalds; +Cc: akpm, netdev, linux-kernel


1) For several bpfilter/UMH bugs, in particular make the UMH build not
   depend upon X86 specific Kconfig symbols.  From Alexei Starovoitov.

2) Fix handling of modified context pointer in bpf verifier, from
   Daniel Borkmann.

3) Kill regression in ifdown/ifup sequences for hv_netvsc driver, from
   Dexuan Cui.

4) When the bonding primary member name changes, we have to
   re-evaluate the bond->force_primary setting, from Xiangning Yu.

5) Eliminate possible padding beyone end of SKB in cdc_ncm driver,
   from Bjørn Mork.

6) RX queue length reported for UDP sockets in procfs and socket diag
   are inaccurate, from Paolo Abeni.

7) Fix br_fdb_find_port() locking, from Petr Machata.

8) Limit sk_rcvlowat values properly in TCP, from Soheil Hassas
   Yeganeh.

Please pull, thanks a lot!

The following changes since commit 3036bc45364f98515a2c446d7fac2c34dcfbeff4:

  Merge tag 'media/v4.18-2' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media (2018-06-07 12:34:37 -0700)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/davem/net.git 

for you to fetch changes up to 867f816badc01e6da655028810d468c9f935b37c:

  tcp: limit sk_rcvlowat by the maximum receive buffer (2018-06-10 14:12:50 -0700)

----------------------------------------------------------------
Alexei Starovoitov (3):
      umh: fix race condition
      bpfilter: fix OUTPUT_FORMAT
      bpfilter: fix race in pipe access

Alvaro Gamez Machado (1):
      net: phy: dp83822: use BMCR_ANENABLE instead of BMSR_ANEGCAPABLE for DP83620

Bjørn Mork (1):
      cdc_ncm: avoid padding beyond end of skb

Colin Ian King (1):
      net: aquantia: fix unsigned numvecs comparison with less than zero

Cong Wang (1):
      socket: close race condition between sock_close() and sockfs_setattr()

Corentin Labbe (1):
      net: stmmac: fix build failure due to missing COMMON_CLK dependency

Daniel Borkmann (2):
      bpf: reject passing modified ctx to helper functions
      bpf, xdp: fix crash in xdp_umem_unaccount_pages

David S. Miller (1):
      Merge git://git.kernel.org/.../bpf/bpf

Davide Caratti (1):
      net/sched: act_simple: fix parsing of TCA_DEF_DATA

Dexuan Cui (1):
      hv_netvsc: Fix a network regression after ifdown/ifup

Geert Uytterhoeven (2):
      net: mscc: ocelot: Fix uninitialized error in ocelot_netdevice_event()
      xsk: Fix umem fill/completion queue mmap on 32-bit

Pablo Neira Ayuso (1):
      netfilter: nf_tables: add NFT_LOGLEVEL_* enumeration and use it

Paolo Abeni (1):
      udp: fix rx queue len reported by diag and proc interface

Petr Machata (1):
      net: bridge: Fix locking in br_fdb_find_port()

Soheil Hassas Yeganeh (1):
      tcp: limit sk_rcvlowat by the maximum receive buffer

Sultan Alsawaf (1):
      ip_tunnel: Fix name string concatenate in __ip_tunnel_create()

Willem de Bruijn (1):
      net: in virtio_net_hdr only add VLAN_HLEN to csum_start if payload holds vlan

Xiangning Yu (1):
      bonding: re-evaluate force_primary when the primary slave name changes

Yonghong Song (1):
      tools/bpf: fix selftest get_cgroup_id_user

YueHaibing (1):
      net: fddi: fix a possible null-ptr-deref

 arch/um/drivers/vector_transports.c                  |  3 ++-
 drivers/net/bonding/bond_options.c                   |  1 +
 drivers/net/ethernet/aquantia/atlantic/aq_pci_func.c | 11 +++++------
 drivers/net/ethernet/mscc/ocelot.c                   |  2 +-
 drivers/net/ethernet/stmicro/stmmac/Kconfig          | 10 +++++-----
 drivers/net/fddi/skfp/skfddi.c                       | 55 ++++++++++++++++++++++++++++---------------------------
 drivers/net/hyperv/netvsc_drv.c                      |  4 +++-
 drivers/net/phy/dp83848.c                            | 35 +++++++++++++++++++++++++++++------
 drivers/net/tap.c                                    |  5 ++++-
 drivers/net/tun.c                                    |  3 ++-
 drivers/net/usb/cdc_ncm.c                            |  4 ++--
 drivers/net/virtio_net.c                             |  3 ++-
 include/linux/virtio_net.h                           | 11 ++++-------
 include/net/transp_v6.h                              | 11 +++++++++--
 include/net/udp.h                                    |  5 +++++
 include/uapi/linux/if_xdp.h                          |  4 ++--
 include/uapi/linux/netfilter/nf_tables.h             | 28 +++++++++++++++++++++++++---
 kernel/bpf/verifier.c                                | 48 +++++++++++++++++++++++++++++++-----------------
 kernel/umh.c                                         |  3 +--
 net/bpfilter/Makefile                                |  2 +-
 net/bpfilter/bpfilter_kern.c                         | 10 +++++++---
 net/bridge/br_fdb.c                                  |  4 +++-
 net/ipv4/ip_tunnel.c                                 |  4 ++--
 net/ipv4/tcp.c                                       | 12 +++++++-----
 net/ipv4/udp.c                                       |  2 +-
 net/ipv4/udp_diag.c                                  |  2 +-
 net/ipv6/datagram.c                                  |  6 +++---
 net/ipv6/udp.c                                       |  3 ++-
 net/netfilter/nft_log.c                              | 10 +++++-----
 net/packet/af_packet.c                               |  4 ++--
 net/sched/act_simple.c                               | 15 ++++++---------
 net/socket.c                                         | 18 +++++++++++++++---
 net/xdp/xdp_umem.c                                   |  6 ++++--
 net/xdp/xsk.c                                        |  2 +-
 tools/testing/selftests/bpf/get_cgroup_id_kern.c     | 14 +++++++++++++-
 tools/testing/selftests/bpf/get_cgroup_id_user.c     | 12 ++++++++++--
 tools/testing/selftests/bpf/test_verifier.c          | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 37 files changed, 301 insertions(+), 129 deletions(-)

^ permalink raw reply

* Re: [PATCH net-next] vlan: implement vlan id and protocol changes
From: kbuild test robot @ 2018-06-11  0:15 UTC (permalink / raw)
  To: Chas Williams
  Cc: kbuild-all, davem, netdev, Charles (Chas) Williams, Chas Williams
In-Reply-To: <20180610231912.1543-1-3chas3@gmail.com>

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

Hi Charles,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on net-next/master]

url:    https://github.com/0day-ci/linux/commits/Chas-Williams/vlan-implement-vlan-id-and-protocol-changes/20180611-072123
config: parisc-c3000_defconfig (attached as .config)
compiler: hppa-linux-gnu-gcc (Debian 7.2.0-11) 7.2.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=parisc 

All warnings (new ones prefixed by >>):

   net/core/dev.c: In function 'netdev_cmd_to_name':
>> net/core/dev.c:1580:2: warning: enumeration value 'NETDEV_CHANGEVLAN' not handled in switch [-Wswitch]
     switch (cmd) {
     ^~~~~~

vim +/NETDEV_CHANGEVLAN +1580 net/core/dev.c

56f5aa77 Michael Chan 2017-12-16  1574  
ede2762d Kirill Tkhai 2018-03-23  1575  const char *netdev_cmd_to_name(enum netdev_cmd cmd)
ede2762d Kirill Tkhai 2018-03-23  1576  {
ede2762d Kirill Tkhai 2018-03-23  1577  #define N(val) 						\
ede2762d Kirill Tkhai 2018-03-23  1578  	case NETDEV_##val:				\
ede2762d Kirill Tkhai 2018-03-23  1579  		return "NETDEV_" __stringify(val);
ede2762d Kirill Tkhai 2018-03-23 @1580  	switch (cmd) {
ede2762d Kirill Tkhai 2018-03-23  1581  	N(UP) N(DOWN) N(REBOOT) N(CHANGE) N(REGISTER) N(UNREGISTER)
ede2762d Kirill Tkhai 2018-03-23  1582  	N(CHANGEMTU) N(CHANGEADDR) N(GOING_DOWN) N(CHANGENAME) N(FEAT_CHANGE)
ede2762d Kirill Tkhai 2018-03-23  1583  	N(BONDING_FAILOVER) N(PRE_UP) N(PRE_TYPE_CHANGE) N(POST_TYPE_CHANGE)
ede2762d Kirill Tkhai 2018-03-23  1584  	N(POST_INIT) N(RELEASE) N(NOTIFY_PEERS) N(JOIN) N(CHANGEUPPER)
ede2762d Kirill Tkhai 2018-03-23  1585  	N(RESEND_IGMP) N(PRECHANGEMTU) N(CHANGEINFODATA) N(BONDING_INFO)
ede2762d Kirill Tkhai 2018-03-23  1586  	N(PRECHANGEUPPER) N(CHANGELOWERSTATE) N(UDP_TUNNEL_PUSH_INFO)
ede2762d Kirill Tkhai 2018-03-23  1587  	N(UDP_TUNNEL_DROP_INFO) N(CHANGE_TX_QUEUE_LEN)
9daae9bd Gal Pressman 2018-03-28  1588  	N(CVLAN_FILTER_PUSH_INFO) N(CVLAN_FILTER_DROP_INFO)
9daae9bd Gal Pressman 2018-03-28  1589  	N(SVLAN_FILTER_PUSH_INFO) N(SVLAN_FILTER_DROP_INFO)
3f5ecd8a Kirill Tkhai 2018-04-26  1590  	}
ede2762d Kirill Tkhai 2018-03-23  1591  #undef N
ede2762d Kirill Tkhai 2018-03-23  1592  	return "UNKNOWN_NETDEV_EVENT";
ede2762d Kirill Tkhai 2018-03-23  1593  }
ede2762d Kirill Tkhai 2018-03-23  1594  EXPORT_SYMBOL_GPL(netdev_cmd_to_name);
ede2762d Kirill Tkhai 2018-03-23  1595  

:::::: The code at line 1580 was first introduced by commit
:::::: ede2762d93ff16e0974f7446516b46b1022db213 net: Make NETDEV_XXX commands enum { }

:::::: TO: Kirill Tkhai <ktkhai@virtuozzo.com>
:::::: CC: David S. Miller <davem@davemloft.net>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 14440 bytes --]

^ permalink raw reply

* Re: [mmotm:master 192/212] include/uapi/asm-generic/int-ll64.h:20:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'typedef'
From: Randy Dunlap @ 2018-06-11  0:01 UTC (permalink / raw)
  To: kbuild test robot, Andrew Morton
  Cc: kbuild-all, Linux Memory Management List, Souptick Joarder,
	Johannes Weiner, LKML, netdev@vger.kernel.org
In-Reply-To: <201806081045.eZrs5GGH%fengguang.wu@intel.com>

On 06/07/2018 07:06 PM, kbuild test robot wrote:
> tree:   git://git.cmpxchg.org/linux-mmotm.git master
> head:   7393732bae530daa27567988b91d16ecfeef6c62
> commit: b1a8bfbadbcb79644ccdd5f9cd370caa63cb1fa7 [192/212] linux-next-git-rejects
> config: i386-randconfig-s0-201822-CONFIG_DEBUG_INFO_REDUCED (attached as .config)
> compiler: gcc-6 (Debian 6.4.0-9) 6.4.0 20171026
> reproduce:
>         git checkout b1a8bfbadbcb79644ccdd5f9cd370caa63cb1fa7
>         # save the attached .config to linux build tree
>         make ARCH=i386 
> 
> All errors (new ones prefixed by >>):
> 
>    In file included from include/asm-generic/int-ll64.h:11:0,
>                     from include/uapi/asm-generic/types.h:7,
>                     from arch/x86/include/uapi/asm/types.h:5,
>                     from include/uapi/linux/types.h:5,
>                     from include/linux/types.h:6,
>                     from net/ipv4/ipconfig.c:36:
>>> include/uapi/asm-generic/int-ll64.h:20:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'typedef'
>     typedef __signed__ char __s8;
>     ^~~~~~~

The problem here was that net/ipv4/ipconfig.c begins like this:

q// SPDX-License-Identifier: GPL-2.0

Did anyone fix that?


-- 
~Randy

^ permalink raw reply

* [PATCH net-next] vlan: implement vlan id and protocol changes
From: Chas Williams @ 2018-06-10 23:19 UTC (permalink / raw)
  To: davem; +Cc: netdev, Charles (Chas) Williams, Chas Williams

From: "Charles (Chas) Williams" <ciwillia@mail.eng.vyatta.net>

vlan_changelink silently ignores attempts to change the vlan id
or protocol id of an existing vlan interface.  Implement by adding
the new vlan id and protocol to the interface's vlan group and then
removing the old vlan id and protocol from the vlan group.

Signed-off-by: Chas Williams <3chas3@gmail.com>
---
 include/linux/netdevice.h |  1 +
 net/8021q/vlan.c          |  4 ++--
 net/8021q/vlan.h          |  2 ++
 net/8021q/vlan_netlink.c  | 38 ++++++++++++++++++++++++++++++++++++++
 4 files changed, 43 insertions(+), 2 deletions(-)

diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 3ec9850c7936..a95ae238addf 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -2409,6 +2409,7 @@ enum netdev_cmd {
 	NETDEV_CVLAN_FILTER_DROP_INFO,
 	NETDEV_SVLAN_FILTER_PUSH_INFO,
 	NETDEV_SVLAN_FILTER_DROP_INFO,
+	NETDEV_CHANGEVLAN,
 };
 const char *netdev_cmd_to_name(enum netdev_cmd cmd);
 
diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
index 73a65789271b..b5e0ad1a581a 100644
--- a/net/8021q/vlan.c
+++ b/net/8021q/vlan.c
@@ -51,8 +51,8 @@ const char vlan_version[] = DRV_VERSION;
 
 /* End of global variables definitions. */
 
-static int vlan_group_prealloc_vid(struct vlan_group *vg,
-				   __be16 vlan_proto, u16 vlan_id)
+int vlan_group_prealloc_vid(struct vlan_group *vg,
+			    __be16 vlan_proto, u16 vlan_id)
 {
 	struct net_device **array;
 	unsigned int pidx, vidx;
diff --git a/net/8021q/vlan.h b/net/8021q/vlan.h
index 44df1c3df02d..c734dd21d70d 100644
--- a/net/8021q/vlan.h
+++ b/net/8021q/vlan.h
@@ -116,6 +116,8 @@ int register_vlan_dev(struct net_device *dev, struct netlink_ext_ack *extack);
 void unregister_vlan_dev(struct net_device *dev, struct list_head *head);
 bool vlan_dev_inherit_address(struct net_device *dev,
 			      struct net_device *real_dev);
+int vlan_group_prealloc_vid(struct vlan_group *vg,
+			    __be16 vlan_proto, u16 vlan_id);
 
 static inline u32 vlan_get_ingress_priority(struct net_device *dev,
 					    u16 vlan_tci)
diff --git a/net/8021q/vlan_netlink.c b/net/8021q/vlan_netlink.c
index 9b60c1e399e2..0e59babe6651 100644
--- a/net/8021q/vlan_netlink.c
+++ b/net/8021q/vlan_netlink.c
@@ -107,10 +107,48 @@ static int vlan_changelink(struct net_device *dev, struct nlattr *tb[],
 			   struct nlattr *data[],
 			   struct netlink_ext_ack *extack)
 {
+	struct vlan_dev_priv *vlan = vlan_dev_priv(dev);
 	struct ifla_vlan_flags *flags;
 	struct ifla_vlan_qos_mapping *m;
 	struct nlattr *attr;
 	int rem;
+	int err;
+	__be16 vlan_proto = vlan->vlan_proto;
+	u16 vlan_id = vlan->vlan_id;
+
+	if (data[IFLA_VLAN_ID])
+		vlan_id = nla_get_u16(data[IFLA_VLAN_ID]);
+
+	if (data[IFLA_VLAN_PROTOCOL])
+		vlan_proto = nla_get_be16(data[IFLA_VLAN_PROTOCOL]);
+
+	if (vlan->vlan_id != vlan_id || vlan->vlan_proto != vlan_proto) {
+		struct net_device *real_dev = vlan->real_dev;
+		struct vlan_info *vlan_info;
+		struct vlan_group *grp;
+		__be16 old_vlan_proto = vlan->vlan_proto;
+		u16 old_vlan_id = vlan->vlan_id;
+
+		err = vlan_vid_add(real_dev, vlan_proto, vlan_id);
+		if (err)
+			return err;
+		vlan_info = rtnl_dereference(real_dev->vlan_info);
+		grp = &vlan_info->grp;
+		err = vlan_group_prealloc_vid(grp, vlan_proto, vlan_id);
+		if (err < 0) {
+			vlan_vid_del(real_dev, vlan_proto, vlan_id);
+			return err;
+		}
+		vlan_group_set_device(grp, vlan_proto, vlan_id, dev);
+		vlan->vlan_proto = vlan_proto;
+		vlan->vlan_id = vlan_id;
+
+		vlan_group_set_device(grp, old_vlan_proto, old_vlan_id, NULL);
+		vlan_vid_del(real_dev, old_vlan_proto, old_vlan_id);
+
+		err = call_netdevice_notifiers(NETDEV_CHANGEVLAN, dev);
+		notifier_to_errno(err);
+	}
 
 	if (data[IFLA_VLAN_FLAGS]) {
 		flags = nla_data(data[IFLA_VLAN_FLAGS]);
-- 
2.14.3

^ permalink raw reply related

* [PATCH net] ipv6: allow PMTU exceptions to local routes
From: Julian Anastasov @ 2018-06-10 23:02 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, Martin KaFai Lau, kernel-team, lvs-devel

IPVS setups with local client and remote tunnel server need
to create exception for the local virtual IP. What we do is to
change PMTU from 64KB (on "lo") to 1460 in the common case.

Suggested-by: Martin KaFai Lau <kafai@fb.com>
Fixes: 45e4fd26683c ("ipv6: Only create RTF_CACHE routes after encountering pmtu exception")
Fixes: 7343ff31ebf0 ("ipv6: Don't create clones of host routes.")
Signed-off-by: Julian Anastasov <ja@ssi.bg>
---
 net/ipv6/route.c | 3 ---
 1 file changed, 3 deletions(-)

Note: I failed to build 2.6.38 kernel for the test but I think
commit 7343ff31ebf0 looks as the one that added the restriction
to change PMTU for local IPs.

So, I'm not sure from how long time the issue with local IPVS
clients and tunnelling method exists. May be it worked between
2.6.28 and 2.6.37.

diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index fb95698..86a0e43 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -2307,9 +2307,6 @@ static void __ip6_rt_update_pmtu(struct dst_entry *dst, const struct sock *sk,
 	const struct in6_addr *daddr, *saddr;
 	struct rt6_info *rt6 = (struct rt6_info *)dst;
 
-	if (rt6->rt6i_flags & RTF_LOCAL)
-		return;
-
 	if (dst_metric_locked(dst, RTAX_MTU))
 		return;
 
-- 
2.9.5

^ permalink raw reply related

* Re: [Patch net] socket: close race condition between sock_close() and sockfs_setattr()
From: Cong Wang @ 2018-06-10 19:43 UTC (permalink / raw)
  To: David Miller
  Cc: Linux Kernel Network Developers, shankarapailoor, Tetsuo Handa,
	Lorenzo Colitti, Al Viro
In-Reply-To: <20180610.122704.2150654250277031669.davem@davemloft.net>

On Sun, Jun 10, 2018 at 12:27 PM, David Miller <davem@davemloft.net> wrote:
> I'm applying this for now, it is at least a step towards fixing
> all of these issues.
>
> If it is really offensive, I can revert, just tell me.

Thanks, David!

Unless there is something fundamentally broken, there is no
reason to revert it. The only risk here is some possible deadlock,
but I am ready to fix any deadlock report caused by this
patch. :)

^ permalink raw reply

* Re: [PATCH] net: phy: dp83822: use BMCR_ANENABLE instead of BMSR_ANEGCAPABLE for DP83620
From: David Miller @ 2018-06-10 19:39 UTC (permalink / raw)
  To: alvaro.gamez; +Cc: andrew, f.fainelli, netdev
In-Reply-To: <20180608102339.2572-1-alvaro.gamez@hazent.com>

From: Alvaro Gamez Machado <alvaro.gamez@hazent.com>
Date: Fri,  8 Jun 2018 12:23:39 +0200

> DP83620 register set is compatible with the DP83848, but it also supports
> 100base-FX. When the hardware is configured such as that fiber mode is
> enabled, autonegotiation is not possible.
> 
> The chip, however, doesn't expose this information via BMSR_ANEGCAPABLE.
> Instead, this bit is always set high, even if the particular hardware
> configuration makes it so that auto negotiation is not possible [1]. Under
> these circumstances, the phy subsystem keeps trying for autonegotiation to
> happen, without success.
> 
> Hereby, we inspect BMCR_ANENABLE bit after genphy_config_init, which on
> reset is set to 0 when auto negotiation is disabled, and so we use this
> value instead of BMSR_ANEGCAPABLE.
> 
> [1] https://e2e.ti.com/support/interface/ethernet/f/903/p/697165/2571170
> 
> Signed-off-by: Alvaro Gamez Machado <alvaro.gamez@hazent.com>

Applied and queued up for -stable, thanks.

^ permalink raw reply

* Re: [PATCH] net: thunderx: prevent concurrent data re-writing by nicvf_set_rx_mode
From: David Miller @ 2018-06-10 19:35 UTC (permalink / raw)
  To: Vadim.Lomovtsev
  Cc: rric, sgoutham, linux-arm-kernel, netdev, linux-kernel, dnelson,
	Vadim.Lomovtsev
In-Reply-To: <20180608092759.28059-1-Vadim.Lomovtsev@caviumnetworks.com>

From: Vadim Lomovtsev <Vadim.Lomovtsev@caviumnetworks.com>
Date: Fri,  8 Jun 2018 02:27:59 -0700

> +	/* Save message data locally to prevent them from
> +	 * being overwritten by next ndo_set_rx_mode call().
> +	 */
> +	spin_lock(&nic->rx_mode_wq_lock);
> +	mode = vf_work->mode;
> +	mc = vf_work->mc;
> +	vf_work->mc = NULL;
> +	spin_unlock(&nic->rx_mode_wq_lock);

At the moment you drop this lock, the memory behind 'mc' can be
freed up by:

> +	spin_lock(&nic->rx_mode_wq_lock);
> +	kfree(nic->rx_mode_work.mc);

And you'll crash when you dereference it above via
__nicvf_set_rx_mode_task().

^ permalink raw reply

* Re: [PATCH v6 net] stmmac: strip all VLAN tag types when kernel 802.1Q support is selected
From: David Miller @ 2018-06-10 19:29 UTC (permalink / raw)
  To: eladv6
  Cc: makita.toshiaki, Jose.Abreu, f.fainelli, netdev, peppe.cavallaro,
	alexandre.torgue
In-Reply-To: <cb89c947-21cf-b5da-9cff-940e904105c3@gmail.com>

From: Elad Nachman <eladv6@gmail.com>
Date: Fri, 8 Jun 2018 12:19:29 +0300

> stmmac reception handler calls stmmac_rx_vlan() to strip the vlan before 
> calling napi_gro_receive().
> 
> The function assumes VLAN tagged frames are always tagged with 
> 802.1Q protocol, and assigns ETH_P_8021Q to the skb by hard-coding
> the parameter on call to __vlan_hwaccel_put_tag() .
> 
> This causes packets not to be passed to the VLAN slave if it was created 
> with 802.1AD protocol
> (ip link add link eth0 eth0.100 type vlan proto 802.1ad id 100).
> 
> This fix passes the protocol from the VLAN header into 
> __vlan_hwaccel_put_tag() instead of using the hard-coded value of
> ETH_P_8021Q.
> 
> NETIF_F_HW_VLAN_CTAG_RX check was removed and instead the strip action 
> is dependent upon a preprocessor define which is defined when 802.1Q 
> support is selected in the kernel config. 
> 
> NETIF_F_HW_VLAN_STAG_RX feature was added to be in line with the driver 
> actual abilities.
> 
> Signed-off-by: Elad Nachman <eladn@gilat.com>

You can't remove the NETIF_F_* checks.

If the user doesn't have VLAN offloading enabled, the VLAN tags should
be left in the packet as-is.

It can't be controlled by a CPP check.

^ permalink raw reply

* Re: [PATCH net] vhost_net: remove VHOST_NET_F_VIRTIO_NET_HDR support
From: David Miller @ 2018-06-10 19:27 UTC (permalink / raw)
  To: jasowang; +Cc: netdev, virtualization, linux-kernel, kvm, mst
In-Reply-To: <1528429842-22835-1-git-send-email-jasowang@redhat.com>

From: Jason Wang <jasowang@redhat.com>
Date: Fri,  8 Jun 2018 11:50:42 +0800

> This feature bit is duplicated with VIRTIO_F_ANY_LAYOUT, this means if
> a userpsace want to enable VRITIO_F_ANY_LAYOUT,
> VHOST_NET_F_VIRTIO_NET_HDR will be implied too. This is wrong and will
> break networking. Fixing this by safely removing
> VHOST_NET_F_VIRTIO_NET_HDR support. There should be very few or even
> no userspace can use this. Further cleanups could be done for
> -net-next for safety.
> 
> In the future, we need a vhost dedicated feature set/get ioctl()
> instead of reusing virtio ones.
> 
> Fixes: 4e9fa50c6ccbe ("vhost: move features to core")
> Signed-off-by: Jason Wang <jasowang@redhat.com>

I don't see this discussion as resolved yet so I'll mark this
as Deferred in patchwork.

Thanks.

^ permalink raw reply

* Re: [Patch net] socket: close race condition between sock_close() and sockfs_setattr()
From: David Miller @ 2018-06-10 19:27 UTC (permalink / raw)
  To: xiyou.wangcong; +Cc: netdev, shankarapailoor, penguin-kernel, lorenzo, viro
In-Reply-To: <20180607203949.16945-1-xiyou.wangcong@gmail.com>

From: Cong Wang <xiyou.wangcong@gmail.com>
Date: Thu,  7 Jun 2018 13:39:49 -0700

> fchownat() doesn't even hold refcnt of fd until it figures out
> fd is really needed (otherwise is ignored) and releases it after
> it resolves the path. This means sock_close() could race with
> sockfs_setattr(), which leads to a NULL pointer dereference
> since typically we set sock->sk to NULL in ->release().
> 
> As pointed out by Al, this is unique to sockfs. So we can fix this
> in socket layer by acquiring inode_lock in sock_close() and
> checking against NULL in sockfs_setattr().
> 
> sock_release() is called in many places, only the sock_close()
> path matters here. And fortunately, this should not affect normal
> sock_close() as it is only called when the last fd refcnt is gone.
> It only affects sock_close() with a parallel sockfs_setattr() in
> progress, which is not common.
> 
> Fixes: 86741ec25462 ("net: core: Add a UID field to struct sock.")
> Reported-by: shankarapailoor <shankarapailoor@gmail.com>
> Cc: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
> Cc: Lorenzo Colitti <lorenzo@google.com>
> Cc: Al Viro <viro@zeniv.linux.org.uk>
> Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>

I'm applying this for now, it is at least a step towards fixing
all of these issues.

If it is really offensive, I can revert, just tell me.

^ permalink raw reply

* [ 54.304576] eth0: hw csum failure
From: Mathieu Malaterre @ 2018-06-10 18:57 UTC (permalink / raw)
  To: netdev

Hi there,

I am getting the following in dmesg upon startup from

[   54.304576] eth0: hw csum failure
[   54.304610] CPU: 0 PID: 0 Comm: swapper Not tainted 4.17.0+ #3
[   54.304616] Call Trace:
[   54.304633] [dffedbd0] [c069d178]
__skb_checksum_complete+0xf0/0x108 (unreliable)
[   54.304653] [dffedbf0] [c077711c] tcp_v4_rcv+0x604/0xe00
[   54.304668] [dffedc70] [c0730c98] ip_local_deliver_finish+0xa8/0x3c4
[   54.304677] [dffedcb0] [c0731aa4] ip_local_deliver+0xf0/0x154
[   54.304687] [dffedcf0] [c0731f50] ip_rcv+0x448/0x774
[   54.304701] [dffedd50] [c06adeac] __netif_receive_skb_core+0x5e8/0x1184
[   54.304712] [dffedde0] [c06badec] napi_gro_receive+0x160/0x22c
[   54.304729] [dffede10] [e1560590] gem_poll+0x7fc/0x1ac0 [sungem]
[   54.304738] [dffedee0] [c06ba0bc] net_rx_action+0x34c/0x618
[   54.304750] [dffedf60] [c07fc904] __do_softirq+0x16c/0x5f0
[   54.304763] [dffedfd0] [c0064c9c] irq_exit+0x110/0x1a8
[   54.304777] [dffedff0] [c0016170] call_do_irq+0x24/0x3c
[   54.304791] [c0cf5e80] [c0009a84] do_IRQ+0x98/0x1a0
[   54.304801] [c0cf5eb0] [c001b474] ret_from_except+0x0/0x14
[   54.304812] --- interrupt: 501 at arch_cpu_idle+0x30/0x78
                   LR = arch_cpu_idle+0x30/0x78
[   54.304821] [c0cf5f70] [c0cf4000] 0xc0cf4000 (unreliable)
[   54.304836] [c0cf5f80] [c00a3868] do_idle+0xc4/0x158
[   54.304845] [c0cf5fb0] [c00a3ab4] cpu_startup_entry+0x24/0x28
[   54.304856] [c0cf5fc0] [c0997820] start_kernel+0x47c/0x490
[   54.304864] [c0cf5ff0] [00003444] 0x3444
[   54.309112] eth0: hw csum failure
[   54.309133] CPU: 0 PID: 7 Comm: ksoftirqd/0 Not tainted 4.17.0+ #3
[   54.309138] Call Trace:
[   54.309154] [df503ab0] [c069d178]
__skb_checksum_complete+0xf0/0x108 (unreliable)
[   54.309172] [df503ad0] [c077711c] tcp_v4_rcv+0x604/0xe00
[   54.309184] [df503b50] [c0730c98] ip_local_deliver_finish+0xa8/0x3c4
[   54.309191] [df503b90] [c0731aa4] ip_local_deliver+0xf0/0x154
[   54.309199] [df503bd0] [c0731f50] ip_rcv+0x448/0x774
[   54.309211] [df503c30] [c06adeac] __netif_receive_skb_core+0x5e8/0x1184
[   54.309220] [df503cc0] [c06badec] napi_gro_receive+0x160/0x22c
[   54.309235] [df503cf0] [e1560590] gem_poll+0x7fc/0x1ac0 [sungem]
[   54.309242] [df503dc0] [c06ba0bc] net_rx_action+0x34c/0x618
[   54.309252] [df503e40] [c07fc904] __do_softirq+0x16c/0x5f0
[   54.309263] [df503eb0] [c00649c8] run_ksoftirqd+0x68/0x9c
[   54.309276] [df503ec0] [c009477c] smpboot_thread_fn+0x1bc/0x324
[   54.309289] [df503f10] [c008e01c] kthread+0x138/0x1f0
[   54.309296] [df503f40] [c001b1c4] ret_from_kernel_thread+0x14/0x1c
[   55.829670] eth0: hw csum failure
[   55.829703] CPU: 0 PID: 0 Comm: swapper Not tainted 4.17.0+ #3
[   55.829709] Call Trace:
[   55.829726] [dffedbd0] [c069d178]
__skb_checksum_complete+0xf0/0x108 (unreliable)
[   55.829746] [dffedbf0] [c077711c] tcp_v4_rcv+0x604/0xe00
[   55.829760] [dffedc70] [c0730c98] ip_local_deliver_finish+0xa8/0x3c4
[   55.829770] [dffedcb0] [c0731aa4] ip_local_deliver+0xf0/0x154
[   55.829779] [dffedcf0] [c0731f50] ip_rcv+0x448/0x774
[   55.829793] [dffedd50] [c06adeac] __netif_receive_skb_core+0x5e8/0x1184
[   55.829804] [dffedde0] [c06badec] napi_gro_receive+0x160/0x22c
[   55.829820] [dffede10] [e1560590] gem_poll+0x7fc/0x1ac0 [sungem]
[   55.829830] [dffedee0] [c06ba0bc] net_rx_action+0x34c/0x618
[   55.829842] [dffedf60] [c07fc904] __do_softirq+0x16c/0x5f0
[   55.829855] [dffedfd0] [c0064c9c] irq_exit+0x110/0x1a8
[   55.829869] [dffedff0] [c0016170] call_do_irq+0x24/0x3c
[   55.829883] [c0cf5e80] [c0009a84] do_IRQ+0x98/0x1a0
[   55.829892] [c0cf5eb0] [c001b474] ret_from_except+0x0/0x14
[   55.829904] --- interrupt: 501 at arch_cpu_idle+0x30/0x78
                   LR = arch_cpu_idle+0x30/0x78
[   55.829912] [c0cf5f70] [c0cf4000] 0xc0cf4000 (unreliable)
[   55.829927] [c0cf5f80] [c00a3868] do_idle+0xc4/0x158
[   55.829936] [c0cf5fb0] [c00a3ab4] cpu_startup_entry+0x24/0x28
[   55.829947] [c0cf5fc0] [c0997820] start_kernel+0x47c/0x490
[   55.829955] [c0cf5ff0] [00003444] 0x3444
[   55.831823] eth0: hw csum failure
...


Do you want me to run a bit-bisect ?

^ permalink raw reply

* Re: [PATCH v2] net-fq: Add WARN_ON check for null flow.
From: Michał Kazior @ 2018-06-10 17:10 UTC (permalink / raw)
  To: Arend van Spriel
  Cc: Ben Greear, Cong Wang, Linux Kernel Network Developers,
	linux-wireless@vger.kernel.org
In-Reply-To: <5B1AF7D4.9080700@broadcom.com>

Ben,

The patch is symptomatic. fq_tin_dequeue() already checks if the list
is empty before it tries to access first entry. I see no point in
using the _or_null() + WARN_ON.

The 0x3c deref is likely an offset off of NULL base pointer. Did you
check gdb/addr2line of the ieee80211_tx_dequeue+0xfb? Where did it
point to?

I suspect there's not enough synchronization between quescing the
device/ath10k after fw crashes and performing mac80211's reconfig
procedure.


Michał

On 8 June 2018 at 23:40, Arend van Spriel <arend.vanspriel@broadcom.com> wrote:
> On 6/8/2018 5:17 PM, Ben Greear wrote:
>
> I recalled an email from Michał leaving tieto so adding his alternate email
> he provided back then.
>
> Gr. AvS
>
>
>> On 06/07/2018 04:59 PM, Cong Wang wrote:
>>>
>>> On Thu, Jun 7, 2018 at 4:48 PM,  <greearb@candelatech.com> wrote:
>>>>
>>>> diff --git a/include/net/fq_impl.h b/include/net/fq_impl.h
>>>> index be7c0fa..cb911f0 100644
>>>> --- a/include/net/fq_impl.h
>>>> +++ b/include/net/fq_impl.h
>>>> @@ -78,7 +78,10 @@ static struct sk_buff *fq_tin_dequeue(struct fq *fq,
>>>>                         return NULL;
>>>>         }
>>>>
>>>> -       flow = list_first_entry(head, struct fq_flow, flowchain);
>>>> +       flow = list_first_entry_or_null(head, struct fq_flow,
>>>> flowchain);
>>>> +
>>>> +       if (WARN_ON_ONCE(!flow))
>>>> +               return NULL;
>>>
>>>
>>> This does not make sense either. list_first_entry_or_null()
>>> returns NULL only when the list is empty, but we already check
>>> list_empty() right before this code, and it is protected by fq->lock.
>>>
>>
>> Hello Michal,
>>
>> git blame shows you as the author of the fq_impl.h code.
>>
>> I saw a crash when debugging funky ath10k firmware in a 4.16 + hacks
>> kernel.  There was an apparent
>> mostly-null deref in the fq_tin_dequeue method.  According to gdb, it
>> was within
>> 1 line of the dereference of 'flow'.
>>
>> My hack above is probably not that useful.  Cong thinks maybe the
>> locking is bad.
>>
>> If you get a chance, please review this thread and see if you have any
>> ideas for
>> a better fix (or better debugging code).
>>
>> As always, if you would like me to generate you a buggy firmware that
>> will crash
>> in the tx path and cause all sorts of mayhem in the ath10k driver and
>> wifi stack,
>> I will be happy to do so.
>>
>> https://www.mail-archive.com/netdev@vger.kernel.org/msg239738.html
>>
>> Thanks,
>> Ben
>>
>

^ permalink raw reply

* Dear Talented
From: Lisa Clement @ 2018-06-10 16:57 UTC (permalink / raw)
  To: Recipients

Dear Talented,

I am Talent Scout For BLUE SKY FILM STUDIO, Present Blue sky Studio a
Film Corporation Located in the United State, is Soliciting for the
Right to use Your Photo/Face and Personality as One of the Semi -Major
Role/ Character in our Upcoming ANIMATED Stereoscope 3D Movie-The Story
of Spies in Disguise (Spies in Disguise 2019) The Movie is Currently Filming (In
Production) Please Note That There Will Be No Auditions, Traveling or
Any Special / Professional Acting Skills, Since the Production of This
Movie Will Be Done with our State of Art Computer -Generating Imagery
Equipment. We Are Prepared to Pay the Total Sum of $620,000.00 USD. For
More Information/Understanding, Please Write us on the E-Mail Below.
CONTACT EMAIL: bluesky.filmstudio@usa.com
All Reply to: bluesky.filmstudio@usa.com
Note: Only the Response send to this mail will be Given a Prior
Consideration.

Talent Scout
Lisa Clement

^ permalink raw reply

* [PATCH RFC v2 9/9] veth: Bulk skb xmit for XDP path
From: Toshiaki Makita @ 2018-06-10 16:02 UTC (permalink / raw)
  To: netdev
  Cc: Toshiaki Makita, Jesper Dangaard Brouer, Alexei Starovoitov,
	Daniel Borkmann
In-Reply-To: <20180610160217.3146-1-toshiaki.makita1@gmail.com>

From: Toshiaki Makita <makita.toshiaki@lab.ntt.co.jp>

Aquire txq lock instead of rxq ptr_ring lock so we avoid per-packet
lock when skb->xmit_more is true. We ensure that rxqs are always not
less than txqs and txq to rxq is one to one mapping, so we can
completely remove rxq side lock.

Since we removed rxq side lock, this change does not increase the number
of locking even when bulk sending is not possible, e.g. non-GSO packets.

Signed-off-by: Toshiaki Makita <makita.toshiaki@lab.ntt.co.jp>
---
 drivers/net/veth.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/net/veth.c b/drivers/net/veth.c
index 67debd3eafe6..376d70f983e5 100644
--- a/drivers/net/veth.c
+++ b/drivers/net/veth.c
@@ -138,7 +138,7 @@ static void __veth_xdp_flush(struct veth_rq *rq)
 
 static int veth_xdp_rx(struct veth_rq *rq, struct sk_buff *skb)
 {
-	if (unlikely(ptr_ring_produce(&rq->xdp_ring, skb))) {
+	if (unlikely(__ptr_ring_produce(&rq->xdp_ring, skb))) {
 		dev_kfree_skb_any(skb);
 		return NET_RX_DROP;
 	}
@@ -188,7 +188,7 @@ static netdev_tx_t veth_xmit(struct sk_buff *skb, struct net_device *dev)
 		atomic64_inc(&priv->dropped);
 	}
 
-	if (rcv_xdp)
+	if (rcv_xdp && !skb->xmit_more)
 		__veth_xdp_flush(rq);
 
 	rcu_read_unlock();
@@ -829,15 +829,21 @@ static netdev_features_t veth_fix_features(struct net_device *dev,
 {
 	struct veth_priv *priv = netdev_priv(dev);
 	struct net_device *peer;
+	bool xdp = false;
 
 	peer = rtnl_dereference(priv->peer);
 	if (peer) {
 		struct veth_priv *peer_priv = netdev_priv(peer);
 
 		if (rtnl_dereference(peer_priv->rq[0].xdp_prog))
-			features &= ~NETIF_F_GSO_SOFTWARE;
+			xdp = true;
 	}
 
+	if (xdp)
+		features &= ~(NETIF_F_GSO_SOFTWARE | NETIF_F_LLTX);
+	else
+		features |= NETIF_F_LLTX;
+
 	return features;
 }
 
-- 
2.14.3

^ 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