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;
89 static struct ppp_channel_ops pppoe_chan_ops;
91 static inline int cmp_2_addr(struct pppoe_addr *a, struct pppoe_addr *b)
93 return (a->sid == b->sid &&
94 (memcmp(a->remote, b->remote, ETH_ALEN) == 0));
97 static inline int cmp_addr(struct pppoe_addr *a, unsigned long sid, char *addr)
99 return (a->sid == sid &&
100 (memcmp(a->remote,addr,ETH_ALEN) == 0));
103 static int hash_item(unsigned long sid, unsigned char *addr)
108 for (i = 0; i < ETH_ALEN ; ++i) {
109 for (j = 0; j < 8/PPPOE_HASH_BITS ; ++j) {
110 hash ^= addr[i] >> ( j * PPPOE_HASH_BITS );
114 for (i = 0; i < (sizeof(unsigned long)*8) / PPPOE_HASH_BITS ; ++i)
115 hash ^= sid >> (i*PPPOE_HASH_BITS);
117 return hash & ( PPPOE_HASH_SIZE - 1 );
120 /* zeroed because its in .bss */
121 static struct pppox_opt *item_hash_table[PPPOE_HASH_SIZE];
123 /**********************************************************************
125 * Set/get/delete/rehash items (internal versions)
127 **********************************************************************/
128 static struct pppox_opt *__get_item(unsigned long sid, unsigned char *addr)
130 int hash = hash_item(sid, addr);
131 struct pppox_opt *ret;
133 ret = item_hash_table[hash];
135 while (ret && !cmp_addr(&ret->pppoe_pa, sid, addr))
141 static int __set_item(struct pppox_opt *po)
143 int hash = hash_item(po->pppoe_pa.sid, po->pppoe_pa.remote);
144 struct pppox_opt *ret;
146 ret = item_hash_table[hash];
148 if (cmp_2_addr(&ret->pppoe_pa, &po->pppoe_pa))
155 po->next = item_hash_table[hash];
156 item_hash_table[hash] = po;
162 static struct pppox_opt *__delete_item(unsigned long sid, char *addr)
164 int hash = hash_item(sid, addr);
165 struct pppox_opt *ret, **src;
167 ret = item_hash_table[hash];
168 src = &item_hash_table[hash];
171 if (cmp_addr(&ret->pppoe_pa, sid, addr)) {
183 /**********************************************************************
185 * Set/get/delete/rehash items
187 **********************************************************************/
188 static inline struct pppox_opt *get_item(unsigned long sid,
191 struct pppox_opt *po;
193 read_lock_bh(&pppoe_hash_lock);
194 po = __get_item(sid, addr);
197 read_unlock_bh(&pppoe_hash_lock);
202 static inline struct pppox_opt *get_item_by_addr(struct sockaddr_pppox *sp)
204 return get_item(sp->sa_addr.pppoe.sid, sp->sa_addr.pppoe.remote);
207 static inline int set_item(struct pppox_opt *po)
214 write_lock_bh(&pppoe_hash_lock);
216 write_unlock_bh(&pppoe_hash_lock);
221 static inline struct pppox_opt *delete_item(unsigned long sid, char *addr)
223 struct pppox_opt *ret;
225 write_lock_bh(&pppoe_hash_lock);
226 ret = __delete_item(sid, addr);
227 write_unlock_bh(&pppoe_hash_lock);
234 /***************************************************************************
236 * Handler for device events.
237 * Certain device events require that sockets be unconnected.
239 **************************************************************************/
241 static void pppoe_flush_dev(struct net_device *dev)
247 read_lock_bh(&pppoe_hash_lock);
248 for (hash = 0; hash < PPPOE_HASH_SIZE; hash++) {
249 struct pppox_opt *po = item_hash_table[hash];
252 if (po->pppoe_dev == dev) {
253 struct sock *sk = po->sk;
256 po->pppoe_dev = NULL;
258 /* We hold a reference to SK, now drop the
259 * hash table lock so that we may attempt
260 * to lock the socket (which can sleep).
262 read_unlock_bh(&pppoe_hash_lock);
267 (PPPOX_CONNECTED | PPPOX_BOUND)) {
268 pppox_unbind_sock(sk);
270 sk->sk_state = PPPOX_ZOMBIE;
271 sk->sk_state_change(sk);
278 read_lock_bh(&pppoe_hash_lock);
280 /* Now restart from the beginning of this
281 * hash chain. We always NULL out pppoe_dev
282 * so we are guaranteed to make forward
285 po = item_hash_table[hash];
291 read_unlock_bh(&pppoe_hash_lock);
294 static int pppoe_device_event(struct notifier_block *this,
295 unsigned long event, void *ptr)
297 struct net_device *dev = (struct net_device *) ptr;
299 /* Only look at sockets that are using this specific device. */
301 case NETDEV_CHANGEMTU:
302 /* A change in mtu is a bad thing, requiring
303 * LCP re-negotiation.
306 case NETDEV_GOING_DOWN:
308 /* Find every socket on this device and kill it. */
309 pppoe_flush_dev(dev);
320 static struct notifier_block pppoe_notifier = {
321 .notifier_call = pppoe_device_event,
325 /************************************************************************
327 * Do the real work of receiving a PPPoE Session frame.
329 ***********************************************************************/
330 static int pppoe_rcv_core(struct sock *sk, struct sk_buff *skb)
332 struct pppox_opt *po = pppox_sk(sk);
333 struct pppox_opt *relay_po = NULL;
335 if (sk->sk_state & PPPOX_BOUND) {
336 struct pppoe_hdr *ph = (struct pppoe_hdr *) skb->nh.raw;
337 int len = ntohs(ph->length);
338 skb_pull(skb, sizeof(struct pppoe_hdr));
341 ppp_input(&po->chan, skb);
342 } else if (sk->sk_state & PPPOX_RELAY) {
343 relay_po = get_item_by_addr(&po->pppoe_relay);
345 if (relay_po == NULL)
348 if ((relay_po->sk->sk_state & PPPOX_CONNECTED) == 0)
351 skb_pull(skb, sizeof(struct pppoe_hdr));
352 if (!__pppoe_xmit( relay_po->sk, skb))
355 if (sock_queue_rcv_skb(sk, skb))
359 return NET_RX_SUCCESS;
362 sock_put(relay_po->sk);
369 /************************************************************************
371 * Receive wrapper called in BH context.
373 ***********************************************************************/
374 static int pppoe_rcv(struct sk_buff *skb,
375 struct net_device *dev,
376 struct packet_type *pt)
379 struct pppoe_hdr *ph;
380 struct pppox_opt *po;
384 if (!pskb_may_pull(skb, sizeof(struct pppoe_hdr)))
387 if (!(skb = skb_share_check(skb, GFP_ATOMIC)))
390 ph = (struct pppoe_hdr *) skb->nh.raw;
392 po = get_item((unsigned long) ph->sid, skb->mac.ethernet->h_source);
399 /* Socket state is unknown, must put skb into backlog. */
400 if (sock_owned_by_user(sk) != 0) {
401 sk_add_backlog(sk, skb);
402 ret = NET_RX_SUCCESS;
404 ret = pppoe_rcv_core(sk, skb);
417 /************************************************************************
419 * Receive a PPPoE Discovery frame.
420 * This is solely for detection of PADT frames
422 ***********************************************************************/
423 static int pppoe_disc_rcv(struct sk_buff *skb,
424 struct net_device *dev,
425 struct packet_type *pt)
428 struct pppoe_hdr *ph;
429 struct pppox_opt *po;
431 if (!pskb_may_pull(skb, sizeof(struct pppoe_hdr)))
434 if (!(skb = skb_share_check(skb, GFP_ATOMIC)))
437 ph = (struct pppoe_hdr *) skb->nh.raw;
438 if (ph->code != PADT_CODE)
441 po = get_item((unsigned long) ph->sid, skb->mac.ethernet->h_source);
443 struct sock *sk = po->sk;
447 /* If the user has locked the socket, just ignore
448 * the packet. With the way two rcv protocols hook into
449 * one socket family type, we cannot (easily) distinguish
450 * what kind of SKB it is during backlog rcv.
452 if (sock_owned_by_user(sk) == 0) {
453 /* We're no longer connect at the PPPOE layer,
454 * and must wait for ppp channel to disconnect us.
456 sk->sk_state = PPPOX_ZOMBIE;
466 return NET_RX_SUCCESS; /* Lies... :-) */
469 static struct packet_type pppoes_ptype = {
470 .type = __constant_htons(ETH_P_PPP_SES),
474 static struct packet_type pppoed_ptype = {
475 .type = __constant_htons(ETH_P_PPP_DISC),
476 .func = pppoe_disc_rcv,
479 /***********************************************************************
481 * Really kill the socket. (Called from pppox_sk_free if refcnt == 0.)
483 **********************************************************************/
484 static void pppoe_sk_free(struct sock *sk)
486 struct pppox_opt *po = pppox_sk(sk);
493 /***********************************************************************
495 * Initialize a new struct sock.
497 **********************************************************************/
498 static int pppoe_create(struct socket *sock)
502 struct pppox_opt *po;
504 sk = sk_alloc(PF_PPPOX, GFP_KERNEL, 1, NULL);
508 sock_init_data(sock, sk);
509 sk_set_owner(sk, THIS_MODULE);
510 sock->state = SS_UNCONNECTED;
511 sock->ops = &pppoe_ops;
513 sk->sk_backlog_rcv = pppoe_rcv_core;
514 sk->sk_state = PPPOX_NONE;
515 sk->sk_type = SOCK_STREAM;
516 sk->sk_family = PF_PPPOX;
517 sk->sk_protocol = PX_PROTO_OE;
518 sk->sk_destruct = pppoe_sk_free;
520 po = sk->sk_protinfo = kmalloc(sizeof(*po), GFP_KERNEL);
523 memset(po, 0, sizeof(*po));
531 static int pppoe_release(struct socket *sock)
533 struct sock *sk = sock->sk;
534 struct pppox_opt *po;
540 if (sock_flag(sk, SOCK_DEAD))
543 pppox_unbind_sock(sk);
545 /* Signal the death of the socket. */
546 sk->sk_state = PPPOX_DEAD;
549 if (po->pppoe_pa.sid) {
550 delete_item(po->pppoe_pa.sid, po->pppoe_pa.remote);
554 dev_put(po->pppoe_dev);
556 po->pppoe_dev = NULL;
561 skb_queue_purge(&sk->sk_receive_queue);
568 static int pppoe_connect(struct socket *sock, struct sockaddr *uservaddr,
569 int sockaddr_len, int flags)
571 struct sock *sk = sock->sk;
572 struct net_device *dev = NULL;
573 struct sockaddr_pppox *sp = (struct sockaddr_pppox *) uservaddr;
574 struct pppox_opt *po = pppox_sk(sk);
580 if (sp->sa_protocol != PX_PROTO_OE)
583 /* Check for already bound sockets */
585 if ((sk->sk_state & PPPOX_CONNECTED) && sp->sa_addr.pppoe.sid)
588 /* Check for already disconnected sockets, on attempts to disconnect */
590 if ((sk->sk_state & PPPOX_DEAD) && !sp->sa_addr.pppoe.sid )
594 if (po->pppoe_pa.sid) {
595 pppox_unbind_sock(sk);
597 /* Delete the old binding */
598 delete_item(po->pppoe_pa.sid,po->pppoe_pa.remote);
601 dev_put(po->pppoe_dev);
603 memset(po, 0, sizeof(struct pppox_opt));
606 sk->sk_state = PPPOX_NONE;
609 /* Don't re-bind if sid==0 */
610 if (sp->sa_addr.pppoe.sid != 0) {
611 dev = dev_get_by_name(sp->sa_addr.pppoe.dev);
619 if (!(dev->flags & IFF_UP))
622 memcpy(&po->pppoe_pa,
624 sizeof(struct pppoe_addr));
626 error = set_item(po);
630 po->chan.hdrlen = (sizeof(struct pppoe_hdr) +
631 dev->hard_header_len);
633 po->chan.private = sk;
634 po->chan.ops = &pppoe_chan_ops;
636 error = ppp_register_channel(&po->chan);
640 sk->sk_state = PPPOX_CONNECTED;
643 po->num = sp->sa_addr.pppoe.sid;
650 dev_put(po->pppoe_dev);
651 po->pppoe_dev = NULL;
657 static int pppoe_getname(struct socket *sock, struct sockaddr *uaddr,
658 int *usockaddr_len, int peer)
660 int len = sizeof(struct sockaddr_pppox);
661 struct sockaddr_pppox sp;
663 sp.sa_family = AF_PPPOX;
664 sp.sa_protocol = PX_PROTO_OE;
665 memcpy(&sp.sa_addr.pppoe, &pppox_sk(sock->sk)->pppoe_pa,
666 sizeof(struct pppoe_addr));
668 memcpy(uaddr, &sp, len);
670 *usockaddr_len = len;
676 static int pppoe_ioctl(struct socket *sock, unsigned int cmd,
679 struct sock *sk = sock->sk;
680 struct pppox_opt *po = pppox_sk(sk);
688 if (!(sk->sk_state & PPPOX_CONNECTED))
692 if (put_user(po->pppoe_dev->mtu -
693 sizeof(struct pppoe_hdr) -
702 if (!(sk->sk_state & PPPOX_CONNECTED))
706 if (get_user(val,(int __user *) arg))
709 if (val < (po->pppoe_dev->mtu
710 - sizeof(struct pppoe_hdr)
719 if (get_user(val, (int __user *) arg))
726 struct pppox_opt *relay_po;
729 if (sk->sk_state & (PPPOX_BOUND | PPPOX_ZOMBIE | PPPOX_DEAD))
733 if (!(sk->sk_state & PPPOX_CONNECTED))
736 /* PPPoE address from the user specifies an outbound
737 PPPoE address to which frames are forwarded to */
739 if (copy_from_user(&po->pppoe_relay,
741 sizeof(struct sockaddr_pppox)))
745 if (po->pppoe_relay.sa_family != AF_PPPOX ||
746 po->pppoe_relay.sa_protocol!= PX_PROTO_OE)
749 /* Check that the socket referenced by the address
751 relay_po = get_item_by_addr(&po->pppoe_relay);
756 sock_put(relay_po->sk);
757 sk->sk_state |= PPPOX_RELAY;
764 if (!(sk->sk_state & PPPOX_RELAY))
767 sk->sk_state &= ~PPPOX_RELAY;
778 static int pppoe_sendmsg(struct kiocb *iocb, struct socket *sock,
779 struct msghdr *m, size_t total_len)
781 struct sk_buff *skb = NULL;
782 struct sock *sk = sock->sk;
783 struct pppox_opt *po = pppox_sk(sk);
785 struct pppoe_hdr hdr;
786 struct pppoe_hdr *ph;
787 struct net_device *dev;
790 if (sock_flag(sk, SOCK_DEAD) || !(sk->sk_state & PPPOX_CONNECTED)) {
805 if (total_len > (dev->mtu + dev->hard_header_len))
809 skb = sock_wmalloc(sk, total_len + dev->hard_header_len + 32,
816 /* Reserve space for headers. */
817 skb_reserve(skb, dev->hard_header_len);
818 skb->nh.raw = skb->data;
822 skb->priority = sk->sk_priority;
823 skb->protocol = __constant_htons(ETH_P_PPP_SES);
825 ph = (struct pppoe_hdr *) skb_put(skb, total_len + sizeof(struct pppoe_hdr));
826 start = (char *) &ph->tag[0];
828 error = memcpy_fromiovec(start, m->msg_iov, total_len);
836 dev->hard_header(skb, dev, ETH_P_PPP_SES,
837 po->pppoe_pa.remote, NULL, total_len);
839 memcpy(ph, &hdr, sizeof(struct pppoe_hdr));
841 ph->length = htons(total_len);
851 /************************************************************************
853 * xmit function for internal use.
855 ***********************************************************************/
856 static int __pppoe_xmit(struct sock *sk, struct sk_buff *skb)
858 struct pppox_opt *po = pppox_sk(sk);
859 struct net_device *dev = po->pppoe_dev;
860 struct pppoe_hdr hdr;
861 struct pppoe_hdr *ph;
862 int headroom = skb_headroom(skb);
863 int data_len = skb->len;
864 struct sk_buff *skb2;
866 if (sock_flag(sk, SOCK_DEAD) || !(sk->sk_state & PPPOX_CONNECTED))
873 hdr.length = htons(skb->len);
878 /* Copy the skb if there is no space for the header. */
879 if (headroom < (sizeof(struct pppoe_hdr) + dev->hard_header_len)) {
880 skb2 = dev_alloc_skb(32+skb->len +
881 sizeof(struct pppoe_hdr) +
882 dev->hard_header_len);
887 skb_reserve(skb2, dev->hard_header_len + sizeof(struct pppoe_hdr));
888 memcpy(skb_put(skb2, skb->len), skb->data, skb->len);
890 /* Make a clone so as to not disturb the original skb,
891 * give dev_queue_xmit something it can free.
893 skb2 = skb_clone(skb, GFP_ATOMIC);
896 ph = (struct pppoe_hdr *) skb_push(skb2, sizeof(struct pppoe_hdr));
897 memcpy(ph, &hdr, sizeof(struct pppoe_hdr));
898 skb2->protocol = __constant_htons(ETH_P_PPP_SES);
900 skb2->nh.raw = skb2->data;
904 dev->hard_header(skb2, dev, ETH_P_PPP_SES,
905 po->pppoe_pa.remote, NULL, data_len);
907 /* We're transmitting skb2, and assuming that dev_queue_xmit
908 * will free it. The generic ppp layer however, is expecting
909 * that we give back 'skb' (not 'skb2') in case of failure,
910 * but free it in case of success.
913 if (dev_queue_xmit(skb2) < 0)
924 /************************************************************************
926 * xmit function called by generic PPP driver
927 * sends PPP frame over PPPoE socket
929 ***********************************************************************/
930 static int pppoe_xmit(struct ppp_channel *chan, struct sk_buff *skb)
932 struct sock *sk = (struct sock *) chan->private;
933 return __pppoe_xmit(sk, skb);
937 static struct ppp_channel_ops pppoe_chan_ops = {
938 .start_xmit = pppoe_xmit,
941 static int pppoe_recvmsg(struct kiocb *iocb, struct socket *sock,
942 struct msghdr *m, size_t total_len, int flags)
944 struct sock *sk = sock->sk;
945 struct sk_buff *skb = NULL;
948 struct pppoe_hdr *ph = NULL;
950 if (sk->sk_state & PPPOX_BOUND) {
955 skb = skb_recv_datagram(sk, flags & ~MSG_DONTWAIT,
956 flags & MSG_DONTWAIT, &error);
966 ph = (struct pppoe_hdr *) skb->nh.raw;
967 len = ntohs(ph->length);
969 error = memcpy_toiovec(m->msg_iov, (unsigned char *) &ph->tag[0], len);
982 #ifdef CONFIG_PROC_FS
983 static int pppoe_seq_show(struct seq_file *seq, void *v)
985 struct pppox_opt *po;
988 if (v == SEQ_START_TOKEN) {
989 seq_puts(seq, "Id Address Device\n");
994 dev_name = po->pppoe_pa.dev;
996 seq_printf(seq, "%08X %02X:%02X:%02X:%02X:%02X:%02X %8s\n",
998 po->pppoe_pa.remote[0], po->pppoe_pa.remote[1],
999 po->pppoe_pa.remote[2], po->pppoe_pa.remote[3],
1000 po->pppoe_pa.remote[4], po->pppoe_pa.remote[5], dev_name);
1005 static __inline__ struct pppox_opt *pppoe_get_idx(loff_t pos)
1007 struct pppox_opt *po = NULL;
1010 for (; i < PPPOE_HASH_SIZE; i++) {
1011 po = item_hash_table[i];
1022 static void *pppoe_seq_start(struct seq_file *seq, loff_t *pos)
1026 read_lock_bh(&pppoe_hash_lock);
1027 return l ? pppoe_get_idx(--l) : SEQ_START_TOKEN;
1030 static void *pppoe_seq_next(struct seq_file *seq, void *v, loff_t *pos)
1032 struct pppox_opt *po;
1035 if (v == SEQ_START_TOKEN) {
1036 po = pppoe_get_idx(0);
1043 int hash = hash_item(po->pppoe_pa.sid, po->pppoe_pa.remote);
1045 while (++hash < PPPOE_HASH_SIZE) {
1046 po = item_hash_table[hash];
1055 static void pppoe_seq_stop(struct seq_file *seq, void *v)
1057 read_unlock_bh(&pppoe_hash_lock);
1060 struct seq_operations pppoe_seq_ops = {
1061 .start = pppoe_seq_start,
1062 .next = pppoe_seq_next,
1063 .stop = pppoe_seq_stop,
1064 .show = pppoe_seq_show,
1067 static int pppoe_seq_open(struct inode *inode, struct file *file)
1069 return seq_open(file, &pppoe_seq_ops);
1072 static struct file_operations pppoe_seq_fops = {
1073 .owner = THIS_MODULE,
1074 .open = pppoe_seq_open,
1076 .llseek = seq_lseek,
1077 .release = seq_release,
1080 static int __init pppoe_proc_init(void)
1082 struct proc_dir_entry *p;
1084 p = create_proc_entry("pppoe", S_IRUGO, proc_net);
1088 p->proc_fops = &pppoe_seq_fops;
1091 #else /* CONFIG_PROC_FS */
1092 static inline int pppoe_proc_init(void) { return 0; }
1093 #endif /* CONFIG_PROC_FS */
1095 /* ->ioctl are set at pppox_create */
1097 static struct proto_ops pppoe_ops = {
1099 .owner = THIS_MODULE,
1100 .release = pppoe_release,
1101 .bind = sock_no_bind,
1102 .connect = pppoe_connect,
1103 .socketpair = sock_no_socketpair,
1104 .accept = sock_no_accept,
1105 .getname = pppoe_getname,
1106 .poll = datagram_poll,
1107 .listen = sock_no_listen,
1108 .shutdown = sock_no_shutdown,
1109 .setsockopt = sock_no_setsockopt,
1110 .getsockopt = sock_no_getsockopt,
1111 .sendmsg = pppoe_sendmsg,
1112 .recvmsg = pppoe_recvmsg,
1113 .mmap = sock_no_mmap
1116 static struct pppox_proto pppoe_proto = {
1117 .create = pppoe_create,
1118 .ioctl = pppoe_ioctl,
1119 .owner = THIS_MODULE,
1123 static int __init pppoe_init(void)
1125 int err = register_pppox_proto(PX_PROTO_OE, &pppoe_proto);
1130 err = pppoe_proc_init();
1132 unregister_pppox_proto(PX_PROTO_OE);
1136 dev_add_pack(&pppoes_ptype);
1137 dev_add_pack(&pppoed_ptype);
1138 register_netdevice_notifier(&pppoe_notifier);
1143 static void __exit pppoe_exit(void)
1145 unregister_pppox_proto(PX_PROTO_OE);
1146 dev_remove_pack(&pppoes_ptype);
1147 dev_remove_pack(&pppoed_ptype);
1148 unregister_netdevice_notifier(&pppoe_notifier);
1149 remove_proc_entry("pppoe", proc_net);
1152 module_init(pppoe_init);
1153 module_exit(pppoe_exit);
1155 MODULE_AUTHOR("Michal Ostrowski <mostrows@speakeasy.net>");
1156 MODULE_DESCRIPTION("PPP over Ethernet driver");
1157 MODULE_LICENSE("GPL");
1158 MODULE_ALIAS_NETPROTO(PF_PPPOX);