Netdev List
 help / color / mirror / Atom feed
* [PATCHv2 net-next 5/5] sctp: check for ipv6_pinfo legal sndflow with flowlabel in sctp_v6_get_dst
From: Xin Long @ 2018-07-02 10:21 UTC (permalink / raw)
  To: network dev, linux-sctp
  Cc: Marcelo Ricardo Leitner, Neil Horman, davem, hideaki.yoshifuji
In-Reply-To: <cover.1530526661.git.lucien.xin@gmail.com>

The transport with illegal flowlabel should not be allowed to send
packets. Other transport protocols already denies this.

Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
 net/sctp/ipv6.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
index 772513d..d83ddc4 100644
--- a/net/sctp/ipv6.c
+++ b/net/sctp/ipv6.c
@@ -262,6 +262,15 @@ static void sctp_v6_get_dst(struct sctp_transport *t, union sctp_addr *saddr,
 	if (t->flowlabel & SCTP_FLOWLABEL_SET_MASK)
 		fl6->flowlabel = htonl(t->flowlabel & SCTP_FLOWLABEL_VAL_MASK);
 
+	if (np->sndflow && (fl6->flowlabel & IPV6_FLOWLABEL_MASK)) {
+		struct ip6_flowlabel *flowlabel;
+
+		flowlabel = fl6_sock_lookup(sk, fl6->flowlabel);
+		if (!flowlabel)
+			goto out;
+		fl6_sock_release(flowlabel);
+	}
+
 	pr_debug("%s: dst=%pI6 ", __func__, &fl6->daddr);
 
 	if (asoc)
-- 
2.1.0

^ permalink raw reply related

* Re: [PATCH net] tcp: prevent bogus FRTO undos with non-SACK flows
From: Ilpo Järvinen @ 2018-07-02 10:26 UTC (permalink / raw)
  To: Neal Cardwell; +Cc: Netdev, Yuchung Cheng, Eric Dumazet, Michal Kubecek
In-Reply-To: <CADVnQymia_drxUkUP1V8MvqCObyKUXhg+xjrssef9S5D8GYnKw@mail.gmail.com>

On Sat, 30 Jun 2018, Neal Cardwell wrote:

> As I mentioned, I ran your patch through all our team's TCP
> packetdrill tests, and it passes all of the tests. One of our tests
> needed updating, because if there is a non-SACK connection with a
> spurious RTO due to a delayed flight of ACKs then the FRTO undo now
> happens one ACK later (when we get an ACK that doesn't cover a
> retransmit). But that seems fine to me.

Yes, this is what is wanted. The non-SACK FRTO cannot make decision on 
the first cumulative ACK because that could be (often is) triggered by the 
retransmit but only from the next ACK after that.

Even with SACK FRTO, there is a hazard on doing it that early as tail ACK 
losses can lead to discovery of newly SACKed skbs from ACK of the
retransmitted segment. For that to occur, however, the cumulative ACK 
cannot cover those skbs implying more holes that need to be recovered. 
Therefore, the window reduction will eventually occur anyway but it would 
still first do a bogus undo also in that case.

> I also cooked the new packetdrill test below to explicitly cover this
> case you are addressing (please let me know if you have an alternate
> suggestion).
> 
> Tested-by: Neal Cardwell <ncardwell@google.com>
> Acked-by: Neal Cardwell <ncardwell@google.com>
> 
> Thanks!
> neal
> 
> ---
> 
>     0 socket(..., SOCK_STREAM, IPPROTO_TCP) = 3
>    +0 setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
>    +0 bind(3, ..., ...) = 0
>    +0 listen(3, 1) = 0
> 
>    +0 < S 0:0(0) win 32792 <mss 1000,nop,wscale 7>
>    +0 > S. 0:0(0) ack 1 <mss 1460,nop,wscale 8>
>  +.02 < . 1:1(0) ack 1 win 257
>    +0 accept(3, ..., ...) = 4
> 
> // Send 3 packets. First is really lost. And the dupacks
> // for the data packets that arrived at the reciver are slow in arriving.
>    +0 write(4, ..., 3000) = 3000
>    +0 > P. 1:3001(3000) ack 1
> 
> // RTO and retransmit head. This fills a real loss.
>  +.22 > . 1:1001(1000) ack 1
> 
> // Dupacks for packets 2 and 3 arrive.
> +.02  < . 1:1(0) ack 1 win 257
>    +0 < . 1:1(0) ack 1 win 257
> 
> // The cumulative ACK for all the data arrives. We do not undo, because
> // this is a non-SACK connection, and retransmitted data was ACKed.
> // It's good that there's no FRTO undo, since a packet was really lost.
> // Because this is non-SACK, tcp_try_undo_recovery() holds CA_Loss
> // until something beyond high_seq is ACKed.
> +.005 < . 1:1(0) ack 3001 win 257
>    +0 %{ assert tcpi_ca_state == TCP_CA_Loss, tcpi_ca_state }%
>    +0 %{ assert tcpi_snd_cwnd == 4, tcpi_snd_cwnd }%
>    +0 %{ assert tcpi_snd_ssthresh == 7, tcpi_snd_ssthresh }%

I think that the snd_cwnd is still fishy there but that would 
require also the other patch from my series (cwnd was 1 so it should be 2 
after the cumulative ACK).


-- 
 i.

^ permalink raw reply

* Re: [RFC PATCH] ipv6: make ipv6_renew_options() interrupt/kernel safe
From: Paul Moore @ 2018-07-02 11:03 UTC (permalink / raw)
  To: netdev; +Cc: Al Viro, selinux, linux-security-module
In-Reply-To: <153050046203.740.13741366203375982437.stgit@chester>

On July 1, 2018 11:01:04 PM Paul Moore <pmoore@redhat.com> wrote:

> From: Paul Moore <paul@paul-moore.com>
>
> At present the ipv6_renew_options_kern() function ends up calling into
> access_ok() which is problematic if done from inside an interrupt as
> access_ok() calls WARN_ON_IN_IRQ() on some (all?) architectures
> (x86-64 is affected).  Example warning/backtrace is shown below:
>
> WARNING: CPU: 1 PID: 3144 at lib/usercopy.c:11 _copy_from_user+0x85/0x90
> ...
> Call Trace:
>  <IRQ>
>  ipv6_renew_option+0xb2/0xf0
>  ipv6_renew_options+0x26a/0x340
>  ipv6_renew_options_kern+0x2c/0x40
>  calipso_req_setattr+0x72/0xe0
>  netlbl_req_setattr+0x126/0x1b0
>  selinux_netlbl_inet_conn_request+0x80/0x100
>  selinux_inet_conn_request+0x6d/0xb0
>  security_inet_conn_request+0x32/0x50
>  tcp_conn_request+0x35f/0xe00
>  ? __lock_acquire+0x250/0x16c0
>  ? selinux_socket_sock_rcv_skb+0x1ae/0x210
>  ? tcp_rcv_state_process+0x289/0x106b
>  tcp_rcv_state_process+0x289/0x106b
>  ? tcp_v6_do_rcv+0x1a7/0x3c0
>  tcp_v6_do_rcv+0x1a7/0x3c0
>  tcp_v6_rcv+0xc82/0xcf0
>  ip6_input_finish+0x10d/0x690
>  ip6_input+0x45/0x1e0
>  ? ip6_rcv_finish+0x1d0/0x1d0
>  ipv6_rcv+0x32b/0x880
>  ? ip6_make_skb+0x1e0/0x1e0
>  __netif_receive_skb_core+0x6f2/0xdf0
>  ? process_backlog+0x85/0x250
>  ? process_backlog+0x85/0x250
>  ? process_backlog+0xec/0x250
>  process_backlog+0xec/0x250
>  net_rx_action+0x153/0x480
>  __do_softirq+0xd9/0x4f7
>  do_softirq_own_stack+0x2a/0x40
>  </IRQ>
>  ...
>
> While not present in the backtrace, ipv6_renew_option() ends up calling
> access_ok() via the following chain:
>
>  access_ok()
>  _copy_from_user()
>  copy_from_user()
>  ipv6_renew_option()
>
> The fix presented in this patch is to perform the userspace copy
> earlier in the call chain such that it is only called when the option
> data is actually coming from userspace; that place is
> do_ipv6_setsockopt().  Not only does this solve the problem seen in
> the backtrace above, it also allows us to simplify the code quite a
> bit by removing ipv6_renew_options_kern() completely.  We also take
> this opportunity to cleanup ipv6_renew_options()/ipv6_renew_option()
> a small amount as well.
>
> This patch is heavily based on a rough patch by Al Viro.  I've taken
> his original patch, converted a kmemdup() call in do_ipv6_setsockopt()
> to a memdup_user() call, made better use of the e_inval jump target in
> the same function, and cleaned up the use ipv6_renew_option() by
> ipv6_renew_options().
>
> CC: Al Viro <viro@zeniv.linux.org.uk>
> Signed-off-by: Paul Moore <paul@paul-moore.com>
> ---
> include/net/ipv6.h       |    9 ----
> net/ipv6/calipso.c       |    9 +---
> net/ipv6/exthdrs.c       |  108 ++++++++++++----------------------------------
> net/ipv6/ipv6_sockglue.c |   27 ++++++++----
> 4 files changed, 50 insertions(+), 103 deletions(-)


Hold off on this patch, while it worked for me, I just received a bug report from Intel's 0day robot that I want to chase down.

> diff --git a/include/net/ipv6.h b/include/net/ipv6.h
> index 16475c269749..d02881e4ad1f 100644
> --- a/include/net/ipv6.h
> +++ b/include/net/ipv6.h
> @@ -355,14 +355,7 @@ struct ipv6_txoptions *ipv6_dup_options(struct sock *sk,
> struct ipv6_txoptions *ipv6_renew_options(struct sock *sk,
> 	 struct ipv6_txoptions *opt,
> 	 int newtype,
> -	 struct ipv6_opt_hdr __user *newopt,
> -	 int newoptlen);
> -struct ipv6_txoptions *
> -ipv6_renew_options_kern(struct sock *sk,
> -	struct ipv6_txoptions *opt,
> -	int newtype,
> -	struct ipv6_opt_hdr *newopt,
> -	int newoptlen);
> +	 struct ipv6_opt_hdr *newopt);
> struct ipv6_txoptions *ipv6_fixup_options(struct ipv6_txoptions *opt_space,
> 	 struct ipv6_txoptions *opt);
>
> diff --git a/net/ipv6/calipso.c b/net/ipv6/calipso.c
> index 1323b9679cf7..1c0bb9fb76e6 100644
> --- a/net/ipv6/calipso.c
> +++ b/net/ipv6/calipso.c
> @@ -799,8 +799,7 @@ static int calipso_opt_update(struct sock *sk, struct ipv6_opt_hdr *hop)
> {
> 	struct ipv6_txoptions *old = txopt_get(inet6_sk(sk)), *txopts;
>
> -	txopts = ipv6_renew_options_kern(sk, old, IPV6_HOPOPTS,
> -	hop, hop ? ipv6_optlen(hop) : 0);
> +	txopts = ipv6_renew_options(sk, old, IPV6_HOPOPTS, hop);
> 	txopt_put(old);
> 	if (IS_ERR(txopts))
> 	return PTR_ERR(txopts);
> @@ -1222,8 +1221,7 @@ static int calipso_req_setattr(struct request_sock *req,
> 	if (IS_ERR(new))
> 	return PTR_ERR(new);
>
> -	txopts = ipv6_renew_options_kern(sk, req_inet->ipv6_opt, IPV6_HOPOPTS,
> -	new, new ? ipv6_optlen(new) : 0);
> +	txopts = ipv6_renew_options(sk, req_inet->ipv6_opt, IPV6_HOPOPTS, new);
>
> 	kfree(new);
>
> @@ -1260,8 +1258,7 @@ static void calipso_req_delattr(struct request_sock *req)
> 	if (calipso_opt_del(req_inet->ipv6_opt->hopopt, &new))
> 	return; /* Nothing to do */
>
> -	txopts = ipv6_renew_options_kern(sk, req_inet->ipv6_opt, IPV6_HOPOPTS,
> -	new, new ? ipv6_optlen(new) : 0);
> +	txopts = ipv6_renew_options(sk, req_inet->ipv6_opt, IPV6_HOPOPTS, new);
>
> 	if (!IS_ERR(txopts)) {
> 	txopts = xchg(&req_inet->ipv6_opt, txopts);
> diff --git a/net/ipv6/exthdrs.c b/net/ipv6/exthdrs.c
> index 5bc2bf3733ab..1e1d9bc2fd3d 100644
> --- a/net/ipv6/exthdrs.c
> +++ b/net/ipv6/exthdrs.c
> @@ -1015,29 +1015,21 @@ ipv6_dup_options(struct sock *sk, struct ipv6_txoptions *opt)
> }
> EXPORT_SYMBOL_GPL(ipv6_dup_options);
>
> -static int ipv6_renew_option(void *ohdr,
> -	    struct ipv6_opt_hdr __user *newopt, int newoptlen,
> -	    int inherit,
> -	    struct ipv6_opt_hdr **hdr,
> -	    char **p)
> +static void ipv6_renew_option(int renewtype,
> +	     struct ipv6_opt_hdr **dest,
> +	     struct ipv6_opt_hdr *old,
> +	     struct ipv6_opt_hdr *new,
> +	     int newtype, char **p)
> {
> -	if (inherit) {
> -	if (ohdr) {
> -	memcpy(*p, ohdr, ipv6_optlen((struct ipv6_opt_hdr *)ohdr));
> -	*hdr = (struct ipv6_opt_hdr *)*p;
> -	*p += CMSG_ALIGN(ipv6_optlen(*hdr));
> -	}
> -	} else {
> -	if (newopt) {
> -	if (copy_from_user(*p, newopt, newoptlen))
> -	return -EFAULT;
> -	*hdr = (struct ipv6_opt_hdr *)*p;
> -	if (ipv6_optlen(*hdr) > newoptlen)
> -	return -EINVAL;
> -	*p += CMSG_ALIGN(newoptlen);
> -	}
> -	}
> -	return 0;
> +	struct ipv6_opt_hdr *src;
> +
> +	src = (renewtype == newtype ? new : old);
> +	if (!src)
> +	return;
> +
> +	memcpy(*p, src, ipv6_optlen(src));
> +	*dest = (struct ipv6_opt_hdr *)*p;
> +	p += CMSG_ALIGN(ipv6_optlen(*dest));
> }
>
> /**
> @@ -1063,13 +1055,11 @@ static int ipv6_renew_option(void *ohdr,
>  */
> struct ipv6_txoptions *
> ipv6_renew_options(struct sock *sk, struct ipv6_txoptions *opt,
> -	  int newtype,
> -	  struct ipv6_opt_hdr __user *newopt, int newoptlen)
> +	  int newtype, struct ipv6_opt_hdr *newopt)
> {
> 	int tot_len = 0;
> 	char *p;
> 	struct ipv6_txoptions *opt2;
> -	int err;
>
> 	if (opt) {
> 	if (newtype != IPV6_HOPOPTS && opt->hopopt)
> @@ -1082,8 +1072,8 @@ ipv6_renew_options(struct sock *sk, struct ipv6_txoptions *opt,
> 	tot_len += CMSG_ALIGN(ipv6_optlen(opt->dst1opt));
> 	}
>
> -	if (newopt && newoptlen)
> -	tot_len += CMSG_ALIGN(newoptlen);
> +	if (newopt)
> +	tot_len += CMSG_ALIGN(ipv6_optlen(newopt));
>
> 	if (!tot_len)
> 	return NULL;
> @@ -1098,29 +1088,16 @@ ipv6_renew_options(struct sock *sk, struct ipv6_txoptions *opt,
> 	opt2->tot_len = tot_len;
> 	p = (char *)(opt2 + 1);
>
> -	err = ipv6_renew_option(opt ? opt->hopopt : NULL, newopt, newoptlen,
> -	newtype != IPV6_HOPOPTS,
> -	&opt2->hopopt, &p);
> -	if (err)
> -	goto out;
> -
> -	err = ipv6_renew_option(opt ? opt->dst0opt : NULL, newopt, newoptlen,
> -	newtype != IPV6_RTHDRDSTOPTS,
> -	&opt2->dst0opt, &p);
> -	if (err)
> -	goto out;
> -
> -	err = ipv6_renew_option(opt ? opt->srcrt : NULL, newopt, newoptlen,
> -	newtype != IPV6_RTHDR,
> -	(struct ipv6_opt_hdr **)&opt2->srcrt, &p);
> -	if (err)
> -	goto out;
> -
> -	err = ipv6_renew_option(opt ? opt->dst1opt : NULL, newopt, newoptlen,
> -	newtype != IPV6_DSTOPTS,
> -	&opt2->dst1opt, &p);
> -	if (err)
> -	goto out;
> +	ipv6_renew_option(IPV6_HOPOPTS, &opt2->hopopt, opt->hopopt,
> +	 newopt, newtype, &p);
> +	ipv6_renew_option(IPV6_RTHDRDSTOPTS, &opt2->dst0opt, opt->dst0opt,
> +	 newopt, newtype, &p);
> +	ipv6_renew_option(IPV6_RTHDR,
> +	 (struct ipv6_opt_hdr **)&opt2->srcrt,
> +	 (struct ipv6_opt_hdr *)opt->srcrt,
> +	 newopt, newtype, &p);
> +	ipv6_renew_option(IPV6_DSTOPTS, &opt2->dst1opt, opt->dst1opt,
> +	 newopt, newtype, &p);
>
> 	opt2->opt_nflen = (opt2->hopopt ? ipv6_optlen(opt2->hopopt) : 0) +
> 	 (opt2->dst0opt ? ipv6_optlen(opt2->dst0opt) : 0) +
> @@ -1128,37 +1105,6 @@ ipv6_renew_options(struct sock *sk, struct ipv6_txoptions *opt,
> 	opt2->opt_flen = (opt2->dst1opt ? ipv6_optlen(opt2->dst1opt) : 0);
>
> 	return opt2;
> -out:
> -	sock_kfree_s(sk, opt2, opt2->tot_len);
> -	return ERR_PTR(err);
> -}
> -
> -/**
> - * ipv6_renew_options_kern - replace a specific ext hdr with a new one.
> - *
> - * @sk: sock from which to allocate memory
> - * @opt: original options
> - * @newtype: option type to replace in @opt
> - * @newopt: new option of type @newtype to replace (kernel-mem)
> - * @newoptlen: length of @newopt
> - *
> - * See ipv6_renew_options().  The difference is that @newopt is
> - * kernel memory, rather than user memory.
> - */
> -struct ipv6_txoptions *
> -ipv6_renew_options_kern(struct sock *sk, struct ipv6_txoptions *opt,
> -	int newtype, struct ipv6_opt_hdr *newopt,
> -	int newoptlen)
> -{
> -	struct ipv6_txoptions *ret_val;
> -	const mm_segment_t old_fs = get_fs();
> -
> -	set_fs(KERNEL_DS);
> -	ret_val = ipv6_renew_options(sk, opt, newtype,
> -	    (struct ipv6_opt_hdr __user *)newopt,
> -	    newoptlen);
> -	set_fs(old_fs);
> -	return ret_val;
> }
>
> struct ipv6_txoptions *ipv6_fixup_options(struct ipv6_txoptions *opt_space,
> diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
> index 4d780c7f0130..c95c3486d904 100644
> --- a/net/ipv6/ipv6_sockglue.c
> +++ b/net/ipv6/ipv6_sockglue.c
> @@ -398,6 +398,12 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname,
> 	case IPV6_DSTOPTS:
> 	{
> 	struct ipv6_txoptions *opt;
> +	struct ipv6_opt_hdr *new = NULL;
> +
> +	/* hop-by-hop / destination options are privileged option */
> +	retv = -EPERM;
> +	if (optname != IPV6_RTHDR && !ns_capable(net->user_ns, CAP_NET_RAW))
> +	break;
>
> 	/* remove any sticky options header with a zero option
> 	* length, per RFC3542.
> @@ -409,17 +415,22 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname,
> 	else if (optlen < sizeof(struct ipv6_opt_hdr) ||
> 	optlen & 0x7 || optlen > 8 * 255)
> 	goto e_inval;
> -
> -	/* hop-by-hop / destination options are privileged option */
> -	retv = -EPERM;
> -	if (optname != IPV6_RTHDR && !ns_capable(net->user_ns, CAP_NET_RAW))
> -	break;
> +	else {
> +	new = memdup_user(optval, optlen);
> +	if (IS_ERR(new)) {
> +	retv = PTR_ERR(new);
> +	break;
> +	}
> +	if (unlikely(ipv6_optlen(new) > optlen)) {
> +	kfree(new);
> +	goto e_inval;
> +	}
> +	}
>
> 	opt = rcu_dereference_protected(np->opt,
> 	lockdep_sock_is_held(sk));
> -	opt = ipv6_renew_options(sk, opt, optname,
> -	(struct ipv6_opt_hdr __user *)optval,
> -	optlen);
> +	opt = ipv6_renew_options(sk, opt, optname, new);
> +	kfree(new);
> 	if (IS_ERR(opt)) {
> 	retv = PTR_ERR(opt);
> 	break;

^ permalink raw reply

* Re: [PATCH v3 1/4] Simplify usbnet_cdc_update_filter
From: Miguel Rodríguez Pérez @ 2018-07-02 11:19 UTC (permalink / raw)
  To: Oliver Neukum, gregkh, linux-usb, netdev
In-Reply-To: <1530519944.18402.10.camel@suse.com>

I get a panic if I remove this patch, because intf comes NULL for
cdc_ncm devices. I'll send an updated patch that solves this issue while
still using usb_control_msg.

On 02/07/18 10:25, Oliver Neukum wrote:
> On So, 2018-07-01 at 11:05 +0200, Miguel Rodríguez Pérez         wrote:
>> Remove some unneded varibles to make the code easier to read
>> and, replace the generic usb_control_msg function for the
>> more specific usbnet_write_cmd.
>>
>> Signed-off-by: Miguel Rodríguez Pérez <miguel@det.uvigo.gal>
> 
> No,
> 
> sorry, but this is not good. The reason is a bit subtle.
> Drivers need to reset the filters when handling post_reset()
> [ and reset_resume() ] usbnet_write_cmd() falls back to
> kmemdup() with GFP_KERNEL. Usbnet is a framework with class
> drivers and some of the devices we drive have a storage
> interface. Thence we are on the block error handling path here.
> 
> The simplest solution is to leave out this patch in the sequence.
> 
> 	Regards
> 		Oliver
> 
> 
> NACKED-BY: Oliver Neukum <oneukum@suse.com>
> 
> 
>> ---
>>  drivers/net/usb/cdc_ether.c | 15 +++++----------
>>  1 file changed, 5 insertions(+), 10 deletions(-)
>>
>> diff --git a/drivers/net/usb/cdc_ether.c b/drivers/net/usb/cdc_ether.c
>> index 178b956501a7..815ed0dc18fe 100644
>> --- a/drivers/net/usb/cdc_ether.c
>> +++ b/drivers/net/usb/cdc_ether.c
>> @@ -77,9 +77,7 @@ static const u8 mbm_guid[16] = {
>>  
>>  static void usbnet_cdc_update_filter(struct usbnet *dev)
>>  {
>> -	struct cdc_state	*info = (void *) &dev->data;
>> -	struct usb_interface	*intf = info->control;
>> -	struct net_device	*net = dev->net;
>> +	struct net_device *net = dev->net;
>>  
>>  	u16 cdc_filter = USB_CDC_PACKET_TYPE_DIRECTED
>>  			| USB_CDC_PACKET_TYPE_BROADCAST;
>> @@ -93,16 +91,13 @@ static void usbnet_cdc_update_filter(struct usbnet *dev)
>>  	if (!netdev_mc_empty(net) || (net->flags & IFF_ALLMULTI))
>>  		cdc_filter |= USB_CDC_PACKET_TYPE_ALL_MULTICAST;
>>  
>> -	usb_control_msg(dev->udev,
>> -			usb_sndctrlpipe(dev->udev, 0),
>> +	usbnet_write_cmd(dev,
>>  			USB_CDC_SET_ETHERNET_PACKET_FILTER,
>> -			USB_TYPE_CLASS | USB_RECIP_INTERFACE,
>> +			USB_TYPE_CLASS | USB_DIR_OUT | USB_RECIP_INTERFACE,
>>  			cdc_filter,
>> -			intf->cur_altsetting->desc.bInterfaceNumber,
>> +			dev->intf->cur_altsetting->desc.bInterfaceNumber,
>>  			NULL,
>> -			0,
>> -			USB_CTRL_SET_TIMEOUT
>> -		);
>> +			0);
>>  }
>>  
>>  /* probes control interface, claims data interface, collects the bulk
> 

-- 
Miguel Rodríguez Pérez
Laboratorio de Redes
EE Telecomunicación – Universidade de Vigo

^ permalink raw reply

* [PATCH v4 1/4] Use dev->intf to get interface information
From: Miguel Rodríguez Pérez @ 2018-07-02 11:28 UTC (permalink / raw)
  To: oliver, linux-usb, netdev, gregkh; +Cc: Miguel Rodríguez Pérez
In-Reply-To: <e3e25aa6-9f9a-0643-a644-e8efdf12a562@det.uvigo.gal>

usbnet_cdc_update_filter was getting the interface number from the
usb_interface struct in cdc_state->control. However, cdc_ncm does
not initialize that structure in its bind function, but uses
cdc_ncm_cts instead. Getting intf directly from struct usbnet solves
the problem.

Signed-off-by: Miguel Rodríguez Pérez <miguel@det.uvigo.gal>
---
 drivers/net/usb/cdc_ether.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/net/usb/cdc_ether.c b/drivers/net/usb/cdc_ether.c
index 178b956501a7..beac02cbde51 100644
--- a/drivers/net/usb/cdc_ether.c
+++ b/drivers/net/usb/cdc_ether.c
@@ -77,8 +77,6 @@ static const u8 mbm_guid[16] = {
 
 static void usbnet_cdc_update_filter(struct usbnet *dev)
 {
-	struct cdc_state	*info = (void *) &dev->data;
-	struct usb_interface	*intf = info->control;
 	struct net_device	*net = dev->net;
 
 	u16 cdc_filter = USB_CDC_PACKET_TYPE_DIRECTED
@@ -98,7 +96,7 @@ static void usbnet_cdc_update_filter(struct usbnet *dev)
 			USB_CDC_SET_ETHERNET_PACKET_FILTER,
 			USB_TYPE_CLASS | USB_RECIP_INTERFACE,
 			cdc_filter,
-			intf->cur_altsetting->desc.bInterfaceNumber,
+			dev->intf->cur_altsetting->desc.bInterfaceNumber,
 			NULL,
 			0,
 			USB_CTRL_SET_TIMEOUT
-- 
2.17.1

^ permalink raw reply related

* Re: [PATCH] wlcore: Fix memory leak in wlcore_cmd_wait_for_event_or_timeout
From: Tony Lindgren @ 2018-07-02 11:30 UTC (permalink / raw)
  To: Gustavo A. R. Silva
  Cc: Kalle Valo, David S. Miller, linux-wireless, netdev, linux-kernel
In-Reply-To: <20180628130809.GA8147@embeddedor.com>

* Gustavo A. R. Silva <gustavo@embeddedor.com> [180628 13:11]:
> In case memory resources for *events_vector* were allocated, release
> them before return.
> 
> Addresses-Coverity-ID: 1470194 ("Resource leak")
> Fixes: 4ec7cece87b3 ("wlcore: Add missing PM call for wlcore_cmd_wait_for_event_or_timeout()")
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>

Thanks for catching this one:

Acked-by: Tony Lindgren <tony@atomide.com>

> ---
>  drivers/net/wireless/ti/wlcore/cmd.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/wireless/ti/wlcore/cmd.c b/drivers/net/wireless/ti/wlcore/cmd.c
> index 836c616..9039687 100644
> --- a/drivers/net/wireless/ti/wlcore/cmd.c
> +++ b/drivers/net/wireless/ti/wlcore/cmd.c
> @@ -195,8 +195,7 @@ int wlcore_cmd_wait_for_event_or_timeout(struct wl1271 *wl,
>  	ret = pm_runtime_get_sync(wl->dev);
>  	if (ret < 0) {
>  		pm_runtime_put_noidle(wl->dev);
> -
> -		return ret;
> +		goto free_vector;
>  	}
>  
>  	do {
> @@ -232,6 +231,7 @@ int wlcore_cmd_wait_for_event_or_timeout(struct wl1271 *wl,
>  out:
>  	pm_runtime_mark_last_busy(wl->dev);
>  	pm_runtime_put_autosuspend(wl->dev);
> +free_vector:
>  	kfree(events_vector);
>  	return ret;
>  }
> -- 
> 2.7.4
> 

^ permalink raw reply

* Re: [PATCH net] net: fix use-after-free in GRO with ESP
From: David Miller @ 2018-07-02 11:34 UTC (permalink / raw)
  To: sd; +Cc: netdev, sbrivio, steffen.klassert
In-Reply-To: <62edcac57b52aa0546936700f7a0b50a2327806a.1530368567.git.sd@queasysnail.net>

From: Sabrina Dubroca <sd@queasysnail.net>
Date: Sat, 30 Jun 2018 17:38:55 +0200

> Since the addition of GRO for ESP, gro_receive can consume the skb and
> return -EINPROGRESS. In that case, the lower layer GRO handler cannot
> touch the skb anymore.
> 
> Commit 5f114163f2f5 ("net: Add a skb_gro_flush_final helper.") converted
> some of the gro_receive handlers that can lead to ESP's gro_receive so
> that they wouldn't access the skb when -EINPROGRESS is returned, but
> missed other spots, mainly in tunneling protocols.
> 
> This patch finishes the conversion to using skb_gro_flush_final(), and
> adds a new helper, skb_gro_flush_final_remcsum(), used in VXLAN and
> GUE.
> 
> Fixes: 5f114163f2f5 ("net: Add a skb_gro_flush_final helper.")
> Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
> Reviewed-by: Stefano Brivio <sbrivio@redhat.com>

Applied and queued up for -stable, thank you.

^ permalink raw reply

* Re: [PATCH][next] netdevsim: fix sa_idx out of bounds check
From: David Miller @ 2018-07-02 11:36 UTC (permalink / raw)
  To: colin.king; +Cc: jakub.kicinski, netdev, kernel-janitors, linux-kernel
In-Reply-To: <20180630203924.5121-1-colin.king@canonical.com>

From: Colin King <colin.king@canonical.com>
Date: Sat, 30 Jun 2018 21:39:24 +0100

> From: Colin Ian King <colin.king@canonical.com>
> 
> Currently if sa_idx is equal to NSIM_IPSEC_MAX_SA_COUNT then
> an out-of-bounds read on ipsec->sa will occur. Fix the
> incorrect bounds check by using >= rather than >.
> 
> Detected by CoverityScan, CID#1470226 ("Out-of-bounds-read")
> 
> Fixes: 7699353da875 ("netdevsim: add ipsec offload testing")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>

Applied, thank you.

^ permalink raw reply

* Re: [PATCH net] ipv6: sr: fix passing wrong flags to crypto_alloc_shash()
From: David Miller @ 2018-07-02 11:37 UTC (permalink / raw)
  To: ebiggers3; +Cc: netdev, david.lebrun, linux-crypto, ebiggers
In-Reply-To: <20180630222656.333-1-ebiggers3@gmail.com>

From: Eric Biggers <ebiggers3@gmail.com>
Date: Sat, 30 Jun 2018 15:26:56 -0700

> From: Eric Biggers <ebiggers@google.com>
> 
> The 'mask' argument to crypto_alloc_shash() uses the CRYPTO_ALG_* flags,
> not 'gfp_t'.  So don't pass GFP_KERNEL to it.
> 
> Fixes: bf355b8d2c30 ("ipv6: sr: add core files for SR HMAC support")
> Signed-off-by: Eric Biggers <ebiggers@google.com>

Oops, applied and queued up for -stable, thanks!

^ permalink raw reply

* Re: [PATCHv2 net] ipvlan: call dev_change_flags when ipvlan mode is reset
From: David Miller @ 2018-07-02 11:38 UTC (permalink / raw)
  To: liuhangbin; +Cc: netdev, sbrivio, pabeni, maheshb, xiyou.wangcong, sd
In-Reply-To: <1530433281-22743-1-git-send-email-liuhangbin@gmail.com>

From: Hangbin Liu <liuhangbin@gmail.com>
Date: Sun,  1 Jul 2018 16:21:21 +0800

> After we change the ipvlan mode from l3 to l2, or vice versa, we only
> reset IFF_NOARP flag, but don't flush the ARP table cache, which will
> cause eth->h_dest to be equal to eth->h_source in ipvlan_xmit_mode_l2().
> Then the message will not come out of host.
> 
> Here is the reproducer on local host:
> 
> ip link set eth1 up
> ip addr add 192.168.1.1/24 dev eth1
> ip link add link eth1 ipvlan1 type ipvlan mode l3
> 
> ip netns add net1
> ip link set ipvlan1 netns net1
> ip netns exec net1 ip link set ipvlan1 up
> ip netns exec net1 ip addr add 192.168.2.1/24 dev ipvlan1
> 
> ip route add 192.168.2.0/24 via 192.168.1.2
> ping 192.168.2.2 -c 2
> 
> ip netns exec net1 ip link set ipvlan1 type ipvlan mode l2
> ping 192.168.2.2 -c 2
> 
> Add the same configuration on remote host. After we set the mode to l2,
> we could find that the src/dst MAC addresses are the same on eth1:
> 
> 21:26:06.648565 00:b7:13:ad:d3:05 > 00:b7:13:ad:d3:05, ethertype IPv4 (0x0800), length 98: (tos 0x0, ttl 64, id 58356, offset 0, flags [DF], proto ICMP (1), length 84)
>     192.168.2.1 > 192.168.2.2: ICMP echo request, id 22686, seq 1, length 64
> 
> Fix this by calling dev_change_flags(), which will call netdevice notifier
> with flag change info.
> 
> v2:
> a) As pointed out by Wang Cong, check return value for dev_change_flags() when
> change dev flags.
> b) As suggested by Stefano and Sabrina, move flags setting before l3mdev_ops.
> So we don't need to redo ipvlan_{, un}register_nf_hook() again in err path.
> 
> Reported-by: Jianlin Shi <jishi@redhat.com>
> Reviewed-by: Stefano Brivio <sbrivio@redhat.com>
> Reviewed-by: Sabrina Dubroca <sd@queasysnail.net>
> Fixes: 2ad7bf3638411 ("ipvlan: Initial check-in of the IPVLAN driver.")
> Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>

Applied, thank you.

^ permalink raw reply

* [PATCH][net-next] net: increase MAX_GRO_SKBS to 64
From: Li RongQing @ 2018-07-02 11:41 UTC (permalink / raw)
  To: netdev

After 07d78363dcffd [net: Convert NAPI gro list into a small hash table]
there is 8 hash buckets, which allow more flows to be held for merging.

keep each as original list length, so increase MAX_GRO_SKBS to 64

Signed-off-by: Li RongQing <lirongqing@baidu.com>
---
 net/core/dev.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/net/core/dev.c b/net/core/dev.c
index 08d58e0debe5..ac315e41d5e7 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -149,8 +149,7 @@
 
 #include "net-sysfs.h"
 
-/* Instead of increasing this, you should create a hash table. */
-#define MAX_GRO_SKBS 8
+#define MAX_GRO_SKBS 64
 
 /* This should be increased if a protocol with a bigger head is added. */
 #define GRO_MAX_HEAD (MAX_HEADER + 128)
-- 
2.16.2

^ permalink raw reply related

* Re: [PATCH][net-next] net: increase MAX_GRO_SKBS to 64
From: David Miller @ 2018-07-02 11:44 UTC (permalink / raw)
  To: lirongqing; +Cc: netdev, eric.dumazet
In-Reply-To: <1530531703-11368-1-git-send-email-lirongqing@baidu.com>

From: Li RongQing <lirongqing@baidu.com>
Date: Mon,  2 Jul 2018 19:41:43 +0800

> After 07d78363dcffd [net: Convert NAPI gro list into a small hash table]
> there is 8 hash buckets, which allow more flows to be held for merging.
> 
> keep each as original list length, so increase MAX_GRO_SKBS to 64
> 
> Signed-off-by: Li RongQing <lirongqing@baidu.com>

I would like to hear some feedback from Eric, 64 might be too big.

^ permalink raw reply

* Re: [PATCH net] sctp: fix the issue that pathmtu may be set lower than MINSEGMENT
From: Neil Horman @ 2018-07-02 11:45 UTC (permalink / raw)
  To: Xin Long; +Cc: network dev, linux-sctp, davem, Marcelo Ricardo Leitner,
	syzkaller
In-Reply-To: <0928f7dda7db59c8aa01e97a87792d9e643e70ab.1530514276.git.lucien.xin@gmail.com>

On Mon, Jul 02, 2018 at 02:51:16PM +0800, Xin Long wrote:
> After commit b6c5734db070 ("sctp: fix the handling of ICMP Frag Needed
> for too small MTUs"), sctp_transport_update_pmtu would refetch pathmtu
> from the dst and set it to transport's pathmtu without any check.
> 
> The new pathmtu may be lower than MINSEGMENT if the dst is obsolete and
> updated by .get_dst() in sctp_transport_update_pmtu.
> 
> Syzbot reported a warning in sctp_mtu_payload caused by this.
> 
> This fix uses the refetched pathmtu only when it's greater than the
> frag_needed pmtu.
> 
> Fixes: b6c5734db070 ("sctp: fix the handling of ICMP Frag Needed for too small MTUs")
> Reported-by: syzbot+f0d9d7cba052f9344b03@syzkaller.appspotmail.com
> Signed-off-by: Xin Long <lucien.xin@gmail.com>
> ---
>  net/sctp/transport.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/net/sctp/transport.c b/net/sctp/transport.c
> index 445b7ef..ddfb687 100644
> --- a/net/sctp/transport.c
> +++ b/net/sctp/transport.c
> @@ -282,7 +282,10 @@ bool sctp_transport_update_pmtu(struct sctp_transport *t, u32 pmtu)
>  
>  	if (dst) {
>  		/* Re-fetch, as under layers may have a higher minimum size */
> -		pmtu = SCTP_TRUNC4(dst_mtu(dst));
> +		u32 mtu = SCTP_TRUNC4(dst_mtu(dst));
> +
> +		if (pmtu < mtu)
> +			pmtu = mtu;
nit, but why not u32 mtu = min(pmtu, SCTP_TRUNC4(dst_mtu(dst))) here ?

Neil

>  		change = t->pathmtu != pmtu;
>  	}
>  	t->pathmtu = pmtu;
> -- 
> 2.1.0
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-sctp" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

^ permalink raw reply

* RE: [RFC net-next 15/15] net: lora: Add Semtech SX1301
From: Ben Whitten @ 2018-07-02 11:51 UTC (permalink / raw)
  To: Andreas Färber, netdev@vger.kernel.org
  Cc: 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, Steve deRosier,
	Mark Brown, linux-spi@vger.kernel.org
In-Reply-To: <20180701110804.32415-16-afaerber@suse.de>

Hi Andreas,

Excellent work on doing this I have also been working on and off
this personally for some time.
Have a look at my repository [1] for sx1301 and sx1257 drivers,
I use regmaps capability of switching pages which should simplify
your driver considerably, I also have a full register map and bit field.

I have also been trying to use the clk framework to capture the various
routing that the cards have.

I will dig into this series this evening.

[1] https://github.com/BWhitten/linux-stable/tree/971aadc8fdfe842020d912449bdd71b33d576fe3/drivers/net/lora


> Subject: [RFC net-next 15/15] net: lora: Add Semtech SX1301
> 
> The Semtech SX1301 was the first multi-channel LoRa "concentrator".
> It uses a SPI interface to the host as well as a dual SPI interface to
> its radios. These two have been implemented as spi_controller, so that
> the Device Tree can specify whether the respective module uses two
> SX1257, two SX1255 or a combination of these or some unforeseen chipset.
> 
> This implementation is the most recent - initialization is not yet
> complete, it will need to load firmware into the two on-chip MCUs.
> 
> Unfortunately there is no full datasheet with register descriptions,
> only a BSD-licensed userspace HAL implementation using spidev devices.
> Therefore some register names are unknown.
> 
> Cc: Ben Whitten <ben.whitten@lairdtech.com>
> Cc: Steve deRosier <derosier@gmail.com>
> Cc: Mark Brown <broonie@kernel.org>
> Cc: Michael Röder <michael.roeder@avnet.eu>
> Cc: Ken Yu (禹凯) <ken.yu@rakwireless.com>
> Cc: linux-spi@vger.kernel.org
> Signed-off-by: Andreas Färber <afaerber@suse.de>
> ---
>  drivers/net/lora/Kconfig  |   7 +
>  drivers/net/lora/Makefile |   3 +
>  drivers/net/lora/sx1301.c | 446
> ++++++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 456 insertions(+)
>  create mode 100644 drivers/net/lora/sx1301.c
> 
> diff --git a/drivers/net/lora/Kconfig b/drivers/net/lora/Kconfig
> index 68c7480d7812..950450e353b4 100644
> --- a/drivers/net/lora/Kconfig
> +++ b/drivers/net/lora/Kconfig
> @@ -45,6 +45,13 @@ config LORA_SX1276
>  	help
>  	  Semtech SX1272/1276/1278
> 
> +config LORA_SX1301
> +	tristate "Semtech SX1301 SPI driver"
> +	default y
> +	depends on SPI
> +	help
> +	  Semtech SX1301
> +
>  config LORA_USI
>  	tristate "USI WM-SG-SM-42 driver"
>  	default y
> diff --git a/drivers/net/lora/Makefile b/drivers/net/lora/Makefile
> index 44c578bde7d5..1cc1e3aa189b 100644
> --- a/drivers/net/lora/Makefile
> +++ b/drivers/net/lora/Makefile
> @@ -22,6 +22,9 @@ lora-sx1257-y := sx1257.o
>  obj-$(CONFIG_LORA_SX1276) += lora-sx1276.o
>  lora-sx1276-y := sx1276.o
> 
> +obj-$(CONFIG_LORA_SX1301) += lora-sx1301.o
> +lora-sx1301-y := sx1301.o
> +
>  obj-$(CONFIG_LORA_USI) += lora-usi.o
>  lora-usi-y := usi.o
> 
> diff --git a/drivers/net/lora/sx1301.c b/drivers/net/lora/sx1301.c
> new file mode 100644
> index 000000000000..5c936c1116d1
> --- /dev/null
> +++ b/drivers/net/lora/sx1301.c
> @@ -0,0 +1,446 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +/*
> + * Semtech SX1301 LoRa concentrator
> + *
> + * Copyright (c) 2018 Andreas Färber
> + *
> + * Based on SX1301 HAL code:
> + * Copyright (c) 2013 Semtech-Cycleo
> + */
> +
> +#include <linux/bitops.h>
> +#include <linux/delay.h>
> +#include <linux/lora.h>
> +#include <linux/module.h>
> +#include <linux/netdevice.h>
> +#include <linux/of.h>
> +#include <linux/of_device.h>
> +#include <linux/of_gpio.h>
> +#include <linux/lora/dev.h>
> +#include <linux/spi/spi.h>
> +
> +#define REG_PAGE_RESET			0
> +#define REG_VERSION			1
> +#define REG_2_SPI_RADIO_A_DATA		33
> +#define REG_2_SPI_RADIO_A_DATA_READBACK	34
> +#define REG_2_SPI_RADIO_A_ADDR		35
> +#define REG_2_SPI_RADIO_A_CS		37
> +#define REG_2_SPI_RADIO_B_DATA		38
> +#define REG_2_SPI_RADIO_B_DATA_READBACK	39
> +#define REG_2_SPI_RADIO_B_ADDR		40
> +#define REG_2_SPI_RADIO_B_CS		42
> +
> +#define REG_PAGE_RESET_SOFT_RESET	BIT(7)
> +
> +#define REG_16_GLOBAL_EN		BIT(3)
> +
> +#define REG_17_CLK32M_EN		BIT(0)
> +
> +#define REG_2_43_RADIO_A_EN		BIT(0)
> +#define REG_2_43_RADIO_B_EN		BIT(1)
> +#define REG_2_43_RADIO_RST		BIT(2)
> +
> +struct spi_sx1301 {
> +	struct spi_device *parent;
> +	u8 page;
> +	u8 regs;
> +};
> +
> +struct sx1301_priv {
> +	struct lora_priv lora;
> +	struct gpio_desc *rst_gpio;
> +	u8 cur_page;
> +	struct spi_controller *radio_a_ctrl, *radio_b_ctrl;
> +};
> +
> +static int sx1301_read(struct spi_device *spi, u8 reg, u8 *val)
> +{
> +	u8 addr = reg & 0x7f;
> +	return spi_write_then_read(spi, &addr, 1, val, 1);
> +}
> +
> +static int sx1301_write(struct spi_device *spi, u8 reg, u8 val)
> +{
> +	u8 buf[2];
> +
> +	buf[0] = reg | BIT(7);
> +	buf[1] = val;
> +	return spi_write(spi, buf, 2);
> +}
> +
> +static int sx1301_page_switch(struct spi_device *spi, u8 page)
> +{
> +	struct sx1301_priv *priv = spi_get_drvdata(spi);
> +	int ret;
> +
> +	if (priv->cur_page == page)
> +		return 0;
> +
> +	dev_dbg(&spi->dev, "switching to page %u\n", (unsigned)page);
> +	ret = sx1301_write(spi, REG_PAGE_RESET, page & 0x3);
> +	if (ret) {
> +		dev_err(&spi->dev, "switching to page %u failed\n",
> (unsigned)page);
> +		return ret;
> +	}
> +
> +	priv->cur_page = page;
> +
> +	return 0;
> +}
> +
> +static int sx1301_soft_reset(struct spi_device *spi)
> +{
> +	return sx1301_write(spi, REG_PAGE_RESET,
> REG_PAGE_RESET_SOFT_RESET);
> +}
> +
> +#define REG_RADIO_X_DATA		0
> +#define REG_RADIO_X_DATA_READBACK	1
> +#define REG_RADIO_X_ADDR		2
> +#define REG_RADIO_X_CS			4
> +
> +static int sx1301_radio_set_cs(struct spi_controller *ctrl, bool enable)
> +{
> +	struct spi_sx1301 *ssx = spi_controller_get_devdata(ctrl);
> +	u8 cs;
> +	int ret;
> +
> +	dev_dbg(&ctrl->dev, "setting CS to %s\n", enable ? "1" : "0");
> +
> +	ret = sx1301_page_switch(ssx->parent, ssx->page);
> +	if (ret) {
> +		dev_warn(&ctrl->dev, "failed to switch page for CS (%d)\n",
> ret);
> +		return ret;
> +	}
> +
> +	ret = sx1301_read(ssx->parent, ssx->regs + REG_RADIO_X_CS, &cs);
> +	if (ret) {
> +		dev_warn(&ctrl->dev, "failed to read CS (%d)\n", ret);
> +		cs = 0;
> +	}
> +
> +	if (enable)
> +		cs |= BIT(0);
> +	else
> +		cs &= ~BIT(0);
> +
> +	ret = sx1301_write(ssx->parent, ssx->regs + REG_RADIO_X_CS, cs);
> +	if (ret)
> +		dev_warn(&ctrl->dev, "failed to write CS (%d)\n", ret);
> +
> +	return 0;
> +}
> +
> +static void sx1301_radio_spi_set_cs(struct spi_device *spi, bool enable)
> +{
> +	int ret;
> +
> +	dev_dbg(&spi->dev, "setting SPI CS to %s\n", enable ? "1" : "0");
> +
> +	if (enable)
> +		return;
> +
> +	ret = sx1301_radio_set_cs(spi->controller, enable);
> +	if (ret)
> +		dev_warn(&spi->dev, "failed to write CS (%d)\n", ret);
> +}
> +
> +static int sx1301_radio_spi_transfer_one(struct spi_controller *ctrl,
> +	struct spi_device *spi, struct spi_transfer *xfr)
> +{
> +	struct spi_sx1301 *ssx = spi_controller_get_devdata(ctrl);
> +	const u8 *tx_buf = xfr->tx_buf;
> +	u8 *rx_buf = xfr->rx_buf;
> +	int ret;
> +
> +	if (xfr->len == 0 || xfr->len > 3)
> +		return -EINVAL;
> +
> +	dev_dbg(&spi->dev, "transferring one (%u)\n", xfr->len);
> +
> +	ret = sx1301_page_switch(ssx->parent, ssx->page);
> +	if (ret) {
> +		dev_err(&spi->dev, "failed to switch page for transfer
> (%d)\n", ret);
> +		return ret;
> +	}
> +
> +	if (tx_buf) {
> +		ret = sx1301_write(ssx->parent, ssx->regs +
> REG_RADIO_X_ADDR, tx_buf ? tx_buf[0] : 0);
> +		if (ret) {
> +			dev_err(&spi->dev, "SPI radio address write
> failed\n");
> +			return ret;
> +		}
> +
> +		ret = sx1301_write(ssx->parent, ssx->regs +
> REG_RADIO_X_DATA, (tx_buf && xfr->len >= 2) ? tx_buf[1] : 0);
> +		if (ret) {
> +			dev_err(&spi->dev, "SPI radio data write failed\n");
> +			return ret;
> +		}
> +
> +		ret = sx1301_radio_set_cs(ctrl, true);
> +		if (ret) {
> +			dev_err(&spi->dev, "SPI radio CS set failed\n");
> +			return ret;
> +		}
> +
> +		ret = sx1301_radio_set_cs(ctrl, false);
> +		if (ret) {
> +			dev_err(&spi->dev, "SPI radio CS unset failed\n");
> +			return ret;
> +		}
> +	}
> +
> +	if (rx_buf) {
> +		ret = sx1301_read(ssx->parent, ssx->regs +
> REG_RADIO_X_DATA_READBACK, &rx_buf[xfr->len - 1]);
> +		if (ret) {
> +			dev_err(&spi->dev, "SPI radio data read failed\n");
> +			return ret;
> +		}
> +	}
> +
> +	return 0;
> +}
> +
> +static void sx1301_radio_setup(struct spi_controller *ctrl)
> +{
> +	ctrl->mode_bits = SPI_CS_HIGH | SPI_NO_CS;
> +	ctrl->bits_per_word_mask = SPI_BPW_MASK(8);
> +	ctrl->num_chipselect = 1;
> +	ctrl->set_cs = sx1301_radio_spi_set_cs;
> +	ctrl->transfer_one = sx1301_radio_spi_transfer_one;
> +}
> +
> +static int sx1301_probe(struct spi_device *spi)
> +{
> +	struct net_device *netdev;
> +	struct sx1301_priv *priv;
> +	struct spi_sx1301 *radio;
> +	struct gpio_desc *rst;
> +	int ret;
> +	u8 val;
> +
> +	rst = devm_gpiod_get_optional(&spi->dev, "reset",
> GPIOD_OUT_LOW);
> +	if (IS_ERR(rst))
> +		return PTR_ERR(rst);
> +
> +	gpiod_set_value_cansleep(rst, 1);
> +	msleep(100);
> +	gpiod_set_value_cansleep(rst, 0);
> +	msleep(100);
> +
> +	spi->bits_per_word = 8;
> +	spi_setup(spi);
> +
> +	ret = sx1301_read(spi, REG_VERSION, &val);
> +	if (ret) {
> +		dev_err(&spi->dev, "version read failed\n");
> +		goto err_version;
> +	}
> +
> +	if (val != 103) {
> +		dev_err(&spi->dev, "unexpected version: %u\n", val);
> +		ret = -ENXIO;
> +		goto err_version;
> +	}
> +
> +	netdev = alloc_loradev(sizeof(*priv));
> +	if (!netdev) {
> +		ret = -ENOMEM;
> +		goto err_alloc_loradev;
> +	}
> +
> +	priv = netdev_priv(netdev);
> +	priv->rst_gpio = rst;
> +	priv->cur_page = 0xff;
> +
> +	spi_set_drvdata(spi, netdev);
> +	SET_NETDEV_DEV(netdev, &spi->dev);
> +
> +	ret = sx1301_write(spi, REG_PAGE_RESET, 0);
> +	if (ret) {
> +		dev_err(&spi->dev, "page/reset write failed\n");
> +		return ret;
> +	}
> +
> +	ret = sx1301_soft_reset(spi);
> +	if (ret) {
> +		dev_err(&spi->dev, "soft reset failed\n");
> +		return ret;
> +	}
> +
> +	ret = sx1301_read(spi, 16, &val);
> +	if (ret) {
> +		dev_err(&spi->dev, "16 read failed\n");
> +		return ret;
> +	}
> +
> +	val &= ~REG_16_GLOBAL_EN;
> +
> +	ret = sx1301_write(spi, 16, val);
> +	if (ret) {
> +		dev_err(&spi->dev, "16 write failed\n");
> +		return ret;
> +	}
> +
> +	ret = sx1301_read(spi, 17, &val);
> +	if (ret) {
> +		dev_err(&spi->dev, "17 read failed\n");
> +		return ret;
> +	}
> +
> +	val &= ~REG_17_CLK32M_EN;
> +
> +	ret = sx1301_write(spi, 17, val);
> +	if (ret) {
> +		dev_err(&spi->dev, "17 write failed\n");
> +		return ret;
> +	}
> +
> +	ret = sx1301_page_switch(spi, 2);
> +	if (ret) {
> +		dev_err(&spi->dev, "page 2 switch failed\n");
> +		return ret;
> +	}
> +
> +	ret = sx1301_read(spi, 43, &val);
> +	if (ret) {
> +		dev_err(&spi->dev, "2|43 read failed\n");
> +		return ret;
> +	}
> +
> +	val |= REG_2_43_RADIO_B_EN | REG_2_43_RADIO_A_EN;
> +
> +	ret = sx1301_write(spi, 43, val);
> +	if (ret) {
> +		dev_err(&spi->dev, "2|43 write failed\n");
> +		return ret;
> +	}
> +
> +	msleep(500);
> +
> +	ret = sx1301_read(spi, 43, &val);
> +	if (ret) {
> +		dev_err(&spi->dev, "2|43 read failed\n");
> +		return ret;
> +	}
> +
> +	val |= REG_2_43_RADIO_RST;
> +
> +	ret = sx1301_write(spi, 43, val);
> +	if (ret) {
> +		dev_err(&spi->dev, "2|43 write failed\n");
> +		return ret;
> +	}
> +
> +	msleep(5);
> +
> +	ret = sx1301_read(spi, 43, &val);
> +	if (ret) {
> +		dev_err(&spi->dev, "2|43 read failed\n");
> +		return ret;
> +	}
> +
> +	val &= ~REG_2_43_RADIO_RST;
> +
> +	ret = sx1301_write(spi, 43, val);
> +	if (ret) {
> +		dev_err(&spi->dev, "2|43 write failed\n");
> +		return ret;
> +	}
> +
> +	/* radio A */
> +
> +	priv->radio_a_ctrl = spi_alloc_master(&spi->dev, sizeof(*radio));
> +	if (!priv->radio_a_ctrl) {
> +		ret = -ENOMEM;
> +		goto err_radio_a_alloc;
> +	}
> +
> +	sx1301_radio_setup(priv->radio_a_ctrl);
> +	priv->radio_a_ctrl->dev.of_node = of_get_child_by_name(spi-
> >dev.of_node, "radio-a");
> +
> +	radio = spi_controller_get_devdata(priv->radio_a_ctrl);
> +	radio->page = 2;
> +	radio->regs = REG_2_SPI_RADIO_A_DATA;
> +	radio->parent = spi;
> +
> +	dev_info(&spi->dev, "registering radio A SPI\n");
> +
> +	ret = devm_spi_register_controller(&spi->dev, priv->radio_a_ctrl);
> +	if (ret) {
> +		dev_err(&spi->dev, "radio A SPI register failed\n");
> +		goto err_radio_a_register;
> +	}
> +
> +	/* radio B */
> +
> +	priv->radio_b_ctrl = spi_alloc_master(&spi->dev, sizeof(*radio));
> +	if (!priv->radio_b_ctrl) {
> +		ret = -ENOMEM;
> +		goto err_radio_b_alloc;
> +	}
> +
> +	sx1301_radio_setup(priv->radio_b_ctrl);
> +	priv->radio_b_ctrl->dev.of_node = of_get_child_by_name(spi-
> >dev.of_node, "radio-b");
> +
> +	radio = spi_controller_get_devdata(priv->radio_b_ctrl);
> +	radio->page = 2;
> +	radio->regs = REG_2_SPI_RADIO_B_DATA;
> +	radio->parent = spi;
> +
> +	dev_info(&spi->dev, "registering radio B SPI\n");
> +
> +	ret = devm_spi_register_controller(&spi->dev, priv->radio_b_ctrl);
> +	if (ret) {
> +		dev_err(&spi->dev, "radio B SPI register failed\n");
> +		goto err_radio_b_register;
> +	}
> +
> +	dev_info(&spi->dev, "SX1301 module probed\n");
> +
> +	return 0;
> +err_radio_b_register:
> +	spi_controller_put(priv->radio_b_ctrl);
> +err_radio_b_alloc:
> +err_radio_a_register:
> +	spi_controller_put(priv->radio_a_ctrl);
> +err_radio_a_alloc:
> +	free_loradev(netdev);
> +err_alloc_loradev:
> +err_version:
> +	return ret;
> +}
> +
> +static int sx1301_remove(struct spi_device *spi)
> +{
> +	struct net_device *netdev = spi_get_drvdata(spi);
> +
> +	//unregister_loradev(netdev);
> +	free_loradev(netdev);
> +
> +	dev_info(&spi->dev, "SX1301 module removed\n");
> +
> +	return 0;
> +}
> +
> +#ifdef CONFIG_OF
> +static const struct of_device_id sx1301_dt_ids[] = {
> +	{ .compatible = "semtech,sx1301" },
> +	{}
> +};
> +MODULE_DEVICE_TABLE(of, sx1301_dt_ids);
> +#endif
> +
> +static struct spi_driver sx1301_spi_driver = {
> +	.driver = {
> +		.name = "sx1301",
> +		.of_match_table = of_match_ptr(sx1301_dt_ids),
> +	},
> +	.probe = sx1301_probe,
> +	.remove = sx1301_remove,
> +};
> +
> +module_spi_driver(sx1301_spi_driver);
> +
> +MODULE_DESCRIPTION("SX1301 SPI driver");
> +MODULE_AUTHOR("Andreas Färber <afaerber@suse.de>");
> +MODULE_LICENSE("GPL");
> --
> 2.16.4


^ permalink raw reply

* [PATCH] net: stmmac_tc: use 64-bit arithmetic instead of 32-bit
From: Gustavo A. R. Silva @ 2018-07-02 12:09 UTC (permalink / raw)
  To: Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu, David S. Miller
  Cc: netdev, linux-kernel, Gustavo A. R. Silva

Add suffix UL to constant 1024 in order to give the compiler complete
information about the proper arithmetic to use. Notice that this
constant is used in a context that expects an expression of type
u64 (64 bits, unsigned) and  following expressions are currently
being evaluated using 32-bit arithmetic:

qopt->idleslope * 1024 * ptr
qopt->hicredit * 1024 * 8
qopt->locredit * 1024 * 8

Addresses-Coverity-ID: 1470246 ("Unintentional integer overflow")
Addresses-Coverity-ID: 1470248 ("Unintentional integer overflow")
Addresses-Coverity-ID: 1470249 ("Unintentional integer overflow")
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c
index 0b0fca0..8fedc28 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c
@@ -321,7 +321,7 @@ static int tc_setup_cbs(struct stmmac_priv *priv,
 	speed_div = (priv->speed == SPEED_100) ? 100000 : 1000000;
 
 	/* Final adjustments for HW */
-	value = qopt->idleslope * 1024 * ptr;
+	value = qopt->idleslope * 1024UL * ptr;
 	do_div(value, speed_div);
 	priv->plat->tx_queues_cfg[queue].idle_slope = value & GENMASK(31, 0);
 
@@ -329,10 +329,10 @@ static int tc_setup_cbs(struct stmmac_priv *priv,
 	do_div(value, speed_div);
 	priv->plat->tx_queues_cfg[queue].send_slope = value & GENMASK(31, 0);
 
-	value = qopt->hicredit * 1024 * 8;
+	value = qopt->hicredit * 1024UL * 8;
 	priv->plat->tx_queues_cfg[queue].high_credit = value & GENMASK(31, 0);
 
-	value = qopt->locredit * 1024 * 8;
+	value = qopt->locredit * 1024UL * 8;
 	priv->plat->tx_queues_cfg[queue].low_credit = value & GENMASK(31, 0);
 
 	ret = stmmac_config_cbs(priv, priv->hw,
-- 
2.7.4

^ permalink raw reply related

* [PATCH net-next v4 1/4] vhost: lock the vqs one by one
From: xiangxia.m.yue @ 2018-07-02 12:57 UTC (permalink / raw)
  To: jasowang
  Cc: mst, makita.toshiaki, virtualization, netdev, Tonghao Zhang,
	Tonghao Zhang
In-Reply-To: <1530536228-17462-1-git-send-email-xiangxia.m.yue@gmail.com>

From: Tonghao Zhang <xiangxia.m.yue@gmail.com>

This patch changes the way that lock all vqs
at the same, to lock them one by one. It will
be used for next patch to avoid the deadlock.

Signed-off-by: Tonghao Zhang <zhangtonghao@didichuxing.com>
Acked-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
---
 drivers/vhost/vhost.c | 24 +++++++-----------------
 1 file changed, 7 insertions(+), 17 deletions(-)

diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
index 895eaa2..4ca9383 100644
--- a/drivers/vhost/vhost.c
+++ b/drivers/vhost/vhost.c
@@ -294,8 +294,11 @@ static void vhost_vq_meta_reset(struct vhost_dev *d)
 {
 	int i;
 
-	for (i = 0; i < d->nvqs; ++i)
+	for (i = 0; i < d->nvqs; ++i) {
+		mutex_lock(&d->vqs[i]->mutex);
 		__vhost_vq_meta_reset(d->vqs[i]);
+		mutex_unlock(&d->vqs[i]->mutex);
+	}
 }
 
 static void vhost_vq_reset(struct vhost_dev *dev,
@@ -887,20 +890,6 @@ static inline void __user *__vhost_get_user(struct vhost_virtqueue *vq,
 #define vhost_get_used(vq, x, ptr) \
 	vhost_get_user(vq, x, ptr, VHOST_ADDR_USED)
 
-static void vhost_dev_lock_vqs(struct vhost_dev *d)
-{
-	int i = 0;
-	for (i = 0; i < d->nvqs; ++i)
-		mutex_lock_nested(&d->vqs[i]->mutex, i);
-}
-
-static void vhost_dev_unlock_vqs(struct vhost_dev *d)
-{
-	int i = 0;
-	for (i = 0; i < d->nvqs; ++i)
-		mutex_unlock(&d->vqs[i]->mutex);
-}
-
 static int vhost_new_umem_range(struct vhost_umem *umem,
 				u64 start, u64 size, u64 end,
 				u64 userspace_addr, int perm)
@@ -950,7 +939,10 @@ static void vhost_iotlb_notify_vq(struct vhost_dev *d,
 		if (msg->iova <= vq_msg->iova &&
 		    msg->iova + msg->size - 1 > vq_msg->iova &&
 		    vq_msg->type == VHOST_IOTLB_MISS) {
+			mutex_lock(&node->vq->mutex);
 			vhost_poll_queue(&node->vq->poll);
+			mutex_unlock(&node->vq->mutex);
+
 			list_del(&node->node);
 			kfree(node);
 		}
@@ -982,7 +974,6 @@ static int vhost_process_iotlb_msg(struct vhost_dev *dev,
 	int ret = 0;
 
 	mutex_lock(&dev->mutex);
-	vhost_dev_lock_vqs(dev);
 	switch (msg->type) {
 	case VHOST_IOTLB_UPDATE:
 		if (!dev->iotlb) {
@@ -1016,7 +1007,6 @@ static int vhost_process_iotlb_msg(struct vhost_dev *dev,
 		break;
 	}
 
-	vhost_dev_unlock_vqs(dev);
 	mutex_unlock(&dev->mutex);
 
 	return ret;
-- 
1.8.3.1

^ permalink raw reply related

* [PATCH net-next v4 2/4] net: vhost: replace magic number of lock annotation
From: xiangxia.m.yue @ 2018-07-02 12:57 UTC (permalink / raw)
  To: jasowang
  Cc: mst, makita.toshiaki, virtualization, netdev, Tonghao Zhang,
	Tonghao Zhang
In-Reply-To: <1530536228-17462-1-git-send-email-xiangxia.m.yue@gmail.com>

From: Tonghao Zhang <xiangxia.m.yue@gmail.com>

Use the VHOST_NET_VQ_XXX as a subclass for mutex_lock_nested.

Signed-off-by: Tonghao Zhang <zhangtonghao@didichuxing.com>
Acked-by: Jason Wang <jasowang@redhat.com>
---
 drivers/vhost/net.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
index e7cf7d2..62bb8e8 100644
--- a/drivers/vhost/net.c
+++ b/drivers/vhost/net.c
@@ -484,7 +484,7 @@ static void handle_tx(struct vhost_net *net)
 	bool zcopy, zcopy_used;
 	int sent_pkts = 0;
 
-	mutex_lock(&vq->mutex);
+	mutex_lock_nested(&vq->mutex, VHOST_NET_VQ_TX);
 	sock = vq->private_data;
 	if (!sock)
 		goto out;
@@ -655,7 +655,7 @@ static int vhost_net_rx_peek_head_len(struct vhost_net *net, struct sock *sk)
 		/* Flush batched heads first */
 		vhost_rx_signal_used(rvq);
 		/* Both tx vq and rx socket were polled here */
-		mutex_lock_nested(&vq->mutex, 1);
+		mutex_lock_nested(&vq->mutex, VHOST_NET_VQ_TX);
 		vhost_disable_notify(&net->dev, vq);
 
 		preempt_disable();
@@ -789,7 +789,7 @@ static void handle_rx(struct vhost_net *net)
 	__virtio16 num_buffers;
 	int recv_pkts = 0;
 
-	mutex_lock_nested(&vq->mutex, 0);
+	mutex_lock_nested(&vq->mutex, VHOST_NET_VQ_RX);
 	sock = vq->private_data;
 	if (!sock)
 		goto out;
-- 
1.8.3.1

^ permalink raw reply related

* [PATCH net-next v4 3/4] net: vhost: factor out busy polling logic to vhost_net_busy_poll()
From: xiangxia.m.yue @ 2018-07-02 12:57 UTC (permalink / raw)
  To: jasowang
  Cc: mst, makita.toshiaki, virtualization, netdev, Tonghao Zhang,
	Tonghao Zhang
In-Reply-To: <1530536228-17462-1-git-send-email-xiangxia.m.yue@gmail.com>

From: Tonghao Zhang <xiangxia.m.yue@gmail.com>

Factor out generic busy polling logic and will be
used for in tx path in the next patch. And with the patch,
qemu can set differently the busyloop_timeout for rx queue.

Signed-off-by: Tonghao Zhang <zhangtonghao@didichuxing.com>
---
 drivers/vhost/net.c | 94 +++++++++++++++++++++++++++++++----------------------
 1 file changed, 55 insertions(+), 39 deletions(-)

diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
index 62bb8e8..2790959 100644
--- a/drivers/vhost/net.c
+++ b/drivers/vhost/net.c
@@ -429,6 +429,52 @@ static int vhost_net_enable_vq(struct vhost_net *n,
 	return vhost_poll_start(poll, sock->file);
 }
 
+static int sk_has_rx_data(struct sock *sk)
+{
+	struct socket *sock = sk->sk_socket;
+
+	if (sock->ops->peek_len)
+		return sock->ops->peek_len(sock);
+
+	return skb_queue_empty(&sk->sk_receive_queue);
+}
+
+static void vhost_net_busy_poll(struct vhost_net *net,
+				struct vhost_virtqueue *rvq,
+				struct vhost_virtqueue *tvq,
+				bool rx)
+{
+	unsigned long uninitialized_var(endtime);
+	unsigned long busyloop_timeout;
+	struct socket *sock;
+	struct vhost_virtqueue *vq = rx ? tvq : rvq;
+
+	mutex_lock_nested(&vq->mutex, rx ? VHOST_NET_VQ_TX: VHOST_NET_VQ_RX);
+
+	vhost_disable_notify(&net->dev, vq);
+	sock = rvq->private_data;
+	busyloop_timeout = rx ? rvq->busyloop_timeout : tvq->busyloop_timeout;
+
+	preempt_disable();
+	endtime = busy_clock() + busyloop_timeout;
+	while (vhost_can_busy_poll(tvq->dev, endtime) &&
+	       !(sock && sk_has_rx_data(sock->sk)) &&
+	       vhost_vq_avail_empty(tvq->dev, tvq))
+		cpu_relax();
+	preempt_enable();
+
+	if ((rx && !vhost_vq_avail_empty(&net->dev, vq)) ||
+	    (!rx && (sock && sk_has_rx_data(sock->sk)))) {
+		vhost_poll_queue(&vq->poll);
+	} else if (unlikely(vhost_enable_notify(&net->dev, vq))) {
+		vhost_disable_notify(&net->dev, vq);
+		vhost_poll_queue(&vq->poll);
+	}
+
+	mutex_unlock(&vq->mutex);
+}
+
+
 static int vhost_net_tx_get_vq_desc(struct vhost_net *net,
 				    struct vhost_virtqueue *vq,
 				    struct iovec iov[], unsigned int iov_size,
@@ -621,16 +667,6 @@ static int peek_head_len(struct vhost_net_virtqueue *rvq, struct sock *sk)
 	return len;
 }
 
-static int sk_has_rx_data(struct sock *sk)
-{
-	struct socket *sock = sk->sk_socket;
-
-	if (sock->ops->peek_len)
-		return sock->ops->peek_len(sock);
-
-	return skb_queue_empty(&sk->sk_receive_queue);
-}
-
 static void vhost_rx_signal_used(struct vhost_net_virtqueue *nvq)
 {
 	struct vhost_virtqueue *vq = &nvq->vq;
@@ -645,39 +681,19 @@ static void vhost_rx_signal_used(struct vhost_net_virtqueue *nvq)
 
 static int vhost_net_rx_peek_head_len(struct vhost_net *net, struct sock *sk)
 {
-	struct vhost_net_virtqueue *rvq = &net->vqs[VHOST_NET_VQ_RX];
-	struct vhost_net_virtqueue *nvq = &net->vqs[VHOST_NET_VQ_TX];
-	struct vhost_virtqueue *vq = &nvq->vq;
-	unsigned long uninitialized_var(endtime);
-	int len = peek_head_len(rvq, sk);
+	struct vhost_net_virtqueue *rnvq = &net->vqs[VHOST_NET_VQ_RX];
+	struct vhost_net_virtqueue *tnvq = &net->vqs[VHOST_NET_VQ_TX];
 
-	if (!len && vq->busyloop_timeout) {
-		/* Flush batched heads first */
-		vhost_rx_signal_used(rvq);
-		/* Both tx vq and rx socket were polled here */
-		mutex_lock_nested(&vq->mutex, VHOST_NET_VQ_TX);
-		vhost_disable_notify(&net->dev, vq);
+	int len = peek_head_len(rnvq, sk);
 
-		preempt_disable();
-		endtime = busy_clock() + vq->busyloop_timeout;
-
-		while (vhost_can_busy_poll(&net->dev, endtime) &&
-		       !sk_has_rx_data(sk) &&
-		       vhost_vq_avail_empty(&net->dev, vq))
-			cpu_relax();
-
-		preempt_enable();
-
-		if (!vhost_vq_avail_empty(&net->dev, vq))
-			vhost_poll_queue(&vq->poll);
-		else if (unlikely(vhost_enable_notify(&net->dev, vq))) {
-			vhost_disable_notify(&net->dev, vq);
-			vhost_poll_queue(&vq->poll);
-		}
+	if (!len && rnvq->vq.busyloop_timeout) {
+		/* Flush batched heads first */
+		vhost_rx_signal_used(rnvq);
 
-		mutex_unlock(&vq->mutex);
+		/* Both tx vq and rx socket were polled here */
+		vhost_net_busy_poll(net, &rnvq->vq, &tnvq->vq, true);
 
-		len = peek_head_len(rvq, sk);
+		len = peek_head_len(rnvq, sk);
 	}
 
 	return len;
-- 
1.8.3.1

^ permalink raw reply related

* [PATCH net-next v4 4/4] net: vhost: add rx busy polling in tx path
From: xiangxia.m.yue @ 2018-07-02 12:57 UTC (permalink / raw)
  To: jasowang
  Cc: mst, makita.toshiaki, virtualization, netdev, Tonghao Zhang,
	Tonghao Zhang
In-Reply-To: <1530536228-17462-1-git-send-email-xiangxia.m.yue@gmail.com>

From: Tonghao Zhang <xiangxia.m.yue@gmail.com>

This patch improves the guest receive and transmit performance.
On the handle_tx side, we poll the sock receive queue at the
same time. handle_rx do that in the same way.

We set the poll-us=100us and use the iperf3 to test
its bandwidth, use the netperf to test throughput and mean
latency. When running the tests, the vhost-net kthread of
that VM, is alway 100% CPU. The commands are shown as below.

iperf3  -s -D
iperf3  -c IP -i 1 -P 1 -t 20 -M 1400

or
netserver
netperf -H IP -t TCP_RR -l 20 -- -O "THROUGHPUT,MEAN_LATENCY"

host -> guest:
iperf3:
* With the patch:     27.0 Gbits/sec
* Without the patch:  14.4 Gbits/sec

netperf (TCP_RR):
* With the patch:     48039.56 trans/s, 20.64us mean latency
* Without the patch:  46027.07 trans/s, 21.58us mean latency

This patch also improves the guest transmit performance.

guest -> host:
iperf3:
* With the patch:     27.2 Gbits/sec
* Without the patch:  24.4 Gbits/sec

netperf (TCP_RR):
* With the patch:     47963.25 trans/s, 20.71us mean latency
* Without the patch:  45796.70 trans/s, 21.68us mean latency

Signed-off-by: Tonghao Zhang <zhangtonghao@didichuxing.com>
---
 drivers/vhost/net.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
index 2790959..3f26547 100644
--- a/drivers/vhost/net.c
+++ b/drivers/vhost/net.c
@@ -480,17 +480,13 @@ static int vhost_net_tx_get_vq_desc(struct vhost_net *net,
 				    struct iovec iov[], unsigned int iov_size,
 				    unsigned int *out_num, unsigned int *in_num)
 {
-	unsigned long uninitialized_var(endtime);
+	struct vhost_net_virtqueue *rnvq = &net->vqs[VHOST_NET_VQ_RX];
 	int r = vhost_get_vq_desc(vq, vq->iov, ARRAY_SIZE(vq->iov),
 				  out_num, in_num, NULL, NULL);
 
 	if (r == vq->num && vq->busyloop_timeout) {
-		preempt_disable();
-		endtime = busy_clock() + vq->busyloop_timeout;
-		while (vhost_can_busy_poll(vq->dev, endtime) &&
-		       vhost_vq_avail_empty(vq->dev, vq))
-			cpu_relax();
-		preempt_enable();
+		vhost_net_busy_poll(net, &rnvq->vq, vq, false);
+
 		r = vhost_get_vq_desc(vq, vq->iov, ARRAY_SIZE(vq->iov),
 				      out_num, in_num, NULL, NULL);
 	}
-- 
1.8.3.1

^ permalink raw reply related

* [PATCH net-next v4 0/4] net: vhost: improve performance when enable busyloop
From: xiangxia.m.yue @ 2018-07-02 12:57 UTC (permalink / raw)
  To: jasowang; +Cc: netdev, virtualization, mst

From: Tonghao Zhang <xiangxia.m.yue@gmail.com>

This patches improve the guest receive and transmit performance.
On the handle_tx side, we poll the sock receive queue at the same time.
handle_rx do that in the same way.

For more performance report, see patch 4.

v3 -> v4:
fix some issues

v2 -> v3:
This patches are splited from previous big patch:
http://patchwork.ozlabs.org/patch/934673/

Tonghao Zhang (4):
  vhost: lock the vqs one by one
  net: vhost: replace magic number of lock annotation
  net: vhost: factor out busy polling logic to vhost_net_busy_poll()
  net: vhost: add rx busy polling in tx path

 drivers/vhost/net.c   | 108 ++++++++++++++++++++++++++++----------------------
 drivers/vhost/vhost.c |  24 ++++-------
 2 files changed, 67 insertions(+), 65 deletions(-)

-- 
1.8.3.1

^ permalink raw reply

* Re: [PATCH] wlcore: Fix memory leak in wlcore_cmd_wait_for_event_or_timeout
From: Gustavo A. R. Silva @ 2018-07-02 13:01 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: Kalle Valo, David S. Miller, linux-wireless, netdev, linux-kernel
In-Reply-To: <20180702113008.GV112168@atomide.com>



On 07/02/2018 06:30 AM, Tony Lindgren wrote:
> * Gustavo A. R. Silva <gustavo@embeddedor.com> [180628 13:11]:
>> In case memory resources for *events_vector* were allocated, release
>> them before return.
>>
>> Addresses-Coverity-ID: 1470194 ("Resource leak")
>> Fixes: 4ec7cece87b3 ("wlcore: Add missing PM call for wlcore_cmd_wait_for_event_or_timeout()")
>> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
> 
> Thanks for catching this one:
> 
> Acked-by: Tony Lindgren <tony@atomide.com>
> 

Glad to help. :)

Thanks
--
Gustavo

^ permalink raw reply

* [GIT] Networking
From: David Miller @ 2018-07-02 13:03 UTC (permalink / raw)
  To: torvalds; +Cc: akpm, netdev, linux-kernel


1) Verify netlink attributes properly in nf_queue, from Eric Dumazet.

2) Need to bump memory lock rlimit for test_sockmap bpf test, from
   Yonghong Song.

3) Fix VLAN handling in lan78xx driver, from Dave Stevenson.

4) Fix uninitialized read in nf_log, from Jann Horn.

5) Fix raw command length parsing in mlx5, from Alex Vesker.

6) Cleanup loopback RDS connections upon netns deletion, from Sowmini
   Varadhan.

7) Fix regressions in FIB rule matching during create, from Jason
   A. Donenfeld and Roopa Prabhu.

8) Fix mpls ether type detection in nfp, from Pieter Jansen van
   Vuuren.

9) More bpfilter build fixes/adjustments from Masahiro Yamada.

10) Fix XDP_{TX,REDIRECT} flushing in various drivers, from Jesper
    Dangaard Brouer.

11) fib_tests.sh file permissions were broken, from Shuah Khan.

12) Make sure BH/preemption is disabled in data path of mac80211,
    from Denis Kenzior.

13) Don't ignore nla_parse_nested() return values in nl80211,
    from Johannes berg.

14) Properly account sock objects ot kmemcg, from Shakeel Butt.

15) Adjustments to setting bpf program permissions to read-only,
    from Daniel Borkmann.

16) TCP Fast Open key endianness was broken, it always took on
    the host endiannness.  Whoops.  Explicitly make it little
    endian.  From Yuching Cheng.

17) Fix prefix route setting for link local addresses in ipv6,
    from David Ahern.

18) Potential Spectre v1 in zatm driver, from Gustavo A. R. Silva.

19) Various bpf sockmap fixes, from John Fastabend.

20) Use after free for GRO with ESP, from Sabrina Dubroca.

21) Passing bogus flags to crypto_alloc_shash() in ipv6 SR code,
    from Eric Biggers.

Please pull, thanks a lot!

The following changes since commit 6f0d349d922ba44e4348a17a78ea51b7135965b1:

  Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net (2018-06-25 15:58:17 +0800)

are available in the Git repository at:

  gitolite@ra.kernel.org:/pub/scm/linux/kernel/git/davem/net.git 

for you to fetch changes up to e48e097996439cd73f36c89b98ba4175d84c9be6:

  Merge branch 'qed-fixes' (2018-07-02 20:41:31 +0900)

----------------------------------------------------------------
Alex Vesker (2):
      net/mlx5: Fix incorrect raw command length parsing
      net/mlx5: Fix command interface race in polling mode

Alexandre Belloni (1):
      net: macb: initialize bp->queues[0].bp for at91rm9200

Alexei Starovoitov (1):
      Merge branch 'bpf-fixes'

Anders Roxell (1):
      selftests: bpf: add missing NET_SCHED to config

Bert Kenward (1):
      sfc: correctly initialise filter rwsem for farch

Bob Copeland (1):
      nl80211: relax ht operation checks for mesh

Chengguang Xu (1):
      nfp: cast sizeof() to int when comparing with error code

Cong Wang (1):
      net: use dev_change_tx_queue_len() for SIOCSIFTXQLEN

Dan Carpenter (2):
      atm: iphase: fix a 64 bit bug
      cnic: tidy up a size calculation

Dan Murphy (1):
      net: phy: DP83TC811: Fix disabling interrupts

Daniel Borkmann (5):
      Merge branch 'bpf-bpftool-fixes'
      bpf, arm32: fix to use bpf_jit_binary_lock_ro api
      bpf, s390: fix potential memleak when later bpf_jit_prog fails
      bpf: undo prog rejection on read-only lock failure
      Merge branch 'bpf-sockmap-fixes'

Dave Stevenson (4):
      net: lan78xx: Allow for VLAN headers in timeout calcs
      net: lan78xx: Add support for VLAN filtering.
      net: lan78xx: Add support for VLAN tag stripping.
      net: lan78xx: Use s/w csum check on VLANs without tag stripping

David Ahern (2):
      bpf: Change bpf_fib_lookup to return lookup status
      net/ipv6: Fix updates to prefix route

David S. Miller (10):
      Merge branch 'lan78xx-minor-fixes'
      Merge branch 'nfp-MPLS-and-shared-blocks-TC-offload-fixes'
      Merge git://git.kernel.org/.../pablo/nf
      Merge branch 'xdp-flush'
      Merge tag 'mlx5-fixes-2018-06-26' of git://git.kernel.org/.../saeed/linux
      Merge tag 'mac80211-for-davem-2018-06-29' of git://git.kernel.org/.../jberg/mac80211
      Merge branch 'DPAA-fixes'
      Merge branch 's390-qeth-fixes'
      Merge git://git.kernel.org/.../bpf/bpf
      Merge branch 'qed-fixes'

Denis Kenzior (1):
      mac80211: disable BHs/preemption in ieee80211_tx_control_port()

Doron Roberts-Kedes (1):
      strparser: Remove early eaten to fix full tcp receive buffer stall

Eli Cohen (2):
      net/mlx5: E-Switch, Disallow vlan/spoofcheck setup if not being esw manager
      net/mlx5: Fix required capability for manipulating MPFS

Eric Biggers (1):
      ipv6: sr: fix passing wrong flags to crypto_alloc_shash()

Eric Dumazet (3):
      netfilter: nf_queue: augment nfqa_cfg_policy
      netfilter: ipv6: nf_defrag: reduce struct net memory waste
      tcp: add one more quick ack after after ECN events

Florian Westphal (1):
      netfilter: nf_conncount: fix garbage collection confirm race

Gao Feng (1):
      netfilter: nf_ct_helper: Fix possible panic after nf_conntrack_helper_unregister

Gustavo A. R. Silva (1):
      atm: zatm: Fix potential Spectre v1

Hangbin Liu (1):
      ipvlan: call dev_change_flags when ipvlan mode is reset

Ilpo Järvinen (1):
      tcp: prevent bogus FRTO undos with non-SACK flows

Jakub Kicinski (3):
      tools: bpftool: remove duplicated error message on prog load
      tools: bpftool: remember to close the libbpf object after prog load
      nfp: bpf: don't stop offload if replace failed

Jann Horn (2):
      netfilter: nf_log: fix uninit read in nf_log_proc_dostring
      netfilter: nf_log: don't hold nf_log_mutex during user access

Jason A. Donenfeld (1):
      fib_rules: match rules based on suppress_* properties too

Jeffrin Jose T (3):
      selftests: bpf: notification about privilege required to run test_kmod.sh testing script
      selftests: bpf: notification about privilege required to run test_lirc_mode2.sh testing script
      selftests: bpf: notification about privilege required to run test_lwt_seg6local.sh testing script

Jesper Dangaard Brouer (3):
      ixgbe: split XDP_TX tail and XDP_REDIRECT map flushing
      i40e: split XDP_TX tail and XDP_REDIRECT map flushing
      virtio_net: split XDP_TX kick and XDP_REDIRECT map flushing

Jiri Slaby (1):
      r8152: napi hangup fix after disconnect

Johannes Berg (1):
      nl80211: check nla_parse_nested() return values

John Fastabend (4):
      bpf: sockmap, fix crash when ipv6 sock is added
      bpf: sockmap, fix smap_list_map_remove when psock is in many maps
      bpf: sockhash fix omitted bucket lock in sock_close
      bpf: sockhash, add release routine

John Hurley (1):
      nfp: reject binding to shared blocks

Jose Abreu (1):
      net: stmmac: Set DMA buffer size in HW

Julian Wiedmann (4):
      Revert "s390/qeth: use Read device to query hypervisor for MAC"
      s390/qeth: fix race when setting MAC address
      s390/qeth: don't clobber buffer on async TX completion
      s390/qeth: consistently re-enable device features

Kleber Sacilotto de Souza (1):
      test_bpf: flag tests that cannot be jited on s390

Madalin Bucur (2):
      fsl/fman: fix parser reporting bad checksum on short frames
      dpaa_eth: DPAA SGT needs to be 256B

Masahiro Yamada (2):
      bpfilter: check compiler capability in Kconfig
      bpfilter: include bpfilter_umh in assembly instead of using objcopy

Michal Hocko (1):
      net: cleanup gfp mask in alloc_skb_with_frags

Or Gerlitz (4):
      net/mlx5e: Don't attempt to dereference the ppriv struct if not being eswitch manager
      net/mlx5: E-Switch, Avoid setup attempt if not being e-switch manager
      net/mlx5e: Avoid dealing with vport representors if not being e-switch manager
      IB/mlx5: Avoid dealing with vport representors if not being e-switch manager

Pieter Jansen van Vuuren (1):
      nfp: flower: fix mpls ether type detection

Roopa Prabhu (1):
      net: fib_rules: bring back rule_exists to match rule during add

Sabrina Dubroca (2):
      alx: take rtnl before calling __alx_open from resume
      net: fix use-after-free in GRO with ESP

Sean Young (1):
      bpf: fix attach type BPF_LIRC_MODE2 dependency wrt CONFIG_CGROUP_BPF

Shakeel Butt (1):
      net, mm: account sock objects to kmemcg

Shay Agroskin (1):
      net/mlx5: Fix wrong size allocation for QoS ETC TC regitster

Shuah Khan (1):
      selftests/net: Fix permissions for fib_tests.sh

Sowmini Varadhan (1):
      rds: clean up loopback rds_connections on netns deletion

Stephen Hemminger (1):
      hv_netvsc: split sub-channel setup into async and sync

Sudarsana Reddy Kalluru (5):
      bnx2x: Fix receiving tx-timeout in error or recovery state.
      qed: Limit msix vectors in kdump kernel to the minimum required count.
      qed: Fix setting of incorrect eswitch mode.
      qed: Fix use of incorrect size in memcpy call.
      qede: Adverstise software timestamp caps when PHC is not available.

Ursula Braun (1):
      net/smc: rebuild nonblocking connect

Vasily Gorbik (1):
      s390/qeth: avoid using is_multicast_ether_addr_64bits on (u8 *)[6]

Wei Yongjun (1):
      hinic: reset irq affinity before freeing irq

Yonghong Song (1):
      tools/bpf: fix test_sockmap failure

Yuchung Cheng (1):
      tcp: fix Fast Open key endianness

 Makefile                                                   |   5 --
 arch/arm/net/bpf_jit_32.c                                  |   2 +-
 arch/s390/net/bpf_jit_comp.c                               |   1 +
 drivers/atm/iphase.c                                       |   2 +-
 drivers/atm/zatm.c                                         |   2 +
 drivers/infiniband/hw/mlx5/main.c                          |   2 +-
 drivers/media/rc/bpf-lirc.c                                |  14 +----
 drivers/net/ethernet/atheros/alx/main.c                    |   8 ++-
 drivers/net/ethernet/broadcom/bnx2x/bnx2x.h                |   1 +
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c            |   6 +++
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c           |   6 +++
 drivers/net/ethernet/broadcom/cnic.c                       |   2 +-
 drivers/net/ethernet/cadence/macb_main.c                   |   2 +
 drivers/net/ethernet/freescale/dpaa/dpaa_eth.c             |  15 +++---
 drivers/net/ethernet/freescale/fman/fman_port.c            |   8 +++
 drivers/net/ethernet/huawei/hinic/hinic_rx.c               |   1 +
 drivers/net/ethernet/intel/i40e/i40e_txrx.c                |  24 +++++----
 drivers/net/ethernet/intel/ixgbe/ixgbe_main.c              |  24 +++++----
 drivers/net/ethernet/mellanox/mlx5/core/cmd.c              |   8 +--
 drivers/net/ethernet/mellanox/mlx5/core/en_main.c          |  12 ++---
 drivers/net/ethernet/mellanox/mlx5/core/en_rep.c           |   8 ++-
 drivers/net/ethernet/mellanox/mlx5/core/eswitch.c          |  12 ++---
 drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c |   4 +-
 drivers/net/ethernet/mellanox/mlx5/core/fs_core.c          |   3 +-
 drivers/net/ethernet/mellanox/mlx5/core/fw.c               |   5 +-
 drivers/net/ethernet/mellanox/mlx5/core/lib/mpfs.c         |   9 ++--
 drivers/net/ethernet/mellanox/mlx5/core/port.c             |   4 +-
 drivers/net/ethernet/mellanox/mlx5/core/sriov.c            |   7 ++-
 drivers/net/ethernet/mellanox/mlx5/core/vport.c            |   2 -
 drivers/net/ethernet/netronome/nfp/bpf/main.c              |   9 ++--
 drivers/net/ethernet/netronome/nfp/flower/match.c          |  14 +++++
 drivers/net/ethernet/netronome/nfp/flower/offload.c        |  11 ++++
 drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nffw.c      |   2 +-
 drivers/net/ethernet/qlogic/qed/qed_dcbx.c                 |   8 +--
 drivers/net/ethernet/qlogic/qed/qed_dev.c                  |   2 +-
 drivers/net/ethernet/qlogic/qed/qed_main.c                 |   8 +++
 drivers/net/ethernet/qlogic/qed/qed_sriov.c                |  19 ++++++-
 drivers/net/ethernet/qlogic/qede/qede_ptp.c                |  10 +++-
 drivers/net/ethernet/sfc/farch.c                           |   1 +
 drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c           |  12 +++++
 drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.h           |   2 +
 drivers/net/ethernet/stmicro/stmmac/hwif.h                 |   3 ++
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c          |   2 +
 drivers/net/geneve.c                                       |   2 +-
 drivers/net/hyperv/hyperv_net.h                            |   2 +-
 drivers/net/hyperv/netvsc.c                                |  37 ++++++++++++-
 drivers/net/hyperv/netvsc_drv.c                            |  17 +++++-
 drivers/net/hyperv/rndis_filter.c                          |  61 +++++----------------
 drivers/net/ipvlan/ipvlan_main.c                           |  36 ++++++++++---
 drivers/net/phy/dp83tc811.c                                |   2 +-
 drivers/net/usb/lan78xx.c                                  |  37 +++++++++++--
 drivers/net/usb/r8152.c                                    |   3 +-
 drivers/net/virtio_net.c                                   |  30 +++++++----
 drivers/net/vxlan.c                                        |   4 +-
 drivers/s390/net/qeth_core.h                               |  13 ++++-
 drivers/s390/net/qeth_core_main.c                          |  47 +++++++++-------
 drivers/s390/net/qeth_l2_main.c                            |  24 +++++----
 drivers/s390/net/qeth_l3_main.c                            |   3 +-
 include/linux/bpf-cgroup.h                                 |  26 +++++++++
 include/linux/bpf.h                                        |   8 +++
 include/linux/bpf_lirc.h                                   |   5 +-
 include/linux/filter.h                                     |  56 +++----------------
 include/linux/mlx5/eswitch.h                               |   2 +
 include/linux/mlx5/mlx5_ifc.h                              |   2 +-
 include/linux/netdevice.h                                  |  20 +++++++
 include/net/net_namespace.h                                |   1 +
 include/net/netns/ipv6.h                                   |   1 -
 include/net/pkt_cls.h                                      |   5 ++
 include/uapi/linux/bpf.h                                   |  28 ++++++++--
 kernel/bpf/cgroup.c                                        |  54 +++++++++++++++++++
 kernel/bpf/core.c                                          |  30 +----------
 kernel/bpf/sockmap.c                                       | 254 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------
 kernel/bpf/syscall.c                                       |  99 ++++++++--------------------------
 lib/test_bpf.c                                             |  20 +++++++
 net/8021q/vlan.c                                           |   2 +-
 net/Makefile                                               |   4 --
 net/bpfilter/Kconfig                                       |   2 +-
 net/bpfilter/Makefile                                      |  17 +-----
 net/bpfilter/bpfilter_kern.c                               |  11 ++--
 net/bpfilter/bpfilter_umh_blob.S                           |   7 +++
 net/core/dev_ioctl.c                                       |  11 +---
 net/core/fib_rules.c                                       |  80 +++++++++++++++++++++++++++-
 net/core/filter.c                                          |  86 +++++++++++++++++++-----------
 net/core/skbuff.c                                          |   3 +-
 net/core/sock.c                                            |   7 ++-
 net/ipv4/fou.c                                             |   4 +-
 net/ipv4/gre_offload.c                                     |   2 +-
 net/ipv4/sysctl_net_ipv4.c                                 |  18 +++++--
 net/ipv4/tcp_input.c                                       |  13 ++++-
 net/ipv4/udp_offload.c                                     |   2 +-
 net/ipv6/addrconf.c                                        |   9 ++--
 net/ipv6/netfilter/nf_conntrack_reasm.c                    |   6 +--
 net/ipv6/seg6_hmac.c                                       |   2 +-
 net/mac80211/tx.c                                          |   2 +
 net/netfilter/nf_conncount.c                               |  52 ++++++++++++++++--
 net/netfilter/nf_conntrack_helper.c                        |   5 ++
 net/netfilter/nf_log.c                                     |  13 +++--
 net/netfilter/nfnetlink_queue.c                            |   3 ++
 net/rds/connection.c                                       |  11 +++-
 net/rds/loop.c                                             |  56 +++++++++++++++++++
 net/rds/loop.h                                             |   2 +
 net/smc/af_smc.c                                           |  91 +++++++++++++++++++++----------
 net/smc/smc.h                                              |   8 +++
 net/strparser/strparser.c                                  |  17 +-----
 net/wireless/nl80211.c                                     |  35 +++++-------
 samples/bpf/xdp_fwd_kern.c                                 |   8 +--
 scripts/cc-can-link.sh                                     |   2 +-
 tools/bpf/bpftool/prog.c                                   |  12 +++--
 tools/testing/selftests/bpf/config                         |   1 +
 tools/testing/selftests/bpf/test_kmod.sh                   |   9 ++++
 tools/testing/selftests/bpf/test_lirc_mode2.sh             |   9 ++++
 tools/testing/selftests/bpf/test_lwt_seg6local.sh          |   9 ++++
 tools/testing/selftests/bpf/test_sockmap.c                 |   6 ---
 tools/testing/selftests/net/fib_tests.sh                   |   0
 114 files changed, 1249 insertions(+), 619 deletions(-)
 create mode 100644 net/bpfilter/bpfilter_umh_blob.S
 mode change 100644 => 100755 tools/testing/selftests/net/fib_tests.sh

^ permalink raw reply

* Re: [PATCH] ieee802154: add rx LQI from userspace
From: Clément Péron @ 2018-07-02 13:28 UTC (permalink / raw)
  To: Romuald Cari, linux-wpan
  Cc: Alexander Aring, Stefan Schmidt, David S . Miller, netdev,
	linux-kernel, Clément Peron
In-Reply-To: <20180607140802.22666-1-peron.clem@gmail.com>

Could you review it please ?

Thanks,
Clement
On Thu, 7 Jun 2018 at 16:08, Clément Péron <peron.clem@gmail.com> wrote:
>
> From: Romuald CARI <romuald.cari@devialet.com>
>
> The Link Quality Indication data exposed by drivers could not be accessed from
> userspace. Since this data is per-datagram received, it makes sense to make it
> available to userspace application through the ancillary data mechanism in
> recvmsg rather than through ioctls. This can be activated using the socket
> option WPAN_WANTLQI under SOL_IEEE802154 protocol.
>
> This LQI data is available in the ancillary data buffer under the SOL_IEEE802154
> level as the type WPAN_LQI. The value is an unsigned byte indicating the link
> quality with values ranging 0-255.
>
> Signed-off-by: Romuald Cari <romuald.cari@devialet.com>
> Signed-off-by: Clément Peron <clement.peron@devialet.com>
> ---
>  include/net/af_ieee802154.h |  1 +
>  net/ieee802154/socket.c     | 17 +++++++++++++++++
>  2 files changed, 18 insertions(+)
>
> diff --git a/include/net/af_ieee802154.h b/include/net/af_ieee802154.h
> index a5563d27a3eb..8003a9f6eb43 100644
> --- a/include/net/af_ieee802154.h
> +++ b/include/net/af_ieee802154.h
> @@ -56,6 +56,7 @@ struct sockaddr_ieee802154 {
>  #define WPAN_WANTACK           0
>  #define WPAN_SECURITY          1
>  #define WPAN_SECURITY_LEVEL    2
> +#define WPAN_WANTLQI           3
>
>  #define WPAN_SECURITY_DEFAULT  0
>  #define WPAN_SECURITY_OFF      1
> diff --git a/net/ieee802154/socket.c b/net/ieee802154/socket.c
> index a60658c85a9a..bc6b912603f1 100644
> --- a/net/ieee802154/socket.c
> +++ b/net/ieee802154/socket.c
> @@ -25,6 +25,7 @@
>  #include <linux/termios.h>     /* For TIOCOUTQ/INQ */
>  #include <linux/list.h>
>  #include <linux/slab.h>
> +#include <linux/socket.h>
>  #include <net/datalink.h>
>  #include <net/psnap.h>
>  #include <net/sock.h>
> @@ -452,6 +453,7 @@ struct dgram_sock {
>         unsigned int bound:1;
>         unsigned int connected:1;
>         unsigned int want_ack:1;
> +       unsigned int want_lqi:1;
>         unsigned int secen:1;
>         unsigned int secen_override:1;
>         unsigned int seclevel:3;
> @@ -486,6 +488,7 @@ static int dgram_init(struct sock *sk)
>         struct dgram_sock *ro = dgram_sk(sk);
>
>         ro->want_ack = 1;
> +       ro->want_lqi = 0;
>         return 0;
>  }
>
> @@ -713,6 +716,7 @@ static int dgram_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
>         size_t copied = 0;
>         int err = -EOPNOTSUPP;
>         struct sk_buff *skb;
> +       struct dgram_sock *ro = dgram_sk(sk);
>         DECLARE_SOCKADDR(struct sockaddr_ieee802154 *, saddr, msg->msg_name);
>
>         skb = skb_recv_datagram(sk, flags, noblock, &err);
> @@ -744,6 +748,13 @@ static int dgram_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
>                 *addr_len = sizeof(*saddr);
>         }
>
> +       if (ro->want_lqi) {
> +               err = put_cmsg(msg, SOL_IEEE802154, WPAN_WANTLQI,
> +                              sizeof(uint8_t), &(mac_cb(skb)->lqi));
> +               if (err)
> +                       goto done;
> +       }
> +
>         if (flags & MSG_TRUNC)
>                 copied = skb->len;
>  done:
> @@ -847,6 +858,9 @@ static int dgram_getsockopt(struct sock *sk, int level, int optname,
>         case WPAN_WANTACK:
>                 val = ro->want_ack;
>                 break;
> +       case WPAN_WANTLQI:
> +               val = ro->want_lqi;
> +               break;
>         case WPAN_SECURITY:
>                 if (!ro->secen_override)
>                         val = WPAN_SECURITY_DEFAULT;
> @@ -892,6 +906,9 @@ static int dgram_setsockopt(struct sock *sk, int level, int optname,
>         case WPAN_WANTACK:
>                 ro->want_ack = !!val;
>                 break;
> +       case WPAN_WANTLQI:
> +               ro->want_lqi = !!val;
> +               break;
>         case WPAN_SECURITY:
>                 if (!ns_capable(net->user_ns, CAP_NET_ADMIN) &&
>                     !ns_capable(net->user_ns, CAP_NET_RAW)) {
> --
> 2.17.1
>

^ permalink raw reply

* [PATCH 0/5] m68k: IO Fixes and Cleanups
From: Geert Uytterhoeven @ 2018-07-02 13:35 UTC (permalink / raw)
  To: Greg Ungerer, David S . Miller, Dmitry Torokhov, Helge Deller
  Cc: linux-m68k, netdev, linux-input, linux-kernel, Geert Uytterhoeven

	Hi all,

This patch series contains fixes and cleanups for I/O accessors on m68k
platforms (with MMU).

The first patch contains small fixes without any dependencies.
Patches 2 and 3 make small adjustments to drivers that are dependencies
for further cleanup.
Patch 4 and 5 complete the cleanup.

Given the dependencies, I think it's easiest if the respective
maintainers would provide their Acked-by, so all patches can go in
through the m68k tree.

Thanks for your comments!

Geert Uytterhoeven (5):
  m68k/io: Add missing ioremap define guards, fix typo
  net: mac8390: Use standard memcpy_{from,to}io()
  Input: hilkbd - Add casts to HP9000/300 I/O accessors
  m68k/io: Move mem*io define guards to <asm/kmap.h>
  m68k/io: Switch mmu variant to <asm-generic/io.h>

 arch/m68k/include/asm/io.h          |  7 +++++
 arch/m68k/include/asm/io_mm.h       | 40 +++--------------------------
 arch/m68k/include/asm/io_no.h       | 12 ---------
 arch/m68k/include/asm/kmap.h        |  7 ++++-
 drivers/input/keyboard/hilkbd.c     |  4 +--
 drivers/net/ethernet/8390/mac8390.c | 20 +++++++--------
 6 files changed, 28 insertions(+), 62 deletions(-)

-- 
2.17.1

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds

^ permalink raw reply

* [PATCH 1/5] m68k/io: Add missing ioremap define guards, fix typo
From: Geert Uytterhoeven @ 2018-07-02 13:35 UTC (permalink / raw)
  To: Greg Ungerer, David S . Miller, Dmitry Torokhov, Helge Deller
  Cc: linux-m68k, netdev, linux-input, linux-kernel, Geert Uytterhoeven
In-Reply-To: <20180702133532.5412-1-geert@linux-m68k.org>

  - Add missing define guard for ioremap_wt(),
  - Fix typo s/ioremap_fillcache/ioremap_fullcache/,
  - Add define guard for iounmap() for consistency with other
    architectures.

Fixes: 9746882f547d2f00 ("m68k: group io mapping definitions and functions")
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
 arch/m68k/include/asm/kmap.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/m68k/include/asm/kmap.h b/arch/m68k/include/asm/kmap.h
index 84b8333db8ad1987..bf1026def698f21f 100644
--- a/arch/m68k/include/asm/kmap.h
+++ b/arch/m68k/include/asm/kmap.h
@@ -16,6 +16,7 @@
  */
 extern void __iomem *__ioremap(unsigned long physaddr, unsigned long size,
 			       int cacheflag);
+#define iounmap iounmap
 extern void iounmap(void __iomem *addr);
 extern void __iounmap(void *addr, unsigned long size);
 
@@ -33,13 +34,14 @@ static inline void __iomem *ioremap_nocache(unsigned long physaddr,
 }
 
 #define ioremap_uc ioremap_nocache
+#define ioremap_wt ioremap_wt
 static inline void __iomem *ioremap_wt(unsigned long physaddr,
 				       unsigned long size)
 {
 	return __ioremap(physaddr, size, IOMAP_WRITETHROUGH);
 }
 
-#define ioremap_fillcache ioremap_fullcache
+#define ioremap_fullcache ioremap_fullcache
 static inline void __iomem *ioremap_fullcache(unsigned long physaddr,
 					      unsigned long size)
 {
-- 
2.17.1

^ 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