cregit-Linux how code gets into the kernel

Release 4.11 drivers/net/ppp/pppox.c

Directory: drivers/net/ppp
/** -*- linux-c -*- ***********************************************************
 * Linux PPP over X/Ethernet (PPPoX/PPPoE) Sockets
 *
 * PPPoX --- Generic PPP encapsulation socket family
 * PPPoE --- PPP over Ethernet (RFC 2516)
 *
 *
 * Version:     0.5.2
 *
 * Author:      Michal Ostrowski <mostrows@speakeasy.net>
 *
 * 051000 :     Initialization cleanup
 *
 * License:
 *              This program is free software; you can redistribute it and/or
 *              modify it under the terms of the GNU General Public License
 *              as published by the Free Software Foundation; either version
 *              2 of the License, or (at your option) any later version.
 *
 */

#include <linux/string.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/errno.h>
#include <linux/netdevice.h>
#include <linux/net.h>
#include <linux/init.h>
#include <linux/if_pppox.h>
#include <linux/ppp_defs.h>
#include <linux/ppp-ioctl.h>
#include <linux/ppp_channel.h>
#include <linux/kmod.h>

#include <net/sock.h>

#include <linux/uaccess.h>


static const struct pppox_proto *pppox_protos[PX_MAX_PROTO + 1];


int register_pppox_proto(int proto_num, const struct pppox_proto *pp) { if (proto_num < 0 || proto_num > PX_MAX_PROTO) return -EINVAL; if (pppox_protos[proto_num]) return -EALREADY; pppox_protos[proto_num] = pp; return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)4693.88%133.33%
Arnaldo Carvalho de Melo24.08%133.33%
Eric Dumazet12.04%133.33%
Total49100.00%3100.00%


void unregister_pppox_proto(int proto_num) { if (proto_num >= 0 && proto_num <= PX_MAX_PROTO) pppox_protos[proto_num] = NULL; }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)2496.00%150.00%
Arnaldo Carvalho de Melo14.00%150.00%
Total25100.00%2100.00%


void pppox_unbind_sock(struct sock *sk) { /* Clear connection to ppp device, if attached. */ if (sk->sk_state & (PPPOX_BOUND | PPPOX_CONNECTED)) { ppp_unregister_channel(&pppox_sk(sk)->chan); sk->sk_state = PPPOX_DEAD; } }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)3173.81%120.00%
Michal Ostrowski511.90%120.00%
David S. Miller37.14%120.00%
Arnaldo Carvalho de Melo24.76%120.00%
Florian Zumbiehl12.38%120.00%
Total42100.00%5100.00%

EXPORT_SYMBOL(register_pppox_proto); EXPORT_SYMBOL(unregister_pppox_proto); EXPORT_SYMBOL(pppox_unbind_sock);
int pppox_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) { struct sock *sk = sock->sk; struct pppox_sock *po = pppox_sk(sk); int rc; lock_sock(sk); switch (cmd) { case PPPIOCGCHAN: { int index; rc = -ENOTCONN; if (!(sk->sk_state & PPPOX_CONNECTED)) break; rc = -EINVAL; index = ppp_channel_index(&po->chan); if (put_user(index , (int __user *) arg)) break; rc = 0; sk->sk_state |= PPPOX_BOUND; break; } default: rc = pppox_protos[sk->sk_protocol]->ioctl ? pppox_protos[sk->sk_protocol]->ioctl(sock, cmd, arg) : -ENOTTY; } release_sock(sk); return rc; }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)12882.05%114.29%
Arnaldo Carvalho de Melo1610.26%342.86%
Florian Zumbiehl63.85%114.29%
David S. Miller53.21%114.29%
Al Viro10.64%114.29%
Total156100.00%7100.00%

EXPORT_SYMBOL(pppox_ioctl);
static int pppox_create(struct net *net, struct socket *sock, int protocol, int kern) { int rc = -EPROTOTYPE; if (protocol < 0 || protocol > PX_MAX_PROTO) goto out; rc = -EPROTONOSUPPORT; if (!pppox_protos[protocol]) request_module("net-pf-%d-proto-%d", PF_PPPOX, protocol); if (!pppox_protos[protocol] || !try_module_get(pppox_protos[protocol]->owner)) goto out; rc = pppox_protos[protocol]->create(net, sock, kern); module_put(pppox_protos[protocol]->owner); out: return rc; }

Contributors

PersonTokensPropCommitsCommitProp
Arnaldo Carvalho de Melo4538.79%327.27%
Linus Torvalds (pre-git)4135.34%19.09%
James Chapman1311.21%19.09%
Eric W. Biedermann97.76%218.18%
Guillaume Nault32.59%19.09%
Eric Paris32.59%19.09%
Linus Torvalds10.86%19.09%
Johannes Berg10.86%19.09%
Total116100.00%11100.00%

static const struct net_proto_family pppox_proto_family = { .family = PF_PPPOX, .create = pppox_create, .owner = THIS_MODULE, };
static int __init pppox_init(void) { return sock_register(&pppox_proto_family); }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)1487.50%360.00%
Arnaldo Carvalho de Melo16.25%120.00%
Linus Torvalds16.25%120.00%
Total16100.00%5100.00%


static void __exit pppox_exit(void) { sock_unregister(PF_PPPOX); }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)1392.86%266.67%
Linus Torvalds17.14%133.33%
Total14100.00%3100.00%

module_init(pppox_init); module_exit(pppox_exit); MODULE_AUTHOR("Michal Ostrowski <mostrows@speakeasy.net>"); MODULE_DESCRIPTION("PPP over Ethernet driver (generic socket layer)"); MODULE_LICENSE("GPL"); MODULE_ALIAS_NETPROTO(PF_PPPOX);

Overall Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)37368.32%310.71%
Arnaldo Carvalho de Melo8515.57%725.00%
Linus Torvalds203.66%310.71%
James Chapman162.93%13.57%
David S. Miller132.38%27.14%
Eric W. Biedermann91.65%27.14%
Guillaume Nault81.47%13.57%
Florian Zumbiehl71.28%27.14%
Michal Ostrowski61.10%13.57%
Eric Paris30.55%13.57%
Eric Dumazet20.37%13.57%
Stephen Hemminger10.18%13.57%
Johannes Berg10.18%13.57%
Paul Mackerras10.18%13.57%
Al Viro10.18%13.57%
Total546100.00%28100.00%
Directory: drivers/net/ppp
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.
Created with cregit.