1 /* net/atm/common.c - ATM sockets (common part for PVC and SVC) */
3 /* Written 1995-2000 by Werner Almesberger, EPFL LRC/ICA */
5 #define pr_fmt(fmt) KBUILD_MODNAME ":%s: " fmt, __func__
7 #include <linux/module.h>
8 #include <linux/kmod.h>
9 #include <linux/net.h> /* struct socket, struct proto_ops */
10 #include <linux/atm.h> /* ATM stuff */
11 #include <linux/atmdev.h>
12 #include <linux/socket.h> /* SOL_SOCKET */
13 #include <linux/errno.h> /* error codes */
14 #include <linux/capability.h>
16 #include <linux/sched.h>
17 #include <linux/time.h> /* struct timeval */
18 #include <linux/skbuff.h>
19 #include <linux/bitops.h>
20 #include <linux/init.h>
21 #include <linux/slab.h>
22 #include <net/sock.h> /* struct sock */
23 #include <linux/uaccess.h>
24 #include <linux/poll.h>
26 #include <asm/atomic.h>
28 #include "resources.h" /* atm_find_dev */
29 #include "common.h" /* prototypes */
30 #include "protocols.h" /* atm_init_<transport> */
31 #include "addr.h" /* address registry */
32 #include "signaling.h" /* for WAITING and sigd_attach */
34 struct hlist_head vcc_hash
[VCC_HTABLE_SIZE
];
35 EXPORT_SYMBOL(vcc_hash
);
37 DEFINE_RWLOCK(vcc_sklist_lock
);
38 EXPORT_SYMBOL(vcc_sklist_lock
);
40 static void __vcc_insert_socket(struct sock
*sk
)
42 struct atm_vcc
*vcc
= atm_sk(sk
);
43 struct hlist_head
*head
= &vcc_hash
[vcc
->vci
& (VCC_HTABLE_SIZE
- 1)];
44 sk
->sk_hash
= vcc
->vci
& (VCC_HTABLE_SIZE
- 1);
45 sk_add_node(sk
, head
);
48 void vcc_insert_socket(struct sock
*sk
)
50 write_lock_irq(&vcc_sklist_lock
);
51 __vcc_insert_socket(sk
);
52 write_unlock_irq(&vcc_sklist_lock
);
54 EXPORT_SYMBOL(vcc_insert_socket
);
56 static void vcc_remove_socket(struct sock
*sk
)
58 write_lock_irq(&vcc_sklist_lock
);
60 write_unlock_irq(&vcc_sklist_lock
);
63 static struct sk_buff
*alloc_tx(struct atm_vcc
*vcc
, unsigned int size
)
66 struct sock
*sk
= sk_atm(vcc
);
68 if (sk_wmem_alloc_get(sk
) && !atm_may_send(vcc
, size
)) {
69 pr_debug("Sorry: wmem_alloc = %d, size = %d, sndbuf = %d\n",
70 sk_wmem_alloc_get(sk
), size
, sk
->sk_sndbuf
);
73 while (!(skb
= alloc_skb(size
, GFP_KERNEL
)))
75 pr_debug("%d += %d\n", sk_wmem_alloc_get(sk
), skb
->truesize
);
76 atomic_add(skb
->truesize
, &sk
->sk_wmem_alloc
);
80 static void vcc_sock_destruct(struct sock
*sk
)
82 if (atomic_read(&sk
->sk_rmem_alloc
))
83 printk(KERN_DEBUG
"%s: rmem leakage (%d bytes) detected.\n",
84 __func__
, atomic_read(&sk
->sk_rmem_alloc
));
86 if (atomic_read(&sk
->sk_wmem_alloc
))
87 printk(KERN_DEBUG
"%s: wmem leakage (%d bytes) detected.\n",
88 __func__
, atomic_read(&sk
->sk_wmem_alloc
));
91 static void vcc_def_wakeup(struct sock
*sk
)
93 read_lock(&sk
->sk_callback_lock
);
94 if (sk_has_sleeper(sk
))
95 wake_up(sk
->sk_sleep
);
96 read_unlock(&sk
->sk_callback_lock
);
99 static inline int vcc_writable(struct sock
*sk
)
101 struct atm_vcc
*vcc
= atm_sk(sk
);
103 return (vcc
->qos
.txtp
.max_sdu
+
104 atomic_read(&sk
->sk_wmem_alloc
)) <= sk
->sk_sndbuf
;
107 static void vcc_write_space(struct sock
*sk
)
109 read_lock(&sk
->sk_callback_lock
);
111 if (vcc_writable(sk
)) {
112 if (sk_has_sleeper(sk
))
113 wake_up_interruptible(sk
->sk_sleep
);
115 sk_wake_async(sk
, SOCK_WAKE_SPACE
, POLL_OUT
);
118 read_unlock(&sk
->sk_callback_lock
);
121 static struct proto vcc_proto
= {
123 .owner
= THIS_MODULE
,
124 .obj_size
= sizeof(struct atm_vcc
),
127 int vcc_create(struct net
*net
, struct socket
*sock
, int protocol
, int family
)
133 if (sock
->type
== SOCK_STREAM
)
135 sk
= sk_alloc(net
, family
, GFP_KERNEL
, &vcc_proto
);
138 sock_init_data(sock
, sk
);
139 sk
->sk_state_change
= vcc_def_wakeup
;
140 sk
->sk_write_space
= vcc_write_space
;
144 memset(&vcc
->local
, 0, sizeof(struct sockaddr_atmsvc
));
145 memset(&vcc
->remote
, 0, sizeof(struct sockaddr_atmsvc
));
146 vcc
->qos
.txtp
.max_sdu
= 1 << 16; /* for meta VCs */
147 atomic_set(&sk
->sk_wmem_alloc
, 1);
148 atomic_set(&sk
->sk_rmem_alloc
, 0);
151 vcc
->push_oam
= NULL
;
152 vcc
->vpi
= vcc
->vci
= 0; /* no VCI/VPI yet */
153 vcc
->atm_options
= vcc
->aal_options
= 0;
154 sk
->sk_destruct
= vcc_sock_destruct
;
158 static void vcc_destroy_socket(struct sock
*sk
)
160 struct atm_vcc
*vcc
= atm_sk(sk
);
163 set_bit(ATM_VF_CLOSE
, &vcc
->flags
);
164 clear_bit(ATM_VF_READY
, &vcc
->flags
);
166 if (vcc
->dev
->ops
->close
)
167 vcc
->dev
->ops
->close(vcc
);
169 vcc
->push(vcc
, NULL
); /* atmarpd has no push */
171 while ((skb
= skb_dequeue(&sk
->sk_receive_queue
)) != NULL
) {
172 atm_return(vcc
, skb
->truesize
);
176 module_put(vcc
->dev
->ops
->owner
);
177 atm_dev_put(vcc
->dev
);
180 vcc_remove_socket(sk
);
183 int vcc_release(struct socket
*sock
)
185 struct sock
*sk
= sock
->sk
;
189 vcc_destroy_socket(sock
->sk
);
197 void vcc_release_async(struct atm_vcc
*vcc
, int reply
)
199 struct sock
*sk
= sk_atm(vcc
);
201 set_bit(ATM_VF_CLOSE
, &vcc
->flags
);
202 sk
->sk_shutdown
|= RCV_SHUTDOWN
;
204 clear_bit(ATM_VF_WAITING
, &vcc
->flags
);
205 sk
->sk_state_change(sk
);
207 EXPORT_SYMBOL(vcc_release_async
);
210 void atm_dev_release_vccs(struct atm_dev
*dev
)
214 write_lock_irq(&vcc_sklist_lock
);
215 for (i
= 0; i
< VCC_HTABLE_SIZE
; i
++) {
216 struct hlist_head
*head
= &vcc_hash
[i
];
217 struct hlist_node
*node
, *tmp
;
221 sk_for_each_safe(s
, node
, tmp
, head
) {
223 if (vcc
->dev
== dev
) {
224 vcc_release_async(vcc
, -EPIPE
);
229 write_unlock_irq(&vcc_sklist_lock
);
232 static int adjust_tp(struct atm_trafprm
*tp
, unsigned char aal
)
236 if (!tp
->traffic_class
)
240 max_sdu
= ATM_CELL_SIZE
-1;
243 max_sdu
= ATM_MAX_AAL34_PDU
;
246 pr_warning("AAL problems ... (%d)\n", aal
);
249 max_sdu
= ATM_MAX_AAL5_PDU
;
252 tp
->max_sdu
= max_sdu
;
253 else if (tp
->max_sdu
> max_sdu
)
256 tp
->max_cdv
= ATM_MAX_CDV
;
260 static int check_ci(const struct atm_vcc
*vcc
, short vpi
, int vci
)
262 struct hlist_head
*head
= &vcc_hash
[vci
& (VCC_HTABLE_SIZE
- 1)];
263 struct hlist_node
*node
;
265 struct atm_vcc
*walk
;
267 sk_for_each(s
, node
, head
) {
269 if (walk
->dev
!= vcc
->dev
)
271 if (test_bit(ATM_VF_ADDR
, &walk
->flags
) && walk
->vpi
== vpi
&&
272 walk
->vci
== vci
&& ((walk
->qos
.txtp
.traffic_class
!=
273 ATM_NONE
&& vcc
->qos
.txtp
.traffic_class
!= ATM_NONE
) ||
274 (walk
->qos
.rxtp
.traffic_class
!= ATM_NONE
&&
275 vcc
->qos
.rxtp
.traffic_class
!= ATM_NONE
)))
279 /* allow VCCs with same VPI/VCI iff they don't collide on
280 TX/RX (but we may refuse such sharing for other reasons,
281 e.g. if protocol requires to have both channels) */
286 static int find_ci(const struct atm_vcc
*vcc
, short *vpi
, int *vci
)
288 static short p
; /* poor man's per-device cache */
294 if (*vpi
!= ATM_VPI_ANY
&& *vci
!= ATM_VCI_ANY
) {
295 err
= check_ci(vcc
, *vpi
, *vci
);
298 /* last scan may have left values out of bounds for current device */
299 if (*vpi
!= ATM_VPI_ANY
)
301 else if (p
>= 1 << vcc
->dev
->ci_range
.vpi_bits
)
303 if (*vci
!= ATM_VCI_ANY
)
305 else if (c
< ATM_NOT_RSV_VCI
|| c
>= 1 << vcc
->dev
->ci_range
.vci_bits
)
310 if (!check_ci(vcc
, p
, c
)) {
315 if (*vci
== ATM_VCI_ANY
) {
317 if (c
>= 1 << vcc
->dev
->ci_range
.vci_bits
)
320 if ((c
== ATM_NOT_RSV_VCI
|| *vci
!= ATM_VCI_ANY
) &&
321 *vpi
== ATM_VPI_ANY
) {
323 if (p
>= 1 << vcc
->dev
->ci_range
.vpi_bits
)
326 } while (old_p
!= p
|| old_c
!= c
);
330 static int __vcc_connect(struct atm_vcc
*vcc
, struct atm_dev
*dev
, short vpi
,
333 struct sock
*sk
= sk_atm(vcc
);
336 if ((vpi
!= ATM_VPI_UNSPEC
&& vpi
!= ATM_VPI_ANY
&&
337 vpi
>> dev
->ci_range
.vpi_bits
) || (vci
!= ATM_VCI_UNSPEC
&&
338 vci
!= ATM_VCI_ANY
&& vci
>> dev
->ci_range
.vci_bits
))
340 if (vci
> 0 && vci
< ATM_NOT_RSV_VCI
&& !capable(CAP_NET_BIND_SERVICE
))
343 if (!try_module_get(dev
->ops
->owner
))
346 write_lock_irq(&vcc_sklist_lock
);
347 if (test_bit(ATM_DF_REMOVED
, &dev
->flags
) ||
348 (error
= find_ci(vcc
, &vpi
, &vci
))) {
349 write_unlock_irq(&vcc_sklist_lock
);
350 goto fail_module_put
;
354 __vcc_insert_socket(sk
);
355 write_unlock_irq(&vcc_sklist_lock
);
356 switch (vcc
->qos
.aal
) {
358 error
= atm_init_aal0(vcc
);
359 vcc
->stats
= &dev
->stats
.aal0
;
362 error
= atm_init_aal34(vcc
);
363 vcc
->stats
= &dev
->stats
.aal34
;
366 /* ATM_AAL5 is also used in the "0 for default" case */
367 vcc
->qos
.aal
= ATM_AAL5
;
370 error
= atm_init_aal5(vcc
);
371 vcc
->stats
= &dev
->stats
.aal5
;
377 error
= adjust_tp(&vcc
->qos
.txtp
, vcc
->qos
.aal
);
379 error
= adjust_tp(&vcc
->qos
.rxtp
, vcc
->qos
.aal
);
382 pr_debug("VCC %d.%d, AAL %d\n", vpi
, vci
, vcc
->qos
.aal
);
383 pr_debug(" TX: %d, PCR %d..%d, SDU %d\n",
384 vcc
->qos
.txtp
.traffic_class
,
385 vcc
->qos
.txtp
.min_pcr
,
386 vcc
->qos
.txtp
.max_pcr
,
387 vcc
->qos
.txtp
.max_sdu
);
388 pr_debug(" RX: %d, PCR %d..%d, SDU %d\n",
389 vcc
->qos
.rxtp
.traffic_class
,
390 vcc
->qos
.rxtp
.min_pcr
,
391 vcc
->qos
.rxtp
.max_pcr
,
392 vcc
->qos
.rxtp
.max_sdu
);
394 if (dev
->ops
->open
) {
395 error
= dev
->ops
->open(vcc
);
402 vcc_remove_socket(sk
);
404 module_put(dev
->ops
->owner
);
405 /* ensure we get dev module ref count correct */
410 int vcc_connect(struct socket
*sock
, int itf
, short vpi
, int vci
)
413 struct atm_vcc
*vcc
= ATM_SD(sock
);
416 pr_debug("(vpi %d, vci %d)\n", vpi
, vci
);
417 if (sock
->state
== SS_CONNECTED
)
419 if (sock
->state
!= SS_UNCONNECTED
)
424 if (vpi
!= ATM_VPI_UNSPEC
&& vci
!= ATM_VCI_UNSPEC
)
425 clear_bit(ATM_VF_PARTIAL
, &vcc
->flags
);
427 if (test_bit(ATM_VF_PARTIAL
, &vcc
->flags
))
429 pr_debug("(TX: cl %d,bw %d-%d,sdu %d; "
430 "RX: cl %d,bw %d-%d,sdu %d,AAL %s%d)\n",
431 vcc
->qos
.txtp
.traffic_class
, vcc
->qos
.txtp
.min_pcr
,
432 vcc
->qos
.txtp
.max_pcr
, vcc
->qos
.txtp
.max_sdu
,
433 vcc
->qos
.rxtp
.traffic_class
, vcc
->qos
.rxtp
.min_pcr
,
434 vcc
->qos
.rxtp
.max_pcr
, vcc
->qos
.rxtp
.max_sdu
,
435 vcc
->qos
.aal
== ATM_AAL5
? "" :
436 vcc
->qos
.aal
== ATM_AAL0
? "" : " ??? code ",
437 vcc
->qos
.aal
== ATM_AAL0
? 0 : vcc
->qos
.aal
);
438 if (!test_bit(ATM_VF_HASQOS
, &vcc
->flags
))
440 if (vcc
->qos
.txtp
.traffic_class
== ATM_ANYCLASS
||
441 vcc
->qos
.rxtp
.traffic_class
== ATM_ANYCLASS
)
443 if (likely(itf
!= ATM_ITF_ANY
)) {
444 dev
= try_then_request_module(atm_dev_lookup(itf
),
445 "atm-device-%d", itf
);
448 mutex_lock(&atm_dev_mutex
);
449 if (!list_empty(&atm_devs
)) {
450 dev
= list_entry(atm_devs
.next
,
451 struct atm_dev
, dev_list
);
454 mutex_unlock(&atm_dev_mutex
);
458 error
= __vcc_connect(vcc
, dev
, vpi
, vci
);
463 if (vpi
== ATM_VPI_UNSPEC
|| vci
== ATM_VCI_UNSPEC
)
464 set_bit(ATM_VF_PARTIAL
, &vcc
->flags
);
465 if (test_bit(ATM_VF_READY
, &ATM_SD(sock
)->flags
))
466 sock
->state
= SS_CONNECTED
;
470 int vcc_recvmsg(struct kiocb
*iocb
, struct socket
*sock
, struct msghdr
*msg
,
471 size_t size
, int flags
)
473 struct sock
*sk
= sock
->sk
;
476 int copied
, error
= -EINVAL
;
478 if (sock
->state
!= SS_CONNECTED
)
480 if (flags
& ~MSG_DONTWAIT
) /* only handle MSG_DONTWAIT */
483 if (test_bit(ATM_VF_RELEASED
, &vcc
->flags
) ||
484 test_bit(ATM_VF_CLOSE
, &vcc
->flags
) ||
485 !test_bit(ATM_VF_READY
, &vcc
->flags
))
488 skb
= skb_recv_datagram(sk
, flags
, flags
& MSG_DONTWAIT
, &error
);
495 msg
->msg_flags
|= MSG_TRUNC
;
498 error
= skb_copy_datagram_iovec(skb
, 0, msg
->msg_iov
, copied
);
501 sock_recv_ts_and_drops(msg
, sk
, skb
);
502 pr_debug("%d -= %d\n", atomic_read(&sk
->sk_rmem_alloc
), skb
->truesize
);
503 atm_return(vcc
, skb
->truesize
);
504 skb_free_datagram(sk
, skb
);
508 int vcc_sendmsg(struct kiocb
*iocb
, struct socket
*sock
, struct msghdr
*m
,
511 struct sock
*sk
= sock
->sk
;
516 const void __user
*buff
;
520 if (sock
->state
!= SS_CONNECTED
) {
528 if (m
->msg_iovlen
!= 1) {
529 error
= -ENOSYS
; /* fix this later @@@ */
532 buff
= m
->msg_iov
->iov_base
;
533 size
= m
->msg_iov
->iov_len
;
535 if (test_bit(ATM_VF_RELEASED
, &vcc
->flags
) ||
536 test_bit(ATM_VF_CLOSE
, &vcc
->flags
) ||
537 !test_bit(ATM_VF_READY
, &vcc
->flags
)) {
539 send_sig(SIGPIPE
, current
, 0);
546 if (size
< 0 || size
> vcc
->qos
.txtp
.max_sdu
) {
551 eff
= (size
+3) & ~3; /* align to word boundary */
552 prepare_to_wait(sk
->sk_sleep
, &wait
, TASK_INTERRUPTIBLE
);
554 while (!(skb
= alloc_tx(vcc
, eff
))) {
555 if (m
->msg_flags
& MSG_DONTWAIT
) {
560 if (signal_pending(current
)) {
561 error
= -ERESTARTSYS
;
564 if (test_bit(ATM_VF_RELEASED
, &vcc
->flags
) ||
565 test_bit(ATM_VF_CLOSE
, &vcc
->flags
) ||
566 !test_bit(ATM_VF_READY
, &vcc
->flags
)) {
568 send_sig(SIGPIPE
, current
, 0);
571 prepare_to_wait(sk
->sk_sleep
, &wait
, TASK_INTERRUPTIBLE
);
573 finish_wait(sk
->sk_sleep
, &wait
);
576 skb
->dev
= NULL
; /* for paths shared with net_device interfaces */
577 ATM_SKB(skb
)->atm_options
= vcc
->atm_options
;
578 if (copy_from_user(skb_put(skb
, size
), buff
, size
)) {
584 memset(skb
->data
+ size
, 0, eff
-size
);
585 error
= vcc
->dev
->ops
->send(vcc
, skb
);
586 error
= error
? error
: size
;
592 unsigned int vcc_poll(struct file
*file
, struct socket
*sock
, poll_table
*wait
)
594 struct sock
*sk
= sock
->sk
;
598 sock_poll_wait(file
, sk
->sk_sleep
, wait
);
603 /* exceptional events */
607 if (test_bit(ATM_VF_RELEASED
, &vcc
->flags
) ||
608 test_bit(ATM_VF_CLOSE
, &vcc
->flags
))
612 if (!skb_queue_empty(&sk
->sk_receive_queue
))
613 mask
|= POLLIN
| POLLRDNORM
;
616 if (sock
->state
== SS_CONNECTING
&&
617 test_bit(ATM_VF_WAITING
, &vcc
->flags
))
620 if (vcc
->qos
.txtp
.traffic_class
!= ATM_NONE
&&
622 mask
|= POLLOUT
| POLLWRNORM
| POLLWRBAND
;
627 static int atm_change_qos(struct atm_vcc
*vcc
, struct atm_qos
*qos
)
632 * Don't let the QoS change the already connected AAL type nor the
635 if (qos
->aal
!= vcc
->qos
.aal
||
636 qos
->rxtp
.traffic_class
!= vcc
->qos
.rxtp
.traffic_class
||
637 qos
->txtp
.traffic_class
!= vcc
->qos
.txtp
.traffic_class
)
639 error
= adjust_tp(&qos
->txtp
, qos
->aal
);
641 error
= adjust_tp(&qos
->rxtp
, qos
->aal
);
644 if (!vcc
->dev
->ops
->change_qos
)
646 if (sk_atm(vcc
)->sk_family
== AF_ATMPVC
)
647 return vcc
->dev
->ops
->change_qos(vcc
, qos
, ATM_MF_SET
);
648 return svc_change_qos(vcc
, qos
);
651 static int check_tp(const struct atm_trafprm
*tp
)
653 /* @@@ Should be merged with adjust_tp */
654 if (!tp
->traffic_class
|| tp
->traffic_class
== ATM_ANYCLASS
)
656 if (tp
->traffic_class
!= ATM_UBR
&& !tp
->min_pcr
&& !tp
->pcr
&&
659 if (tp
->min_pcr
== ATM_MAX_PCR
)
661 if (tp
->min_pcr
&& tp
->max_pcr
&& tp
->max_pcr
!= ATM_MAX_PCR
&&
662 tp
->min_pcr
> tp
->max_pcr
)
665 * We allow pcr to be outside [min_pcr,max_pcr], because later
666 * adjustment may still push it in the valid range.
671 static int check_qos(const struct atm_qos
*qos
)
675 if (!qos
->txtp
.traffic_class
&& !qos
->rxtp
.traffic_class
)
677 if (qos
->txtp
.traffic_class
!= qos
->rxtp
.traffic_class
&&
678 qos
->txtp
.traffic_class
&& qos
->rxtp
.traffic_class
&&
679 qos
->txtp
.traffic_class
!= ATM_ANYCLASS
&&
680 qos
->rxtp
.traffic_class
!= ATM_ANYCLASS
)
682 error
= check_tp(&qos
->txtp
);
685 return check_tp(&qos
->rxtp
);
688 int vcc_setsockopt(struct socket
*sock
, int level
, int optname
,
689 char __user
*optval
, unsigned int optlen
)
695 if (__SO_LEVEL_MATCH(optname
, level
) && optlen
!= __SO_SIZE(optname
))
704 if (copy_from_user(&qos
, optval
, sizeof(qos
)))
706 error
= check_qos(&qos
);
709 if (sock
->state
== SS_CONNECTED
)
710 return atm_change_qos(vcc
, &qos
);
711 if (sock
->state
!= SS_UNCONNECTED
)
714 set_bit(ATM_VF_HASQOS
, &vcc
->flags
);
718 if (get_user(value
, (unsigned long __user
*)optval
))
721 vcc
->atm_options
|= ATM_ATMOPT_CLP
;
723 vcc
->atm_options
&= ~ATM_ATMOPT_CLP
;
726 if (level
== SOL_SOCKET
)
730 if (!vcc
->dev
|| !vcc
->dev
->ops
->setsockopt
)
732 return vcc
->dev
->ops
->setsockopt(vcc
, level
, optname
, optval
, optlen
);
735 int vcc_getsockopt(struct socket
*sock
, int level
, int optname
,
736 char __user
*optval
, int __user
*optlen
)
741 if (get_user(len
, optlen
))
743 if (__SO_LEVEL_MATCH(optname
, level
) && len
!= __SO_SIZE(optname
))
749 if (!test_bit(ATM_VF_HASQOS
, &vcc
->flags
))
751 return copy_to_user(optval
, &vcc
->qos
, sizeof(vcc
->qos
))
754 return put_user(vcc
->atm_options
& ATM_ATMOPT_CLP
? 1 : 0,
755 (unsigned long __user
*)optval
) ? -EFAULT
: 0;
758 struct sockaddr_atmpvc pvc
;
760 if (!vcc
->dev
|| !test_bit(ATM_VF_ADDR
, &vcc
->flags
))
762 pvc
.sap_family
= AF_ATMPVC
;
763 pvc
.sap_addr
.itf
= vcc
->dev
->number
;
764 pvc
.sap_addr
.vpi
= vcc
->vpi
;
765 pvc
.sap_addr
.vci
= vcc
->vci
;
766 return copy_to_user(optval
, &pvc
, sizeof(pvc
)) ? -EFAULT
: 0;
769 if (level
== SOL_SOCKET
)
773 if (!vcc
->dev
|| !vcc
->dev
->ops
->getsockopt
)
775 return vcc
->dev
->ops
->getsockopt(vcc
, level
, optname
, optval
, len
);
778 static int __init
atm_init(void)
782 error
= proto_register(&vcc_proto
, 0);
785 error
= atmpvc_init();
787 pr_err("atmpvc_init() failed with %d\n", error
);
788 goto out_unregister_vcc_proto
;
790 error
= atmsvc_init();
792 pr_err("atmsvc_init() failed with %d\n", error
);
793 goto out_atmpvc_exit
;
795 error
= atm_proc_init();
797 pr_err("atm_proc_init() failed with %d\n", error
);
798 goto out_atmsvc_exit
;
800 error
= atm_sysfs_init();
802 pr_err("atm_sysfs_init() failed with %d\n", error
);
803 goto out_atmproc_exit
;
813 out_unregister_vcc_proto
:
814 proto_unregister(&vcc_proto
);
818 static void __exit
atm_exit(void)
824 proto_unregister(&vcc_proto
);
827 subsys_initcall(atm_init
);
829 module_exit(atm_exit
);
831 MODULE_LICENSE("GPL");
832 MODULE_ALIAS_NETPROTO(PF_ATMPVC
);
833 MODULE_ALIAS_NETPROTO(PF_ATMSVC
);