2005-04-16 15:20:36 -07:00
|
|
|
/*
|
|
|
|
* Generic PPP layer for Linux.
|
|
|
|
*
|
|
|
|
* Copyright 1999-2002 Paul Mackerras.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* The generic PPP layer handles the PPP network interfaces, the
|
|
|
|
* /dev/ppp device, packet and VJ compression, and multilink.
|
|
|
|
* It talks to PPP `channels' via the interface defined in
|
|
|
|
* include/linux/ppp_channel.h. Channels provide the basic means for
|
|
|
|
* sending and receiving PPP frames on some kind of communications
|
|
|
|
* channel.
|
|
|
|
*
|
|
|
|
* Part of the code in this driver was inspired by the old async-only
|
|
|
|
* PPP driver, written by Michael Callahan and Al Longyear, and
|
|
|
|
* subsequently hacked by Paul Mackerras.
|
|
|
|
*
|
|
|
|
* ==FILEVERSION 20041108==
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/kmod.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/list.h>
|
2008-12-17 01:34:06 -07:00
|
|
|
#include <linux/idr.h>
|
2005-04-16 15:20:36 -07:00
|
|
|
#include <linux/netdevice.h>
|
|
|
|
#include <linux/poll.h>
|
|
|
|
#include <linux/ppp_defs.h>
|
|
|
|
#include <linux/filter.h>
|
|
|
|
#include <linux/if_ppp.h>
|
|
|
|
#include <linux/ppp_channel.h>
|
|
|
|
#include <linux/ppp-comp.h>
|
|
|
|
#include <linux/skbuff.h>
|
|
|
|
#include <linux/rtnetlink.h>
|
|
|
|
#include <linux/if_arp.h>
|
|
|
|
#include <linux/ip.h>
|
|
|
|
#include <linux/tcp.h>
|
2008-05-18 14:32:43 -07:00
|
|
|
#include <linux/smp_lock.h>
|
2005-04-16 15:20:36 -07:00
|
|
|
#include <linux/spinlock.h>
|
|
|
|
#include <linux/rwsem.h>
|
|
|
|
#include <linux/stddef.h>
|
|
|
|
#include <linux/device.h>
|
2006-03-23 04:00:21 -07:00
|
|
|
#include <linux/mutex.h>
|
2005-04-16 15:20:36 -07:00
|
|
|
#include <net/slhc_vj.h>
|
|
|
|
#include <asm/atomic.h>
|
|
|
|
|
2009-01-21 16:55:35 -07:00
|
|
|
#include <linux/nsproxy.h>
|
|
|
|
#include <net/net_namespace.h>
|
|
|
|
#include <net/netns/generic.h>
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
#define PPP_VERSION "2.4.2"
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Network protocols we support.
|
|
|
|
*/
|
|
|
|
#define NP_IP 0 /* Internet Protocol V4 */
|
|
|
|
#define NP_IPV6 1 /* Internet Protocol V6 */
|
|
|
|
#define NP_IPX 2 /* IPX protocol */
|
|
|
|
#define NP_AT 3 /* Appletalk protocol */
|
|
|
|
#define NP_MPLS_UC 4 /* MPLS unicast */
|
|
|
|
#define NP_MPLS_MC 5 /* MPLS multicast */
|
|
|
|
#define NUM_NP 6 /* Number of NPs. */
|
|
|
|
|
|
|
|
#define MPHDRLEN 6 /* multilink protocol header length */
|
|
|
|
#define MPHDRLEN_SSN 4 /* ditto with short sequence numbers */
|
|
|
|
#define MIN_FRAG_SIZE 64
|
|
|
|
|
|
|
|
/*
|
|
|
|
* An instance of /dev/ppp can be associated with either a ppp
|
|
|
|
* interface unit or a ppp channel. In both cases, file->private_data
|
|
|
|
* points to one of these.
|
|
|
|
*/
|
|
|
|
struct ppp_file {
|
|
|
|
enum {
|
|
|
|
INTERFACE=1, CHANNEL
|
|
|
|
} kind;
|
|
|
|
struct sk_buff_head xq; /* pppd transmit queue */
|
|
|
|
struct sk_buff_head rq; /* receive queue for pppd */
|
|
|
|
wait_queue_head_t rwait; /* for poll on reading /dev/ppp */
|
|
|
|
atomic_t refcnt; /* # refs (incl /dev/ppp attached) */
|
|
|
|
int hdrlen; /* space to leave for headers */
|
|
|
|
int index; /* interface unit / channel number */
|
|
|
|
int dead; /* unit/channel has been shut down */
|
|
|
|
};
|
|
|
|
|
2007-02-10 02:46:25 -07:00
|
|
|
#define PF_TO_X(pf, X) container_of(pf, X, file)
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
#define PF_TO_PPP(pf) PF_TO_X(pf, struct ppp)
|
|
|
|
#define PF_TO_CHANNEL(pf) PF_TO_X(pf, struct channel)
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Data structure describing one ppp unit.
|
|
|
|
* A ppp unit corresponds to a ppp network interface device
|
|
|
|
* and represents a multilink bundle.
|
|
|
|
* It can have 0 or more ppp channels connected to it.
|
|
|
|
*/
|
|
|
|
struct ppp {
|
|
|
|
struct ppp_file file; /* stuff for read/write/poll 0 */
|
|
|
|
struct file *owner; /* file that owns this unit 48 */
|
|
|
|
struct list_head channels; /* list of attached channels 4c */
|
|
|
|
int n_channels; /* how many channels are attached 54 */
|
|
|
|
spinlock_t rlock; /* lock for receive side 58 */
|
|
|
|
spinlock_t wlock; /* lock for transmit side 5c */
|
|
|
|
int mru; /* max receive unit 60 */
|
|
|
|
unsigned int flags; /* control bits 64 */
|
|
|
|
unsigned int xstate; /* transmit state bits 68 */
|
|
|
|
unsigned int rstate; /* receive state bits 6c */
|
|
|
|
int debug; /* debug flags 70 */
|
|
|
|
struct slcompress *vj; /* state for VJ header compression */
|
|
|
|
enum NPmode npmode[NUM_NP]; /* what to do with each net proto 78 */
|
|
|
|
struct sk_buff *xmit_pending; /* a packet ready to go out 88 */
|
|
|
|
struct compressor *xcomp; /* transmit packet compressor 8c */
|
|
|
|
void *xc_state; /* its internal state 90 */
|
|
|
|
struct compressor *rcomp; /* receive decompressor 94 */
|
|
|
|
void *rc_state; /* its internal state 98 */
|
|
|
|
unsigned long last_xmit; /* jiffies when last pkt sent 9c */
|
|
|
|
unsigned long last_recv; /* jiffies when last pkt rcvd a0 */
|
|
|
|
struct net_device *dev; /* network interface device a4 */
|
2008-12-17 05:02:16 -07:00
|
|
|
int closing; /* is device closing down? a8 */
|
2005-04-16 15:20:36 -07:00
|
|
|
#ifdef CONFIG_PPP_MULTILINK
|
|
|
|
int nxchan; /* next channel to send something on */
|
|
|
|
u32 nxseq; /* next sequence number to send */
|
|
|
|
int mrru; /* MP: max reconst. receive unit */
|
|
|
|
u32 nextseq; /* MP: seq no of next packet */
|
|
|
|
u32 minseq; /* MP: min of most recent seqnos */
|
|
|
|
struct sk_buff_head mrq; /* MP: receive reconstruction queue */
|
|
|
|
#endif /* CONFIG_PPP_MULTILINK */
|
|
|
|
#ifdef CONFIG_PPP_FILTER
|
|
|
|
struct sock_filter *pass_filter; /* filter for packets to pass */
|
|
|
|
struct sock_filter *active_filter;/* filter for pkts to reset idle */
|
|
|
|
unsigned pass_len, active_len;
|
|
|
|
#endif /* CONFIG_PPP_FILTER */
|
2009-01-21 16:55:35 -07:00
|
|
|
struct net *ppp_net; /* the net we belong to */
|
2005-04-16 15:20:36 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Bits in flags: SC_NO_TCP_CCID, SC_CCP_OPEN, SC_CCP_UP, SC_LOOP_TRAFFIC,
|
2005-11-08 10:40:47 -07:00
|
|
|
* SC_MULTILINK, SC_MP_SHORTSEQ, SC_MP_XSHORTSEQ, SC_COMP_TCP, SC_REJ_COMP_TCP,
|
|
|
|
* SC_MUST_COMP
|
2005-04-16 15:20:36 -07:00
|
|
|
* Bits in rstate: SC_DECOMP_RUN, SC_DC_ERROR, SC_DC_FERROR.
|
|
|
|
* Bits in xstate: SC_COMP_RUN
|
|
|
|
*/
|
|
|
|
#define SC_FLAG_BITS (SC_NO_TCP_CCID|SC_CCP_OPEN|SC_CCP_UP|SC_LOOP_TRAFFIC \
|
|
|
|
|SC_MULTILINK|SC_MP_SHORTSEQ|SC_MP_XSHORTSEQ \
|
2005-11-08 10:40:47 -07:00
|
|
|
|SC_COMP_TCP|SC_REJ_COMP_TCP|SC_MUST_COMP)
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Private data structure for each channel.
|
|
|
|
* This includes the data structure used for multilink.
|
|
|
|
*/
|
|
|
|
struct channel {
|
|
|
|
struct ppp_file file; /* stuff for read/write/poll */
|
|
|
|
struct list_head list; /* link in all/new_channels list */
|
|
|
|
struct ppp_channel *chan; /* public channel data structure */
|
|
|
|
struct rw_semaphore chan_sem; /* protects `chan' during chan ioctl */
|
|
|
|
spinlock_t downl; /* protects `chan', file.xq dequeue */
|
|
|
|
struct ppp *ppp; /* ppp unit we're connected to */
|
2009-01-21 16:55:35 -07:00
|
|
|
struct net *chan_net; /* the net channel belongs to */
|
2005-04-16 15:20:36 -07:00
|
|
|
struct list_head clist; /* link in list of channels per unit */
|
|
|
|
rwlock_t upl; /* protects `ppp' */
|
|
|
|
#ifdef CONFIG_PPP_MULTILINK
|
|
|
|
u8 avail; /* flag used in multilink stuff */
|
|
|
|
u8 had_frag; /* >= 1 fragments have been sent */
|
|
|
|
u32 lastseq; /* MP: last sequence # received */
|
ppp: ppp_mp_explode() redesign
I found the PPP subsystem to not work properly when connecting channels
with different speeds to the same bundle.
Problem Description:
As the "ppp_mp_explode" function fragments the sk_buff buffer evenly
among the PPP channels that are connected to a certain PPP unit to
make up a bundle, if we are transmitting using an upper layer protocol
that requires an Ack before sending the next packet (like TCP/IP for
example), we will have a bandwidth bottleneck on the slowest channel
of the bundle.
Let's clarify by an example. Let's consider a scenario where we have
two PPP links making up a bundle: a slow link (10KB/sec) and a fast
link (1000KB/sec) working at the best (full bandwidth). On the top we
have a TCP/IP stack sending a 1000 Bytes sk_buff buffer down to the
PPP subsystem. The "ppp_mp_explode" function will divide the buffer in
two fragments of 500B each (we are neglecting all the headers, crc,
flags etc?.). Before the TCP/IP stack sends out the next buffer, it
will have to wait for the ACK response from the remote peer, so it
will have to wait for both fragments to have been sent over the two
PPP links, received by the remote peer and reconstructed. The
resulting behaviour is that, rather than having a bundle working
@1010KB/sec (the sum of the channels bandwidths), we'll have a bundle
working @20KB/sec (the double of the slowest channels bandwidth).
Problem Solution:
The problem has been solved by redesigning the "ppp_mp_explode"
function in such a way to make it split the sk_buff buffer according
to the speeds of the underlying PPP channels (the speeds of the serial
interfaces respectively attached to the PPP channels). Referring to
the above example, the redesigned "ppp_mp_explode" function will now
divide the 1000 Bytes buffer into two fragments whose sizes are set
according to the speeds of the channels where they are going to be
sent on (e.g . 10 Byets on 10KB/sec channel and 990 Bytes on
1000KB/sec channel). The reworked function grants the same
performances of the original one in optimal working conditions (i.e. a
bundle made up of PPP links all working at the same speed), while
greatly improving performances on the bundles made up of channels
working at different speeds.
Signed-off-by: Gabriele Paoloni <gabriele.paoloni@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2009-03-13 16:09:12 -07:00
|
|
|
int speed; /* speed of the corresponding ppp channel*/
|
2005-04-16 15:20:36 -07:00
|
|
|
#endif /* CONFIG_PPP_MULTILINK */
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* SMP locking issues:
|
|
|
|
* Both the ppp.rlock and ppp.wlock locks protect the ppp.channels
|
|
|
|
* list and the ppp.n_channels field, you need to take both locks
|
|
|
|
* before you modify them.
|
|
|
|
* The lock ordering is: channel.upl -> ppp.wlock -> ppp.rlock ->
|
|
|
|
* channel.downl.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static atomic_t ppp_unit_count = ATOMIC_INIT(0);
|
|
|
|
static atomic_t channel_count = ATOMIC_INIT(0);
|
|
|
|
|
2009-01-21 16:55:35 -07:00
|
|
|
/* per-net private data for this module */
|
2009-02-14 04:13:52 -07:00
|
|
|
static int ppp_net_id;
|
2009-01-21 16:55:35 -07:00
|
|
|
struct ppp_net {
|
|
|
|
/* units to ppp mapping */
|
|
|
|
struct idr units_idr;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* all_ppp_mutex protects the units_idr mapping.
|
|
|
|
* It also ensures that finding a ppp unit in the units_idr
|
|
|
|
* map and updating its file.refcnt field is atomic.
|
|
|
|
*/
|
|
|
|
struct mutex all_ppp_mutex;
|
|
|
|
|
|
|
|
/* channels */
|
|
|
|
struct list_head all_channels;
|
|
|
|
struct list_head new_channels;
|
|
|
|
int last_channel_index;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* all_channels_lock protects all_channels and
|
|
|
|
* last_channel_index, and the atomicity of find
|
|
|
|
* a channel and updating its file.refcnt field.
|
|
|
|
*/
|
|
|
|
spinlock_t all_channels_lock;
|
|
|
|
};
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
/* Get the PPP protocol number from a skb */
|
|
|
|
#define PPP_PROTO(skb) (((skb)->data[0] << 8) + (skb)->data[1])
|
|
|
|
|
|
|
|
/* We limit the length of ppp->file.rq to this (arbitrary) value */
|
|
|
|
#define PPP_MAX_RQLEN 32
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Maximum number of multilink fragments queued up.
|
|
|
|
* This has to be large enough to cope with the maximum latency of
|
|
|
|
* the slowest channel relative to the others. Strictly it should
|
|
|
|
* depend on the number of channels and their characteristics.
|
|
|
|
*/
|
|
|
|
#define PPP_MP_MAX_QLEN 128
|
|
|
|
|
|
|
|
/* Multilink header bits. */
|
|
|
|
#define B 0x80 /* this fragment begins a packet */
|
|
|
|
#define E 0x40 /* this fragment ends a packet */
|
|
|
|
|
|
|
|
/* Compare multilink sequence numbers (assumed to be 32 bits wide) */
|
|
|
|
#define seq_before(a, b) ((s32)((a) - (b)) < 0)
|
|
|
|
#define seq_after(a, b) ((s32)((a) - (b)) > 0)
|
|
|
|
|
|
|
|
/* Prototypes. */
|
2009-01-21 16:55:35 -07:00
|
|
|
static int ppp_unattached_ioctl(struct net *net, struct ppp_file *pf,
|
|
|
|
struct file *file, unsigned int cmd, unsigned long arg);
|
2005-04-16 15:20:36 -07:00
|
|
|
static void ppp_xmit_process(struct ppp *ppp);
|
|
|
|
static void ppp_send_frame(struct ppp *ppp, struct sk_buff *skb);
|
|
|
|
static void ppp_push(struct ppp *ppp);
|
|
|
|
static void ppp_channel_push(struct channel *pch);
|
|
|
|
static void ppp_receive_frame(struct ppp *ppp, struct sk_buff *skb,
|
|
|
|
struct channel *pch);
|
|
|
|
static void ppp_receive_error(struct ppp *ppp);
|
|
|
|
static void ppp_receive_nonmp_frame(struct ppp *ppp, struct sk_buff *skb);
|
|
|
|
static struct sk_buff *ppp_decompress_frame(struct ppp *ppp,
|
|
|
|
struct sk_buff *skb);
|
|
|
|
#ifdef CONFIG_PPP_MULTILINK
|
|
|
|
static void ppp_receive_mp_frame(struct ppp *ppp, struct sk_buff *skb,
|
|
|
|
struct channel *pch);
|
|
|
|
static void ppp_mp_insert(struct ppp *ppp, struct sk_buff *skb);
|
|
|
|
static struct sk_buff *ppp_mp_reconstruct(struct ppp *ppp);
|
|
|
|
static int ppp_mp_explode(struct ppp *ppp, struct sk_buff *skb);
|
|
|
|
#endif /* CONFIG_PPP_MULTILINK */
|
|
|
|
static int ppp_set_compress(struct ppp *ppp, unsigned long arg);
|
|
|
|
static void ppp_ccp_peek(struct ppp *ppp, struct sk_buff *skb, int inbound);
|
|
|
|
static void ppp_ccp_closed(struct ppp *ppp);
|
|
|
|
static struct compressor *find_compressor(int type);
|
|
|
|
static void ppp_get_stats(struct ppp *ppp, struct ppp_stats *st);
|
2009-01-21 16:55:35 -07:00
|
|
|
static struct ppp *ppp_create_interface(struct net *net, int unit, int *retp);
|
2005-04-16 15:20:36 -07:00
|
|
|
static void init_ppp_file(struct ppp_file *pf, int kind);
|
|
|
|
static void ppp_shutdown_interface(struct ppp *ppp);
|
|
|
|
static void ppp_destroy_interface(struct ppp *ppp);
|
2009-01-21 16:55:35 -07:00
|
|
|
static struct ppp *ppp_find_unit(struct ppp_net *pn, int unit);
|
|
|
|
static struct channel *ppp_find_channel(struct ppp_net *pn, int unit);
|
2005-04-16 15:20:36 -07:00
|
|
|
static int ppp_connect_channel(struct channel *pch, int unit);
|
|
|
|
static int ppp_disconnect_channel(struct channel *pch);
|
|
|
|
static void ppp_destroy_channel(struct channel *pch);
|
2008-12-17 01:34:06 -07:00
|
|
|
static int unit_get(struct idr *p, void *ptr);
|
2009-01-12 23:11:56 -07:00
|
|
|
static int unit_set(struct idr *p, void *ptr, int n);
|
2008-12-17 01:34:06 -07:00
|
|
|
static void unit_put(struct idr *p, int n);
|
|
|
|
static void *unit_find(struct idr *p, int n);
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2005-03-23 11:01:41 -07:00
|
|
|
static struct class *ppp_class;
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2009-01-21 16:55:35 -07:00
|
|
|
/* per net-namespace data */
|
|
|
|
static inline struct ppp_net *ppp_pernet(struct net *net)
|
|
|
|
{
|
|
|
|
BUG_ON(!net);
|
|
|
|
|
|
|
|
return net_generic(net, ppp_net_id);
|
|
|
|
}
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
/* Translates a PPP protocol number to a NP index (NP == network protocol) */
|
|
|
|
static inline int proto_to_npindex(int proto)
|
|
|
|
{
|
|
|
|
switch (proto) {
|
|
|
|
case PPP_IP:
|
|
|
|
return NP_IP;
|
|
|
|
case PPP_IPV6:
|
|
|
|
return NP_IPV6;
|
|
|
|
case PPP_IPX:
|
|
|
|
return NP_IPX;
|
|
|
|
case PPP_AT:
|
|
|
|
return NP_AT;
|
|
|
|
case PPP_MPLS_UC:
|
|
|
|
return NP_MPLS_UC;
|
|
|
|
case PPP_MPLS_MC:
|
|
|
|
return NP_MPLS_MC;
|
|
|
|
}
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Translates an NP index into a PPP protocol number */
|
|
|
|
static const int npindex_to_proto[NUM_NP] = {
|
|
|
|
PPP_IP,
|
|
|
|
PPP_IPV6,
|
|
|
|
PPP_IPX,
|
|
|
|
PPP_AT,
|
|
|
|
PPP_MPLS_UC,
|
|
|
|
PPP_MPLS_MC,
|
|
|
|
};
|
2006-09-13 10:24:59 -07:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
/* Translates an ethertype into an NP index */
|
|
|
|
static inline int ethertype_to_npindex(int ethertype)
|
|
|
|
{
|
|
|
|
switch (ethertype) {
|
|
|
|
case ETH_P_IP:
|
|
|
|
return NP_IP;
|
|
|
|
case ETH_P_IPV6:
|
|
|
|
return NP_IPV6;
|
|
|
|
case ETH_P_IPX:
|
|
|
|
return NP_IPX;
|
|
|
|
case ETH_P_PPPTALK:
|
|
|
|
case ETH_P_ATALK:
|
|
|
|
return NP_AT;
|
|
|
|
case ETH_P_MPLS_UC:
|
|
|
|
return NP_MPLS_UC;
|
|
|
|
case ETH_P_MPLS_MC:
|
|
|
|
return NP_MPLS_MC;
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Translates an NP index into an ethertype */
|
|
|
|
static const int npindex_to_ethertype[NUM_NP] = {
|
|
|
|
ETH_P_IP,
|
|
|
|
ETH_P_IPV6,
|
|
|
|
ETH_P_IPX,
|
|
|
|
ETH_P_PPPTALK,
|
|
|
|
ETH_P_MPLS_UC,
|
|
|
|
ETH_P_MPLS_MC,
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Locking shorthand.
|
|
|
|
*/
|
|
|
|
#define ppp_xmit_lock(ppp) spin_lock_bh(&(ppp)->wlock)
|
|
|
|
#define ppp_xmit_unlock(ppp) spin_unlock_bh(&(ppp)->wlock)
|
|
|
|
#define ppp_recv_lock(ppp) spin_lock_bh(&(ppp)->rlock)
|
|
|
|
#define ppp_recv_unlock(ppp) spin_unlock_bh(&(ppp)->rlock)
|
|
|
|
#define ppp_lock(ppp) do { ppp_xmit_lock(ppp); \
|
|
|
|
ppp_recv_lock(ppp); } while (0)
|
|
|
|
#define ppp_unlock(ppp) do { ppp_recv_unlock(ppp); \
|
|
|
|
ppp_xmit_unlock(ppp); } while (0)
|
|
|
|
|
|
|
|
/*
|
|
|
|
* /dev/ppp device routines.
|
|
|
|
* The /dev/ppp device is used by pppd to control the ppp unit.
|
|
|
|
* It supports the read, write, ioctl and poll functions.
|
|
|
|
* Open instances of /dev/ppp can be in one of three states:
|
|
|
|
* unattached, attached to a ppp unit, or attached to a ppp channel.
|
|
|
|
*/
|
|
|
|
static int ppp_open(struct inode *inode, struct file *file)
|
|
|
|
{
|
2008-05-18 14:32:43 -07:00
|
|
|
cycle_kernel_lock();
|
2005-04-16 15:20:36 -07:00
|
|
|
/*
|
|
|
|
* This could (should?) be enforced by the permissions on /dev/ppp.
|
|
|
|
*/
|
|
|
|
if (!capable(CAP_NET_ADMIN))
|
|
|
|
return -EPERM;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-05-25 23:40:58 -07:00
|
|
|
static int ppp_release(struct inode *unused, struct file *file)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
|
|
|
struct ppp_file *pf = file->private_data;
|
|
|
|
struct ppp *ppp;
|
|
|
|
|
2007-11-12 19:07:31 -07:00
|
|
|
if (pf) {
|
2005-04-16 15:20:36 -07:00
|
|
|
file->private_data = NULL;
|
|
|
|
if (pf->kind == INTERFACE) {
|
|
|
|
ppp = PF_TO_PPP(pf);
|
|
|
|
if (file == ppp->owner)
|
|
|
|
ppp_shutdown_interface(ppp);
|
|
|
|
}
|
|
|
|
if (atomic_dec_and_test(&pf->refcnt)) {
|
|
|
|
switch (pf->kind) {
|
|
|
|
case INTERFACE:
|
|
|
|
ppp_destroy_interface(PF_TO_PPP(pf));
|
|
|
|
break;
|
|
|
|
case CHANNEL:
|
|
|
|
ppp_destroy_channel(PF_TO_CHANNEL(pf));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t ppp_read(struct file *file, char __user *buf,
|
|
|
|
size_t count, loff_t *ppos)
|
|
|
|
{
|
|
|
|
struct ppp_file *pf = file->private_data;
|
|
|
|
DECLARE_WAITQUEUE(wait, current);
|
|
|
|
ssize_t ret;
|
|
|
|
struct sk_buff *skb = NULL;
|
|
|
|
|
|
|
|
ret = count;
|
|
|
|
|
2007-11-12 19:07:31 -07:00
|
|
|
if (!pf)
|
2005-04-16 15:20:36 -07:00
|
|
|
return -ENXIO;
|
|
|
|
add_wait_queue(&pf->rwait, &wait);
|
|
|
|
for (;;) {
|
|
|
|
set_current_state(TASK_INTERRUPTIBLE);
|
|
|
|
skb = skb_dequeue(&pf->rq);
|
|
|
|
if (skb)
|
|
|
|
break;
|
|
|
|
ret = 0;
|
|
|
|
if (pf->dead)
|
|
|
|
break;
|
|
|
|
if (pf->kind == INTERFACE) {
|
|
|
|
/*
|
|
|
|
* Return 0 (EOF) on an interface that has no
|
|
|
|
* channels connected, unless it is looping
|
|
|
|
* network traffic (demand mode).
|
|
|
|
*/
|
|
|
|
struct ppp *ppp = PF_TO_PPP(pf);
|
|
|
|
if (ppp->n_channels == 0
|
|
|
|
&& (ppp->flags & SC_LOOP_TRAFFIC) == 0)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
ret = -EAGAIN;
|
|
|
|
if (file->f_flags & O_NONBLOCK)
|
|
|
|
break;
|
|
|
|
ret = -ERESTARTSYS;
|
|
|
|
if (signal_pending(current))
|
|
|
|
break;
|
|
|
|
schedule();
|
|
|
|
}
|
|
|
|
set_current_state(TASK_RUNNING);
|
|
|
|
remove_wait_queue(&pf->rwait, &wait);
|
|
|
|
|
2007-11-12 19:07:31 -07:00
|
|
|
if (!skb)
|
2005-04-16 15:20:36 -07:00
|
|
|
goto out;
|
|
|
|
|
|
|
|
ret = -EOVERFLOW;
|
|
|
|
if (skb->len > count)
|
|
|
|
goto outf;
|
|
|
|
ret = -EFAULT;
|
|
|
|
if (copy_to_user(buf, skb->data, skb->len))
|
|
|
|
goto outf;
|
|
|
|
ret = skb->len;
|
|
|
|
|
|
|
|
outf:
|
|
|
|
kfree_skb(skb);
|
|
|
|
out:
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t ppp_write(struct file *file, const char __user *buf,
|
|
|
|
size_t count, loff_t *ppos)
|
|
|
|
{
|
|
|
|
struct ppp_file *pf = file->private_data;
|
|
|
|
struct sk_buff *skb;
|
|
|
|
ssize_t ret;
|
|
|
|
|
2007-11-12 19:07:31 -07:00
|
|
|
if (!pf)
|
2005-04-16 15:20:36 -07:00
|
|
|
return -ENXIO;
|
|
|
|
ret = -ENOMEM;
|
|
|
|
skb = alloc_skb(count + pf->hdrlen, GFP_KERNEL);
|
2007-11-12 19:07:31 -07:00
|
|
|
if (!skb)
|
2005-04-16 15:20:36 -07:00
|
|
|
goto out;
|
|
|
|
skb_reserve(skb, pf->hdrlen);
|
|
|
|
ret = -EFAULT;
|
|
|
|
if (copy_from_user(skb_put(skb, count), buf, count)) {
|
|
|
|
kfree_skb(skb);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
skb_queue_tail(&pf->xq, skb);
|
|
|
|
|
|
|
|
switch (pf->kind) {
|
|
|
|
case INTERFACE:
|
|
|
|
ppp_xmit_process(PF_TO_PPP(pf));
|
|
|
|
break;
|
|
|
|
case CHANNEL:
|
|
|
|
ppp_channel_push(PF_TO_CHANNEL(pf));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = count;
|
|
|
|
|
|
|
|
out:
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* No kernel lock - fine */
|
|
|
|
static unsigned int ppp_poll(struct file *file, poll_table *wait)
|
|
|
|
{
|
|
|
|
struct ppp_file *pf = file->private_data;
|
|
|
|
unsigned int mask;
|
|
|
|
|
2007-11-12 19:07:31 -07:00
|
|
|
if (!pf)
|
2005-04-16 15:20:36 -07:00
|
|
|
return 0;
|
|
|
|
poll_wait(file, &pf->rwait, wait);
|
|
|
|
mask = POLLOUT | POLLWRNORM;
|
2007-11-12 19:07:31 -07:00
|
|
|
if (skb_peek(&pf->rq))
|
2005-04-16 15:20:36 -07:00
|
|
|
mask |= POLLIN | POLLRDNORM;
|
|
|
|
if (pf->dead)
|
|
|
|
mask |= POLLHUP;
|
|
|
|
else if (pf->kind == INTERFACE) {
|
|
|
|
/* see comment in ppp_read */
|
|
|
|
struct ppp *ppp = PF_TO_PPP(pf);
|
|
|
|
if (ppp->n_channels == 0
|
|
|
|
&& (ppp->flags & SC_LOOP_TRAFFIC) == 0)
|
|
|
|
mask |= POLLIN | POLLRDNORM;
|
|
|
|
}
|
|
|
|
|
|
|
|
return mask;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef CONFIG_PPP_FILTER
|
|
|
|
static int get_filter(void __user *arg, struct sock_filter **p)
|
|
|
|
{
|
|
|
|
struct sock_fprog uprog;
|
|
|
|
struct sock_filter *code = NULL;
|
|
|
|
int len, err;
|
|
|
|
|
|
|
|
if (copy_from_user(&uprog, arg, sizeof(uprog)))
|
|
|
|
return -EFAULT;
|
|
|
|
|
|
|
|
if (!uprog.len) {
|
|
|
|
*p = NULL;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
len = uprog.len * sizeof(struct sock_filter);
|
|
|
|
code = kmalloc(len, GFP_KERNEL);
|
|
|
|
if (code == NULL)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
if (copy_from_user(code, uprog.filter, len)) {
|
|
|
|
kfree(code);
|
|
|
|
return -EFAULT;
|
|
|
|
}
|
|
|
|
|
|
|
|
err = sk_chk_filter(code, uprog.len);
|
|
|
|
if (err) {
|
|
|
|
kfree(code);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
*p = code;
|
|
|
|
return uprog.len;
|
|
|
|
}
|
|
|
|
#endif /* CONFIG_PPP_FILTER */
|
|
|
|
|
2008-05-25 23:40:58 -07:00
|
|
|
static long ppp_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
|
|
|
struct ppp_file *pf = file->private_data;
|
|
|
|
struct ppp *ppp;
|
|
|
|
int err = -EFAULT, val, val2, i;
|
|
|
|
struct ppp_idle idle;
|
|
|
|
struct npioctl npi;
|
|
|
|
int unit, cflags;
|
|
|
|
struct slcompress *vj;
|
|
|
|
void __user *argp = (void __user *)arg;
|
|
|
|
int __user *p = argp;
|
|
|
|
|
2007-11-12 19:07:31 -07:00
|
|
|
if (!pf)
|
2009-01-21 16:55:35 -07:00
|
|
|
return ppp_unattached_ioctl(current->nsproxy->net_ns,
|
|
|
|
pf, file, cmd, arg);
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
if (cmd == PPPIOCDETACH) {
|
|
|
|
/*
|
|
|
|
* We have to be careful here... if the file descriptor
|
|
|
|
* has been dup'd, we could have another process in the
|
|
|
|
* middle of a poll using the same file *, so we had
|
|
|
|
* better not free the interface data structures -
|
|
|
|
* instead we fail the ioctl. Even in this case, we
|
|
|
|
* shut down the interface if we are the owner of it.
|
|
|
|
* Actually, we should get rid of PPPIOCDETACH, userland
|
|
|
|
* (i.e. pppd) could achieve the same effect by closing
|
|
|
|
* this fd and reopening /dev/ppp.
|
|
|
|
*/
|
|
|
|
err = -EINVAL;
|
2008-05-25 23:40:58 -07:00
|
|
|
lock_kernel();
|
2005-04-16 15:20:36 -07:00
|
|
|
if (pf->kind == INTERFACE) {
|
|
|
|
ppp = PF_TO_PPP(pf);
|
|
|
|
if (file == ppp->owner)
|
|
|
|
ppp_shutdown_interface(ppp);
|
|
|
|
}
|
2008-07-25 21:39:17 -07:00
|
|
|
if (atomic_long_read(&file->f_count) <= 2) {
|
2008-05-25 23:40:58 -07:00
|
|
|
ppp_release(NULL, file);
|
2005-04-16 15:20:36 -07:00
|
|
|
err = 0;
|
|
|
|
} else
|
2008-07-25 21:39:17 -07:00
|
|
|
printk(KERN_DEBUG "PPPIOCDETACH file->f_count=%ld\n",
|
|
|
|
atomic_long_read(&file->f_count));
|
2008-05-25 23:40:58 -07:00
|
|
|
unlock_kernel();
|
2005-04-16 15:20:36 -07:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pf->kind == CHANNEL) {
|
2008-05-25 23:40:58 -07:00
|
|
|
struct channel *pch;
|
2005-04-16 15:20:36 -07:00
|
|
|
struct ppp_channel *chan;
|
|
|
|
|
2008-05-25 23:40:58 -07:00
|
|
|
lock_kernel();
|
|
|
|
pch = PF_TO_CHANNEL(pf);
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
switch (cmd) {
|
|
|
|
case PPPIOCCONNECT:
|
|
|
|
if (get_user(unit, p))
|
|
|
|
break;
|
|
|
|
err = ppp_connect_channel(pch, unit);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PPPIOCDISCONN:
|
|
|
|
err = ppp_disconnect_channel(pch);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
down_read(&pch->chan_sem);
|
|
|
|
chan = pch->chan;
|
|
|
|
err = -ENOTTY;
|
|
|
|
if (chan && chan->ops->ioctl)
|
|
|
|
err = chan->ops->ioctl(chan, cmd, arg);
|
|
|
|
up_read(&pch->chan_sem);
|
|
|
|
}
|
2008-05-25 23:40:58 -07:00
|
|
|
unlock_kernel();
|
2005-04-16 15:20:36 -07:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pf->kind != INTERFACE) {
|
|
|
|
/* can't happen */
|
|
|
|
printk(KERN_ERR "PPP: not interface or channel??\n");
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2008-05-25 23:40:58 -07:00
|
|
|
lock_kernel();
|
2005-04-16 15:20:36 -07:00
|
|
|
ppp = PF_TO_PPP(pf);
|
|
|
|
switch (cmd) {
|
|
|
|
case PPPIOCSMRU:
|
|
|
|
if (get_user(val, p))
|
|
|
|
break;
|
|
|
|
ppp->mru = val;
|
|
|
|
err = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PPPIOCSFLAGS:
|
|
|
|
if (get_user(val, p))
|
|
|
|
break;
|
|
|
|
ppp_lock(ppp);
|
|
|
|
cflags = ppp->flags & ~val;
|
|
|
|
ppp->flags = val & SC_FLAG_BITS;
|
|
|
|
ppp_unlock(ppp);
|
|
|
|
if (cflags & SC_CCP_OPEN)
|
|
|
|
ppp_ccp_closed(ppp);
|
|
|
|
err = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PPPIOCGFLAGS:
|
|
|
|
val = ppp->flags | ppp->xstate | ppp->rstate;
|
|
|
|
if (put_user(val, p))
|
|
|
|
break;
|
|
|
|
err = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PPPIOCSCOMPRESS:
|
|
|
|
err = ppp_set_compress(ppp, arg);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PPPIOCGUNIT:
|
|
|
|
if (put_user(ppp->file.index, p))
|
|
|
|
break;
|
|
|
|
err = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PPPIOCSDEBUG:
|
|
|
|
if (get_user(val, p))
|
|
|
|
break;
|
|
|
|
ppp->debug = val;
|
|
|
|
err = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PPPIOCGDEBUG:
|
|
|
|
if (put_user(ppp->debug, p))
|
|
|
|
break;
|
|
|
|
err = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PPPIOCGIDLE:
|
|
|
|
idle.xmit_idle = (jiffies - ppp->last_xmit) / HZ;
|
|
|
|
idle.recv_idle = (jiffies - ppp->last_recv) / HZ;
|
|
|
|
if (copy_to_user(argp, &idle, sizeof(idle)))
|
|
|
|
break;
|
|
|
|
err = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PPPIOCSMAXCID:
|
|
|
|
if (get_user(val, p))
|
|
|
|
break;
|
|
|
|
val2 = 15;
|
|
|
|
if ((val >> 16) != 0) {
|
|
|
|
val2 = val >> 16;
|
|
|
|
val &= 0xffff;
|
|
|
|
}
|
|
|
|
vj = slhc_init(val2+1, val+1);
|
2007-11-12 19:07:31 -07:00
|
|
|
if (!vj) {
|
2005-04-16 15:20:36 -07:00
|
|
|
printk(KERN_ERR "PPP: no memory (VJ compressor)\n");
|
|
|
|
err = -ENOMEM;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
ppp_lock(ppp);
|
2007-11-12 19:07:31 -07:00
|
|
|
if (ppp->vj)
|
2005-04-16 15:20:36 -07:00
|
|
|
slhc_free(ppp->vj);
|
|
|
|
ppp->vj = vj;
|
|
|
|
ppp_unlock(ppp);
|
|
|
|
err = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PPPIOCGNPMODE:
|
|
|
|
case PPPIOCSNPMODE:
|
|
|
|
if (copy_from_user(&npi, argp, sizeof(npi)))
|
|
|
|
break;
|
|
|
|
err = proto_to_npindex(npi.protocol);
|
|
|
|
if (err < 0)
|
|
|
|
break;
|
|
|
|
i = err;
|
|
|
|
if (cmd == PPPIOCGNPMODE) {
|
|
|
|
err = -EFAULT;
|
|
|
|
npi.mode = ppp->npmode[i];
|
|
|
|
if (copy_to_user(argp, &npi, sizeof(npi)))
|
|
|
|
break;
|
|
|
|
} else {
|
|
|
|
ppp->npmode[i] = npi.mode;
|
|
|
|
/* we may be able to transmit more packets now (??) */
|
|
|
|
netif_wake_queue(ppp->dev);
|
|
|
|
}
|
|
|
|
err = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
#ifdef CONFIG_PPP_FILTER
|
|
|
|
case PPPIOCSPASS:
|
|
|
|
{
|
|
|
|
struct sock_filter *code;
|
|
|
|
err = get_filter(argp, &code);
|
|
|
|
if (err >= 0) {
|
|
|
|
ppp_lock(ppp);
|
|
|
|
kfree(ppp->pass_filter);
|
|
|
|
ppp->pass_filter = code;
|
|
|
|
ppp->pass_len = err;
|
|
|
|
ppp_unlock(ppp);
|
|
|
|
err = 0;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case PPPIOCSACTIVE:
|
|
|
|
{
|
|
|
|
struct sock_filter *code;
|
|
|
|
err = get_filter(argp, &code);
|
|
|
|
if (err >= 0) {
|
|
|
|
ppp_lock(ppp);
|
|
|
|
kfree(ppp->active_filter);
|
|
|
|
ppp->active_filter = code;
|
|
|
|
ppp->active_len = err;
|
|
|
|
ppp_unlock(ppp);
|
|
|
|
err = 0;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
#endif /* CONFIG_PPP_FILTER */
|
|
|
|
|
|
|
|
#ifdef CONFIG_PPP_MULTILINK
|
|
|
|
case PPPIOCSMRRU:
|
|
|
|
if (get_user(val, p))
|
|
|
|
break;
|
|
|
|
ppp_recv_lock(ppp);
|
|
|
|
ppp->mrru = val;
|
|
|
|
ppp_recv_unlock(ppp);
|
|
|
|
err = 0;
|
|
|
|
break;
|
|
|
|
#endif /* CONFIG_PPP_MULTILINK */
|
|
|
|
|
|
|
|
default:
|
|
|
|
err = -ENOTTY;
|
|
|
|
}
|
2008-05-25 23:40:58 -07:00
|
|
|
unlock_kernel();
|
2005-04-16 15:20:36 -07:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2009-01-21 16:55:35 -07:00
|
|
|
static int ppp_unattached_ioctl(struct net *net, struct ppp_file *pf,
|
|
|
|
struct file *file, unsigned int cmd, unsigned long arg)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
|
|
|
int unit, err = -EFAULT;
|
|
|
|
struct ppp *ppp;
|
|
|
|
struct channel *chan;
|
2009-01-21 16:55:35 -07:00
|
|
|
struct ppp_net *pn;
|
2005-04-16 15:20:36 -07:00
|
|
|
int __user *p = (int __user *)arg;
|
|
|
|
|
2008-05-25 23:40:58 -07:00
|
|
|
lock_kernel();
|
2005-04-16 15:20:36 -07:00
|
|
|
switch (cmd) {
|
|
|
|
case PPPIOCNEWUNIT:
|
|
|
|
/* Create a new ppp unit */
|
|
|
|
if (get_user(unit, p))
|
|
|
|
break;
|
2009-01-21 16:55:35 -07:00
|
|
|
ppp = ppp_create_interface(net, unit, &err);
|
2007-11-12 19:07:31 -07:00
|
|
|
if (!ppp)
|
2005-04-16 15:20:36 -07:00
|
|
|
break;
|
|
|
|
file->private_data = &ppp->file;
|
|
|
|
ppp->owner = file;
|
|
|
|
err = -EFAULT;
|
|
|
|
if (put_user(ppp->file.index, p))
|
|
|
|
break;
|
|
|
|
err = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PPPIOCATTACH:
|
|
|
|
/* Attach to an existing ppp unit */
|
|
|
|
if (get_user(unit, p))
|
|
|
|
break;
|
|
|
|
err = -ENXIO;
|
2009-01-21 16:55:35 -07:00
|
|
|
pn = ppp_pernet(net);
|
|
|
|
mutex_lock(&pn->all_ppp_mutex);
|
|
|
|
ppp = ppp_find_unit(pn, unit);
|
2007-11-12 19:07:31 -07:00
|
|
|
if (ppp) {
|
2005-04-16 15:20:36 -07:00
|
|
|
atomic_inc(&ppp->file.refcnt);
|
|
|
|
file->private_data = &ppp->file;
|
|
|
|
err = 0;
|
|
|
|
}
|
2009-01-21 16:55:35 -07:00
|
|
|
mutex_unlock(&pn->all_ppp_mutex);
|
2005-04-16 15:20:36 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PPPIOCATTCHAN:
|
|
|
|
if (get_user(unit, p))
|
|
|
|
break;
|
|
|
|
err = -ENXIO;
|
2009-01-21 16:55:35 -07:00
|
|
|
pn = ppp_pernet(net);
|
|
|
|
spin_lock_bh(&pn->all_channels_lock);
|
|
|
|
chan = ppp_find_channel(pn, unit);
|
2007-11-12 19:07:31 -07:00
|
|
|
if (chan) {
|
2005-04-16 15:20:36 -07:00
|
|
|
atomic_inc(&chan->file.refcnt);
|
|
|
|
file->private_data = &chan->file;
|
|
|
|
err = 0;
|
|
|
|
}
|
2009-01-21 16:55:35 -07:00
|
|
|
spin_unlock_bh(&pn->all_channels_lock);
|
2005-04-16 15:20:36 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
err = -ENOTTY;
|
|
|
|
}
|
2008-05-25 23:40:58 -07:00
|
|
|
unlock_kernel();
|
2005-04-16 15:20:36 -07:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2007-02-12 01:55:34 -07:00
|
|
|
static const struct file_operations ppp_device_fops = {
|
2005-04-16 15:20:36 -07:00
|
|
|
.owner = THIS_MODULE,
|
|
|
|
.read = ppp_read,
|
|
|
|
.write = ppp_write,
|
|
|
|
.poll = ppp_poll,
|
2008-05-25 23:40:58 -07:00
|
|
|
.unlocked_ioctl = ppp_ioctl,
|
2005-04-16 15:20:36 -07:00
|
|
|
.open = ppp_open,
|
|
|
|
.release = ppp_release
|
|
|
|
};
|
|
|
|
|
2009-01-21 16:55:35 -07:00
|
|
|
static __net_init int ppp_init_net(struct net *net)
|
|
|
|
{
|
|
|
|
struct ppp_net *pn;
|
|
|
|
int err;
|
|
|
|
|
|
|
|
pn = kzalloc(sizeof(*pn), GFP_KERNEL);
|
|
|
|
if (!pn)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
idr_init(&pn->units_idr);
|
|
|
|
mutex_init(&pn->all_ppp_mutex);
|
|
|
|
|
|
|
|
INIT_LIST_HEAD(&pn->all_channels);
|
|
|
|
INIT_LIST_HEAD(&pn->new_channels);
|
|
|
|
|
|
|
|
spin_lock_init(&pn->all_channels_lock);
|
|
|
|
|
|
|
|
err = net_assign_generic(net, ppp_net_id, pn);
|
|
|
|
if (err) {
|
|
|
|
kfree(pn);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static __net_exit void ppp_exit_net(struct net *net)
|
|
|
|
{
|
|
|
|
struct ppp_net *pn;
|
|
|
|
|
|
|
|
pn = net_generic(net, ppp_net_id);
|
|
|
|
idr_destroy(&pn->units_idr);
|
|
|
|
/*
|
|
|
|
* if someone has cached our net then
|
|
|
|
* further net_generic call will return NULL
|
|
|
|
*/
|
|
|
|
net_assign_generic(net, ppp_net_id, NULL);
|
|
|
|
kfree(pn);
|
|
|
|
}
|
|
|
|
|
2009-02-09 19:05:16 -07:00
|
|
|
static struct pernet_operations ppp_net_ops = {
|
2009-01-21 16:55:35 -07:00
|
|
|
.init = ppp_init_net,
|
|
|
|
.exit = ppp_exit_net,
|
|
|
|
};
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
#define PPP_MAJOR 108
|
|
|
|
|
|
|
|
/* Called at boot time if ppp is compiled into the kernel,
|
|
|
|
or at module load time (from init_module) if compiled as a module. */
|
|
|
|
static int __init ppp_init(void)
|
|
|
|
{
|
|
|
|
int err;
|
|
|
|
|
|
|
|
printk(KERN_INFO "PPP generic driver version " PPP_VERSION "\n");
|
2009-01-21 16:55:35 -07:00
|
|
|
|
|
|
|
err = register_pernet_gen_device(&ppp_net_id, &ppp_net_ops);
|
|
|
|
if (err) {
|
|
|
|
printk(KERN_ERR "failed to register PPP pernet device (%d)\n", err);
|
|
|
|
goto out;
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
|
|
|
|
2009-01-21 16:55:35 -07:00
|
|
|
err = register_chrdev(PPP_MAJOR, "ppp", &ppp_device_fops);
|
|
|
|
if (err) {
|
2005-04-16 15:20:36 -07:00
|
|
|
printk(KERN_ERR "failed to register PPP device (%d)\n", err);
|
2009-01-21 16:55:35 -07:00
|
|
|
goto out_net;
|
|
|
|
}
|
|
|
|
|
|
|
|
ppp_class = class_create(THIS_MODULE, "ppp");
|
|
|
|
if (IS_ERR(ppp_class)) {
|
|
|
|
err = PTR_ERR(ppp_class);
|
|
|
|
goto out_chrdev;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* not a big deal if we fail here :-) */
|
|
|
|
device_create(ppp_class, NULL, MKDEV(PPP_MAJOR, 0), NULL, "ppp");
|
|
|
|
|
|
|
|
return 0;
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
out_chrdev:
|
|
|
|
unregister_chrdev(PPP_MAJOR, "ppp");
|
2009-01-21 16:55:35 -07:00
|
|
|
out_net:
|
|
|
|
unregister_pernet_gen_device(ppp_net_id, &ppp_net_ops);
|
|
|
|
out:
|
|
|
|
return err;
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Network interface unit routines.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
ppp_start_xmit(struct sk_buff *skb, struct net_device *dev)
|
|
|
|
{
|
2008-11-20 05:24:17 -07:00
|
|
|
struct ppp *ppp = netdev_priv(dev);
|
2005-04-16 15:20:36 -07:00
|
|
|
int npi, proto;
|
|
|
|
unsigned char *pp;
|
|
|
|
|
|
|
|
npi = ethertype_to_npindex(ntohs(skb->protocol));
|
|
|
|
if (npi < 0)
|
|
|
|
goto outf;
|
|
|
|
|
|
|
|
/* Drop, accept or reject the packet */
|
|
|
|
switch (ppp->npmode[npi]) {
|
|
|
|
case NPMODE_PASS:
|
|
|
|
break;
|
|
|
|
case NPMODE_QUEUE:
|
|
|
|
/* it would be nice to have a way to tell the network
|
|
|
|
system to queue this one up for later. */
|
|
|
|
goto outf;
|
|
|
|
case NPMODE_DROP:
|
|
|
|
case NPMODE_ERROR:
|
|
|
|
goto outf;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Put the 2-byte PPP protocol number on the front,
|
|
|
|
making sure there is room for the address and control fields. */
|
2007-09-16 16:21:42 -07:00
|
|
|
if (skb_cow_head(skb, PPP_HDRLEN))
|
|
|
|
goto outf;
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
pp = skb_push(skb, 2);
|
|
|
|
proto = npindex_to_proto[npi];
|
|
|
|
pp[0] = proto >> 8;
|
|
|
|
pp[1] = proto;
|
|
|
|
|
|
|
|
netif_stop_queue(dev);
|
|
|
|
skb_queue_tail(&ppp->file.xq, skb);
|
|
|
|
ppp_xmit_process(ppp);
|
2009-06-22 23:03:08 -07:00
|
|
|
return NETDEV_TX_OK;
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
outf:
|
|
|
|
kfree_skb(skb);
|
2009-02-22 21:59:43 -07:00
|
|
|
++dev->stats.tx_dropped;
|
2009-06-22 23:03:08 -07:00
|
|
|
return NETDEV_TX_OK;
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
|
|
|
|
{
|
2008-11-20 05:24:17 -07:00
|
|
|
struct ppp *ppp = netdev_priv(dev);
|
2005-04-16 15:20:36 -07:00
|
|
|
int err = -EFAULT;
|
|
|
|
void __user *addr = (void __user *) ifr->ifr_ifru.ifru_data;
|
|
|
|
struct ppp_stats stats;
|
|
|
|
struct ppp_comp_stats cstats;
|
|
|
|
char *vers;
|
|
|
|
|
|
|
|
switch (cmd) {
|
|
|
|
case SIOCGPPPSTATS:
|
|
|
|
ppp_get_stats(ppp, &stats);
|
|
|
|
if (copy_to_user(addr, &stats, sizeof(stats)))
|
|
|
|
break;
|
|
|
|
err = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SIOCGPPPCSTATS:
|
|
|
|
memset(&cstats, 0, sizeof(cstats));
|
2007-11-12 19:07:31 -07:00
|
|
|
if (ppp->xc_state)
|
2005-04-16 15:20:36 -07:00
|
|
|
ppp->xcomp->comp_stat(ppp->xc_state, &cstats.c);
|
2007-11-12 19:07:31 -07:00
|
|
|
if (ppp->rc_state)
|
2005-04-16 15:20:36 -07:00
|
|
|
ppp->rcomp->decomp_stat(ppp->rc_state, &cstats.d);
|
|
|
|
if (copy_to_user(addr, &cstats, sizeof(cstats)))
|
|
|
|
break;
|
|
|
|
err = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SIOCGPPPVER:
|
|
|
|
vers = PPP_VERSION;
|
|
|
|
if (copy_to_user(addr, vers, strlen(vers) + 1))
|
|
|
|
break;
|
|
|
|
err = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
err = -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2008-11-19 23:22:30 -07:00
|
|
|
static const struct net_device_ops ppp_netdev_ops = {
|
2008-11-20 21:14:53 -07:00
|
|
|
.ndo_start_xmit = ppp_start_xmit,
|
|
|
|
.ndo_do_ioctl = ppp_net_ioctl,
|
2008-11-19 23:22:30 -07:00
|
|
|
};
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
static void ppp_setup(struct net_device *dev)
|
|
|
|
{
|
2008-11-19 23:22:30 -07:00
|
|
|
dev->netdev_ops = &ppp_netdev_ops;
|
2005-04-16 15:20:36 -07:00
|
|
|
dev->hard_header_len = PPP_HDRLEN;
|
|
|
|
dev->mtu = PPP_MTU;
|
|
|
|
dev->addr_len = 0;
|
|
|
|
dev->tx_queue_len = 3;
|
|
|
|
dev->type = ARPHRD_PPP;
|
|
|
|
dev->flags = IFF_POINTOPOINT | IFF_NOARP | IFF_MULTICAST;
|
2009-01-21 16:55:35 -07:00
|
|
|
dev->features |= NETIF_F_NETNS_LOCAL;
|
2009-05-19 14:24:37 -07:00
|
|
|
dev->priv_flags &= ~IFF_XMIT_DST_RELEASE;
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Transmit-side routines.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Called to do any work queued up on the transmit side
|
|
|
|
* that can now be done.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
ppp_xmit_process(struct ppp *ppp)
|
|
|
|
{
|
|
|
|
struct sk_buff *skb;
|
|
|
|
|
|
|
|
ppp_xmit_lock(ppp);
|
2008-12-17 05:02:16 -07:00
|
|
|
if (!ppp->closing) {
|
2005-04-16 15:20:36 -07:00
|
|
|
ppp_push(ppp);
|
2007-11-12 19:07:31 -07:00
|
|
|
while (!ppp->xmit_pending
|
|
|
|
&& (skb = skb_dequeue(&ppp->file.xq)))
|
2005-04-16 15:20:36 -07:00
|
|
|
ppp_send_frame(ppp, skb);
|
|
|
|
/* If there's no work left to do, tell the core net
|
|
|
|
code that we can accept some more. */
|
2007-11-12 19:07:31 -07:00
|
|
|
if (!ppp->xmit_pending && !skb_peek(&ppp->file.xq))
|
2005-04-16 15:20:36 -07:00
|
|
|
netif_wake_queue(ppp->dev);
|
|
|
|
}
|
|
|
|
ppp_xmit_unlock(ppp);
|
|
|
|
}
|
|
|
|
|
2005-11-08 10:40:47 -07:00
|
|
|
static inline struct sk_buff *
|
|
|
|
pad_compress_skb(struct ppp *ppp, struct sk_buff *skb)
|
|
|
|
{
|
|
|
|
struct sk_buff *new_skb;
|
|
|
|
int len;
|
|
|
|
int new_skb_size = ppp->dev->mtu +
|
|
|
|
ppp->xcomp->comp_extra + ppp->dev->hard_header_len;
|
|
|
|
int compressor_skb_size = ppp->dev->mtu +
|
|
|
|
ppp->xcomp->comp_extra + PPP_HDRLEN;
|
|
|
|
new_skb = alloc_skb(new_skb_size, GFP_ATOMIC);
|
|
|
|
if (!new_skb) {
|
|
|
|
if (net_ratelimit())
|
|
|
|
printk(KERN_ERR "PPP: no memory (comp pkt)\n");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
if (ppp->dev->hard_header_len > PPP_HDRLEN)
|
|
|
|
skb_reserve(new_skb,
|
|
|
|
ppp->dev->hard_header_len - PPP_HDRLEN);
|
|
|
|
|
|
|
|
/* compressor still expects A/C bytes in hdr */
|
|
|
|
len = ppp->xcomp->compress(ppp->xc_state, skb->data - 2,
|
|
|
|
new_skb->data, skb->len + 2,
|
|
|
|
compressor_skb_size);
|
|
|
|
if (len > 0 && (ppp->flags & SC_CCP_UP)) {
|
|
|
|
kfree_skb(skb);
|
|
|
|
skb = new_skb;
|
|
|
|
skb_put(skb, len);
|
|
|
|
skb_pull(skb, 2); /* pull off A/C bytes */
|
|
|
|
} else if (len == 0) {
|
|
|
|
/* didn't compress, or CCP not up yet */
|
|
|
|
kfree_skb(new_skb);
|
|
|
|
new_skb = skb;
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* (len < 0)
|
|
|
|
* MPPE requires that we do not send unencrypted
|
|
|
|
* frames. The compressor will return -1 if we
|
|
|
|
* should drop the frame. We cannot simply test
|
|
|
|
* the compress_proto because MPPE and MPPC share
|
|
|
|
* the same number.
|
|
|
|
*/
|
|
|
|
if (net_ratelimit())
|
|
|
|
printk(KERN_ERR "ppp: compressor dropped pkt\n");
|
|
|
|
kfree_skb(skb);
|
|
|
|
kfree_skb(new_skb);
|
|
|
|
new_skb = NULL;
|
|
|
|
}
|
|
|
|
return new_skb;
|
|
|
|
}
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
/*
|
|
|
|
* Compress and send a frame.
|
|
|
|
* The caller should have locked the xmit path,
|
|
|
|
* and xmit_pending should be 0.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
ppp_send_frame(struct ppp *ppp, struct sk_buff *skb)
|
|
|
|
{
|
|
|
|
int proto = PPP_PROTO(skb);
|
|
|
|
struct sk_buff *new_skb;
|
|
|
|
int len;
|
|
|
|
unsigned char *cp;
|
|
|
|
|
|
|
|
if (proto < 0x8000) {
|
|
|
|
#ifdef CONFIG_PPP_FILTER
|
|
|
|
/* check if we should pass this packet */
|
|
|
|
/* the filter instructions are constructed assuming
|
|
|
|
a four-byte PPP header on each packet */
|
|
|
|
*skb_push(skb, 2) = 1;
|
|
|
|
if (ppp->pass_filter
|
|
|
|
&& sk_run_filter(skb, ppp->pass_filter,
|
|
|
|
ppp->pass_len) == 0) {
|
|
|
|
if (ppp->debug & 1)
|
|
|
|
printk(KERN_DEBUG "PPP: outbound frame not passed\n");
|
|
|
|
kfree_skb(skb);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
/* if this packet passes the active filter, record the time */
|
|
|
|
if (!(ppp->active_filter
|
|
|
|
&& sk_run_filter(skb, ppp->active_filter,
|
|
|
|
ppp->active_len) == 0))
|
|
|
|
ppp->last_xmit = jiffies;
|
|
|
|
skb_pull(skb, 2);
|
|
|
|
#else
|
|
|
|
/* for data packets, record the time */
|
|
|
|
ppp->last_xmit = jiffies;
|
|
|
|
#endif /* CONFIG_PPP_FILTER */
|
|
|
|
}
|
|
|
|
|
2008-04-23 18:54:01 -07:00
|
|
|
++ppp->dev->stats.tx_packets;
|
|
|
|
ppp->dev->stats.tx_bytes += skb->len - 2;
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
switch (proto) {
|
|
|
|
case PPP_IP:
|
2007-11-12 19:07:31 -07:00
|
|
|
if (!ppp->vj || (ppp->flags & SC_COMP_TCP) == 0)
|
2005-04-16 15:20:36 -07:00
|
|
|
break;
|
|
|
|
/* try to do VJ TCP header compression */
|
|
|
|
new_skb = alloc_skb(skb->len + ppp->dev->hard_header_len - 2,
|
|
|
|
GFP_ATOMIC);
|
2007-11-12 19:07:31 -07:00
|
|
|
if (!new_skb) {
|
2005-04-16 15:20:36 -07:00
|
|
|
printk(KERN_ERR "PPP: no memory (VJ comp pkt)\n");
|
|
|
|
goto drop;
|
|
|
|
}
|
|
|
|
skb_reserve(new_skb, ppp->dev->hard_header_len - 2);
|
|
|
|
cp = skb->data + 2;
|
|
|
|
len = slhc_compress(ppp->vj, cp, skb->len - 2,
|
|
|
|
new_skb->data + 2, &cp,
|
|
|
|
!(ppp->flags & SC_NO_TCP_CCID));
|
|
|
|
if (cp == skb->data + 2) {
|
|
|
|
/* didn't compress */
|
|
|
|
kfree_skb(new_skb);
|
|
|
|
} else {
|
|
|
|
if (cp[0] & SL_TYPE_COMPRESSED_TCP) {
|
|
|
|
proto = PPP_VJC_COMP;
|
|
|
|
cp[0] &= ~SL_TYPE_COMPRESSED_TCP;
|
|
|
|
} else {
|
|
|
|
proto = PPP_VJC_UNCOMP;
|
|
|
|
cp[0] = skb->data[2];
|
|
|
|
}
|
|
|
|
kfree_skb(skb);
|
|
|
|
skb = new_skb;
|
|
|
|
cp = skb_put(skb, len + 2);
|
|
|
|
cp[0] = 0;
|
|
|
|
cp[1] = proto;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PPP_CCP:
|
|
|
|
/* peek at outbound CCP frames */
|
|
|
|
ppp_ccp_peek(ppp, skb, 0);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* try to do packet compression */
|
2007-11-12 19:07:31 -07:00
|
|
|
if ((ppp->xstate & SC_COMP_RUN) && ppp->xc_state
|
2005-04-16 15:20:36 -07:00
|
|
|
&& proto != PPP_LCP && proto != PPP_CCP) {
|
2005-11-08 10:40:47 -07:00
|
|
|
if (!(ppp->flags & SC_CCP_UP) && (ppp->flags & SC_MUST_COMP)) {
|
|
|
|
if (net_ratelimit())
|
|
|
|
printk(KERN_ERR "ppp: compression required but down - pkt dropped.\n");
|
2005-04-16 15:20:36 -07:00
|
|
|
goto drop;
|
|
|
|
}
|
2005-11-08 10:40:47 -07:00
|
|
|
skb = pad_compress_skb(ppp, skb);
|
|
|
|
if (!skb)
|
|
|
|
goto drop;
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If we are waiting for traffic (demand dialling),
|
|
|
|
* queue it up for pppd to receive.
|
|
|
|
*/
|
|
|
|
if (ppp->flags & SC_LOOP_TRAFFIC) {
|
|
|
|
if (ppp->file.rq.qlen > PPP_MAX_RQLEN)
|
|
|
|
goto drop;
|
|
|
|
skb_queue_tail(&ppp->file.rq, skb);
|
|
|
|
wake_up_interruptible(&ppp->file.rwait);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ppp->xmit_pending = skb;
|
|
|
|
ppp_push(ppp);
|
|
|
|
return;
|
|
|
|
|
|
|
|
drop:
|
2009-02-24 17:16:08 -07:00
|
|
|
kfree_skb(skb);
|
2008-04-23 18:54:01 -07:00
|
|
|
++ppp->dev->stats.tx_errors;
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Try to send the frame in xmit_pending.
|
|
|
|
* The caller should have the xmit path locked.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
ppp_push(struct ppp *ppp)
|
|
|
|
{
|
|
|
|
struct list_head *list;
|
|
|
|
struct channel *pch;
|
|
|
|
struct sk_buff *skb = ppp->xmit_pending;
|
|
|
|
|
2007-11-12 19:07:31 -07:00
|
|
|
if (!skb)
|
2005-04-16 15:20:36 -07:00
|
|
|
return;
|
|
|
|
|
|
|
|
list = &ppp->channels;
|
|
|
|
if (list_empty(list)) {
|
|
|
|
/* nowhere to send the packet, just drop it */
|
|
|
|
ppp->xmit_pending = NULL;
|
|
|
|
kfree_skb(skb);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((ppp->flags & SC_MULTILINK) == 0) {
|
|
|
|
/* not doing multilink: send it down the first channel */
|
|
|
|
list = list->next;
|
|
|
|
pch = list_entry(list, struct channel, clist);
|
|
|
|
|
|
|
|
spin_lock_bh(&pch->downl);
|
|
|
|
if (pch->chan) {
|
|
|
|
if (pch->chan->ops->start_xmit(pch->chan, skb))
|
|
|
|
ppp->xmit_pending = NULL;
|
|
|
|
} else {
|
|
|
|
/* channel got unregistered */
|
|
|
|
kfree_skb(skb);
|
|
|
|
ppp->xmit_pending = NULL;
|
|
|
|
}
|
|
|
|
spin_unlock_bh(&pch->downl);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef CONFIG_PPP_MULTILINK
|
|
|
|
/* Multilink: fragment the packet over as many links
|
|
|
|
as can take the packet at the moment. */
|
|
|
|
if (!ppp_mp_explode(ppp, skb))
|
|
|
|
return;
|
|
|
|
#endif /* CONFIG_PPP_MULTILINK */
|
|
|
|
|
|
|
|
ppp->xmit_pending = NULL;
|
|
|
|
kfree_skb(skb);
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef CONFIG_PPP_MULTILINK
|
|
|
|
/*
|
|
|
|
* Divide a packet to be transmitted into fragments and
|
|
|
|
* send them out the individual links.
|
|
|
|
*/
|
|
|
|
static int ppp_mp_explode(struct ppp *ppp, struct sk_buff *skb)
|
|
|
|
{
|
ppp: ppp_mp_explode() redesign
I found the PPP subsystem to not work properly when connecting channels
with different speeds to the same bundle.
Problem Description:
As the "ppp_mp_explode" function fragments the sk_buff buffer evenly
among the PPP channels that are connected to a certain PPP unit to
make up a bundle, if we are transmitting using an upper layer protocol
that requires an Ack before sending the next packet (like TCP/IP for
example), we will have a bandwidth bottleneck on the slowest channel
of the bundle.
Let's clarify by an example. Let's consider a scenario where we have
two PPP links making up a bundle: a slow link (10KB/sec) and a fast
link (1000KB/sec) working at the best (full bandwidth). On the top we
have a TCP/IP stack sending a 1000 Bytes sk_buff buffer down to the
PPP subsystem. The "ppp_mp_explode" function will divide the buffer in
two fragments of 500B each (we are neglecting all the headers, crc,
flags etc?.). Before the TCP/IP stack sends out the next buffer, it
will have to wait for the ACK response from the remote peer, so it
will have to wait for both fragments to have been sent over the two
PPP links, received by the remote peer and reconstructed. The
resulting behaviour is that, rather than having a bundle working
@1010KB/sec (the sum of the channels bandwidths), we'll have a bundle
working @20KB/sec (the double of the slowest channels bandwidth).
Problem Solution:
The problem has been solved by redesigning the "ppp_mp_explode"
function in such a way to make it split the sk_buff buffer according
to the speeds of the underlying PPP channels (the speeds of the serial
interfaces respectively attached to the PPP channels). Referring to
the above example, the redesigned "ppp_mp_explode" function will now
divide the 1000 Bytes buffer into two fragments whose sizes are set
according to the speeds of the channels where they are going to be
sent on (e.g . 10 Byets on 10KB/sec channel and 990 Bytes on
1000KB/sec channel). The reworked function grants the same
performances of the original one in optimal working conditions (i.e. a
bundle made up of PPP links all working at the same speed), while
greatly improving performances on the bundles made up of channels
working at different speeds.
Signed-off-by: Gabriele Paoloni <gabriele.paoloni@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2009-03-13 16:09:12 -07:00
|
|
|
int len, totlen;
|
|
|
|
int i, bits, hdrlen, mtu;
|
|
|
|
int flen;
|
|
|
|
int navail, nfree, nzero;
|
|
|
|
int nbigger;
|
|
|
|
int totspeed;
|
|
|
|
int totfree;
|
2005-04-16 15:20:36 -07:00
|
|
|
unsigned char *p, *q;
|
|
|
|
struct list_head *list;
|
|
|
|
struct channel *pch;
|
|
|
|
struct sk_buff *frag;
|
|
|
|
struct ppp_channel *chan;
|
|
|
|
|
ppp: ppp_mp_explode() redesign
I found the PPP subsystem to not work properly when connecting channels
with different speeds to the same bundle.
Problem Description:
As the "ppp_mp_explode" function fragments the sk_buff buffer evenly
among the PPP channels that are connected to a certain PPP unit to
make up a bundle, if we are transmitting using an upper layer protocol
that requires an Ack before sending the next packet (like TCP/IP for
example), we will have a bandwidth bottleneck on the slowest channel
of the bundle.
Let's clarify by an example. Let's consider a scenario where we have
two PPP links making up a bundle: a slow link (10KB/sec) and a fast
link (1000KB/sec) working at the best (full bandwidth). On the top we
have a TCP/IP stack sending a 1000 Bytes sk_buff buffer down to the
PPP subsystem. The "ppp_mp_explode" function will divide the buffer in
two fragments of 500B each (we are neglecting all the headers, crc,
flags etc?.). Before the TCP/IP stack sends out the next buffer, it
will have to wait for the ACK response from the remote peer, so it
will have to wait for both fragments to have been sent over the two
PPP links, received by the remote peer and reconstructed. The
resulting behaviour is that, rather than having a bundle working
@1010KB/sec (the sum of the channels bandwidths), we'll have a bundle
working @20KB/sec (the double of the slowest channels bandwidth).
Problem Solution:
The problem has been solved by redesigning the "ppp_mp_explode"
function in such a way to make it split the sk_buff buffer according
to the speeds of the underlying PPP channels (the speeds of the serial
interfaces respectively attached to the PPP channels). Referring to
the above example, the redesigned "ppp_mp_explode" function will now
divide the 1000 Bytes buffer into two fragments whose sizes are set
according to the speeds of the channels where they are going to be
sent on (e.g . 10 Byets on 10KB/sec channel and 990 Bytes on
1000KB/sec channel). The reworked function grants the same
performances of the original one in optimal working conditions (i.e. a
bundle made up of PPP links all working at the same speed), while
greatly improving performances on the bundles made up of channels
working at different speeds.
Signed-off-by: Gabriele Paoloni <gabriele.paoloni@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2009-03-13 16:09:12 -07:00
|
|
|
totspeed = 0; /*total bitrate of the bundle*/
|
|
|
|
nfree = 0; /* # channels which have no packet already queued */
|
2005-05-12 16:47:12 -07:00
|
|
|
navail = 0; /* total # of usable channels (not deregistered) */
|
ppp: ppp_mp_explode() redesign
I found the PPP subsystem to not work properly when connecting channels
with different speeds to the same bundle.
Problem Description:
As the "ppp_mp_explode" function fragments the sk_buff buffer evenly
among the PPP channels that are connected to a certain PPP unit to
make up a bundle, if we are transmitting using an upper layer protocol
that requires an Ack before sending the next packet (like TCP/IP for
example), we will have a bandwidth bottleneck on the slowest channel
of the bundle.
Let's clarify by an example. Let's consider a scenario where we have
two PPP links making up a bundle: a slow link (10KB/sec) and a fast
link (1000KB/sec) working at the best (full bandwidth). On the top we
have a TCP/IP stack sending a 1000 Bytes sk_buff buffer down to the
PPP subsystem. The "ppp_mp_explode" function will divide the buffer in
two fragments of 500B each (we are neglecting all the headers, crc,
flags etc?.). Before the TCP/IP stack sends out the next buffer, it
will have to wait for the ACK response from the remote peer, so it
will have to wait for both fragments to have been sent over the two
PPP links, received by the remote peer and reconstructed. The
resulting behaviour is that, rather than having a bundle working
@1010KB/sec (the sum of the channels bandwidths), we'll have a bundle
working @20KB/sec (the double of the slowest channels bandwidth).
Problem Solution:
The problem has been solved by redesigning the "ppp_mp_explode"
function in such a way to make it split the sk_buff buffer according
to the speeds of the underlying PPP channels (the speeds of the serial
interfaces respectively attached to the PPP channels). Referring to
the above example, the redesigned "ppp_mp_explode" function will now
divide the 1000 Bytes buffer into two fragments whose sizes are set
according to the speeds of the channels where they are going to be
sent on (e.g . 10 Byets on 10KB/sec channel and 990 Bytes on
1000KB/sec channel). The reworked function grants the same
performances of the original one in optimal working conditions (i.e. a
bundle made up of PPP links all working at the same speed), while
greatly improving performances on the bundles made up of channels
working at different speeds.
Signed-off-by: Gabriele Paoloni <gabriele.paoloni@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2009-03-13 16:09:12 -07:00
|
|
|
nzero = 0; /* number of channels with zero speed associated*/
|
|
|
|
totfree = 0; /*total # of channels available and
|
|
|
|
*having no queued packets before
|
|
|
|
*starting the fragmentation*/
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
hdrlen = (ppp->flags & SC_MP_XSHORTSEQ)? MPHDRLEN_SSN: MPHDRLEN;
|
ppp: ppp_mp_explode() redesign
I found the PPP subsystem to not work properly when connecting channels
with different speeds to the same bundle.
Problem Description:
As the "ppp_mp_explode" function fragments the sk_buff buffer evenly
among the PPP channels that are connected to a certain PPP unit to
make up a bundle, if we are transmitting using an upper layer protocol
that requires an Ack before sending the next packet (like TCP/IP for
example), we will have a bandwidth bottleneck on the slowest channel
of the bundle.
Let's clarify by an example. Let's consider a scenario where we have
two PPP links making up a bundle: a slow link (10KB/sec) and a fast
link (1000KB/sec) working at the best (full bandwidth). On the top we
have a TCP/IP stack sending a 1000 Bytes sk_buff buffer down to the
PPP subsystem. The "ppp_mp_explode" function will divide the buffer in
two fragments of 500B each (we are neglecting all the headers, crc,
flags etc?.). Before the TCP/IP stack sends out the next buffer, it
will have to wait for the ACK response from the remote peer, so it
will have to wait for both fragments to have been sent over the two
PPP links, received by the remote peer and reconstructed. The
resulting behaviour is that, rather than having a bundle working
@1010KB/sec (the sum of the channels bandwidths), we'll have a bundle
working @20KB/sec (the double of the slowest channels bandwidth).
Problem Solution:
The problem has been solved by redesigning the "ppp_mp_explode"
function in such a way to make it split the sk_buff buffer according
to the speeds of the underlying PPP channels (the speeds of the serial
interfaces respectively attached to the PPP channels). Referring to
the above example, the redesigned "ppp_mp_explode" function will now
divide the 1000 Bytes buffer into two fragments whose sizes are set
according to the speeds of the channels where they are going to be
sent on (e.g . 10 Byets on 10KB/sec channel and 990 Bytes on
1000KB/sec channel). The reworked function grants the same
performances of the original one in optimal working conditions (i.e. a
bundle made up of PPP links all working at the same speed), while
greatly improving performances on the bundles made up of channels
working at different speeds.
Signed-off-by: Gabriele Paoloni <gabriele.paoloni@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2009-03-13 16:09:12 -07:00
|
|
|
i = 0;
|
|
|
|
list_for_each_entry(pch, &ppp->channels, clist) {
|
2005-05-12 16:47:12 -07:00
|
|
|
navail += pch->avail = (pch->chan != NULL);
|
ppp: ppp_mp_explode() redesign
I found the PPP subsystem to not work properly when connecting channels
with different speeds to the same bundle.
Problem Description:
As the "ppp_mp_explode" function fragments the sk_buff buffer evenly
among the PPP channels that are connected to a certain PPP unit to
make up a bundle, if we are transmitting using an upper layer protocol
that requires an Ack before sending the next packet (like TCP/IP for
example), we will have a bandwidth bottleneck on the slowest channel
of the bundle.
Let's clarify by an example. Let's consider a scenario where we have
two PPP links making up a bundle: a slow link (10KB/sec) and a fast
link (1000KB/sec) working at the best (full bandwidth). On the top we
have a TCP/IP stack sending a 1000 Bytes sk_buff buffer down to the
PPP subsystem. The "ppp_mp_explode" function will divide the buffer in
two fragments of 500B each (we are neglecting all the headers, crc,
flags etc?.). Before the TCP/IP stack sends out the next buffer, it
will have to wait for the ACK response from the remote peer, so it
will have to wait for both fragments to have been sent over the two
PPP links, received by the remote peer and reconstructed. The
resulting behaviour is that, rather than having a bundle working
@1010KB/sec (the sum of the channels bandwidths), we'll have a bundle
working @20KB/sec (the double of the slowest channels bandwidth).
Problem Solution:
The problem has been solved by redesigning the "ppp_mp_explode"
function in such a way to make it split the sk_buff buffer according
to the speeds of the underlying PPP channels (the speeds of the serial
interfaces respectively attached to the PPP channels). Referring to
the above example, the redesigned "ppp_mp_explode" function will now
divide the 1000 Bytes buffer into two fragments whose sizes are set
according to the speeds of the channels where they are going to be
sent on (e.g . 10 Byets on 10KB/sec channel and 990 Bytes on
1000KB/sec channel). The reworked function grants the same
performances of the original one in optimal working conditions (i.e. a
bundle made up of PPP links all working at the same speed), while
greatly improving performances on the bundles made up of channels
working at different speeds.
Signed-off-by: Gabriele Paoloni <gabriele.paoloni@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2009-03-13 16:09:12 -07:00
|
|
|
pch->speed = pch->chan->speed;
|
|
|
|
if (pch->avail) {
|
2005-07-08 14:57:23 -07:00
|
|
|
if (skb_queue_empty(&pch->file.xq) ||
|
ppp: ppp_mp_explode() redesign
I found the PPP subsystem to not work properly when connecting channels
with different speeds to the same bundle.
Problem Description:
As the "ppp_mp_explode" function fragments the sk_buff buffer evenly
among the PPP channels that are connected to a certain PPP unit to
make up a bundle, if we are transmitting using an upper layer protocol
that requires an Ack before sending the next packet (like TCP/IP for
example), we will have a bandwidth bottleneck on the slowest channel
of the bundle.
Let's clarify by an example. Let's consider a scenario where we have
two PPP links making up a bundle: a slow link (10KB/sec) and a fast
link (1000KB/sec) working at the best (full bandwidth). On the top we
have a TCP/IP stack sending a 1000 Bytes sk_buff buffer down to the
PPP subsystem. The "ppp_mp_explode" function will divide the buffer in
two fragments of 500B each (we are neglecting all the headers, crc,
flags etc?.). Before the TCP/IP stack sends out the next buffer, it
will have to wait for the ACK response from the remote peer, so it
will have to wait for both fragments to have been sent over the two
PPP links, received by the remote peer and reconstructed. The
resulting behaviour is that, rather than having a bundle working
@1010KB/sec (the sum of the channels bandwidths), we'll have a bundle
working @20KB/sec (the double of the slowest channels bandwidth).
Problem Solution:
The problem has been solved by redesigning the "ppp_mp_explode"
function in such a way to make it split the sk_buff buffer according
to the speeds of the underlying PPP channels (the speeds of the serial
interfaces respectively attached to the PPP channels). Referring to
the above example, the redesigned "ppp_mp_explode" function will now
divide the 1000 Bytes buffer into two fragments whose sizes are set
according to the speeds of the channels where they are going to be
sent on (e.g . 10 Byets on 10KB/sec channel and 990 Bytes on
1000KB/sec channel). The reworked function grants the same
performances of the original one in optimal working conditions (i.e. a
bundle made up of PPP links all working at the same speed), while
greatly improving performances on the bundles made up of channels
working at different speeds.
Signed-off-by: Gabriele Paoloni <gabriele.paoloni@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2009-03-13 16:09:12 -07:00
|
|
|
!pch->had_frag) {
|
|
|
|
if (pch->speed == 0)
|
|
|
|
nzero++;
|
|
|
|
else
|
|
|
|
totspeed += pch->speed;
|
|
|
|
|
|
|
|
pch->avail = 2;
|
|
|
|
++nfree;
|
|
|
|
++totfree;
|
|
|
|
}
|
|
|
|
if (!pch->had_frag && i < ppp->nxchan)
|
|
|
|
ppp->nxchan = i;
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
2005-05-12 16:47:12 -07:00
|
|
|
++i;
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
2005-05-12 16:47:12 -07:00
|
|
|
/*
|
ppp: ppp_mp_explode() redesign
I found the PPP subsystem to not work properly when connecting channels
with different speeds to the same bundle.
Problem Description:
As the "ppp_mp_explode" function fragments the sk_buff buffer evenly
among the PPP channels that are connected to a certain PPP unit to
make up a bundle, if we are transmitting using an upper layer protocol
that requires an Ack before sending the next packet (like TCP/IP for
example), we will have a bandwidth bottleneck on the slowest channel
of the bundle.
Let's clarify by an example. Let's consider a scenario where we have
two PPP links making up a bundle: a slow link (10KB/sec) and a fast
link (1000KB/sec) working at the best (full bandwidth). On the top we
have a TCP/IP stack sending a 1000 Bytes sk_buff buffer down to the
PPP subsystem. The "ppp_mp_explode" function will divide the buffer in
two fragments of 500B each (we are neglecting all the headers, crc,
flags etc?.). Before the TCP/IP stack sends out the next buffer, it
will have to wait for the ACK response from the remote peer, so it
will have to wait for both fragments to have been sent over the two
PPP links, received by the remote peer and reconstructed. The
resulting behaviour is that, rather than having a bundle working
@1010KB/sec (the sum of the channels bandwidths), we'll have a bundle
working @20KB/sec (the double of the slowest channels bandwidth).
Problem Solution:
The problem has been solved by redesigning the "ppp_mp_explode"
function in such a way to make it split the sk_buff buffer according
to the speeds of the underlying PPP channels (the speeds of the serial
interfaces respectively attached to the PPP channels). Referring to
the above example, the redesigned "ppp_mp_explode" function will now
divide the 1000 Bytes buffer into two fragments whose sizes are set
according to the speeds of the channels where they are going to be
sent on (e.g . 10 Byets on 10KB/sec channel and 990 Bytes on
1000KB/sec channel). The reworked function grants the same
performances of the original one in optimal working conditions (i.e. a
bundle made up of PPP links all working at the same speed), while
greatly improving performances on the bundles made up of channels
working at different speeds.
Signed-off-by: Gabriele Paoloni <gabriele.paoloni@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2009-03-13 16:09:12 -07:00
|
|
|
* Don't start sending this packet unless at least half of
|
|
|
|
* the channels are free. This gives much better TCP
|
|
|
|
* performance if we have a lot of channels.
|
2005-05-12 16:47:12 -07:00
|
|
|
*/
|
ppp: ppp_mp_explode() redesign
I found the PPP subsystem to not work properly when connecting channels
with different speeds to the same bundle.
Problem Description:
As the "ppp_mp_explode" function fragments the sk_buff buffer evenly
among the PPP channels that are connected to a certain PPP unit to
make up a bundle, if we are transmitting using an upper layer protocol
that requires an Ack before sending the next packet (like TCP/IP for
example), we will have a bandwidth bottleneck on the slowest channel
of the bundle.
Let's clarify by an example. Let's consider a scenario where we have
two PPP links making up a bundle: a slow link (10KB/sec) and a fast
link (1000KB/sec) working at the best (full bandwidth). On the top we
have a TCP/IP stack sending a 1000 Bytes sk_buff buffer down to the
PPP subsystem. The "ppp_mp_explode" function will divide the buffer in
two fragments of 500B each (we are neglecting all the headers, crc,
flags etc?.). Before the TCP/IP stack sends out the next buffer, it
will have to wait for the ACK response from the remote peer, so it
will have to wait for both fragments to have been sent over the two
PPP links, received by the remote peer and reconstructed. The
resulting behaviour is that, rather than having a bundle working
@1010KB/sec (the sum of the channels bandwidths), we'll have a bundle
working @20KB/sec (the double of the slowest channels bandwidth).
Problem Solution:
The problem has been solved by redesigning the "ppp_mp_explode"
function in such a way to make it split the sk_buff buffer according
to the speeds of the underlying PPP channels (the speeds of the serial
interfaces respectively attached to the PPP channels). Referring to
the above example, the redesigned "ppp_mp_explode" function will now
divide the 1000 Bytes buffer into two fragments whose sizes are set
according to the speeds of the channels where they are going to be
sent on (e.g . 10 Byets on 10KB/sec channel and 990 Bytes on
1000KB/sec channel). The reworked function grants the same
performances of the original one in optimal working conditions (i.e. a
bundle made up of PPP links all working at the same speed), while
greatly improving performances on the bundles made up of channels
working at different speeds.
Signed-off-by: Gabriele Paoloni <gabriele.paoloni@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2009-03-13 16:09:12 -07:00
|
|
|
if (nfree == 0 || nfree < navail / 2)
|
|
|
|
return 0; /* can't take now, leave it in xmit_pending */
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
/* Do protocol field compression (XXX this should be optional) */
|
ppp: ppp_mp_explode() redesign
I found the PPP subsystem to not work properly when connecting channels
with different speeds to the same bundle.
Problem Description:
As the "ppp_mp_explode" function fragments the sk_buff buffer evenly
among the PPP channels that are connected to a certain PPP unit to
make up a bundle, if we are transmitting using an upper layer protocol
that requires an Ack before sending the next packet (like TCP/IP for
example), we will have a bandwidth bottleneck on the slowest channel
of the bundle.
Let's clarify by an example. Let's consider a scenario where we have
two PPP links making up a bundle: a slow link (10KB/sec) and a fast
link (1000KB/sec) working at the best (full bandwidth). On the top we
have a TCP/IP stack sending a 1000 Bytes sk_buff buffer down to the
PPP subsystem. The "ppp_mp_explode" function will divide the buffer in
two fragments of 500B each (we are neglecting all the headers, crc,
flags etc?.). Before the TCP/IP stack sends out the next buffer, it
will have to wait for the ACK response from the remote peer, so it
will have to wait for both fragments to have been sent over the two
PPP links, received by the remote peer and reconstructed. The
resulting behaviour is that, rather than having a bundle working
@1010KB/sec (the sum of the channels bandwidths), we'll have a bundle
working @20KB/sec (the double of the slowest channels bandwidth).
Problem Solution:
The problem has been solved by redesigning the "ppp_mp_explode"
function in such a way to make it split the sk_buff buffer according
to the speeds of the underlying PPP channels (the speeds of the serial
interfaces respectively attached to the PPP channels). Referring to
the above example, the redesigned "ppp_mp_explode" function will now
divide the 1000 Bytes buffer into two fragments whose sizes are set
according to the speeds of the channels where they are going to be
sent on (e.g . 10 Byets on 10KB/sec channel and 990 Bytes on
1000KB/sec channel). The reworked function grants the same
performances of the original one in optimal working conditions (i.e. a
bundle made up of PPP links all working at the same speed), while
greatly improving performances on the bundles made up of channels
working at different speeds.
Signed-off-by: Gabriele Paoloni <gabriele.paoloni@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2009-03-13 16:09:12 -07:00
|
|
|
p = skb->data;
|
|
|
|
len = skb->len;
|
2005-04-16 15:20:36 -07:00
|
|
|
if (*p == 0) {
|
|
|
|
++p;
|
|
|
|
--len;
|
|
|
|
}
|
|
|
|
|
ppp: ppp_mp_explode() redesign
I found the PPP subsystem to not work properly when connecting channels
with different speeds to the same bundle.
Problem Description:
As the "ppp_mp_explode" function fragments the sk_buff buffer evenly
among the PPP channels that are connected to a certain PPP unit to
make up a bundle, if we are transmitting using an upper layer protocol
that requires an Ack before sending the next packet (like TCP/IP for
example), we will have a bandwidth bottleneck on the slowest channel
of the bundle.
Let's clarify by an example. Let's consider a scenario where we have
two PPP links making up a bundle: a slow link (10KB/sec) and a fast
link (1000KB/sec) working at the best (full bandwidth). On the top we
have a TCP/IP stack sending a 1000 Bytes sk_buff buffer down to the
PPP subsystem. The "ppp_mp_explode" function will divide the buffer in
two fragments of 500B each (we are neglecting all the headers, crc,
flags etc?.). Before the TCP/IP stack sends out the next buffer, it
will have to wait for the ACK response from the remote peer, so it
will have to wait for both fragments to have been sent over the two
PPP links, received by the remote peer and reconstructed. The
resulting behaviour is that, rather than having a bundle working
@1010KB/sec (the sum of the channels bandwidths), we'll have a bundle
working @20KB/sec (the double of the slowest channels bandwidth).
Problem Solution:
The problem has been solved by redesigning the "ppp_mp_explode"
function in such a way to make it split the sk_buff buffer according
to the speeds of the underlying PPP channels (the speeds of the serial
interfaces respectively attached to the PPP channels). Referring to
the above example, the redesigned "ppp_mp_explode" function will now
divide the 1000 Bytes buffer into two fragments whose sizes are set
according to the speeds of the channels where they are going to be
sent on (e.g . 10 Byets on 10KB/sec channel and 990 Bytes on
1000KB/sec channel). The reworked function grants the same
performances of the original one in optimal working conditions (i.e. a
bundle made up of PPP links all working at the same speed), while
greatly improving performances on the bundles made up of channels
working at different speeds.
Signed-off-by: Gabriele Paoloni <gabriele.paoloni@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2009-03-13 16:09:12 -07:00
|
|
|
totlen = len;
|
|
|
|
nbigger = len % nfree;
|
|
|
|
|
|
|
|
/* skip to the channel after the one we last used
|
|
|
|
and start at that one */
|
2005-09-10 00:27:04 -07:00
|
|
|
list = &ppp->channels;
|
ppp: ppp_mp_explode() redesign
I found the PPP subsystem to not work properly when connecting channels
with different speeds to the same bundle.
Problem Description:
As the "ppp_mp_explode" function fragments the sk_buff buffer evenly
among the PPP channels that are connected to a certain PPP unit to
make up a bundle, if we are transmitting using an upper layer protocol
that requires an Ack before sending the next packet (like TCP/IP for
example), we will have a bandwidth bottleneck on the slowest channel
of the bundle.
Let's clarify by an example. Let's consider a scenario where we have
two PPP links making up a bundle: a slow link (10KB/sec) and a fast
link (1000KB/sec) working at the best (full bandwidth). On the top we
have a TCP/IP stack sending a 1000 Bytes sk_buff buffer down to the
PPP subsystem. The "ppp_mp_explode" function will divide the buffer in
two fragments of 500B each (we are neglecting all the headers, crc,
flags etc?.). Before the TCP/IP stack sends out the next buffer, it
will have to wait for the ACK response from the remote peer, so it
will have to wait for both fragments to have been sent over the two
PPP links, received by the remote peer and reconstructed. The
resulting behaviour is that, rather than having a bundle working
@1010KB/sec (the sum of the channels bandwidths), we'll have a bundle
working @20KB/sec (the double of the slowest channels bandwidth).
Problem Solution:
The problem has been solved by redesigning the "ppp_mp_explode"
function in such a way to make it split the sk_buff buffer according
to the speeds of the underlying PPP channels (the speeds of the serial
interfaces respectively attached to the PPP channels). Referring to
the above example, the redesigned "ppp_mp_explode" function will now
divide the 1000 Bytes buffer into two fragments whose sizes are set
according to the speeds of the channels where they are going to be
sent on (e.g . 10 Byets on 10KB/sec channel and 990 Bytes on
1000KB/sec channel). The reworked function grants the same
performances of the original one in optimal working conditions (i.e. a
bundle made up of PPP links all working at the same speed), while
greatly improving performances on the bundles made up of channels
working at different speeds.
Signed-off-by: Gabriele Paoloni <gabriele.paoloni@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2009-03-13 16:09:12 -07:00
|
|
|
for (i = 0; i < ppp->nxchan; ++i) {
|
2005-04-16 15:20:36 -07:00
|
|
|
list = list->next;
|
ppp: ppp_mp_explode() redesign
I found the PPP subsystem to not work properly when connecting channels
with different speeds to the same bundle.
Problem Description:
As the "ppp_mp_explode" function fragments the sk_buff buffer evenly
among the PPP channels that are connected to a certain PPP unit to
make up a bundle, if we are transmitting using an upper layer protocol
that requires an Ack before sending the next packet (like TCP/IP for
example), we will have a bandwidth bottleneck on the slowest channel
of the bundle.
Let's clarify by an example. Let's consider a scenario where we have
two PPP links making up a bundle: a slow link (10KB/sec) and a fast
link (1000KB/sec) working at the best (full bandwidth). On the top we
have a TCP/IP stack sending a 1000 Bytes sk_buff buffer down to the
PPP subsystem. The "ppp_mp_explode" function will divide the buffer in
two fragments of 500B each (we are neglecting all the headers, crc,
flags etc?.). Before the TCP/IP stack sends out the next buffer, it
will have to wait for the ACK response from the remote peer, so it
will have to wait for both fragments to have been sent over the two
PPP links, received by the remote peer and reconstructed. The
resulting behaviour is that, rather than having a bundle working
@1010KB/sec (the sum of the channels bandwidths), we'll have a bundle
working @20KB/sec (the double of the slowest channels bandwidth).
Problem Solution:
The problem has been solved by redesigning the "ppp_mp_explode"
function in such a way to make it split the sk_buff buffer according
to the speeds of the underlying PPP channels (the speeds of the serial
interfaces respectively attached to the PPP channels). Referring to
the above example, the redesigned "ppp_mp_explode" function will now
divide the 1000 Bytes buffer into two fragments whose sizes are set
according to the speeds of the channels where they are going to be
sent on (e.g . 10 Byets on 10KB/sec channel and 990 Bytes on
1000KB/sec channel). The reworked function grants the same
performances of the original one in optimal working conditions (i.e. a
bundle made up of PPP links all working at the same speed), while
greatly improving performances on the bundles made up of channels
working at different speeds.
Signed-off-by: Gabriele Paoloni <gabriele.paoloni@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2009-03-13 16:09:12 -07:00
|
|
|
if (list == &ppp->channels) {
|
|
|
|
i = 0;
|
2005-04-16 15:20:36 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
ppp: ppp_mp_explode() redesign
I found the PPP subsystem to not work properly when connecting channels
with different speeds to the same bundle.
Problem Description:
As the "ppp_mp_explode" function fragments the sk_buff buffer evenly
among the PPP channels that are connected to a certain PPP unit to
make up a bundle, if we are transmitting using an upper layer protocol
that requires an Ack before sending the next packet (like TCP/IP for
example), we will have a bandwidth bottleneck on the slowest channel
of the bundle.
Let's clarify by an example. Let's consider a scenario where we have
two PPP links making up a bundle: a slow link (10KB/sec) and a fast
link (1000KB/sec) working at the best (full bandwidth). On the top we
have a TCP/IP stack sending a 1000 Bytes sk_buff buffer down to the
PPP subsystem. The "ppp_mp_explode" function will divide the buffer in
two fragments of 500B each (we are neglecting all the headers, crc,
flags etc?.). Before the TCP/IP stack sends out the next buffer, it
will have to wait for the ACK response from the remote peer, so it
will have to wait for both fragments to have been sent over the two
PPP links, received by the remote peer and reconstructed. The
resulting behaviour is that, rather than having a bundle working
@1010KB/sec (the sum of the channels bandwidths), we'll have a bundle
working @20KB/sec (the double of the slowest channels bandwidth).
Problem Solution:
The problem has been solved by redesigning the "ppp_mp_explode"
function in such a way to make it split the sk_buff buffer according
to the speeds of the underlying PPP channels (the speeds of the serial
interfaces respectively attached to the PPP channels). Referring to
the above example, the redesigned "ppp_mp_explode" function will now
divide the 1000 Bytes buffer into two fragments whose sizes are set
according to the speeds of the channels where they are going to be
sent on (e.g . 10 Byets on 10KB/sec channel and 990 Bytes on
1000KB/sec channel). The reworked function grants the same
performances of the original one in optimal working conditions (i.e. a
bundle made up of PPP links all working at the same speed), while
greatly improving performances on the bundles made up of channels
working at different speeds.
Signed-off-by: Gabriele Paoloni <gabriele.paoloni@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2009-03-13 16:09:12 -07:00
|
|
|
/* create a fragment for each channel */
|
2005-04-16 15:20:36 -07:00
|
|
|
bits = B;
|
2009-07-28 00:43:57 -07:00
|
|
|
while (len > 0) {
|
2005-04-16 15:20:36 -07:00
|
|
|
list = list->next;
|
ppp: ppp_mp_explode() redesign
I found the PPP subsystem to not work properly when connecting channels
with different speeds to the same bundle.
Problem Description:
As the "ppp_mp_explode" function fragments the sk_buff buffer evenly
among the PPP channels that are connected to a certain PPP unit to
make up a bundle, if we are transmitting using an upper layer protocol
that requires an Ack before sending the next packet (like TCP/IP for
example), we will have a bandwidth bottleneck on the slowest channel
of the bundle.
Let's clarify by an example. Let's consider a scenario where we have
two PPP links making up a bundle: a slow link (10KB/sec) and a fast
link (1000KB/sec) working at the best (full bandwidth). On the top we
have a TCP/IP stack sending a 1000 Bytes sk_buff buffer down to the
PPP subsystem. The "ppp_mp_explode" function will divide the buffer in
two fragments of 500B each (we are neglecting all the headers, crc,
flags etc?.). Before the TCP/IP stack sends out the next buffer, it
will have to wait for the ACK response from the remote peer, so it
will have to wait for both fragments to have been sent over the two
PPP links, received by the remote peer and reconstructed. The
resulting behaviour is that, rather than having a bundle working
@1010KB/sec (the sum of the channels bandwidths), we'll have a bundle
working @20KB/sec (the double of the slowest channels bandwidth).
Problem Solution:
The problem has been solved by redesigning the "ppp_mp_explode"
function in such a way to make it split the sk_buff buffer according
to the speeds of the underlying PPP channels (the speeds of the serial
interfaces respectively attached to the PPP channels). Referring to
the above example, the redesigned "ppp_mp_explode" function will now
divide the 1000 Bytes buffer into two fragments whose sizes are set
according to the speeds of the channels where they are going to be
sent on (e.g . 10 Byets on 10KB/sec channel and 990 Bytes on
1000KB/sec channel). The reworked function grants the same
performances of the original one in optimal working conditions (i.e. a
bundle made up of PPP links all working at the same speed), while
greatly improving performances on the bundles made up of channels
working at different speeds.
Signed-off-by: Gabriele Paoloni <gabriele.paoloni@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2009-03-13 16:09:12 -07:00
|
|
|
if (list == &ppp->channels) {
|
|
|
|
i = 0;
|
2005-04-16 15:20:36 -07:00
|
|
|
continue;
|
|
|
|
}
|
ppp: ppp_mp_explode() redesign
I found the PPP subsystem to not work properly when connecting channels
with different speeds to the same bundle.
Problem Description:
As the "ppp_mp_explode" function fragments the sk_buff buffer evenly
among the PPP channels that are connected to a certain PPP unit to
make up a bundle, if we are transmitting using an upper layer protocol
that requires an Ack before sending the next packet (like TCP/IP for
example), we will have a bandwidth bottleneck on the slowest channel
of the bundle.
Let's clarify by an example. Let's consider a scenario where we have
two PPP links making up a bundle: a slow link (10KB/sec) and a fast
link (1000KB/sec) working at the best (full bandwidth). On the top we
have a TCP/IP stack sending a 1000 Bytes sk_buff buffer down to the
PPP subsystem. The "ppp_mp_explode" function will divide the buffer in
two fragments of 500B each (we are neglecting all the headers, crc,
flags etc?.). Before the TCP/IP stack sends out the next buffer, it
will have to wait for the ACK response from the remote peer, so it
will have to wait for both fragments to have been sent over the two
PPP links, received by the remote peer and reconstructed. The
resulting behaviour is that, rather than having a bundle working
@1010KB/sec (the sum of the channels bandwidths), we'll have a bundle
working @20KB/sec (the double of the slowest channels bandwidth).
Problem Solution:
The problem has been solved by redesigning the "ppp_mp_explode"
function in such a way to make it split the sk_buff buffer according
to the speeds of the underlying PPP channels (the speeds of the serial
interfaces respectively attached to the PPP channels). Referring to
the above example, the redesigned "ppp_mp_explode" function will now
divide the 1000 Bytes buffer into two fragments whose sizes are set
according to the speeds of the channels where they are going to be
sent on (e.g . 10 Byets on 10KB/sec channel and 990 Bytes on
1000KB/sec channel). The reworked function grants the same
performances of the original one in optimal working conditions (i.e. a
bundle made up of PPP links all working at the same speed), while
greatly improving performances on the bundles made up of channels
working at different speeds.
Signed-off-by: Gabriele Paoloni <gabriele.paoloni@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2009-03-13 16:09:12 -07:00
|
|
|
pch = list_entry(list, struct channel, clist);
|
2005-04-16 15:20:36 -07:00
|
|
|
++i;
|
|
|
|
if (!pch->avail)
|
|
|
|
continue;
|
|
|
|
|
2005-05-12 16:47:12 -07:00
|
|
|
/*
|
ppp: ppp_mp_explode() redesign
I found the PPP subsystem to not work properly when connecting channels
with different speeds to the same bundle.
Problem Description:
As the "ppp_mp_explode" function fragments the sk_buff buffer evenly
among the PPP channels that are connected to a certain PPP unit to
make up a bundle, if we are transmitting using an upper layer protocol
that requires an Ack before sending the next packet (like TCP/IP for
example), we will have a bandwidth bottleneck on the slowest channel
of the bundle.
Let's clarify by an example. Let's consider a scenario where we have
two PPP links making up a bundle: a slow link (10KB/sec) and a fast
link (1000KB/sec) working at the best (full bandwidth). On the top we
have a TCP/IP stack sending a 1000 Bytes sk_buff buffer down to the
PPP subsystem. The "ppp_mp_explode" function will divide the buffer in
two fragments of 500B each (we are neglecting all the headers, crc,
flags etc?.). Before the TCP/IP stack sends out the next buffer, it
will have to wait for the ACK response from the remote peer, so it
will have to wait for both fragments to have been sent over the two
PPP links, received by the remote peer and reconstructed. The
resulting behaviour is that, rather than having a bundle working
@1010KB/sec (the sum of the channels bandwidths), we'll have a bundle
working @20KB/sec (the double of the slowest channels bandwidth).
Problem Solution:
The problem has been solved by redesigning the "ppp_mp_explode"
function in such a way to make it split the sk_buff buffer according
to the speeds of the underlying PPP channels (the speeds of the serial
interfaces respectively attached to the PPP channels). Referring to
the above example, the redesigned "ppp_mp_explode" function will now
divide the 1000 Bytes buffer into two fragments whose sizes are set
according to the speeds of the channels where they are going to be
sent on (e.g . 10 Byets on 10KB/sec channel and 990 Bytes on
1000KB/sec channel). The reworked function grants the same
performances of the original one in optimal working conditions (i.e. a
bundle made up of PPP links all working at the same speed), while
greatly improving performances on the bundles made up of channels
working at different speeds.
Signed-off-by: Gabriele Paoloni <gabriele.paoloni@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2009-03-13 16:09:12 -07:00
|
|
|
* Skip this channel if it has a fragment pending already and
|
|
|
|
* we haven't given a fragment to all of the free channels.
|
2005-05-12 16:47:12 -07:00
|
|
|
*/
|
|
|
|
if (pch->avail == 1) {
|
ppp: ppp_mp_explode() redesign
I found the PPP subsystem to not work properly when connecting channels
with different speeds to the same bundle.
Problem Description:
As the "ppp_mp_explode" function fragments the sk_buff buffer evenly
among the PPP channels that are connected to a certain PPP unit to
make up a bundle, if we are transmitting using an upper layer protocol
that requires an Ack before sending the next packet (like TCP/IP for
example), we will have a bandwidth bottleneck on the slowest channel
of the bundle.
Let's clarify by an example. Let's consider a scenario where we have
two PPP links making up a bundle: a slow link (10KB/sec) and a fast
link (1000KB/sec) working at the best (full bandwidth). On the top we
have a TCP/IP stack sending a 1000 Bytes sk_buff buffer down to the
PPP subsystem. The "ppp_mp_explode" function will divide the buffer in
two fragments of 500B each (we are neglecting all the headers, crc,
flags etc?.). Before the TCP/IP stack sends out the next buffer, it
will have to wait for the ACK response from the remote peer, so it
will have to wait for both fragments to have been sent over the two
PPP links, received by the remote peer and reconstructed. The
resulting behaviour is that, rather than having a bundle working
@1010KB/sec (the sum of the channels bandwidths), we'll have a bundle
working @20KB/sec (the double of the slowest channels bandwidth).
Problem Solution:
The problem has been solved by redesigning the "ppp_mp_explode"
function in such a way to make it split the sk_buff buffer according
to the speeds of the underlying PPP channels (the speeds of the serial
interfaces respectively attached to the PPP channels). Referring to
the above example, the redesigned "ppp_mp_explode" function will now
divide the 1000 Bytes buffer into two fragments whose sizes are set
according to the speeds of the channels where they are going to be
sent on (e.g . 10 Byets on 10KB/sec channel and 990 Bytes on
1000KB/sec channel). The reworked function grants the same
performances of the original one in optimal working conditions (i.e. a
bundle made up of PPP links all working at the same speed), while
greatly improving performances on the bundles made up of channels
working at different speeds.
Signed-off-by: Gabriele Paoloni <gabriele.paoloni@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2009-03-13 16:09:12 -07:00
|
|
|
if (nfree > 0)
|
2005-05-12 16:47:12 -07:00
|
|
|
continue;
|
|
|
|
} else {
|
|
|
|
pch->avail = 1;
|
|
|
|
}
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
/* check the channel's mtu and whether it is still attached. */
|
|
|
|
spin_lock_bh(&pch->downl);
|
2005-05-12 16:47:12 -07:00
|
|
|
if (pch->chan == NULL) {
|
ppp: ppp_mp_explode() redesign
I found the PPP subsystem to not work properly when connecting channels
with different speeds to the same bundle.
Problem Description:
As the "ppp_mp_explode" function fragments the sk_buff buffer evenly
among the PPP channels that are connected to a certain PPP unit to
make up a bundle, if we are transmitting using an upper layer protocol
that requires an Ack before sending the next packet (like TCP/IP for
example), we will have a bandwidth bottleneck on the slowest channel
of the bundle.
Let's clarify by an example. Let's consider a scenario where we have
two PPP links making up a bundle: a slow link (10KB/sec) and a fast
link (1000KB/sec) working at the best (full bandwidth). On the top we
have a TCP/IP stack sending a 1000 Bytes sk_buff buffer down to the
PPP subsystem. The "ppp_mp_explode" function will divide the buffer in
two fragments of 500B each (we are neglecting all the headers, crc,
flags etc?.). Before the TCP/IP stack sends out the next buffer, it
will have to wait for the ACK response from the remote peer, so it
will have to wait for both fragments to have been sent over the two
PPP links, received by the remote peer and reconstructed. The
resulting behaviour is that, rather than having a bundle working
@1010KB/sec (the sum of the channels bandwidths), we'll have a bundle
working @20KB/sec (the double of the slowest channels bandwidth).
Problem Solution:
The problem has been solved by redesigning the "ppp_mp_explode"
function in such a way to make it split the sk_buff buffer according
to the speeds of the underlying PPP channels (the speeds of the serial
interfaces respectively attached to the PPP channels). Referring to
the above example, the redesigned "ppp_mp_explode" function will now
divide the 1000 Bytes buffer into two fragments whose sizes are set
according to the speeds of the channels where they are going to be
sent on (e.g . 10 Byets on 10KB/sec channel and 990 Bytes on
1000KB/sec channel). The reworked function grants the same
performances of the original one in optimal working conditions (i.e. a
bundle made up of PPP links all working at the same speed), while
greatly improving performances on the bundles made up of channels
working at different speeds.
Signed-off-by: Gabriele Paoloni <gabriele.paoloni@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2009-03-13 16:09:12 -07:00
|
|
|
/* can't use this channel, it's being deregistered */
|
|
|
|
if (pch->speed == 0)
|
|
|
|
nzero--;
|
|
|
|
else
|
|
|
|
totspeed -= pch->speed;
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
spin_unlock_bh(&pch->downl);
|
|
|
|
pch->avail = 0;
|
ppp: ppp_mp_explode() redesign
I found the PPP subsystem to not work properly when connecting channels
with different speeds to the same bundle.
Problem Description:
As the "ppp_mp_explode" function fragments the sk_buff buffer evenly
among the PPP channels that are connected to a certain PPP unit to
make up a bundle, if we are transmitting using an upper layer protocol
that requires an Ack before sending the next packet (like TCP/IP for
example), we will have a bandwidth bottleneck on the slowest channel
of the bundle.
Let's clarify by an example. Let's consider a scenario where we have
two PPP links making up a bundle: a slow link (10KB/sec) and a fast
link (1000KB/sec) working at the best (full bandwidth). On the top we
have a TCP/IP stack sending a 1000 Bytes sk_buff buffer down to the
PPP subsystem. The "ppp_mp_explode" function will divide the buffer in
two fragments of 500B each (we are neglecting all the headers, crc,
flags etc?.). Before the TCP/IP stack sends out the next buffer, it
will have to wait for the ACK response from the remote peer, so it
will have to wait for both fragments to have been sent over the two
PPP links, received by the remote peer and reconstructed. The
resulting behaviour is that, rather than having a bundle working
@1010KB/sec (the sum of the channels bandwidths), we'll have a bundle
working @20KB/sec (the double of the slowest channels bandwidth).
Problem Solution:
The problem has been solved by redesigning the "ppp_mp_explode"
function in such a way to make it split the sk_buff buffer according
to the speeds of the underlying PPP channels (the speeds of the serial
interfaces respectively attached to the PPP channels). Referring to
the above example, the redesigned "ppp_mp_explode" function will now
divide the 1000 Bytes buffer into two fragments whose sizes are set
according to the speeds of the channels where they are going to be
sent on (e.g . 10 Byets on 10KB/sec channel and 990 Bytes on
1000KB/sec channel). The reworked function grants the same
performances of the original one in optimal working conditions (i.e. a
bundle made up of PPP links all working at the same speed), while
greatly improving performances on the bundles made up of channels
working at different speeds.
Signed-off-by: Gabriele Paoloni <gabriele.paoloni@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2009-03-13 16:09:12 -07:00
|
|
|
totlen = len;
|
|
|
|
totfree--;
|
|
|
|
nfree--;
|
|
|
|
if (--navail == 0)
|
2005-04-16 15:20:36 -07:00
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
ppp: ppp_mp_explode() redesign
I found the PPP subsystem to not work properly when connecting channels
with different speeds to the same bundle.
Problem Description:
As the "ppp_mp_explode" function fragments the sk_buff buffer evenly
among the PPP channels that are connected to a certain PPP unit to
make up a bundle, if we are transmitting using an upper layer protocol
that requires an Ack before sending the next packet (like TCP/IP for
example), we will have a bandwidth bottleneck on the slowest channel
of the bundle.
Let's clarify by an example. Let's consider a scenario where we have
two PPP links making up a bundle: a slow link (10KB/sec) and a fast
link (1000KB/sec) working at the best (full bandwidth). On the top we
have a TCP/IP stack sending a 1000 Bytes sk_buff buffer down to the
PPP subsystem. The "ppp_mp_explode" function will divide the buffer in
two fragments of 500B each (we are neglecting all the headers, crc,
flags etc?.). Before the TCP/IP stack sends out the next buffer, it
will have to wait for the ACK response from the remote peer, so it
will have to wait for both fragments to have been sent over the two
PPP links, received by the remote peer and reconstructed. The
resulting behaviour is that, rather than having a bundle working
@1010KB/sec (the sum of the channels bandwidths), we'll have a bundle
working @20KB/sec (the double of the slowest channels bandwidth).
Problem Solution:
The problem has been solved by redesigning the "ppp_mp_explode"
function in such a way to make it split the sk_buff buffer according
to the speeds of the underlying PPP channels (the speeds of the serial
interfaces respectively attached to the PPP channels). Referring to
the above example, the redesigned "ppp_mp_explode" function will now
divide the 1000 Bytes buffer into two fragments whose sizes are set
according to the speeds of the channels where they are going to be
sent on (e.g . 10 Byets on 10KB/sec channel and 990 Bytes on
1000KB/sec channel). The reworked function grants the same
performances of the original one in optimal working conditions (i.e. a
bundle made up of PPP links all working at the same speed), while
greatly improving performances on the bundles made up of channels
working at different speeds.
Signed-off-by: Gabriele Paoloni <gabriele.paoloni@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2009-03-13 16:09:12 -07:00
|
|
|
*if the channel speed is not set divide
|
|
|
|
*the packet evenly among the free channels;
|
|
|
|
*otherwise divide it according to the speed
|
|
|
|
*of the channel we are going to transmit on
|
|
|
|
*/
|
2009-08-19 13:55:55 -07:00
|
|
|
flen = len;
|
2009-07-28 00:43:57 -07:00
|
|
|
if (nfree > 0) {
|
|
|
|
if (pch->speed == 0) {
|
|
|
|
flen = totlen/nfree ;
|
|
|
|
if (nbigger > 0) {
|
|
|
|
flen++;
|
|
|
|
nbigger--;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
flen = (((totfree - nzero)*(totlen + hdrlen*totfree)) /
|
|
|
|
((totspeed*totfree)/pch->speed)) - hdrlen;
|
|
|
|
if (nbigger > 0) {
|
|
|
|
flen += ((totfree - nzero)*pch->speed)/totspeed;
|
|
|
|
nbigger -= ((totfree - nzero)*pch->speed)/
|
ppp: ppp_mp_explode() redesign
I found the PPP subsystem to not work properly when connecting channels
with different speeds to the same bundle.
Problem Description:
As the "ppp_mp_explode" function fragments the sk_buff buffer evenly
among the PPP channels that are connected to a certain PPP unit to
make up a bundle, if we are transmitting using an upper layer protocol
that requires an Ack before sending the next packet (like TCP/IP for
example), we will have a bandwidth bottleneck on the slowest channel
of the bundle.
Let's clarify by an example. Let's consider a scenario where we have
two PPP links making up a bundle: a slow link (10KB/sec) and a fast
link (1000KB/sec) working at the best (full bandwidth). On the top we
have a TCP/IP stack sending a 1000 Bytes sk_buff buffer down to the
PPP subsystem. The "ppp_mp_explode" function will divide the buffer in
two fragments of 500B each (we are neglecting all the headers, crc,
flags etc?.). Before the TCP/IP stack sends out the next buffer, it
will have to wait for the ACK response from the remote peer, so it
will have to wait for both fragments to have been sent over the two
PPP links, received by the remote peer and reconstructed. The
resulting behaviour is that, rather than having a bundle working
@1010KB/sec (the sum of the channels bandwidths), we'll have a bundle
working @20KB/sec (the double of the slowest channels bandwidth).
Problem Solution:
The problem has been solved by redesigning the "ppp_mp_explode"
function in such a way to make it split the sk_buff buffer according
to the speeds of the underlying PPP channels (the speeds of the serial
interfaces respectively attached to the PPP channels). Referring to
the above example, the redesigned "ppp_mp_explode" function will now
divide the 1000 Bytes buffer into two fragments whose sizes are set
according to the speeds of the channels where they are going to be
sent on (e.g . 10 Byets on 10KB/sec channel and 990 Bytes on
1000KB/sec channel). The reworked function grants the same
performances of the original one in optimal working conditions (i.e. a
bundle made up of PPP links all working at the same speed), while
greatly improving performances on the bundles made up of channels
working at different speeds.
Signed-off-by: Gabriele Paoloni <gabriele.paoloni@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2009-03-13 16:09:12 -07:00
|
|
|
totspeed;
|
2009-07-28 00:43:57 -07:00
|
|
|
}
|
ppp: ppp_mp_explode() redesign
I found the PPP subsystem to not work properly when connecting channels
with different speeds to the same bundle.
Problem Description:
As the "ppp_mp_explode" function fragments the sk_buff buffer evenly
among the PPP channels that are connected to a certain PPP unit to
make up a bundle, if we are transmitting using an upper layer protocol
that requires an Ack before sending the next packet (like TCP/IP for
example), we will have a bandwidth bottleneck on the slowest channel
of the bundle.
Let's clarify by an example. Let's consider a scenario where we have
two PPP links making up a bundle: a slow link (10KB/sec) and a fast
link (1000KB/sec) working at the best (full bandwidth). On the top we
have a TCP/IP stack sending a 1000 Bytes sk_buff buffer down to the
PPP subsystem. The "ppp_mp_explode" function will divide the buffer in
two fragments of 500B each (we are neglecting all the headers, crc,
flags etc?.). Before the TCP/IP stack sends out the next buffer, it
will have to wait for the ACK response from the remote peer, so it
will have to wait for both fragments to have been sent over the two
PPP links, received by the remote peer and reconstructed. The
resulting behaviour is that, rather than having a bundle working
@1010KB/sec (the sum of the channels bandwidths), we'll have a bundle
working @20KB/sec (the double of the slowest channels bandwidth).
Problem Solution:
The problem has been solved by redesigning the "ppp_mp_explode"
function in such a way to make it split the sk_buff buffer according
to the speeds of the underlying PPP channels (the speeds of the serial
interfaces respectively attached to the PPP channels). Referring to
the above example, the redesigned "ppp_mp_explode" function will now
divide the 1000 Bytes buffer into two fragments whose sizes are set
according to the speeds of the channels where they are going to be
sent on (e.g . 10 Byets on 10KB/sec channel and 990 Bytes on
1000KB/sec channel). The reworked function grants the same
performances of the original one in optimal working conditions (i.e. a
bundle made up of PPP links all working at the same speed), while
greatly improving performances on the bundles made up of channels
working at different speeds.
Signed-off-by: Gabriele Paoloni <gabriele.paoloni@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2009-03-13 16:09:12 -07:00
|
|
|
}
|
2009-07-28 00:43:57 -07:00
|
|
|
nfree--;
|
ppp: ppp_mp_explode() redesign
I found the PPP subsystem to not work properly when connecting channels
with different speeds to the same bundle.
Problem Description:
As the "ppp_mp_explode" function fragments the sk_buff buffer evenly
among the PPP channels that are connected to a certain PPP unit to
make up a bundle, if we are transmitting using an upper layer protocol
that requires an Ack before sending the next packet (like TCP/IP for
example), we will have a bandwidth bottleneck on the slowest channel
of the bundle.
Let's clarify by an example. Let's consider a scenario where we have
two PPP links making up a bundle: a slow link (10KB/sec) and a fast
link (1000KB/sec) working at the best (full bandwidth). On the top we
have a TCP/IP stack sending a 1000 Bytes sk_buff buffer down to the
PPP subsystem. The "ppp_mp_explode" function will divide the buffer in
two fragments of 500B each (we are neglecting all the headers, crc,
flags etc?.). Before the TCP/IP stack sends out the next buffer, it
will have to wait for the ACK response from the remote peer, so it
will have to wait for both fragments to have been sent over the two
PPP links, received by the remote peer and reconstructed. The
resulting behaviour is that, rather than having a bundle working
@1010KB/sec (the sum of the channels bandwidths), we'll have a bundle
working @20KB/sec (the double of the slowest channels bandwidth).
Problem Solution:
The problem has been solved by redesigning the "ppp_mp_explode"
function in such a way to make it split the sk_buff buffer according
to the speeds of the underlying PPP channels (the speeds of the serial
interfaces respectively attached to the PPP channels). Referring to
the above example, the redesigned "ppp_mp_explode" function will now
divide the 1000 Bytes buffer into two fragments whose sizes are set
according to the speeds of the channels where they are going to be
sent on (e.g . 10 Byets on 10KB/sec channel and 990 Bytes on
1000KB/sec channel). The reworked function grants the same
performances of the original one in optimal working conditions (i.e. a
bundle made up of PPP links all working at the same speed), while
greatly improving performances on the bundles made up of channels
working at different speeds.
Signed-off-by: Gabriele Paoloni <gabriele.paoloni@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2009-03-13 16:09:12 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
*check if we are on the last channel or
|
|
|
|
*we exceded the lenght of the data to
|
|
|
|
*fragment
|
|
|
|
*/
|
2009-07-28 00:43:57 -07:00
|
|
|
if ((nfree <= 0) || (flen > len))
|
ppp: ppp_mp_explode() redesign
I found the PPP subsystem to not work properly when connecting channels
with different speeds to the same bundle.
Problem Description:
As the "ppp_mp_explode" function fragments the sk_buff buffer evenly
among the PPP channels that are connected to a certain PPP unit to
make up a bundle, if we are transmitting using an upper layer protocol
that requires an Ack before sending the next packet (like TCP/IP for
example), we will have a bandwidth bottleneck on the slowest channel
of the bundle.
Let's clarify by an example. Let's consider a scenario where we have
two PPP links making up a bundle: a slow link (10KB/sec) and a fast
link (1000KB/sec) working at the best (full bandwidth). On the top we
have a TCP/IP stack sending a 1000 Bytes sk_buff buffer down to the
PPP subsystem. The "ppp_mp_explode" function will divide the buffer in
two fragments of 500B each (we are neglecting all the headers, crc,
flags etc?.). Before the TCP/IP stack sends out the next buffer, it
will have to wait for the ACK response from the remote peer, so it
will have to wait for both fragments to have been sent over the two
PPP links, received by the remote peer and reconstructed. The
resulting behaviour is that, rather than having a bundle working
@1010KB/sec (the sum of the channels bandwidths), we'll have a bundle
working @20KB/sec (the double of the slowest channels bandwidth).
Problem Solution:
The problem has been solved by redesigning the "ppp_mp_explode"
function in such a way to make it split the sk_buff buffer according
to the speeds of the underlying PPP channels (the speeds of the serial
interfaces respectively attached to the PPP channels). Referring to
the above example, the redesigned "ppp_mp_explode" function will now
divide the 1000 Bytes buffer into two fragments whose sizes are set
according to the speeds of the channels where they are going to be
sent on (e.g . 10 Byets on 10KB/sec channel and 990 Bytes on
1000KB/sec channel). The reworked function grants the same
performances of the original one in optimal working conditions (i.e. a
bundle made up of PPP links all working at the same speed), while
greatly improving performances on the bundles made up of channels
working at different speeds.
Signed-off-by: Gabriele Paoloni <gabriele.paoloni@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2009-03-13 16:09:12 -07:00
|
|
|
flen = len;
|
|
|
|
/*
|
|
|
|
*it is not worth to tx on slow channels:
|
|
|
|
*in that case from the resulting flen according to the
|
|
|
|
*above formula will be equal or less than zero.
|
|
|
|
*Skip the channel in this case
|
2005-04-16 15:20:36 -07:00
|
|
|
*/
|
ppp: ppp_mp_explode() redesign
I found the PPP subsystem to not work properly when connecting channels
with different speeds to the same bundle.
Problem Description:
As the "ppp_mp_explode" function fragments the sk_buff buffer evenly
among the PPP channels that are connected to a certain PPP unit to
make up a bundle, if we are transmitting using an upper layer protocol
that requires an Ack before sending the next packet (like TCP/IP for
example), we will have a bandwidth bottleneck on the slowest channel
of the bundle.
Let's clarify by an example. Let's consider a scenario where we have
two PPP links making up a bundle: a slow link (10KB/sec) and a fast
link (1000KB/sec) working at the best (full bandwidth). On the top we
have a TCP/IP stack sending a 1000 Bytes sk_buff buffer down to the
PPP subsystem. The "ppp_mp_explode" function will divide the buffer in
two fragments of 500B each (we are neglecting all the headers, crc,
flags etc?.). Before the TCP/IP stack sends out the next buffer, it
will have to wait for the ACK response from the remote peer, so it
will have to wait for both fragments to have been sent over the two
PPP links, received by the remote peer and reconstructed. The
resulting behaviour is that, rather than having a bundle working
@1010KB/sec (the sum of the channels bandwidths), we'll have a bundle
working @20KB/sec (the double of the slowest channels bandwidth).
Problem Solution:
The problem has been solved by redesigning the "ppp_mp_explode"
function in such a way to make it split the sk_buff buffer according
to the speeds of the underlying PPP channels (the speeds of the serial
interfaces respectively attached to the PPP channels). Referring to
the above example, the redesigned "ppp_mp_explode" function will now
divide the 1000 Bytes buffer into two fragments whose sizes are set
according to the speeds of the channels where they are going to be
sent on (e.g . 10 Byets on 10KB/sec channel and 990 Bytes on
1000KB/sec channel). The reworked function grants the same
performances of the original one in optimal working conditions (i.e. a
bundle made up of PPP links all working at the same speed), while
greatly improving performances on the bundles made up of channels
working at different speeds.
Signed-off-by: Gabriele Paoloni <gabriele.paoloni@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2009-03-13 16:09:12 -07:00
|
|
|
if (flen <= 0) {
|
|
|
|
pch->avail = 2;
|
|
|
|
spin_unlock_bh(&pch->downl);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2009-07-28 00:43:57 -07:00
|
|
|
mtu = pch->chan->mtu - hdrlen;
|
ppp: ppp_mp_explode() redesign
I found the PPP subsystem to not work properly when connecting channels
with different speeds to the same bundle.
Problem Description:
As the "ppp_mp_explode" function fragments the sk_buff buffer evenly
among the PPP channels that are connected to a certain PPP unit to
make up a bundle, if we are transmitting using an upper layer protocol
that requires an Ack before sending the next packet (like TCP/IP for
example), we will have a bandwidth bottleneck on the slowest channel
of the bundle.
Let's clarify by an example. Let's consider a scenario where we have
two PPP links making up a bundle: a slow link (10KB/sec) and a fast
link (1000KB/sec) working at the best (full bandwidth). On the top we
have a TCP/IP stack sending a 1000 Bytes sk_buff buffer down to the
PPP subsystem. The "ppp_mp_explode" function will divide the buffer in
two fragments of 500B each (we are neglecting all the headers, crc,
flags etc?.). Before the TCP/IP stack sends out the next buffer, it
will have to wait for the ACK response from the remote peer, so it
will have to wait for both fragments to have been sent over the two
PPP links, received by the remote peer and reconstructed. The
resulting behaviour is that, rather than having a bundle working
@1010KB/sec (the sum of the channels bandwidths), we'll have a bundle
working @20KB/sec (the double of the slowest channels bandwidth).
Problem Solution:
The problem has been solved by redesigning the "ppp_mp_explode"
function in such a way to make it split the sk_buff buffer according
to the speeds of the underlying PPP channels (the speeds of the serial
interfaces respectively attached to the PPP channels). Referring to
the above example, the redesigned "ppp_mp_explode" function will now
divide the 1000 Bytes buffer into two fragments whose sizes are set
according to the speeds of the channels where they are going to be
sent on (e.g . 10 Byets on 10KB/sec channel and 990 Bytes on
1000KB/sec channel). The reworked function grants the same
performances of the original one in optimal working conditions (i.e. a
bundle made up of PPP links all working at the same speed), while
greatly improving performances on the bundles made up of channels
working at different speeds.
Signed-off-by: Gabriele Paoloni <gabriele.paoloni@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2009-03-13 16:09:12 -07:00
|
|
|
if (mtu < 4)
|
|
|
|
mtu = 4;
|
2005-05-12 16:47:12 -07:00
|
|
|
if (flen > mtu)
|
|
|
|
flen = mtu;
|
ppp: ppp_mp_explode() redesign
I found the PPP subsystem to not work properly when connecting channels
with different speeds to the same bundle.
Problem Description:
As the "ppp_mp_explode" function fragments the sk_buff buffer evenly
among the PPP channels that are connected to a certain PPP unit to
make up a bundle, if we are transmitting using an upper layer protocol
that requires an Ack before sending the next packet (like TCP/IP for
example), we will have a bandwidth bottleneck on the slowest channel
of the bundle.
Let's clarify by an example. Let's consider a scenario where we have
two PPP links making up a bundle: a slow link (10KB/sec) and a fast
link (1000KB/sec) working at the best (full bandwidth). On the top we
have a TCP/IP stack sending a 1000 Bytes sk_buff buffer down to the
PPP subsystem. The "ppp_mp_explode" function will divide the buffer in
two fragments of 500B each (we are neglecting all the headers, crc,
flags etc?.). Before the TCP/IP stack sends out the next buffer, it
will have to wait for the ACK response from the remote peer, so it
will have to wait for both fragments to have been sent over the two
PPP links, received by the remote peer and reconstructed. The
resulting behaviour is that, rather than having a bundle working
@1010KB/sec (the sum of the channels bandwidths), we'll have a bundle
working @20KB/sec (the double of the slowest channels bandwidth).
Problem Solution:
The problem has been solved by redesigning the "ppp_mp_explode"
function in such a way to make it split the sk_buff buffer according
to the speeds of the underlying PPP channels (the speeds of the serial
interfaces respectively attached to the PPP channels). Referring to
the above example, the redesigned "ppp_mp_explode" function will now
divide the 1000 Bytes buffer into two fragments whose sizes are set
according to the speeds of the channels where they are going to be
sent on (e.g . 10 Byets on 10KB/sec channel and 990 Bytes on
1000KB/sec channel). The reworked function grants the same
performances of the original one in optimal working conditions (i.e. a
bundle made up of PPP links all working at the same speed), while
greatly improving performances on the bundles made up of channels
working at different speeds.
Signed-off-by: Gabriele Paoloni <gabriele.paoloni@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2009-03-13 16:09:12 -07:00
|
|
|
if (flen == len)
|
|
|
|
bits |= E;
|
|
|
|
frag = alloc_skb(flen + hdrlen + (flen == 0), GFP_ATOMIC);
|
2007-11-12 19:07:31 -07:00
|
|
|
if (!frag)
|
2005-05-12 16:47:12 -07:00
|
|
|
goto noskb;
|
ppp: ppp_mp_explode() redesign
I found the PPP subsystem to not work properly when connecting channels
with different speeds to the same bundle.
Problem Description:
As the "ppp_mp_explode" function fragments the sk_buff buffer evenly
among the PPP channels that are connected to a certain PPP unit to
make up a bundle, if we are transmitting using an upper layer protocol
that requires an Ack before sending the next packet (like TCP/IP for
example), we will have a bandwidth bottleneck on the slowest channel
of the bundle.
Let's clarify by an example. Let's consider a scenario where we have
two PPP links making up a bundle: a slow link (10KB/sec) and a fast
link (1000KB/sec) working at the best (full bandwidth). On the top we
have a TCP/IP stack sending a 1000 Bytes sk_buff buffer down to the
PPP subsystem. The "ppp_mp_explode" function will divide the buffer in
two fragments of 500B each (we are neglecting all the headers, crc,
flags etc?.). Before the TCP/IP stack sends out the next buffer, it
will have to wait for the ACK response from the remote peer, so it
will have to wait for both fragments to have been sent over the two
PPP links, received by the remote peer and reconstructed. The
resulting behaviour is that, rather than having a bundle working
@1010KB/sec (the sum of the channels bandwidths), we'll have a bundle
working @20KB/sec (the double of the slowest channels bandwidth).
Problem Solution:
The problem has been solved by redesigning the "ppp_mp_explode"
function in such a way to make it split the sk_buff buffer according
to the speeds of the underlying PPP channels (the speeds of the serial
interfaces respectively attached to the PPP channels). Referring to
the above example, the redesigned "ppp_mp_explode" function will now
divide the 1000 Bytes buffer into two fragments whose sizes are set
according to the speeds of the channels where they are going to be
sent on (e.g . 10 Byets on 10KB/sec channel and 990 Bytes on
1000KB/sec channel). The reworked function grants the same
performances of the original one in optimal working conditions (i.e. a
bundle made up of PPP links all working at the same speed), while
greatly improving performances on the bundles made up of channels
working at different speeds.
Signed-off-by: Gabriele Paoloni <gabriele.paoloni@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2009-03-13 16:09:12 -07:00
|
|
|
q = skb_put(frag, flen + hdrlen);
|
2005-05-12 16:47:12 -07:00
|
|
|
|
ppp: ppp_mp_explode() redesign
I found the PPP subsystem to not work properly when connecting channels
with different speeds to the same bundle.
Problem Description:
As the "ppp_mp_explode" function fragments the sk_buff buffer evenly
among the PPP channels that are connected to a certain PPP unit to
make up a bundle, if we are transmitting using an upper layer protocol
that requires an Ack before sending the next packet (like TCP/IP for
example), we will have a bandwidth bottleneck on the slowest channel
of the bundle.
Let's clarify by an example. Let's consider a scenario where we have
two PPP links making up a bundle: a slow link (10KB/sec) and a fast
link (1000KB/sec) working at the best (full bandwidth). On the top we
have a TCP/IP stack sending a 1000 Bytes sk_buff buffer down to the
PPP subsystem. The "ppp_mp_explode" function will divide the buffer in
two fragments of 500B each (we are neglecting all the headers, crc,
flags etc?.). Before the TCP/IP stack sends out the next buffer, it
will have to wait for the ACK response from the remote peer, so it
will have to wait for both fragments to have been sent over the two
PPP links, received by the remote peer and reconstructed. The
resulting behaviour is that, rather than having a bundle working
@1010KB/sec (the sum of the channels bandwidths), we'll have a bundle
working @20KB/sec (the double of the slowest channels bandwidth).
Problem Solution:
The problem has been solved by redesigning the "ppp_mp_explode"
function in such a way to make it split the sk_buff buffer according
to the speeds of the underlying PPP channels (the speeds of the serial
interfaces respectively attached to the PPP channels). Referring to
the above example, the redesigned "ppp_mp_explode" function will now
divide the 1000 Bytes buffer into two fragments whose sizes are set
according to the speeds of the channels where they are going to be
sent on (e.g . 10 Byets on 10KB/sec channel and 990 Bytes on
1000KB/sec channel). The reworked function grants the same
performances of the original one in optimal working conditions (i.e. a
bundle made up of PPP links all working at the same speed), while
greatly improving performances on the bundles made up of channels
working at different speeds.
Signed-off-by: Gabriele Paoloni <gabriele.paoloni@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2009-03-13 16:09:12 -07:00
|
|
|
/* make the MP header */
|
2005-05-12 16:47:12 -07:00
|
|
|
q[0] = PPP_MP >> 8;
|
|
|
|
q[1] = PPP_MP;
|
|
|
|
if (ppp->flags & SC_MP_XSHORTSEQ) {
|
ppp: ppp_mp_explode() redesign
I found the PPP subsystem to not work properly when connecting channels
with different speeds to the same bundle.
Problem Description:
As the "ppp_mp_explode" function fragments the sk_buff buffer evenly
among the PPP channels that are connected to a certain PPP unit to
make up a bundle, if we are transmitting using an upper layer protocol
that requires an Ack before sending the next packet (like TCP/IP for
example), we will have a bandwidth bottleneck on the slowest channel
of the bundle.
Let's clarify by an example. Let's consider a scenario where we have
two PPP links making up a bundle: a slow link (10KB/sec) and a fast
link (1000KB/sec) working at the best (full bandwidth). On the top we
have a TCP/IP stack sending a 1000 Bytes sk_buff buffer down to the
PPP subsystem. The "ppp_mp_explode" function will divide the buffer in
two fragments of 500B each (we are neglecting all the headers, crc,
flags etc?.). Before the TCP/IP stack sends out the next buffer, it
will have to wait for the ACK response from the remote peer, so it
will have to wait for both fragments to have been sent over the two
PPP links, received by the remote peer and reconstructed. The
resulting behaviour is that, rather than having a bundle working
@1010KB/sec (the sum of the channels bandwidths), we'll have a bundle
working @20KB/sec (the double of the slowest channels bandwidth).
Problem Solution:
The problem has been solved by redesigning the "ppp_mp_explode"
function in such a way to make it split the sk_buff buffer according
to the speeds of the underlying PPP channels (the speeds of the serial
interfaces respectively attached to the PPP channels). Referring to
the above example, the redesigned "ppp_mp_explode" function will now
divide the 1000 Bytes buffer into two fragments whose sizes are set
according to the speeds of the channels where they are going to be
sent on (e.g . 10 Byets on 10KB/sec channel and 990 Bytes on
1000KB/sec channel). The reworked function grants the same
performances of the original one in optimal working conditions (i.e. a
bundle made up of PPP links all working at the same speed), while
greatly improving performances on the bundles made up of channels
working at different speeds.
Signed-off-by: Gabriele Paoloni <gabriele.paoloni@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2009-03-13 16:09:12 -07:00
|
|
|
q[2] = bits + ((ppp->nxseq >> 8) & 0xf);
|
2005-05-12 16:47:12 -07:00
|
|
|
q[3] = ppp->nxseq;
|
|
|
|
} else {
|
|
|
|
q[2] = bits;
|
|
|
|
q[3] = ppp->nxseq >> 16;
|
|
|
|
q[4] = ppp->nxseq >> 8;
|
|
|
|
q[5] = ppp->nxseq;
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
2005-05-12 16:47:12 -07:00
|
|
|
|
ppp: ppp_mp_explode() redesign
I found the PPP subsystem to not work properly when connecting channels
with different speeds to the same bundle.
Problem Description:
As the "ppp_mp_explode" function fragments the sk_buff buffer evenly
among the PPP channels that are connected to a certain PPP unit to
make up a bundle, if we are transmitting using an upper layer protocol
that requires an Ack before sending the next packet (like TCP/IP for
example), we will have a bandwidth bottleneck on the slowest channel
of the bundle.
Let's clarify by an example. Let's consider a scenario where we have
two PPP links making up a bundle: a slow link (10KB/sec) and a fast
link (1000KB/sec) working at the best (full bandwidth). On the top we
have a TCP/IP stack sending a 1000 Bytes sk_buff buffer down to the
PPP subsystem. The "ppp_mp_explode" function will divide the buffer in
two fragments of 500B each (we are neglecting all the headers, crc,
flags etc?.). Before the TCP/IP stack sends out the next buffer, it
will have to wait for the ACK response from the remote peer, so it
will have to wait for both fragments to have been sent over the two
PPP links, received by the remote peer and reconstructed. The
resulting behaviour is that, rather than having a bundle working
@1010KB/sec (the sum of the channels bandwidths), we'll have a bundle
working @20KB/sec (the double of the slowest channels bandwidth).
Problem Solution:
The problem has been solved by redesigning the "ppp_mp_explode"
function in such a way to make it split the sk_buff buffer according
to the speeds of the underlying PPP channels (the speeds of the serial
interfaces respectively attached to the PPP channels). Referring to
the above example, the redesigned "ppp_mp_explode" function will now
divide the 1000 Bytes buffer into two fragments whose sizes are set
according to the speeds of the channels where they are going to be
sent on (e.g . 10 Byets on 10KB/sec channel and 990 Bytes on
1000KB/sec channel). The reworked function grants the same
performances of the original one in optimal working conditions (i.e. a
bundle made up of PPP links all working at the same speed), while
greatly improving performances on the bundles made up of channels
working at different speeds.
Signed-off-by: Gabriele Paoloni <gabriele.paoloni@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2009-03-13 16:09:12 -07:00
|
|
|
memcpy(q + hdrlen, p, flen);
|
2005-05-12 16:47:12 -07:00
|
|
|
|
|
|
|
/* try to send it down the channel */
|
|
|
|
chan = pch->chan;
|
ppp: ppp_mp_explode() redesign
I found the PPP subsystem to not work properly when connecting channels
with different speeds to the same bundle.
Problem Description:
As the "ppp_mp_explode" function fragments the sk_buff buffer evenly
among the PPP channels that are connected to a certain PPP unit to
make up a bundle, if we are transmitting using an upper layer protocol
that requires an Ack before sending the next packet (like TCP/IP for
example), we will have a bandwidth bottleneck on the slowest channel
of the bundle.
Let's clarify by an example. Let's consider a scenario where we have
two PPP links making up a bundle: a slow link (10KB/sec) and a fast
link (1000KB/sec) working at the best (full bandwidth). On the top we
have a TCP/IP stack sending a 1000 Bytes sk_buff buffer down to the
PPP subsystem. The "ppp_mp_explode" function will divide the buffer in
two fragments of 500B each (we are neglecting all the headers, crc,
flags etc?.). Before the TCP/IP stack sends out the next buffer, it
will have to wait for the ACK response from the remote peer, so it
will have to wait for both fragments to have been sent over the two
PPP links, received by the remote peer and reconstructed. The
resulting behaviour is that, rather than having a bundle working
@1010KB/sec (the sum of the channels bandwidths), we'll have a bundle
working @20KB/sec (the double of the slowest channels bandwidth).
Problem Solution:
The problem has been solved by redesigning the "ppp_mp_explode"
function in such a way to make it split the sk_buff buffer according
to the speeds of the underlying PPP channels (the speeds of the serial
interfaces respectively attached to the PPP channels). Referring to
the above example, the redesigned "ppp_mp_explode" function will now
divide the 1000 Bytes buffer into two fragments whose sizes are set
according to the speeds of the channels where they are going to be
sent on (e.g . 10 Byets on 10KB/sec channel and 990 Bytes on
1000KB/sec channel). The reworked function grants the same
performances of the original one in optimal working conditions (i.e. a
bundle made up of PPP links all working at the same speed), while
greatly improving performances on the bundles made up of channels
working at different speeds.
Signed-off-by: Gabriele Paoloni <gabriele.paoloni@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2009-03-13 16:09:12 -07:00
|
|
|
if (!skb_queue_empty(&pch->file.xq) ||
|
|
|
|
!chan->ops->start_xmit(chan, frag))
|
2005-05-12 16:47:12 -07:00
|
|
|
skb_queue_tail(&pch->file.xq, frag);
|
ppp: ppp_mp_explode() redesign
I found the PPP subsystem to not work properly when connecting channels
with different speeds to the same bundle.
Problem Description:
As the "ppp_mp_explode" function fragments the sk_buff buffer evenly
among the PPP channels that are connected to a certain PPP unit to
make up a bundle, if we are transmitting using an upper layer protocol
that requires an Ack before sending the next packet (like TCP/IP for
example), we will have a bandwidth bottleneck on the slowest channel
of the bundle.
Let's clarify by an example. Let's consider a scenario where we have
two PPP links making up a bundle: a slow link (10KB/sec) and a fast
link (1000KB/sec) working at the best (full bandwidth). On the top we
have a TCP/IP stack sending a 1000 Bytes sk_buff buffer down to the
PPP subsystem. The "ppp_mp_explode" function will divide the buffer in
two fragments of 500B each (we are neglecting all the headers, crc,
flags etc?.). Before the TCP/IP stack sends out the next buffer, it
will have to wait for the ACK response from the remote peer, so it
will have to wait for both fragments to have been sent over the two
PPP links, received by the remote peer and reconstructed. The
resulting behaviour is that, rather than having a bundle working
@1010KB/sec (the sum of the channels bandwidths), we'll have a bundle
working @20KB/sec (the double of the slowest channels bandwidth).
Problem Solution:
The problem has been solved by redesigning the "ppp_mp_explode"
function in such a way to make it split the sk_buff buffer according
to the speeds of the underlying PPP channels (the speeds of the serial
interfaces respectively attached to the PPP channels). Referring to
the above example, the redesigned "ppp_mp_explode" function will now
divide the 1000 Bytes buffer into two fragments whose sizes are set
according to the speeds of the channels where they are going to be
sent on (e.g . 10 Byets on 10KB/sec channel and 990 Bytes on
1000KB/sec channel). The reworked function grants the same
performances of the original one in optimal working conditions (i.e. a
bundle made up of PPP links all working at the same speed), while
greatly improving performances on the bundles made up of channels
working at different speeds.
Signed-off-by: Gabriele Paoloni <gabriele.paoloni@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2009-03-13 16:09:12 -07:00
|
|
|
pch->had_frag = 1;
|
2005-05-12 16:47:12 -07:00
|
|
|
p += flen;
|
ppp: ppp_mp_explode() redesign
I found the PPP subsystem to not work properly when connecting channels
with different speeds to the same bundle.
Problem Description:
As the "ppp_mp_explode" function fragments the sk_buff buffer evenly
among the PPP channels that are connected to a certain PPP unit to
make up a bundle, if we are transmitting using an upper layer protocol
that requires an Ack before sending the next packet (like TCP/IP for
example), we will have a bandwidth bottleneck on the slowest channel
of the bundle.
Let's clarify by an example. Let's consider a scenario where we have
two PPP links making up a bundle: a slow link (10KB/sec) and a fast
link (1000KB/sec) working at the best (full bandwidth). On the top we
have a TCP/IP stack sending a 1000 Bytes sk_buff buffer down to the
PPP subsystem. The "ppp_mp_explode" function will divide the buffer in
two fragments of 500B each (we are neglecting all the headers, crc,
flags etc?.). Before the TCP/IP stack sends out the next buffer, it
will have to wait for the ACK response from the remote peer, so it
will have to wait for both fragments to have been sent over the two
PPP links, received by the remote peer and reconstructed. The
resulting behaviour is that, rather than having a bundle working
@1010KB/sec (the sum of the channels bandwidths), we'll have a bundle
working @20KB/sec (the double of the slowest channels bandwidth).
Problem Solution:
The problem has been solved by redesigning the "ppp_mp_explode"
function in such a way to make it split the sk_buff buffer according
to the speeds of the underlying PPP channels (the speeds of the serial
interfaces respectively attached to the PPP channels). Referring to
the above example, the redesigned "ppp_mp_explode" function will now
divide the 1000 Bytes buffer into two fragments whose sizes are set
according to the speeds of the channels where they are going to be
sent on (e.g . 10 Byets on 10KB/sec channel and 990 Bytes on
1000KB/sec channel). The reworked function grants the same
performances of the original one in optimal working conditions (i.e. a
bundle made up of PPP links all working at the same speed), while
greatly improving performances on the bundles made up of channels
working at different speeds.
Signed-off-by: Gabriele Paoloni <gabriele.paoloni@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2009-03-13 16:09:12 -07:00
|
|
|
len -= flen;
|
2005-05-12 16:47:12 -07:00
|
|
|
++ppp->nxseq;
|
|
|
|
bits = 0;
|
2005-04-16 15:20:36 -07:00
|
|
|
spin_unlock_bh(&pch->downl);
|
2005-05-12 16:47:12 -07:00
|
|
|
}
|
ppp: ppp_mp_explode() redesign
I found the PPP subsystem to not work properly when connecting channels
with different speeds to the same bundle.
Problem Description:
As the "ppp_mp_explode" function fragments the sk_buff buffer evenly
among the PPP channels that are connected to a certain PPP unit to
make up a bundle, if we are transmitting using an upper layer protocol
that requires an Ack before sending the next packet (like TCP/IP for
example), we will have a bandwidth bottleneck on the slowest channel
of the bundle.
Let's clarify by an example. Let's consider a scenario where we have
two PPP links making up a bundle: a slow link (10KB/sec) and a fast
link (1000KB/sec) working at the best (full bandwidth). On the top we
have a TCP/IP stack sending a 1000 Bytes sk_buff buffer down to the
PPP subsystem. The "ppp_mp_explode" function will divide the buffer in
two fragments of 500B each (we are neglecting all the headers, crc,
flags etc?.). Before the TCP/IP stack sends out the next buffer, it
will have to wait for the ACK response from the remote peer, so it
will have to wait for both fragments to have been sent over the two
PPP links, received by the remote peer and reconstructed. The
resulting behaviour is that, rather than having a bundle working
@1010KB/sec (the sum of the channels bandwidths), we'll have a bundle
working @20KB/sec (the double of the slowest channels bandwidth).
Problem Solution:
The problem has been solved by redesigning the "ppp_mp_explode"
function in such a way to make it split the sk_buff buffer according
to the speeds of the underlying PPP channels (the speeds of the serial
interfaces respectively attached to the PPP channels). Referring to
the above example, the redesigned "ppp_mp_explode" function will now
divide the 1000 Bytes buffer into two fragments whose sizes are set
according to the speeds of the channels where they are going to be
sent on (e.g . 10 Byets on 10KB/sec channel and 990 Bytes on
1000KB/sec channel). The reworked function grants the same
performances of the original one in optimal working conditions (i.e. a
bundle made up of PPP links all working at the same speed), while
greatly improving performances on the bundles made up of channels
working at different speeds.
Signed-off-by: Gabriele Paoloni <gabriele.paoloni@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2009-03-13 16:09:12 -07:00
|
|
|
ppp->nxchan = i;
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
noskb:
|
|
|
|
spin_unlock_bh(&pch->downl);
|
|
|
|
if (ppp->debug & 1)
|
ppp: ppp_mp_explode() redesign
I found the PPP subsystem to not work properly when connecting channels
with different speeds to the same bundle.
Problem Description:
As the "ppp_mp_explode" function fragments the sk_buff buffer evenly
among the PPP channels that are connected to a certain PPP unit to
make up a bundle, if we are transmitting using an upper layer protocol
that requires an Ack before sending the next packet (like TCP/IP for
example), we will have a bandwidth bottleneck on the slowest channel
of the bundle.
Let's clarify by an example. Let's consider a scenario where we have
two PPP links making up a bundle: a slow link (10KB/sec) and a fast
link (1000KB/sec) working at the best (full bandwidth). On the top we
have a TCP/IP stack sending a 1000 Bytes sk_buff buffer down to the
PPP subsystem. The "ppp_mp_explode" function will divide the buffer in
two fragments of 500B each (we are neglecting all the headers, crc,
flags etc?.). Before the TCP/IP stack sends out the next buffer, it
will have to wait for the ACK response from the remote peer, so it
will have to wait for both fragments to have been sent over the two
PPP links, received by the remote peer and reconstructed. The
resulting behaviour is that, rather than having a bundle working
@1010KB/sec (the sum of the channels bandwidths), we'll have a bundle
working @20KB/sec (the double of the slowest channels bandwidth).
Problem Solution:
The problem has been solved by redesigning the "ppp_mp_explode"
function in such a way to make it split the sk_buff buffer according
to the speeds of the underlying PPP channels (the speeds of the serial
interfaces respectively attached to the PPP channels). Referring to
the above example, the redesigned "ppp_mp_explode" function will now
divide the 1000 Bytes buffer into two fragments whose sizes are set
according to the speeds of the channels where they are going to be
sent on (e.g . 10 Byets on 10KB/sec channel and 990 Bytes on
1000KB/sec channel). The reworked function grants the same
performances of the original one in optimal working conditions (i.e. a
bundle made up of PPP links all working at the same speed), while
greatly improving performances on the bundles made up of channels
working at different speeds.
Signed-off-by: Gabriele Paoloni <gabriele.paoloni@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2009-03-13 16:09:12 -07:00
|
|
|
printk(KERN_ERR "PPP: no memory (fragment)\n");
|
2008-04-23 18:54:01 -07:00
|
|
|
++ppp->dev->stats.tx_errors;
|
2005-04-16 15:20:36 -07:00
|
|
|
++ppp->nxseq;
|
|
|
|
return 1; /* abandon the frame */
|
|
|
|
}
|
|
|
|
#endif /* CONFIG_PPP_MULTILINK */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Try to send data out on a channel.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
ppp_channel_push(struct channel *pch)
|
|
|
|
{
|
|
|
|
struct sk_buff *skb;
|
|
|
|
struct ppp *ppp;
|
|
|
|
|
|
|
|
spin_lock_bh(&pch->downl);
|
2007-11-12 19:07:31 -07:00
|
|
|
if (pch->chan) {
|
2005-07-08 14:57:23 -07:00
|
|
|
while (!skb_queue_empty(&pch->file.xq)) {
|
2005-04-16 15:20:36 -07:00
|
|
|
skb = skb_dequeue(&pch->file.xq);
|
|
|
|
if (!pch->chan->ops->start_xmit(pch->chan, skb)) {
|
|
|
|
/* put the packet back and try again later */
|
|
|
|
skb_queue_head(&pch->file.xq, skb);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* channel got deregistered */
|
|
|
|
skb_queue_purge(&pch->file.xq);
|
|
|
|
}
|
|
|
|
spin_unlock_bh(&pch->downl);
|
|
|
|
/* see if there is anything from the attached unit to be sent */
|
2005-07-08 14:57:23 -07:00
|
|
|
if (skb_queue_empty(&pch->file.xq)) {
|
2005-04-16 15:20:36 -07:00
|
|
|
read_lock_bh(&pch->upl);
|
|
|
|
ppp = pch->ppp;
|
2007-11-12 19:07:31 -07:00
|
|
|
if (ppp)
|
2005-04-16 15:20:36 -07:00
|
|
|
ppp_xmit_process(ppp);
|
|
|
|
read_unlock_bh(&pch->upl);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Receive-side routines.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* misuse a few fields of the skb for MP reconstruction */
|
|
|
|
#define sequence priority
|
|
|
|
#define BEbits cb[0]
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
ppp_do_recv(struct ppp *ppp, struct sk_buff *skb, struct channel *pch)
|
|
|
|
{
|
|
|
|
ppp_recv_lock(ppp);
|
2008-12-17 05:02:16 -07:00
|
|
|
if (!ppp->closing)
|
2005-04-16 15:20:36 -07:00
|
|
|
ppp_receive_frame(ppp, skb, pch);
|
|
|
|
else
|
|
|
|
kfree_skb(skb);
|
|
|
|
ppp_recv_unlock(ppp);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ppp_input(struct ppp_channel *chan, struct sk_buff *skb)
|
|
|
|
{
|
|
|
|
struct channel *pch = chan->ppp;
|
|
|
|
int proto;
|
|
|
|
|
2007-11-12 19:07:31 -07:00
|
|
|
if (!pch || skb->len == 0) {
|
2005-04-16 15:20:36 -07:00
|
|
|
kfree_skb(skb);
|
|
|
|
return;
|
|
|
|
}
|
2005-05-12 16:47:12 -07:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
proto = PPP_PROTO(skb);
|
|
|
|
read_lock_bh(&pch->upl);
|
2007-11-12 19:07:31 -07:00
|
|
|
if (!pch->ppp || proto >= 0xc000 || proto == PPP_CCPFRAG) {
|
2005-04-16 15:20:36 -07:00
|
|
|
/* put it on the channel queue */
|
|
|
|
skb_queue_tail(&pch->file.rq, skb);
|
|
|
|
/* drop old frames if queue too long */
|
|
|
|
while (pch->file.rq.qlen > PPP_MAX_RQLEN
|
2007-11-12 19:07:31 -07:00
|
|
|
&& (skb = skb_dequeue(&pch->file.rq)))
|
2005-04-16 15:20:36 -07:00
|
|
|
kfree_skb(skb);
|
|
|
|
wake_up_interruptible(&pch->file.rwait);
|
|
|
|
} else {
|
|
|
|
ppp_do_recv(pch->ppp, skb, pch);
|
|
|
|
}
|
|
|
|
read_unlock_bh(&pch->upl);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Put a 0-length skb in the receive queue as an error indication */
|
|
|
|
void
|
|
|
|
ppp_input_error(struct ppp_channel *chan, int code)
|
|
|
|
{
|
|
|
|
struct channel *pch = chan->ppp;
|
|
|
|
struct sk_buff *skb;
|
|
|
|
|
2007-11-12 19:07:31 -07:00
|
|
|
if (!pch)
|
2005-04-16 15:20:36 -07:00
|
|
|
return;
|
|
|
|
|
|
|
|
read_lock_bh(&pch->upl);
|
2007-11-12 19:07:31 -07:00
|
|
|
if (pch->ppp) {
|
2005-04-16 15:20:36 -07:00
|
|
|
skb = alloc_skb(0, GFP_ATOMIC);
|
2007-11-12 19:07:31 -07:00
|
|
|
if (skb) {
|
2005-04-16 15:20:36 -07:00
|
|
|
skb->len = 0; /* probably unnecessary */
|
|
|
|
skb->cb[0] = code;
|
|
|
|
ppp_do_recv(pch->ppp, skb, pch);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
read_unlock_bh(&pch->upl);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We come in here to process a received frame.
|
|
|
|
* The receive side of the ppp unit is locked.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
ppp_receive_frame(struct ppp *ppp, struct sk_buff *skb, struct channel *pch)
|
|
|
|
{
|
2007-09-16 16:22:13 -07:00
|
|
|
if (pskb_may_pull(skb, 2)) {
|
2005-04-16 15:20:36 -07:00
|
|
|
#ifdef CONFIG_PPP_MULTILINK
|
|
|
|
/* XXX do channel-level decompression here */
|
|
|
|
if (PPP_PROTO(skb) == PPP_MP)
|
|
|
|
ppp_receive_mp_frame(ppp, skb, pch);
|
|
|
|
else
|
|
|
|
#endif /* CONFIG_PPP_MULTILINK */
|
|
|
|
ppp_receive_nonmp_frame(ppp, skb);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (skb->len > 0)
|
|
|
|
/* note: a 0-length skb is used as an error indication */
|
2008-04-23 18:54:01 -07:00
|
|
|
++ppp->dev->stats.rx_length_errors;
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
kfree_skb(skb);
|
|
|
|
ppp_receive_error(ppp);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ppp_receive_error(struct ppp *ppp)
|
|
|
|
{
|
2008-04-23 18:54:01 -07:00
|
|
|
++ppp->dev->stats.rx_errors;
|
2007-11-12 19:07:31 -07:00
|
|
|
if (ppp->vj)
|
2005-04-16 15:20:36 -07:00
|
|
|
slhc_toss(ppp->vj);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ppp_receive_nonmp_frame(struct ppp *ppp, struct sk_buff *skb)
|
|
|
|
{
|
|
|
|
struct sk_buff *ns;
|
|
|
|
int proto, len, npi;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Decompress the frame, if compressed.
|
|
|
|
* Note that some decompressors need to see uncompressed frames
|
|
|
|
* that come in as well as compressed frames.
|
|
|
|
*/
|
2007-11-12 19:07:31 -07:00
|
|
|
if (ppp->rc_state && (ppp->rstate & SC_DECOMP_RUN)
|
2005-04-16 15:20:36 -07:00
|
|
|
&& (ppp->rstate & (SC_DC_FERROR | SC_DC_ERROR)) == 0)
|
|
|
|
skb = ppp_decompress_frame(ppp, skb);
|
|
|
|
|
2005-11-08 10:40:47 -07:00
|
|
|
if (ppp->flags & SC_MUST_COMP && ppp->rstate & SC_DC_FERROR)
|
|
|
|
goto err;
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
proto = PPP_PROTO(skb);
|
|
|
|
switch (proto) {
|
|
|
|
case PPP_VJC_COMP:
|
|
|
|
/* decompress VJ compressed packets */
|
2007-11-12 19:07:31 -07:00
|
|
|
if (!ppp->vj || (ppp->flags & SC_REJ_COMP_TCP))
|
2005-04-16 15:20:36 -07:00
|
|
|
goto err;
|
|
|
|
|
2007-09-16 16:22:13 -07:00
|
|
|
if (skb_tailroom(skb) < 124 || skb_cloned(skb)) {
|
2005-04-16 15:20:36 -07:00
|
|
|
/* copy to a new sk_buff with more tailroom */
|
|
|
|
ns = dev_alloc_skb(skb->len + 128);
|
2007-11-12 19:07:31 -07:00
|
|
|
if (!ns) {
|
2005-04-16 15:20:36 -07:00
|
|
|
printk(KERN_ERR"PPP: no memory (VJ decomp)\n");
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
skb_reserve(ns, 2);
|
|
|
|
skb_copy_bits(skb, 0, skb_put(ns, skb->len), skb->len);
|
|
|
|
kfree_skb(skb);
|
|
|
|
skb = ns;
|
|
|
|
}
|
2006-02-05 21:23:33 -07:00
|
|
|
else
|
|
|
|
skb->ip_summed = CHECKSUM_NONE;
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
len = slhc_uncompress(ppp->vj, skb->data + 2, skb->len - 2);
|
|
|
|
if (len <= 0) {
|
|
|
|
printk(KERN_DEBUG "PPP: VJ decompression error\n");
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
len += 2;
|
|
|
|
if (len > skb->len)
|
|
|
|
skb_put(skb, len - skb->len);
|
|
|
|
else if (len < skb->len)
|
|
|
|
skb_trim(skb, len);
|
|
|
|
proto = PPP_IP;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PPP_VJC_UNCOMP:
|
2007-11-12 19:07:31 -07:00
|
|
|
if (!ppp->vj || (ppp->flags & SC_REJ_COMP_TCP))
|
2005-04-16 15:20:36 -07:00
|
|
|
goto err;
|
2006-09-13 10:24:59 -07:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
/* Until we fix the decompressor need to make sure
|
|
|
|
* data portion is linear.
|
|
|
|
*/
|
2006-09-13 10:24:59 -07:00
|
|
|
if (!pskb_may_pull(skb, skb->len))
|
2005-04-16 15:20:36 -07:00
|
|
|
goto err;
|
|
|
|
|
|
|
|
if (slhc_remember(ppp->vj, skb->data + 2, skb->len - 2) <= 0) {
|
|
|
|
printk(KERN_ERR "PPP: VJ uncompressed error\n");
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
proto = PPP_IP;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PPP_CCP:
|
|
|
|
ppp_ccp_peek(ppp, skb, 1);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2008-04-23 18:54:01 -07:00
|
|
|
++ppp->dev->stats.rx_packets;
|
|
|
|
ppp->dev->stats.rx_bytes += skb->len - 2;
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
npi = proto_to_npindex(proto);
|
|
|
|
if (npi < 0) {
|
|
|
|
/* control or unknown frame - pass it to pppd */
|
|
|
|
skb_queue_tail(&ppp->file.rq, skb);
|
|
|
|
/* limit queue length by dropping old frames */
|
|
|
|
while (ppp->file.rq.qlen > PPP_MAX_RQLEN
|
2007-11-12 19:07:31 -07:00
|
|
|
&& (skb = skb_dequeue(&ppp->file.rq)))
|
2005-04-16 15:20:36 -07:00
|
|
|
kfree_skb(skb);
|
|
|
|
/* wake up any process polling or blocking on read */
|
|
|
|
wake_up_interruptible(&ppp->file.rwait);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
/* network protocol frame - give it to the kernel */
|
|
|
|
|
|
|
|
#ifdef CONFIG_PPP_FILTER
|
|
|
|
/* check if the packet passes the pass and active filters */
|
|
|
|
/* the filter instructions are constructed assuming
|
|
|
|
a four-byte PPP header on each packet */
|
2007-09-16 16:22:13 -07:00
|
|
|
if (ppp->pass_filter || ppp->active_filter) {
|
|
|
|
if (skb_cloned(skb) &&
|
|
|
|
pskb_expand_head(skb, 0, 0, GFP_ATOMIC))
|
|
|
|
goto err;
|
|
|
|
|
|
|
|
*skb_push(skb, 2) = 0;
|
|
|
|
if (ppp->pass_filter
|
|
|
|
&& sk_run_filter(skb, ppp->pass_filter,
|
|
|
|
ppp->pass_len) == 0) {
|
|
|
|
if (ppp->debug & 1)
|
|
|
|
printk(KERN_DEBUG "PPP: inbound frame "
|
|
|
|
"not passed\n");
|
|
|
|
kfree_skb(skb);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!(ppp->active_filter
|
|
|
|
&& sk_run_filter(skb, ppp->active_filter,
|
|
|
|
ppp->active_len) == 0))
|
|
|
|
ppp->last_recv = jiffies;
|
|
|
|
__skb_pull(skb, 2);
|
|
|
|
} else
|
2005-04-16 15:20:36 -07:00
|
|
|
#endif /* CONFIG_PPP_FILTER */
|
2007-09-16 16:22:13 -07:00
|
|
|
ppp->last_recv = jiffies;
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
if ((ppp->dev->flags & IFF_UP) == 0
|
|
|
|
|| ppp->npmode[npi] != NPMODE_PASS) {
|
|
|
|
kfree_skb(skb);
|
|
|
|
} else {
|
2006-03-20 23:43:56 -07:00
|
|
|
/* chop off protocol */
|
|
|
|
skb_pull_rcsum(skb, 2);
|
2005-04-16 15:20:36 -07:00
|
|
|
skb->dev = ppp->dev;
|
|
|
|
skb->protocol = htons(npindex_to_ethertype[npi]);
|
2007-03-19 15:30:44 -07:00
|
|
|
skb_reset_mac_header(skb);
|
2005-04-16 15:20:36 -07:00
|
|
|
netif_rx(skb);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
|
|
|
|
err:
|
|
|
|
kfree_skb(skb);
|
|
|
|
ppp_receive_error(ppp);
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct sk_buff *
|
|
|
|
ppp_decompress_frame(struct ppp *ppp, struct sk_buff *skb)
|
|
|
|
{
|
|
|
|
int proto = PPP_PROTO(skb);
|
|
|
|
struct sk_buff *ns;
|
|
|
|
int len;
|
|
|
|
|
|
|
|
/* Until we fix all the decompressor's need to make sure
|
|
|
|
* data portion is linear.
|
|
|
|
*/
|
|
|
|
if (!pskb_may_pull(skb, skb->len))
|
|
|
|
goto err;
|
|
|
|
|
|
|
|
if (proto == PPP_COMP) {
|
2007-06-23 23:05:54 -07:00
|
|
|
int obuff_size;
|
|
|
|
|
|
|
|
switch(ppp->rcomp->compress_proto) {
|
|
|
|
case CI_MPPE:
|
|
|
|
obuff_size = ppp->mru + PPP_HDRLEN + 1;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
obuff_size = ppp->mru + PPP_HDRLEN;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
ns = dev_alloc_skb(obuff_size);
|
2007-11-12 19:07:31 -07:00
|
|
|
if (!ns) {
|
2005-04-16 15:20:36 -07:00
|
|
|
printk(KERN_ERR "ppp_decompress_frame: no memory\n");
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
/* the decompressor still expects the A/C bytes in the hdr */
|
|
|
|
len = ppp->rcomp->decompress(ppp->rc_state, skb->data - 2,
|
2007-08-21 00:12:44 -07:00
|
|
|
skb->len + 2, ns->data, obuff_size);
|
2005-04-16 15:20:36 -07:00
|
|
|
if (len < 0) {
|
|
|
|
/* Pass the compressed frame to pppd as an
|
|
|
|
error indication. */
|
|
|
|
if (len == DECOMP_FATALERROR)
|
|
|
|
ppp->rstate |= SC_DC_FERROR;
|
|
|
|
kfree_skb(ns);
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
kfree_skb(skb);
|
|
|
|
skb = ns;
|
|
|
|
skb_put(skb, len);
|
|
|
|
skb_pull(skb, 2); /* pull off the A/C bytes */
|
|
|
|
|
|
|
|
} else {
|
|
|
|
/* Uncompressed frame - pass to decompressor so it
|
|
|
|
can update its dictionary if necessary. */
|
|
|
|
if (ppp->rcomp->incomp)
|
|
|
|
ppp->rcomp->incomp(ppp->rc_state, skb->data - 2,
|
|
|
|
skb->len + 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
return skb;
|
|
|
|
|
|
|
|
err:
|
|
|
|
ppp->rstate |= SC_DC_ERROR;
|
|
|
|
ppp_receive_error(ppp);
|
|
|
|
return skb;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef CONFIG_PPP_MULTILINK
|
|
|
|
/*
|
|
|
|
* Receive a multilink frame.
|
|
|
|
* We put it on the reconstruction queue and then pull off
|
|
|
|
* as many completed frames as we can.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
ppp_receive_mp_frame(struct ppp *ppp, struct sk_buff *skb, struct channel *pch)
|
|
|
|
{
|
|
|
|
u32 mask, seq;
|
2005-09-10 00:27:04 -07:00
|
|
|
struct channel *ch;
|
2005-04-16 15:20:36 -07:00
|
|
|
int mphdrlen = (ppp->flags & SC_MP_SHORTSEQ)? MPHDRLEN_SSN: MPHDRLEN;
|
|
|
|
|
2007-09-16 16:22:13 -07:00
|
|
|
if (!pskb_may_pull(skb, mphdrlen + 1) || ppp->mrru == 0)
|
2005-04-16 15:20:36 -07:00
|
|
|
goto err; /* no good, throw it away */
|
|
|
|
|
|
|
|
/* Decode sequence number and begin/end bits */
|
|
|
|
if (ppp->flags & SC_MP_SHORTSEQ) {
|
|
|
|
seq = ((skb->data[2] & 0x0f) << 8) | skb->data[3];
|
|
|
|
mask = 0xfff;
|
|
|
|
} else {
|
|
|
|
seq = (skb->data[3] << 16) | (skb->data[4] << 8)| skb->data[5];
|
|
|
|
mask = 0xffffff;
|
|
|
|
}
|
|
|
|
skb->BEbits = skb->data[2];
|
|
|
|
skb_pull(skb, mphdrlen); /* pull off PPP and MP headers */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Do protocol ID decompression on the first fragment of each packet.
|
|
|
|
*/
|
|
|
|
if ((skb->BEbits & B) && (skb->data[0] & 1))
|
|
|
|
*skb_push(skb, 1) = 0;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Expand sequence number to 32 bits, making it as close
|
|
|
|
* as possible to ppp->minseq.
|
|
|
|
*/
|
|
|
|
seq |= ppp->minseq & ~mask;
|
|
|
|
if ((int)(ppp->minseq - seq) > (int)(mask >> 1))
|
|
|
|
seq += mask + 1;
|
|
|
|
else if ((int)(seq - ppp->minseq) > (int)(mask >> 1))
|
|
|
|
seq -= mask + 1; /* should never happen */
|
|
|
|
skb->sequence = seq;
|
|
|
|
pch->lastseq = seq;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If this packet comes before the next one we were expecting,
|
|
|
|
* drop it.
|
|
|
|
*/
|
|
|
|
if (seq_before(seq, ppp->nextseq)) {
|
|
|
|
kfree_skb(skb);
|
2008-04-23 18:54:01 -07:00
|
|
|
++ppp->dev->stats.rx_dropped;
|
2005-04-16 15:20:36 -07:00
|
|
|
ppp_receive_error(ppp);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Reevaluate minseq, the minimum over all channels of the
|
|
|
|
* last sequence number received on each channel. Because of
|
|
|
|
* the increasing sequence number rule, we know that any fragment
|
|
|
|
* before `minseq' which hasn't arrived is never going to arrive.
|
|
|
|
* The list of channels can't change because we have the receive
|
|
|
|
* side of the ppp unit locked.
|
|
|
|
*/
|
2005-09-10 00:27:04 -07:00
|
|
|
list_for_each_entry(ch, &ppp->channels, clist) {
|
2005-04-16 15:20:36 -07:00
|
|
|
if (seq_before(ch->lastseq, seq))
|
|
|
|
seq = ch->lastseq;
|
|
|
|
}
|
|
|
|
if (seq_before(ppp->minseq, seq))
|
|
|
|
ppp->minseq = seq;
|
|
|
|
|
|
|
|
/* Put the fragment on the reconstruction queue */
|
|
|
|
ppp_mp_insert(ppp, skb);
|
|
|
|
|
|
|
|
/* If the queue is getting long, don't wait any longer for packets
|
|
|
|
before the start of the queue. */
|
2008-09-23 01:17:18 -07:00
|
|
|
if (skb_queue_len(&ppp->mrq) >= PPP_MP_MAX_QLEN) {
|
|
|
|
struct sk_buff *skb = skb_peek(&ppp->mrq);
|
|
|
|
if (seq_before(ppp->minseq, skb->sequence))
|
|
|
|
ppp->minseq = skb->sequence;
|
|
|
|
}
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
/* Pull completed packets off the queue and receive them. */
|
2007-11-12 19:07:31 -07:00
|
|
|
while ((skb = ppp_mp_reconstruct(ppp)))
|
2005-04-16 15:20:36 -07:00
|
|
|
ppp_receive_nonmp_frame(ppp, skb);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
err:
|
|
|
|
kfree_skb(skb);
|
|
|
|
ppp_receive_error(ppp);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Insert a fragment on the MP reconstruction queue.
|
|
|
|
* The queue is ordered by increasing sequence number.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
ppp_mp_insert(struct ppp *ppp, struct sk_buff *skb)
|
|
|
|
{
|
|
|
|
struct sk_buff *p;
|
|
|
|
struct sk_buff_head *list = &ppp->mrq;
|
|
|
|
u32 seq = skb->sequence;
|
|
|
|
|
|
|
|
/* N.B. we don't need to lock the list lock because we have the
|
|
|
|
ppp unit receive-side lock. */
|
2008-10-09 16:40:29 -07:00
|
|
|
skb_queue_walk(list, p) {
|
2005-04-16 15:20:36 -07:00
|
|
|
if (seq_before(seq, p->sequence))
|
|
|
|
break;
|
2008-10-09 16:40:29 -07:00
|
|
|
}
|
2008-09-21 21:28:51 -07:00
|
|
|
__skb_queue_before(list, p, skb);
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Reconstruct a packet from the MP fragment queue.
|
|
|
|
* We go through increasing sequence numbers until we find a
|
|
|
|
* complete packet, or we get to the sequence number for a fragment
|
|
|
|
* which hasn't arrived but might still do so.
|
|
|
|
*/
|
2008-01-23 21:54:07 -07:00
|
|
|
static struct sk_buff *
|
2005-04-16 15:20:36 -07:00
|
|
|
ppp_mp_reconstruct(struct ppp *ppp)
|
|
|
|
{
|
|
|
|
u32 seq = ppp->nextseq;
|
|
|
|
u32 minseq = ppp->minseq;
|
|
|
|
struct sk_buff_head *list = &ppp->mrq;
|
|
|
|
struct sk_buff *p, *next;
|
|
|
|
struct sk_buff *head, *tail;
|
|
|
|
struct sk_buff *skb = NULL;
|
|
|
|
int lost = 0, len = 0;
|
|
|
|
|
|
|
|
if (ppp->mrru == 0) /* do nothing until mrru is set */
|
|
|
|
return NULL;
|
|
|
|
head = list->next;
|
|
|
|
tail = NULL;
|
|
|
|
for (p = head; p != (struct sk_buff *) list; p = next) {
|
|
|
|
next = p->next;
|
|
|
|
if (seq_before(p->sequence, seq)) {
|
|
|
|
/* this can't happen, anyway ignore the skb */
|
|
|
|
printk(KERN_ERR "ppp_mp_reconstruct bad seq %u < %u\n",
|
|
|
|
p->sequence, seq);
|
|
|
|
head = next;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (p->sequence != seq) {
|
|
|
|
/* Fragment `seq' is missing. If it is after
|
|
|
|
minseq, it might arrive later, so stop here. */
|
|
|
|
if (seq_after(seq, minseq))
|
|
|
|
break;
|
|
|
|
/* Fragment `seq' is lost, keep going. */
|
|
|
|
lost = 1;
|
|
|
|
seq = seq_before(minseq, p->sequence)?
|
|
|
|
minseq + 1: p->sequence;
|
|
|
|
next = p;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* At this point we know that all the fragments from
|
|
|
|
* ppp->nextseq to seq are either present or lost.
|
|
|
|
* Also, there are no complete packets in the queue
|
|
|
|
* that have no missing fragments and end before this
|
|
|
|
* fragment.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* B bit set indicates this fragment starts a packet */
|
|
|
|
if (p->BEbits & B) {
|
|
|
|
head = p;
|
|
|
|
lost = 0;
|
|
|
|
len = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
len += p->len;
|
|
|
|
|
|
|
|
/* Got a complete packet yet? */
|
|
|
|
if (lost == 0 && (p->BEbits & E) && (head->BEbits & B)) {
|
|
|
|
if (len > ppp->mrru + 2) {
|
2008-04-23 18:54:01 -07:00
|
|
|
++ppp->dev->stats.rx_length_errors;
|
2005-04-16 15:20:36 -07:00
|
|
|
printk(KERN_DEBUG "PPP: reconstructed packet"
|
|
|
|
" is too long (%d)\n", len);
|
|
|
|
} else if (p == head) {
|
|
|
|
/* fragment is complete packet - reuse skb */
|
|
|
|
tail = p;
|
|
|
|
skb = skb_get(p);
|
|
|
|
break;
|
|
|
|
} else if ((skb = dev_alloc_skb(len)) == NULL) {
|
2008-04-23 18:54:01 -07:00
|
|
|
++ppp->dev->stats.rx_missed_errors;
|
2005-04-16 15:20:36 -07:00
|
|
|
printk(KERN_DEBUG "PPP: no memory for "
|
|
|
|
"reconstructed packet");
|
|
|
|
} else {
|
|
|
|
tail = p;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
ppp->nextseq = seq + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If this is the ending fragment of a packet,
|
|
|
|
* and we haven't found a complete valid packet yet,
|
|
|
|
* we can discard up to and including this fragment.
|
|
|
|
*/
|
|
|
|
if (p->BEbits & E)
|
|
|
|
head = next;
|
|
|
|
|
|
|
|
++seq;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If we have a complete packet, copy it all into one skb. */
|
|
|
|
if (tail != NULL) {
|
|
|
|
/* If we have discarded any fragments,
|
|
|
|
signal a receive error. */
|
|
|
|
if (head->sequence != ppp->nextseq) {
|
|
|
|
if (ppp->debug & 1)
|
|
|
|
printk(KERN_DEBUG " missed pkts %u..%u\n",
|
|
|
|
ppp->nextseq, head->sequence-1);
|
2008-04-23 18:54:01 -07:00
|
|
|
++ppp->dev->stats.rx_dropped;
|
2005-04-16 15:20:36 -07:00
|
|
|
ppp_receive_error(ppp);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (head != tail)
|
|
|
|
/* copy to a single skb */
|
|
|
|
for (p = head; p != tail->next; p = p->next)
|
|
|
|
skb_copy_bits(p, 0, skb_put(skb, p->len), p->len);
|
|
|
|
ppp->nextseq = tail->sequence + 1;
|
|
|
|
head = tail->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Discard all the skbuffs that we have copied the data out of
|
|
|
|
or that we can't use. */
|
|
|
|
while ((p = list->next) != head) {
|
|
|
|
__skb_unlink(p, list);
|
|
|
|
kfree_skb(p);
|
|
|
|
}
|
|
|
|
|
|
|
|
return skb;
|
|
|
|
}
|
|
|
|
#endif /* CONFIG_PPP_MULTILINK */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Channel interface.
|
|
|
|
*/
|
|
|
|
|
2009-01-21 16:55:35 -07:00
|
|
|
/* Create a new, unattached ppp channel. */
|
|
|
|
int ppp_register_channel(struct ppp_channel *chan)
|
|
|
|
{
|
|
|
|
return ppp_register_net_channel(current->nsproxy->net_ns, chan);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Create a new, unattached ppp channel for specified net. */
|
|
|
|
int ppp_register_net_channel(struct net *net, struct ppp_channel *chan)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
|
|
|
struct channel *pch;
|
2009-01-21 16:55:35 -07:00
|
|
|
struct ppp_net *pn;
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2006-08-15 16:01:07 -07:00
|
|
|
pch = kzalloc(sizeof(struct channel), GFP_KERNEL);
|
2007-11-12 19:07:31 -07:00
|
|
|
if (!pch)
|
2005-04-16 15:20:36 -07:00
|
|
|
return -ENOMEM;
|
2009-01-21 16:55:35 -07:00
|
|
|
|
|
|
|
pn = ppp_pernet(net);
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
pch->ppp = NULL;
|
|
|
|
pch->chan = chan;
|
2009-01-21 16:55:35 -07:00
|
|
|
pch->chan_net = net;
|
2005-04-16 15:20:36 -07:00
|
|
|
chan->ppp = pch;
|
|
|
|
init_ppp_file(&pch->file, CHANNEL);
|
|
|
|
pch->file.hdrlen = chan->hdrlen;
|
|
|
|
#ifdef CONFIG_PPP_MULTILINK
|
|
|
|
pch->lastseq = -1;
|
|
|
|
#endif /* CONFIG_PPP_MULTILINK */
|
|
|
|
init_rwsem(&pch->chan_sem);
|
|
|
|
spin_lock_init(&pch->downl);
|
|
|
|
rwlock_init(&pch->upl);
|
2009-01-21 16:55:35 -07:00
|
|
|
|
|
|
|
spin_lock_bh(&pn->all_channels_lock);
|
|
|
|
pch->file.index = ++pn->last_channel_index;
|
|
|
|
list_add(&pch->list, &pn->new_channels);
|
2005-04-16 15:20:36 -07:00
|
|
|
atomic_inc(&channel_count);
|
2009-01-21 16:55:35 -07:00
|
|
|
spin_unlock_bh(&pn->all_channels_lock);
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Return the index of a channel.
|
|
|
|
*/
|
|
|
|
int ppp_channel_index(struct ppp_channel *chan)
|
|
|
|
{
|
|
|
|
struct channel *pch = chan->ppp;
|
|
|
|
|
2007-11-12 19:07:31 -07:00
|
|
|
if (pch)
|
2005-04-16 15:20:36 -07:00
|
|
|
return pch->file.index;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Return the PPP unit number to which a channel is connected.
|
|
|
|
*/
|
|
|
|
int ppp_unit_number(struct ppp_channel *chan)
|
|
|
|
{
|
|
|
|
struct channel *pch = chan->ppp;
|
|
|
|
int unit = -1;
|
|
|
|
|
2007-11-12 19:07:31 -07:00
|
|
|
if (pch) {
|
2005-04-16 15:20:36 -07:00
|
|
|
read_lock_bh(&pch->upl);
|
2007-11-12 19:07:31 -07:00
|
|
|
if (pch->ppp)
|
2005-04-16 15:20:36 -07:00
|
|
|
unit = pch->ppp->file.index;
|
|
|
|
read_unlock_bh(&pch->upl);
|
|
|
|
}
|
|
|
|
return unit;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Disconnect a channel from the generic layer.
|
|
|
|
* This must be called in process context.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
ppp_unregister_channel(struct ppp_channel *chan)
|
|
|
|
{
|
|
|
|
struct channel *pch = chan->ppp;
|
2009-01-21 16:55:35 -07:00
|
|
|
struct ppp_net *pn;
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2007-11-12 19:07:31 -07:00
|
|
|
if (!pch)
|
2005-04-16 15:20:36 -07:00
|
|
|
return; /* should never happen */
|
2009-01-21 16:55:35 -07:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
chan->ppp = NULL;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This ensures that we have returned from any calls into the
|
|
|
|
* the channel's start_xmit or ioctl routine before we proceed.
|
|
|
|
*/
|
|
|
|
down_write(&pch->chan_sem);
|
|
|
|
spin_lock_bh(&pch->downl);
|
|
|
|
pch->chan = NULL;
|
|
|
|
spin_unlock_bh(&pch->downl);
|
|
|
|
up_write(&pch->chan_sem);
|
|
|
|
ppp_disconnect_channel(pch);
|
2009-01-21 16:55:35 -07:00
|
|
|
|
|
|
|
pn = ppp_pernet(pch->chan_net);
|
|
|
|
spin_lock_bh(&pn->all_channels_lock);
|
2005-04-16 15:20:36 -07:00
|
|
|
list_del(&pch->list);
|
2009-01-21 16:55:35 -07:00
|
|
|
spin_unlock_bh(&pn->all_channels_lock);
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
pch->file.dead = 1;
|
|
|
|
wake_up_interruptible(&pch->file.rwait);
|
|
|
|
if (atomic_dec_and_test(&pch->file.refcnt))
|
|
|
|
ppp_destroy_channel(pch);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Callback from a channel when it can accept more to transmit.
|
|
|
|
* This should be called at BH/softirq level, not interrupt level.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
ppp_output_wakeup(struct ppp_channel *chan)
|
|
|
|
{
|
|
|
|
struct channel *pch = chan->ppp;
|
|
|
|
|
2007-11-12 19:07:31 -07:00
|
|
|
if (!pch)
|
2005-04-16 15:20:36 -07:00
|
|
|
return;
|
|
|
|
ppp_channel_push(pch);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Compression control.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Process the PPPIOCSCOMPRESS ioctl. */
|
|
|
|
static int
|
|
|
|
ppp_set_compress(struct ppp *ppp, unsigned long arg)
|
|
|
|
{
|
|
|
|
int err;
|
|
|
|
struct compressor *cp, *ocomp;
|
|
|
|
struct ppp_option_data data;
|
|
|
|
void *state, *ostate;
|
|
|
|
unsigned char ccp_option[CCP_MAX_OPTION_LENGTH];
|
|
|
|
|
|
|
|
err = -EFAULT;
|
|
|
|
if (copy_from_user(&data, (void __user *) arg, sizeof(data))
|
|
|
|
|| (data.length <= CCP_MAX_OPTION_LENGTH
|
|
|
|
&& copy_from_user(ccp_option, (void __user *) data.ptr, data.length)))
|
|
|
|
goto out;
|
|
|
|
err = -EINVAL;
|
|
|
|
if (data.length > CCP_MAX_OPTION_LENGTH
|
|
|
|
|| ccp_option[1] < 2 || ccp_option[1] > data.length)
|
|
|
|
goto out;
|
|
|
|
|
2008-07-09 01:28:38 -07:00
|
|
|
cp = try_then_request_module(
|
|
|
|
find_compressor(ccp_option[0]),
|
|
|
|
"ppp-compress-%d", ccp_option[0]);
|
2007-11-12 19:07:31 -07:00
|
|
|
if (!cp)
|
2005-04-16 15:20:36 -07:00
|
|
|
goto out;
|
|
|
|
|
|
|
|
err = -ENOBUFS;
|
|
|
|
if (data.transmit) {
|
|
|
|
state = cp->comp_alloc(ccp_option, data.length);
|
2007-11-12 19:07:31 -07:00
|
|
|
if (state) {
|
2005-04-16 15:20:36 -07:00
|
|
|
ppp_xmit_lock(ppp);
|
|
|
|
ppp->xstate &= ~SC_COMP_RUN;
|
|
|
|
ocomp = ppp->xcomp;
|
|
|
|
ostate = ppp->xc_state;
|
|
|
|
ppp->xcomp = cp;
|
|
|
|
ppp->xc_state = state;
|
|
|
|
ppp_xmit_unlock(ppp);
|
2007-11-12 19:07:31 -07:00
|
|
|
if (ostate) {
|
2005-04-16 15:20:36 -07:00
|
|
|
ocomp->comp_free(ostate);
|
|
|
|
module_put(ocomp->owner);
|
|
|
|
}
|
|
|
|
err = 0;
|
|
|
|
} else
|
|
|
|
module_put(cp->owner);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
state = cp->decomp_alloc(ccp_option, data.length);
|
2007-11-12 19:07:31 -07:00
|
|
|
if (state) {
|
2005-04-16 15:20:36 -07:00
|
|
|
ppp_recv_lock(ppp);
|
|
|
|
ppp->rstate &= ~SC_DECOMP_RUN;
|
|
|
|
ocomp = ppp->rcomp;
|
|
|
|
ostate = ppp->rc_state;
|
|
|
|
ppp->rcomp = cp;
|
|
|
|
ppp->rc_state = state;
|
|
|
|
ppp_recv_unlock(ppp);
|
2007-11-12 19:07:31 -07:00
|
|
|
if (ostate) {
|
2005-04-16 15:20:36 -07:00
|
|
|
ocomp->decomp_free(ostate);
|
|
|
|
module_put(ocomp->owner);
|
|
|
|
}
|
|
|
|
err = 0;
|
|
|
|
} else
|
|
|
|
module_put(cp->owner);
|
|
|
|
}
|
|
|
|
|
|
|
|
out:
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Look at a CCP packet and update our state accordingly.
|
|
|
|
* We assume the caller has the xmit or recv path locked.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
ppp_ccp_peek(struct ppp *ppp, struct sk_buff *skb, int inbound)
|
|
|
|
{
|
|
|
|
unsigned char *dp;
|
|
|
|
int len;
|
|
|
|
|
|
|
|
if (!pskb_may_pull(skb, CCP_HDRLEN + 2))
|
|
|
|
return; /* no header */
|
|
|
|
dp = skb->data + 2;
|
|
|
|
|
|
|
|
switch (CCP_CODE(dp)) {
|
|
|
|
case CCP_CONFREQ:
|
|
|
|
|
2006-09-13 10:24:59 -07:00
|
|
|
/* A ConfReq starts negotiation of compression
|
2005-04-16 15:20:36 -07:00
|
|
|
* in one direction of transmission,
|
|
|
|
* and hence brings it down...but which way?
|
|
|
|
*
|
|
|
|
* Remember:
|
|
|
|
* A ConfReq indicates what the sender would like to receive
|
|
|
|
*/
|
|
|
|
if(inbound)
|
|
|
|
/* He is proposing what I should send */
|
|
|
|
ppp->xstate &= ~SC_COMP_RUN;
|
2006-09-13 10:24:59 -07:00
|
|
|
else
|
2005-04-16 15:20:36 -07:00
|
|
|
/* I am proposing to what he should send */
|
|
|
|
ppp->rstate &= ~SC_DECOMP_RUN;
|
2006-09-13 10:24:59 -07:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
break;
|
2006-09-13 10:24:59 -07:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
case CCP_TERMREQ:
|
|
|
|
case CCP_TERMACK:
|
|
|
|
/*
|
2006-09-13 10:24:59 -07:00
|
|
|
* CCP is going down, both directions of transmission
|
2005-04-16 15:20:36 -07:00
|
|
|
*/
|
|
|
|
ppp->rstate &= ~SC_DECOMP_RUN;
|
|
|
|
ppp->xstate &= ~SC_COMP_RUN;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CCP_CONFACK:
|
|
|
|
if ((ppp->flags & (SC_CCP_OPEN | SC_CCP_UP)) != SC_CCP_OPEN)
|
|
|
|
break;
|
|
|
|
len = CCP_LENGTH(dp);
|
|
|
|
if (!pskb_may_pull(skb, len + 2))
|
|
|
|
return; /* too short */
|
|
|
|
dp += CCP_HDRLEN;
|
|
|
|
len -= CCP_HDRLEN;
|
|
|
|
if (len < CCP_OPT_MINLEN || len < CCP_OPT_LENGTH(dp))
|
|
|
|
break;
|
|
|
|
if (inbound) {
|
|
|
|
/* we will start receiving compressed packets */
|
2007-11-12 19:07:31 -07:00
|
|
|
if (!ppp->rc_state)
|
2005-04-16 15:20:36 -07:00
|
|
|
break;
|
|
|
|
if (ppp->rcomp->decomp_init(ppp->rc_state, dp, len,
|
|
|
|
ppp->file.index, 0, ppp->mru, ppp->debug)) {
|
|
|
|
ppp->rstate |= SC_DECOMP_RUN;
|
|
|
|
ppp->rstate &= ~(SC_DC_ERROR | SC_DC_FERROR);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* we will soon start sending compressed packets */
|
2007-11-12 19:07:31 -07:00
|
|
|
if (!ppp->xc_state)
|
2005-04-16 15:20:36 -07:00
|
|
|
break;
|
|
|
|
if (ppp->xcomp->comp_init(ppp->xc_state, dp, len,
|
|
|
|
ppp->file.index, 0, ppp->debug))
|
|
|
|
ppp->xstate |= SC_COMP_RUN;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CCP_RESETACK:
|
|
|
|
/* reset the [de]compressor */
|
|
|
|
if ((ppp->flags & SC_CCP_UP) == 0)
|
|
|
|
break;
|
|
|
|
if (inbound) {
|
|
|
|
if (ppp->rc_state && (ppp->rstate & SC_DECOMP_RUN)) {
|
|
|
|
ppp->rcomp->decomp_reset(ppp->rc_state);
|
|
|
|
ppp->rstate &= ~SC_DC_ERROR;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (ppp->xc_state && (ppp->xstate & SC_COMP_RUN))
|
|
|
|
ppp->xcomp->comp_reset(ppp->xc_state);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Free up compression resources. */
|
|
|
|
static void
|
|
|
|
ppp_ccp_closed(struct ppp *ppp)
|
|
|
|
{
|
|
|
|
void *xstate, *rstate;
|
|
|
|
struct compressor *xcomp, *rcomp;
|
|
|
|
|
|
|
|
ppp_lock(ppp);
|
|
|
|
ppp->flags &= ~(SC_CCP_OPEN | SC_CCP_UP);
|
|
|
|
ppp->xstate = 0;
|
|
|
|
xcomp = ppp->xcomp;
|
|
|
|
xstate = ppp->xc_state;
|
|
|
|
ppp->xc_state = NULL;
|
|
|
|
ppp->rstate = 0;
|
|
|
|
rcomp = ppp->rcomp;
|
|
|
|
rstate = ppp->rc_state;
|
|
|
|
ppp->rc_state = NULL;
|
|
|
|
ppp_unlock(ppp);
|
|
|
|
|
|
|
|
if (xstate) {
|
|
|
|
xcomp->comp_free(xstate);
|
|
|
|
module_put(xcomp->owner);
|
|
|
|
}
|
|
|
|
if (rstate) {
|
|
|
|
rcomp->decomp_free(rstate);
|
|
|
|
module_put(rcomp->owner);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* List of compressors. */
|
|
|
|
static LIST_HEAD(compressor_list);
|
|
|
|
static DEFINE_SPINLOCK(compressor_list_lock);
|
|
|
|
|
|
|
|
struct compressor_entry {
|
|
|
|
struct list_head list;
|
|
|
|
struct compressor *comp;
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct compressor_entry *
|
|
|
|
find_comp_entry(int proto)
|
|
|
|
{
|
|
|
|
struct compressor_entry *ce;
|
|
|
|
|
2005-09-10 00:27:04 -07:00
|
|
|
list_for_each_entry(ce, &compressor_list, list) {
|
2005-04-16 15:20:36 -07:00
|
|
|
if (ce->comp->compress_proto == proto)
|
|
|
|
return ce;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Register a compressor */
|
|
|
|
int
|
|
|
|
ppp_register_compressor(struct compressor *cp)
|
|
|
|
{
|
|
|
|
struct compressor_entry *ce;
|
|
|
|
int ret;
|
|
|
|
spin_lock(&compressor_list_lock);
|
|
|
|
ret = -EEXIST;
|
2007-11-12 19:07:31 -07:00
|
|
|
if (find_comp_entry(cp->compress_proto))
|
2005-04-16 15:20:36 -07:00
|
|
|
goto out;
|
|
|
|
ret = -ENOMEM;
|
|
|
|
ce = kmalloc(sizeof(struct compressor_entry), GFP_ATOMIC);
|
2007-11-12 19:07:31 -07:00
|
|
|
if (!ce)
|
2005-04-16 15:20:36 -07:00
|
|
|
goto out;
|
|
|
|
ret = 0;
|
|
|
|
ce->comp = cp;
|
|
|
|
list_add(&ce->list, &compressor_list);
|
|
|
|
out:
|
|
|
|
spin_unlock(&compressor_list_lock);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Unregister a compressor */
|
|
|
|
void
|
|
|
|
ppp_unregister_compressor(struct compressor *cp)
|
|
|
|
{
|
|
|
|
struct compressor_entry *ce;
|
|
|
|
|
|
|
|
spin_lock(&compressor_list_lock);
|
|
|
|
ce = find_comp_entry(cp->compress_proto);
|
2007-11-12 19:07:31 -07:00
|
|
|
if (ce && ce->comp == cp) {
|
2005-04-16 15:20:36 -07:00
|
|
|
list_del(&ce->list);
|
|
|
|
kfree(ce);
|
|
|
|
}
|
|
|
|
spin_unlock(&compressor_list_lock);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Find a compressor. */
|
|
|
|
static struct compressor *
|
|
|
|
find_compressor(int type)
|
|
|
|
{
|
|
|
|
struct compressor_entry *ce;
|
|
|
|
struct compressor *cp = NULL;
|
|
|
|
|
|
|
|
spin_lock(&compressor_list_lock);
|
|
|
|
ce = find_comp_entry(type);
|
2007-11-12 19:07:31 -07:00
|
|
|
if (ce) {
|
2005-04-16 15:20:36 -07:00
|
|
|
cp = ce->comp;
|
|
|
|
if (!try_module_get(cp->owner))
|
|
|
|
cp = NULL;
|
|
|
|
}
|
|
|
|
spin_unlock(&compressor_list_lock);
|
|
|
|
return cp;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Miscelleneous stuff.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void
|
|
|
|
ppp_get_stats(struct ppp *ppp, struct ppp_stats *st)
|
|
|
|
{
|
|
|
|
struct slcompress *vj = ppp->vj;
|
|
|
|
|
|
|
|
memset(st, 0, sizeof(*st));
|
2008-04-23 18:54:01 -07:00
|
|
|
st->p.ppp_ipackets = ppp->dev->stats.rx_packets;
|
|
|
|
st->p.ppp_ierrors = ppp->dev->stats.rx_errors;
|
|
|
|
st->p.ppp_ibytes = ppp->dev->stats.rx_bytes;
|
|
|
|
st->p.ppp_opackets = ppp->dev->stats.tx_packets;
|
|
|
|
st->p.ppp_oerrors = ppp->dev->stats.tx_errors;
|
|
|
|
st->p.ppp_obytes = ppp->dev->stats.tx_bytes;
|
2007-11-12 19:07:31 -07:00
|
|
|
if (!vj)
|
2005-04-16 15:20:36 -07:00
|
|
|
return;
|
|
|
|
st->vj.vjs_packets = vj->sls_o_compressed + vj->sls_o_uncompressed;
|
|
|
|
st->vj.vjs_compressed = vj->sls_o_compressed;
|
|
|
|
st->vj.vjs_searches = vj->sls_o_searches;
|
|
|
|
st->vj.vjs_misses = vj->sls_o_misses;
|
|
|
|
st->vj.vjs_errorin = vj->sls_i_error;
|
|
|
|
st->vj.vjs_tossed = vj->sls_i_tossed;
|
|
|
|
st->vj.vjs_uncompressedin = vj->sls_i_uncompressed;
|
|
|
|
st->vj.vjs_compressedin = vj->sls_i_compressed;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Stuff for handling the lists of ppp units and channels
|
|
|
|
* and for initialization.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Create a new ppp interface unit. Fails if it can't allocate memory
|
|
|
|
* or if there is already a unit with the requested number.
|
|
|
|
* unit == -1 means allocate a new number.
|
|
|
|
*/
|
|
|
|
static struct ppp *
|
2009-01-21 16:55:35 -07:00
|
|
|
ppp_create_interface(struct net *net, int unit, int *retp)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
|
|
|
struct ppp *ppp;
|
2009-01-21 16:55:35 -07:00
|
|
|
struct ppp_net *pn;
|
2005-04-16 15:20:36 -07:00
|
|
|
struct net_device *dev = NULL;
|
|
|
|
int ret = -ENOMEM;
|
|
|
|
int i;
|
|
|
|
|
2008-11-20 05:24:17 -07:00
|
|
|
dev = alloc_netdev(sizeof(struct ppp), "", ppp_setup);
|
2005-04-16 15:20:36 -07:00
|
|
|
if (!dev)
|
|
|
|
goto out1;
|
|
|
|
|
2009-01-21 16:55:35 -07:00
|
|
|
pn = ppp_pernet(net);
|
|
|
|
|
2008-11-20 05:24:17 -07:00
|
|
|
ppp = netdev_priv(dev);
|
|
|
|
ppp->dev = dev;
|
2005-04-16 15:20:36 -07:00
|
|
|
ppp->mru = PPP_MRU;
|
|
|
|
init_ppp_file(&ppp->file, INTERFACE);
|
|
|
|
ppp->file.hdrlen = PPP_HDRLEN - 2; /* don't count proto bytes */
|
|
|
|
for (i = 0; i < NUM_NP; ++i)
|
|
|
|
ppp->npmode[i] = NPMODE_PASS;
|
|
|
|
INIT_LIST_HEAD(&ppp->channels);
|
|
|
|
spin_lock_init(&ppp->rlock);
|
|
|
|
spin_lock_init(&ppp->wlock);
|
|
|
|
#ifdef CONFIG_PPP_MULTILINK
|
|
|
|
ppp->minseq = -1;
|
|
|
|
skb_queue_head_init(&ppp->mrq);
|
|
|
|
#endif /* CONFIG_PPP_MULTILINK */
|
|
|
|
|
2009-01-21 16:55:35 -07:00
|
|
|
/*
|
|
|
|
* drum roll: don't forget to set
|
|
|
|
* the net device is belong to
|
|
|
|
*/
|
|
|
|
dev_net_set(dev, net);
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
ret = -EEXIST;
|
2009-01-21 16:55:35 -07:00
|
|
|
mutex_lock(&pn->all_ppp_mutex);
|
2008-12-17 01:34:06 -07:00
|
|
|
|
|
|
|
if (unit < 0) {
|
2009-01-21 16:55:35 -07:00
|
|
|
unit = unit_get(&pn->units_idr, ppp);
|
2008-12-17 01:34:06 -07:00
|
|
|
if (unit < 0) {
|
|
|
|
*retp = unit;
|
|
|
|
goto out2;
|
|
|
|
}
|
|
|
|
} else {
|
2009-01-21 16:55:35 -07:00
|
|
|
if (unit_find(&pn->units_idr, unit))
|
2008-12-17 01:34:06 -07:00
|
|
|
goto out2; /* unit already exists */
|
2009-01-12 23:11:56 -07:00
|
|
|
/*
|
|
|
|
* if caller need a specified unit number
|
|
|
|
* lets try to satisfy him, otherwise --
|
|
|
|
* he should better ask us for new unit number
|
|
|
|
*
|
|
|
|
* NOTE: yes I know that returning EEXIST it's not
|
|
|
|
* fair but at least pppd will ask us to allocate
|
|
|
|
* new unit in this case so user is happy :)
|
|
|
|
*/
|
2009-01-21 16:55:35 -07:00
|
|
|
unit = unit_set(&pn->units_idr, ppp, unit);
|
2009-01-12 23:11:56 -07:00
|
|
|
if (unit < 0)
|
2008-12-17 01:34:06 -07:00
|
|
|
goto out2;
|
|
|
|
}
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
/* Initialize the new ppp unit */
|
|
|
|
ppp->file.index = unit;
|
|
|
|
sprintf(dev->name, "ppp%d", unit);
|
|
|
|
|
|
|
|
ret = register_netdev(dev);
|
|
|
|
if (ret != 0) {
|
2009-01-21 16:55:35 -07:00
|
|
|
unit_put(&pn->units_idr, unit);
|
2005-04-16 15:20:36 -07:00
|
|
|
printk(KERN_ERR "PPP: couldn't register device %s (%d)\n",
|
|
|
|
dev->name, ret);
|
|
|
|
goto out2;
|
|
|
|
}
|
|
|
|
|
2009-01-21 16:55:35 -07:00
|
|
|
ppp->ppp_net = net;
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
atomic_inc(&ppp_unit_count);
|
2009-01-21 16:55:35 -07:00
|
|
|
mutex_unlock(&pn->all_ppp_mutex);
|
2008-12-17 01:34:06 -07:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
*retp = 0;
|
|
|
|
return ppp;
|
|
|
|
|
|
|
|
out2:
|
2009-01-21 16:55:35 -07:00
|
|
|
mutex_unlock(&pn->all_ppp_mutex);
|
2005-04-16 15:20:36 -07:00
|
|
|
free_netdev(dev);
|
|
|
|
out1:
|
|
|
|
*retp = ret;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialize a ppp_file structure.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
init_ppp_file(struct ppp_file *pf, int kind)
|
|
|
|
{
|
|
|
|
pf->kind = kind;
|
|
|
|
skb_queue_head_init(&pf->xq);
|
|
|
|
skb_queue_head_init(&pf->rq);
|
|
|
|
atomic_set(&pf->refcnt, 1);
|
|
|
|
init_waitqueue_head(&pf->rwait);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Take down a ppp interface unit - called when the owning file
|
|
|
|
* (the one that created the unit) is closed or detached.
|
|
|
|
*/
|
|
|
|
static void ppp_shutdown_interface(struct ppp *ppp)
|
|
|
|
{
|
2009-01-21 16:55:35 -07:00
|
|
|
struct ppp_net *pn;
|
|
|
|
|
|
|
|
pn = ppp_pernet(ppp->ppp_net);
|
|
|
|
mutex_lock(&pn->all_ppp_mutex);
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
/* This will call dev_close() for us. */
|
2008-12-17 05:02:16 -07:00
|
|
|
ppp_lock(ppp);
|
|
|
|
if (!ppp->closing) {
|
|
|
|
ppp->closing = 1;
|
|
|
|
ppp_unlock(ppp);
|
|
|
|
unregister_netdev(ppp->dev);
|
|
|
|
} else
|
|
|
|
ppp_unlock(ppp);
|
|
|
|
|
2009-01-21 16:55:35 -07:00
|
|
|
unit_put(&pn->units_idr, ppp->file.index);
|
2005-04-16 15:20:36 -07:00
|
|
|
ppp->file.dead = 1;
|
|
|
|
ppp->owner = NULL;
|
|
|
|
wake_up_interruptible(&ppp->file.rwait);
|
2009-01-21 16:55:35 -07:00
|
|
|
|
|
|
|
mutex_unlock(&pn->all_ppp_mutex);
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Free the memory used by a ppp unit. This is only called once
|
|
|
|
* there are no channels connected to the unit and no file structs
|
|
|
|
* that reference the unit.
|
|
|
|
*/
|
|
|
|
static void ppp_destroy_interface(struct ppp *ppp)
|
|
|
|
{
|
|
|
|
atomic_dec(&ppp_unit_count);
|
|
|
|
|
|
|
|
if (!ppp->file.dead || ppp->n_channels) {
|
|
|
|
/* "can't happen" */
|
|
|
|
printk(KERN_ERR "ppp: destroying ppp struct %p but dead=%d "
|
|
|
|
"n_channels=%d !\n", ppp, ppp->file.dead,
|
|
|
|
ppp->n_channels);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ppp_ccp_closed(ppp);
|
|
|
|
if (ppp->vj) {
|
|
|
|
slhc_free(ppp->vj);
|
|
|
|
ppp->vj = NULL;
|
|
|
|
}
|
|
|
|
skb_queue_purge(&ppp->file.xq);
|
|
|
|
skb_queue_purge(&ppp->file.rq);
|
|
|
|
#ifdef CONFIG_PPP_MULTILINK
|
|
|
|
skb_queue_purge(&ppp->mrq);
|
|
|
|
#endif /* CONFIG_PPP_MULTILINK */
|
|
|
|
#ifdef CONFIG_PPP_FILTER
|
2005-05-03 14:38:09 -07:00
|
|
|
kfree(ppp->pass_filter);
|
|
|
|
ppp->pass_filter = NULL;
|
|
|
|
kfree(ppp->active_filter);
|
|
|
|
ppp->active_filter = NULL;
|
2005-04-16 15:20:36 -07:00
|
|
|
#endif /* CONFIG_PPP_FILTER */
|
|
|
|
|
2009-02-24 17:16:08 -07:00
|
|
|
kfree_skb(ppp->xmit_pending);
|
2007-03-25 19:04:09 -07:00
|
|
|
|
2008-12-17 05:02:16 -07:00
|
|
|
free_netdev(ppp->dev);
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Locate an existing ppp unit.
|
2006-03-23 04:00:21 -07:00
|
|
|
* The caller should have locked the all_ppp_mutex.
|
2005-04-16 15:20:36 -07:00
|
|
|
*/
|
|
|
|
static struct ppp *
|
2009-01-21 16:55:35 -07:00
|
|
|
ppp_find_unit(struct ppp_net *pn, int unit)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
2009-01-21 16:55:35 -07:00
|
|
|
return unit_find(&pn->units_idr, unit);
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Locate an existing ppp channel.
|
|
|
|
* The caller should have locked the all_channels_lock.
|
|
|
|
* First we look in the new_channels list, then in the
|
|
|
|
* all_channels list. If found in the new_channels list,
|
|
|
|
* we move it to the all_channels list. This is for speed
|
|
|
|
* when we have a lot of channels in use.
|
|
|
|
*/
|
|
|
|
static struct channel *
|
2009-01-21 16:55:35 -07:00
|
|
|
ppp_find_channel(struct ppp_net *pn, int unit)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
|
|
|
struct channel *pch;
|
|
|
|
|
2009-01-21 16:55:35 -07:00
|
|
|
list_for_each_entry(pch, &pn->new_channels, list) {
|
2005-04-16 15:20:36 -07:00
|
|
|
if (pch->file.index == unit) {
|
2009-01-21 16:55:35 -07:00
|
|
|
list_move(&pch->list, &pn->all_channels);
|
2005-04-16 15:20:36 -07:00
|
|
|
return pch;
|
|
|
|
}
|
|
|
|
}
|
2009-01-21 16:55:35 -07:00
|
|
|
|
|
|
|
list_for_each_entry(pch, &pn->all_channels, list) {
|
2005-04-16 15:20:36 -07:00
|
|
|
if (pch->file.index == unit)
|
|
|
|
return pch;
|
|
|
|
}
|
2009-01-21 16:55:35 -07:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Connect a PPP channel to a PPP interface unit.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
ppp_connect_channel(struct channel *pch, int unit)
|
|
|
|
{
|
|
|
|
struct ppp *ppp;
|
2009-01-21 16:55:35 -07:00
|
|
|
struct ppp_net *pn;
|
2005-04-16 15:20:36 -07:00
|
|
|
int ret = -ENXIO;
|
|
|
|
int hdrlen;
|
|
|
|
|
2009-01-21 16:55:35 -07:00
|
|
|
pn = ppp_pernet(pch->chan_net);
|
|
|
|
|
|
|
|
mutex_lock(&pn->all_ppp_mutex);
|
|
|
|
ppp = ppp_find_unit(pn, unit);
|
2007-11-12 19:07:31 -07:00
|
|
|
if (!ppp)
|
2005-04-16 15:20:36 -07:00
|
|
|
goto out;
|
|
|
|
write_lock_bh(&pch->upl);
|
|
|
|
ret = -EINVAL;
|
2007-11-12 19:07:31 -07:00
|
|
|
if (pch->ppp)
|
2005-04-16 15:20:36 -07:00
|
|
|
goto outl;
|
|
|
|
|
|
|
|
ppp_lock(ppp);
|
|
|
|
if (pch->file.hdrlen > ppp->file.hdrlen)
|
|
|
|
ppp->file.hdrlen = pch->file.hdrlen;
|
|
|
|
hdrlen = pch->file.hdrlen + 2; /* for protocol bytes */
|
2008-12-17 05:02:16 -07:00
|
|
|
if (hdrlen > ppp->dev->hard_header_len)
|
2005-04-16 15:20:36 -07:00
|
|
|
ppp->dev->hard_header_len = hdrlen;
|
|
|
|
list_add_tail(&pch->clist, &ppp->channels);
|
|
|
|
++ppp->n_channels;
|
|
|
|
pch->ppp = ppp;
|
|
|
|
atomic_inc(&ppp->file.refcnt);
|
|
|
|
ppp_unlock(ppp);
|
|
|
|
ret = 0;
|
|
|
|
|
|
|
|
outl:
|
|
|
|
write_unlock_bh(&pch->upl);
|
|
|
|
out:
|
2009-01-21 16:55:35 -07:00
|
|
|
mutex_unlock(&pn->all_ppp_mutex);
|
2005-04-16 15:20:36 -07:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Disconnect a channel from its ppp unit.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
ppp_disconnect_channel(struct channel *pch)
|
|
|
|
{
|
|
|
|
struct ppp *ppp;
|
|
|
|
int err = -EINVAL;
|
|
|
|
|
|
|
|
write_lock_bh(&pch->upl);
|
|
|
|
ppp = pch->ppp;
|
|
|
|
pch->ppp = NULL;
|
|
|
|
write_unlock_bh(&pch->upl);
|
2007-11-12 19:07:31 -07:00
|
|
|
if (ppp) {
|
2005-04-16 15:20:36 -07:00
|
|
|
/* remove it from the ppp unit's list */
|
|
|
|
ppp_lock(ppp);
|
|
|
|
list_del(&pch->clist);
|
|
|
|
if (--ppp->n_channels == 0)
|
|
|
|
wake_up_interruptible(&ppp->file.rwait);
|
|
|
|
ppp_unlock(ppp);
|
|
|
|
if (atomic_dec_and_test(&ppp->file.refcnt))
|
|
|
|
ppp_destroy_interface(ppp);
|
|
|
|
err = 0;
|
|
|
|
}
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Free up the resources used by a ppp channel.
|
|
|
|
*/
|
|
|
|
static void ppp_destroy_channel(struct channel *pch)
|
|
|
|
{
|
|
|
|
atomic_dec(&channel_count);
|
|
|
|
|
|
|
|
if (!pch->file.dead) {
|
|
|
|
/* "can't happen" */
|
|
|
|
printk(KERN_ERR "ppp: destroying undead channel %p !\n",
|
|
|
|
pch);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
skb_queue_purge(&pch->file.xq);
|
|
|
|
skb_queue_purge(&pch->file.rq);
|
|
|
|
kfree(pch);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __exit ppp_cleanup(void)
|
|
|
|
{
|
|
|
|
/* should never happen */
|
|
|
|
if (atomic_read(&ppp_unit_count) || atomic_read(&channel_count))
|
|
|
|
printk(KERN_ERR "PPP: removing module but units remain!\n");
|
2007-07-19 01:47:50 -07:00
|
|
|
unregister_chrdev(PPP_MAJOR, "ppp");
|
2006-09-12 08:00:10 -07:00
|
|
|
device_destroy(ppp_class, MKDEV(PPP_MAJOR, 0));
|
2005-03-23 11:01:41 -07:00
|
|
|
class_destroy(ppp_class);
|
2009-01-21 16:55:35 -07:00
|
|
|
unregister_pernet_gen_device(ppp_net_id, &ppp_net_ops);
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2008-12-17 01:34:06 -07:00
|
|
|
* Units handling. Caller must protect concurrent access
|
|
|
|
* by holding all_ppp_mutex
|
2005-04-16 15:20:36 -07:00
|
|
|
*/
|
2008-12-17 01:34:06 -07:00
|
|
|
|
2009-01-12 23:11:56 -07:00
|
|
|
/* associate pointer with specified number */
|
|
|
|
static int unit_set(struct idr *p, void *ptr, int n)
|
|
|
|
{
|
|
|
|
int unit, err;
|
|
|
|
|
|
|
|
again:
|
|
|
|
if (!idr_pre_get(p, GFP_KERNEL)) {
|
|
|
|
printk(KERN_ERR "PPP: No free memory for idr\n");
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
err = idr_get_new_above(p, ptr, n, &unit);
|
|
|
|
if (err == -EAGAIN)
|
|
|
|
goto again;
|
|
|
|
|
|
|
|
if (unit != n) {
|
|
|
|
idr_remove(p, unit);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return unit;
|
|
|
|
}
|
|
|
|
|
2008-12-17 01:34:06 -07:00
|
|
|
/* get new free unit number and associate pointer with it */
|
|
|
|
static int unit_get(struct idr *p, void *ptr)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
2008-12-17 01:34:06 -07:00
|
|
|
int unit, err;
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2008-12-17 01:34:06 -07:00
|
|
|
again:
|
2009-01-12 23:11:56 -07:00
|
|
|
if (!idr_pre_get(p, GFP_KERNEL)) {
|
|
|
|
printk(KERN_ERR "PPP: No free memory for idr\n");
|
2008-12-17 01:34:06 -07:00
|
|
|
return -ENOMEM;
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
|
|
|
|
2008-12-17 01:34:06 -07:00
|
|
|
err = idr_get_new_above(p, ptr, 0, &unit);
|
|
|
|
if (err == -EAGAIN)
|
|
|
|
goto again;
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2008-12-17 01:34:06 -07:00
|
|
|
return unit;
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
|
|
|
|
2008-12-17 01:34:06 -07:00
|
|
|
/* put unit number back to a pool */
|
|
|
|
static void unit_put(struct idr *p, int n)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
2008-12-17 01:34:06 -07:00
|
|
|
idr_remove(p, n);
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
|
|
|
|
2008-12-17 01:34:06 -07:00
|
|
|
/* get pointer associated with the number */
|
|
|
|
static void *unit_find(struct idr *p, int n)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
2008-12-17 01:34:06 -07:00
|
|
|
return idr_find(p, n);
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Module/initialization stuff */
|
|
|
|
|
|
|
|
module_init(ppp_init);
|
|
|
|
module_exit(ppp_cleanup);
|
|
|
|
|
2009-01-21 16:55:35 -07:00
|
|
|
EXPORT_SYMBOL(ppp_register_net_channel);
|
2005-04-16 15:20:36 -07:00
|
|
|
EXPORT_SYMBOL(ppp_register_channel);
|
|
|
|
EXPORT_SYMBOL(ppp_unregister_channel);
|
|
|
|
EXPORT_SYMBOL(ppp_channel_index);
|
|
|
|
EXPORT_SYMBOL(ppp_unit_number);
|
|
|
|
EXPORT_SYMBOL(ppp_input);
|
|
|
|
EXPORT_SYMBOL(ppp_input_error);
|
|
|
|
EXPORT_SYMBOL(ppp_output_wakeup);
|
|
|
|
EXPORT_SYMBOL(ppp_register_compressor);
|
|
|
|
EXPORT_SYMBOL(ppp_unregister_compressor);
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
MODULE_ALIAS_CHARDEV_MAJOR(PPP_MAJOR);
|
|
|
|
MODULE_ALIAS("/dev/ppp");
|