* [PATCH 01/15] netfilter: xt_CT: Reject the non-null terminated string from user space
From: Pablo Neira Ayuso @ 2018-06-11 9:22 UTC (permalink / raw)
To: netfilter-devel; +Cc: davem, netdev
In-Reply-To: <20180611092233.3219-1-pablo@netfilter.org>
From: Gao Feng <gfree.wind@vip.163.com>
The helper and timeout strings are from user-space, we need to make
sure they are null terminated. If not, evil user could make kernel
read the unexpected memory, even print it when fail to find by the
following codes.
pr_info_ratelimited("No such helper \"%s\"\n", helper_name);
Signed-off-by: Gao Feng <gfree.wind@vip.163.com>
Acked-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
net/netfilter/xt_CT.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/net/netfilter/xt_CT.c b/net/netfilter/xt_CT.c
index 8790190c6feb..03b9a50ec93b 100644
--- a/net/netfilter/xt_CT.c
+++ b/net/netfilter/xt_CT.c
@@ -245,12 +245,22 @@ static int xt_ct_tg_check(const struct xt_tgchk_param *par,
}
if (info->helper[0]) {
+ if (strnlen(info->helper, sizeof(info->helper)) == sizeof(info->helper)) {
+ ret = -ENAMETOOLONG;
+ goto err3;
+ }
+
ret = xt_ct_set_helper(ct, info->helper, par);
if (ret < 0)
goto err3;
}
if (info->timeout[0]) {
+ if (strnlen(info->timeout, sizeof(info->timeout)) == sizeof(info->timeout)) {
+ ret = -ENAMETOOLONG;
+ goto err4;
+ }
+
ret = xt_ct_set_timeout(ct, par, info->timeout);
if (ret < 0)
goto err4;
--
2.11.0
^ permalink raw reply related
* [PATCH 00/15] Netfilter/IPVS fixes for net
From: Pablo Neira Ayuso @ 2018-06-11 9:22 UTC (permalink / raw)
To: netfilter-devel; +Cc: davem, netdev
Hi David,
The following patchset contains Netfilter/IPVS fixes for your net tree:
1) Reject non-null terminated helper names from xt_CT, from Gao Feng.
2) Fix KASAN splat due to out-of-bound access from commit phase, from
Alexey Kodanev.
3) Missing conntrack hook registration on IPVS FTP helper, from Julian
Anastasov.
4) Incorrect skbuff allocation size in bridge nft_reject, from Taehee Yoo.
5) Fix inverted check on packet xmit to non-local addresses, also from
Julian.
6) Fix ebtables alignment compat problems, from Alin Nastac.
7) Hook mask checks are not correct in xt_set, from Serhey Popovych.
8) Fix timeout listing of element in ipsets, from Jozsef.
9) Cap maximum timeout value in ipset, also from Jozsef.
10) Don't allow family option for hash:mac sets, from Florent Fourcot.
11) Restrict ebtables to work with NFPROTO_BRIDGE targets only, this
Florian.
12) Another bug reported by KASAN in the rbtree set backend, from
Taehee Yoo.
13) Missing __IPS_MAX_BIT update doesn't include IPS_OFFLOAD_BIT.
From Gao Feng.
14) Missing initialization of match/target in ebtables, from Florian
Westphal.
15) Remove useless nft_dup.h file in include path, from C. Labbe.
You can pull these changes from:
git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf.git
Thanks.
----------------------------------------------------------------
The following changes since commit 664088f8d68178809b848ca450f2797efb34e8e7:
net-sysfs: Fix memory leak in XPS configuration (2018-05-31 23:02:42 -0400)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf.git HEAD
for you to fetch changes up to d8e87fc6d11c31525430a388317b52f4a98a5328:
netfilter: remove include/net/netfilter/nft_dup.h (2018-06-08 12:42:24 +0200)
----------------------------------------------------------------
Alexey Kodanev (1):
netfilter: nf_tables: check msg_type before nft_trans_set(trans)
Alin Nastac (1):
netfilter: ebtables: fix compat entry padding
Corentin Labbe (1):
netfilter: remove include/net/netfilter/nft_dup.h
Florent Fourcot (1):
netfilter: ipset: forbid family for hash:mac sets
Florian Westphal (2):
netfilter: ebtables: reject non-bridge targets
netfilter: x_tables: initialise match/target check parameter struct
Gao Feng (2):
netfilter: xt_CT: Reject the non-null terminated string from user space
netfilter: nf_conntrack: Increase __IPS_MAX_BIT with new bit IPS_OFFLOAD_BIT
Jozsef Kadlecsik (2):
netfilter: ipset: List timing out entries with "timeout 1" instead of zero
netfilter: ipset: Limit max timeout value
Julian Anastasov (2):
ipvs: register conntrack hooks for ftp
ipvs: fix check on xmit to non-local addresses
Pablo Neira Ayuso (1):
Merge git://blackhole.kfki.hu/nf
Serhey Popovych (1):
netfilter: xt_set: Check hook mask correctly
Taehee Yoo (2):
netfilter: nft_reject_bridge: fix skb allocation size in nft_reject_br_send_v6_unreach
netfilter: nft_set_rbtree: fix parameter of __nft_rbtree_lookup()
include/linux/netfilter/ipset/ip_set_timeout.h | 20 ++++++++++-----
include/net/ip_vs.h | 30 ++++++++++++++++++++++
include/net/netfilter/nft_dup.h | 10 --------
include/uapi/linux/netfilter/nf_conntrack_common.h | 2 +-
net/bridge/netfilter/ebtables.c | 25 ++++++++++++++----
net/bridge/netfilter/nft_reject_bridge.c | 2 +-
net/ipv4/netfilter/ip_tables.c | 1 +
net/ipv6/netfilter/ip6_tables.c | 1 +
net/netfilter/ipset/ip_set_hash_gen.h | 5 +++-
net/netfilter/ipvs/ip_vs_ctl.c | 4 +++
net/netfilter/ipvs/ip_vs_xmit.c | 2 +-
net/netfilter/nf_tables_api.c | 11 ++++----
net/netfilter/nft_set_rbtree.c | 2 +-
net/netfilter/xt_CT.c | 10 ++++++++
net/netfilter/xt_set.c | 10 ++++----
15 files changed, 99 insertions(+), 36 deletions(-)
delete mode 100644 include/net/netfilter/nft_dup.h
^ permalink raw reply
* [PATCH 08/15] netfilter: ipset: List timing out entries with "timeout 1" instead of zero
From: Pablo Neira Ayuso @ 2018-06-11 9:22 UTC (permalink / raw)
To: netfilter-devel; +Cc: davem, netdev
In-Reply-To: <20180611092233.3219-1-pablo@netfilter.org>
From: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
When listing sets with timeout support, there's a probability that
just timing out entries with "0" timeout value is listed/saved.
However when restoring the saved list, the zero timeout value means
permanent elelements.
The new behaviour is that timing out entries are listed with "timeout 1"
instead of zero.
Fixes netfilter bugzilla #1258.
Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
---
include/linux/netfilter/ipset/ip_set_timeout.h | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/include/linux/netfilter/ipset/ip_set_timeout.h b/include/linux/netfilter/ipset/ip_set_timeout.h
index bfb3531fd88a..7ad8ddf9ca8a 100644
--- a/include/linux/netfilter/ipset/ip_set_timeout.h
+++ b/include/linux/netfilter/ipset/ip_set_timeout.h
@@ -65,8 +65,14 @@ ip_set_timeout_set(unsigned long *timeout, u32 value)
static inline u32
ip_set_timeout_get(const unsigned long *timeout)
{
- return *timeout == IPSET_ELEM_PERMANENT ? 0 :
- jiffies_to_msecs(*timeout - jiffies)/MSEC_PER_SEC;
+ u32 t;
+
+ if (*timeout == IPSET_ELEM_PERMANENT)
+ return 0;
+
+ t = jiffies_to_msecs(*timeout - jiffies)/MSEC_PER_SEC;
+ /* Zero value in userspace means no timeout */
+ return t == 0 ? 1 : t;
}
#endif /* __KERNEL__ */
--
2.11.0
^ permalink raw reply related
* [PATCH 04/15] netfilter: nft_reject_bridge: fix skb allocation size in nft_reject_br_send_v6_unreach
From: Pablo Neira Ayuso @ 2018-06-11 9:22 UTC (permalink / raw)
To: netfilter-devel; +Cc: davem, netdev
In-Reply-To: <20180611092233.3219-1-pablo@netfilter.org>
From: Taehee Yoo <ap420073@gmail.com>
In order to allocate icmpv6 skb, sizeof(struct ipv6hdr) should be used.
Signed-off-by: Taehee Yoo <ap420073@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
net/bridge/netfilter/nft_reject_bridge.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/bridge/netfilter/nft_reject_bridge.c b/net/bridge/netfilter/nft_reject_bridge.c
index eaf05de37f75..6de981270566 100644
--- a/net/bridge/netfilter/nft_reject_bridge.c
+++ b/net/bridge/netfilter/nft_reject_bridge.c
@@ -261,7 +261,7 @@ static void nft_reject_br_send_v6_unreach(struct net *net,
if (!reject6_br_csum_ok(oldskb, hook))
return;
- nskb = alloc_skb(sizeof(struct iphdr) + sizeof(struct icmp6hdr) +
+ nskb = alloc_skb(sizeof(struct ipv6hdr) + sizeof(struct icmp6hdr) +
LL_MAX_HEADER + len, GFP_ATOMIC);
if (!nskb)
return;
--
2.11.0
^ permalink raw reply related
* [PATCH 02/15] netfilter: nf_tables: check msg_type before nft_trans_set(trans)
From: Pablo Neira Ayuso @ 2018-06-11 9:22 UTC (permalink / raw)
To: netfilter-devel; +Cc: davem, netdev
In-Reply-To: <20180611092233.3219-1-pablo@netfilter.org>
From: Alexey Kodanev <alexey.kodanev@oracle.com>
The patch moves the "trans->msg_type == NFT_MSG_NEWSET" check before
using nft_trans_set(trans). Otherwise we can get out of bounds read.
For example, KASAN reported the one when running 0001_cache_handling_0 nft
test. In this case "trans->msg_type" was NFT_MSG_NEWTABLE:
[75517.177808] BUG: KASAN: slab-out-of-bounds in nft_set_lookup_global+0x22f/0x270 [nf_tables]
[75517.279094] Read of size 8 at addr ffff881bdb643fc8 by task nft/7356
...
[75517.375605] CPU: 26 PID: 7356 Comm: nft Tainted: G E 4.17.0-rc7.1.x86_64 #1
[75517.489587] Hardware name: Oracle Corporation SUN SERVER X4-2
[75517.618129] Call Trace:
[75517.648821] dump_stack+0xd1/0x13b
[75517.691040] ? show_regs_print_info+0x5/0x5
[75517.742519] ? kmsg_dump_rewind_nolock+0xf5/0xf5
[75517.799300] ? lock_acquire+0x143/0x310
[75517.846738] print_address_description+0x85/0x3a0
[75517.904547] kasan_report+0x18d/0x4b0
[75517.949892] ? nft_set_lookup_global+0x22f/0x270 [nf_tables]
[75518.019153] ? nft_set_lookup_global+0x22f/0x270 [nf_tables]
[75518.088420] ? nft_set_lookup_global+0x22f/0x270 [nf_tables]
[75518.157689] nft_set_lookup_global+0x22f/0x270 [nf_tables]
[75518.224869] nf_tables_newsetelem+0x1a5/0x5d0 [nf_tables]
[75518.291024] ? nft_add_set_elem+0x2280/0x2280 [nf_tables]
[75518.357154] ? nla_parse+0x1a5/0x300
[75518.401455] ? kasan_kmalloc+0xa6/0xd0
[75518.447842] nfnetlink_rcv+0xc43/0x1bdf [nfnetlink]
[75518.507743] ? nfnetlink_rcv+0x7a5/0x1bdf [nfnetlink]
[75518.569745] ? nfnl_err_reset+0x3c0/0x3c0 [nfnetlink]
[75518.631711] ? lock_acquire+0x143/0x310
[75518.679133] ? netlink_deliver_tap+0x9b/0x1070
[75518.733840] ? kasan_unpoison_shadow+0x31/0x40
[75518.788542] netlink_unicast+0x45d/0x680
[75518.837111] ? __isolate_free_page+0x890/0x890
[75518.891913] ? netlink_attachskb+0x6b0/0x6b0
[75518.944542] netlink_sendmsg+0x6fa/0xd30
[75518.993107] ? netlink_unicast+0x680/0x680
[75519.043758] ? netlink_unicast+0x680/0x680
[75519.094402] sock_sendmsg+0xd9/0x160
[75519.138810] ___sys_sendmsg+0x64d/0x980
[75519.186234] ? copy_msghdr_from_user+0x350/0x350
[75519.243118] ? lock_downgrade+0x650/0x650
[75519.292738] ? do_raw_spin_unlock+0x5d/0x250
[75519.345456] ? _raw_spin_unlock+0x24/0x30
[75519.395065] ? __handle_mm_fault+0xbde/0x3410
[75519.448830] ? sock_setsockopt+0x3d2/0x1940
[75519.500516] ? __lock_acquire.isra.25+0xdc/0x19d0
[75519.558448] ? lock_downgrade+0x650/0x650
[75519.608057] ? __audit_syscall_entry+0x317/0x720
[75519.664960] ? __fget_light+0x58/0x250
[75519.711325] ? __sys_sendmsg+0xde/0x170
[75519.758850] __sys_sendmsg+0xde/0x170
[75519.804193] ? __ia32_sys_shutdown+0x90/0x90
[75519.856725] ? syscall_trace_enter+0x897/0x10e0
[75519.912354] ? trace_event_raw_event_sys_enter+0x920/0x920
[75519.979432] ? __audit_syscall_entry+0x720/0x720
[75520.036118] do_syscall_64+0xa3/0x3d0
[75520.081248] ? prepare_exit_to_usermode+0x47/0x1d0
[75520.139904] entry_SYSCALL_64_after_hwframe+0x44/0xa9
[75520.201680] RIP: 0033:0x7fc153320ba0
[75520.245772] RSP: 002b:00007ffe294c3638 EFLAGS: 00000246 ORIG_RAX: 000000000000002e
[75520.337708] RAX: ffffffffffffffda RBX: 00007ffe294c4820 RCX: 00007fc153320ba0
[75520.424547] RDX: 0000000000000000 RSI: 00007ffe294c46b0 RDI: 0000000000000003
[75520.511386] RBP: 00007ffe294c47b0 R08: 0000000000000004 R09: 0000000002114090
[75520.598225] R10: 00007ffe294c30a0 R11: 0000000000000246 R12: 00007ffe294c3660
[75520.684961] R13: 0000000000000001 R14: 00007ffe294c3650 R15: 0000000000000001
[75520.790946] Allocated by task 7356:
[75520.833994] kasan_kmalloc+0xa6/0xd0
[75520.878088] __kmalloc+0x189/0x450
[75520.920107] nft_trans_alloc_gfp+0x20/0x190 [nf_tables]
[75520.983961] nf_tables_newtable+0xcd0/0x1bd0 [nf_tables]
[75521.048857] nfnetlink_rcv+0xc43/0x1bdf [nfnetlink]
[75521.108655] netlink_unicast+0x45d/0x680
[75521.157013] netlink_sendmsg+0x6fa/0xd30
[75521.205271] sock_sendmsg+0xd9/0x160
[75521.249365] ___sys_sendmsg+0x64d/0x980
[75521.296686] __sys_sendmsg+0xde/0x170
[75521.341822] do_syscall_64+0xa3/0x3d0
[75521.386957] entry_SYSCALL_64_after_hwframe+0x44/0xa9
[75521.467867] Freed by task 23454:
[75521.507804] __kasan_slab_free+0x132/0x180
[75521.558137] kfree+0x14d/0x4d0
[75521.596005] free_rt_sched_group+0x153/0x280
[75521.648410] sched_autogroup_create_attach+0x19a/0x520
[75521.711330] ksys_setsid+0x2ba/0x400
[75521.755529] __ia32_sys_setsid+0xa/0x10
[75521.802850] do_syscall_64+0xa3/0x3d0
[75521.848090] entry_SYSCALL_64_after_hwframe+0x44/0xa9
[75521.929000] The buggy address belongs to the object at ffff881bdb643f80
which belongs to the cache kmalloc-96 of size 96
[75522.079797] The buggy address is located 72 bytes inside of
96-byte region [ffff881bdb643f80, ffff881bdb643fe0)
[75522.221234] The buggy address belongs to the page:
[75522.280100] page:ffffea006f6d90c0 count:1 mapcount:0 mapping:0000000000000000 index:0x0
[75522.377443] flags: 0x2fffff80000100(slab)
[75522.426956] raw: 002fffff80000100 0000000000000000 0000000000000000 0000000180200020
[75522.521275] raw: ffffea006e6fafc0 0000000c0000000c ffff881bf180f400 0000000000000000
[75522.615601] page dumped because: kasan: bad access detected
Fixes: 37a9cc525525 ("netfilter: nf_tables: add generation mask to sets")
Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com>
Acked-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
net/netfilter/nf_tables_api.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
index 501e48a7965b..8d8dfe417014 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -2728,12 +2728,13 @@ static struct nft_set *nf_tables_set_lookup_byid(const struct net *net,
u32 id = ntohl(nla_get_be32(nla));
list_for_each_entry(trans, &net->nft.commit_list, list) {
- struct nft_set *set = nft_trans_set(trans);
+ if (trans->msg_type == NFT_MSG_NEWSET) {
+ struct nft_set *set = nft_trans_set(trans);
- if (trans->msg_type == NFT_MSG_NEWSET &&
- id == nft_trans_set_id(trans) &&
- nft_active_genmask(set, genmask))
- return set;
+ if (id == nft_trans_set_id(trans) &&
+ nft_active_genmask(set, genmask))
+ return set;
+ }
}
return ERR_PTR(-ENOENT);
}
--
2.11.0
^ permalink raw reply related
* Re: [bug] cxgb4: vrf stopped working with cxgb4 card
From: Ganesh Goudar @ 2018-06-11 9:17 UTC (permalink / raw)
To: David Ahern; +Cc: AMG Zollner Robert, netdev
In-Reply-To: <c8c76c2f-4c51-4260-f828-09751f73972c@cumulusnetworks.com>
On Saturday, June 06/09/18, 2018 at 18:47:55 -0600, David Ahern wrote:
> Ganesh:
>
> On 6/4/18 9:03 AM, AMG Zollner Robert wrote:
> > I have noticed that vrf is not working with kernel v4.15.0 but was
> > working with v4.13.0 when using cxgb4 Chelsio driver (T520-cr)
> >
> > Setup:
> > Two metal servers with a T520-cr card each, directly connected without a
> > switch in between.
> >
> > SVR1 only ipfwd SVR2 with vrf
> > .----------------------------. .----------------------------------.
> > | | | |
> > | 192.168.8.1 [ ens2f4]--|---------|--[ens1f4] 192.168.8.2 |
> > | 192.168.9.1 [ens2f4d1]--|---------|--<ens1f4d1> 192.168.9.2 VRF=10 |
> > `----------------------------' `----------------------------------'
> >
> > When vrf is not working there are no error messages (dmesg or iproute
> > commands), tcpdump on the interface (SVR2.ens1f4d1) enslaved in vrf 10
> > shows packets(arp req/reply) coming in and going out, but outgoing
> > packets(arp reply) do not reach the other server SVR1.ens2f4d1
> >
> >
> > Bisect:
> > Found this commit to be the problem after doing a git bisect between
> > v4.13..v4.15:
> >
> > commit ba581f77df23c8ee70b372966e69cf10bc5453d8
> > Author: Ganesh Goudar <ganeshgr@chelsio.com>
> > Date: Sat Sep 23 16:07:28 2017 +0530
> >
> > cxgb4: do DCB state reset in couple of places
> >
> > reset the driver's DCB state in couple of places
> > where it was missing.
>
> Are you working on a fix for this or should a revert of the above patch
> be sent?
Will look into it and fix/revert it soon, Thanks for responding to Robert.
>
>
> >
> >
> > A bisect step was considered good when:
> > - successful ping from SVR1 to SVR2.ens1f4d1 vrf interface
> > - successful ping from SVR2 global to SVR2 vrf interface trough SVR1(l3
> > forwarding) (this check was redundant,both tests fail or pass simultaneous)
> >
> > The problem is still present on recent kernels also, checked v4.16.0 and
> > v4.17.rc7
> >
> > Disabling DCB for the card support fixes the problem ( Compiling kernel
> > with "CONFIG_CHELSIO_T4_DCB=n")
> >
> >
> >
> > This is my first time reporting a bug to the linux kernel and hope I
> > have included the right amount of information. Please let me know if I
> > have missed something.
> >
> >
> >
> > Thank you,
> > Zollner Robert
> >
> >
> > --------
> > Logs:
> >
> > VRF configured using folowing commands:
> >
> > #!/bin/sh
> >
> > CHDEV=ens1f4
> > VRF=vrf-recv
> >
> > sysctl -w net.ipv4.tcp_l3mdev_accept=1
> > sysctl -w net.ipv4.udp_l3mdev_accept=1
> > sysctl -w net.ipv4.conf.all.accept_local=1
> >
> > ifconfig ${CHDEV} 192.168.8.2/24
> > ifconfig ${CHDEV}d1 192.168.9.2/24
> >
> > ip link add ${VRF} type vrf table 10
> > ip link set dev ${VRF} up
> >
> > ip rule add pref 32765 table local
> > ip rule del pref 0
> >
> > ip route add table 10 unreachable default metric 4278198272
> >
> > ip link set dev ${CHDEV}d1 master ${VRF}
> >
> > ip route add table 10 default via 192.168.9.1
> > ip route add 192.168.9.0/24 via 192.168.8.1
> >
> >
> >
> >
>
^ permalink raw reply
* Re: [PATCH 3/3 RFC] Revert "net: stmmac: fix build failure due to missing COMMON_CLK dependency"
From: Geert Uytterhoeven @ 2018-06-11 9:13 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Greg Ungerer, Ralf Baechle, James Hogan, Giuseppe Cavallaro,
Alexandre Torgue, Jose Abreu, Corentin Labbe, David S. Miller,
linux-m68k, Linux MIPS Mailing List, netdev,
Linux Kernel Mailing List
In-Reply-To: <CAK8P3a1mhVJYuQGZM+ypQ1mKbB=+5gA6L=_D7-jjPmShLarwUQ@mail.gmail.com>
Hi Arnd,
On Mon, Jun 11, 2018 at 10:59 AM Arnd Bergmann <arnd@arndb.de> wrote:
> On Mon, Jun 11, 2018 at 10:44 AM, Geert Uytterhoeven
> <geert@linux-m68k.org> wrote:
> > This reverts commit bde4975310eb1982bd0bbff673989052d92fd481.
> >
> > All legacy clock implementations now implement clk_set_rate() (Some
> > implementations may be dummies, though).
> >
> > Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
> > ---
> > Marked "RFC", as this depends on "m68k: coldfire: Normalize clk API" and
> > "MIPS: AR7: Normalize clk API".
>
> This seems reasonable. It's possible that it will cause regressions because the
> COMMON_CLK dependency hides another dependency on something else
> that not everything implements, but we should fix that properly if that happens.
Compile-testing was enabled 2 years ago, in commit 2e280c188f06b190
("stmmac: make platform drivers depend on their associated SoC"), but the
dependency on COMMON_CLK was added only recently.
That's what triggered me: the drivers were suddenly disabled in m68k
allmodconfig,
while they built fine for years before.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply
* Re: [PATCH 0/3] Legacy clock drivers: Normalize clk API
From: Geert Uytterhoeven @ 2018-06-11 9:09 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Greg Ungerer, Ralf Baechle, James Hogan, Giuseppe Cavallaro,
Alexandre Torgue, Jose Abreu, Corentin Labbe, David S. Miller,
linux-m68k, Linux MIPS Mailing List, netdev,
Linux Kernel Mailing List
In-Reply-To: <CAK8P3a0CJmpf0L-OXDmqP=kRLGCokR=v6jUPaCSpnFuCwHa7WA@mail.gmail.com>
Hi Arnd,
On Mon, Jun 11, 2018 at 11:02 AM Arnd Bergmann <arnd@arndb.de> wrote:
> On Mon, Jun 11, 2018 at 10:44 AM, Geert Uytterhoeven
> <geert@linux-m68k.org> wrote:
> > When seeing commit bde4975310eb1982 ("net: stmmac: fix build failure due
> > to missing COMMON_CLK dependency"), I wondered why this dependency is
> > needed, as all implementations of the clock API should implement all
> > required functionality, or provide dummies.
> >
> > It turns out there were still two implementations that lacked the
> > clk_set_rate() function: Coldfire and AR7.
> >
> > This series contains three patches:
> > - The first two patches add dummies for clk_set_rate(),
> > clk_set_rate(), clk_set_parent(), and clk_get_parent() to the
> > Coldfire and AR7, like Arnd has done for other legacy clock
> > implementations a while ago.
> > - The second patch removes the COMMON_CLK dependency from the stmmac
> > network drivers again, as it is no longer needed.
> > Obviously this patch has a hard dependency on the first two patches.
>
> Yes, good idea.
>
> Acked-by: Arnd Bergmann <arnd@arnd.de>
Thanks!
> One question: what happens on machines that don't support any CLK
> interface, i.e.
> that don't have any of COMMON_CLK/HAVE_CLK/CLKDEV_LOOKUP?
>
> I guess those are already hopelessly broken for many drivers, right?
Nope, they (e.g. m68k allmodconfig) build fine, as they don't define
CONFIG_HAVE_CLK.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply
* Re: [PATCH 0/3] Legacy clock drivers: Normalize clk API
From: Arnd Bergmann @ 2018-06-11 9:02 UTC (permalink / raw)
To: Geert Uytterhoeven
Cc: Greg Ungerer, Ralf Baechle, James Hogan, Giuseppe Cavallaro,
Alexandre Torgue, Jose Abreu, Corentin Labbe, David S . Miller,
linux-m68k, open list:RALINK MIPS ARCHITECTURE, Networking,
Linux Kernel Mailing List
In-Reply-To: <1528706663-20670-1-git-send-email-geert@linux-m68k.org>
On Mon, Jun 11, 2018 at 10:44 AM, Geert Uytterhoeven
<geert@linux-m68k.org> wrote:
> Hi all,
>
> When seeing commit bde4975310eb1982 ("net: stmmac: fix build failure due
> to missing COMMON_CLK dependency"), I wondered why this dependency is
> needed, as all implementations of the clock API should implement all
> required functionality, or provide dummies.
>
> It turns out there were still two implementations that lacked the
> clk_set_rate() function: Coldfire and AR7.
>
> This series contains three patches:
> - The first two patches add dummies for clk_set_rate(),
> clk_set_rate(), clk_set_parent(), and clk_get_parent() to the
> Coldfire and AR7, like Arnd has done for other legacy clock
> implementations a while ago.
> - The second patch removes the COMMON_CLK dependency from the stmmac
> network drivers again, as it is no longer needed.
> Obviously this patch has a hard dependency on the first two patches.
Yes, good idea.
Acked-by: Arnd Bergmann <arnd@arnd.de>
One question: what happens on machines that don't support any CLK
interface, i.e.
that don't have any of COMMON_CLK/HAVE_CLK/CLKDEV_LOOKUP?
I guess those are already hopelessly broken for many drivers, right?
Arnd
^ permalink raw reply
* Re: [PATCH 3/3 RFC] Revert "net: stmmac: fix build failure due to missing COMMON_CLK dependency"
From: Arnd Bergmann @ 2018-06-11 8:59 UTC (permalink / raw)
To: Geert Uytterhoeven
Cc: Greg Ungerer, Ralf Baechle, James Hogan, Giuseppe Cavallaro,
Alexandre Torgue, Jose Abreu, Corentin Labbe, David S . Miller,
linux-m68k, open list:RALINK MIPS ARCHITECTURE, Networking,
Linux Kernel Mailing List
In-Reply-To: <1528706663-20670-4-git-send-email-geert@linux-m68k.org>
On Mon, Jun 11, 2018 at 10:44 AM, Geert Uytterhoeven
<geert@linux-m68k.org> wrote:
> This reverts commit bde4975310eb1982bd0bbff673989052d92fd481.
>
> All legacy clock implementations now implement clk_set_rate() (Some
> implementations may be dummies, though).
>
> Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
> ---
> Marked "RFC", as this depends on "m68k: coldfire: Normalize clk API" and
> "MIPS: AR7: Normalize clk API".
This seems reasonable. It's possible that it will cause regressions because the
COMMON_CLK dependency hides another dependency on something else
that not everything implements, but we should fix that properly if that happens.
Arnd
^ permalink raw reply
* [PATCH 3/3 RFC] Revert "net: stmmac: fix build failure due to missing COMMON_CLK dependency"
From: Geert Uytterhoeven @ 2018-06-11 8:44 UTC (permalink / raw)
To: Greg Ungerer, Ralf Baechle, James Hogan, Giuseppe Cavallaro,
Alexandre Torgue, Jose Abreu, Corentin Labbe, David S . Miller
Cc: Arnd Bergmann, linux-m68k, linux-mips, netdev, linux-kernel,
Geert Uytterhoeven
In-Reply-To: <1528706663-20670-1-git-send-email-geert@linux-m68k.org>
This reverts commit bde4975310eb1982bd0bbff673989052d92fd481.
All legacy clock implementations now implement clk_set_rate() (Some
implementations may be dummies, though).
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
Marked "RFC", as this depends on "m68k: coldfire: Normalize clk API" and
"MIPS: AR7: Normalize clk API".
---
drivers/net/ethernet/stmicro/stmmac/Kconfig | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/Kconfig b/drivers/net/ethernet/stmicro/stmmac/Kconfig
index cb5b0f58c395c2bd..e28c0d2c58e911ed 100644
--- a/drivers/net/ethernet/stmicro/stmmac/Kconfig
+++ b/drivers/net/ethernet/stmicro/stmmac/Kconfig
@@ -33,7 +33,7 @@ config DWMAC_DWC_QOS_ETH
select PHYLIB
select CRC32
select MII
- depends on OF && COMMON_CLK && HAS_DMA
+ depends on OF && HAS_DMA
help
Support for chips using the snps,dwc-qos-ethernet.txt DT binding.
@@ -57,7 +57,7 @@ config DWMAC_ANARION
config DWMAC_IPQ806X
tristate "QCA IPQ806x DWMAC support"
default ARCH_QCOM
- depends on OF && COMMON_CLK && (ARCH_QCOM || COMPILE_TEST)
+ depends on OF && (ARCH_QCOM || COMPILE_TEST)
select MFD_SYSCON
help
Support for QCA IPQ806X DWMAC Ethernet.
@@ -100,7 +100,7 @@ config DWMAC_OXNAS
config DWMAC_ROCKCHIP
tristate "Rockchip dwmac support"
default ARCH_ROCKCHIP
- depends on OF && COMMON_CLK && (ARCH_ROCKCHIP || COMPILE_TEST)
+ depends on OF && (ARCH_ROCKCHIP || COMPILE_TEST)
select MFD_SYSCON
help
Support for Ethernet controller on Rockchip RK3288 SoC.
@@ -123,7 +123,7 @@ config DWMAC_SOCFPGA
config DWMAC_STI
tristate "STi GMAC support"
default ARCH_STI
- depends on OF && COMMON_CLK && (ARCH_STI || COMPILE_TEST)
+ depends on OF && (ARCH_STI || COMPILE_TEST)
select MFD_SYSCON
---help---
Support for ethernet controller on STi SOCs.
@@ -147,7 +147,7 @@ config DWMAC_STM32
config DWMAC_SUNXI
tristate "Allwinner GMAC support"
default ARCH_SUNXI
- depends on OF && COMMON_CLK && (ARCH_SUNXI || COMPILE_TEST)
+ depends on OF && (ARCH_SUNXI || COMPILE_TEST)
---help---
Support for Allwinner A20/A31 GMAC ethernet controllers.
--
2.7.4
^ permalink raw reply related
* [PATCH 2/3] MIPS: AR7: Normalize clk API
From: Geert Uytterhoeven @ 2018-06-11 8:44 UTC (permalink / raw)
To: Greg Ungerer, Ralf Baechle, James Hogan, Giuseppe Cavallaro,
Alexandre Torgue, Jose Abreu, Corentin Labbe, David S . Miller
Cc: Arnd Bergmann, linux-m68k, linux-mips, netdev, linux-kernel,
Geert Uytterhoeven
In-Reply-To: <1528706663-20670-1-git-send-email-geert@linux-m68k.org>
Coldfire still provides its own variant of the clk API rather than using
the generic COMMON_CLK API. This generally works, but it causes some
link errors with drivers using the clk_round_rate(), clk_set_rate(),
clk_set_parent(), or clk_get_parent() functions when a platform lacks
those interfaces.
This adds empty stub implementations for each of them, and I don't even
try to do something useful here but instead just print a WARN() message
to make it obvious what is going on if they ever end up being called.
The drivers that call these won't be used on these platforms (otherwise
we'd get a link error today), so the added code is harmless bloat and
will warn about accidental use.
Based on commit bd7fefe1f06ca6cc ("ARM: w90x900: normalize clk API").
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
arch/mips/ar7/clock.c | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/arch/mips/ar7/clock.c b/arch/mips/ar7/clock.c
index 0137656107a9c5b5..6b64fd96dba8fb26 100644
--- a/arch/mips/ar7/clock.c
+++ b/arch/mips/ar7/clock.c
@@ -476,3 +476,32 @@ void __init ar7_init_clocks(void)
/* adjust vbus clock rate */
vbus_clk.rate = bus_clk.rate / 2;
}
+
+/* dummy functions, should not be called */
+long clk_round_rate(struct clk *clk, unsigned long rate)
+{
+ WARN_ON(clk);
+ return 0;
+}
+EXPORT_SYMBOL(clk_round_rate);
+
+int clk_set_rate(struct clk *clk, unsigned long rate)
+{
+ WARN_ON(clk);
+ return 0;
+}
+EXPORT_SYMBOL(clk_set_rate);
+
+int clk_set_parent(struct clk *clk, struct clk *parent)
+{
+ WARN_ON(clk);
+ return 0;
+}
+EXPORT_SYMBOL(clk_set_parent);
+
+struct clk *clk_get_parent(struct clk *clk)
+{
+ WARN_ON(clk);
+ return NULL;
+}
+EXPORT_SYMBOL(clk_get_parent);
--
2.7.4
^ permalink raw reply related
* [PATCH 1/3] m68k: coldfire: Normalize clk API
From: Geert Uytterhoeven @ 2018-06-11 8:44 UTC (permalink / raw)
To: Greg Ungerer, Ralf Baechle, James Hogan, Giuseppe Cavallaro,
Alexandre Torgue, Jose Abreu, Corentin Labbe, David S . Miller
Cc: Arnd Bergmann, linux-m68k, linux-mips, netdev, linux-kernel,
Geert Uytterhoeven
In-Reply-To: <1528706663-20670-1-git-send-email-geert@linux-m68k.org>
Coldfire still provides its own variant of the clk API rather than using
the generic COMMON_CLK API. This generally works, but it causes some
link errors with drivers using the clk_round_rate(), clk_set_rate(),
clk_set_parent(), or clk_get_parent() functions when a platform lacks
those interfaces.
This adds empty stub implementations for each of them, and I don't even
try to do something useful here but instead just print a WARN() message
to make it obvious what is going on if they ever end up being called.
The drivers that call these won't be used on these platforms (otherwise
we'd get a link error today), so the added code is harmless bloat and
will warn about accidental use.
Based on commit bd7fefe1f06ca6cc ("ARM: w90x900: normalize clk API").
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
arch/m68k/coldfire/clk.c | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/arch/m68k/coldfire/clk.c b/arch/m68k/coldfire/clk.c
index 849cd208e2ed99e6..7bc666e482ebe82f 100644
--- a/arch/m68k/coldfire/clk.c
+++ b/arch/m68k/coldfire/clk.c
@@ -129,4 +129,33 @@ unsigned long clk_get_rate(struct clk *clk)
}
EXPORT_SYMBOL(clk_get_rate);
+/* dummy functions, should not be called */
+long clk_round_rate(struct clk *clk, unsigned long rate)
+{
+ WARN_ON(clk);
+ return 0;
+}
+EXPORT_SYMBOL(clk_round_rate);
+
+int clk_set_rate(struct clk *clk, unsigned long rate)
+{
+ WARN_ON(clk);
+ return 0;
+}
+EXPORT_SYMBOL(clk_set_rate);
+
+int clk_set_parent(struct clk *clk, struct clk *parent)
+{
+ WARN_ON(clk);
+ return 0;
+}
+EXPORT_SYMBOL(clk_set_parent);
+
+struct clk *clk_get_parent(struct clk *clk)
+{
+ WARN_ON(clk);
+ return NULL;
+}
+EXPORT_SYMBOL(clk_get_parent);
+
/***************************************************************************/
--
2.7.4
^ permalink raw reply related
* [PATCH 0/3] Legacy clock drivers: Normalize clk API
From: Geert Uytterhoeven @ 2018-06-11 8:44 UTC (permalink / raw)
To: Greg Ungerer, Ralf Baechle, James Hogan, Giuseppe Cavallaro,
Alexandre Torgue, Jose Abreu, Corentin Labbe, David S . Miller
Cc: Arnd Bergmann, linux-m68k, linux-mips, netdev, linux-kernel,
Geert Uytterhoeven
Hi all,
When seeing commit bde4975310eb1982 ("net: stmmac: fix build failure due
to missing COMMON_CLK dependency"), I wondered why this dependency is
needed, as all implementations of the clock API should implement all
required functionality, or provide dummies.
It turns out there were still two implementations that lacked the
clk_set_rate() function: Coldfire and AR7.
This series contains three patches:
- The first two patches add dummies for clk_set_rate(),
clk_set_rate(), clk_set_parent(), and clk_get_parent() to the
Coldfire and AR7, like Arnd has done for other legacy clock
implementations a while ago.
- The second patch removes the COMMON_CLK dependency from the stmmac
network drivers again, as it is no longer needed.
Obviously this patch has a hard dependency on the first two patches.
Thanks!
Geert Uytterhoeven (3):
m68k: coldfire: Normalize clk API
MIPS: AR7: Normalize clk API
[RFC] Revert "net: stmmac: fix build failure due to missing COMMON_CLK
dependency"
arch/m68k/coldfire/clk.c | 29 +++++++++++++++++++++++++++++
arch/mips/ar7/clock.c | 29 +++++++++++++++++++++++++++++
drivers/net/ethernet/stmicro/stmmac/Kconfig | 10 +++++-----
3 files changed, 63 insertions(+), 5 deletions(-)
--
2.7.4
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply
* [PATCH] net: cxgb3: add error handling for some functions
From: Zhouyang Jia @ 2018-06-11 8:42 UTC (permalink / raw)
Cc: Zhouyang Jia, Santosh Raspatur, David S. Miller, netdev,
linux-kernel
When sysfs_create_group or alloc_skb fails, the lack of error-handling
code may cause unexpected results.
This patch adds error-handling code after the functions.
Signed-off-by: Zhouyang Jia <jiazhouyang09@gmail.com>
---
drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c b/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c
index 2edfdbd..bb51b7e 100644
--- a/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c
@@ -545,6 +545,8 @@ static int init_tp_parity(struct adapter *adap)
if (skb == adap->nofail_skb) {
i = await_mgmt_replies(adap, cnt, 16 + 2048 + 2048 + 1);
adap->nofail_skb = alloc_skb(sizeof(*greq), GFP_KERNEL);
+ if (!adap->nofail_skb)
+ goto alloc_skb_fail;
}
t3_tp_set_offload_mode(adap, 0);
@@ -3362,6 +3364,10 @@ static int init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
err = sysfs_create_group(&adapter->port[0]->dev.kobj,
&cxgb3_attr_group);
+ if (err) {
+ dev_err(&pdev->dev, "cannot create sysfs group\n");
+ goto out_free_dev;
+ }
print_port_info(adapter, ai);
return 0;
--
2.7.4
^ permalink raw reply related
* [PATCH] xen/netfront: raise max number of slots in xennet_get_responses()
From: Juergen Gross @ 2018-06-11 7:57 UTC (permalink / raw)
To: linux-kernel, xen-devel, netdev; +Cc: boris.ostrovsky, davem, Juergen Gross
The max number of slots used in xennet_get_responses() is set to
MAX_SKB_FRAGS + (rx->status <= RX_COPY_THRESHOLD).
In old kernel-xen MAX_SKB_FRAGS was 18, while nowadays it is 17. This
difference is resulting in frequent messages "too many slots" and a
reduced network throughput for some workloads (factor 10 below that of
a kernel-xen based guest).
Replacing MAX_SKB_FRAGS by XEN_NETIF_NR_SLOTS_MIN for calculation of
the max number of slots to use solves that problem (tests showed no
more messages "too many slots" and throughput was as high as with the
kernel-xen based guest system).
Signed-off-by: Juergen Gross <jgross@suse.com>
---
drivers/net/xen-netfront.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
index 679da1abd73c..ba411005d829 100644
--- a/drivers/net/xen-netfront.c
+++ b/drivers/net/xen-netfront.c
@@ -790,7 +790,7 @@ static int xennet_get_responses(struct netfront_queue *queue,
RING_IDX cons = queue->rx.rsp_cons;
struct sk_buff *skb = xennet_get_rx_skb(queue, cons);
grant_ref_t ref = xennet_get_rx_ref(queue, cons);
- int max = MAX_SKB_FRAGS + (rx->status <= RX_COPY_THRESHOLD);
+ int max = XEN_NETIF_NR_SLOTS_MIN + (rx->status <= RX_COPY_THRESHOLD);
int slots = 1;
int err = 0;
unsigned long ret;
--
2.13.7
^ permalink raw reply related
* Re: WARNING: kmalloc bug in xdp_umem_create
From: Dmitry Vyukov @ 2018-06-11 5:49 UTC (permalink / raw)
To: Björn Töpel
Cc: Tetsuo Handa, syzbot+4abadc5d69117b346506, Björn Töpel,
Karlsson, Magnus, David Miller, LKML, Netdev, syzkaller-bugs
In-Reply-To: <CAJ+HfNh9pRGcd9EO7BEfPPEdCmP5EDdu_rNgLR7r4oDrcLgvQQ@mail.gmail.com>
On Sun, Jun 10, 2018 at 3:03 PM, Björn Töpel <bjorn.topel@gmail.com> wrote:
>> On 2018/06/10 20:52, Dmitry Vyukov wrote:
>> > On Sun, Jun 10, 2018 at 11:31 AM, Björn Töpel <bjorn.topel@gmail.com> wrote:
>> >> Den sön 10 juni 2018 kl 04:53 skrev Tetsuo Handa
>> >> <penguin-kernel@i-love.sakura.ne.jp>:
>> >>>
>> >>> On 2018/06/10 7:47, syzbot wrote:
>> >>>> Hello,
>> >>>>
>> >>>> syzbot found the following crash on:
>> >>>>
>> >>>> HEAD commit: 7d3bf613e99a Merge tag 'libnvdimm-for-4.18' of git://git.k..
>> >>>> git tree: upstream
>> >>>> console output: https://syzkaller.appspot.com/x/log.txt?x=1073f68f800000
>> >>>> kernel config: https://syzkaller.appspot.com/x/.config?x=f04d8d0a2afb789a
>> >>>> dashboard link: https://syzkaller.appspot.com/bug?extid=4abadc5d69117b346506
>> >>>> compiler: gcc (GCC) 8.0.1 20180413 (experimental)
>> >>>> syzkaller repro:https://syzkaller.appspot.com/x/repro.syz?x=13c9756f800000
>> >>>> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=16366f9f800000
>> >>>>
>> >>>> IMPORTANT: if you fix the bug, please add the following tag to the commit:
>> >>>> Reported-by: syzbot+4abadc5d69117b346506@syzkaller.appspotmail.com
>> >>>>
>> >>>> random: sshd: uninitialized urandom read (32 bytes read)
>> >>>> random: sshd: uninitialized urandom read (32 bytes read)
>> >>>> random: sshd: uninitialized urandom read (32 bytes read)
>> >>>> random: sshd: uninitialized urandom read (32 bytes read)
>> >>>> random: sshd: uninitialized urandom read (32 bytes read)
>> >>>> WARNING: CPU: 1 PID: 4537 at mm/slab_common.c:996 kmalloc_slab+0x56/0x70 mm/slab_common.c:996
>> >>>> Kernel panic - not syncing: panic_on_warn set ...
>> >>>
>> >>> syzbot gave up upon kmalloc(), but actually error handling path has
>> >>> NULL pointer dereference bug.
>> >>>
>> >>
>> >> Thanks Tetsuo! This crash has been fixed by Daniel Borkmann in commit
>> >> c09290c56376 ("bpf, xdp: fix crash in xdp_umem_unaccount_pages").
>> >
>> > Let's tell syzbot about this:
>> >
>> > #syz fix: bpf, xdp: fix crash in xdp_umem_unaccount_pages
>> >
>> >
>> Excuse me, but that patch fixes NULL pointer dereference which occurs after kmalloc()'s
>> "WARNING: CPU: 1 PID: 4537 at mm/slab_common.c:996 kmalloc_slab+0x56/0x70 mm/slab_common.c:996"
>> message. That is, "Too large memory allocation" itself is not yet fixed.
>
> The code relies on that the sl{u,a,o}b layer says no, and the
> setsockopt bails out. The warning could be opted out using
> __GFP_NOWARN. Is there another preferred way? Two get_user_pages
> calls, where the first call would set pages to NULL just to fault the
> region? Walk the process' VMAs? Something else?
Hi Björn,
Yes, either __GFP_NOWARN for allocations with user-controllable size
or stricter custom limit (if we don't want current sla/u/ob
implementation details to be part of public kernel interface).
^ permalink raw reply
* [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
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox