From: Haggai Eran <haggaie-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
To: Yuval Shaia <yuval.shaia-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>,
linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH] IB/ipoib: Expose ioctl command to retrieve SGID of a given socket
Date: Thu, 31 Dec 2015 17:34:03 +0200 [thread overview]
Message-ID: <56854AEB.50802@mellanox.com> (raw)
In-Reply-To: <1451572875-24961-1-git-send-email-yuval.shaia-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
On 31/12/2015 16:41, Yuval Shaia wrote:
> To support security applications, that need to filter out connections based
> on SGID, an ioctl command to retrieve SGID of a given socket is added.
Could you elaborate on the security applications? How do you see this ioctl
being used?
> diff --git a/drivers/infiniband/ulp/ipoib/ipoib_ioctl.c b/drivers/infiniband/ulp/ipoib/ipoib_ioctl.c
> new file mode 100644
> index 0000000..124d545
> --- /dev/null
> +++ b/drivers/infiniband/ulp/ipoib/ipoib_ioctl.c
> +static int ipoib_get_sguid(struct net_device *dev, int fd, u64 *sgid,
> + u64 *subnet_prefix)
A GID is composed of a GUID and a subnet prefix.
> +{
> + struct socket *sock;
> + struct inet_sock *inetsock;
> + struct neighbour *neigh;
> + int rc = 0;
> + union ib_gid *gid;
> + struct list_head *dev_list = 0;
> + struct ipoib_dev_priv *priv = netdev_priv(dev);
> + u16 pkey_index = priv->pkey_index;
> + struct ipoib_dev_priv *child_priv;
> +
> + sock = sockfd_lookup(fd, &rc);
> + if (IS_ERR_OR_NULL(sock))
> + return -EINVAL;
> +
> + inetsock = inet_sk(sock->sk);
> +
> + neigh = neigh_lookup(&arp_tbl, &inetsock->inet_daddr, dev);
Also, isn't inet_daddr the destination address? But the function claims
to return the SGID. I guess these can be ambiguous but still it seems
confusing.
> + if (!IS_ERR_OR_NULL(neigh))
> + goto found;
> +
> + /* If not found try in all other ipoib devices */
> + dev_list = ipoib_get_dev_list(priv->ca);
> + if (!dev_list)
> + return -EINVAL;
> +
> + list_for_each_entry(priv, dev_list, list) {
This list can contain devices that belong to a different namespace. It
doesn't make sense to do a neighbor lookup on these. Also, you can simply use
neigh_lookup_nodev if you don't care about the device.
> + if (priv->pkey_index == pkey_index) {
> + neigh = neigh_lookup(&arp_tbl, &inetsock->inet_daddr,
> + priv->dev);
> + if (!IS_ERR_OR_NULL(neigh))
> + goto found;
> + }
> + list_for_each_entry(child_priv, &priv->child_intfs, list) {
> + if (child_priv->pkey_index == pkey_index) {
> + neigh = neigh_lookup(&arp_tbl,
> + &inetsock->inet_daddr,
> + child_priv->dev);
> + if (!IS_ERR_OR_NULL(neigh))
> + goto found;
> + }
> + }
> + }
> +
> + return -ENODEV;
> +
> +found:
> + if (!(neigh->nud_state & NUD_VALID))
> + return -EINVAL;
> +
> + gid = (union ib_gid *)(neigh->ha + 4);
If you just take the GID from the hardware address why not do that from userspace?
Why do you need a new ioctl to do that for you?
> + *sgid = be64_to_cpu(gid->global.interface_id);
> + *subnet_prefix = be64_to_cpu(gid->global.subnet_prefix);
> +
> + neigh_release(neigh);
> +
> + return 0;
> +}
Regards,
Haggai
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2015-12-31 15:34 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-31 14:41 [PATCH] IB/ipoib: Expose ioctl command to retrieve SGID of a given socket Yuval Shaia
[not found] ` <1451572875-24961-1-git-send-email-yuval.shaia-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2015-12-31 15:31 ` Or Gerlitz
[not found] ` <56854A60.6040202-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2016-01-03 7:53 ` Yuval Shaia
2015-12-31 15:34 ` Haggai Eran [this message]
[not found] ` <56854AEB.50802-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2016-01-03 7:52 ` Yuval Shaia
2016-01-06 11:03 ` Yuval Shaia
2016-01-06 12:25 ` Haggai Eran
[not found] ` <568D07D0.8080404-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2016-01-06 13:10 ` Yuval Shaia
2016-01-19 21:06 ` 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=56854AEB.50802@mellanox.com \
--to=haggaie-vpraknaxozvwk0htik3j/w@public.gmane.org \
--cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=yuval.shaia-QHcLZuEGTsvQT0dZR+AlfA@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.