Netdev List
 help / color / mirror / Atom feed
* I have an urgent project for you
From: drygin @ 2018-07-15  0:16 UTC (permalink / raw)




^ permalink raw reply

* 16-byte extra data, and 16-byte alignment, in the memory-mapped receive code for AF_PACKET sockets
From: Guy Harris @ 2018-07-15  1:21 UTC (permalink / raw)
  To: netdev

tpacket_rcv() does

	if (sk->sk_type == SOCK_DGRAM) {
		macoff = netoff = TPACKET_ALIGN(po->tp_hdrlen) + 16 +
				  po->tp_reserve;
	} else {
		unsigned int maclen = skb_network_offset(skb);
		netoff = TPACKET_ALIGN(po->tp_hdrlen +
				       (maclen < 16 ? 16 : maclen)) +
				       po->tp_reserve;
		if (po->has_vnet_hdr) {
			netoff += sizeof(struct virtio_net_hdr);
			do_vnet = true;
		}
		macoff = netoff - maclen;
	}

1) What is the "+ 16" in the SOCK_DGRAM case?  Is it reserving space for libpcap to put a "Linux cooked mode" header in before the packet data?  If so, that should probably be mentioned in a comment, or a #define should be used.

2) The documentation speaks of putting the raw packet data on a 16-byte boundary.

2a) Is this to avoid the "If the data is not aligned on a 16-Byte boundary, then whenever a store crosses a cache-line boundary there is typically a stall." issue mentioned on https://software.intel.com/en-us/forums/intel-isa-extensions/topic/709279 ?

2b) Does this mean that the argument to the PACKET_RESERVE socket option should be a multiple of 16?  If so, that should probably be mentioned in the packet(7) man page.

3) In the non-SOCK_DGRAM case, why does it use 16 instead of a less-than-16-bytes maclen?

^ permalink raw reply

* [PATCH net] tcp: Fix broken repair socket window probe patch
From: Stefan Baranoff @ 2018-07-15  1:54 UTC (permalink / raw)
  Cc: Andrey Vagin, Pavel Emelyanov, Stefan Baranoff, Eric Dumazet,
	David S. Miller, Alexey Kuznetsov, Hideaki YOSHIFUJI, netdev,
	linux-kernel

Correct previous bad attempt at allowing sockets to come out of TCP
repair without sending window probes. To avoid changing size of
the repair variable in struct tcp_sock, this lets the decision for
sending probes or not to be made when coming out of repair by
introducing two ways to turn it off.

Fixes: 70b7ff130224 ("tcp: allow user to create repair socket without window probes")
Signed-off-by: Stefan Baranoff <sbaranoff@gmail.com>
---
 include/uapi/linux/tcp.h |  4 ++++
 net/ipv4/tcp.c           | 12 +++++++-----
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/include/uapi/linux/tcp.h b/include/uapi/linux/tcp.h
index 29eb659..e3f6ed8 100644
--- a/include/uapi/linux/tcp.h
+++ b/include/uapi/linux/tcp.h
@@ -127,6 +127,10 @@ enum {
 
 #define TCP_CM_INQ		TCP_INQ
 
+#define TCP_REPAIR_ON		1
+#define TCP_REPAIR_OFF		0
+#define TCP_REPAIR_OFF_NO_WP	-1	/* Turn off without window probes */
+
 struct tcp_repair_opt {
 	__u32	opt_code;
 	__u32	opt_val;
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 8e5e2ca..9163fb1 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -2824,15 +2824,17 @@ static int do_tcp_setsockopt(struct sock *sk, int level,
 		if (!tcp_can_repair_sock(sk))
 			err = -EPERM;
 		/* 1 for normal repair, 2 for no window probes */
-		else if (val == 1 || val == 2) {
-			tp->repair = val;
+		else if (val == TCP_REPAIR_ON) {
+			tp->repair = 1;
 			sk->sk_reuse = SK_FORCE_REUSE;
 			tp->repair_queue = TCP_NO_QUEUE;
-		} else if (val == 0) {
+		} else if (val == TCP_REPAIR_OFF) {
+			tp->repair = 0;
+			sk->sk_reuse = SK_NO_REUSE;
+			tcp_send_window_probe(sk);
+		} else if (val == TCP_REPAIR_OFF_NO_WP) {
 			tp->repair = 0;
 			sk->sk_reuse = SK_NO_REUSE;
-			if (tp->repair == 1)
-				tcp_send_window_probe(sk);
 		} else
 			err = -EINVAL;
 
-- 
1.8.3.1

^ permalink raw reply related

* Re: [PATCH v2 iproute2-next 2/5] bridge: colorize output and use JSON print library
From: Roopa Prabhu @ 2018-07-15  1:41 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: netdev, Stephen Hemminger, Julien Fortin, David Ahern
In-Reply-To: <20180220192408.19763-3-stephen@networkplumber.org>

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}]]

^ permalink raw reply

* Re: pull-request: bpf-next 2018-07-15
From: David Miller @ 2018-07-15  1:48 UTC (permalink / raw)
  To: daniel; +Cc: ast, netdev
In-Reply-To: <20180714231949.14700-1-daniel@iogearbox.net>

From: Daniel Borkmann <daniel@iogearbox.net>
Date: Sun, 15 Jul 2018 01:19:49 +0200

> The following pull-request contains BPF updates for your *net-next* tree.
> 
> The main changes are:
...
> Please consider pulling these changes from:
> 
>   git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git

Pulled, thanks Daniel!

^ permalink raw reply

* I have an urgent project for you
From: drygin @ 2018-07-15  3:23 UTC (permalink / raw)




^ permalink raw reply

* Re: [PATCH mlx5-next v1 1/8] net/mlx5: Add forward compatible support for the FTE match data
From: Yishai Hadas @ 2018-07-15  7:26 UTC (permalink / raw)
  To: Or Gerlitz
  Cc: Yishai Hadas, Doug Ledford, Jason Gunthorpe, Leon Romanovsky,
	RDMA mailing list, Saeed Mahameed, linux-netdev, Majd Dibbiny
In-Reply-To: <CAJ3xEMipJhe0PdsmR7kshrG-dXSqaLJ5xorwbMZyBvdXy0jA0A@mail.gmail.com>

On 7/12/2018 11:53 PM, Or Gerlitz wrote:
> On Wed, Jul 11, 2018 at 2:10 PM, Leon Romanovsky <leon@kernel.org> wrote:
>> From: Yishai Hadas <yishaih@mellanox.com>
>>
>> Use the PRM size including the reserved when working with the FTE
>> match data.
> 
> is this actually a bug fix?

No, it's some requirement from the new API to enable forward compatible 
support without changing the kernel code.


>> Also drop some driver checks around the match criteria leaving the work
>> for firmware to enable forward compatibility for future bits there.
> 
> not following,
> 

Same as for the 'reserved' field but also for extending the 'match 
criteria' field with new bits without changing the kernel.


> OTOH, suppose today we check that one of four bits is set and now one
> added bit #5 and the
> kernel doesn't check it, what removing the existing four checks buys you?

The idea was to have one place for those checking (i.e. firmware) 
instead of splitting between legacy to new bits. (i.e. driver vs firmware).

^ permalink raw reply

* Re: [PATCH net-next v3 02/11] devlink: Add callback to query for snapshot id before snapshot create
From: Alex Vesker @ 2018-07-15  7:43 UTC (permalink / raw)
  To: Jakub Kicinski; +Cc: netdev, jiri, dsahern, andrew, rahul.lakkireddy
In-Reply-To: <20180712175128.457848ec@cakuba.lan>



On 7/13/2018 3:51 AM, Jakub Kicinski wrote:
> On Thu, 12 Jul 2018 15:13:09 +0300, Alex Vesker wrote:
>> To restrict the driver with the snapshot ID selection a new callback
>> is introduced for the driver to get the snapshot ID before creating
>> a new snapshot. This will also allow giving the same ID for multiple
>> snapshots taken of different regions on the same time.
> I'm not in position to criticize other people's commit messages :), but
> I find this one hard to parse.  I think what you meant to say is that
> you add a helper for numbering the snapshot per-devlink instance.
> There is no callback to be seen here.  You *prevent* from giving the
> same ID to multiple snapshot even if they are from different regions.
Let me try to clarify,
The idea is to have a simple helper function that assigns IDs to provide 
a more complete
API, an example use case is when you want to add a new snapshot to 
multiple regions
from the same trigger, then it should be called once to get an ID, this 
ID should be used
on all new snapshots.

>> diff --git a/net/core/devlink.c b/net/core/devlink.c
>> index cac8561..6c92ddd 100644
>> --- a/net/core/devlink.c
>> +++ b/net/core/devlink.c
>> @@ -4193,6 +4193,27 @@ void devlink_region_destroy(struct devlink_region *region)
>>   }
>>   EXPORT_SYMBOL_GPL(devlink_region_destroy);
>>   
>> +/**
>> + *	devlink_region_shapshot_id_get - get snapshot ID
>> + *
>> + *	This callback should be called when adding a new snapshot,
>> + *	Driver should use the same id for multiple snapshots taken
>> + *	on multiple regions at the same time/by the same trigger.
>> + *
>> + *	@devlink: devlink
>> + */
>> +u32 devlink_region_shapshot_id_get(struct devlink *devlink)
>> +{
>> +	u32 id;
>> +
>> +	mutex_lock(&devlink->lock);
>> +	id = ++devlink->snapshot_id;
> Any reason not to use an IDA?  The reuse may seem unlikely, OTOH IDA
> isn't going to cost much, so why risk it...
As you mentioned more than u32_max_value snapshots doesn't sound likely.
New snapshots will be created, old snapshots should be deleted by the user
a wrap around sounds unlikely. Let me think about it some more, might send a
patch that changes to IDA.

>> +	mutex_unlock(&devlink->lock);
>> +
>> +	return id;
>> +}
>> +EXPORT_SYMBOL_GPL(devlink_region_shapshot_id_get);
> Sorry for only spotting this now.

^ permalink raw reply

* [PATCH net-next] mlxsw: spectrum: Expose counters for various packet sizes
From: Ido Schimmel @ 2018-07-15  7:45 UTC (permalink / raw)
  To: netdev; +Cc: davem, jiri, mlxsw, Ido Schimmel

From: Jiri Pirko <jiri@mellanox.com>

Expose counters ASIC has in the group of RFC 2819 counters that count
number of packets within specific size range.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlxsw/reg.h      | 63 ++++++++++++++++++++++++++
 drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 62 ++++++++++++++++++++++++-
 2 files changed, 124 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/reg.h b/drivers/net/ethernet/mellanox/mlxsw/reg.h
index 6f98a43e75f5..f76c17308a51 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/reg.h
+++ b/drivers/net/ethernet/mellanox/mlxsw/reg.h
@@ -3365,6 +3365,7 @@ MLXSW_ITEM32(reg, ppcnt, pnat, 0x00, 14, 2);
 
 enum mlxsw_reg_ppcnt_grp {
 	MLXSW_REG_PPCNT_IEEE_8023_CNT = 0x0,
+	MLXSW_REG_PPCNT_RFC_2819_CNT = 0x2,
 	MLXSW_REG_PPCNT_EXT_CNT = 0x5,
 	MLXSW_REG_PPCNT_PRIO_CNT = 0x10,
 	MLXSW_REG_PPCNT_TC_CNT = 0x11,
@@ -3523,6 +3524,68 @@ MLXSW_ITEM64(reg, ppcnt, a_pause_mac_ctrl_frames_received,
 MLXSW_ITEM64(reg, ppcnt, a_pause_mac_ctrl_frames_transmitted,
 	     MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x90, 0, 64);
 
+/* Ethernet RFC 2819 Counter Group */
+
+/* reg_ppcnt_ether_stats_pkts64octets
+ * Access: RO
+ */
+MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts64octets,
+	     MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x58, 0, 64);
+
+/* reg_ppcnt_ether_stats_pkts65to127octets
+ * Access: RO
+ */
+MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts65to127octets,
+	     MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x60, 0, 64);
+
+/* reg_ppcnt_ether_stats_pkts128to255octets
+ * Access: RO
+ */
+MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts128to255octets,
+	     MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x68, 0, 64);
+
+/* reg_ppcnt_ether_stats_pkts256to511octets
+ * Access: RO
+ */
+MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts256to511octets,
+	     MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x70, 0, 64);
+
+/* reg_ppcnt_ether_stats_pkts512to1023octets
+ * Access: RO
+ */
+MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts512to1023octets,
+	     MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x78, 0, 64);
+
+/* reg_ppcnt_ether_stats_pkts1024to1518octets
+ * Access: RO
+ */
+MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts1024to1518octets,
+	     MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x80, 0, 64);
+
+/* reg_ppcnt_ether_stats_pkts1519to2047octets
+ * Access: RO
+ */
+MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts1519to2047octets,
+	     MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x88, 0, 64);
+
+/* reg_ppcnt_ether_stats_pkts2048to4095octets
+ * Access: RO
+ */
+MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts2048to4095octets,
+	     MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x90, 0, 64);
+
+/* reg_ppcnt_ether_stats_pkts4096to8191octets
+ * Access: RO
+ */
+MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts4096to8191octets,
+	     MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x98, 0, 64);
+
+/* reg_ppcnt_ether_stats_pkts8192to10239octets
+ * Access: RO
+ */
+MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts8192to10239octets,
+	     MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0xA0, 0, 64);
+
 /* Ethernet Extended Counter Group Counters */
 
 /* reg_ppcnt_ecn_marked
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
index 6ec0f91a93cc..62c5f1c5bf62 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
@@ -1888,6 +1888,52 @@ static struct mlxsw_sp_port_hw_stats mlxsw_sp_port_hw_stats[] = {
 
 #define MLXSW_SP_PORT_HW_STATS_LEN ARRAY_SIZE(mlxsw_sp_port_hw_stats)
 
+static struct mlxsw_sp_port_hw_stats mlxsw_sp_port_hw_rfc_2819_stats[] = {
+	{
+		.str = "ether_pkts64octets",
+		.getter = mlxsw_reg_ppcnt_ether_stats_pkts64octets_get,
+	},
+	{
+		.str = "ether_pkts65to127octets",
+		.getter = mlxsw_reg_ppcnt_ether_stats_pkts65to127octets_get,
+	},
+	{
+		.str = "ether_pkts128to255octets",
+		.getter = mlxsw_reg_ppcnt_ether_stats_pkts128to255octets_get,
+	},
+	{
+		.str = "ether_pkts256to511octets",
+		.getter = mlxsw_reg_ppcnt_ether_stats_pkts256to511octets_get,
+	},
+	{
+		.str = "ether_pkts512to1023octets",
+		.getter = mlxsw_reg_ppcnt_ether_stats_pkts512to1023octets_get,
+	},
+	{
+		.str = "ether_pkts1024to1518octets",
+		.getter = mlxsw_reg_ppcnt_ether_stats_pkts1024to1518octets_get,
+	},
+	{
+		.str = "ether_pkts1519to2047octets",
+		.getter = mlxsw_reg_ppcnt_ether_stats_pkts1519to2047octets_get,
+	},
+	{
+		.str = "ether_pkts2048to4095octets",
+		.getter = mlxsw_reg_ppcnt_ether_stats_pkts2048to4095octets_get,
+	},
+	{
+		.str = "ether_pkts4096to8191octets",
+		.getter = mlxsw_reg_ppcnt_ether_stats_pkts4096to8191octets_get,
+	},
+	{
+		.str = "ether_pkts8192to10239octets",
+		.getter = mlxsw_reg_ppcnt_ether_stats_pkts8192to10239octets_get,
+	},
+};
+
+#define MLXSW_SP_PORT_HW_RFC_2819_STATS_LEN \
+	ARRAY_SIZE(mlxsw_sp_port_hw_rfc_2819_stats)
+
 static struct mlxsw_sp_port_hw_stats mlxsw_sp_port_hw_prio_stats[] = {
 	{
 		.str = "rx_octets_prio",
@@ -1979,6 +2025,11 @@ static void mlxsw_sp_port_get_strings(struct net_device *dev,
 			       ETH_GSTRING_LEN);
 			p += ETH_GSTRING_LEN;
 		}
+		for (i = 0; i < MLXSW_SP_PORT_HW_RFC_2819_STATS_LEN; i++) {
+			memcpy(p, mlxsw_sp_port_hw_rfc_2819_stats[i].str,
+			       ETH_GSTRING_LEN);
+			p += ETH_GSTRING_LEN;
+		}
 
 		for (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++)
 			mlxsw_sp_port_get_prio_strings(&p, i);
@@ -2018,10 +2069,14 @@ mlxsw_sp_get_hw_stats_by_group(struct mlxsw_sp_port_hw_stats **p_hw_stats,
 			       int *p_len, enum mlxsw_reg_ppcnt_grp grp)
 {
 	switch (grp) {
-	case  MLXSW_REG_PPCNT_IEEE_8023_CNT:
+	case MLXSW_REG_PPCNT_IEEE_8023_CNT:
 		*p_hw_stats = mlxsw_sp_port_hw_stats;
 		*p_len = MLXSW_SP_PORT_HW_STATS_LEN;
 		break;
+	case MLXSW_REG_PPCNT_RFC_2819_CNT:
+		*p_hw_stats = mlxsw_sp_port_hw_rfc_2819_stats;
+		*p_len = MLXSW_SP_PORT_HW_RFC_2819_STATS_LEN;
+		break;
 	case MLXSW_REG_PPCNT_PRIO_CNT:
 		*p_hw_stats = mlxsw_sp_port_hw_prio_stats;
 		*p_len = MLXSW_SP_PORT_HW_PRIO_STATS_LEN;
@@ -2071,6 +2126,11 @@ static void mlxsw_sp_port_get_stats(struct net_device *dev,
 				  data, data_index);
 	data_index = MLXSW_SP_PORT_HW_STATS_LEN;
 
+	/* RFC 2819 Counters */
+	__mlxsw_sp_port_get_stats(dev, MLXSW_REG_PPCNT_RFC_2819_CNT, 0,
+				  data, data_index);
+	data_index += MLXSW_SP_PORT_HW_RFC_2819_STATS_LEN;
+
 	/* Per-Priority Counters */
 	for (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++) {
 		__mlxsw_sp_port_get_stats(dev, MLXSW_REG_PPCNT_PRIO_CNT, i,
-- 
2.14.4

^ permalink raw reply related

* Re: [PATCH mlx5-next v1 1/8] net/mlx5: Add forward compatible support for the FTE match data
From: Or Gerlitz @ 2018-07-15  8:03 UTC (permalink / raw)
  To: Yishai Hadas
  Cc: Yishai Hadas, Doug Ledford, Jason Gunthorpe, Leon Romanovsky,
	RDMA mailing list, Saeed Mahameed, linux-netdev, Majd Dibbiny
In-Reply-To: <84e6a046-881d-65ce-ab58-2ed9691cc864@dev.mellanox.co.il>

On Sun, Jul 15, 2018 at 10:26 AM, Yishai Hadas
<yishaih@dev.mellanox.co.il> wrote:
> On 7/12/2018 11:53 PM, Or Gerlitz wrote:
>> On Wed, Jul 11, 2018 at 2:10 PM, Leon Romanovsky <leon@kernel.org> wrote:
>>> From: Yishai Hadas <yishaih@mellanox.com>

>>> Use the PRM size including the reserved when working with the FTE
>>> match data.

>> is this actually a bug fix?

> No, it's some requirement from the new API to enable forward compatible
> support without changing the kernel code.

ok, but

>>> Also drop some driver checks around the match criteria leaving the work
>>> for firmware to enable forward compatibility for future bits there.

>> not following,

> Same as for the 'reserved' field but also for extending the 'match criteria'
> field with new bits without changing the kernel.

-- we need a clear memo as part of your change-logs and/or cover-letter/s that
explains the overall approach/design for
doing-things-without-changing-the-kernel,
does this exist? the arch/approach need not be deciphered from the
code or change logs
snapshots but rather stated clearly.

^ permalink raw reply

* [PATCH] bpf: allow BPF programs access skb_shared_info->gso_segs field
From: Eddie Hao @ 2018-07-15  8:45 UTC (permalink / raw)
  To: ast, daniel; +Cc: davem, netdev, linux-kernel, Eddie Hao

This adds the ability to read gso_segs from a BPF program. This is useful
for user space monitoring systems to get gso_segs statistics for each
arbitrary group of flows defined by the BPF program.

Signed-off-by: Eddie Hao <eddieh@google.com>
---
 include/uapi/linux/bpf.h | 1 +
 net/core/filter.c        | 9 +++++++++
 2 files changed, 10 insertions(+)

diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h
index b7db3261c62d..282085445616 100644
--- a/include/uapi/linux/bpf.h
+++ b/include/uapi/linux/bpf.h
@@ -2266,6 +2266,7 @@ struct __sk_buff {
 	/* ... here. */
 
 	__u32 data_meta;
+	unsigned short gso_segs;
 };
 
 struct bpf_tunnel_key {
diff --git a/net/core/filter.c b/net/core/filter.c
index b9ec916f4e3a..f17e249f3fbb 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -5820,6 +5820,15 @@ static u32 bpf_convert_ctx_access(enum bpf_access_type type,
 				      bpf_target_off(struct sock_common,
 						     skc_num, 2, target_size));
 		break;
+
+	case offsetof(struct __sk_buff, gso_segs):
+		BUILD_BUG_ON(FIELD_SIZEOF(struct skb_shared_info, gso_segs) !=
+					  sizeof(unsigned short));
+		off = offsetof(struct sk_buff, end);
+		off += offsetof(struct skb_shared_info, gso_segs);
+		*insn++ = BPF_LDX_MEM(BPF_SIZEOF(unsigned short), si->dst_reg,
+						 si->src_reg, off);
+		break;
 	}
 
 	return insn - insn_buf;
-- 
2.18.0.203.gfac676dfb9-goog

^ permalink raw reply related

* Re: [PATCH mlx5-next v1 1/8] net/mlx5: Add forward compatible support for the FTE match data
From: Yishai Hadas @ 2018-07-15  8:26 UTC (permalink / raw)
  To: Or Gerlitz
  Cc: Yishai Hadas, Doug Ledford, Jason Gunthorpe, Leon Romanovsky,
	RDMA mailing list, Saeed Mahameed, linux-netdev, Majd Dibbiny
In-Reply-To: <CAJ3xEMhO_89Fxj3=2=pas_R_9M6sPXOPu0V3saBaqeJ3j+-hkw@mail.gmail.com>

On 7/15/2018 11:03 AM, Or Gerlitz wrote:
> On Sun, Jul 15, 2018 at 10:26 AM, Yishai Hadas
> <yishaih@dev.mellanox.co.il> wrote:
>> On 7/12/2018 11:53 PM, Or Gerlitz wrote:
>>> On Wed, Jul 11, 2018 at 2:10 PM, Leon Romanovsky <leon@kernel.org> wrote:
>>>> From: Yishai Hadas <yishaih@mellanox.com>
> 
>>>> Use the PRM size including the reserved when working with the FTE
>>>> match data.
> 

> -- we need a clear memo as part of your change-logs and/or cover-letter/s that
> explains the overall approach/design for
> doing-things-without-changing-the-kernel,
> does this exist? 

Yes, the DEVX series that was previously accepted clearly stated that 
this is its target as part of its cover-letter [1]. This motivation 
appears also as part of this specific commit log.

 From the cover letter:
"The main purpose here is to make the user space driver as independent 
as possible from the kernel so that future device functionality and 
commands can be activated with minimal to none kernel changes.

[1]
https://patchwork.ozlabs.org/cover/930449/

^ permalink raw reply

* Re: general protection fault in bpf_tcp_close (2)
From: syzbot @ 2018-07-15  8:39 UTC (permalink / raw)
  To: ast, daniel, linux-kernel, netdev, syzkaller-bugs
In-Reply-To: <00000000000054fd6b0570be9fa8@google.com>

syzbot has found a reproducer for the following crash on:

HEAD commit:    13f7432bdd8e Merge branch 'bpf-tcp-listen-cb'
git tree:       bpf-next
console output: https://syzkaller.appspot.com/x/log.txt?x=12d6a9a4400000
kernel config:  https://syzkaller.appspot.com/x/.config?x=a501a01deaf0fe9
dashboard link: https://syzkaller.appspot.com/bug?extid=339037020e772651f1d8
compiler:       gcc (GCC) 8.0.1 20180413 (experimental)
syzkaller repro:https://syzkaller.appspot.com/x/repro.syz?x=1647db68400000
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=12a04d1c400000

IMPORTANT: if you fix the bug, please add the following tag to the commit:
Reported-by: syzbot+339037020e772651f1d8@syzkaller.appspotmail.com

random: sshd: uninitialized urandom read (32 bytes read)
random: sshd: uninitialized urandom read (32 bytes read)
random: sshd: uninitialized urandom read (32 bytes read)
kasan: CONFIG_KASAN_INLINE enabled
kasan: GPF could be caused by NULL-ptr deref or user memory access
general protection fault: 0000 [#1] SMP KASAN
CPU: 0 PID: 4474 Comm: syz-executor715 Not tainted 4.18.0-rc3+ #55
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS  
Google 01/01/2011
RIP: 0010:__hlist_del include/linux/list.h:679 [inline]
RIP: 0010:hlist_del_rcu include/linux/rculist.h:440 [inline]
RIP: 0010:bpf_tcp_close+0x94c/0x1050 kernel/bpf/sockmap.c:365
Code: 85 25 06 00 00 48 8d 95 18 ff ff ff 49 8b 4c 24 18 48 89 d6 48 c1 ee  
03 c6 04 1e 00 48 89 ce 48 c1 ee 03 48 89 85 18 ff ff ff <80> 3c 1e 00 0f  
85 bf 05 00 00 48 c1 ea 03 48 85 c0 48 89 01 48 89
RSP: 0018:ffff8801c5da7950 EFLAGS: 00010a02
RAX: 0000000000000000 RBX: dffffc0000000000 RCX: dead000000000200
RDX: ffff8801c5da7a40 RSI: 1bd5a00000000040 RDI: ffff8801d3175790
RBP: ffff8801c5da7b28 R08: ffff8801b3c50540 R09: ffffed003a62eb11
R10: ffffed003a62eb11 R11: ffff8801d317588b R12: ffff8801d3175780
R13: ffff8801aad5d800 R14: ffff8801d3175888 R15: ffff8801d3175798
FS:  00000000018e5880(0000) GS:ffff8801dae00000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f9b79d7fe78 CR3: 00000001aba3d000 CR4: 00000000001406f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
  inet_release+0x104/0x1f0 net/ipv4/af_inet.c:428
  inet6_release+0x50/0x70 net/ipv6/af_inet6.c:459
  __sock_release+0xd7/0x260 net/socket.c:599
  sock_close+0x19/0x20 net/socket.c:1150
  __fput+0x355/0x8b0 fs/file_table.c:209
  ____fput+0x15/0x20 fs/file_table.c:243
  task_work_run+0x1ec/0x2a0 kernel/task_work.c:113
  tracehook_notify_resume include/linux/tracehook.h:192 [inline]
  exit_to_usermode_loop+0x313/0x370 arch/x86/entry/common.c:166
  prepare_exit_to_usermode arch/x86/entry/common.c:197 [inline]
  syscall_return_slowpath arch/x86/entry/common.c:268 [inline]
  do_syscall_64+0x6be/0x820 arch/x86/entry/common.c:293
  entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x405781
Code: 75 14 b8 03 00 00 00 0f 05 48 3d 01 f0 ff ff 0f 83 54 17 00 00 c3 48  
83 ec 08 e8 6a fc ff ff 48 89 04 24 b8 03 00 00 00 0f 05 <48> 8b 3c 24 48  
89 c2 e8 b3 fc ff ff 48 89 d0 48 83 c4 08 48 3d 01
RSP: 002b:00007fff3d5e3680 EFLAGS: 00000293 ORIG_RAX: 0000000000000003
RAX: 0000000000000000 RBX: 0000000000000004 RCX: 0000000000405781
RDX: 0000000000000000 RSI: 0000000000000001 RDI: 0000000000000004
RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000293 R12: 0000000000006b70
R13: 00000000004073d0 R14: 0000000000000000 R15: 0000000000000000
Modules linked in:
Dumping ftrace buffer:
    (ftrace buffer empty)
---[ end trace 24c47acbb9ad1d76 ]---
RIP: 0010:__hlist_del include/linux/list.h:679 [inline]
RIP: 0010:hlist_del_rcu include/linux/rculist.h:440 [inline]
RIP: 0010:bpf_tcp_close+0x94c/0x1050 kernel/bpf/sockmap.c:365
Code: 85 25 06 00 00 48 8d 95 18 ff ff ff 49 8b 4c 24 18 48 89 d6 48 c1 ee  
03 c6 04 1e 00 48 89 ce 48 c1 ee 03 48 89 85 18 ff ff ff <80> 3c 1e 00 0f  
85 bf 05 00 00 48 c1 ea 03 48 85 c0 48 89 01 48 89
RSP: 0018:ffff8801c5da7950 EFLAGS: 00010a02
RAX: 0000000000000000 RBX: dffffc0000000000 RCX: dead000000000200
RDX: ffff8801c5da7a40 RSI: 1bd5a00000000040 RDI: ffff8801d3175790
RBP: ffff8801c5da7b28 R08: ffff8801b3c50540 R09: ffffed003a62eb11
R10: ffffed003a62eb11 R11: ffff8801d317588b R12: ffff8801d3175780
R13: ffff8801aad5d800 R14: ffff8801d3175888 R15: ffff8801d3175798
FS:  00000000018e5880(0000) GS:ffff8801dae00000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f9b79d7fe78 CR3: 00000001aba3d000 CR4: 00000000001406f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400

^ permalink raw reply

* Re: Fwd: [PATCH v1] datagram: return from __skb_recv_datagram() as soon as possible
From: gregkh @ 2018-07-15  9:32 UTC (permalink / raw)
  To: baoyou xie
  Cc: davem, willemb, viro, pombredanne, tklauser, matthew, scxby,
	netdev, linux-kernel
In-Reply-To: <CAPTX1NRsaLK9YmphwoiRyOLD+MxWJE2ZzEWOKQVzW-YS7T-vaA@mail.gmail.com>

On Sun, Jul 15, 2018 at 05:16:50PM +0800, baoyou xie wrote:
> The raw mail was posted back by linux-kernel@vger.kernel.org and 
> netdev@vger.kernel.org, so resend it by this email address.

You are sending HTML email, which is rejected by all kernel mailing
lists.

Please fix up your email client and try again.

greg k-h

^ permalink raw reply

* Re: Fwd: [PATCH v1] datagram: return from __skb_recv_datagram() as soon as possible
From: gregkh @ 2018-07-15 10:47 UTC (permalink / raw)
  To: baoyou xie
  Cc: davem, willemb, viro, pombredanne, tklauser, matthew, scxby,
	netdev, linux-kernel
In-Reply-To: <CAPTX1NQAMDE-5+4jnCmf+YKY1tTPTPJshE0VaUhgeU9RM3Zv_g@mail.gmail.com>

On Sun, Jul 15, 2018 at 06:27:16PM +0800, baoyou xie wrote:
> Thanks for gregkh's reply:-)
> It's sure that the mail was sent with git, so guys may commit this patch in
> this mail.

You are still sending html email, and you need to properly resend the
patch without that in order for anyone to even be able to see it.

greg k-h

^ permalink raw reply

* [PATCH v2] datagram: return from __skb_recv_datagram() as soon as possible
From: Baoyou Xie @ 2018-07-15 11:13 UTC (permalink / raw)
  To: davem, willemb, viro, gregkh, pombredanne, tklauser, matthew
  Cc: netdev, linux-kernel, Baoyou Xie

We got a soft lockup in a heavy busy cloud server where RIP is
at _raw_spin_unlock_irqrestore+0x1b/0x40:
        [] finish_wait+0x56/0x70
        [] __skb_recv_datagram+0x3fb/0x5a0
        [] ? datagram_poll+0x100/0x100
        [] skb_recv_datagram+0x41/0x60
        [] netlink_recvmsg+0x62/0x450
        [] sock_recvmsg+0xbf/0x100
        [] ? futex_wait+0x193/0x280
        [] ? finish_task_switch+0x108/0x170
        [] SYSC_recvfrom+0xe8/0x160
        [] ? __schedule+0x3c8/0x990
        [] SyS_recvfrom+0xe/0x10
        [] system_call_fastpath+0x16/0x1b

In fact, a mistake exists in __skb_recv_datagram(). For example,
if a datagram come in persistently after go through the socket
queue, then __skb_wait_for_more_packets() will find out that the
last peeked skb is not the real last one, so it return 0. this
results in long time outer loop, and can trigger soft lockup.

So this patch changes the loop condition to prevent soft lockup.

Signed-off-by: Baoyou Xie <baoyou.xie@gmail.com>
---
 net/core/datagram.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/core/datagram.c b/net/core/datagram.c
index 9938952..76c1001 100644
--- a/net/core/datagram.c
+++ b/net/core/datagram.c
@@ -295,9 +295,11 @@ struct sk_buff *__skb_recv_datagram(struct sock *sk, unsigned int flags,
 				    int *peeked, int *off, int *err)
 {
 	struct sk_buff *skb, *last;
+	unsigned long expire;
 	long timeo;
 
 	timeo = sock_rcvtimeo(sk, flags & MSG_DONTWAIT);
+	expire = jiffies + timeo;
 
 	do {
 		skb = __skb_try_recv_datagram(sk, flags, destructor, peeked,
@@ -307,7 +309,7 @@ struct sk_buff *__skb_recv_datagram(struct sock *sk, unsigned int flags,
 
 		if (*err != -EAGAIN)
 			break;
-	} while (timeo &&
+	} while (time_before(jiffies, expire) &&
 		!__skb_wait_for_more_packets(sk, err, &timeo, last));
 
 	return NULL;
-- 
2.7.4

^ permalink raw reply related

* [PATCH net] net/mlx4_en: Don't reuse RX page when XDP is set
From: Tariq Toukan @ 2018-07-15 10:54 UTC (permalink / raw)
  To: David S. Miller
  Cc: netdev, Eran Ben Elisha, Martin KaFai Lau, Saeed Mahameed,
	Tariq Toukan, Eric Dumazet

From: Saeed Mahameed <saeedm@mellanox.com>

When a new rx packet arrives, the rx path will decide whether to reuse
the remainder of the page or not according to one of the below conditions:
1. frag_info->frag_stride == PAGE_SIZE / 2
2. frags->page_offset + frag_info->frag_size > PAGE_SIZE;

The first condition is no met for when XDP is set.
For XDP, page_offset is always set to priv->rx_headroom which is
XDP_PACKET_HEADROOM and frag_info->frag_size is around mtu size + some
padding, still the 2nd release condition will hold since
XDP_PACKET_HEADROOM + 1536 < PAGE_SIZE, as a result the page will not
be released and will be _wrongly_ reused for next free rx descriptor.

In XDP there is an assumption to have a page per packet and reuse can
break such assumption and might cause packet data corruptions.

Fix this by adding an extra condition (!priv->rx_headroom) to the 2nd
case to avoid page reuse when XDP is set, since rx_headroom is set to 0
for non XDP setup and set to XDP_PACKET_HEADROOM for XDP setup.

No additional cache line is required for the new condition.

Fixes: 34db548bfb95 ("mlx4: add page recycling in receive path")
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
Signed-off-by: Tariq Toukan <tariqt@mellanox.com>
Suggested-by: Martin KaFai Lau <kafai@fb.com>
CC: Eric Dumazet <edumazet@google.com>
---
 drivers/net/ethernet/mellanox/mlx4/en_rx.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx4/en_rx.c b/drivers/net/ethernet/mellanox/mlx4/en_rx.c
index 9f54ccbddea7..3360f7b9ee73 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_rx.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_rx.c
@@ -474,10 +474,10 @@ static int mlx4_en_complete_rx_desc(struct mlx4_en_priv *priv,
 {
 	const struct mlx4_en_frag_info *frag_info = priv->frag_info;
 	unsigned int truesize = 0;
+	bool release = true;
 	int nr, frag_size;
 	struct page *page;
 	dma_addr_t dma;
-	bool release;
 
 	/* Collect used fragments while replacing them in the HW descriptors */
 	for (nr = 0;; frags++) {
@@ -500,7 +500,11 @@ static int mlx4_en_complete_rx_desc(struct mlx4_en_priv *priv,
 			release = page_count(page) != 1 ||
 				  page_is_pfmemalloc(page) ||
 				  page_to_nid(page) != numa_mem_id();
-		} else {
+		} else if (!priv->rx_headroom) {
+			/* rx_headroom for non XDP setup is always 0.
+			 * When XDP is set, the above condition will
+			 * guarantee page is always released.
+			 */
 			u32 sz_align = ALIGN(frag_size, SMP_CACHE_BYTES);
 
 			frags->page_offset += sz_align;
-- 
1.8.3.1

^ permalink raw reply related

* [PATCH] ARM: dts: sunxi: Remove unused address-cells/size-cells of dwmac-sun8i
From: Corentin Labbe @ 2018-07-15 11:55 UTC (permalink / raw)
  To: catalin.marinas, linux, mark.rutland, maxime.ripard, robh+dt,
	wens, will.deacon
  Cc: devicetree, netdev, linux-kernel, linux-sunxi, Corentin Labbe,
	linux-arm-kernel

address-cells/size-cells is unnecessary for dwmac-sun8i node.
It was in early days, but since a mdio node is used, it could be
removed.

This patch fix the following DT warning:
Warning (avoid_unnecessary_addr_size): /soc/ethernet@1c50000: unnecessary #address-cells/#size-cells without "ranges" or child "reg" property

Signed-off-by: Corentin Labbe <clabbe@baylibre.com>
---
 Documentation/devicetree/bindings/net/dwmac-sun8i.txt | 8 --------
 arch/arm/boot/dts/sun8i-a83t.dtsi                     | 2 --
 arch/arm/boot/dts/sun8i-r40.dtsi                      | 2 --
 arch/arm/boot/dts/sunxi-h3-h5.dtsi                    | 2 --
 arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi         | 2 --
 5 files changed, 16 deletions(-)

diff --git a/Documentation/devicetree/bindings/net/dwmac-sun8i.txt b/Documentation/devicetree/bindings/net/dwmac-sun8i.txt
index cfe724398a12..5bb3a18cc38d 100644
--- a/Documentation/devicetree/bindings/net/dwmac-sun8i.txt
+++ b/Documentation/devicetree/bindings/net/dwmac-sun8i.txt
@@ -19,8 +19,6 @@ Required properties:
 - reset-names: must be "stmmaceth"
 - phy-mode: See ethernet.txt
 - phy-handle: See ethernet.txt
-- #address-cells: shall be 1
-- #size-cells: shall be 0
 - syscon: A phandle to the device containing the EMAC or GMAC clock register
 
 Optional properties:
@@ -86,8 +84,6 @@ emac: ethernet@1c0b000 {
 	reset-names = "stmmaceth";
 	clocks = <&ccu CLK_BUS_EMAC>;
 	clock-names = "stmmaceth";
-	#address-cells = <1>;
-	#size-cells = <0>;
 
 	phy-handle = <&int_mii_phy>;
 	phy-mode = "mii";
@@ -137,8 +133,6 @@ emac: ethernet@1c0b000 {
 	reset-names = "stmmaceth";
 	clocks = <&ccu CLK_BUS_EMAC>;
 	clock-names = "stmmaceth";
-	#address-cells = <1>;
-	#size-cells = <0>;
 
 	phy-handle = <&ext_rgmii_phy>;
 	phy-mode = "rgmii";
@@ -191,8 +185,6 @@ emac: ethernet@1c0b000 {
 	reset-names = "stmmaceth";
 	clocks = <&ccu CLK_BUS_EMAC>;
 	clock-names = "stmmaceth";
-	#address-cells = <1>;
-	#size-cells = <0>;
 
 	phy-handle = <&ext_rgmii_phy>;
 	phy-mode = "rgmii";
diff --git a/arch/arm/boot/dts/sun8i-a83t.dtsi b/arch/arm/boot/dts/sun8i-a83t.dtsi
index b047f05e690d..276c99fcfcc8 100644
--- a/arch/arm/boot/dts/sun8i-a83t.dtsi
+++ b/arch/arm/boot/dts/sun8i-a83t.dtsi
@@ -913,8 +913,6 @@
 			reset-names = "stmmaceth";
 			clocks = <&ccu 27>;
 			clock-names = "stmmaceth";
-			#address-cells = <1>;
-			#size-cells = <0>;
 			status = "disabled";
 
 			mdio: mdio {
diff --git a/arch/arm/boot/dts/sun8i-r40.dtsi b/arch/arm/boot/dts/sun8i-r40.dtsi
index cb8932bcef0d..bd369112a400 100644
--- a/arch/arm/boot/dts/sun8i-r40.dtsi
+++ b/arch/arm/boot/dts/sun8i-r40.dtsi
@@ -576,8 +576,6 @@
 			reset-names = "stmmaceth";
 			clocks = <&ccu CLK_BUS_GMAC>;
 			clock-names = "stmmaceth";
-			#address-cells = <1>;
-			#size-cells = <0>;
 			status = "disabled";
 
 			gmac_mdio: mdio {
diff --git a/arch/arm/boot/dts/sunxi-h3-h5.dtsi b/arch/arm/boot/dts/sunxi-h3-h5.dtsi
index 90021f38c1ef..f0352b8da19f 100644
--- a/arch/arm/boot/dts/sunxi-h3-h5.dtsi
+++ b/arch/arm/boot/dts/sunxi-h3-h5.dtsi
@@ -516,8 +516,6 @@
 			reset-names = "stmmaceth";
 			clocks = <&ccu CLK_BUS_EMAC>;
 			clock-names = "stmmaceth";
-			#address-cells = <1>;
-			#size-cells = <0>;
 			status = "disabled";
 
 			mdio: mdio {
diff --git a/arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi b/arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi
index 91dd5dd9e205..357f6cba00cd 100644
--- a/arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi
+++ b/arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi
@@ -668,8 +668,6 @@
 			clocks = <&ccu CLK_BUS_EMAC>;
 			clock-names = "stmmaceth";
 			status = "disabled";
-			#address-cells = <1>;
-			#size-cells = <0>;
 
 			mdio: mdio {
 				compatible = "snps,dwmac-mdio";
-- 
2.16.4

^ permalink raw reply related

* general protection fault in smc_ioctl (2)
From: syzbot @ 2018-07-15 13:49 UTC (permalink / raw)
  To: davem, linux-kernel, linux-s390, netdev, syzkaller-bugs, ubraun

Hello,

syzbot found the following crash on:

HEAD commit:    9cee8c437543 net: mvpp2: mvpp2_cls_flow_get() can be static
git tree:       net-next
console output: https://syzkaller.appspot.com/x/log.txt?x=12807b70400000
kernel config:  https://syzkaller.appspot.com/x/.config?x=89129667b46496c3
dashboard link: https://syzkaller.appspot.com/bug?extid=35b2c5aa76fd398b9fd4
compiler:       gcc (GCC) 8.0.1 20180413 (experimental)
syzkaller repro:https://syzkaller.appspot.com/x/repro.syz?x=14e9cf0c400000
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=136325d0400000

IMPORTANT: if you fix the bug, please add the following tag to the commit:
Reported-by: syzbot+35b2c5aa76fd398b9fd4@syzkaller.appspotmail.com

kasan: CONFIG_KASAN_INLINE enabled
kasan: GPF could be caused by NULL-ptr deref or user memory access
general protection fault: 0000 [#1] SMP KASAN
CPU: 0 PID: 4516 Comm: syz-executor129 Not tainted 4.18.0-rc3+ #121
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS  
Google 01/01/2011
RIP: 0010:smc_ioctl+0x846/0xd00 net/smc/af_smc.c:1748
Code: 48 c1 e9 03 80 3c 11 00 0f 85 29 04 00 00 4d 8b b6 a0 04 00 00 48 ba  
00 00 00 00 00 fc ff df 49 8d 7e 20 48 89 f9 48 c1 e9 03 <0f> b6 14 11 84  
d2 74 09 80 fa 03 0f 8e 65 03 00 00 48 8d 7b 02 41
RSP: 0018:ffff8801b258f750 EFLAGS: 00010202
RAX: ffff8801b258f7c8 RBX: ffff8801b258f788 RCX: 0000000000000004
RDX: dffffc0000000000 RSI: 1ffff100364b1ef9 RDI: 0000000000000020
RBP: ffff8801b258f9b0 R08: ffffed00364b1efa R09: ffffed00364b1ef9
R10: ffffed00364b1ef9 R11: ffff8801b258f7cf R12: 1ffff100364b1eed
R13: 0000000020000040 R14: 0000000000000000 R15: 1ffff100364b1f11
FS:  00007fdddb23c700(0000) GS:ffff8801dae00000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007fdddb21ae78 CR3: 00000001b6c9a000 CR4: 00000000001406f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
  sock_do_ioctl+0xe4/0x3e0 net/socket.c:969
  sock_ioctl+0x30d/0x680 net/socket.c:1093
  vfs_ioctl fs/ioctl.c:46 [inline]
  file_ioctl fs/ioctl.c:500 [inline]
  do_vfs_ioctl+0x1de/0x1720 fs/ioctl.c:684
  ksys_ioctl+0xa9/0xd0 fs/ioctl.c:701
  __do_sys_ioctl fs/ioctl.c:708 [inline]
  __se_sys_ioctl fs/ioctl.c:706 [inline]
  __x64_sys_ioctl+0x73/0xb0 fs/ioctl.c:706
  do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
  entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x445e89
Code: e8 7c e6 ff ff 48 83 c4 18 c3 0f 1f 80 00 00 00 00 48 89 f8 48 89 f7  
48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff  
ff 0f 83 eb 0c fc ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007fdddb23bdb8 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00000000006dbc3c RCX: 0000000000445e89
RDX: 0000000020000040 RSI: 0000000000008905 RDI: 000000000000006d
RBP: 00000000006dbc38 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007ffe54550fbf R14: 00007fdddb23c9c0 R15: 0000000000000004
Modules linked in:
Dumping ftrace buffer:
    (ftrace buffer empty)
---[ end trace 924422afa249de86 ]---
RIP: 0010:smc_ioctl+0x846/0xd00 net/smc/af_smc.c:1748
Code: 48 c1 e9 03 80 3c 11 00 0f 85 29 04 00 00 4d 8b b6 a0 04 00 00 48 ba  
00 00 00 00 00 fc ff df 49 8d 7e 20 48 89 f9 48 c1 e9 03 <0f> b6 14 11 84  
d2 74 09 80 fa 03 0f 8e 65 03 00 00 48 8d 7b 02 41
RSP: 0018:ffff8801b258f750 EFLAGS: 00010202
RAX: ffff8801b258f7c8 RBX: ffff8801b258f788 RCX: 0000000000000004
RDX: dffffc0000000000 RSI: 1ffff100364b1ef9 RDI: 0000000000000020
RBP: ffff8801b258f9b0 R08: ffffed00364b1efa R09: ffffed00364b1ef9
R10: ffffed00364b1ef9 R11: ffff8801b258f7cf R12: 1ffff100364b1eed
R13: 0000000020000040 R14: 0000000000000000 R15: 1ffff100364b1f11
FS:  00007fdddb23c700(0000) GS:ffff8801dae00000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007fdddb21ae78 CR3: 00000001b6c9a000 CR4: 00000000001406f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400


---
This bug is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzkaller@googlegroups.com.

syzbot will keep track of this bug report. See:
https://goo.gl/tpsmEJ#bug-status-tracking for how to communicate with  
syzbot.
syzbot can test patches for this bug, for details see:
https://goo.gl/tpsmEJ#testing-patches

^ permalink raw reply

* Re: general protection fault in smc_ioctl (2)
From: Eric Dumazet @ 2018-07-15 13:56 UTC (permalink / raw)
  To: syzbot, davem, linux-kernel, linux-s390, netdev, syzkaller-bugs,
	ubraun, Stefan Raspl
In-Reply-To: <000000000000d62689057109f9b4@google.com>



On 07/15/2018 06:49 AM, syzbot wrote:
> Hello,
> 
> syzbot found the following crash on:
> 
> HEAD commit:    9cee8c437543 net: mvpp2: mvpp2_cls_flow_get() can be static
> git tree:       net-next
> console output: https://syzkaller.appspot.com/x/log.txt?x=12807b70400000
> kernel config:  https://syzkaller.appspot.com/x/.config?x=89129667b46496c3
> dashboard link: https://syzkaller.appspot.com/bug?extid=35b2c5aa76fd398b9fd4
> compiler:       gcc (GCC) 8.0.1 20180413 (experimental)
> syzkaller repro:https://syzkaller.appspot.com/x/repro.syz?x=14e9cf0c400000
> C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=136325d0400000
> 
> IMPORTANT: if you fix the bug, please add the following tag to the commit:
> Reported-by: syzbot+35b2c5aa76fd398b9fd4@syzkaller.appspotmail.com
> 
> kasan: CONFIG_KASAN_INLINE enabled
> kasan: GPF could be caused by NULL-ptr deref or user memory access
> general protection fault: 0000 [#1] SMP KASAN
> CPU: 0 PID: 4516 Comm: syz-executor129 Not tainted 4.18.0-rc3+ #121
> Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
> RIP: 0010:smc_ioctl+0x846/0xd00 net/smc/af_smc.c:1748
> Code: 48 c1 e9 03 80 3c 11 00 0f 85 29 04 00 00 4d 8b b6 a0 04 00 00 48 ba 00 00 00 00 00 fc ff df 49 8d 7e 20 48 89 f9 48 c1 e9 03 <0f> b6 14 11 84 d2 74 09 80 fa 03 0f 8e 65 03 00 00 48 8d 7b 02 41
> RSP: 0018:ffff8801b258f750 EFLAGS: 00010202
> RAX: ffff8801b258f7c8 RBX: ffff8801b258f788 RCX: 0000000000000004
> RDX: dffffc0000000000 RSI: 1ffff100364b1ef9 RDI: 0000000000000020
> RBP: ffff8801b258f9b0 R08: ffffed00364b1efa R09: ffffed00364b1ef9
> R10: ffffed00364b1ef9 R11: ffff8801b258f7cf R12: 1ffff100364b1eed
> R13: 0000000020000040 R14: 0000000000000000 R15: 1ffff100364b1f11
> FS:  00007fdddb23c700(0000) GS:ffff8801dae00000(0000) knlGS:0000000000000000
> CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> CR2: 00007fdddb21ae78 CR3: 00000001b6c9a000 CR4: 00000000001406f0
> DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
> DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
> Call Trace:
>  sock_do_ioctl+0xe4/0x3e0 net/socket.c:969
>  sock_ioctl+0x30d/0x680 net/socket.c:1093
>  vfs_ioctl fs/ioctl.c:46 [inline]
>  file_ioctl fs/ioctl.c:500 [inline]
>  do_vfs_ioctl+0x1de/0x1720 fs/ioctl.c:684
>  ksys_ioctl+0xa9/0xd0 fs/ioctl.c:701
>  __do_sys_ioctl fs/ioctl.c:708 [inline]
>  __se_sys_ioctl fs/ioctl.c:706 [inline]
>  __x64_sys_ioctl+0x73/0xb0 fs/ioctl.c:706
>  do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
>  entry_SYSCALL_64_after_hwframe+0x49/0xbe
> RIP: 0033:0x445e89
> Code: e8 7c e6 ff ff 48 83 c4 18 c3 0f 1f 80 00 00 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 0f 83 eb 0c fc ff c3 66 2e 0f 1f 84 00 00 00 00
> RSP: 002b:00007fdddb23bdb8 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
> RAX: ffffffffffffffda RBX: 00000000006dbc3c RCX: 0000000000445e89
> RDX: 0000000020000040 RSI: 0000000000008905 RDI: 000000000000006d
> RBP: 00000000006dbc38 R08: 0000000000000000 R09: 0000000000000000
> R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
> R13: 00007ffe54550fbf R14: 00007fdddb23c9c0 R15: 0000000000000004
> Modules linked in:
> Dumping ftrace buffer:
>    (ftrace buffer empty)
> ---[ end trace 924422afa249de86 ]---
> RIP: 0010:smc_ioctl+0x846/0xd00 net/smc/af_smc.c:1748
> Code: 48 c1 e9 03 80 3c 11 00 0f 85 29 04 00 00 4d 8b b6 a0 04 00 00 48 ba 00 00 00 00 00 fc ff df 49 8d 7e 20 48 89 f9 48 c1 e9 03 <0f> b6 14 11 84 d2 74 09 80 fa 03 0f 8e 65 03 00 00 48 8d 7b 02 41
> RSP: 0018:ffff8801b258f750 EFLAGS: 00010202
> RAX: ffff8801b258f7c8 RBX: ffff8801b258f788 RCX: 0000000000000004
> RDX: dffffc0000000000 RSI: 1ffff100364b1ef9 RDI: 0000000000000020
> RBP: ffff8801b258f9b0 R08: ffffed00364b1efa R09: ffffed00364b1ef9
> R10: ffffed00364b1ef9 R11: ffff8801b258f7cf R12: 1ffff100364b1eed
> R13: 0000000020000040 R14: 0000000000000000 R15: 1ffff100364b1f11
> FS:  00007fdddb23c700(0000) GS:ffff8801dae00000(0000) knlGS:0000000000000000
> CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> CR2: 00007fdddb21ae78 CR3: 00000001b6c9a000 CR4: 00000000001406f0
> DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
> DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
> 
> 
> ---
> This bug is generated by a bot. It may contain errors.
> See https://goo.gl/tpsmEJ for more information about syzbot.
> syzbot engineers can be reached at syzkaller@googlegroups.com.
> 
> syzbot will keep track of this bug report. See:
> https://goo.gl/tpsmEJ#bug-status-tracking for how to communicate with syzbot.
> syzbot can test patches for this bug, for details see:
> https://goo.gl/tpsmEJ#testing-patches


Probably caused by commit de8474eb9d50fd47b8c73816f34739dec5e96754
("net/smc: urgent data support")

^ permalink raw reply

* Re: [PATCH net] tcp: Fix broken repair socket window probe patch
From: Neal Cardwell @ 2018-07-15 14:57 UTC (permalink / raw)
  To: sbaranoff
  Cc: avagin, xemul, Eric Dumazet, David Miller, Alexey Kuznetsov,
	Hideaki YOSHIFUJI, Netdev, LKML
In-Reply-To: <1531619649-1518-1-git-send-email-sbaranoff@gmail.com>

On Sat, Jul 14, 2018 at 9:54 PM Stefan Baranoff <sbaranoff@gmail.com> wrote:
>
> Correct previous bad attempt at allowing sockets to come out of TCP
> repair without sending window probes. To avoid changing size of
> the repair variable in struct tcp_sock, this lets the decision for
> sending probes or not to be made when coming out of repair by
> introducing two ways to turn it off.
>
> Fixes: 70b7ff130224 ("tcp: allow user to create repair socket without window probes")
> Signed-off-by: Stefan Baranoff <sbaranoff@gmail.com>
> ---
>  include/uapi/linux/tcp.h |  4 ++++
>  net/ipv4/tcp.c           | 12 +++++++-----
>  2 files changed, 11 insertions(+), 5 deletions(-)
>
> diff --git a/include/uapi/linux/tcp.h b/include/uapi/linux/tcp.h
> index 29eb659..e3f6ed8 100644
> --- a/include/uapi/linux/tcp.h
> +++ b/include/uapi/linux/tcp.h
> @@ -127,6 +127,10 @@ enum {
>
>  #define TCP_CM_INQ             TCP_INQ
>
> +#define TCP_REPAIR_ON          1
> +#define TCP_REPAIR_OFF         0
> +#define TCP_REPAIR_OFF_NO_WP   -1      /* Turn off without window probes */
> +
>  struct tcp_repair_opt {
>         __u32   opt_code;
>         __u32   opt_val;
> diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
> index 8e5e2ca..9163fb1 100644
> --- a/net/ipv4/tcp.c
> +++ b/net/ipv4/tcp.c
> @@ -2824,15 +2824,17 @@ static int do_tcp_setsockopt(struct sock *sk, int level,
>                 if (!tcp_can_repair_sock(sk))
>                         err = -EPERM;
>                 /* 1 for normal repair, 2 for no window probes */

Looks like this comment is now inconsistent with the code.

cheers,
neal

^ permalink raw reply

* [PATCH net,v2] tcp: Fix broken repair socket window probe patch
From: Stefan Baranoff @ 2018-07-15 15:36 UTC (permalink / raw)
  Cc: Andrey Vagin, Pavel Emelyanov, Stefan Baranoff, Eric Dumazet,
	David S. Miller, Alexey Kuznetsov, Hideaki YOSHIFUJI, netdev,
	linux-kernel

Correct previous bad attempt at allowing sockets to come out of TCP
repair without sending window probes. To avoid changing size of
the repair variable in struct tcp_sock, this lets the decision for
sending probes or not to be made when coming out of repair by
introducing two ways to turn it off.

v2:
* Remove erroneous comment; defines now make behavior clear

Fixes: 70b7ff130224 ("tcp: allow user to create repair socket without window probes")
Signed-off-by: Stefan Baranoff <sbaranoff@gmail.com>
---
 include/uapi/linux/tcp.h |  4 ++++
 net/ipv4/tcp.c           | 13 +++++++------
 2 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/include/uapi/linux/tcp.h b/include/uapi/linux/tcp.h
index 29eb659..e3f6ed8 100644
--- a/include/uapi/linux/tcp.h
+++ b/include/uapi/linux/tcp.h
@@ -127,6 +127,10 @@ enum {
 
 #define TCP_CM_INQ		TCP_INQ
 
+#define TCP_REPAIR_ON		1
+#define TCP_REPAIR_OFF		0
+#define TCP_REPAIR_OFF_NO_WP	-1	/* Turn off without window probes */
+
 struct tcp_repair_opt {
 	__u32	opt_code;
 	__u32	opt_val;
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 8e5e2ca..ec2186e 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -2823,16 +2823,17 @@ static int do_tcp_setsockopt(struct sock *sk, int level,
 	case TCP_REPAIR:
 		if (!tcp_can_repair_sock(sk))
 			err = -EPERM;
-		/* 1 for normal repair, 2 for no window probes */
-		else if (val == 1 || val == 2) {
-			tp->repair = val;
+		else if (val == TCP_REPAIR_ON) {
+			tp->repair = 1;
 			sk->sk_reuse = SK_FORCE_REUSE;
 			tp->repair_queue = TCP_NO_QUEUE;
-		} else if (val == 0) {
+		} else if (val == TCP_REPAIR_OFF) {
+			tp->repair = 0;
+			sk->sk_reuse = SK_NO_REUSE;
+			tcp_send_window_probe(sk);
+		} else if (val == TCP_REPAIR_OFF_NO_WP) {
 			tp->repair = 0;
 			sk->sk_reuse = SK_NO_REUSE;
-			if (tp->repair == 1)
-				tcp_send_window_probe(sk);
 		} else
 			err = -EINVAL;
 
-- 
1.8.3.1

^ permalink raw reply related

* [PATCH v2 net] net/ipv6: Do not allow device only routes via the multipath API
From: dsahern @ 2018-07-15 16:35 UTC (permalink / raw)
  To: netdev; +Cc: eric.dumazet, David Ahern

From: David Ahern <dsahern@gmail.com>

Eric reported that reverting the patch that fixed and simplified IPv6
multipath routes means reverting back to invalid userspace notifications.
eg.,
$ ip -6 route add 2001:db8:1::/64 nexthop dev eth0 nexthop dev eth1

only generates a single notification:
2001:db8:1::/64 dev eth0 metric 1024 pref medium

While working on a fix for this problem I found another case that is just
broken completely - a multipath route with a gateway followed by device
followed by gateway:
    $ ip -6 ro add 2001:db8:103::/64
          nexthop via 2001:db8:1::64
          nexthop dev dummy2
          nexthop via 2001:db8:3::64

In this case the device only route is dropped completely - no notification
to userpsace but no addition to the FIB either:

$ ip -6 ro ls
2001:db8:1::/64 dev dummy1 proto kernel metric 256 pref medium
2001:db8:2::/64 dev dummy2 proto kernel metric 256 pref medium
2001:db8:3::/64 dev dummy3 proto kernel metric 256 pref medium
2001:db8:103::/64 metric 1024
	nexthop via 2001:db8:1::64 dev dummy1 weight 1
	nexthop via 2001:db8:3::64 dev dummy3 weight 1 pref medium
fe80::/64 dev dummy1 proto kernel metric 256 pref medium
fe80::/64 dev dummy2 proto kernel metric 256 pref medium
fe80::/64 dev dummy3 proto kernel metric 256 pref medium

Really, IPv6 multipath is just FUBAR'ed beyond repair when it comes to
device only routes, so do not allow it all.

This change will break any scripts relying on the mpath api for insert,
but I don't see any other way to handle the permutations. Besides, since
the routes are added to the FIB as standalone (non-multipath) routes the
kernel is not doing what the user requested, so it might as well tell the
user that.

Reported-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: David Ahern <dsahern@gmail.com>
---
v2:
- error should be negative as noted by Stefano

 net/ipv6/route.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 63f99411f0de..1f1f0f318d74 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -4388,6 +4388,13 @@ static int ip6_route_multipath_add(struct fib6_config *cfg,
 			rt = NULL;
 			goto cleanup;
 		}
+		if (!rt6_qualify_for_ecmp(rt)) {
+			err = -EINVAL;
+			NL_SET_ERR_MSG(extack,
+				       "Device only routes can not be added for IPv6 using the multipath API.");
+			fib6_info_release(rt);
+			goto cleanup;
+		}
 
 		rt->fib6_nh.nh_weight = rtnh->rtnh_hops + 1;
 
-- 
2.11.0

^ permalink raw reply related

* Re: [RFC net-next 00/15] net: A socket API for LoRa
From: Andreas Färber @ 2018-07-15 18:13 UTC (permalink / raw)
  To: Ben Whitten
  Cc: netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, Jian-Hong Pan, Jiri Pirko,
	Marcel Holtmann, David S . Miller, Matthias Brugger, Janus Piwek,
	Michael Röder, Dollar Chen, Ken Yu, Konstantin Böhm,
	Jan Jongboom, Jon Ortego, contact@snootlab.com, Brian Ray
In-Reply-To: <BY1PR02MB11147C7443AB9623D6B65798E75A0@BY1PR02MB1114.namprd02.prod.outlook.com>

+ linux-wireless + Stefan + Seth

Am 11.07.2018 um 17:21 schrieb Ben Whitten:
>> This patchset is clearly not ready for merging, but is being
>> submitted for
>> discussion, as requested by Jiri, in particular of the design
>> choices:
>>
>> 1) PF_LORA/AF_LORA and associated identifiers are
>> proposed to represent
>>    this technology. While for an SX1276 - case a) above - it
>> might work to
>>    layer LoRaWAN as a protocol option for PF_LORA and add
>> LoRaWAN address
>>    fields to the union in my sockaddr_lora, how would that
>> work for devices
>>    that only support LoRaWAN but not pure LoRa? Do we
>> need both AF_LORA and
>>    AF_LORAWAN, or just a separate ETH_P_LORAWAN or
>> ARPHRD_LORAWAN?
>>
>> 2) PF_LORA is used with SOCK_DGRAM here. The
>> assumption is that RAW mode
>>    would be DGRAM plus preamble plus optional checksum.
>>
>> 3) Only the transmit path is partially implemented already.
>> The assumption
>>    is that the devices should go into receive mode by default
>> and only
>>    interrupt that when asked to transmit.
>>
>> 4) Some hardware settings need to be supplied externally,
>> such as the radio
>>    frequency for some modules, but many others can be
>> runtime-configured,
>>    such as Spreading Factor, Bandwidth, Sync Word, or which
>> antenna to use.
>>    What settings should be implemented as socket option vs.
>> netlink layer
>>    vs. ioctl vs. sysfs? What are the criteria to apply?
>>
>> 5) Many of the modules support multiple modes, such as
>> LoRa, LoRaWAN and FSK.
>>    Lacking a LoRaWAN implementation, I am currently
>> switching them into LoRa
>>    mode at probe time wherever possible. How do we deal
>> with that properly?
>>
>>   a) Is there any precedence from the Wifi world for
>> dynamically selecting
>>      between our own trusted Open Source implementation
>> vs. hardware/firmware
>>      accelerated and/or certified implementations?
>>
>>   b) Would a proof of concept for FSK (non-LoRa) modes be
>> required for
>>      merging any LoRa driver for chipsets that support both?
>> Or is there any
>>      facility or design guidelines that would allow us to focus
>> on LoRa and
>>      LoRaWAN and leave non-LoRa radio modes to later
>> contributors?
> 
> Down the line I think we should also plan for a CRDA style regdb somewhere in the path for raw LoRa transceivers operating as softMAC, much like with WiFi.

Yes, I had raised the topic of wireless-regdb for Stefan's conference -
currently it seems to only cover 2.4 GHz, 5 GHz and 60 GHz. Not sure if
we can easily extend that to cover 433 MHz, 868 MHz, 915 MHz and 923 MHz
bands or whether we'd just need something similar... Is 802.15.4 able to
share this database with Wifi?

An argument to share with Wifi might be that Semtech's SX1280 and SX1281
2.4 GHz transceivers claim to support LoRa modulation, too. Having two
different regulatory DBs interact with LoRa drivers seems a bad idea,
and duplicating 2.4 GHz into a new DB doesn't sound appealing either.

https://www.semtech.com/products/wireless-rf/24-ghz-transceivers

Meanwhile my attempt to play with netlink during SUSE Hackweek has been
going slow and I could use some guidance or a volunteer to contribute: I
have a bare skeleton of registration, commands, attributes and multicast
groups, but no plan yet how to connect that to the actual drivers to
query or apply the settings...

https://git.kernel.org/pub/scm/linux/kernel/git/afaerber/linux-lora.git/tree/net/lora/netlink.c?h=lora-next

> LoRa radios used in Gateway devices are typically relatively high power (capable of 27dBm) and operate in bands with certain restrictions, eg the EU has keep out areas within 868MHz for alarms and SRD devices must abide by certain duty cycle restrictions, there are also maximum powers to consider for sub-bands. (ETSI EN 300 220-2 V3.2.1, Bands K, L, M, N, P, Q)

> The certified AT style modules will (should) already have this regulatory data baked in so it only applied to situations where we drive the transceivers directly, but it wouldn't hurt to check that the frequency being asked to transmit on doesn't spill into a restricted band.

Some do have configuration options that will need to be set or checked.

Regards,
Andreas

-- 
SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)

^ permalink raw reply

* [PATCH net] net/mlx5e: Move mlx5e_priv_flags into en_ethtool.c
From: Kamal Heib @ 2018-07-15 19:06 UTC (permalink / raw)
  To: David S . Miller, Saeed Mahameed; +Cc: netdev, Kamal Heib

Move the definition of mlx5e_priv_flags into en_ethtool.c because it's
only used there.

Fixes: 4e59e2888139 ("net/mlx5e: Introduce net device priv flags infrastructure")
Signed-off-by: Kamal Heib <kamalheib1@gmail.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/en.h         | 7 -------
 drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c | 7 +++++++
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en.h b/drivers/net/ethernet/mellanox/mlx5/core/en.h
index eb9eb7aa953a..84e6a5b42286 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en.h
@@ -208,13 +208,6 @@ struct mlx5e_umr_wqe {
 
 extern const char mlx5e_self_tests[][ETH_GSTRING_LEN];
 
-static const char mlx5e_priv_flags[][ETH_GSTRING_LEN] = {
-	"rx_cqe_moder",
-	"tx_cqe_moder",
-	"rx_cqe_compress",
-	"rx_striding_rq",
-};
-
 enum mlx5e_priv_flag {
 	MLX5E_PFLAG_RX_CQE_BASED_MODER = (1 << 0),
 	MLX5E_PFLAG_TX_CQE_BASED_MODER = (1 << 1),
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
index fffe514ba855..2a1c35d82c2e 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
@@ -33,6 +33,13 @@
 #include "en.h"
 #include "en/port.h"
 
+static const char mlx5e_priv_flags[][ETH_GSTRING_LEN] = {
+	"rx_cqe_moder",
+	"tx_cqe_moder",
+	"rx_cqe_compress",
+	"rx_striding_rq",
+};
+
 void mlx5e_ethtool_get_drvinfo(struct mlx5e_priv *priv,
 			       struct ethtool_drvinfo *drvinfo)
 {
-- 
2.14.4

^ permalink raw reply related


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