netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marcel Holtmann <marcel@holtmann.org>
To: sjur.brandeland@stericsson.com
Cc: davem@davemloft.net, netdev@vger.kernel.org,
	stefano.babic@babic.homelinux.org, randy.dunlap@oracle.com,
	daniel.martensson@stericsson.com, kaber@trash.net
Subject: Re: [PATCH net-next-2.6 v2 08/12] net-caif: add CAIF socket implementation
Date: Tue, 16 Feb 2010 07:57:56 -0800	[thread overview]
Message-ID: <1266335876.8849.11.camel@localhost.localdomain> (raw)
In-Reply-To: <1266328017-28406-9-git-send-email-sjur.brandeland@stericsson.com>

Hi Sjur,

> +static int setsockopt(struct socket *sock,
> +			int lvl, int opt, char __user *ov, unsigned int ol)
> +{
> +	struct sock *sk = sock->sk;
> +	struct caifsock *cf_sk = container_of(sk, struct caifsock, sk);
> +	int prio, linksel;
> +	struct ifreq ifreq;
> +	struct caif_param caif_param;
> +	if (lvl != SOL_CAIF) {
> +		pr_debug("CAIF: %s(): setsockopt bad level\n", __func__);
> +		return -ENOPROTOOPT;
> +	}
> +	if (STATE_IS_OPEN(cf_sk)) {
> +		pr_debug("CAIF: %s(): setsockopt "
> +			 "cannot be done on a connected socket\n",
> +			 __func__);
> +		return -ENOPROTOOPT;
> +	}
> +	switch (opt) {
> +	case CAIFSO_LINK_SELECT:
> +		if (ol < sizeof(int)) {
> +			pr_debug("CAIF: %s(): setsockopt"
> +				 " CAIFSO_CHANNEL_CONFIG bad size\n", __func__);
> +			return -EINVAL;
> +		}
> +		if (copy_from_user(&linksel, ov, sizeof(int)))
> +			return -EINVAL;
> +		lock_sock(&(cf_sk->sk));
> +		cf_sk->config.phy_pref = linksel;
> +		pr_debug("CAIF: %s(): Setting sockopt pref=%dn", __func__,
> +			cf_sk->config.phy_pref);
> +		release_sock(&cf_sk->sk);
> +		return 0;
> +
> +	case SO_PRIORITY:
> +		if (ol < sizeof(int)) {
> +			pr_debug("CAIF: %s(): setsockopt"
> +				 " SO_PRIORITY bad size\n", __func__);
> +			return -EINVAL;
> +		}
> +		if (copy_from_user(&prio, ov, sizeof(int)))
> +			return -EINVAL;
> +		lock_sock(&(cf_sk->sk));
> +		cf_sk->config.phy_pref = prio;
> +		pr_debug("CAIF: %s(): Setting sockopt pref=%dn", __func__,
> +			cf_sk->config.phy_pref);
> +		release_sock(&cf_sk->sk);
> +		return 0;
> +
> +	case SO_BINDTODEVICE:
> +		if (ol < sizeof(struct ifreq)) {
> +			pr_debug("CAIF: %s(): setsockopt"
> +				 " SO_PRIORITY bad size\n", __func__);
> +			return -EINVAL;
> +		}
> +		if (copy_from_user(&ifreq, ov, sizeof(ifreq)))
> +			return -EFAULT;
> +		lock_sock(&(cf_sk->sk));
> +		strncpy(cf_sk->config.phy_name, ifreq.ifr_name,
> +			sizeof(cf_sk->config.phy_name));
> +		cf_sk->config.phy_name[sizeof(cf_sk->config.phy_name)-1] = 0;
> +
> +		release_sock(&cf_sk->sk);
> +		return 0;

I would have implemented SO_PRIORITY and SO_BINDTODEVICE on SOL_SOCKET
level. Having them on SOL_CAIF level is not really useful.

Regards

Marcel



  parent reply	other threads:[~2010-02-16 15:59 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-16 13:46 [PATCH net-next-2.6 v2 00/12] net-caif: introducing CAIF protocol stack sjur.brandeland
2010-02-16 13:46 ` [PATCH net-next-2.6 v2 01/12] net-caif: add CAIF protocol definitions sjur.brandeland
2010-02-16 13:46   ` [PATCH net-next-2.6 v2 02/12] net-caif: add CAIF socket and configuration headers sjur.brandeland
2010-02-16 13:46     ` [PATCH net-next-2.6 v2 03/12] net-caif: add CAIF core protocol stack header files sjur.brandeland
2010-02-16 13:46       ` [PATCH net-next-2.6 v2 04/12] net-caif: add CAIF Link layer device " sjur.brandeland
2010-02-16 13:46         ` [PATCH net-next-2.6 v2 05/12] net-caif: add CAIF core protocol stack sjur.brandeland
2010-02-16 13:46           ` [PATCH net-next-2.6 v2 06/12] net-caif: add CAIF generic caif support functions sjur.brandeland
2010-02-16 13:46             ` [PATCH net-next-2.6 v2 07/12] net-caif: add CAIF device registration functionality sjur.brandeland
2010-02-16 13:46               ` [PATCH net-next-2.6 v2 08/12] net-caif: add CAIF socket implementation sjur.brandeland
2010-02-16 13:46                 ` [PATCH net-next-2.6 v2 09/12] net-caif: add CAIF netdevice sjur.brandeland
2010-02-16 13:46                   ` [PATCH net-next-2.6 v2 10/12] net-caif: add CAIF Kconfig and Makefiles sjur.brandeland
2010-02-16 13:46                     ` [PATCH net-next-2.6 v2 11/12] net-caif: add CAIF documentation sjur.brandeland
2010-02-16 13:46                       ` [PATCH net-next-2.6 v2 12/12] net-caif-driver: add CAIF serial driver (ldisc) sjur.brandeland
2010-02-16 15:57                 ` Marcel Holtmann [this message]
2010-02-16 23:40     ` [PATCH net-next-2.6 v2 02/12] net-caif: add CAIF socket and configuration headers David Miller

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=1266335876.8849.11.camel@localhost.localdomain \
    --to=marcel@holtmann.org \
    --cc=daniel.martensson@stericsson.com \
    --cc=davem@davemloft.net \
    --cc=kaber@trash.net \
    --cc=netdev@vger.kernel.org \
    --cc=randy.dunlap@oracle.com \
    --cc=sjur.brandeland@stericsson.com \
    --cc=stefano.babic@babic.homelinux.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).