* Re: Kernel Panic on high bandwidth transfer over wifi
From: Eric Dumazet @ 2018-08-29 15:29 UTC (permalink / raw)
To: Nathaniel Munk, netdev@vger.kernel.org
In-Reply-To: <porA6Oc9uVOmzI_nV2MhBU5RzBhBCq82gffuA1TBkrQxwTToIy03qc44DkN8BmdVKgQAGU6qDyrkCx7sDQI5SbSt9b9-HHf9ufHcIQlT-kg=@munk.com.au>
On 08/29/2018 04:42 AM, Nathaniel Munk wrote:
> Hi all,
> I'm running Arch Linux on kernel 4.18.5 (same issue on both arch-provided kernel and mainline built-from-source). There is an issue whereby the kernel crashes when transferring at high bandwidths (approx 6mB/s) over a specific wifi connection. I can only reproduce the issue when using the Personal Hotspot on my iPhone 6S+, but can reproduce it very consistently on that connection.
>
> More often than not, any download reaching this speed will cause a panic, but if the download is immediately terminated at the first error the system can recover (and doing this I have obtained the attached logs). Unfortunately, I have not had access to a second machine to obtain the netconsole printout of the panic.
>
> As above, high-bandwidth transfers on other wifi networks do not cause the issue (nor on ethernet connections).
>
> As you can see from the attached log, the issue appears at tcp_recvmsg+0x579 and net_tx_action+0x1fe. At both these positions (net/ipv4/tcp.c:2000 and net/core/dev.c:4279 in mainline 4.18.5), a member of the skb struct is called.
>
> Thank you for your time (and I apologize if this is spurious or badly worded, this is my first bug report), and please don't hesitate to let me know if there's anything else I can do to help work this out.
>
> Regards,
> -------------------
> Nathaniel Munk
> nathaniel@munk.com.au
>
Unfortunately there is no attached log ;)
^ permalink raw reply
* Re: [PATCH] rtnetlink: expose value from SET_NETDEV_DEVTYPE via IFLA_DEVTYPE attribute
From: Stephen Hemminger @ 2018-08-29 15:24 UTC (permalink / raw)
To: Jiri Pirko; +Cc: Marcel Holtmann, netdev, davem
In-Reply-To: <20180829071855.GB2181@nanopsycho>
On Wed, 29 Aug 2018 09:18:55 +0200
Jiri Pirko <jiri@resnulli.us> wrote:
> Tue, Aug 28, 2018 at 10:58:11PM CEST, marcel@holtmann.org wrote:
> >The name value from SET_NETDEV_DEVTYPE only ended up in the uevent sysfs
> >file as DEVTYPE= information. To avoid any kind of race conditions
> >between netlink messages and reading from sysfs, it is useful to add the
> >same string as new IFLA_DEVTYPE attribute included in the RTM_NEWLINK
> >messages.
> >
> >For network managing daemons that have to classify ARPHRD_ETHER network
> >devices into different types (like Wireless LAN, Bluetooth etc.), this
> >avoids the extra round trip to sysfs and parsing of the uevent file.
> >
> >Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
> >---
> > include/uapi/linux/if_link.h | 2 ++
> > net/core/rtnetlink.c | 12 ++++++++++++
> > 2 files changed, 14 insertions(+)
> >
> >diff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h
> >index 43391e2d1153..781294972bb4 100644
> >--- a/include/uapi/linux/if_link.h
> >+++ b/include/uapi/linux/if_link.h
> >@@ -166,6 +166,8 @@ enum {
> > IFLA_NEW_IFINDEX,
> > IFLA_MIN_MTU,
> > IFLA_MAX_MTU,
> >+ IFLA_DEVTYPE, /* Name value from SET_NETDEV_DEVTYPE */
>
> This is not something netdev-related. dev->dev.type is struct device_type.
> This is a generic "device" thing. Incorrect to expose over
> netdev-specific API. Please use "device" API for this.
There is no device API in netlink. The whole point of this patch is to
do it in one message. It might be a performance optimization, but I can't
see how it could be a race condition. Devices set type before registering.
^ permalink raw reply
* Re: [PATCH] rtnetlink: expose value from SET_NETDEV_DEVTYPE via IFLA_DEVTYPE attribute
From: Marcel Holtmann @ 2018-08-29 15:23 UTC (permalink / raw)
To: Jiri Pirko; +Cc: netdev, David S. Miller
In-Reply-To: <20180829071855.GB2181@nanopsycho>
Hi Jiri,
>> The name value from SET_NETDEV_DEVTYPE only ended up in the uevent sysfs
>> file as DEVTYPE= information. To avoid any kind of race conditions
>> between netlink messages and reading from sysfs, it is useful to add the
>> same string as new IFLA_DEVTYPE attribute included in the RTM_NEWLINK
>> messages.
>>
>> For network managing daemons that have to classify ARPHRD_ETHER network
>> devices into different types (like Wireless LAN, Bluetooth etc.), this
>> avoids the extra round trip to sysfs and parsing of the uevent file.
>>
>> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
>> ---
>> include/uapi/linux/if_link.h | 2 ++
>> net/core/rtnetlink.c | 12 ++++++++++++
>> 2 files changed, 14 insertions(+)
>>
>> diff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h
>> index 43391e2d1153..781294972bb4 100644
>> --- a/include/uapi/linux/if_link.h
>> +++ b/include/uapi/linux/if_link.h
>> @@ -166,6 +166,8 @@ enum {
>> IFLA_NEW_IFINDEX,
>> IFLA_MIN_MTU,
>> IFLA_MAX_MTU,
>> + IFLA_DEVTYPE, /* Name value from SET_NETDEV_DEVTYPE */
>
> This is not something netdev-related. dev->dev.type is struct device_type.
> This is a generic "device" thing. Incorrect to expose over
> netdev-specific API. Please use "device" API for this.
it is not just "device" related since this is a sub-classification of ARPHRD_ETHER type as a wrote above. Don't get hang up that this information is part of struct device. The dev->dev.type contains strings like "wlan", "bluetooth", "wimax", "gadget" etc. so that you can tell what kind of Ethernet card you have.
We can revive the patches for adding this information as IFLA_INFO_KIND, but last time they where reverted since NetworkManager did all the wrong decisions based on that. That part is fixed now and we can put that back and declare the sub-type classification of Ethernet device in two places. Or we just take the information that we added a long time ago for exactly this sub-classification and provide them to userspace via RTNL.
Regards
Marcel
^ permalink raw reply
* Re: [PATCH] net: sched: Fix memory exposure from short TCA_U32_SEL
From: Cong Wang @ 2018-08-29 19:07 UTC (permalink / raw)
To: Al Viro
Cc: Jamal Hadi Salim, Kees Cook, LKML, Jiri Pirko, David Miller,
Linux Kernel Network Developers
In-Reply-To: <20180828000310.GE6515@ZenIV.linux.org.uk>
On Mon, Aug 27, 2018 at 5:03 PM Al Viro <viro@zeniv.linux.org.uk> wrote:
>
> On Mon, Aug 27, 2018 at 02:31:41PM -0700, Cong Wang wrote:
> > > I cant think of any challenges. Cong/Jiri? Would it require development
> > > time classifiers/actions/qdiscs to sit in that directory (I suspect you
> > > dont want them in include/net).
> > > BTW, the idea of improving grep-ability of the code by prefixing the
> > > ops appropriately makes sense. i.e we should have ops->cls_init,
> > > ops->act_init etc.
> >
> > Hmm? Isn't struct tcf_proto_ops used and must be provided
> > by each tc filter module? How does it work if you move it into
> > net/sched/* for out-of-tree modules? Are they supposed to
> > include "..../net/sched/tcf_proto.h"?? Or something else?
>
> If you care about out-of-tree modules, that could easily live in
> include/net/tcf_proto.h, provided that it's not pulled by indirect
> includes into hell knows how many places. Try
> make allmodconfig
> make >/dev/null 2>&1
> find -name '.*.cmd'|xargs grep sch_generic.h
>
> That finds 2977 files here, most of them having nothing to do with
> net/sched.
Moving it to include/net/tcf_proto.h is fine, as out-of-tree modules
can still compile by modifying the included header path.
include/net/pkt_cls.h might be a choice here too.
^ permalink raw reply
* mlx5 driver loading failing on v4.19 / net-next / bpf-next
From: Jesper Dangaard Brouer @ 2018-08-29 15:05 UTC (permalink / raw)
To: Saeed Mahameed, netdev@vger.kernel.org
Cc: brouer, Tariq Toukan, Eran Ben Elisha
Hi Saeed,
I'm having issues loading mlx5 driver on v4.19 kernels (tested both
net-next and bpf-next), while kernel v4.18 seems to work. It happens
with a Mellanox ConnectX-5 NIC (and also a CX4-Lx but I removed that
from the system now).
One pain point is very long boot-time, caused by some timeout code in
the driver. The kernel console log (dmesg) says:
[ 5.763330] mlx5_core 0000:03:00.0: firmware version: 16.22.1002
[ 5.769367] mlx5_core 0000:03:00.0: 126.016 Gb/s available PCIe bandwidth, limited by 8 GT/s x16 link at 0000:00:02.0 (capable of 252.048 Gb/s with 16 GT/s x16 link)
(...) other drivers loading
[ 66.816635] mlx5_core 0000:03:00.0: wait_func:964:(pid 112): ENABLE_HCA(0x104) timeout. Will cause a leak of a command resource
[ 66.828123] mlx5_core 0000:03:00.0: enable hca failed
[ 66.845516] mlx5_core 0000:03:00.0: mlx5_load_one failed with error code -110
[ 66.852802] mlx5_core: probe of 0000:03:00.0 failed with error -110
[ 66.859347] mlx5_core 0000:03:00.1: firmware version: 16.22.1002
[ 66.865388] mlx5_core 0000:03:00.1: 126.016 Gb/s available PCIe bandwidth, limited by 8 GT/s x16 link at 0000:00:02.0 (capable of 252.048 Gb/s with 16 GT/s x16 link)
[ 125.787395] XFS (sda3): Mounting V5 Filesystem
[ 125.848509] XFS (sda3): Ending clean mount
[ 127.984784] mlx5_core 0000:03:00.1: wait_func:964:(pid 5): ENABLE_HCA(0x104) timeout. Will cause a leak of a command resource
[ 127.996090] mlx5_core 0000:03:00.1: enable hca failed
[ 128.013819] mlx5_core 0000:03:00.1: mlx5_load_one failed with error code -110
[ 128.021076] mlx5_core: probe of 0000:03:00.1 failed with error -110
Do you have any idea what could be causing this?
--
Best regards,
Jesper Dangaard Brouer
MSc.CS, Principal Kernel Engineer at Red Hat
LinkedIn: http://www.linkedin.com/in/brouer
^ permalink raw reply
* Re: [PATCH v2 iproute2-next 2/5] bridge: colorize output and use JSON print library
From: Stephen Hemminger @ 2018-08-29 15:04 UTC (permalink / raw)
To: Roopa Prabhu; +Cc: netdev, Stephen Hemminger, Julien Fortin, David Ahern
In-Reply-To: <CAJieiUi3BZPmaEJP6AK14zUwo20ssTNMz6eUfjFS0ZExizK9ng@mail.gmail.com>
On Sat, 14 Jul 2018 18:41:03 -0700
Roopa Prabhu <roopa@cumulusnetworks.com> wrote:
> On Tue, Feb 20, 2018 at 11:24 AM, Stephen Hemminger
> <stephen@networkplumber.org> wrote:
> > From: Stephen Hemminger <sthemmin@microsoft.com>
> >
> > Use new functions from json_print to simplify code.
> > Provide standard flag for colorizing output.
> >
> > The shortened -c flag is ambiguous it could mean color or
> > compressvlan; it is now changed to mean color for consistency
> > with other iproute2 commands.
> >
> > Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> > ---
> > bridge/br_common.h | 2 +-
> > bridge/bridge.c | 10 +-
> > bridge/fdb.c | 281 +++++++++++++++--------------------------
> > bridge/mdb.c | 362 ++++++++++++++++++++++-------------------------------
> > bridge/vlan.c | 276 +++++++++++++++-------------------------
> > 5 files changed, 363 insertions(+), 568 deletions(-)
> >
> > diff --git a/bridge/br_common.h b/bridge/br_common.h
> > index b25f61e50e05..2f1cb8fd9f3d 100644
> > --- a/bridge/br_common.h
> > +++ b/bridge/br_common.h
> > @@ -6,7 +6,7 @@
> > #define MDB_RTR_RTA(r) \
> > ((struct rtattr *)(((char *)(r)) + RTA_ALIGN(sizeof(__u32))))
> >
> > -extern void print_vlan_info(FILE *fp, struct rtattr *tb, int ifindex);
> > +extern void print_vlan_info(FILE *fp, struct rtattr *tb);
> > extern int print_linkinfo(const struct sockaddr_nl *who,
> > struct nlmsghdr *n,
> > void *arg);
> > diff --git a/bridge/bridge.c b/bridge/bridge.c
> > index 4b112e3b8da9..e5b4c3c2198f 100644
> > --- a/bridge/bridge.c
> > +++ b/bridge/bridge.c
> > @@ -16,12 +16,15 @@
> > #include "utils.h"
> > #include "br_common.h"
> > #include "namespace.h"
> > +#include "color.h"
> >
> > struct rtnl_handle rth = { .fd = -1 };
> > int preferred_family = AF_UNSPEC;
> > int oneline;
> > int show_stats;
> > int show_details;
> > +int show_pretty;
> > +int color;
> > int compress_vlans;
> > int json;
> > int timestamp;
> > @@ -39,7 +42,7 @@ static void usage(void)
> > "where OBJECT := { link | fdb | mdb | vlan | monitor }\n"
> > " OPTIONS := { -V[ersion] | -s[tatistics] | -d[etails] |\n"
> > " -o[neline] | -t[imestamp] | -n[etns] name |\n"
> > -" -c[ompressvlans] -p[retty] -j{son} }\n");
> > +" -c[ompressvlans] -color -p[retty] -j{son} }\n");
> > exit(-1);
> > }
> >
> > @@ -170,6 +173,8 @@ main(int argc, char **argv)
> > NEXT_ARG();
> > if (netns_switch(argv[1]))
> > exit(-1);
> > + } else if (matches(opt, "-color") == 0) {
> > + enable_color();
> > } else if (matches(opt, "-compressvlans") == 0) {
> > ++compress_vlans;
> > } else if (matches(opt, "-force") == 0) {
> > @@ -195,6 +200,9 @@ main(int argc, char **argv)
> >
> > _SL_ = oneline ? "\\" : "\n";
> >
> > + if (json)
> > + check_if_color_enabled();
> > +
> > if (batch_file)
> > return batch(batch_file);
> >
> > diff --git a/bridge/fdb.c b/bridge/fdb.c
> > index 93b5b2e694e3..b4f6e8b3a01b 100644
> > --- a/bridge/fdb.c
> > +++ b/bridge/fdb.c
> > @@ -22,9 +22,9 @@
> > #include <linux/neighbour.h>
> > #include <string.h>
> > #include <limits.h>
> > -#include <json_writer.h>
> > #include <stdbool.h>
> >
> > +#include "json_print.h"
> > #include "libnetlink.h"
> > #include "br_common.h"
> > #include "rt_names.h"
> > @@ -32,8 +32,6 @@
> >
> > static unsigned int filter_index, filter_vlan, filter_state;
> >
> > -json_writer_t *jw_global;
> > -
> > static void usage(void)
> > {
> > fprintf(stderr,
> > @@ -83,13 +81,46 @@ static int state_a2n(unsigned int *s, const char *arg)
> > return 0;
> > }
> >
> > -static void start_json_fdb_flags_array(bool *fdb_flags)
> > +static void fdb_print_flags(FILE *fp, unsigned int flags)
> > +{
> > + open_json_array(PRINT_JSON,
> > + is_json_context() ? "flags" : "");
> > +
> > + if (flags & NTF_SELF)
> > + print_string(PRINT_ANY, NULL, "%s ", "self");
> > +
> > + if (flags & NTF_ROUTER)
> > + print_string(PRINT_ANY, NULL, "%s ", "router");
> > +
> > + if (flags & NTF_EXT_LEARNED)
> > + print_string(PRINT_ANY, NULL, "%s ", "extern_learn");
> > +
> > + if (flags & NTF_OFFLOADED)
> > + print_string(PRINT_ANY, NULL, "%s ", "offload");
> > +
> > + if (flags & NTF_MASTER)
> > + print_string(PRINT_ANY, NULL, "%s ", "master");
> > +
> > + close_json_array(PRINT_JSON, NULL);
> > +}
> > +
> > +static void fdb_print_stats(FILE *fp, const struct nda_cacheinfo *ci)
> > {
> > - if (*fdb_flags)
> > - return;
> > - jsonw_name(jw_global, "flags");
> > - jsonw_start_array(jw_global);
> > - *fdb_flags = true;
> > + static int hz;
> > +
> > + if (!hz)
> > + hz = get_user_hz();
> > +
> > + if (is_json_context()) {
> > + print_uint(PRINT_JSON, "used", NULL,
> > + ci->ndm_used / hz);
> > + print_uint(PRINT_JSON, "updated", NULL,
> > + ci->ndm_updated / hz);
> > + } else {
> > + fprintf(fp, "used %d/%d ", ci->ndm_used / hz,
> > + ci->ndm_updated / hz);
> > +
> > + }
> > }
> >
> > int print_fdb(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
> > @@ -99,8 +130,6 @@ int print_fdb(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
> > int len = n->nlmsg_len;
> > struct rtattr *tb[NDA_MAX+1];
> > __u16 vid = 0;
> > - bool fdb_flags = false;
> > - const char *state_s;
> >
> > if (n->nlmsg_type != RTM_NEWNEIGH && n->nlmsg_type != RTM_DELNEIGH) {
> > fprintf(stderr, "Not RTM_NEWNEIGH: %08x %08x %08x\n",
> > @@ -132,189 +161,98 @@ int print_fdb(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
> > if (filter_vlan && filter_vlan != vid)
> > return 0;
> >
> > - if (jw_global)
> > - jsonw_start_object(jw_global);
> > -
> > - if (n->nlmsg_type == RTM_DELNEIGH) {
> > - if (jw_global)
> > - jsonw_string_field(jw_global, "opCode", "deleted");
> > - else
> > - fprintf(fp, "Deleted ");
> > - }
> > + open_json_object(NULL);
> > + if (n->nlmsg_type == RTM_DELNEIGH)
> > + print_bool(PRINT_ANY, "deleted", "Deleted ", true);
> >
> > if (tb[NDA_LLADDR]) {
> > + const char *lladdr;
> > SPRINT_BUF(b1);
> > - ll_addr_n2a(RTA_DATA(tb[NDA_LLADDR]),
> > - RTA_PAYLOAD(tb[NDA_LLADDR]),
> > - ll_index_to_type(r->ndm_ifindex),
> > - b1, sizeof(b1));
> > - if (jw_global)
> > - jsonw_string_field(jw_global, "mac", b1);
> > - else
> > - fprintf(fp, "%s ", b1);
> > +
> > + lladdr = ll_addr_n2a(RTA_DATA(tb[NDA_LLADDR]),
> > + RTA_PAYLOAD(tb[NDA_LLADDR]),
> > + ll_index_to_type(r->ndm_ifindex),
> > + b1, sizeof(b1));
> > +
> > + print_color_string(PRINT_ANY, COLOR_MAC,
> > + "mac", "%s ", lladdr);
> > }
> >
> > if (!filter_index && r->ndm_ifindex) {
> > - if (jw_global)
> > - jsonw_string_field(jw_global, "dev",
> > - ll_index_to_name(r->ndm_ifindex));
> > - else
> > - fprintf(fp, "dev %s ",
> > - ll_index_to_name(r->ndm_ifindex));
> > + if (!is_json_context())
> > + fprintf(fp, "dev ");
> > + print_color_string(PRINT_ANY, COLOR_IFNAME,
> > + "ifname", "%s ",
> > + ll_index_to_name(r->ndm_ifindex));
> > }
> >
> > if (tb[NDA_DST]) {
> > int family = AF_INET;
> > - const char *abuf_s;
> > + const char *dst;
> >
> > if (RTA_PAYLOAD(tb[NDA_DST]) == sizeof(struct in6_addr))
> > family = AF_INET6;
> >
> > - abuf_s = format_host(family,
> > - RTA_PAYLOAD(tb[NDA_DST]),
> > - RTA_DATA(tb[NDA_DST]));
> > - if (jw_global)
> > - jsonw_string_field(jw_global, "dst", abuf_s);
> > - else
> > - fprintf(fp, "dst %s ", abuf_s);
> > - }
> > + dst = format_host(family,
> > + RTA_PAYLOAD(tb[NDA_DST]),
> > + RTA_DATA(tb[NDA_DST]));
> >
> > - if (vid) {
> > - if (jw_global)
> > - jsonw_uint_field(jw_global, "vlan", vid);
> > - else
> > - fprintf(fp, "vlan %hu ", vid);
> > + print_color_string(PRINT_ANY,
> > + ifa_family_color(family),
> > + "dst", "%s ", dst);
> > }
> >
> > - if (tb[NDA_PORT]) {
> > - if (jw_global)
> > - jsonw_uint_field(jw_global, "port",
> > - rta_getattr_be16(tb[NDA_PORT]));
> > - else
> > - fprintf(fp, "port %d ",
> > - rta_getattr_be16(tb[NDA_PORT]));
> > - }
> > + if (vid)
> > + print_uint(PRINT_ANY,
> > + "vlan", "vlan %hu ", vid);
> >
> > - if (tb[NDA_VNI]) {
> > - if (jw_global)
> > - jsonw_uint_field(jw_global, "vni",
> > - rta_getattr_u32(tb[NDA_VNI]));
> > - else
> > - fprintf(fp, "vni %d ",
> > - rta_getattr_u32(tb[NDA_VNI]));
> > - }
> > + if (tb[NDA_PORT])
> > + print_uint(PRINT_ANY,
> > + "port", "port %u ",
> > + rta_getattr_be16(tb[NDA_PORT]));
> >
> > - if (tb[NDA_SRC_VNI]) {
> > - if (jw_global)
> > - jsonw_uint_field(jw_global, "src_vni",
> > - rta_getattr_u32(tb[NDA_SRC_VNI]));
> > - else
> > - fprintf(fp, "src_vni %d ",
> > + if (tb[NDA_VNI])
> > + print_uint(PRINT_ANY,
> > + "vni", "vni %u ",
> > + rta_getattr_u32(tb[NDA_VNI]));
> > +
> > + if (tb[NDA_SRC_VNI])
> > + print_uint(PRINT_ANY,
> > + "src_vni", "src_vni %u ",
> > rta_getattr_u32(tb[NDA_SRC_VNI]));
> > - }
> >
> > if (tb[NDA_IFINDEX]) {
> > unsigned int ifindex = rta_getattr_u32(tb[NDA_IFINDEX]);
> >
> > - if (ifindex) {
> > - if (!tb[NDA_LINK_NETNSID]) {
> > - const char *ifname = ll_index_to_name(ifindex);
> > -
> > - if (jw_global)
> > - jsonw_string_field(jw_global, "viaIf",
> > - ifname);
> > - else
> > - fprintf(fp, "via %s ", ifname);
> > - } else {
> > - if (jw_global)
> > - jsonw_uint_field(jw_global, "viaIfIndex",
> > - ifindex);
> > - else
> > - fprintf(fp, "via ifindex %u ", ifindex);
> > - }
> > - }
> > - }
> > -
> > - if (tb[NDA_LINK_NETNSID]) {
> > - if (jw_global)
> > - jsonw_uint_field(jw_global, "linkNetNsId",
> > - rta_getattr_u32(tb[NDA_LINK_NETNSID]));
> > + if (tb[NDA_LINK_NETNSID])
> > + print_uint(PRINT_ANY,
> > + "viaIfIndex", "via ifindex %u ",
> > + ifindex);
> > else
> > - fprintf(fp, "link-netnsid %d ",
> > - rta_getattr_u32(tb[NDA_LINK_NETNSID]));
> > + print_string(PRINT_ANY,
> > + "viaIf", "via %s ",
> > + ll_index_to_name(ifindex));
> > }
> >
> > - if (show_stats && tb[NDA_CACHEINFO]) {
> > - struct nda_cacheinfo *ci = RTA_DATA(tb[NDA_CACHEINFO]);
> > - int hz = get_user_hz();
> > + if (tb[NDA_LINK_NETNSID])
> > + print_uint(PRINT_ANY,
> > + "linkNetNsId", "link-netnsid %d ",
> > + rta_getattr_u32(tb[NDA_LINK_NETNSID]));
> >
> > - if (jw_global) {
> > - jsonw_uint_field(jw_global, "used",
> > - ci->ndm_used/hz);
> > - jsonw_uint_field(jw_global, "updated",
> > - ci->ndm_updated/hz);
> > - } else {
> > - fprintf(fp, "used %d/%d ", ci->ndm_used/hz,
> > - ci->ndm_updated/hz);
> > - }
> > - }
> > + if (show_stats && tb[NDA_CACHEINFO])
> > + fdb_print_stats(fp, RTA_DATA(tb[NDA_CACHEINFO]));
> >
> > - if (jw_global) {
> > - if (r->ndm_flags & NTF_SELF) {
> > - start_json_fdb_flags_array(&fdb_flags);
> > - jsonw_string(jw_global, "self");
> > - }
> > - if (r->ndm_flags & NTF_ROUTER) {
> > - start_json_fdb_flags_array(&fdb_flags);
> > - jsonw_string(jw_global, "router");
> > - }
> > - if (r->ndm_flags & NTF_EXT_LEARNED) {
> > - start_json_fdb_flags_array(&fdb_flags);
> > - jsonw_string(jw_global, "extern_learn");
> > - }
> > - if (r->ndm_flags & NTF_OFFLOADED) {
> > - start_json_fdb_flags_array(&fdb_flags);
> > - jsonw_string(jw_global, "offload");
> > - }
> > - if (r->ndm_flags & NTF_MASTER)
> > - jsonw_string(jw_global, "master");
> > - if (fdb_flags)
> > - jsonw_end_array(jw_global);
> > + fdb_print_flags(fp, r->ndm_flags);
> >
> > - if (tb[NDA_MASTER])
> > - jsonw_string_field(jw_global,
> > - "master",
> > - ll_index_to_name(rta_getattr_u32(tb[NDA_MASTER])));
> >
> > - } else {
> > - if (r->ndm_flags & NTF_SELF)
> > - fprintf(fp, "self ");
> > - if (r->ndm_flags & NTF_ROUTER)
> > - fprintf(fp, "router ");
> > - if (r->ndm_flags & NTF_EXT_LEARNED)
> > - fprintf(fp, "extern_learn ");
> > - if (r->ndm_flags & NTF_OFFLOADED)
> > - fprintf(fp, "offload ");
> > - if (tb[NDA_MASTER]) {
> > - fprintf(fp, "master %s ",
> > - ll_index_to_name(rta_getattr_u32(tb[NDA_MASTER])));
> > - } else if (r->ndm_flags & NTF_MASTER) {
> > - fprintf(fp, "master ");
> > - }
> > - }
> > -
> > - state_s = state_n2a(r->ndm_state);
> > - if (jw_global) {
> > - if (state_s[0])
> > - jsonw_string_field(jw_global, "state", state_s);
> > -
> > - jsonw_end_object(jw_global);
> > - } else {
> > - fprintf(fp, "%s\n", state_s);
> > -
> > - fflush(fp);
> > - }
> > + if (tb[NDA_MASTER])
> > + print_string(PRINT_ANY, "master", "%s ",
> > + ll_index_to_name(rta_getattr_u32(tb[NDA_MASTER])));
> >
> > + print_string(PRINT_ANY, "state", "%s\n",
> > + state_n2a(r->ndm_state));
> > + close_json_object();
> > + fflush(fp);
> > return 0;
> > }
> >
> > @@ -386,26 +324,13 @@ static int fdb_show(int argc, char **argv)
> > exit(1);
> > }
> >
> > - if (json) {
> > - jw_global = jsonw_new(stdout);
> > - if (!jw_global) {
> > - fprintf(stderr, "Error allocation json object\n");
> > - exit(1);
> > - }
> > - if (pretty)
> > - jsonw_pretty(jw_global, 1);
> > -
> > - jsonw_start_array(jw_global);
> > - }
> > -
> > + new_json_obj(json);
> > if (rtnl_dump_filter(&rth, print_fdb, stdout) < 0) {
> > fprintf(stderr, "Dump terminated\n");
> > exit(1);
> > }
> > - if (jw_global) {
> > - jsonw_end_array(jw_global);
> > - jsonw_destroy(&jw_global);
> > - }
> > + delete_json_obj();
> > + fflush(stdout);
> >
> > return 0;
> > }
> > diff --git a/bridge/mdb.c b/bridge/mdb.c
> > index da0282fdc91c..8c08baf570ec 100644
> > --- a/bridge/mdb.c
> > +++ b/bridge/mdb.c
> > @@ -14,12 +14,12 @@
> > #include <linux/if_ether.h>
> > #include <string.h>
> > #include <arpa/inet.h>
> > -#include <json_writer.h>
> >
> > #include "libnetlink.h"
> > #include "br_common.h"
> > #include "rt_names.h"
> > #include "utils.h"
> > +#include "json_print.h"
> >
> > #ifndef MDBA_RTA
> > #define MDBA_RTA(r) \
> > @@ -27,9 +27,6 @@
> > #endif
> >
> > static unsigned int filter_index, filter_vlan;
> > -json_writer_t *jw_global;
> > -static bool print_mdb_entries = true;
> > -static bool print_mdb_router = true;
> >
> > static void usage(void)
> > {
> > @@ -43,162 +40,131 @@ static bool is_temp_mcast_rtr(__u8 type)
> > return type == MDB_RTR_TYPE_TEMP_QUERY || type == MDB_RTR_TYPE_TEMP;
> > }
> >
> > +static const char *format_timer(__u32 ticks)
> > +{
> > + struct timeval tv;
> > + static char tbuf[32];
> > +
> > + __jiffies_to_tv(&tv, ticks);
> > + snprintf(tbuf, sizeof(tbuf), "%4lu.%.2lu",
> > + (unsigned long)tv.tv_sec,
> > + (unsigned long)tv.tv_usec / 10000);
> > +
> > + return tbuf;
> > +}
> > +
> > static void __print_router_port_stats(FILE *f, struct rtattr *pattr)
> > {
> > struct rtattr *tb[MDBA_ROUTER_PATTR_MAX + 1];
> > - struct timeval tv;
> > - __u8 type;
> >
> > parse_rtattr(tb, MDBA_ROUTER_PATTR_MAX, MDB_RTR_RTA(RTA_DATA(pattr)),
> > RTA_PAYLOAD(pattr) - RTA_ALIGN(sizeof(uint32_t)));
> > +
> > if (tb[MDBA_ROUTER_PATTR_TIMER]) {
> > - __jiffies_to_tv(&tv,
> > - rta_getattr_u32(tb[MDBA_ROUTER_PATTR_TIMER]));
> > - if (jw_global) {
> > - char formatted_time[9];
> > -
> > - snprintf(formatted_time, sizeof(formatted_time),
> > - "%4i.%.2i", (int)tv.tv_sec,
> > - (int)tv.tv_usec/10000);
> > - jsonw_string_field(jw_global, "timer", formatted_time);
> > - } else {
> > - fprintf(f, " %4i.%.2i",
> > - (int)tv.tv_sec, (int)tv.tv_usec/10000);
> > - }
> > + __u32 timer = rta_getattr_u32(tb[MDBA_ROUTER_PATTR_TIMER]);
> > +
> > + print_string(PRINT_ANY, "timer", " %s",
> > + format_timer(timer));
> > }
> > +
> > if (tb[MDBA_ROUTER_PATTR_TYPE]) {
> > - type = rta_getattr_u8(tb[MDBA_ROUTER_PATTR_TYPE]);
> > - if (jw_global)
> > - jsonw_string_field(jw_global, "type",
> > - is_temp_mcast_rtr(type) ? "temp" : "permanent");
> > - else
> > - fprintf(f, " %s",
> > - is_temp_mcast_rtr(type) ? "temp" : "permanent");
> > + __u8 type = rta_getattr_u8(tb[MDBA_ROUTER_PATTR_TYPE]);
> > +
> > + print_string(PRINT_ANY, "type", " %s",
> > + is_temp_mcast_rtr(type) ? "temp" : "permanent");
> > }
> > }
> >
> > -static void br_print_router_ports(FILE *f, struct rtattr *attr, __u32 brifidx)
> > +static void br_print_router_ports(FILE *f, struct rtattr *attr,
> > + const char *brifname)
> > {
> > - uint32_t *port_ifindex;
> > + int rem = RTA_PAYLOAD(attr);
> > struct rtattr *i;
> > - int rem;
> >
> > - rem = RTA_PAYLOAD(attr);
> > - if (jw_global) {
> > - jsonw_name(jw_global, ll_index_to_name(brifidx));
> > - jsonw_start_array(jw_global);
> > - for (i = RTA_DATA(attr); RTA_OK(i, rem); i = RTA_NEXT(i, rem)) {
> > - port_ifindex = RTA_DATA(i);
> > - jsonw_start_object(jw_global);
> > - jsonw_string_field(jw_global,
> > - "port",
> > - ll_index_to_name(*port_ifindex));
> > + if (is_json_context())
> > + open_json_array(PRINT_JSON, brifname);
> > + else if (!show_stats)
> > + fprintf(f, "router ports on %s: ", brifname);
> > +
> > + for (i = RTA_DATA(attr); RTA_OK(i, rem); i = RTA_NEXT(i, rem)) {
> > + uint32_t *port_ifindex = RTA_DATA(i);
> > + const char *port_ifname = ll_index_to_name(*port_ifindex);
> > +
> > + if (is_json_context()) {
> > + open_json_object(NULL);
> > + print_string(PRINT_JSON, "port", NULL, port_ifname);
> > +
> > if (show_stats)
> > __print_router_port_stats(f, i);
> > - jsonw_end_object(jw_global);
> > - }
> > - jsonw_end_array(jw_global);
> > - } else {
> > - if (!show_stats)
> > - fprintf(f, "router ports on %s: ",
> > - ll_index_to_name(brifidx));
> > - for (i = RTA_DATA(attr); RTA_OK(i, rem); i = RTA_NEXT(i, rem)) {
> > - port_ifindex = RTA_DATA(i);
> > - if (show_stats) {
> > - fprintf(f, "router ports on %s: %s",
> > - ll_index_to_name(brifidx),
> > - ll_index_to_name(*port_ifindex));
> > - __print_router_port_stats(f, i);
> > - fprintf(f, "\n");
> > - } else{
> > - fprintf(f, "%s ",
> > - ll_index_to_name(*port_ifindex));
> > - }
> > - }
> > - if (!show_stats)
> > + close_json_object();
> > + } else if (show_stats) {
> > + fprintf(f, "router ports on %s: %s",
> > + brifname, port_ifname);
> > +
> > + __print_router_port_stats(f, i);
> > fprintf(f, "\n");
> > + } else {
> > + fprintf(f, "%s ", port_ifname);
> > + }
> > }
> > + close_json_array(PRINT_JSON, NULL);
> > }
> >
> > -static void start_json_mdb_flags_array(bool *mdb_flags)
> > -{
> > - if (*mdb_flags)
> > - return;
> > - jsonw_name(jw_global, "flags");
> > - jsonw_start_array(jw_global);
> > - *mdb_flags = true;
> > -}
> > -
> > -static void print_mdb_entry(FILE *f, int ifindex, struct br_mdb_entry *e,
> > +static void print_mdb_entry(FILE *f, int ifindex, const struct br_mdb_entry *e,
> > struct nlmsghdr *n, struct rtattr **tb)
> > {
> > SPRINT_BUF(abuf);
> > + const char *dev;
> > const void *src;
> > int af;
> > - bool mdb_flags = false;
> >
> > if (filter_vlan && e->vid != filter_vlan)
> > return;
> > +
> > af = e->addr.proto == htons(ETH_P_IP) ? AF_INET : AF_INET6;
> > src = af == AF_INET ? (const void *)&e->addr.u.ip4 :
> > (const void *)&e->addr.u.ip6;
> > - if (jw_global)
> > - jsonw_start_object(jw_global);
> > - if (n->nlmsg_type == RTM_DELMDB) {
> > - if (jw_global)
> > - jsonw_string_field(jw_global, "opCode", "deleted");
> > - else
> > - fprintf(f, "Deleted ");
> > - }
> > - if (jw_global) {
> > - jsonw_string_field(jw_global, "dev", ll_index_to_name(ifindex));
> > - jsonw_string_field(jw_global,
> > - "port",
> > - ll_index_to_name(e->ifindex));
> > - jsonw_string_field(jw_global, "grp", inet_ntop(af, src,
> > - abuf, sizeof(abuf)));
> > - jsonw_string_field(jw_global, "state",
> > - (e->state & MDB_PERMANENT) ? "permanent" : "temp");
> > - if (e->flags & MDB_FLAGS_OFFLOAD) {
> > - start_json_mdb_flags_array(&mdb_flags);
> > - jsonw_string(jw_global, "offload");
> > - }
> > - if (mdb_flags)
> > - jsonw_end_array(jw_global);
> > - } else{
> > - fprintf(f, "dev %s port %s grp %s %s %s",
> > - ll_index_to_name(ifindex),
> > - ll_index_to_name(e->ifindex),
> > - inet_ntop(af, src, abuf, sizeof(abuf)),
> > - (e->state & MDB_PERMANENT) ? "permanent" : "temp",
> > - (e->flags & MDB_FLAGS_OFFLOAD) ? "offload" : "");
> > - }
> > - if (e->vid) {
> > - if (jw_global)
> > - jsonw_uint_field(jw_global, "vid", e->vid);
> > - else
> > - fprintf(f, " vid %hu", e->vid);
> > + dev = ll_index_to_name(ifindex);
> > +
> > + open_json_object(NULL);
> > +
> > + if (n->nlmsg_type == RTM_DELMDB)
> > + print_bool(PRINT_ANY, "deleted", "Deleted ", true);
> > +
> > +
> > + if (is_json_context()) {
> > + print_int(PRINT_JSON, "index", NULL, ifindex);
> > + print_string(PRINT_JSON, "dev", NULL, dev);
> > + } else {
> > + fprintf(f, "%u: ", ifindex);
> > + color_fprintf(f, COLOR_IFNAME, "%s ", dev);
> > }
> > - if (show_stats && tb && tb[MDBA_MDB_EATTR_TIMER]) {
> > - struct timeval tv;
> >
> > - __jiffies_to_tv(&tv, rta_getattr_u32(tb[MDBA_MDB_EATTR_TIMER]));
> > - if (jw_global) {
> > - char formatted_time[9];
> > + print_string(PRINT_ANY, "port", " %s ",
> > + ll_index_to_name(e->ifindex));
> >
> > - snprintf(formatted_time, sizeof(formatted_time),
> > - "%4i.%.2i", (int)tv.tv_sec,
> > - (int)tv.tv_usec/10000);
> > - jsonw_string_field(jw_global, "timer", formatted_time);
> > - } else {
> > - fprintf(f, "%4i.%.2i", (int)tv.tv_sec,
> > - (int)tv.tv_usec/10000);
> > - }
> > + print_color_string(PRINT_ANY, ifa_family_color(af),
> > + "grp", " %s ",
> > + inet_ntop(af, src, abuf, sizeof(abuf)));
> > +
> > + print_string(PRINT_ANY, "state", " %s ",
> > + (e->state & MDB_PERMANENT) ? "permanent" : "temp");
> > +
> > + open_json_array(PRINT_JSON, "flags");
> > + if (e->flags & MDB_FLAGS_OFFLOAD)
> > + print_string(PRINT_ANY, NULL, "%s ", "offload");
> > + close_json_array(PRINT_JSON, NULL);
> > +
> > + if (e->vid)
> > + print_uint(PRINT_ANY, "vid", " vid %u", e->vid);
> > +
> > + if (show_stats && tb && tb[MDBA_MDB_EATTR_TIMER]) {
> > + __u32 timer = rta_getattr_u32(tb[MDBA_MDB_EATTR_TIMER]);
> > +
> > + print_string(PRINT_ANY, "timer", " %s",
> > + format_timer(timer));
> > }
> > - if (jw_global)
> > - jsonw_end_object(jw_global);
> > - else
> > - fprintf(f, "\n");
> > + close_json_object();
> > }
> >
> > static void br_print_mdb_entry(FILE *f, int ifindex, struct rtattr *attr,
> > @@ -218,15 +184,60 @@ static void br_print_mdb_entry(FILE *f, int ifindex, struct rtattr *attr,
> > }
> > }
> >
> > +static void print_mdb_entries(FILE *fp, struct nlmsghdr *n,
> > + int ifindex, struct rtattr *mdb)
> > +{
> > + int rem = RTA_PAYLOAD(mdb);
> > + struct rtattr *i;
> > +
> > + open_json_array(PRINT_JSON, "mdb");
> > + for (i = RTA_DATA(mdb); RTA_OK(i, rem); i = RTA_NEXT(i, rem))
> > + br_print_mdb_entry(fp, ifindex, i, n);
> > + close_json_array(PRINT_JSON, NULL);
> > +}
> > +
> > +static void print_router_entries(FILE *fp, struct nlmsghdr *n,
> > + int ifindex, struct rtattr *router)
> > +{
> > + const char *brifname = ll_index_to_name(ifindex);
> > +
> > + open_json_array(PRINT_JSON, "router");
> > + if (n->nlmsg_type == RTM_GETMDB) {
> > + if (show_details)
> > + br_print_router_ports(fp, router, brifname);
> > + } else {
> > + struct rtattr *i = RTA_DATA(router);
> > + uint32_t *port_ifindex = RTA_DATA(i);
> > +
> > + if (is_json_context()) {
> > + open_json_array(PRINT_JSON, brifname);
> > + open_json_object(NULL);
> > +
> > + print_string(PRINT_JSON, "port", NULL,
> > + ll_index_to_name(*port_ifindex));
> > + close_json_object();
> > + close_json_array(PRINT_JSON, NULL);
> > + } else {
> > + fprintf(fp, "router port dev %s master %s\n",
> > + ll_index_to_name(*port_ifindex),
> > + brifname);
> > + }
> > + }
> > + close_json_array(PRINT_JSON, NULL);
> > +}
> > +
> > int print_mdb(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
> > {
> > FILE *fp = arg;
> > struct br_port_msg *r = NLMSG_DATA(n);
> > int len = n->nlmsg_len;
> > - struct rtattr *tb[MDBA_MAX+1], *i;
> > + struct rtattr *tb[MDBA_MAX+1];
> >
> > - if (n->nlmsg_type != RTM_GETMDB && n->nlmsg_type != RTM_NEWMDB && n->nlmsg_type != RTM_DELMDB) {
> > - fprintf(stderr, "Not RTM_GETMDB, RTM_NEWMDB or RTM_DELMDB: %08x %08x %08x\n",
> > + if (n->nlmsg_type != RTM_GETMDB &&
> > + n->nlmsg_type != RTM_NEWMDB &&
> > + n->nlmsg_type != RTM_DELMDB) {
> > + fprintf(stderr,
> > + "Not RTM_GETMDB, RTM_NEWMDB or RTM_DELMDB: %08x %08x %08x\n",
> > n->nlmsg_len, n->nlmsg_type, n->nlmsg_flags);
> >
> > return 0;
> > @@ -243,50 +254,14 @@ int print_mdb(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
> >
> > parse_rtattr(tb, MDBA_MAX, MDBA_RTA(r), n->nlmsg_len - NLMSG_LENGTH(sizeof(*r)));
> >
> > - if (tb[MDBA_MDB] && print_mdb_entries) {
> > - int rem = RTA_PAYLOAD(tb[MDBA_MDB]);
> > + if (n->nlmsg_type == RTM_DELMDB)
> > + print_bool(PRINT_ANY, "deleted", "Deleted ", true);
> >
> > - for (i = RTA_DATA(tb[MDBA_MDB]); RTA_OK(i, rem); i = RTA_NEXT(i, rem))
> > - br_print_mdb_entry(fp, r->ifindex, i, n);
> > - }
> > + if (tb[MDBA_MDB])
> > + print_mdb_entries(fp, n, r->ifindex, tb[MDBA_MDB]);
> >
> > - if (tb[MDBA_ROUTER] && print_mdb_router) {
> > - if (n->nlmsg_type == RTM_GETMDB) {
> > - if (show_details)
> > - br_print_router_ports(fp, tb[MDBA_ROUTER],
> > - r->ifindex);
> > - } else {
> > - uint32_t *port_ifindex;
> > -
> > - i = RTA_DATA(tb[MDBA_ROUTER]);
> > - port_ifindex = RTA_DATA(i);
> > - if (n->nlmsg_type == RTM_DELMDB) {
> > - if (jw_global)
> > - jsonw_string_field(jw_global,
> > - "opCode",
> > - "deleted");
> > - else
> > - fprintf(fp, "Deleted ");
> > - }
> > - if (jw_global) {
> > - jsonw_name(jw_global,
> > - ll_index_to_name(r->ifindex));
> > - jsonw_start_array(jw_global);
> > - jsonw_start_object(jw_global);
> > - jsonw_string_field(jw_global, "port",
> > - ll_index_to_name(*port_ifindex));
> > - jsonw_end_object(jw_global);
> > - jsonw_end_array(jw_global);
> > - } else {
> > - fprintf(fp, "router port dev %s master %s\n",
> > - ll_index_to_name(*port_ifindex),
> > - ll_index_to_name(r->ifindex));
> > - }
> > - }
> > - }
> > -
> > - if (!jw_global)
> > - fflush(fp);
> > + if (tb[MDBA_ROUTER])
> > + print_router_entries(fp, n, r->ifindex, tb[MDBA_ROUTER]);
> >
> > return 0;
> > }
> > @@ -319,62 +294,21 @@ static int mdb_show(int argc, char **argv)
> > }
> > }
> >
> > + new_json_obj(json);
> > +
> > /* get mdb entries*/
> > if (rtnl_wilddump_request(&rth, PF_BRIDGE, RTM_GETMDB) < 0) {
> > perror("Cannot send dump request");
> > return -1;
> > }
> >
> > - if (!json) {
> > - /* Normal output */
> > - if (rtnl_dump_filter(&rth, print_mdb, stdout) < 0) {
> > - fprintf(stderr, "Dump terminated\n");
> > - return -1;
> > - }
> > - return 0;
> > - }
> > -
> > - /* Json output */
> > - jw_global = jsonw_new(stdout);
> > - if (!jw_global) {
> > - fprintf(stderr, "Error allocation json object\n");
> > - exit(1);
> > - }
> > -
> > - if (pretty)
> > - jsonw_pretty(jw_global, 1);
> > -
> > - jsonw_start_object(jw_global);
> > - jsonw_name(jw_global, "mdb");
> > - jsonw_start_array(jw_global);
> > -
> > - /* print mdb entries */
> > - print_mdb_entries = true;
> > - print_mdb_router = false;
> > if (rtnl_dump_filter(&rth, print_mdb, stdout) < 0) {
> > fprintf(stderr, "Dump terminated\n");
> > return -1;
> > }
> > - jsonw_end_array(jw_global);
> > -
> > - /* get router ports */
> > - if (rtnl_wilddump_request(&rth, PF_BRIDGE, RTM_GETMDB) < 0) {
> > - perror("Cannot send dump request");
> > - return -1;
> > - }
> > - jsonw_name(jw_global, "router");
> > - jsonw_start_object(jw_global);
> >
> > - /* print router ports */
> > - print_mdb_entries = false;
> > - print_mdb_router = true;
> > - if (rtnl_dump_filter(&rth, print_mdb, stdout) < 0) {
> > - fprintf(stderr, "Dump terminated\n");
> > - return -1;
> > - }
> > - jsonw_end_object(jw_global);
> > - jsonw_end_object(jw_global);
> > - jsonw_destroy(&jw_global);
> > + delete_json_obj();
> > + fflush(stdout);
> >
> > return 0;
> > }
> > diff --git a/bridge/vlan.c b/bridge/vlan.c
> > index 7c8b3ad54857..9f4a7a2be55c 100644
> > --- a/bridge/vlan.c
> > +++ b/bridge/vlan.c
> > @@ -8,19 +8,16 @@
> > #include <netinet/in.h>
> > #include <linux/if_bridge.h>
> > #include <linux/if_ether.h>
> > -#include <json_writer.h>
> > #include <string.h>
> >
> > +#include "json_print.h"
> > #include "libnetlink.h"
> > #include "br_common.h"
> > #include "utils.h"
> >
> > static unsigned int filter_index, filter_vlan;
> > -static int last_ifidx = -1;
> > static int show_vlan_tunnel_info = 0;
> >
> > -json_writer_t *jw_global;
> > -
> > static void usage(void)
> > {
> > fprintf(stderr,
> > @@ -257,38 +254,33 @@ static int filter_vlan_check(__u16 vid, __u16 flags)
> >
> > static void print_vlan_port(FILE *fp, int ifi_index)
> > {
> > - if (jw_global) {
> > - jsonw_name(jw_global,
> > - ll_index_to_name(ifi_index));
> > - jsonw_start_array(jw_global);
> > - } else {
> > - fprintf(fp, "%s",
> > - ll_index_to_name(ifi_index));
> > - }
> > + print_string(PRINT_ANY, NULL, "%s",
> > + ll_index_to_name(ifi_index));
> > }
> >
>
> Stephen, this seems to have broken both json and non-json output.
>
> Here is some output before and after the patch (same thing for tunnelshow):
>
> before:
> $bridge vlan show
> port vlan ids
> hostbond4 1000
> 1001 PVID Egress Untagged
> 1002
> 1003
> 1004
>
> hostbond3 1000 PVID Egress Untagged
> 1001
> 1002
> 1003
> 1004
>
> bridge 1 PVID Egress Untagged
> 1000
> 1001
> 1002
> 1003
> 1004
>
> vxlan0 1 PVID Egress Untagged
> 1000
> 1001
> 1002
> 1003
> 1004
>
>
> $ bridge -j -c vlan show
> {
> "hostbond4": [{
> "vlan": 1000
> },{
> "vlan": 1001,
> "flags": ["PVID","Egress Untagged"
> ]
> },{
> "vlan": 1002,
> "vlanEnd": 1004
> }
> ],
> "hostbond3": [{
> "vlan": 1000,
> "flags": ["PVID","Egress Untagged"
> ]
> },{
> "vlan": 1001,
> "vlanEnd": 1004
> }
> ],
> "bridge": [{
> "vlan": 1,
> "flags": ["PVID","Egress Untagged"
> ]
> },{
> "vlan": 1000,
> "vlanEnd": 1004
> }
> ],
> "vxlan0": [{
> "vlan": 1,
> "flags": ["PVID","Egress Untagged"
> ]
> },{
> "vlan": 1000,
> "vlanEnd": 1004
> }
> ]
> }
>
>
> after:
> ====
>
> $bridge vlan show
> port vlan ids
> hostbond4
> 1000 1001 PVID untagged 1002 1003 1004
> hostbond3
> 1000 PVID untagged 1001 1002 1003 1004
> bridge
> 1 PVID untagged 1000 1001 1002 1003 1004
> vxlan0
> 1 PVID untagged 1000 1001 1002 1003 1004
>
> $bridge -j -c vlan show
> ["hostbond4","vlan":[{"vlan":1000},{"vlan":1001,"pvid":null,"untagged":null},{"vlan":1002},{"vlan":1003},{"vlan":1004}],"hostbond3","vlan":[{"vlan":1000,"pvid":null,"untagged":null},{"vlan":1001},{"vlan":1002},{"vlan":1003},{"vlan":1004}],"bridge","vlan":[{"vlan":1,"pvid":null,"untagged":null},{"vlan":1000},{"vlan":1001},{"vlan":1002},{"vlan":1003},{"vlan":1004}],"vxlan0","vlan":[{"vlan":1,"pvid":null,"untagged":null},{"vlan":1000},{"vlan":1001},{"vlan":1002},{"vlan":1003},{"vlan":1004}]]
I can fix it.
^ permalink raw reply
* Fw: [Bug 200943] New: Repeating tcp_mark_head_lost in dmesg
From: Stephen Hemminger @ 2018-08-29 15:02 UTC (permalink / raw)
To: netdev
Begin forwarded message:
Date: Sun, 26 Aug 2018 22:24:12 +0000
From: bugzilla-daemon@bugzilla.kernel.org
To: stephen@networkplumber.org
Subject: [Bug 200943] New: Repeating tcp_mark_head_lost in dmesg
https://bugzilla.kernel.org/show_bug.cgi?id=200943
Bug ID: 200943
Summary: Repeating tcp_mark_head_lost in dmesg
Product: Networking
Version: 2.5
Kernel Version: 4.14.66
Hardware: All
OS: Linux
Tree: Mainline
Status: NEW
Severity: normal
Priority: P1
Component: IPV4
Assignee: stephen@networkplumber.org
Reporter: rm+bko@romanrm.net
Regression: No
Getting a bunch of these now every hour during continuous ~100 Mbit of network
traffic.
What's up with that? Seems harmless, as in the kernel doesn't crash and the
network connection is not interrupted. (Maybe the particular TCP session is?)
If there are no ill-effects from this condition, is such spammy WARN_ON really
necessary?
[Mon Aug 27 02:16:11 2018] ------------[ cut here ]------------
[Mon Aug 27 02:16:11 2018] WARNING: CPU: 5 PID: 0 at net/ipv4/tcp_input.c:2263
tcp_mark_head_lost+0x247/0x260
[Mon Aug 27 02:16:11 2018] Modules linked in: dm_snapshot loop vhost_net vhost
tap tun ip6t_MASQUERADE nf_nat_masquerade_ipv6 ipt_MASQUERADE
nf_nat_masquerade_ipv4 xt_DSCP xt_mark ip6t_REJECT nf_reject_ipv6 ipt_REJECT
nf_reject_ipv4 xt_owner xt_tcpudp xt_set ip_set_hash_net ip_set nfnetlink
xt_limit xt_length xt_multiport xt_conntrack ip6t_rpfilter ipt_rpfilter
ip6table_nat nf_conntrack_ipv6 nf_defrag_ipv6 nf_nat_ipv6 ip6table_raw
wireguard ip6_udp_tunnel udp_tunnel ip6table_mangle iptable_nat
nf_conntrack_ipv4 nf_defrag_ipv4 nf_nat_ipv4 nf_nat nf_conntrack iptable_raw
iptable_mangle ip6table_filter ip6_tables matroxfb_base matroxfb_g450
matroxfb_Ti3026 matroxfb_accel matroxfb_DAC1064 g450_pll matroxfb_misc
iptable_filter ip_tables x_tables cpufreq_powersave cpufreq_userspace
cpufreq_conservative 8021q garp mrp
[Mon Aug 27 02:16:11 2018] bridge stp llc bonding tcp_bbr sch_fq tcp_illinois
fuse radeon ttm drm_kms_helper drm i2c_algo_bit it87 hwmon_vid eeepc_wmi
asus_wmi sparse_keymap rfkill video wmi_bmof mxm_wmi edac_mce_amd kvm_amd kvm
snd_pcm snd_timer snd soundcore joydev evdev pcspkr k10temp fam15h_power
sp5100_tco sg shpchp wmi pcc_cpufreq acpi_cpufreq button ext4 crc16 mbcache
jbd2 fscrypto btrfs zstd_decompress zstd_compress xxhash algif_skcipher af_alg
dm_crypt dm_thin_pool dm_persistent_data dm_bio_prison dm_bufio dm_mod
hid_generic usbhid hid raid10 raid456 async_raid6_recov async_memcpy async_pq
async_xor async_tx xor sd_mod raid6_pq libcrc32c crc32c_generic raid1 raid0
multipath linear md_mod vfio_pci irqbypass vfio_virqfd vfio_iommu_type1 vfio
ohci_pci crct10dif_pclmul crc32_pclmul crc32c_intel ghash_clmulni_intel
[Mon Aug 27 02:16:11 2018] pcbc aesni_intel aes_x86_64 crypto_simd glue_helper
cryptd r8169 ahci xhci_pci libahci ohci_hcd ehci_pci mii xhci_hcd ehci_hcd
i2c_piix4 libata usbcore scsi_mod bnx2
[Mon Aug 27 02:16:11 2018] CPU: 5 PID: 0 Comm: swapper/5 Tainted: G W
4.14.66-rm1+ #132
[Mon Aug 27 02:16:11 2018] Hardware name: To be filled by O.E.M. To be filled
by O.E.M./SABERTOOTH 990FX R2.0, BIOS 2901 05/04/2016
[Mon Aug 27 02:16:11 2018] task: ffff8ba79c679dc0 task.stack: ffffb4d741928000
[Mon Aug 27 02:16:11 2018] RIP: 0010:tcp_mark_head_lost+0x247/0x260
[Mon Aug 27 02:16:11 2018] RSP: 0018:ffff8ba7aed437d8 EFLAGS: 00010202
[Mon Aug 27 02:16:11 2018] RAX: 0000000000000018 RBX: ffff8ba3901a0800 RCX:
0000000000000000
[Mon Aug 27 02:16:11 2018] RDX: 0000000000000017 RSI: 0000000000000001 RDI:
ffff8ba4d47e9000
[Mon Aug 27 02:16:11 2018] RBP: ffff8ba4d47e9000 R08: 000000000000000d R09:
0000000000000000
[Mon Aug 27 02:16:11 2018] R10: 000000000000100c R11: 0000000000000000 R12:
0000000000000001
[Mon Aug 27 02:16:11 2018] R13: ffff8ba4d47e9158 R14: 0000000000000001 R15:
000000009d0b6708
[Mon Aug 27 02:16:11 2018] FS: 0000000000000000(0000)
GS:ffff8ba7aed40000(0000) knlGS:0000000000000000
[Mon Aug 27 02:16:11 2018] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[Mon Aug 27 02:16:11 2018] CR2: 0000000001fbdff0 CR3: 000000040c8d6000 CR4:
00000000000406e0
[Mon Aug 27 02:16:11 2018] Call Trace:
[Mon Aug 27 02:16:11 2018] <IRQ>
[Mon Aug 27 02:16:11 2018] tcp_fastretrans_alert+0x5c3/0xa20
[Mon Aug 27 02:16:11 2018] tcp_ack+0x95a/0x1170
[Mon Aug 27 02:16:11 2018] ? __slab_free.isra.70+0x79/0x200
[Mon Aug 27 02:16:11 2018] tcp_rcv_established+0x16a/0x5a0
[Mon Aug 27 02:16:11 2018] ? tcp_v4_inbound_md5_hash+0x76/0x1e0
[Mon Aug 27 02:16:11 2018] tcp_v4_do_rcv+0x130/0x1f0
[Mon Aug 27 02:16:11 2018] tcp_v4_rcv+0x9ac/0xaa0
[Mon Aug 27 02:16:11 2018] ip_local_deliver_finish+0x9a/0x1c0
[Mon Aug 27 02:16:11 2018] ip_local_deliver+0x6b/0xe0
[Mon Aug 27 02:16:11 2018] ? ip_rcv_finish+0x440/0x440
[Mon Aug 27 02:16:11 2018] ip_rcv+0x2b0/0x3c0
[Mon Aug 27 02:16:11 2018] ? inet_del_offload+0x50/0x50
[Mon Aug 27 02:16:11 2018] __netif_receive_skb_core+0x85f/0xb50
[Mon Aug 27 02:16:11 2018] ? br_allowed_egress+0x2d/0x50 [bridge]
[Mon Aug 27 02:16:11 2018] ? br_forward+0x49/0xe0 [bridge]
[Mon Aug 27 02:16:11 2018] ? br_vlan_lookup+0xdd/0x150 [bridge]
[Mon Aug 27 02:16:11 2018] netif_receive_skb_internal+0x34/0xe0
[Mon Aug 27 02:16:11 2018] ? br_handle_vlan+0x4b/0xf0 [bridge]
[Mon Aug 27 02:16:11 2018] br_pass_frame_up+0xd4/0x180 [bridge]
[Mon Aug 27 02:16:11 2018] ? br_allowed_ingress+0x1ea/0x2e0 [bridge]
[Mon Aug 27 02:16:11 2018] br_handle_frame_finish+0x23f/0x530 [bridge]
[Mon Aug 27 02:16:11 2018] ? get_partial_node.isra.69+0x13c/0x1d0
[Mon Aug 27 02:16:11 2018] br_handle_frame+0x1b7/0x320 [bridge]
[Mon Aug 27 02:16:11 2018] __netif_receive_skb_core+0x367/0xb50
[Mon Aug 27 02:16:11 2018] ? inet_gro_receive+0x203/0x2b0
[Mon Aug 27 02:16:11 2018] netif_receive_skb_internal+0x34/0xe0
[Mon Aug 27 02:16:11 2018] napi_gro_receive+0xb8/0xe0
[Mon Aug 27 02:16:11 2018] bnx2_poll_work+0x71a/0x12e0 [bnx2]
[Mon Aug 27 02:16:11 2018] bnx2_poll_msix+0x41/0xf0 [bnx2]
[Mon Aug 27 02:16:11 2018] net_rx_action+0x28c/0x3f0
[Mon Aug 27 02:16:11 2018] __do_softirq+0x10a/0x2a2
[Mon Aug 27 02:16:11 2018] irq_exit+0xbe/0xd0
[Mon Aug 27 02:16:11 2018] do_IRQ+0x66/0x100
[Mon Aug 27 02:16:11 2018] common_interrupt+0x7d/0x7d
[Mon Aug 27 02:16:11 2018] </IRQ>
[Mon Aug 27 02:16:11 2018] RIP: 0010:cpuidle_enter_state+0xa4/0x2d0
[Mon Aug 27 02:16:11 2018] RSP: 0018:ffffb4d74192bea0 EFLAGS: 00000246
ORIG_RAX: ffffffffffffff1a
[Mon Aug 27 02:16:11 2018] RAX: ffff8ba7aed61800 RBX: 0000f8f2a31961cb RCX:
000000000000001f
[Mon Aug 27 02:16:11 2018] RDX: 0000f8f2a31961cb RSI: fffffff1cd4e0887 RDI:
0000000000000000
[Mon Aug 27 02:16:11 2018] RBP: 0000000000000002 R08: 000000000000000a R09:
000000000000000a
[Mon Aug 27 02:16:11 2018] R10: 0000000000000364 R11: 00000000000002a6 R12:
ffff8ba7961b3200
[Mon Aug 27 02:16:11 2018] R13: ffffffff90cb2c58 R14: 0000f8f2a3139a63 R15:
ffffffff90cb2b80
[Mon Aug 27 02:16:11 2018] do_idle+0x19d/0x200
[Mon Aug 27 02:16:11 2018] cpu_startup_entry+0x6f/0x80
[Mon Aug 27 02:16:11 2018] start_secondary+0x1ae/0x200
[Mon Aug 27 02:16:11 2018] secondary_startup_64+0xa5/0xb0
[Mon Aug 27 02:16:11 2018] Code: e8 df aa 00 00 85 c0 78 0c 0f b6 43 39 44 89
e6 e9 16 ff ff ff 8b 95 ec 05 00 00 8b 85 80 06 00 00 03 85 84 06 00 00 39 d0
76 a7 <0f> 0b eb a3 31 f6 e9 12 fe ff ff 66 66 2e 0f 1f 84 00 00 00 00
[Mon Aug 27 02:16:11 2018] ---[ end trace 3d7c0b943ef03b6a ]---
--
You are receiving this mail because:
You are the assignee for the bug.
^ permalink raw reply
* Fw: [Bug 200967] New: No network with U.S. Robotics USR997902
From: Stephen Hemminger @ 2018-08-29 15:02 UTC (permalink / raw)
To: netdev
Begin forwarded message:
Date: Wed, 29 Aug 2018 04:36:20 +0000
From: bugzilla-daemon@bugzilla.kernel.org
To: stephen@networkplumber.org
Subject: [Bug 200967] New: No network with U.S. Robotics USR997902
https://bugzilla.kernel.org/show_bug.cgi?id=200967
Bug ID: 200967
Summary: No network with U.S. Robotics USR997902
Product: Networking
Version: 2.5
Kernel Version: 4.18.5
Hardware: x86-64
OS: Linux
Tree: Mainline
Status: NEW
Severity: normal
Priority: P1
Component: IPV4
Assignee: stephen@networkplumber.org
Reporter: kyrimis@alumni.princeton.edu
Regression: No
Created attachment 278193
--> https://bugzilla.kernel.org/attachment.cgi?id=278193&action=edit
dmesg and hwinfo output
(I am reporting this upstream as instructed by OpenSUSE, where I had originally
reported this problem.)
After upgrading to kernel 4.18 (originally noticed the problem with kernel
4.18.0, the problem persists with kernel 4.18.5), I could no longer connect to
the network.
A similar machine, which I upgraded at the same time, had no problem, so I
thought that the problem might be due to my using a network card instead of the
motherboard's built-in network controller. Sure enough, configuring the
built-in controller and connecting that to the network worked fine.
According to lspci, the card that doesn't work with the new kernel is:
U.S. Robotics USR997902 10/100/1000 Mbps PCI Network Card (rev 10)
Ifconfig shows that the network controller has been recognized as such, but
that it has not obtained an IP address.
The problem did not occur with kernel 4.17.14.
I have attached the output of hwinfo and dmesg for kernels 4.17.14 and 4.18.5,
with the network cable connected to the U.S. Robotics controller (enp5s0).
--
You are receiving this mail because:
You are the assignee for the bug.
^ permalink raw reply
* [PATCH 2/2] net: ethernet: cpsw-phy-sel: prefer phandle for phy sel
From: Tony Lindgren @ 2018-08-29 15:00 UTC (permalink / raw)
To: David Miller
Cc: netdev, linux-omap, devicetree, Andrew Lunn, Grygorii Strashko,
Ivan Khoronzhuk, Mark Rutland, Murali Karicheri, Rob Herring
In-Reply-To: <20180829150024.43210-1-tony@atomide.com>
The cpsw-phy-sel device is not a child of the cpsw interconnect target
module. It lives in the system control module.
Let's fix this issue by trying to use cpsw-phy-sel phandle first if it
exists and if not fall back to current usage of trying to find the
cpsw-phy-sel child. That way the phy sel driver can be a child of the
system control module where it belongs in the device tree.
Without this fix, we cannot have a proper interconnect target module
hierarchy in device tree for things like genpd.
Note that deferred probe is mostly not supported by cpsw and this patch
does not attempt to fix that. In case deferred probe support is needed,
this could be added to cpsw_slave_open() and phy_connect() so they start
handling and returning errors.
For documenting it, looks like the cpsw-phy-sel is used for all cpsw device
tree nodes. It's missing the related binding documentation, so let's also
update the binding documentation accordingly.
Cc: devicetree@vger.kernel.org
Cc: Andrew Lunn <andrew@lunn.ch>
Cc: Grygorii Strashko <grygorii.strashko@ti.com>
Cc: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Murali Karicheri <m-karicheri2@ti.com>
Cc: Rob Herring <robh+dt@kernel.org>
Signed-off-by: Tony Lindgren <tony@atomide.com>
---
drivers/net/ethernet/ti/cpsw-phy-sel.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/ti/cpsw-phy-sel.c b/drivers/net/ethernet/ti/cpsw-phy-sel.c
--- a/drivers/net/ethernet/ti/cpsw-phy-sel.c
+++ b/drivers/net/ethernet/ti/cpsw-phy-sel.c
@@ -170,10 +170,13 @@ void cpsw_phy_sel(struct device *dev, phy_interface_t phy_mode, int slave)
struct device_node *node;
struct cpsw_phy_sel_priv *priv;
- node = of_get_child_by_name(dev->of_node, "cpsw-phy-sel");
+ node = of_parse_phandle(dev->of_node, "cpsw-phy-sel", 0);
if (!node) {
- dev_err(dev, "Phy mode driver DT not found\n");
- return;
+ node = of_get_child_by_name(dev->of_node, "cpsw-phy-sel");
+ if (!node) {
+ dev_err(dev, "Phy mode driver DT not found\n");
+ return;
+ }
}
dev = bus_find_device(&platform_bus_type, NULL, node, match);
--
2.18.0
^ permalink raw reply
* [PATCH 1/2] dt-bindings: net: cpsw: Document cpsw-phy-sel usage but prefer phandle
From: Tony Lindgren @ 2018-08-29 15:00 UTC (permalink / raw)
To: David Miller
Cc: netdev, linux-omap, devicetree, Andrew Lunn, Grygorii Strashko,
Ivan Khoronzhuk, Mark Rutland, Murali Karicheri, Rob Herring
The current cpsw usage for cpsw-phy-sel is undocumented but is used for
all the boards using cpsw. And cpsw-phy-sel is not really a child of
the cpsw device, it lives in the system control module instead.
Let's document the existing usage, and improve it a bit where we prefer
to use a phandle instead of a child device for it. That way we can
properly describe the hardware in dts files for things like genpd.
Cc: devicetree@vger.kernel.org
Cc: Andrew Lunn <andrew@lunn.ch>
Cc: Grygorii Strashko <grygorii.strashko@ti.com>
Cc: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Murali Karicheri <m-karicheri2@ti.com>
Cc: Rob Herring <robh+dt@kernel.org>
Signed-off-by: Tony Lindgren <tony@atomide.com>
---
Documentation/devicetree/bindings/net/cpsw.txt | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/Documentation/devicetree/bindings/net/cpsw.txt b/Documentation/devicetree/bindings/net/cpsw.txt
--- a/Documentation/devicetree/bindings/net/cpsw.txt
+++ b/Documentation/devicetree/bindings/net/cpsw.txt
@@ -19,6 +19,10 @@ Required properties:
- slaves : Specifies number for slaves
- active_slave : Specifies the slave to use for time stamping,
ethtool and SIOCGMIIPHY
+- cpsw-phy-sel : Specifies the phandle to the CPSW phy mode selection
+ device. See also cpsw-phy-sel.txt for it's binding.
+ Note that in legacy cases cpsw-phy-sel may be
+ a child device instead of a phandle.
Optional properties:
- ti,hwmods : Must be "cpgmac0"
@@ -75,6 +79,7 @@ Examples:
cpts_clock_mult = <0x80000000>;
cpts_clock_shift = <29>;
syscon = <&cm>;
+ cpsw-phy-sel = <&phy_sel>;
cpsw_emac0: slave@0 {
phy_id = <&davinci_mdio>, <0>;
phy-mode = "rgmii-txid";
@@ -103,6 +108,7 @@ Examples:
cpts_clock_mult = <0x80000000>;
cpts_clock_shift = <29>;
syscon = <&cm>;
+ cpsw-phy-sel = <&phy_sel>;
cpsw_emac0: slave@0 {
phy_id = <&davinci_mdio>, <0>;
phy-mode = "rgmii-txid";
--
2.18.0
^ permalink raw reply
* [PATCH bpf 3/3] bpf: fix sg shift repair start offset in bpf_msg_pull_data
From: Daniel Borkmann @ 2018-08-29 14:50 UTC (permalink / raw)
To: alexei.starovoitov; +Cc: john.fastabend, netdev, Daniel Borkmann
In-Reply-To: <20180829145036.5514-1-daniel@iogearbox.net>
When we perform the sg shift repair for the scatterlist ring, we
currently start out at i = first_sg + 1. However, this is not
correct since the first_sg could point to the sge sitting at slot
MAX_SKB_FRAGS - 1, and a subsequent i = MAX_SKB_FRAGS will access
the scatterlist ring (sg) out of bounds. Add the sk_msg_iter_var()
helper for iterating through the ring, and apply the same rule
for advancing to the next ring element as we do elsewhere. Later
work will use this helper also in other places.
Fixes: 015632bb30da ("bpf: sk_msg program helper bpf_sk_msg_pull_data")
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: John Fastabend <john.fastabend@gmail.com>
---
net/core/filter.c | 26 +++++++++++++-------------
1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/net/core/filter.c b/net/core/filter.c
index 43ba5f8..2c7801f 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -2282,6 +2282,13 @@ static const struct bpf_func_proto bpf_msg_cork_bytes_proto = {
.arg2_type = ARG_ANYTHING,
};
+#define sk_msg_iter_var(var) \
+ do { \
+ var++; \
+ if (var == MAX_SKB_FRAGS) \
+ var = 0; \
+ } while (0)
+
BPF_CALL_4(bpf_msg_pull_data,
struct sk_msg_buff *, msg, u32, start, u32, end, u64, flags)
{
@@ -2302,9 +2309,7 @@ BPF_CALL_4(bpf_msg_pull_data,
if (start < offset + len)
break;
offset += len;
- i++;
- if (i == MAX_SKB_FRAGS)
- i = 0;
+ sk_msg_iter_var(i);
} while (i != msg->sg_end);
if (unlikely(start >= offset + len))
@@ -2330,9 +2335,7 @@ BPF_CALL_4(bpf_msg_pull_data,
*/
do {
copy += sg[i].length;
- i++;
- if (i == MAX_SKB_FRAGS)
- i = 0;
+ sk_msg_iter_var(i);
if (bytes_sg_total <= copy)
break;
} while (i != msg->sg_end);
@@ -2358,9 +2361,7 @@ BPF_CALL_4(bpf_msg_pull_data,
sg[i].length = 0;
put_page(sg_page(&sg[i]));
- i++;
- if (i == MAX_SKB_FRAGS)
- i = 0;
+ sk_msg_iter_var(i);
} while (i != last_sg);
sg[first_sg].length = copy;
@@ -2377,7 +2378,8 @@ BPF_CALL_4(bpf_msg_pull_data,
if (!shift)
goto out;
- i = first_sg + 1;
+ i = first_sg;
+ sk_msg_iter_var(i);
do {
int move_from;
@@ -2394,9 +2396,7 @@ BPF_CALL_4(bpf_msg_pull_data,
sg[move_from].page_link = 0;
sg[move_from].offset = 0;
- i++;
- if (i == MAX_SKB_FRAGS)
- i = 0;
+ sk_msg_iter_var(i);
} while (1);
msg->sg_end -= shift;
if (msg->sg_end < 0)
--
2.9.5
^ permalink raw reply related
* [PATCH bpf 2/3] bpf: fix shift upon scatterlist ring wrap-around in bpf_msg_pull_data
From: Daniel Borkmann @ 2018-08-29 14:50 UTC (permalink / raw)
To: alexei.starovoitov; +Cc: john.fastabend, netdev, Daniel Borkmann
In-Reply-To: <20180829145036.5514-1-daniel@iogearbox.net>
If first_sg and last_sg wraps around in the scatterlist ring, then we
need to account for that in the shift as well. E.g. crafting such msgs
where this is the case leads to a hang as shift becomes negative. E.g.
consider the following scenario:
first_sg := 14 |=> shift := -12 msg->sg_start := 10
last_sg := 3 | msg->sg_end := 5
round 1: i := 15, move_from := 3, sg[15] := sg[ 3]
round 2: i := 0, move_from := -12, sg[ 0] := sg[-12]
round 3: i := 1, move_from := -11, sg[ 1] := sg[-11]
round 4: i := 2, move_from := -10, sg[ 2] := sg[-10]
[...]
round 13: i := 11, move_from := -1, sg[ 2] := sg[ -1]
round 14: i := 12, move_from := 0, sg[ 2] := sg[ 0]
round 15: i := 13, move_from := 1, sg[ 2] := sg[ 1]
round 16: i := 14, move_from := 2, sg[ 2] := sg[ 2]
round 17: i := 15, move_from := 3, sg[ 2] := sg[ 3]
[...]
This means we will loop forever and never hit the msg->sg_end condition
to break out of the loop. When we see that the ring wraps around, then
the shift should be MAX_SKB_FRAGS - first_sg + last_sg - 1. Meaning,
the remainder slots from the tail of the ring and the head until last_sg
combined.
Fixes: 015632bb30da ("bpf: sk_msg program helper bpf_sk_msg_pull_data")
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: John Fastabend <john.fastabend@gmail.com>
---
net/core/filter.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/net/core/filter.c b/net/core/filter.c
index b9225c5..43ba5f8 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -2370,7 +2370,10 @@ BPF_CALL_4(bpf_msg_pull_data,
* had a single entry though we can just replace it and
* be done. Otherwise walk the ring and shift the entries.
*/
- shift = last_sg - first_sg - 1;
+ WARN_ON_ONCE(last_sg == first_sg);
+ shift = last_sg > first_sg ?
+ last_sg - first_sg - 1 :
+ MAX_SKB_FRAGS - first_sg + last_sg - 1;
if (!shift)
goto out;
--
2.9.5
^ permalink raw reply related
* [PATCH bpf 1/3] bpf: fix msg->data/data_end after sg shift repair in bpf_msg_pull_data
From: Daniel Borkmann @ 2018-08-29 14:50 UTC (permalink / raw)
To: alexei.starovoitov; +Cc: john.fastabend, netdev, Daniel Borkmann
In-Reply-To: <20180829145036.5514-1-daniel@iogearbox.net>
In the current code, msg->data is set as sg_virt(&sg[i]) + start - offset
and msg->data_end relative to it as msg->data + bytes. Using iterator i
to point to the updated starting scatterlist element holds true for some
cases, however not for all where we'd end up pointing out of bounds. It
is /correct/ for these ones:
1) When first finding the starting scatterlist element (sge) where we
find that the page is already privately owned by the msg and where
the requested bytes and headroom fit into the sge's length.
However, it's /incorrect/ for the following ones:
2) After we made the requested area private and updated the newly allocated
page into first_sg slot of the scatterlist ring; when we find that no
shift repair of the ring is needed where we bail out updating msg->data
and msg->data_end. At that point i will point to last_sg, which in this
case is the next elem of first_sg in the ring. The sge at that point
might as well be invalid (e.g. i == msg->sg_end), which we use for
setting the range of sg_virt(&sg[i]). The correct one would have been
first_sg.
3) Similar as in 2) but when we find that a shift repair of the ring is
needed. In this case we fix up all sges and stop once we've reached the
end. In this case i will point to will point to the new msg->sg_end,
and the sge at that point will be invalid. Again here the requested
range sits in first_sg.
Fixes: 015632bb30da ("bpf: sk_msg program helper bpf_sk_msg_pull_data")
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: John Fastabend <john.fastabend@gmail.com>
---
net/core/filter.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/net/core/filter.c b/net/core/filter.c
index ec4d67c..b9225c5 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -2310,6 +2310,7 @@ BPF_CALL_4(bpf_msg_pull_data,
if (unlikely(start >= offset + len))
return -EINVAL;
+ first_sg = i;
/* The start may point into the sg element so we need to also
* account for the headroom.
*/
@@ -2317,8 +2318,6 @@ BPF_CALL_4(bpf_msg_pull_data,
if (!msg->sg_copy[i] && bytes_sg_total <= len)
goto out;
- first_sg = i;
-
/* At this point we need to linearize multiple scatterlist
* elements or a single shared page. Either way we need to
* copy into a linear buffer exclusively owned by BPF. Then
@@ -2400,7 +2399,7 @@ BPF_CALL_4(bpf_msg_pull_data,
if (msg->sg_end < 0)
msg->sg_end += MAX_SKB_FRAGS;
out:
- msg->data = sg_virt(&sg[i]) + start - offset;
+ msg->data = sg_virt(&sg[first_sg]) + start - offset;
msg->data_end = msg->data + bytes;
return 0;
--
2.9.5
^ permalink raw reply related
* [PATCH bpf 0/3] Three fixes for bpf_msg_pull_data
From: Daniel Borkmann @ 2018-08-29 14:50 UTC (permalink / raw)
To: alexei.starovoitov; +Cc: john.fastabend, netdev, Daniel Borkmann
This set contains three more fixes for the bpf_msg_pull_data()
mainly for correcting scatterlist ring wrap-arounds as well as
fixing up data pointers. For details please see individual patches.
Thanks!
Daniel Borkmann (3):
bpf: fix msg->data/data_end after sg shift repair in bpf_msg_pull_data
bpf: fix shift upon scatterlist ring wrap-around in bpf_msg_pull_data
bpf: fix sg shift repair start offset in bpf_msg_pull_data
net/core/filter.c | 36 +++++++++++++++++++-----------------
1 file changed, 19 insertions(+), 17 deletions(-)
--
2.9.5
^ permalink raw reply
* [PATCH] ieee802154: mcr20a: read out of bounds in mcr20a_set_channel()
From: Dan Carpenter @ 2018-08-29 14:49 UTC (permalink / raw)
To: Xue Liu
Cc: Alexander Aring, Stefan Schmidt, David S. Miller, linux-wpan,
netdev, kernel-janitors
The "channel" variable can be any u8 value. We need to make sure we
don't read outside of the PLL_INT[] or PLL_FRAC[] arrays.
Fixes: 8c6ad9cc5157 ("ieee802154: Add NXP MCR20A IEEE 802.15.4 transceiver driver")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
This patch is obviously harmless, but it's from static analysis. I'm
pretty sure this is required, but I can't swear.
diff --git a/drivers/net/ieee802154/mcr20a.c b/drivers/net/ieee802154/mcr20a.c
index e428277781ac..4f41d1d3588e 100644
--- a/drivers/net/ieee802154/mcr20a.c
+++ b/drivers/net/ieee802154/mcr20a.c
@@ -512,6 +512,9 @@ mcr20a_set_channel(struct ieee802154_hw *hw, u8 page, u8 channel)
dev_dbg(printdev(lp), "%s\n", __func__);
+ if (channel < 11 || channel - 11 >= ARRAY_SIZE(PLL_INT))
+ return -EINVAL;
+
/* freqency = ((PLL_INT+64) + (PLL_FRAC/65536)) * 32 MHz */
ret = regmap_write(lp->regmap_dar, DAR_PLL_INT0, PLL_INT[channel - 11]);
if (ret)
^ permalink raw reply related
* Re: [PATCH net-next 0/5] rtnetlink: add IFA_IF_NETNSID for RTM_GETADDR
From: Christian Brauner @ 2018-08-29 18:13 UTC (permalink / raw)
To: Kirill Tkhai
Cc: netdev, linux-kernel, davem, kuznet, yoshfuji, pombredanne,
kstewart, gregkh, dsahern, fw, lucien.xin, jakub.kicinski, jbenc,
nicolas.dichtel
In-Reply-To: <adc2fae5-e22b-3a74-d531-01570e7970ee@virtuozzo.com>
Hi Kirill,
Thanks for the question!
On Wed, Aug 29, 2018 at 11:30:37AM +0300, Kirill Tkhai wrote:
> Hi, Christian,
>
> On 29.08.2018 02:18, Christian Brauner wrote:
> > From: Christian Brauner <christian@brauner.io>
> >
> > Hey,
> >
> > A while back we introduced and enabled IFLA_IF_NETNSID in
> > RTM_{DEL,GET,NEW}LINK requests (cf. [1], [2], [3], [4], [5]). This has led
> > to signficant performance increases since it allows userspace to avoid
> > taking the hit of a setns(netns_fd, CLONE_NEWNET), then getting the
> > interfaces from the netns associated with the netns_fd. Especially when a
> > lot of network namespaces are in use, using setns() becomes increasingly
> > problematic when performance matters.
>
> could you please give a real example, when setns()+socket(AF_NETLINK) cause
> problems with the performance? You should do this only once on application
> startup, and then you have created netlink sockets in any net namespaces you
> need. What is the problem here?
So we have a daemon (LXD) that is often running thousands of containers.
When users issue a lxc list request against the daemon it returns a list
of all containers including all of the interfaces and addresses for each
container. To retrieve those addresses we currently rely on setns() +
getifaddrs() for each of those containers. That has horrible
performance.
The problem with what you're proposing is that the daemon would need to
cache a socket file descriptor for each container which is something
that we unfortunately cannot do since we can't excessively cache file
descriptors because we can easily hit the open file limit. We also
refrain from caching file descriptors for a long time for security
reasons.
For the case where users just request a list of the interfaces we
can already use RTM_GETLINK + IFLA_IF_NETNS which has way better
performance. But we can't do the same with RTM_GETADDR requests which
was an oversight on my part when I wrote the original patchset for the
RTM_*LINK requests. This just rectifies this and aligns RTM_GETLINK +
RTM_GETADDR.
Based on this patchset I have written a userspace POC that is basically
a netns namespace aware getifaddr() or - as I like to call it -
netns_getifaddr().
>
> > Usually, RTML_GETLINK requests are followed by RTM_GETADDR requests (cf.
> > getifaddrs() style functions and friends). But currently, RTM_GETADDR
> > requests do not support a similar property like IFLA_IF_NETNSID for
> > RTM_*LINK requests.
> > This is problematic since userspace can retrieve interfaces from another
> > network namespace by sending a IFLA_IF_NETNSID property along but
> > RTM_GETLINK request but is still forced to use the legacy setns() style of
> > retrieving interfaces in RTM_GETADDR requests.
> >
> > The goal of this series is to make it possible to perform RTM_GETADDR
> > requests on different network namespaces. To this end a new IFA_IF_NETNSID
> > property for RTM_*ADDR requests is introduced. It can be used to send a
> > network namespace identifier along in RTM_*ADDR requests. The network
> > namespace identifier will be used to retrieve the target network namespace
> > in which the request is supposed to be fulfilled. This aligns the behavior
> > of RTM_*ADDR requests with the behavior of RTM_*LINK requests.
> >
> > Security:
> > - The caller must have assigned a valid network namespace identifier for
> > the target network namespace.
> > - The caller must have CAP_NET_ADMIN in the owning user namespace of the
> > target network namespace.
> >
> > Thanks!
> > Christian
> >
> > [1]: commit 7973bfd8758d ("rtnetlink: remove check for IFLA_IF_NETNSID")
> > [2]: commit 5bb8ed075428 ("rtnetlink: enable IFLA_IF_NETNSID for RTM_NEWLINK")
> > [3]: commit b61ad68a9fe8 ("rtnetlink: enable IFLA_IF_NETNSID for RTM_DELLINK")
> > [4]: commit c310bfcb6e1b ("rtnetlink: enable IFLA_IF_NETNSID for RTM_SETLINK")
> > [5]: commit 7c4f63ba8243 ("rtnetlink: enable IFLA_IF_NETNSID in do_setlink()")
> >
> > Christian Brauner (5):
> > rtnetlink: add rtnl_get_net_ns_capable()
> > if_addr: add IFA_IF_NETNSID
> > ipv4: enable IFA_IF_NETNSID for RTM_GETADDR
> > ipv6: enable IFA_IF_NETNSID for RTM_GETADDR
> > rtnetlink: move type calculation out of loop
> >
> > include/net/rtnetlink.h | 1 +
> > include/uapi/linux/if_addr.h | 1 +
> > net/core/rtnetlink.c | 15 +++++---
> > net/ipv4/devinet.c | 38 +++++++++++++++-----
> > net/ipv6/addrconf.c | 70 ++++++++++++++++++++++++++++--------
> > 5 files changed, 97 insertions(+), 28 deletions(-)
> >
^ permalink raw reply
* Re: [PATCH] Revert "net: stmmac: Do not keep rearming the coalesce timer in stmmac_xmit"
From: Martin Blumenstingl @ 2018-08-29 18:05 UTC (permalink / raw)
To: Jose.Abreu
Cc: jbrunet, peppe.cavallaro, alexandre.torgue, netdev, linux-amlogic,
Joao.Pinto, clabbe, linux-kernel, Vitor.Soares
In-Reply-To: <CAFBinCA+Q6vLzutdMLOgeTDg5GBkqvp3YzBQiUd_y-qyiz=dsQ@mail.gmail.com>
On Wed, Aug 29, 2018 at 8:03 PM Martin Blumenstingl
<martin.blumenstingl@googlemail.com> wrote:
[snip]
> from that point on:
> # dmesg | tail -n 4
> [ 47.782778] RTL8211F Gigabit Ethernet 0.2009087f:00: attached PHY driver [RTL8211F Gigabit Ethernet] (mii_bus:phy_addr=0.2009087f:00, irq=30)
> [ 47.803540] meson8b-dwmac c9410000.ethernet eth0: No Safety Features support found
> [ 47.805505] meson8b-dwmac c9410000.ethernet eth0: PTP not supported by HW
> [ 50.311975] meson8b-dwmac c9410000.ethernet eth0: Link is Up - 1Gbps/Full - flow control rx/tx
I forgot to mention: after traffic doesn't flow anymore there are no
additional messages in the kernel log
thus the output of "dmesg | tail -n 4" is identical before and after
the test run
Regards
Martin
^ permalink raw reply
* Re: [PATCH] Revert "net: stmmac: Do not keep rearming the coalesce timer in stmmac_xmit"
From: Martin Blumenstingl @ 2018-08-29 18:03 UTC (permalink / raw)
To: Jose.Abreu
Cc: jbrunet, peppe.cavallaro, alexandre.torgue, netdev, linux-amlogic,
Joao.Pinto, clabbe, linux-kernel, Vitor.Soares
In-Reply-To: <d3858ef0-97c7-28b5-db4a-4ac71af52ba5@synopsys.com>
Hi Jose,
On Tue, Aug 28, 2018 at 10:12 AM Jose Abreu <Jose.Abreu@synopsys.com> wrote:
>
> Hi Jerome,
>
> On 24-08-2018 10:04, Jerome Brunet wrote:
> > This reverts commit 4ae0169fd1b3c792b66be58995b7e6b629919ecf.
> >
> > This change in the handling of the coalesce timer is causing regression on
> > (at least) amlogic platforms.
> >
> > Network will break down very quickly (a few seconds) after starting
> > a download. This can easily be reproduced using iperf3 for example.
> >
> > The problem has been reported on the S805, S905, S912 and A113 SoCs
> > (Realtek and Micrel PHYs) and it is likely impacting all Amlogics
> > platforms using Gbit ethernet
> >
> > No problem was seen with the platform using 10/100 only PHYs (GXL internal)
> >
> > Reverting change brings things back to normal and allows to use network
> > again until we better understand the problem with the coalesce timer.
> >
> >
>
> Apologies for the delayed answer but I was in FTO.
I hope you were able to enjoy your time off
> I'm not sure what can be causing this but I have some questions
> for you:
> - What do you mean by "network will break down"? Do you see
> queue timeout?
in case of iperf3 traffic just stops
> - What do you see in ethtool/ifconfig stats? Can you send me
> the stats before and after network break?
see below for my exact steps. let me know if you need more information
(but be prepared for some delay until I respond)
> - Is your setup multi-queue/channel?
we don't specify anything in the .dtsi files of our platform, so the
"default" is being used
> - Can you point me to the DT bindings of your setup?
in this specific case I used
arch/arm64/boot/dts/amlogic/meson-gxm-khadas-vim2.dts which inherits
the platform settings from arch/arm64/boot/dts/amlogic/meson-gx.dtsi
("ethmac" node)
so here's my exact steps to reproduce:
- boot the board
- IP address is auto-assigned via DHCP
- iperf3 -c 192.168.1.100
- wait until network breaks, CTRL+C
- ifconfig eth0 down
- ifconfig eth0 up
- (now Ethernet is working again)
from that point on:
# dmesg | tail -n 4
[ 47.782778] RTL8211F Gigabit Ethernet 0.2009087f:00: attached PHY
driver [RTL8211F Gigabit Ethernet] (mii_bus:phy_addr=0.2009087f:00,
irq=30)
[ 47.803540] meson8b-dwmac c9410000.ethernet eth0: No Safety
Features support found
[ 47.805505] meson8b-dwmac c9410000.ethernet eth0: PTP not supported by HW
[ 50.311975] meson8b-dwmac c9410000.ethernet eth0: Link is Up -
1Gbps/Full - flow control rx/tx
# ethtool -S eth0
NIC statistics:
mmc_tx_octetcount_gb: 0
mmc_tx_framecount_gb: 0
mmc_tx_broadcastframe_g: 0
mmc_tx_multicastframe_g: 0
mmc_tx_64_octets_gb: 0
mmc_tx_65_to_127_octets_gb: 0
mmc_tx_128_to_255_octets_gb: 0
mmc_tx_256_to_511_octets_gb: 0
mmc_tx_512_to_1023_octets_gb: 0
mmc_tx_1024_to_max_octets_gb: 0
mmc_tx_unicast_gb: 0
mmc_tx_multicast_gb: 0
mmc_tx_broadcast_gb: 0
mmc_tx_underflow_error: 0
mmc_tx_singlecol_g: 0
mmc_tx_multicol_g: 0
mmc_tx_deferred: 0
mmc_tx_latecol: 0
mmc_tx_exesscol: 0
mmc_tx_carrier_error: 0
mmc_tx_octetcount_g: 0
mmc_tx_framecount_g: 0
mmc_tx_excessdef: 0
mmc_tx_pause_frame: 0
mmc_tx_vlan_frame_g: 0
mmc_rx_framecount_gb: 43
mmc_rx_octetcount_gb: 3096
mmc_rx_octetcount_g: 3096
mmc_rx_broadcastframe_g: 38
mmc_rx_multicastframe_g: 0
mmc_rx_crc_error: 0
mmc_rx_align_error: 0
mmc_rx_run_error: 0
mmc_rx_jabber_error: 0
mmc_rx_undersize_g: 0
mmc_rx_oversize_g: 0
mmc_rx_64_octets_gb: 29
mmc_rx_65_to_127_octets_gb: 13
mmc_rx_128_to_255_octets_gb: 0
mmc_rx_256_to_511_octets_gb: 1
mmc_rx_512_to_1023_octets_gb: 0
mmc_rx_1024_to_max_octets_gb: 0
mmc_rx_unicast_g: 5
mmc_rx_length_error: 0
mmc_rx_autofrangetype: 0
mmc_rx_pause_frames: 0
mmc_rx_fifo_overflow: 0
mmc_rx_vlan_frames_gb: 0
mmc_rx_watchdog_error: 0
mmc_rx_ipc_intr_mask: 1073692671
mmc_rx_ipc_intr: 0
mmc_rx_ipv4_gd: 15
mmc_rx_ipv4_hderr: 0
mmc_rx_ipv4_nopay: 0
mmc_rx_ipv4_frag: 0
mmc_rx_ipv4_udsbl: 0
mmc_rx_ipv4_gd_octets: 1028
mmc_rx_ipv4_hderr_octets: 0
mmc_rx_ipv4_nopay_octets: 0
mmc_rx_ipv4_frag_octets: 0
mmc_rx_ipv4_udsbl_octets: 0
mmc_rx_ipv6_gd_octets: 0
mmc_rx_ipv6_hderr_octets: 0
mmc_rx_ipv6_nopay_octets: 0
mmc_rx_ipv6_gd: 0
mmc_rx_ipv6_hderr: 0
mmc_rx_ipv6_nopay: 0
mmc_rx_udp_gd: 11
mmc_rx_udp_err: 0
mmc_rx_tcp_gd: 4
mmc_rx_tcp_err: 0
mmc_rx_icmp_gd: 0
mmc_rx_icmp_err: 0
mmc_rx_udp_gd_octets: 592
mmc_rx_udp_err_octets: 0
mmc_rx_tcp_gd_octets: 136
mmc_rx_tcp_err_octets: 0
mmc_rx_icmp_gd_octets: 0
mmc_rx_icmp_err_octets: 0
tx_underflow: 0
tx_carrier: 0
tx_losscarrier: 0
vlan_tag: 0
tx_deferred: 0
tx_vlan: 0
tx_jabber: 0
tx_frame_flushed: 0
tx_payload_error: 0
tx_ip_header_error: 0
rx_desc: 0
sa_filter_fail: 0
overflow_error: 0
ipc_csum_error: 0
rx_collision: 0
rx_crc_errors: 0
dribbling_bit: 0
rx_length: 0
rx_mii: 0
rx_multicast: 0
rx_gmac_overflow: 0
rx_watchdog: 0
da_rx_filter_fail: 0
sa_rx_filter_fail: 0
rx_missed_cntr: 0
rx_overflow_cntr: 0
rx_vlan: 0
tx_undeflow_irq: 0
tx_process_stopped_irq: 0
tx_jabber_irq: 0
rx_overflow_irq: 0
rx_buf_unav_irq: 0
rx_process_stopped_irq: 0
rx_watchdog_irq: 0
tx_early_irq: 0
fatal_bus_error_irq: 0
rx_early_irq: 0
threshold: 1
tx_pkt_n: 8
rx_pkt_n: 43
normal_irq_n: 38
rx_normal_irq_n: 34
napi_poll: 38
tx_normal_irq_n: 4
tx_clean: 43
tx_set_ic_bit: 4
irq_receive_pmt_irq_n: 0
mmc_tx_irq_n: 0
mmc_rx_irq_n: 0
mmc_rx_csum_offload_irq_n: 0
irq_tx_path_in_lpi_mode_n: 0
irq_tx_path_exit_lpi_mode_n: 0
irq_rx_path_in_lpi_mode_n: 0
irq_rx_path_exit_lpi_mode_n: 0
phy_eee_wakeup_error_n: 0
ip_hdr_err: 0
ip_payload_err: 0
ip_csum_bypassed: 0
ipv4_pkt_rcvd: 0
ipv6_pkt_rcvd: 0
no_ptp_rx_msg_type_ext: 0
ptp_rx_msg_type_sync: 0
ptp_rx_msg_type_follow_up: 0
ptp_rx_msg_type_delay_req: 0
ptp_rx_msg_type_delay_resp: 0
ptp_rx_msg_type_pdelay_req: 0
ptp_rx_msg_type_pdelay_resp: 0
ptp_rx_msg_type_pdelay_follow_up: 0
ptp_rx_msg_type_announce: 0
ptp_rx_msg_type_management: 0
ptp_rx_msg_pkt_reserved_type: 0
ptp_frame_type: 0
ptp_ver: 0
timestamp_dropped: 0
av_pkt_rcvd: 0
av_tagged_pkt_rcvd: 0
vlan_tag_priority_val: 0
l3_filter_match: 0
l4_filter_match: 0
l3_l4_filter_no_match: 0
irq_pcs_ane_n: 0
irq_pcs_link_n: 0
irq_rgmii_n: 0
mtl_tx_status_fifo_full: 0
mtl_tx_fifo_not_empty: 0
mmtl_fifo_ctrl: 0
mtl_tx_fifo_read_ctrl_write: 0
mtl_tx_fifo_read_ctrl_wait: 0
mtl_tx_fifo_read_ctrl_read: 0
mtl_tx_fifo_read_ctrl_idle: 0
mac_tx_in_pause: 0
mac_tx_frame_ctrl_xfer: 0
mac_tx_frame_ctrl_idle: 0
mac_tx_frame_ctrl_wait: 0
mac_tx_frame_ctrl_pause: 0
mac_gmii_tx_proto_engine: 0
mtl_rx_fifo_fill_level_full: 0
mtl_rx_fifo_fill_above_thresh: 0
mtl_rx_fifo_fill_below_thresh: 0
mtl_rx_fifo_fill_level_empty: 0
mtl_rx_fifo_read_ctrl_flush: 0
mtl_rx_fifo_read_ctrl_read_data: 0
mtl_rx_fifo_read_ctrl_status: 0
mtl_rx_fifo_read_ctrl_idle: 0
mtl_rx_fifo_ctrl_active: 0
mac_rx_frame_ctrl_fifo: 0
mac_gmii_rx_proto_engine: 0
tx_tso_frames: 0
tx_tso_nfrags: 0
# ethtool eth0
Settings for eth0:
Supported ports: [ TP MII ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Supported pause frame use: Symmetric Receive-only
Supports auto-negotiation: Yes
Supported FEC modes: Not reported
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Advertised pause frame use: No
Advertised auto-negotiation: Yes
Advertised FEC modes: Not reported
Link partner advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Link partner advertised pause frame use: Symmetric Receive-only
Link partner advertised auto-negotiation: Yes
Link partner advertised FEC modes: Not reported
Speed: 1000Mb/s
Duplex: Full
Port: MII
PHYAD: 0
Transceiver: internal
Auto-negotiation: on
Supports Wake-on: ug
Wake-on: d
Current message level: 0x0000003f (63)
drv probe link timer ifdown ifup
Link detected: yes
# ifconfig eth0
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.116 netmask 255.255.255.0 broadcast 192.168.1.255
ether 66:d8:d0:34:f1:cb txqueuelen 1000 (Ethernet)
RX packets 4420 bytes 292864 (286.0 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 19165 bytes 28975001 (27.6 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 21
# iperf3 -c 192.168.1.100
Connecting to host 192.168.1.100, port 5201
[ 5] local 192.168.1.116 port 50608 connected to 192.168.1.100 port 5201
[ ID] Interval Transfer Bitrate Retr Cwnd
[ 5] 0.00-1.00 sec 111 MBytes 932 Mbits/sec 1 338 KBytes
[ 5] 1.00-2.00 sec 111 MBytes 930 Mbits/sec 0 351 KBytes
[ 5] 2.00-3.00 sec 112 MBytes 938 Mbits/sec 0 375 KBytes
[ 5] 3.00-4.00 sec 112 MBytes 943 Mbits/sec 0 390 KBytes
[ 5] 4.00-5.00 sec 50.3 MBytes 421 Mbits/sec 1 1.41 KBytes
[ 5] 5.00-6.00 sec 0.00 Bytes 0.00 bits/sec 1 1.41 KBytes
[ 5] 6.00-7.00 sec 0.00 Bytes 0.00 bits/sec 0 1.41 KBytes
[ 5] 7.00-8.00 sec 0.00 Bytes 0.00 bits/sec 0 1.41 KBytes
[ 5] 8.00-9.00 sec 0.00 Bytes 0.00 bits/sec 0 1.41 KBytes
[ 5] 10.00-29.11 sec 0.00 Bytes 0.00 bits/sec 2 1.41 KBytes
<CTRL+C after ~30 seconds>
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bitrate Retr
[ 5] 0.00-29.11 sec 496 MBytes 143 Mbits/sec 5 sender
[ 5] 0.00-29.11 sec 0.00 Bytes 0.00 bits/sec receiver
iperf3: interrupt - the client has terminated
# ethtool -S eth0
NIC statistics:
mmc_tx_octetcount_gb: 0
mmc_tx_framecount_gb: 0
mmc_tx_broadcastframe_g: 0
mmc_tx_multicastframe_g: 0
mmc_tx_64_octets_gb: 0
mmc_tx_65_to_127_octets_gb: 0
mmc_tx_128_to_255_octets_gb: 0
mmc_tx_256_to_511_octets_gb: 0
mmc_tx_512_to_1023_octets_gb: 0
mmc_tx_1024_to_max_octets_gb: 0
mmc_tx_unicast_gb: 0
mmc_tx_multicast_gb: 0
mmc_tx_broadcast_gb: 0
mmc_tx_underflow_error: 0
mmc_tx_singlecol_g: 0
mmc_tx_multicol_g: 0
mmc_tx_deferred: 0
mmc_tx_latecol: 0
mmc_tx_exesscol: 0
mmc_tx_carrier_error: 0
mmc_tx_octetcount_g: 0
mmc_tx_framecount_g: 0
mmc_tx_excessdef: 0
mmc_tx_pause_frame: 0
mmc_tx_vlan_frame_g: 0
mmc_rx_framecount_gb: 16766
mmc_rx_octetcount_gb: 1173986
mmc_rx_octetcount_g: 1173986
mmc_rx_broadcastframe_g: 98
mmc_rx_multicastframe_g: 0
mmc_rx_crc_error: 0
mmc_rx_align_error: 0
mmc_rx_run_error: 0
mmc_rx_jabber_error: 0
mmc_rx_undersize_g: 0
mmc_rx_oversize_g: 0
mmc_rx_64_octets_gb: 96
mmc_rx_65_to_127_octets_gb: 16669
mmc_rx_128_to_255_octets_gb: 0
mmc_rx_256_to_511_octets_gb: 1
mmc_rx_512_to_1023_octets_gb: 0
mmc_rx_1024_to_max_octets_gb: 0
mmc_rx_unicast_g: 16668
mmc_rx_length_error: 0
mmc_rx_autofrangetype: 0
mmc_rx_pause_frames: 0
mmc_rx_fifo_overflow: 0
mmc_rx_vlan_frames_gb: 0
mmc_rx_watchdog_error: 0
mmc_rx_ipc_intr_mask: 2147385342
mmc_rx_ipc_intr: 0
mmc_rx_ipv4_gd: 16671
mmc_rx_ipv4_hderr: 0
mmc_rx_ipv4_nopay: 0
mmc_rx_ipv4_frag: 0
mmc_rx_ipv4_udsbl: 0
mmc_rx_ipv4_gd_octets: 867822
mmc_rx_ipv4_hderr_octets: 0
mmc_rx_ipv4_nopay_octets: 0
mmc_rx_ipv4_frag_octets: 0
mmc_rx_ipv4_udsbl_octets: 0
mmc_rx_ipv6_gd_octets: 0
mmc_rx_ipv6_hderr_octets: 0
mmc_rx_ipv6_nopay_octets: 0
mmc_rx_ipv6_gd: 0
mmc_rx_ipv6_hderr: 0
mmc_rx_ipv6_nopay: 0
mmc_rx_udp_gd: 28
mmc_rx_udp_err: 0
mmc_rx_tcp_gd: 16643
mmc_rx_tcp_err: 0
mmc_rx_icmp_gd: 0
mmc_rx_icmp_err: 0
mmc_rx_udp_gd_octets: 1068
mmc_rx_udp_err_octets: 0
mmc_rx_tcp_gd_octets: 533334
mmc_rx_tcp_err_octets: 0
mmc_rx_icmp_gd_octets: 0
mmc_rx_icmp_err_octets: 0
tx_underflow: 0
tx_carrier: 0
tx_losscarrier: 0
vlan_tag: 0
tx_deferred: 0
tx_vlan: 0
tx_jabber: 0
tx_frame_flushed: 0
tx_payload_error: 0
tx_ip_header_error: 0
rx_desc: 0
sa_filter_fail: 0
overflow_error: 0
ipc_csum_error: 0
rx_collision: 0
rx_crc_errors: 0
dribbling_bit: 0
rx_length: 0
rx_mii: 0
rx_multicast: 0
rx_gmac_overflow: 0
rx_watchdog: 0
da_rx_filter_fail: 0
sa_rx_filter_fail: 0
rx_missed_cntr: 0
rx_overflow_cntr: 0
rx_vlan: 0
tx_undeflow_irq: 0
tx_process_stopped_irq: 0
tx_jabber_irq: 0
rx_overflow_irq: 0
rx_buf_unav_irq: 0
rx_process_stopped_irq: 0
rx_watchdog_irq: 0
tx_early_irq: 0
fatal_bus_error_irq: 0
rx_early_irq: 11717
threshold: 1
tx_pkt_n: 359107
rx_pkt_n: 16660
normal_irq_n: 108987
rx_normal_irq_n: 7449
napi_poll: 107154
tx_normal_irq_n: 105918
tx_clean: 107179
tx_set_ic_bit: 179554
irq_receive_pmt_irq_n: 0
mmc_tx_irq_n: 0
mmc_rx_irq_n: 0
mmc_rx_csum_offload_irq_n: 0
irq_tx_path_in_lpi_mode_n: 0
irq_tx_path_exit_lpi_mode_n: 0
irq_rx_path_in_lpi_mode_n: 0
irq_rx_path_exit_lpi_mode_n: 0
phy_eee_wakeup_error_n: 0
ip_hdr_err: 0
ip_payload_err: 0
ip_csum_bypassed: 0
ipv4_pkt_rcvd: 0
ipv6_pkt_rcvd: 0
no_ptp_rx_msg_type_ext: 0
ptp_rx_msg_type_sync: 0
ptp_rx_msg_type_follow_up: 0
ptp_rx_msg_type_delay_req: 0
ptp_rx_msg_type_delay_resp: 0
ptp_rx_msg_type_pdelay_req: 0
ptp_rx_msg_type_pdelay_resp: 0
ptp_rx_msg_type_pdelay_follow_up: 0
ptp_rx_msg_type_announce: 0
ptp_rx_msg_type_management: 0
ptp_rx_msg_pkt_reserved_type: 0
ptp_frame_type: 0
ptp_ver: 0
timestamp_dropped: 0
av_pkt_rcvd: 0
av_tagged_pkt_rcvd: 0
vlan_tag_priority_val: 0
l3_filter_match: 0
l4_filter_match: 0
l3_l4_filter_no_match: 0
irq_pcs_ane_n: 0
irq_pcs_link_n: 0
irq_rgmii_n: 0
mtl_tx_status_fifo_full: 0
mtl_tx_fifo_not_empty: 0
mmtl_fifo_ctrl: 0
mtl_tx_fifo_read_ctrl_write: 0
mtl_tx_fifo_read_ctrl_wait: 0
mtl_tx_fifo_read_ctrl_read: 0
mtl_tx_fifo_read_ctrl_idle: 0
mac_tx_in_pause: 0
mac_tx_frame_ctrl_xfer: 0
mac_tx_frame_ctrl_idle: 0
mac_tx_frame_ctrl_wait: 0
mac_tx_frame_ctrl_pause: 0
mac_gmii_tx_proto_engine: 0
mtl_rx_fifo_fill_level_full: 0
mtl_rx_fifo_fill_above_thresh: 0
mtl_rx_fifo_fill_below_thresh: 0
mtl_rx_fifo_fill_level_empty: 0
mtl_rx_fifo_read_ctrl_flush: 0
mtl_rx_fifo_read_ctrl_read_data: 0
mtl_rx_fifo_read_ctrl_status: 0
mtl_rx_fifo_read_ctrl_idle: 0
mtl_rx_fifo_ctrl_active: 0
mac_rx_frame_ctrl_fifo: 0
mac_gmii_rx_proto_engine: 0
tx_tso_frames: 0
tx_tso_nfrags: 0
# ethtool eth0
Settings for eth0:
Supported ports: [ TP MII ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Supported pause frame use: Symmetric Receive-only
Supports auto-negotiation: Yes
Supported FEC modes: Not reported
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Advertised pause frame use: No
Advertised auto-negotiation: Yes
Advertised FEC modes: Not reported
Link partner advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Link partner advertised pause frame use: Symmetric Receive-only
Link partner advertised auto-negotiation: Yes
Link partner advertised FEC modes: Not reported
Speed: 1000Mb/s
Duplex: Full
Port: MII
PHYAD: 0
Transceiver: internal
Auto-negotiation: on
Supports Wake-on: ug
Wake-on: d
Current message level: 0x0000003f (63)
drv probe link timer ifdown ifup
Link detected: yes
# ifconfig eth0
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.116 netmask 255.255.255.0 broadcast 192.168.1.255
ether 66:d8:d0:34:f1:cb txqueuelen 1000 (Ethernet)
RX packets 21021 bytes 1389130 (1.3 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 378272 bytes 572598814 (546.0 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 21
Regards
Martin
^ permalink raw reply
* [PATCH] wil6210: fix unsigned cid comparison with >= 0
From: Gustavo A. R. Silva @ 2018-08-29 17:50 UTC (permalink / raw)
To: Maya Erez, Kalle Valo, David S. Miller
Cc: linux-wireless, wil6210, netdev, linux-kernel,
Gustavo A. R. Silva
The comparison of cid >= 0 is always true because cid is of type u8
(8 bits, unsigned).
Fix this by removing such comparison and updating the type of
variable cid to u8 in the caller function.
Addresses-Coverity-ID: 1473079 ("Unsigned compared against 0")
Fixes: b9010f105f21 ("wil6210: add FT roam support for AP and station")
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
---
drivers/net/wireless/ath/wil6210/wil6210.h | 2 +-
drivers/net/wireless/ath/wil6210/wmi.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/wireless/ath/wil6210/wil6210.h b/drivers/net/wireless/ath/wil6210/wil6210.h
index cf6a691..abb8201 100644
--- a/drivers/net/wireless/ath/wil6210/wil6210.h
+++ b/drivers/net/wireless/ath/wil6210/wil6210.h
@@ -455,7 +455,7 @@ static inline void parse_cidxtid(u8 cidxtid, u8 *cid, u8 *tid)
*/
static inline bool wil_cid_valid(u8 cid)
{
- return (cid >= 0 && cid < WIL6210_MAX_CID);
+ return cid < WIL6210_MAX_CID;
}
struct wil6210_mbox_ring {
diff --git a/drivers/net/wireless/ath/wil6210/wmi.c b/drivers/net/wireless/ath/wil6210/wmi.c
index c3ad8e4..4859f0e 100644
--- a/drivers/net/wireless/ath/wil6210/wmi.c
+++ b/drivers/net/wireless/ath/wil6210/wmi.c
@@ -1177,7 +1177,7 @@ static void wmi_evt_ring_en(struct wil6210_vif *vif, int id, void *d, int len)
u8 vri = evt->ring_index;
struct wireless_dev *wdev = vif_to_wdev(vif);
struct wil_sta_info *sta;
- int cid;
+ u8 cid;
struct key_params params;
wil_dbg_wmi(wil, "Enable vring %d MID %d\n", vri, vif->mid);
--
2.7.4
^ permalink raw reply related
* [iproute PATCH] iprule: Fix for incorrect space between dst and prefix
From: Phil Sutter @ 2018-08-29 13:52 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: netdev
This was added by accident when introducing JSON support.
Fixes: 0dd4ccc56c0e3 ("iprule: add json support")
Signed-off-by: Phil Sutter <phil@nwl.cc>
---
ip/iprule.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ip/iprule.c b/ip/iprule.c
index 8b9421431c26a..744d6d88e3433 100644
--- a/ip/iprule.c
+++ b/ip/iprule.c
@@ -239,7 +239,7 @@ int print_rule(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
print_string(PRINT_FP, NULL, "to ", NULL);
print_color_string(PRINT_ANY, ifa_family_color(frh->family),
- "dst", "%s ", dst);
+ "dst", "%s", dst);
if (frh->dst_len != host_len)
print_uint(PRINT_ANY, "dstlen", "/%u ", frh->dst_len);
else
--
2.18.0
^ permalink raw reply related
* [PATCH v2 5/6] net/wan/fsl_ucc_hdlc: GUMR for non tsa mode
From: David Gounaris @ 2018-08-29 13:13 UTC (permalink / raw)
To: qiang.zhao, netdev, linuxppc-dev, robh+dt; +Cc: David Gounaris
In-Reply-To: <20180829131328.27901-1-david.gounaris@infinera.com>
The following bits in the GUMR is changed for non
tsa mode: CDS, CTSP and CTSS are set to zero.
When set, there is no tx interrupts from the controller.
Signed-off-by: David Gounaris <david.gounaris@infinera.com>
---
drivers/net/wan/fsl_ucc_hdlc.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/net/wan/fsl_ucc_hdlc.c b/drivers/net/wan/fsl_ucc_hdlc.c
index be5b0096af3b..248f1f5bcd04 100644
--- a/drivers/net/wan/fsl_ucc_hdlc.c
+++ b/drivers/net/wan/fsl_ucc_hdlc.c
@@ -97,6 +97,13 @@ static int uhdlc_init(struct ucc_hdlc_private *priv)
if (priv->tsa) {
uf_info->tsa = 1;
uf_info->ctsp = 1;
+ uf_info->cds = 1;
+ uf_info->ctss = 1;
+ }
+ else {
+ uf_info->cds = 0;
+ uf_info->ctsp = 0;
+ uf_info->ctss = 0;
}
/* This sets HPM register in CMXUCR register which configures a
--
2.13.6
^ permalink raw reply related
* [PATCH v2 6/6] net/wan/fsl_ucc_hdlc: tx timeout handler
From: David Gounaris @ 2018-08-29 13:13 UTC (permalink / raw)
To: qiang.zhao, netdev, linuxppc-dev, robh+dt; +Cc: David Gounaris
In-Reply-To: <20180829131328.27901-1-david.gounaris@infinera.com>
Added tx timerout handler. This helps
when troubleshooting.
Signed-off-by: David Gounaris <david.gounaris@infinera.com>
---
drivers/net/wan/fsl_ucc_hdlc.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/net/wan/fsl_ucc_hdlc.c b/drivers/net/wan/fsl_ucc_hdlc.c
index 248f1f5bcd04..629ef5049d27 100644
--- a/drivers/net/wan/fsl_ucc_hdlc.c
+++ b/drivers/net/wan/fsl_ucc_hdlc.c
@@ -1002,11 +1002,15 @@ static const struct dev_pm_ops uhdlc_pm_ops = {
#define HDLC_PM_OPS NULL
#endif
+static void uhdlc_tx_timeout(struct net_device *ndev) {
+ netdev_err(ndev, "%s\n", __FUNCTION__);
+}
static const struct net_device_ops uhdlc_ops = {
.ndo_open = uhdlc_open,
.ndo_stop = uhdlc_close,
.ndo_start_xmit = hdlc_start_xmit,
.ndo_do_ioctl = uhdlc_ioctl,
+ .ndo_tx_timeout = uhdlc_tx_timeout,
};
static int ucc_hdlc_probe(struct platform_device *pdev)
@@ -1125,6 +1129,7 @@ static int ucc_hdlc_probe(struct platform_device *pdev)
hdlc = dev_to_hdlc(dev);
dev->tx_queue_len = 16;
dev->netdev_ops = &uhdlc_ops;
+ dev->watchdog_timeo = 2*HZ;
hdlc->attach = ucc_hdlc_attach;
hdlc->xmit = ucc_hdlc_tx;
netif_napi_add(dev, &uhdlc_priv->napi, ucc_hdlc_poll, 32);
--
2.13.6
^ permalink raw reply related
* [PATCH v2 4/6] net/wan/fsl_ucc_hdlc: hmask
From: David Gounaris @ 2018-08-29 13:13 UTC (permalink / raw)
To: qiang.zhao, netdev, linuxppc-dev, robh+dt; +Cc: David Gounaris
In-Reply-To: <20180829131328.27901-1-david.gounaris@infinera.com>
Ability to set hmask in the device-tree,
which can be used to change address
filtering of packets.
Signed-off-by: David Gounaris <david.gounaris@infinera.com>
---
Documentation/devicetree/bindings/soc/fsl/cpm_qe/network.txt | 6 ++++++
drivers/net/wan/fsl_ucc_hdlc.c | 5 ++++-
drivers/net/wan/fsl_ucc_hdlc.h | 1 +
3 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/Documentation/devicetree/bindings/soc/fsl/cpm_qe/network.txt b/Documentation/devicetree/bindings/soc/fsl/cpm_qe/network.txt
index 03c741602c6d..6d2dd8a31482 100644
--- a/Documentation/devicetree/bindings/soc/fsl/cpm_qe/network.txt
+++ b/Documentation/devicetree/bindings/soc/fsl/cpm_qe/network.txt
@@ -98,6 +98,12 @@ The property below is dependent on fsl,tdm-interface:
usage: optional for tdm interface
value type: <empty>
Definition : Internal loopback connecting on TDM layer.
+- fsl,hmask
+ usage: optional
+ Value type: <u16>
+ Definition: HDLC address recognition. Set to zero to disable
+ address filtering of packets:
+ fsl,hmask = /bits/ 16 <0x0000>;
Example for tdm interface:
diff --git a/drivers/net/wan/fsl_ucc_hdlc.c b/drivers/net/wan/fsl_ucc_hdlc.c
index 0f703d7be5e0..be5b0096af3b 100644
--- a/drivers/net/wan/fsl_ucc_hdlc.c
+++ b/drivers/net/wan/fsl_ucc_hdlc.c
@@ -263,7 +263,7 @@ static int uhdlc_init(struct ucc_hdlc_private *priv)
iowrite16be(MAX_FRAME_LENGTH, &priv->ucc_pram->mflr);
iowrite16be(DEFAULT_RFTHR, &priv->ucc_pram->rfthr);
iowrite16be(DEFAULT_RFTHR, &priv->ucc_pram->rfcnt);
- iowrite16be(DEFAULT_ADDR_MASK, &priv->ucc_pram->hmask);
+ iowrite16be(priv->hmask, &priv->ucc_pram->hmask);
iowrite16be(DEFAULT_HDLC_ADDR, &priv->ucc_pram->haddr1);
iowrite16be(DEFAULT_HDLC_ADDR, &priv->ucc_pram->haddr2);
iowrite16be(DEFAULT_HDLC_ADDR, &priv->ucc_pram->haddr3);
@@ -1097,6 +1097,9 @@ static int ucc_hdlc_probe(struct platform_device *pdev)
if (ret)
goto free_utdm;
}
+
+ if (of_property_read_u16(np, "fsl,hmask", &uhdlc_priv->hmask))
+ uhdlc_priv->hmask = DEFAULT_ADDR_MASK;
ret = uhdlc_init(uhdlc_priv);
if (ret) {
diff --git a/drivers/net/wan/fsl_ucc_hdlc.h b/drivers/net/wan/fsl_ucc_hdlc.h
index c21134c1f180..b99fa2f1cd99 100644
--- a/drivers/net/wan/fsl_ucc_hdlc.h
+++ b/drivers/net/wan/fsl_ucc_hdlc.h
@@ -106,6 +106,7 @@ struct ucc_hdlc_private {
unsigned short encoding;
unsigned short parity;
+ unsigned short hmask;
u32 clocking;
spinlock_t lock; /* lock for Tx BD and Tx buffer */
#ifdef CONFIG_PM
--
2.13.6
^ permalink raw reply related
* [PATCH v2 3/6] net/wan/fsl_ucc_hdlc: Adding ARPHRD_ETHER
From: David Gounaris @ 2018-08-29 13:13 UTC (permalink / raw)
To: qiang.zhao, netdev, linuxppc-dev, robh+dt; +Cc: David Gounaris
In-Reply-To: <20180829131328.27901-1-david.gounaris@infinera.com>
This patch is to avoid discarding ethernet
packets when using HDLC_ETH protocol.
Signed-off-by: David Gounaris <david.gounaris@infinera.com>
---
drivers/net/wan/fsl_ucc_hdlc.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/net/wan/fsl_ucc_hdlc.c b/drivers/net/wan/fsl_ucc_hdlc.c
index c8e526bf1130..0f703d7be5e0 100644
--- a/drivers/net/wan/fsl_ucc_hdlc.c
+++ b/drivers/net/wan/fsl_ucc_hdlc.c
@@ -376,6 +376,10 @@ static netdev_tx_t ucc_hdlc_tx(struct sk_buff *skb, struct net_device *dev)
dev->stats.tx_bytes += skb->len;
break;
+ case ARPHRD_ETHER:
+ dev->stats.tx_bytes += skb->len;
+ break;
+
default:
dev->stats.tx_dropped++;
dev_kfree_skb(skb);
@@ -513,6 +517,8 @@ static int hdlc_rx_done(struct ucc_hdlc_private *priv, int rx_work_limit)
break;
case ARPHRD_PPP:
+ case ARPHRD_ETHER:
+
length -= HDLC_CRC_SIZE;
skb = dev_alloc_skb(length);
--
2.13.6
^ permalink raw reply related
* [PATCH v2 2/6] net/wan/fsl_ucc_hdlc: allow PARITY_CRC16_PR0_CCITT parity
From: David Gounaris @ 2018-08-29 13:13 UTC (permalink / raw)
To: qiang.zhao, netdev, linuxppc-dev, robh+dt; +Cc: David Gounaris
In-Reply-To: <20180829131328.27901-1-david.gounaris@infinera.com>
Signed-off-by: David Gounaris <david.gounaris@infinera.com>
---
drivers/net/wan/fsl_ucc_hdlc.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/net/wan/fsl_ucc_hdlc.c b/drivers/net/wan/fsl_ucc_hdlc.c
index 5cf6dcba039c..c8e526bf1130 100644
--- a/drivers/net/wan/fsl_ucc_hdlc.c
+++ b/drivers/net/wan/fsl_ucc_hdlc.c
@@ -781,7 +781,8 @@ static int ucc_hdlc_attach(struct net_device *dev, unsigned short encoding,
if (parity != PARITY_NONE &&
parity != PARITY_CRC32_PR1_CCITT &&
- parity != PARITY_CRC16_PR1_CCITT)
+ parity != PARITY_CRC16_PR1_CCITT &&
+ parity != PARITY_CRC16_PR0_CCITT)
return -EINVAL;
priv->encoding = encoding;
--
2.13.6
^ permalink raw reply related
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