Commit acaf7df610ff3faf1778ce40d601fc3dd4a41b40
Committed by
David S. Miller
1 parent
f7ae8d59f6
Exists in
master
and in
4 other branches
Phonet: provide pipe socket option to retrieve the pipe identifier
User-space sometimes needs this information. In particular, the GPRS context or the AT commands pipe setups may use the pipe handle as a reference. This removes the settable pipe handle with CONFIG_PHONET_PIPECTRLR. It did not handle error cases correctly. Furthermore, the kernel *could* implement a smart scheme for allocating handles (if ever needed), but userspace really cannot. Signed-off-by: Rémi Denis-Courmont <remi.denis-courmont@nokia.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Showing 3 changed files with 12 additions and 12 deletions Side-by-side Diff
Documentation/networking/phonet.txt
... | ... | @@ -181,7 +181,11 @@ |
181 | 181 | interface index of the network interface created by PNPIPE_ENCAP, |
182 | 182 | or zero if encapsulation is off. |
183 | 183 | |
184 | + PNPIPE_HANDLE is a read-only integer value. It contains the underlying | |
185 | + identifier ("pipe handle") of the pipe. This is only defined for | |
186 | + socket descriptors that are already connected or being connected. | |
184 | 187 | |
188 | + | |
185 | 189 | Phonet Pipe-controller Implementation |
186 | 190 | ------------------------------------- |
187 | 191 | |
... | ... | @@ -198,9 +202,6 @@ |
198 | 202 | between itself and a remote pipe-end point (e.g. modem). |
199 | 203 | |
200 | 204 | The implementation adds socket options at SOL_PNPIPE level: |
201 | - | |
202 | - PNPIPE_PIPE_HANDLE | |
203 | - It accepts an integer argument for setting value of pipe handle. | |
204 | 205 | |
205 | 206 | PNPIPE_ENABLE accepts one integer value (int). If set to zero, the pipe |
206 | 207 | is disabled. If the value is non-zero, the pipe is enabled. If the pipe |
include/linux/phonet.h
net/phonet/pep.c
... | ... | @@ -853,6 +853,7 @@ |
853 | 853 | |
854 | 854 | pn->pn_sk.dobject = pn_sockaddr_get_object(spn); |
855 | 855 | pn->pn_sk.resource = pn_sockaddr_get_resource(spn); |
856 | + pn->pipe_handle = 1; /* anything but INVALID_HANDLE */ | |
856 | 857 | return pipe_handler_request(sk, PNS_PEP_CONNECT_REQ, |
857 | 858 | PN_PIPE_DISABLE, data, 4); |
858 | 859 | } |
... | ... | @@ -909,14 +910,6 @@ |
909 | 910 | |
910 | 911 | lock_sock(sk); |
911 | 912 | switch (optname) { |
912 | -#ifdef CONFIG_PHONET_PIPECTRLR | |
913 | - case PNPIPE_PIPE_HANDLE: | |
914 | - if (val) { | |
915 | - pn->pipe_handle = val; | |
916 | - break; | |
917 | - } | |
918 | -#endif | |
919 | - | |
920 | 913 | case PNPIPE_ENCAP: |
921 | 914 | if (val && val != PNPIPE_ENCAP_IP) { |
922 | 915 | err = -EINVAL; |
... | ... | @@ -980,6 +973,12 @@ |
980 | 973 | |
981 | 974 | case PNPIPE_IFINDEX: |
982 | 975 | val = pn->ifindex; |
976 | + break; | |
977 | + | |
978 | + case PNPIPE_HANDLE: | |
979 | + val = pn->pipe_handle; | |
980 | + if (val == PN_PIPE_INVALID_HANDLE) | |
981 | + return -EINVAL; | |
983 | 982 | break; |
984 | 983 | |
985 | 984 | #ifdef CONFIG_PHONET_PIPECTRLR |