From: "Rémi Denis-Courmont" <remi.denis-courmont@nokia.com>
To: ext Hemant Vilas RAMDASI <hemant.ramdasi@stericsson.com>
Cc: netdev@vger.kernel.org,
Dinesh Kumar Sharma <dinesh.sharma@stericsson.com>
Subject: Re: [PATCH] Phonet: set the pipe handle using setsockopt
Date: Wed, 09 Nov 2011 17:00:48 +0200 [thread overview]
Message-ID: <6033284.KrP4yu8ukf@hector> (raw)
In-Reply-To: <1320837653-7471-1-git-send-email-hemant.ramdasi@stericsson.com>
Inline...
Le Mercredi 9 Novembre 2011 16:50:53 ext Hemant Vilas RAMDASI a écrit :
> @@ -863,9 +902,27 @@ static int pep_sock_connect(struct sock *sk, struct
> sockaddr *addr, int len) int err;
> u8 data[4] = { 0 /* sub-blocks */, PAD, PAD, PAD };
>
> - pn->pipe_handle = 1; /* anything but INVALID_HANDLE */
> + if (pn->pipe_handle == PN_PIPE_INVALID_HANDLE)
> + pn->pipe_handle = 1; /* anything but INVALID_HANDLE */
> +
> err = pipe_handler_request(sk, PNS_PEP_CONNECT_REQ,
> - PN_PIPE_ENABLE, data, 4);
> + pn->init_enable, data, 4);
> +
> + if (err) {
> + pn->pipe_handle = PN_PIPE_INVALID_HANDLE;
This undoes the setsockopt() silently. I'm not sure you intend this?
> + return err;
> + }
> + sk->sk_state = TCP_SYN_SENT;
> + return 0;
> +}
> +
> +static int pep_sock_enable(struct sock *sk, struct sockaddr *addr, int len)
> +{
> + struct pep_sock *pn = pep_sk(sk);
> + int err;
> +
> + err = pipe_handler_request(sk, PNS_PEP_ENABLE_REQ, PAD,
> + NULL, 0);
> if (err) {
> pn->pipe_handle = PN_PIPE_INVALID_HANDLE;
> return err;
> @@ -959,6 +1016,24 @@ static int pep_setsockopt(struct sock *sk, int level,
> int optname, }
> goto out_norel;
>
> + case PNPIPE_HANDLE:
> + if (val)
> + pn->pipe_handle = val;
> + else
> + err = -EINVAL;
> + break;
Why is zero a special case? What about out-of-range values?
> +
> + case PNPIPE_ENABLE:
> + err = pep_sock_enable(sk, NULL, 0);
> + break;
This is reintroducing the problems with the older code. As far as I know,
setsockopt() needs to be idempotent, which this does not seem to be?
> +
> + case PNPIPE_INITSTATE:
> + if ((val == PN_PIPE_DISABLE) || (val == PN_PIPE_ENABLE))
> + pn->init_enable = val;
> + else
> + err = -EINVAL;
> + break;
It looks like there is no use-case for init-enabled pipes then, right? How
about dropping this extra bit of code and assuming connect()ed pipes are
always init-disabled?
> +
> default:
> err = -ENOPROTOOPT;
> }
> @@ -994,6 +1069,13 @@ static int pep_getsockopt(struct sock *sk, int level,
> int optname, return -EINVAL;
> break;
>
> + case PNPIPE_ENABLE:
> + if (sk->sk_state != TCP_ESTABLISHED)
> + return -EINVAL;
> + else
> + val = 1;
> + break;
> +
> default:
> return -ENOPROTOOPT;
> }
--
Rémi Denis-Courmont
http://www.remlab.net/
next prev parent reply other threads:[~2011-11-09 15:00 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-09 11:20 [PATCH] Phonet: set the pipe handle using setsockopt Hemant Vilas RAMDASI
2011-11-09 15:00 ` Rémi Denis-Courmont [this message]
2011-11-10 9:44 ` Hemant-vilas RAMDASI
-- strict thread matches above, loose matches on Subject: below --
2011-11-14 7:53 Hemant Vilas RAMDASI
2011-11-14 9:29 ` Rémi Denis-Courmont
2011-11-14 10:36 ` Hemant-vilas RAMDASI
2011-11-16 6:30 ` Rémi Denis-Courmont
2011-11-16 8:46 ` Hemant-vilas RAMDASI
2011-11-16 10:15 ` Rémi Denis-Courmont
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=6033284.KrP4yu8ukf@hector \
--to=remi.denis-courmont@nokia.com \
--cc=dinesh.sharma@stericsson.com \
--cc=hemant.ramdasi@stericsson.com \
--cc=netdev@vger.kernel.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.