diff options
Diffstat (limited to 'kernel/drivers/net/ppp')
-rw-r--r-- | kernel/drivers/net/ppp/ppp_generic.c | 103 | ||||
-rw-r--r-- | kernel/drivers/net/ppp/pppoe.c | 23 | ||||
-rw-r--r-- | kernel/drivers/net/ppp/pppox.c | 2 | ||||
-rw-r--r-- | kernel/drivers/net/ppp/pptp.c | 53 |
4 files changed, 113 insertions, 68 deletions
diff --git a/kernel/drivers/net/ppp/ppp_generic.c b/kernel/drivers/net/ppp/ppp_generic.c index 9d1556652..9a863c6a6 100644 --- a/kernel/drivers/net/ppp/ppp_generic.c +++ b/kernel/drivers/net/ppp/ppp_generic.c @@ -269,9 +269,9 @@ 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); -static struct ppp *ppp_create_interface(struct net *net, int unit, int *retp); +static struct ppp *ppp_create_interface(struct net *net, int unit, + struct file *file, int *retp); 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); static struct ppp *ppp_find_unit(struct ppp_net *pn, int unit); static struct channel *ppp_find_channel(struct ppp_net *pn, int unit); @@ -283,6 +283,8 @@ static int unit_set(struct idr *p, void *ptr, int n); static void unit_put(struct idr *p, int n); static void *unit_find(struct idr *p, int n); +static const struct net_device_ops ppp_netdev_ops; + static struct class *ppp_class; /* per net-namespace data */ @@ -392,8 +394,10 @@ static int ppp_release(struct inode *unused, struct file *file) file->private_data = NULL; if (pf->kind == INTERFACE) { ppp = PF_TO_PPP(pf); + rtnl_lock(); if (file == ppp->owner) - ppp_shutdown_interface(ppp); + unregister_netdevice(ppp->dev); + rtnl_unlock(); } if (atomic_dec_and_test(&pf->refcnt)) { switch (pf->kind) { @@ -593,8 +597,10 @@ static long ppp_ioctl(struct file *file, unsigned int cmd, unsigned long arg) mutex_lock(&ppp_mutex); if (pf->kind == INTERFACE) { ppp = PF_TO_PPP(pf); + rtnl_lock(); if (file == ppp->owner) - ppp_shutdown_interface(ppp); + unregister_netdevice(ppp->dev); + rtnl_unlock(); } if (atomic_long_read(&file->f_count) < 2) { ppp_release(NULL, file); @@ -715,10 +721,8 @@ static long ppp_ioctl(struct file *file, unsigned int cmd, unsigned long arg) val &= 0xffff; } vj = slhc_init(val2+1, val+1); - if (!vj) { - netdev_err(ppp->dev, - "PPP: no memory (VJ compressor)\n"); - err = -ENOMEM; + if (IS_ERR(vj)) { + err = PTR_ERR(vj); break; } ppp_lock(ppp); @@ -838,11 +842,10 @@ static int ppp_unattached_ioctl(struct net *net, struct ppp_file *pf, /* Create a new ppp unit */ if (get_user(unit, p)) break; - ppp = ppp_create_interface(net, unit, &err); + ppp = ppp_create_interface(net, unit, file, &err); if (!ppp) break; file->private_data = &ppp->file; - ppp->owner = file; err = -EFAULT; if (put_user(ppp->file.index, p)) break; @@ -916,6 +919,25 @@ static __net_init int ppp_init_net(struct net *net) static __net_exit void ppp_exit_net(struct net *net) { struct ppp_net *pn = net_generic(net, ppp_net_id); + struct net_device *dev; + struct net_device *aux; + struct ppp *ppp; + LIST_HEAD(list); + int id; + + rtnl_lock(); + for_each_netdev_safe(net, dev, aux) { + if (dev->netdev_ops == &ppp_netdev_ops) + unregister_netdevice_queue(dev, &list); + } + + idr_for_each_entry(&pn->units_idr, ppp, id) + /* Skip devices already unregistered by previous loop */ + if (!net_eq(dev_net(ppp->dev), net)) + unregister_netdevice_queue(ppp->dev, &list); + + unregister_netdevice_many(&list); + rtnl_unlock(); idr_destroy(&pn->units_idr); } @@ -1004,6 +1026,7 @@ ppp_start_xmit(struct sk_buff *skb, struct net_device *dev) proto = npindex_to_proto[npi]; put_unaligned_be16(proto, pp); + skb_scrub_packet(skb, !net_eq(ppp->ppp_net, dev_net(dev))); skb_queue_tail(&ppp->file.xq, skb); ppp_xmit_process(ppp); return NETDEV_TX_OK; @@ -1088,8 +1111,28 @@ static int ppp_dev_init(struct net_device *dev) return 0; } +static void ppp_dev_uninit(struct net_device *dev) +{ + struct ppp *ppp = netdev_priv(dev); + struct ppp_net *pn = ppp_pernet(ppp->ppp_net); + + ppp_lock(ppp); + ppp->closing = 1; + ppp_unlock(ppp); + + mutex_lock(&pn->all_ppp_mutex); + unit_put(&pn->units_idr, ppp->file.index); + mutex_unlock(&pn->all_ppp_mutex); + + ppp->owner = NULL; + + ppp->file.dead = 1; + wake_up_interruptible(&ppp->file.rwait); +} + static const struct net_device_ops ppp_netdev_ops = { .ndo_init = ppp_dev_init, + .ndo_uninit = ppp_dev_uninit, .ndo_start_xmit = ppp_start_xmit, .ndo_do_ioctl = ppp_net_ioctl, .ndo_get_stats64 = ppp_get_stats64, @@ -1104,7 +1147,6 @@ static void ppp_setup(struct net_device *dev) dev->tx_queue_len = 3; dev->type = ARPHRD_PPP; dev->flags = IFF_POINTOPOINT | IFF_NOARP | IFF_MULTICAST; - dev->features |= NETIF_F_NETNS_LOCAL; netif_keep_dst(dev); } @@ -1867,6 +1909,8 @@ ppp_receive_nonmp_frame(struct ppp *ppp, struct sk_buff *skb) skb->dev = ppp->dev; skb->protocol = htons(npindex_to_ethertype[npi]); skb_reset_mac_header(skb); + skb_scrub_packet(skb, !net_eq(ppp->ppp_net, + dev_net(ppp->dev))); netif_rx(skb); } } @@ -2667,8 +2711,8 @@ ppp_get_stats(struct ppp *ppp, struct ppp_stats *st) * or if there is already a unit with the requested number. * unit == -1 means allocate a new number. */ -static struct ppp * -ppp_create_interface(struct net *net, int unit, int *retp) +static struct ppp *ppp_create_interface(struct net *net, int unit, + struct file *file, int *retp) { struct ppp *ppp; struct ppp_net *pn; @@ -2688,6 +2732,7 @@ ppp_create_interface(struct net *net, int unit, int *retp) ppp->mru = PPP_MRU; init_ppp_file(&ppp->file, INTERFACE); ppp->file.hdrlen = PPP_HDRLEN - 2; /* don't count proto bytes */ + ppp->owner = file; for (i = 0; i < NUM_NP; ++i) ppp->npmode[i] = NPMODE_PASS; INIT_LIST_HEAD(&ppp->channels); @@ -2708,6 +2753,7 @@ ppp_create_interface(struct net *net, int unit, int *retp) */ dev_net_set(dev, net); #!/bin/bash
# Copyright 2015 Intel Corporation.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# VSPERF code checker
PYLINT="pylint"
PYLINT_RC='pylintrc'
PYLINT_RATING_GATE="10"
FILE_REGEX="(vsperf|.*\.py)"
FIND_OPTIONS="-regextype posix-egrep -iregex (./)?$FILE_REGEX"
FILE_LIST="/tmp/vsperf_check_list.txt"
# print usage if requested
function usage() {
cat <<EOM
Usage: $0 [TARGET]...
Performs code check for defined TARGETs. Target can be file or directory.
In case that directory is specified, then it will be searched recursively
for all python files.
If TARGET is not specified, then all python files from current VSPERF
repository will be checked.
Files listed in EXCLUDE_MODULES defined in conf/00_common.conf will be skipped.
File will pass check if its pylint rating is greater or equal to $PYLINT_RATING_GATE.
Otherwise gained pylint rating will be displayed.
-h, --help Script usage
-m, --modified Script will check python files, which have
been modified within current repository.
Examples:
./check
Check all python files in current VSPERF repository except EXCLUDE_MODULES
./check vsperf
Check just one file.
./check -m
Check all modified files in current VSPERF repository
./check vnfs/qemu core tools/pkt_gen
Check all python files in given directories
EOM
}
# compare pylint result with predefined gate
function rating_is_ok() {
# bc is not part of basic Centos installation
# so let us do integer comparison only
int_rating=`echo $1 | sed -e 's/\..*$//'`
[ $int_rating -ge $PYLINT_RATING_GATE ]
}
##### MAIN #####
# check if help is requested
if [ "x$1" == "x-h" -o "x$1" == "x--help" ] ; then
usage
exit 0
fi
# check if pylint is available
if ! which $PYLINT &>/dev/null ; then
echo "$PYLINT is not available, thus check can't be executed"
exit 1
fi
# check if we were run within vsperf directory
if [ ! -x ./vsperf 2> /dev/null ] ; then
echo "`basename $0` must be run from vsperf root directory"
exit 2
fi
# get list of excluded modules
EXCLUDED_MODULES=`grep "^ *EXCLUDE_MODULES" conf/00_common.conf | tr '"' "'"`
# get list of files to be checked
rm $FILE_LIST &> /dev/null
if [ "x$1" == "x-m" -o "x$1" == "x--modified" ] ; then
# check of modified files requested
git status --porcelain | cut -b4- | egrep -i "^${FILE_REGEX}$" > $FILE_LIST
elif [ "x$*" == "x" ] ; then
# list is empty, check all python files
find . -type f $FIND_OPTIONS > $FILE_LIST
else
for item in $* ; do
if [ -d $item |