public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
From: Leon Romanovsky <leon-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
To: "Hefty, Sean" <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Cc: Doug Ledford <dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
	"linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	Noa Osherovich <noaos-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
Subject: Re: [PATCH rdma-next 1/3] IB/core: Fix the validations of a multicast LID in attach or detach operations
Date: Tue, 13 Jun 2017 09:29:03 +0300	[thread overview]
Message-ID: <20170613062903.GG2576@mtr-leonro.local> (raw)
In-Reply-To: <1828884A29C6694DAF28B7E6B8A82373AB142896-P5GAC/sN6hkd3b2yrw5b5LfspsVTdybXVpNB7YpNyf8@public.gmane.org>

[-- Attachment #1: Type: text/plain, Size: 2753 bytes --]

On Mon, Jun 12, 2017 at 04:15:11PM +0000, Hefty, Sean wrote:
> > +static bool is_valid_mcast_lid(struct ib_qp *qp, u16 lid)
> > +{
> > +	struct ib_qp_init_attr init_attr = {};
> > +	struct ib_qp_attr attr = {};
> > +	int num_eth_ports = 0;
> > +	int port;
> > +
> > +	/* If QP state >= init, it is assigned to a port and we can
> > check this
> > +	 * port only.
> > +	 */
> > +	if (!ib_query_qp(qp, &attr, IB_QP_STATE | IB_QP_PORT,
> > &init_attr)) {
> > +		if (attr.qp_state >= IB_QPS_INIT) {
> > +			if (qp->device->get_link_layer(qp->device,
> > attr.port_num) !=
> > +			    IB_LINK_LAYER_INFINIBAND)
> > +				return true;
> > +			goto lid_check;
> > +		}
> > +	}
> > +
> > +	/* Can't get a quick answer, iterate over all ports */
> > +	for (port = 0; port < qp->device->phys_port_cnt; port++)
> > +		if (qp->device->get_link_layer(qp->device, port) !=
> > +		    IB_LINK_LAYER_INFINIBAND)
> > +			num_eth_ports++;
> > +
> > +	/* If we have at lease one Ethernet port, RoCE annex declares
> > that
> > +	 * multicast LID should be ignored. We can't tell at this step
> > if the
> > +	 * QP belongs to an IB or Ethernet port.
> > +	 */
> > +	if (num_eth_ports)
> > +		return true;
>
> Reporting that a lid *might* be valid is a really weak check.  Can we require that RoCE QPs be in the INIT state prior to joining, or use the mgid, or something to make the validation check work?  Do we even know if the qp is a roce qp?

It would be possible if ah existed (ib_qp_attr->rdma_ah_attr->rdma_ah_attr_type), but it isn't filled for IB_QPT_UD in mlx5.

>
>
> > +
> > +	/* If all the ports are IB, we can check according to IB spec.
> > */
> > +lid_check:
> > +	return !(lid < be16_to_cpu(IB_MULTICAST_LID_BASE) ||
> > +		 lid == be16_to_cpu(IB_LID_PERMISSIVE));
> > +}
> > +
> >  int ib_attach_mcast(struct ib_qp *qp, union ib_gid *gid, u16 lid)
> >  {
> >  	int ret;
> > @@ -1526,8 +1564,7 @@ int ib_attach_mcast(struct ib_qp *qp, union
> > ib_gid *gid, u16 lid)
> >  	if (!qp->device->attach_mcast)
> >  		return -ENOSYS;
> >  	if (gid->raw[0] != 0xff || qp->qp_type != IB_QPT_UD ||
> > -	    lid < be16_to_cpu(IB_MULTICAST_LID_BASE) ||
> > -	    lid == be16_to_cpu(IB_LID_PERMISSIVE))
> > +	    !is_valid_mcast_lid(qp, lid))
> >  		return -EINVAL;
> >
> >  	ret = qp->device->attach_mcast(qp, gid, lid);
> > @@ -1544,8 +1581,7 @@ int ib_detach_mcast(struct ib_qp *qp, union
> > ib_gid *gid, u16 lid)
> >  	if (!qp->device->detach_mcast)
> >  		return -ENOSYS;
> >  	if (gid->raw[0] != 0xff || qp->qp_type != IB_QPT_UD ||
> > -	    lid < be16_to_cpu(IB_MULTICAST_LID_BASE) ||
> > -	    lid == be16_to_cpu(IB_LID_PERMISSIVE))
> > +	    !is_valid_mcast_lid(qp, lid))
> >  		return -EINVAL;
> >
> >  	ret = qp->device->detach_mcast(qp, gid, lid);
> > --

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  parent reply	other threads:[~2017-06-13  6:29 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-12  8:14 [PATCH rdma-next 0/3] Add support for multicast in RoCEv2 Leon Romanovsky
     [not found] ` <20170612081404.17553-1-leon-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2017-06-12  8:14   ` [PATCH rdma-next 1/3] IB/core: Fix the validations of a multicast LID in attach or detach operations Leon Romanovsky
     [not found]     ` <20170612081404.17553-2-leon-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2017-06-12 16:15       ` Hefty, Sean
     [not found]         ` <1828884A29C6694DAF28B7E6B8A82373AB142896-P5GAC/sN6hkd3b2yrw5b5LfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2017-06-13  6:29           ` Leon Romanovsky [this message]
2017-06-13  7:44           ` Moni Shoua
2017-06-12  8:14   ` [PATCH rdma-next 2/3] IB/core: Set RoCEv2 MGID according to spec Leon Romanovsky
2017-06-12  8:14   ` [PATCH rdma-next 3/3] IB/core: Add support for RoCEv2 multicast Leon Romanovsky
2017-07-28 18:21   ` [PATCH rdma-next 0/3] Add support for multicast in RoCEv2 Doug Ledford

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=20170613062903.GG2576@mtr-leonro.local \
    --to=leon-dgejt+ai2ygdnm+yrofe0a@public.gmane.org \
    --cc=dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=noaos-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org \
    --cc=sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.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