1 /** -*- linux-c -*- ***********************************************************
2 * Linux PPP over Ethernet (PPPoX/PPPoE) Sockets
4 * PPPoX --- Generic PPP encapsulation socket family
5 * PPPoE --- PPP over Ethernet (RFC 2516)
10 * 220102 : Fix module use count on failure in pppoe_create, pppox_sk -acme
11 * 030700 : Fixed connect logic to allow for disconnect.
12 * 270700 : Fixed potential SMP problems; we must protect against
13 * simultaneous invocation of ppp_input
14 * and ppp_unregister_channel.
15 * 040800 : Respect reference count mechanisms on net-devices.
16 * 200800 : fix kfree(skb) in pppoe_rcv (acme)
17 * Module reference count is decremented in the right spot now,
18 * guards against sock_put not actually freeing the sk
20 * 051000 : Initialization cleanup.
21 * 111100 : Fix recvmsg.
22 * 050101 : Fix PADT procesing.
23 * 140501 : Use pppoe_rcv_core to handle all backlog. (Alexey)
24 * 170701 : Do not lock_sock with rwlock held. (DaveM)
25 * Ignore discovery frames if user has socket
27 * Ignore return value of dev_queue_xmit in __pppoe_xmit
28 * or else we may kfree an SKB twice. (DaveM)
29 * 190701 : When doing copies of skb's in __pppoe_xmit, always delete
30 * the original skb that was passed in on success, never on
31 * failure. Delete the copy of the skb on failure to avoid
33 * 081001 : Misc. cleanup (licence string, non-blocking, prevent
34 * reference of device on close).
35 * 121301 : New ppp channels interface; cannot unregister a channel
36 * from interrupts. Thus, we mark the socket as a ZOMBIE
37 * and do the unregistration later.
38 * 081002 : seq_file support for proc stuff -acme
39 * 111602 : Merge all 2.4 fixes into 2.5/2.6 tree. Label 2.5/2.6
40 * as version 0.7. Spacing cleanup.
41 * Author: Michal Ostrowski <mostrows@speakeasy.net>
43 * Arnaldo Carvalho de Melo <acme@conectiva.com.br>
44 * David S. Miller (davem@redhat.com)
47 * This program is free software; you can redistribute it and/or
48 * modify it under the terms of the GNU General Public License
49 * as published by the Free Software Foundation; either version
50 * 2 of the License, or (at your option) any later version.
54 #include <linux/string.h>
55 #include <linux/module.h>
56 #include <linux/kernel.h>
57 #include <linux/slab.h>
58 #include <linux/errno.h>
59 #include <linux/netdevice.h>
60 #include <linux/net.h>
61 #include <linux/inetdevice.h>
62 #include <linux/etherdevice.h>
63 #include <linux/skbuff.h>
64 #include <linux/init.h>
65 #include <linux/if_ether.h>
66 #include <linux/if_pppox.h>
67 #include <linux/ppp_channel.h>
68 #include <linux/ppp_defs.h>
69 #include <linux/if_ppp.h>
70 #include <linux/notifier.h>
71 #include <linux/file.h>
72 #include <linux/proc_fs.h>
73 #include <linux/seq_file.h>
77 #include <asm/uaccess.h>
79 #define PPPOE_HASH_BITS 4
80 #define PPPOE_HASH_SIZE (1<<PPPOE_HASH_BITS)
82 static int pppoe_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg);
83 static int pppoe_xmit(struct ppp_channel *chan, struct sk_buff *skb);
84 static int __pppoe_xmit(struct sock *sk, struct sk_buff *skb);
86 static struct proto_ops pppoe_ops;
87 static rwlock_t pppoe_hash_lock = RW_LOCK_UNLOCKED;
90 static inline int cmp_2_addr(struct pppoe_addr *a, struct pppoe_addr *b)
92 return (a->sid == b->sid &&
93 (memcmp(a->remote, b->remote, ETH_ALEN) == 0));
96 static inline int cmp_addr(struct pppoe_addr *a, unsigned long sid, char *addr)
98 return (a->sid == sid &&
99 (memcmp(a->remote,addr,ETH_ALEN) == 0));
102 static int hash_item(unsigned long sid, unsigned char *addr)
107 for (i = 0; i < ETH_ALEN ; ++i) {
108 for (j = 0; j < 8/PPPOE_HASH_BITS ; ++j) {
109 hash ^= addr[i] >> ( j * PPPOE_HASH_BITS );
113 for (i = 0; i < (sizeof(unsigned long)*8) / PPPOE_HASH_BITS ; ++i)
114 hash ^= sid >> (i*PPPOE_HASH_BITS);
116 return hash & ( PPPOE_HASH_SIZE - 1 );
119 /* zeroed because its in .bss */
120 static struct pppox_opt *item_hash_table[PPPOE_HASH_SIZE];
122 /**********************************************************************
124 * Set/get/delete/rehash items (internal versions)
126 **********************************************************************/
127 static struct pppox_opt *__get_item(unsigned long sid, unsigned char *addr)
129 int hash = hash_item(sid, addr);
130 struct pppox_opt *ret;
132 ret = item_hash_table[hash];
134 while (ret && !cmp_addr(&ret->pppoe_pa, sid, addr))
140 static int __set_item(struct pppox_opt *po)
142 int hash = hash_item(po->pppoe_pa.sid, po->pppoe_pa.remote);
143 struct pppox_opt *ret;
145 ret = item_hash_table[hash];
147 if (cmp_2_addr(&ret->pppoe_pa, &po->pppoe_pa))
154 po->next = item_hash_table[hash];
155 item_hash_table[hash] = po;
161 static struct pppox_opt *__delete_item(unsigned long sid, char *addr)
163 int hash = hash_item(sid, addr);
164 struct pppox_opt *ret, **src;
166 ret = item_hash_table[hash];
167 src = &item_hash_table[hash];
170 if (cmp_addr(&ret->pppoe_pa, sid, addr)) {
182 /**********************************************************************
184 * Set/get/delete/rehash items
186 **********************************************************************/
187 static inline struct pppox_opt *get_item(unsigned long sid,
190 struct pppox_opt *po;
192 read_lock_bh(&pppoe_hash_lock);
193 po = __get_item(sid, addr);
196 read_unlock_bh(&pppoe_hash_lock);
201 static inline struct pppox_opt *get_item_by_addr(struct sockaddr_pppox *sp)
203 return get_item(sp->sa_addr.pppoe.sid, sp->sa_addr.pppoe.remote);
206 static inline int set_item(struct pppox_opt *po)
213 write_lock_bh(&pppoe_hash_lock);
215 write_unlock_bh(&pppoe_hash_lock);
220 static inline struct pppox_opt *delete_item(unsigned long sid, char *addr)
222 struct pppox_opt *ret;
224 write_lock_bh(&pppoe_hash_lock);
225 ret = __delete_item(sid, addr);
226 write_unlock_bh(&pppoe_hash_lock);
233 /***************************************************************************
235 * Handler for device events.
236 * Certain device events require that sockets be unconnected.
238 **************************************************************************/
240 static void pppoe_flush_dev(struct net_device *dev)
246 read_lock_bh(&pppoe_hash_lock);
247 for (hash = 0; hash < PPPOE_HASH_SIZE; hash++) {
248 struct pppox_opt *po = item_hash_table[hash];
251 if (po->pppoe_dev == dev) {
252 struct sock *sk = po->sk;
255 po->pppoe_dev = NULL;
257 /* We hold a reference to SK, now drop the
258 * hash table lock so that we may attempt
259 * to lock the socket (which can sleep).
261 read_unlock_bh(&pppoe_hash_lock);
266 (PPPOX_CONNECTED | PPPOX_BOUND)) {
267 pppox_unbind_sock(sk);
269 sk->sk_state = PPPOX_ZOMBIE;
270 sk->sk_state_change(sk);
277 read_lock_bh(&pppoe_hash_lock);
279 /* Now restart from the beginning of this
280 * hash chain. We always NULL out pppoe_dev
281 * so we are guaranteed to make forward
284 po = item_hash_table[hash];
290 read_unlock_bh(&pppoe_hash_lock);
293 static int pppoe_device_event(struct notifier_block *this,
294 unsigned long event, void *ptr)
296 struct net_device *dev = (struct net_device *) ptr;
298 /* Only look at sockets that are using this specific device. */
300 case NETDEV_CHANGEMTU:
301 /* A change in mtu is a bad thing, requiring
302 * LCP re-negotiation.
305 case NETDEV_GOING_DOWN:
307 /* Find every socket on this device and kill it. */
308 pppoe_flush_dev(dev);
319 static struct notifier_block pppoe_notifier = {
320 .notifier_call = pppoe_device_event,
324 /************************************************************************
326 * Do the real work of receiving a PPPoE Session frame.
328 ***********************************************************************/
329 static int pppoe_rcv_core(struct sock *sk, struct sk_buff *skb)
331 struct pppox_opt *po = pppox_sk(sk);
332 struct pppox_opt *relay_po = NULL;
334 if (sk->sk_state & PPPOX_BOUND) {
335 struct pppoe_hdr *ph = (struct pppoe_hdr *) skb->nh.raw;
336 int len = ntohs(ph->length);
337 skb_pull(skb, sizeof(struct pppoe_hdr));
340 ppp_input(&po->chan, skb);
341 } else if (sk->sk_state & PPPOX_RELAY) {
342 relay_po = get_item_by_addr(&po->pppoe_relay);
344 if (relay_po == NULL)
347 if ((relay_po->sk->sk_state & PPPOX_CONNECTED) == 0)
350 skb_pull(skb, sizeof(struct pppoe_hdr));
351 if (!__pppoe_xmit( relay_po->sk, skb))
354 if (sock_queue_rcv_skb(sk, skb))
358 return NET_RX_SUCCESS;
361 sock_put(relay_po->sk);
368 /************************************************************************
370 * Receive wrapper called in BH context.
372 ***********************************************************************/
373 static int pppoe_rcv(struct sk_buff *skb,
374 struct net_device *dev,
375 struct packet_type *pt)
378 struct pppoe_hdr *ph;
379 struct pppox_opt *po;
383 if (!pskb_may_pull(skb, sizeof(struct pppoe_hdr)))
386 if (!(skb = skb_share_check(skb, GFP_ATOMIC)))
389 ph = (struct pppoe_hdr *) skb->nh.raw;
391 po = get_item((unsigned long) ph->sid, skb->mac.ethernet->h_source);
398 /* Socket state is unknown, must put skb into backlog. */
399 if (sock_owned_by_user(sk) != 0) {
400 sk_add_backlog(sk, skb);
401 ret = NET_RX_SUCCESS;
403 ret = pppoe_rcv_core(sk, skb);
416 /************************************************************************
418 * Receive a PPPoE Discovery frame.
419 * This is solely for detection of PADT frames
421 ***********************************************************************/
422 static int pppoe_disc_rcv(struct sk_buff *skb,
423 struct net_device *dev,
424 struct packet_type *pt)
427 struct pppoe_hdr *ph;
428 struct pppox_opt *po;
430 if (!pskb_may_pull(skb, sizeof(struct pppoe_hdr)))
433 if (!(skb = skb_share_check(skb, GFP_ATOMIC)))
436 ph = (struct pppoe_hdr *) skb->nh.raw;
437 if (ph->code != PADT_CODE)
440 po = get_item((unsigned long) ph->sid, skb->mac.ethernet->h_source);
442 struct sock *sk = po->sk;
446 /* If the user has locked the socket, just ignore
447 * the packet. With the way two rcv protocols hook into
448 * one socket family type, we cannot (easily) distinguish
449 * what kind of SKB it is during backlog rcv.
451 if (sock_owned_by_user(sk) == 0) {
452 /* We're no longer connect at the PPPOE layer,
453 * and must wait for ppp channel to disconnect us.
455 sk->sk_state = PPPOX_ZOMBIE;
465 return NET_RX_SUCCESS; /* Lies... :-) */
468 static struct packet_type pppoes_ptype = {
469 .type = __constant_htons(ETH_P_PPP_SES),
473 static struct packet_type pppoed_ptype = {
474 .type = __constant_htons(ETH_P_PPP_DISC),
475 .func = pppoe_disc_rcv,
478 /***********************************************************************
480 * Really kill the socket. (Called from pppox_sk_free if refcnt == 0.)
482 **********************************************************************/
483 static void pppoe_sk_free(struct sock *sk)
485 struct pppox_opt *po = pppox_sk(sk);
492 /***********************************************************************
494 * Initialize a new struct sock.
496 **********************************************************************/
497 static int pppoe_create(struct socket *sock)
501 struct pppox_opt *po;
503 sk = sk_alloc(PF_PPPOX, GFP_KERNEL, 1, NULL);
507 sock_init_data(sock, sk);
508 sk_set_owner(sk, THIS_MODULE);
509 sock->state = SS_UNCONNECTED;
510 sock->ops = &pppoe_ops;
512 sk->sk_backlog_rcv = pppoe_rcv_core;
513 sk->sk_state = PPPOX_NONE;
514 sk->sk_type = SOCK_STREAM;
515 sk->sk_family = PF_PPPOX;
516 sk->sk_protocol = PX_PROTO_OE;
517 sk->sk_destruct = pppoe_sk_free;
519 po = sk->sk_protinfo = kmalloc(sizeof(*po), GFP_KERNEL);
522 memset(po, 0, sizeof(*po));
530 static int pppoe_release(struct socket *sock)
532 struct sock *sk = sock->sk;
533 struct pppox_opt *po;
539 if (sock_flag(sk, SOCK_DEAD))
542 pppox_unbind_sock(sk);
544 /* Signal the death of the socket. */
545 sk->sk_state = PPPOX_DEAD;
548 if (po->pppoe_pa.sid) {
549 delete_item(po->pppoe_pa.sid, po->pppoe_pa.remote);
553 dev_put(po->pppoe_dev);
555 po->pppoe_dev = NULL;
560 skb_queue_purge(&sk->sk_receive_queue);
567 static int pppoe_connect(struct socket *sock, struct sockaddr *uservaddr,
568 int sockaddr_len, int flags)
570 struct sock *sk = sock->sk;
571 struct net_device *dev = NULL;
572 struct sockaddr_pppox *sp = (struct sockaddr_pppox *) uservaddr;
573 struct pppox_opt *po = pppox_sk(sk);
579 if (sp->sa_protocol != PX_PROTO_OE)
582 /* Check for already bound sockets */
584 if ((sk->sk_state & PPPOX_CONNECTED) && sp->sa_addr.pppoe.sid)
587 /* Check for already disconnected sockets, on attempts to disconnect */
589 if ((sk->sk_state & PPPOX_DEAD) && !sp->sa_addr.pppoe.sid )
593 if (po->pppoe_pa.sid) {
594 pppox_unbind_sock(sk);
596 /* Delete the old binding */
597 delete_item(po->pppoe_pa.sid,po->pppoe_pa.remote);
600 dev_put(po->pppoe_dev);
602 memset(po, 0, sizeof(struct pppox_opt));
605 sk->sk_state = PPPOX_NONE;
608 /* Don't re-bind if sid==0 */
609 if (sp->sa_addr.pppoe.sid != 0) {
610 dev = dev_get_by_name(sp->sa_addr.pppoe.dev);
618 if (!(dev->flags & IFF_UP))
621 memcpy(&po->pppoe_pa,
623 sizeof(struct pppoe_addr));
625 error = set_item(po);
629 po->chan.hdrlen = (sizeof(struct pppoe_hdr) +
630 dev->hard_header_len);
632 po->chan.private = sk;
633 po->chan.ops = &pppoe_chan_ops;
635 error = ppp_register_channel(&po->chan);
639 sk->sk_state = PPPOX_CONNECTED;
642 po->num = sp->sa_addr.pppoe.sid;
649 dev_put(po->pppoe_dev);
650 po->pppoe_dev = NULL;
656 static int pppoe_getname(struct socket *sock, struct sockaddr *uaddr,
657 int *usockaddr_len, int peer)
659 int len = sizeof(struct sockaddr_pppox);
660 struct sockaddr_pppox sp;
662 sp.sa_family = AF_PPPOX;
663 sp.sa_protocol = PX_PROTO_OE;
664 memcpy(&sp.sa_addr.pppoe, &pppox_sk(sock->sk)->pppoe_pa,
665 sizeof(struct pppoe_addr));
667 memcpy(uaddr, &sp, len);
669 *usockaddr_len = len;
675 static int pppoe_ioctl(struct socket *sock, unsigned int cmd,
678 struct sock *sk = sock->sk;
679 struct pppox_opt *po = pppox_sk(sk);
687 if (!(sk->sk_state & PPPOX_CONNECTED))
691 if (put_user(po->pppoe_dev->mtu -
692 sizeof(struct pppoe_hdr) -
701 if (!(sk->sk_state & PPPOX_CONNECTED))
705 if (get_user(val,(int *) arg))
708 if (val < (po->pppoe_dev->mtu
709 - sizeof(struct pppoe_hdr)
718 if (get_user(val, (int *) arg))
725 struct pppox_opt *relay_po;
728 if (sk->sk_state & (PPPOX_BOUND | PPPOX_ZOMBIE | PPPOX_DEAD))
732 if (!(sk->sk_state & PPPOX_CONNECTED))
735 /* PPPoE address from the user specifies an outbound
736 PPPoE address to which frames are forwarded to */
738 if (copy_from_user(&po->pppoe_relay,
740 sizeof(struct sockaddr_pppox)))
744 if (po->pppoe_relay.sa_family != AF_PPPOX ||
745 po->pppoe_relay.sa_protocol!= PX_PROTO_OE)
748 /* Check that the socket referenced by the address
750 relay_po = get_item_by_addr(&po->pppoe_relay);
755 sock_put(relay_po->sk);
756 sk->sk_state |= PPPOX_RELAY;
763 if (!(sk->sk_state & PPPOX_RELAY))
766 sk->sk_state &= ~PPPOX_RELAY;
777 static int pppoe_sendmsg(struct kiocb *iocb, struct socket *sock,
778 struct msghdr *m, size_t total_len)
780 struct sk_buff *skb = NULL;
781 struct sock *sk = sock->sk;
782 struct pppox_opt *po = pppox_sk(sk);
784 struct pppoe_hdr hdr;
785 struct pppoe_hdr *ph;
786 struct net_device *dev;
789 if (sock_flag(sk, SOCK_DEAD) || !(sk->sk_state & PPPOX_CONNECTED)) {
804 if (total_len > (dev->mtu + dev->hard_header_len))
808 skb = sock_wmalloc(sk, total_len + dev->hard_header_len + 32,
815 /* Reserve space for headers. */
816 skb_reserve(skb, dev->hard_header_len);
817 skb->nh.raw = skb->data;
821 skb->priority = sk->sk_priority;
822 skb->protocol = __constant_htons(ETH_P_PPP_SES);
824 ph = (struct pppoe_hdr *) skb_put(skb, total_len + sizeof(struct pppoe_hdr));
825 start = (char *) &ph->tag[0];
827 error = memcpy_fromiovec(start, m->msg_iov, total_len);
835 dev->hard_header(skb, dev, ETH_P_PPP_SES,
836 po->pppoe_pa.remote, NULL, total_len);
838 memcpy(ph, &hdr, sizeof(struct pppoe_hdr));
840 ph->length = htons(total_len);
850 /************************************************************************
852 * xmit function for internal use.
854 ***********************************************************************/
855 static int __pppoe_xmit(struct sock *sk, struct sk_buff *skb)
857 struct pppox_opt *po = pppox_sk(sk);
858 struct net_device *dev = po->pppoe_dev;
859 struct pppoe_hdr hdr;
860 struct pppoe_hdr *ph;
861 int headroom = skb_headroom(skb);
862 int data_len = skb->len;
863 struct sk_buff *skb2;
865 if (sock_flag(sk, SOCK_DEAD) || !(sk->sk_state & PPPOX_CONNECTED))
872 hdr.length = htons(skb->len);
877 /* Copy the skb if there is no space for the header. */
878 if (headroom < (sizeof(struct pppoe_hdr) + dev->hard_header_len)) {
879 skb2 = dev_alloc_skb(32+skb->len +
880 sizeof(struct pppoe_hdr) +
881 dev->hard_header_len);
886 skb_reserve(skb2, dev->hard_header_len + sizeof(struct pppoe_hdr));
887 memcpy(skb_put(skb2, skb->len), skb->data, skb->len);
889 /* Make a clone so as to not disturb the original skb,
890 * give dev_queue_xmit something it can free.
892 skb2 = skb_clone(skb, GFP_ATOMIC);
895 ph = (struct pppoe_hdr *) skb_push(skb2, sizeof(struct pppoe_hdr));
896 memcpy(ph, &hdr, sizeof(struct pppoe_hdr));
897 skb2->protocol = __constant_htons(ETH_P_PPP_SES);
899 skb2->nh.raw = skb2->data;
903 dev->hard_header(skb2, dev, ETH_P_PPP_SES,
904 po->pppoe_pa.remote, NULL, data_len);
906 /* We're transmitting skb2, and assuming that dev_queue_xmit
907 * will free it. The generic ppp layer however, is expecting
908 * that we give back 'skb' (not 'skb2') in case of failure,
909 * but free it in case of success.
912 if (dev_queue_xmit(skb2) < 0)
923 /************************************************************************
925 * xmit function called by generic PPP driver
926 * sends PPP frame over PPPoE socket
928 ***********************************************************************/
929 static int pppoe_xmit(struct ppp_channel *chan, struct sk_buff *skb)
931 struct sock *sk = (struct sock *) chan->private;
932 return __pppoe_xmit(sk, skb);
936 static struct ppp_channel_ops pppoe_chan_ops = {
937 .start_xmit = pppoe_xmit,
940 static int pppoe_recvmsg(struct kiocb *iocb, struct socket *sock,
941 struct msghdr *m, size_t total_len, int flags)
943 struct sock *sk = sock->sk;
944 struct sk_buff *skb = NULL;
947 struct pppoe_hdr *ph = NULL;
949 if (sk->sk_state & PPPOX_BOUND) {
954 skb = skb_recv_datagram(sk, flags & ~MSG_DONTWAIT,
955 flags & MSG_DONTWAIT, &error);
965 ph = (struct pppoe_hdr *) skb->nh.raw;
966 len = ntohs(ph->length);
968 error = memcpy_toiovec(m->msg_iov, (unsigned char *) &ph->tag[0], len);
981 #ifdef CONFIG_PROC_FS
982 static int pppoe_seq_show(struct seq_file *seq, void *v)
984 struct pppox_opt *po;
987 if (v == SEQ_START_TOKEN) {
988 seq_puts(seq, "Id Address Device\n");
993 dev_name = po->pppoe_pa.dev;
995 seq_printf(seq, "%08X %02X:%02X:%02X:%02X:%02X:%02X %8s\n",
997 po->pppoe_pa.remote[0], po->pppoe_pa.remote[1],
998 po->pppoe_pa.remote[2], po->pppoe_pa.remote[3],
999 po->pppoe_pa.remote[4], po->pppoe_pa.remote[5], dev_name);
1004 static __inline__ struct pppox_opt *pppoe_get_idx(loff_t pos)
1006 struct pppox_opt *po = NULL;
1009 for (; i < PPPOE_HASH_SIZE; i++) {
1010 po = item_hash_table[i];
1021 static void *pppoe_seq_start(struct seq_file *seq, loff_t *pos)
1025 read_lock_bh(&pppoe_hash_lock);
1026 return l ? pppoe_get_idx(--l) : SEQ_START_TOKEN;
1029 static void *pppoe_seq_next(struct seq_file *seq, void *v, loff_t *pos)
1031 struct pppox_opt *po;
1034 if (v == SEQ_START_TOKEN) {
1035 po = pppoe_get_idx(0);
1042 int hash = hash_item(po->pppoe_pa.sid, po->pppoe_pa.remote);
1044 while (++hash < PPPOE_HASH_SIZE) {
1045 po = item_hash_table[hash];
1054 static void pppoe_seq_stop(struct seq_file *seq, void *v)
1056 read_unlock_bh(&pppoe_hash_lock);
1059 struct seq_operations pppoe_seq_ops = {
1060 .start = pppoe_seq_start,
1061 .next = pppoe_seq_next,
1062 .stop = pppoe_seq_stop,
1063 .show = pppoe_seq_show,
1066 static int pppoe_seq_open(struct inode *inode, struct file *file)
1068 return seq_open(file, &pppoe_seq_ops);
1071 static struct file_operations pppoe_seq_fops = {
1072 .owner = THIS_MODULE,
1073 .open = pppoe_seq_open,
1075 .llseek = seq_lseek,
1076 .release = seq_release,
1079 static int __init pppoe_proc_init(void)
1081 struct proc_dir_entry *p;
1083 p = create_proc_entry("pppoe", S_IRUGO, proc_net);
1087 p->proc_fops = &pppoe_seq_fops;
1090 #else /* CONFIG_PROC_FS */
1091 static inline int pppoe_proc_init(void) { return 0; }
1092 #endif /* CONFIG_PROC_FS */
1094 /* ->ioctl are set at pppox_create */
1096 static struct proto_ops pppoe_ops = {
1098 .owner = THIS_MODULE,
1099 .release = pppoe_release,
1100 .bind = sock_no_bind,
1101 .connect = pppoe_connect,
1102 .socketpair = sock_no_socketpair,
1103 .accept = sock_no_accept,
1104 .getname = pppoe_getname,
1105 .poll = datagram_poll,
1106 .listen = sock_no_listen,
1107 .shutdown = sock_no_shutdown,
1108 .setsockopt = sock_no_setsockopt,
1109 .getsockopt = sock_no_getsockopt,
1110 .sendmsg = pppoe_sendmsg,
1111 .recvmsg = pppoe_recvmsg,
1112 .mmap = sock_no_mmap
1115 static struct pppox_proto pppoe_proto = {
1116 .create = pppoe_create,
1117 .ioctl = pppoe_ioctl,
1118 .owner = THIS_MODULE,
1122 static int __init pppoe_init(void)
1124 int err = register_pppox_proto(PX_PROTO_OE, &pppoe_proto);
1129 err = pppoe_proc_init();
1131 unregister_pppox_proto(PX_PROTO_OE);
1135 dev_add_pack(&pppoes_ptype);
1136 dev_add_pack(&pppoed_ptype);
1137 register_netdevice_notifier(&pppoe_notifier);
1142 static void __exit pppoe_exit(void)
1144 unregister_pppox_proto(PX_PROTO_OE);
1145 dev_remove_pack(&pppoes_ptype);
1146 dev_remove_pack(&pppoed_ptype);
1147 unregister_netdevice_notifier(&pppoe_notifier);
1148 remove_proc_entry("pppoe", proc_net);
1151 module_init(pppoe_init);
1152 module_exit(pppoe_exit);
1154 MODULE_AUTHOR("Michal Ostrowski <mostrows@speakeasy.net>");
1155 MODULE_DESCRIPTION("PPP over Ethernet driver");
1156 MODULE_LICENSE("GPL");
1157 MODULE_ALIAS_NETPROTO(PF_PPPOX);