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
)
96 wq
= rcu_dereference(sk
->sk_wq
);
97 if (wq_has_sleeper(wq
))
102 static inline int vcc_writable(struct sock
*sk
)
104 struct atm_vcc
*vcc
= atm_sk(sk
);
106 return (vcc
->qos
.txtp
.max_sdu
+
107 atomic_read(&sk
->sk_wmem_alloc
)) <= sk
->sk_sndbuf
;
110 static void vcc_write_space(struct sock
*sk
)
112 struct socket_wq
*wq
;
116 if (vcc_writable(sk
)) {
117 wq
= rcu_dereference(sk
->sk_wq
);
118 if (wq_has_sleeper(wq
))
119 wake_up_interruptible(&wq
->wait
);
121 sk_wake_async(sk
, SOCK_WAKE_SPACE
, POLL_OUT
);
127 static struct proto vcc_proto
= {
129 .owner
= THIS_MODULE
,
130 .obj_size
= sizeof(struct atm_vcc
),
133 int vcc_create(struct net
*net
, struct socket
*sock
, int protocol
, int family
)
139 if (sock
->type
== SOCK_STREAM
)
141 sk
= sk_alloc(net
, family
, GFP_KERNEL
, &vcc_proto
);
144 sock_init_data(sock
, sk
);
145 sk
->sk_state_change
= vcc_def_wakeup
;
146 sk
->sk_write_space
= vcc_write_space
;
150 memset(&vcc
->local
, 0, sizeof(struct sockaddr_atmsvc
));
151 memset(&vcc
->remote
, 0, sizeof(struct sockaddr_atmsvc
));
152 vcc
->qos
.txtp
.max_sdu
= 1 << 16; /* for meta VCs */
153 atomic_set(&sk
->sk_wmem_alloc
, 1);
154 atomic_set(&sk
->sk_rmem_alloc
, 0);
157 vcc
->push_oam
= NULL
;
158 vcc
->vpi
= vcc
->vci
= 0; /* no VCI/VPI yet */
159 vcc
->atm_options
= vcc
->aal_options
= 0;
160 sk
->sk_destruct
= vcc_sock_destruct
;
164 static void vcc_destroy_socket(struct sock
*sk
)
166 struct atm_vcc
*vcc
= atm_sk(sk
);
169 set_bit(ATM_VF_CLOSE
, &vcc
->flags
);
170 clear_bit(ATM_VF_READY
, &vcc
->flags
);
172 if (vcc
->dev
->ops
->close
)
173 vcc
->dev
->ops
->close(vcc
);
175 vcc
->push(vcc
, NULL
); /* atmarpd has no push */
177 while ((skb
= skb_dequeue(&sk
->sk_receive_queue
)) != NULL
) {
178 atm_return(vcc
, skb
->truesize
);
182 module_put(vcc
->dev
->ops
->owner
);
183 atm_dev_put(vcc
->dev
);
186 vcc_remove_socket(sk
);
189 int vcc_release(struct socket
*sock
)
191 struct sock
*sk
= sock
->sk
;
195 vcc_destroy_socket(sock
->sk
);
203 void vcc_release_async(struct atm_vcc
*vcc
, int reply
)
205 struct sock
*sk
= sk_atm(vcc
);
207 set_bit(ATM_VF_CLOSE
, &vcc
->flags
);
208 sk
->sk_shutdown
|= RCV_SHUTDOWN
;
210 clear_bit(ATM_VF_WAITING
, &vcc
->flags
);
211 sk
->sk_state_change(sk
);
213 EXPORT_SYMBOL(vcc_release_async
);
216 void atm_dev_release_vccs(struct atm_dev
*dev
)
220 write_lock_irq(&vcc_sklist_lock
);
221 for (i
= 0; i
< VCC_HTABLE_SIZE
; i
++) {
222 struct hlist_head
*head
= &vcc_hash
[i
];
223 struct hlist_node
*node
, *tmp
;
227 sk_for_each_safe(s
, node
, tmp
, head
) {
229 if (vcc
->dev
== dev
) {
230 vcc_release_async(vcc
, -EPIPE
);
235 write_unlock_irq(&vcc_sklist_lock
);
238 static int adjust_tp(struct atm_trafprm
*tp
, unsigned char aal
)
242 if (!tp
->traffic_class
)
246 max_sdu
= ATM_CELL_SIZE
-1;
249 max_sdu
= ATM_MAX_AAL34_PDU
;
252 pr_warning("AAL problems ... (%d)\n", aal
);
255 max_sdu
= ATM_MAX_AAL5_PDU
;
258 tp
->max_sdu
= max_sdu
;
259 else if (tp
->max_sdu
> max_sdu
)
262 tp
->max_cdv
= ATM_MAX_CDV
;
266 static int check_ci(const struct atm_vcc
*vcc
, short vpi
, int vci
)
268 struct hlist_head
*head
= &vcc_hash
[vci
& (VCC_HTABLE_SIZE
- 1)];
269 struct hlist_node
*node
;
271 struct atm_vcc
*walk
;
273 sk_for_each(s
, node
, head
) {
275 if (walk
->dev
!= vcc
->dev
)
277 if (test_bit(ATM_VF_ADDR
, &walk
->flags
) && walk
->vpi
== vpi
&&
278 walk
->vci
== vci
&& ((walk
->qos
.txtp
.traffic_class
!=
279 ATM_NONE
&& vcc
->qos
.txtp
.traffic_class
!= ATM_NONE
) ||
280 (walk
->qos
.rxtp
.traffic_class
!= ATM_NONE
&&
281 vcc
->qos
.rxtp
.traffic_class
!= ATM_NONE
)))
285 /* allow VCCs with same VPI/VCI iff they don't collide on
286 TX/RX (but we may refuse such sharing for other reasons,
287 e.g. if protocol requires to have both channels) */
292 static int find_ci(const struct atm_vcc
*vcc
, short *vpi
, int *vci
)
294 static short p
; /* poor man's per-device cache */
300 if (*vpi
!= ATM_VPI_ANY
&& *vci
!= ATM_VCI_ANY
) {
301 err
= check_ci(vcc
, *vpi
, *vci
);
304 /* last scan may have left values out of bounds for current device */
305 if (*vpi
!= ATM_VPI_ANY
)
307 else if (p
>= 1 << vcc
->dev
->ci_range
.vpi_bits
)
309 if (*vci
!= ATM_VCI_ANY
)
311 else if (c
< ATM_NOT_RSV_VCI
|| c
>= 1 << vcc
->dev
->ci_range
.vci_bits
)
316 if (!check_ci(vcc
, p
, c
)) {
321 if (*vci
== ATM_VCI_ANY
) {
323 if (c
>= 1 << vcc
->dev
->ci_range
.vci_bits
)
326 if ((c
== ATM_NOT_RSV_VCI
|| *vci
!= ATM_VCI_ANY
) &&
327 *vpi
== ATM_VPI_ANY
) {
329 if (p
>= 1 << vcc
->dev
->ci_range
.vpi_bits
)
332 } while (old_p
!= p
|| old_c
!= c
);
336 static int __vcc_connect(struct atm_vcc
*vcc
, struct atm_dev
*dev
, short vpi
,
339 struct sock
*sk
= sk_atm(vcc
);
342 if ((vpi
!= ATM_VPI_UNSPEC
&& vpi
!= ATM_VPI_ANY
&&
343 vpi
>> dev
->ci_range
.vpi_bits
) || (vci
!= ATM_VCI_UNSPEC
&&
344 vci
!= ATM_VCI_ANY
&& vci
>> dev
->ci_range
.vci_bits
))
346 if (vci
> 0 && vci
< ATM_NOT_RSV_VCI
&& !capable(CAP_NET_BIND_SERVICE
))
349 if (!try_module_get(dev
->ops
->owner
))
352 write_lock_irq(&vcc_sklist_lock
);
353 if (test_bit(ATM_DF_REMOVED
, &dev
->flags
) ||
354 (error
= find_ci(vcc
, &vpi
, &vci
))) {
355 write_unlock_irq(&vcc_sklist_lock
);
356 goto fail_module_put
;
360 __vcc_insert_socket(sk
);
361 write_unlock_irq(&vcc_sklist_lock
);
362 switch (vcc
->qos
.aal
) {
364 error
= atm_init_aal0(vcc
);
365 vcc
->stats
= &dev
->stats
.aal0
;
368 error
= atm_init_aal34(vcc
);
369 vcc
->stats
= &dev
->stats
.aal34
;
372 /* ATM_AAL5 is also used in the "0 for default" case */
373 vcc
->qos
.aal
= ATM_AAL5
;
376 error
= atm_init_aal5(vcc
);
377 vcc
->stats
= &dev
->stats
.aal5
;
383 error
= adjust_tp(&vcc
->qos
.txtp
, vcc
->qos
.aal
);
385 error
= adjust_tp(&vcc
->qos
.rxtp
, vcc
->qos
.aal
);
388 pr_debug("VCC %d.%d, AAL %d\n", vpi
, vci
, vcc
->qos
.aal
);
389 pr_debug(" TX: %d, PCR %d..%d, SDU %d\n",
390 vcc
->qos
.txtp
.traffic_class
,
391 vcc
->qos
.txtp
.min_pcr
,
392 vcc
->qos
.txtp
.max_pcr
,
393 vcc
->qos
.txtp
.max_sdu
);
394 pr_debug(" RX: %d, PCR %d..%d, SDU %d\n",
395 vcc
->qos
.rxtp
.traffic_class
,
396 vcc
->qos
.rxtp
.min_pcr
,
397 vcc
->qos
.rxtp
.max_pcr
,
398 vcc
->qos
.rxtp
.max_sdu
);
400 if (dev
->ops
->open
) {
401 error
= dev
->ops
->open(vcc
);
408 vcc_remove_socket(sk
);
410 module_put(dev
->ops
->owner
);
411 /* ensure we get dev module ref count correct */
416 int vcc_connect(struct socket
*sock
, int itf
, short vpi
, int vci
)
419 struct atm_vcc
*vcc
= ATM_SD(sock
);
422 pr_debug("(vpi %d, vci %d)\n", vpi
, vci
);
423 if (sock
->state
== SS_CONNECTED
)
425 if (sock
->state
!= SS_UNCONNECTED
)
430 if (vpi
!= ATM_VPI_UNSPEC
&& vci
!= ATM_VCI_UNSPEC
)
431 clear_bit(ATM_VF_PARTIAL
, &vcc
->flags
);
433 if (test_bit(ATM_VF_PARTIAL
, &vcc
->flags
))
435 pr_debug("(TX: cl %d,bw %d-%d,sdu %d; "
436 "RX: cl %d,bw %d-%d,sdu %d,AAL %s%d)\n",
437 vcc
->qos
.txtp
.traffic_class
, vcc
->qos
.txtp
.min_pcr
,
438 vcc
->qos
.txtp
.max_pcr
, vcc
->qos
.txtp
.max_sdu
,
439 vcc
->qos
.rxtp
.traffic_class
, vcc
->qos
.rxtp
.min_pcr
,
440 vcc
->qos
.rxtp
.max_pcr
, vcc
->qos
.rxtp
.max_sdu
,
441 vcc
->qos
.aal
== ATM_AAL5
? "" :
442 vcc
->qos
.aal
== ATM_AAL0
? "" : " ??? code ",
443 vcc
->qos
.aal
== ATM_AAL0
? 0 : vcc
->qos
.aal
);
444 if (!test_bit(ATM_VF_HASQOS
, &vcc
->flags
))
446 if (vcc
->qos
.txtp
.traffic_class
== ATM_ANYCLASS
||
447 vcc
->qos
.rxtp
.traffic_class
== ATM_ANYCLASS
)
449 if (likely(itf
!= ATM_ITF_ANY
)) {
450 dev
= try_then_request_module(atm_dev_lookup(itf
),
451 "atm-device-%d", itf
);
454 mutex_lock(&atm_dev_mutex
);
455 if (!list_empty(&atm_devs
)) {
456 dev
= list_entry(atm_devs
.next
,
457 struct atm_dev
, dev_list
);
460 mutex_unlock(&atm_dev_mutex
);
464 error
= __vcc_connect(vcc
, dev
, vpi
, vci
);
469 if (vpi
== ATM_VPI_UNSPEC
|| vci
== ATM_VCI_UNSPEC
)
470 set_bit(ATM_VF_PARTIAL
, &vcc
->flags
);
471 if (test_bit(ATM_VF_READY
, &ATM_SD(sock
)->flags
))
472 sock
->state
= SS_CONNECTED
;
476 int vcc_recvmsg(struct kiocb
*iocb
, struct socket
*sock
, struct msghdr
*msg
,
477 size_t size
, int flags
)
479 struct sock
*sk
= sock
->sk
;
482 int copied
, error
= -EINVAL
;
484 if (sock
->state
!= SS_CONNECTED
)
486 if (flags
& ~MSG_DONTWAIT
) /* only handle MSG_DONTWAIT */
489 if (test_bit(ATM_VF_RELEASED
, &vcc
->flags
) ||
490 test_bit(ATM_VF_CLOSE
, &vcc
->flags
) ||
491 !test_bit(ATM_VF_READY
, &vcc
->flags
))
494 skb
= skb_recv_datagram(sk
, flags
, flags
& MSG_DONTWAIT
, &error
);
501 msg
->msg_flags
|= MSG_TRUNC
;
504 error
= skb_copy_datagram_iovec(skb
, 0, msg
->msg_iov
, copied
);
507 sock_recv_ts_and_drops(msg
, sk
, skb
);
508 pr_debug("%d -= %d\n", atomic_read(&sk
->sk_rmem_alloc
), skb
->truesize
);
509 atm_return(vcc
, skb
->truesize
);
510 skb_free_datagram(sk
, skb
);
514 int vcc_sendmsg(struct kiocb
*iocb
, struct socket
*sock
, struct msghdr
*m
,
517 struct sock
*sk
= sock
->sk
;
522 const void __user
*buff
;
526 if (sock
->state
!= SS_CONNECTED
) {
534 if (m
->msg_iovlen
!= 1) {
535 error
= -ENOSYS
; /* fix this later @@@ */
538 buff
= m
->msg_iov
->iov_base
;
539 size
= m
->msg_iov
->iov_len
;
541 if (test_bit(ATM_VF_RELEASED
, &vcc
->flags
) ||
542 test_bit(ATM_VF_CLOSE
, &vcc
->flags
) ||
543 !test_bit(ATM_VF_READY
, &vcc
->flags
)) {
545 send_sig(SIGPIPE
, current
, 0);
552 if (size
< 0 || size
> vcc
->qos
.txtp
.max_sdu
) {
557 eff
= (size
+3) & ~3; /* align to word boundary */
558 prepare_to_wait(sk_sleep(sk
), &wait
, TASK_INTERRUPTIBLE
);
560 while (!(skb
= alloc_tx(vcc
, eff
))) {
561 if (m
->msg_flags
& MSG_DONTWAIT
) {
566 if (signal_pending(current
)) {
567 error
= -ERESTARTSYS
;
570 if (test_bit(ATM_VF_RELEASED
, &vcc
->flags
) ||
571 test_bit(ATM_VF_CLOSE
, &vcc
->flags
) ||
572 !test_bit(ATM_VF_READY
, &vcc
->flags
)) {
574 send_sig(SIGPIPE
, current
, 0);
577 prepare_to_wait(sk_sleep(sk
), &wait
, TASK_INTERRUPTIBLE
);
579 finish_wait(sk_sleep(sk
), &wait
);
582 skb
->dev
= NULL
; /* for paths shared with net_device interfaces */
583 ATM_SKB(skb
)->atm_options
= vcc
->atm_options
;
584 if (copy_from_user(skb_put(skb
, size
), buff
, size
)) {
590 memset(skb
->data
+ size
, 0, eff
-size
);
591 error
= vcc
->dev
->ops
->send(vcc
, skb
);
592 error
= error
? error
: size
;
598 unsigned int vcc_poll(struct file
*file
, struct socket
*sock
, poll_table
*wait
)
600 struct sock
*sk
= sock
->sk
;
604 sock_poll_wait(file
, sk_sleep(sk
), wait
);
609 /* exceptional events */
613 if (test_bit(ATM_VF_RELEASED
, &vcc
->flags
) ||
614 test_bit(ATM_VF_CLOSE
, &vcc
->flags
))
618 if (!skb_queue_empty(&sk
->sk_receive_queue
))
619 mask
|= POLLIN
| POLLRDNORM
;
622 if (sock
->state
== SS_CONNECTING
&&
623 test_bit(ATM_VF_WAITING
, &vcc
->flags
))
626 if (vcc
->qos
.txtp
.traffic_class
!= ATM_NONE
&&
628 mask
|= POLLOUT
| POLLWRNORM
| POLLWRBAND
;
633 static int atm_change_qos(struct atm_vcc
*vcc
, struct atm_qos
*qos
)
638 * Don't let the QoS change the already connected AAL type nor the
641 if (qos
->aal
!= vcc
->qos
.aal
||
642 qos
->rxtp
.traffic_class
!= vcc
->qos
.rxtp
.traffic_class
||
643 qos
->txtp
.traffic_class
!= vcc
->qos
.txtp
.traffic_class
)
645 error
= adjust_tp(&qos
->txtp
, qos
->aal
);
647 error
= adjust_tp(&qos
->rxtp
, qos
->aal
);
650 if (!vcc
->dev
->ops
->change_qos
)
652 if (sk_atm(vcc
)->sk_family
== AF_ATMPVC
)
653 return vcc
->dev
->ops
->change_qos(vcc
, qos
, ATM_MF_SET
);
654 return svc_change_qos(vcc
, qos
);
657 static int check_tp(const struct atm_trafprm
*tp
)
659 /* @@@ Should be merged with adjust_tp */
660 if (!tp
->traffic_class
|| tp
->traffic_class
== ATM_ANYCLASS
)
662 if (tp
->traffic_class
!= ATM_UBR
&& !tp
->min_pcr
&& !tp
->pcr
&&
665 if (tp
->min_pcr
== ATM_MAX_PCR
)
667 if (tp
->min_pcr
&& tp
->max_pcr
&& tp
->max_pcr
!= ATM_MAX_PCR
&&
668 tp
->min_pcr
> tp
->max_pcr
)
671 * We allow pcr to be outside [min_pcr,max_pcr], because later
672 * adjustment may still push it in the valid range.
677 static int check_qos(const struct atm_qos
*qos
)
681 if (!qos
->txtp
.traffic_class
&& !qos
->rxtp
.traffic_class
)
683 if (qos
->txtp
.traffic_class
!= qos
->rxtp
.traffic_class
&&
684 qos
->txtp
.traffic_class
&& qos
->rxtp
.traffic_class
&&
685 qos
->txtp
.traffic_class
!= ATM_ANYCLASS
&&
686 qos
->rxtp
.traffic_class
!= ATM_ANYCLASS
)
688 error
= check_tp(&qos
->txtp
);
691 return check_tp(&qos
->rxtp
);
694 int vcc_setsockopt(struct socket
*sock
, int level
, int optname
,
695 char __user
*optval
, unsigned int optlen
)
701 if (__SO_LEVEL_MATCH(optname
, level
) && optlen
!= __SO_SIZE(optname
))
710 if (copy_from_user(&qos
, optval
, sizeof(qos
)))
712 error
= check_qos(&qos
);
715 if (sock
->state
== SS_CONNECTED
)
716 return atm_change_qos(vcc
, &qos
);
717 if (sock
->state
!= SS_UNCONNECTED
)
720 set_bit(ATM_VF_HASQOS
, &vcc
->flags
);
724 if (get_user(value
, (unsigned long __user
*)optval
))
727 vcc
->atm_options
|= ATM_ATMOPT_CLP
;
729 vcc
->atm_options
&= ~ATM_ATMOPT_CLP
;
732 if (level
== SOL_SOCKET
)
736 if (!vcc
->dev
|| !vcc
->dev
->ops
->setsockopt
)
738 return vcc
->dev
->ops
->setsockopt(vcc
, level
, optname
, optval
, optlen
);
741 int vcc_getsockopt(struct socket
*sock
, int level
, int optname
,
742 char __user
*optval
, int __user
*optlen
)
747 if (get_user(len
, optlen
))
749 if (__SO_LEVEL_MATCH(optname
, level
) && len
!= __SO_SIZE(optname
))
755 if (!test_bit(ATM_VF_HASQOS
, &vcc
->flags
))
757 return copy_to_user(optval
, &vcc
->qos
, sizeof(vcc
->qos
))
760 return put_user(vcc
->atm_options
& ATM_ATMOPT_CLP
? 1 : 0,
761 (unsigned long __user
*)optval
) ? -EFAULT
: 0;
764 struct sockaddr_atmpvc pvc
;
766 if (!vcc
->dev
|| !test_bit(ATM_VF_ADDR
, &vcc
->flags
))
768 pvc
.sap_family
= AF_ATMPVC
;
769 pvc
.sap_addr
.itf
= vcc
->dev
->number
;
770 pvc
.sap_addr
.vpi
= vcc
->vpi
;
771 pvc
.sap_addr
.vci
= vcc
->vci
;
772 return copy_to_user(optval
, &pvc
, sizeof(pvc
)) ? -EFAULT
: 0;
775 if (level
== SOL_SOCKET
)
779 if (!vcc
->dev
|| !vcc
->dev
->ops
->getsockopt
)
781 return vcc
->dev
->ops
->getsockopt(vcc
, level
, optname
, optval
, len
);
784 static int __init
atm_init(void)
788 error
= proto_register(&vcc_proto
, 0);
791 error
= atmpvc_init();
793 pr_err("atmpvc_init() failed with %d\n", error
);
794 goto out_unregister_vcc_proto
;
796 error
= atmsvc_init();
798 pr_err("atmsvc_init() failed with %d\n", error
);
799 goto out_atmpvc_exit
;
801 error
= atm_proc_init();
803 pr_err("atm_proc_init() failed with %d\n", error
);
804 goto out_atmsvc_exit
;
806 error
= atm_sysfs_init();
808 pr_err("atm_sysfs_init() failed with %d\n", error
);
809 goto out_atmproc_exit
;
819 out_unregister_vcc_proto
:
820 proto_unregister(&vcc_proto
);
824 static void __exit
atm_exit(void)
830 proto_unregister(&vcc_proto
);
833 subsys_initcall(atm_init
);
835 module_exit(atm_exit
);
837 MODULE_LICENSE("GPL");
838 MODULE_ALIAS_NETPROTO(PF_ATMPVC
);
839 MODULE_ALIAS_NETPROTO(PF_ATMSVC
);