linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Paul Durrant <Paul.Durrant@citrix.com>
To: Juergen Gross <jgross@suse.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"xen-devel@lists.xen.org" <xen-devel@lists.xen.org>
Cc: David Vrabel <david.vrabel@citrix.com>,
	"boris.ostrovsky@oracle.com" <boris.ostrovsky@oracle.com>,
	Wei Liu <wei.liu2@citrix.com>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>
Subject: RE: [PATCH 06/12] xen: make use of xenbus_read_unsigned() in xen-netback
Date: Tue, 1 Nov 2016 09:42:21 +0000	[thread overview]
Message-ID: <4f93ec8497514ec891f90cb2b540b0b9@AMSPEX02CL03.citrite.net> (raw)
In-Reply-To: <1477932510-28594-7-git-send-email-jgross@suse.com>

> -----Original Message-----
> From: Juergen Gross [mailto:jgross@suse.com]
> Sent: 31 October 2016 16:48
> To: linux-kernel@vger.kernel.org; xen-devel@lists.xen.org
> Cc: David Vrabel <david.vrabel@citrix.com>; boris.ostrovsky@oracle.com;
> Juergen Gross <jgross@suse.com>; Wei Liu <wei.liu2@citrix.com>; Paul
> Durrant <Paul.Durrant@citrix.com>; netdev@vger.kernel.org
> Subject: [PATCH 06/12] xen: make use of xenbus_read_unsigned() in xen-
> netback
> 
> Use xenbus_read_unsigned() instead of xenbus_scanf() when possible.
> This requires to change the type of some reads from int to unsigned,
> but these cases have been wrong before: negative values are not allowed
> for the modified cases.
> 
> Cc: wei.liu2@citrix.com
> Cc: paul.durrant@citrix.com

Reviewed-by: Paul Durrant <paul.durrant@citrix.com>

> Cc: netdev@vger.kernel.org
> 
> Signed-off-by: Juergen Gross <jgross@suse.com>
> ---
>  drivers/net/xen-netback/xenbus.c | 50 +++++++++++---------------------------
> --
>  1 file changed, 14 insertions(+), 36 deletions(-)
> 
> diff --git a/drivers/net/xen-netback/xenbus.c b/drivers/net/xen-
> netback/xenbus.c
> index 8674e18..7356e00 100644
> --- a/drivers/net/xen-netback/xenbus.c
> +++ b/drivers/net/xen-netback/xenbus.c
> @@ -785,12 +785,9 @@ static void xen_mcast_ctrl_changed(struct
> xenbus_watch *watch,
>  	struct xenvif *vif = container_of(watch, struct xenvif,
>  					  mcast_ctrl_watch);
>  	struct xenbus_device *dev = xenvif_to_xenbus_device(vif);
> -	int val;
> 
> -	if (xenbus_scanf(XBT_NIL, dev->otherend,
> -			 "request-multicast-control", "%d", &val) < 0)
> -		val = 0;
> -	vif->multicast_control = !!val;
> +	vif->multicast_control = !!xenbus_read_unsigned(dev->otherend,
> +					"request-multicast-control", 0);
>  }
> 
>  static int xen_register_mcast_ctrl_watch(struct xenbus_device *dev,
> @@ -934,12 +931,9 @@ static void connect(struct backend_info *be)
>  	/* Check whether the frontend requested multiple queues
>  	 * and read the number requested.
>  	 */
> -	err = xenbus_scanf(XBT_NIL, dev->otherend,
> -			   "multi-queue-num-queues",
> -			   "%u", &requested_num_queues);
> -	if (err < 0) {
> -		requested_num_queues = 1; /* Fall back to single queue */
> -	} else if (requested_num_queues > xenvif_max_queues) {
> +	requested_num_queues = xenbus_read_unsigned(dev->otherend,
> +					"multi-queue-num-queues", 1);
> +	if (requested_num_queues > xenvif_max_queues) {
>  		/* buggy or malicious guest */
>  		xenbus_dev_fatal(dev, err,
>  				 "guest requested %u queues, exceeding the
> maximum of %u.",
> @@ -1134,7 +1128,7 @@ static int read_xenbus_vif_flags(struct
> backend_info *be)
>  	struct xenvif *vif = be->vif;
>  	struct xenbus_device *dev = be->dev;
>  	unsigned int rx_copy;
> -	int err, val;
> +	int err;
> 
>  	err = xenbus_scanf(XBT_NIL, dev->otherend, "request-rx-copy",
> "%u",
>  			   &rx_copy);
> @@ -1150,10 +1144,7 @@ static int read_xenbus_vif_flags(struct
> backend_info *be)
>  	if (!rx_copy)
>  		return -EOPNOTSUPP;
> 
> -	if (xenbus_scanf(XBT_NIL, dev->otherend,
> -			 "feature-rx-notify", "%d", &val) < 0)
> -		val = 0;
> -	if (!val) {
> +	if (!xenbus_read_unsigned(dev->otherend, "feature-rx-notify", 0)) {
>  		/* - Reduce drain timeout to poll more frequently for
>  		 *   Rx requests.
>  		 * - Disable Rx stall detection.
> @@ -1162,34 +1153,21 @@ static int read_xenbus_vif_flags(struct
> backend_info *be)
>  		be->vif->stall_timeout = 0;
>  	}
> 
> -	if (xenbus_scanf(XBT_NIL, dev->otherend, "feature-sg",
> -			 "%d", &val) < 0)
> -		val = 0;
> -	vif->can_sg = !!val;
> +	vif->can_sg = !!xenbus_read_unsigned(dev->otherend, "feature-
> sg", 0);
> 
>  	vif->gso_mask = 0;
> 
> -	if (xenbus_scanf(XBT_NIL, dev->otherend, "feature-gso-tcpv4",
> -			 "%d", &val) < 0)
> -		val = 0;
> -	if (val)
> +	if (xenbus_read_unsigned(dev->otherend, "feature-gso-tcpv4", 0))
>  		vif->gso_mask |= GSO_BIT(TCPV4);
> 
> -	if (xenbus_scanf(XBT_NIL, dev->otherend, "feature-gso-tcpv6",
> -			 "%d", &val) < 0)
> -		val = 0;
> -	if (val)
> +	if (xenbus_read_unsigned(dev->otherend, "feature-gso-tcpv6", 0))
>  		vif->gso_mask |= GSO_BIT(TCPV6);
> 
> -	if (xenbus_scanf(XBT_NIL, dev->otherend, "feature-no-csum-
> offload",
> -			 "%d", &val) < 0)
> -		val = 0;
> -	vif->ip_csum = !val;
> +	vif->ip_csum = !xenbus_read_unsigned(dev->otherend,
> +					     "feature-no-csum-offload", 0);
> 
> -	if (xenbus_scanf(XBT_NIL, dev->otherend, "feature-ipv6-csum-
> offload",
> -			 "%d", &val) < 0)
> -		val = 0;
> -	vif->ipv6_csum = !!val;
> +	vif->ipv6_csum = !!xenbus_read_unsigned(dev->otherend,
> +						"feature-ipv6-csum-offload",
> 0);
> 
>  	return 0;
>  }
> --
> 2.6.6

  reply	other threads:[~2016-11-01  9:42 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-31 16:48 [PATCH 00/12] xen: add common function for reading optional value Juergen Gross
2016-10-31 16:48 ` [PATCH 01/12] xen: introduce xenbus_read_unsigned() Juergen Gross
2016-11-07 11:02   ` [Xen-devel] " David Vrabel
2016-10-31 16:48 ` [PATCH 02/12] xen: make use of xenbus_read_unsigned() in xen-blkback Juergen Gross
2016-10-31 16:48 ` [PATCH 03/12] xen: make use of xenbus_read_unsigned() in xen-blkfront Juergen Gross
2016-10-31 16:48 ` [PATCH 04/12] xen: make use of xenbus_read_unsigned() in xen-tpmfront Juergen Gross
2016-11-02 10:34   ` Jarkko Sakkinen
2016-11-04  4:26   ` Jarkko Sakkinen
2016-10-31 16:48 ` [PATCH 05/12] xen: make use of xenbus_read_unsigned() in xen-kbdfront Juergen Gross
2016-11-09  0:29   ` Dmitry Torokhov
2016-10-31 16:48 ` [PATCH 06/12] xen: make use of xenbus_read_unsigned() in xen-netback Juergen Gross
2016-11-01  9:42   ` Paul Durrant [this message]
2016-10-31 16:48 ` [PATCH 07/12] xen: make use of xenbus_read_unsigned() in xen-netfront Juergen Gross
2016-10-31 16:48 ` [PATCH 08/12] xen: make use of xenbus_read_unsigned() in xen-pcifront Juergen Gross
2016-10-31 18:18   ` Bjorn Helgaas
2016-10-31 16:48 ` [PATCH 09/12] xen: make use of xenbus_read_unsigned() in xen-scsifront Juergen Gross
2016-10-31 16:48 ` [PATCH 10/12] xen: make use of xenbus_read_unsigned() in xen-fbfront Juergen Gross
2016-10-31 16:48 ` [PATCH 11/12] xen: make use of xenbus_read_unsigned() in xen-pciback Juergen Gross
2016-10-31 16:48 ` [PATCH 12/12] xen: make use of xenbus_read_unsigned() in xenbus Juergen Gross
2016-10-31 17:08 ` [PATCH 00/12] xen: add common function for reading optional value David Miller
2016-11-01  4:33   ` Juergen Gross
2016-11-07 11:08 ` David Vrabel
2016-11-07 16:20   ` Jarkko Sakkinen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4f93ec8497514ec891f90cb2b540b0b9@AMSPEX02CL03.citrite.net \
    --to=paul.durrant@citrix.com \
    --cc=boris.ostrovsky@oracle.com \
    --cc=david.vrabel@citrix.com \
    --cc=jgross@suse.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).