2005-04-17 02:20:36 +04:00
|
|
|
/*
|
|
|
|
* Equalizer Load-balancer for serial network interfaces.
|
|
|
|
*
|
|
|
|
* (c) Copyright 1995 Simon "Guru Aleph-Null" Janes
|
|
|
|
* NCM: Network and Communications Management, Inc.
|
|
|
|
*
|
|
|
|
* (c) Copyright 2002 David S. Miller (davem@redhat.com)
|
|
|
|
*
|
|
|
|
* This software may be used and distributed according to the terms
|
|
|
|
* of the GNU General Public License, incorporated herein by reference.
|
2006-09-13 21:24:59 +04:00
|
|
|
*
|
2005-04-17 02:20:36 +04:00
|
|
|
* The author may be reached as simon@ncm.com, or C/O
|
|
|
|
* NCM
|
|
|
|
* Attn: Simon Janes
|
|
|
|
* 6803 Whittier Ave
|
|
|
|
* McLean VA 22101
|
|
|
|
* Phone: 1-703-847-0040 ext 103
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Sources:
|
|
|
|
* skeleton.c by Donald Becker.
|
|
|
|
* Inspirations:
|
|
|
|
* The Harried and Overworked Alan Cox
|
|
|
|
* Conspiracies:
|
2006-09-13 21:24:59 +04:00
|
|
|
* The Alan Cox and Mike McLagan plot to get someone else to do the code,
|
2005-04-17 02:20:36 +04:00
|
|
|
* which turned out to be me.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* $Log: eql.c,v $
|
|
|
|
* Revision 1.2 1996/04/11 17:51:52 guru
|
|
|
|
* Added one-line eql_remove_slave patch.
|
|
|
|
*
|
|
|
|
* Revision 1.1 1996/04/11 17:44:17 guru
|
|
|
|
* Initial revision
|
|
|
|
*
|
|
|
|
* Revision 3.13 1996/01/21 15:17:18 alan
|
|
|
|
* tx_queue_len changes.
|
|
|
|
* reformatted.
|
|
|
|
*
|
|
|
|
* Revision 3.12 1995/03/22 21:07:51 anarchy
|
|
|
|
* Added capable() checks on configuration.
|
|
|
|
* Moved header file.
|
|
|
|
*
|
|
|
|
* Revision 3.11 1995/01/19 23:14:31 guru
|
|
|
|
* slave_load = (ULONG_MAX - (ULONG_MAX / 2)) -
|
|
|
|
* (priority_Bps) + bytes_queued * 8;
|
|
|
|
*
|
|
|
|
* Revision 3.10 1995/01/19 23:07:53 guru
|
|
|
|
* back to
|
|
|
|
* slave_load = (ULONG_MAX - (ULONG_MAX / 2)) -
|
|
|
|
* (priority_Bps) + bytes_queued;
|
|
|
|
*
|
|
|
|
* Revision 3.9 1995/01/19 22:38:20 guru
|
|
|
|
* slave_load = (ULONG_MAX - (ULONG_MAX / 2)) -
|
|
|
|
* (priority_Bps) + bytes_queued * 4;
|
|
|
|
*
|
|
|
|
* Revision 3.8 1995/01/19 22:30:55 guru
|
|
|
|
* slave_load = (ULONG_MAX - (ULONG_MAX / 2)) -
|
|
|
|
* (priority_Bps) + bytes_queued * 2;
|
|
|
|
*
|
|
|
|
* Revision 3.7 1995/01/19 21:52:35 guru
|
|
|
|
* printk's trimmed out.
|
|
|
|
*
|
|
|
|
* Revision 3.6 1995/01/19 21:49:56 guru
|
|
|
|
* This is working pretty well. I gained 1 K/s in speed.. now it's just
|
|
|
|
* robustness and printk's to be diked out.
|
|
|
|
*
|
|
|
|
* Revision 3.5 1995/01/18 22:29:59 guru
|
|
|
|
* still crashes the kernel when the lock_wait thing is woken up.
|
|
|
|
*
|
|
|
|
* Revision 3.4 1995/01/18 21:59:47 guru
|
|
|
|
* Broken set-bit locking snapshot
|
|
|
|
*
|
|
|
|
* Revision 3.3 1995/01/17 22:09:18 guru
|
|
|
|
* infinite sleep in a lock somewhere..
|
|
|
|
*
|
|
|
|
* Revision 3.2 1995/01/15 16:46:06 guru
|
|
|
|
* Log trimmed of non-pertinent 1.x branch messages
|
|
|
|
*
|
|
|
|
* Revision 3.1 1995/01/15 14:41:45 guru
|
|
|
|
* New Scheduler and timer stuff...
|
|
|
|
*
|
|
|
|
* Revision 1.15 1995/01/15 14:29:02 guru
|
|
|
|
* Will make 1.14 (now 1.15) the 3.0 branch, and the 1.12 the 2.0 branch, the one
|
|
|
|
* with the dumber scheduler
|
|
|
|
*
|
|
|
|
* Revision 1.14 1995/01/15 02:37:08 guru
|
|
|
|
* shock.. the kept-new-versions could have zonked working
|
|
|
|
* stuff.. shudder
|
|
|
|
*
|
|
|
|
* Revision 1.13 1995/01/15 02:36:31 guru
|
|
|
|
* big changes
|
|
|
|
*
|
|
|
|
* scheduler was torn out and replaced with something smarter
|
|
|
|
*
|
|
|
|
* global names not prefixed with eql_ were renamed to protect
|
|
|
|
* against namespace collisions
|
|
|
|
*
|
|
|
|
* a few more abstract interfaces were added to facilitate any
|
|
|
|
* potential change of datastructure. the driver is still using
|
|
|
|
* a linked list of slaves. going to a heap would be a bit of
|
|
|
|
* an overkill.
|
|
|
|
*
|
|
|
|
* this compiles fine with no warnings.
|
|
|
|
*
|
|
|
|
* the locking mechanism and timer stuff must be written however,
|
|
|
|
* this version will not work otherwise
|
|
|
|
*
|
|
|
|
* Sorry, I had to rewrite most of this for 2.5.x -DaveM
|
|
|
|
*/
|
|
|
|
|
2011-03-04 00:30:20 +03:00
|
|
|
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
|
|
|
|
|
2009-10-07 17:09:06 +04:00
|
|
|
#include <linux/capability.h>
|
2005-04-17 02:20:36 +04:00
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/init.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 11:04:11 +03:00
|
|
|
#include <linux/slab.h>
|
2005-04-17 02:20:36 +04:00
|
|
|
#include <linux/timer.h>
|
|
|
|
#include <linux/netdevice.h>
|
2007-09-17 22:56:21 +04:00
|
|
|
#include <net/net_namespace.h>
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
#include <linux/if.h>
|
|
|
|
#include <linux/if_arp.h>
|
|
|
|
#include <linux/if_eql.h>
|
2012-03-27 02:52:00 +04:00
|
|
|
#include <linux/pkt_sched.h>
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2016-12-24 22:46:01 +03:00
|
|
|
#include <linux/uaccess.h>
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
static int eql_open(struct net_device *dev);
|
|
|
|
static int eql_close(struct net_device *dev);
|
|
|
|
static int eql_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd);
|
2009-08-31 23:50:51 +04:00
|
|
|
static netdev_tx_t eql_slave_xmit(struct sk_buff *skb, struct net_device *dev);
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
#define eql_is_slave(dev) ((dev->flags & IFF_SLAVE) == IFF_SLAVE)
|
|
|
|
#define eql_is_master(dev) ((dev->flags & IFF_MASTER) == IFF_MASTER)
|
|
|
|
|
2005-07-22 01:16:54 +04:00
|
|
|
static void eql_kill_one_slave(slave_queue_t *queue, slave_t *slave);
|
2005-04-17 02:20:36 +04:00
|
|
|
|
treewide: setup_timer() -> timer_setup()
This converts all remaining cases of the old setup_timer() API into using
timer_setup(), where the callback argument is the structure already
holding the struct timer_list. These should have no behavioral changes,
since they just change which pointer is passed into the callback with
the same available pointers after conversion. It handles the following
examples, in addition to some other variations.
Casting from unsigned long:
void my_callback(unsigned long data)
{
struct something *ptr = (struct something *)data;
...
}
...
setup_timer(&ptr->my_timer, my_callback, ptr);
and forced object casts:
void my_callback(struct something *ptr)
{
...
}
...
setup_timer(&ptr->my_timer, my_callback, (unsigned long)ptr);
become:
void my_callback(struct timer_list *t)
{
struct something *ptr = from_timer(ptr, t, my_timer);
...
}
...
timer_setup(&ptr->my_timer, my_callback, 0);
Direct function assignments:
void my_callback(unsigned long data)
{
struct something *ptr = (struct something *)data;
...
}
...
ptr->my_timer.function = my_callback;
have a temporary cast added, along with converting the args:
void my_callback(struct timer_list *t)
{
struct something *ptr = from_timer(ptr, t, my_timer);
...
}
...
ptr->my_timer.function = (TIMER_FUNC_TYPE)my_callback;
And finally, callbacks without a data assignment:
void my_callback(unsigned long data)
{
...
}
...
setup_timer(&ptr->my_timer, my_callback, 0);
have their argument renamed to verify they're unused during conversion:
void my_callback(struct timer_list *unused)
{
...
}
...
timer_setup(&ptr->my_timer, my_callback, 0);
The conversion is done with the following Coccinelle script:
spatch --very-quiet --all-includes --include-headers \
-I ./arch/x86/include -I ./arch/x86/include/generated \
-I ./include -I ./arch/x86/include/uapi \
-I ./arch/x86/include/generated/uapi -I ./include/uapi \
-I ./include/generated/uapi --include ./include/linux/kconfig.h \
--dir . \
--cocci-file ~/src/data/timer_setup.cocci
@fix_address_of@
expression e;
@@
setup_timer(
-&(e)
+&e
, ...)
// Update any raw setup_timer() usages that have a NULL callback, but
// would otherwise match change_timer_function_usage, since the latter
// will update all function assignments done in the face of a NULL
// function initialization in setup_timer().
@change_timer_function_usage_NULL@
expression _E;
identifier _timer;
type _cast_data;
@@
(
-setup_timer(&_E->_timer, NULL, _E);
+timer_setup(&_E->_timer, NULL, 0);
|
-setup_timer(&_E->_timer, NULL, (_cast_data)_E);
+timer_setup(&_E->_timer, NULL, 0);
|
-setup_timer(&_E._timer, NULL, &_E);
+timer_setup(&_E._timer, NULL, 0);
|
-setup_timer(&_E._timer, NULL, (_cast_data)&_E);
+timer_setup(&_E._timer, NULL, 0);
)
@change_timer_function_usage@
expression _E;
identifier _timer;
struct timer_list _stl;
identifier _callback;
type _cast_func, _cast_data;
@@
(
-setup_timer(&_E->_timer, _callback, _E);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E->_timer, &_callback, _E);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E->_timer, _callback, (_cast_data)_E);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E->_timer, &_callback, (_cast_data)_E);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E->_timer, (_cast_func)_callback, _E);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E->_timer, (_cast_func)&_callback, _E);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E->_timer, (_cast_func)_callback, (_cast_data)_E);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E->_timer, (_cast_func)&_callback, (_cast_data)_E);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E._timer, _callback, (_cast_data)_E);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_E._timer, _callback, (_cast_data)&_E);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_E._timer, &_callback, (_cast_data)_E);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_E._timer, &_callback, (_cast_data)&_E);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_E._timer, (_cast_func)_callback, (_cast_data)_E);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_E._timer, (_cast_func)_callback, (_cast_data)&_E);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_E._timer, (_cast_func)&_callback, (_cast_data)_E);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_E._timer, (_cast_func)&_callback, (_cast_data)&_E);
+timer_setup(&_E._timer, _callback, 0);
|
_E->_timer@_stl.function = _callback;
|
_E->_timer@_stl.function = &_callback;
|
_E->_timer@_stl.function = (_cast_func)_callback;
|
_E->_timer@_stl.function = (_cast_func)&_callback;
|
_E._timer@_stl.function = _callback;
|
_E._timer@_stl.function = &_callback;
|
_E._timer@_stl.function = (_cast_func)_callback;
|
_E._timer@_stl.function = (_cast_func)&_callback;
)
// callback(unsigned long arg)
@change_callback_handle_cast
depends on change_timer_function_usage@
identifier change_timer_function_usage._callback;
identifier change_timer_function_usage._timer;
type _origtype;
identifier _origarg;
type _handletype;
identifier _handle;
@@
void _callback(
-_origtype _origarg
+struct timer_list *t
)
{
(
... when != _origarg
_handletype *_handle =
-(_handletype *)_origarg;
+from_timer(_handle, t, _timer);
... when != _origarg
|
... when != _origarg
_handletype *_handle =
-(void *)_origarg;
+from_timer(_handle, t, _timer);
... when != _origarg
|
... when != _origarg
_handletype *_handle;
... when != _handle
_handle =
-(_handletype *)_origarg;
+from_timer(_handle, t, _timer);
... when != _origarg
|
... when != _origarg
_handletype *_handle;
... when != _handle
_handle =
-(void *)_origarg;
+from_timer(_handle, t, _timer);
... when != _origarg
)
}
// callback(unsigned long arg) without existing variable
@change_callback_handle_cast_no_arg
depends on change_timer_function_usage &&
!change_callback_handle_cast@
identifier change_timer_function_usage._callback;
identifier change_timer_function_usage._timer;
type _origtype;
identifier _origarg;
type _handletype;
@@
void _callback(
-_origtype _origarg
+struct timer_list *t
)
{
+ _handletype *_origarg = from_timer(_origarg, t, _timer);
+
... when != _origarg
- (_handletype *)_origarg
+ _origarg
... when != _origarg
}
// Avoid already converted callbacks.
@match_callback_converted
depends on change_timer_function_usage &&
!change_callback_handle_cast &&
!change_callback_handle_cast_no_arg@
identifier change_timer_function_usage._callback;
identifier t;
@@
void _callback(struct timer_list *t)
{ ... }
// callback(struct something *handle)
@change_callback_handle_arg
depends on change_timer_function_usage &&
!match_callback_converted &&
!change_callback_handle_cast &&
!change_callback_handle_cast_no_arg@
identifier change_timer_function_usage._callback;
identifier change_timer_function_usage._timer;
type _handletype;
identifier _handle;
@@
void _callback(
-_handletype *_handle
+struct timer_list *t
)
{
+ _handletype *_handle = from_timer(_handle, t, _timer);
...
}
// If change_callback_handle_arg ran on an empty function, remove
// the added handler.
@unchange_callback_handle_arg
depends on change_timer_function_usage &&
change_callback_handle_arg@
identifier change_timer_function_usage._callback;
identifier change_timer_function_usage._timer;
type _handletype;
identifier _handle;
identifier t;
@@
void _callback(struct timer_list *t)
{
- _handletype *_handle = from_timer(_handle, t, _timer);
}
// We only want to refactor the setup_timer() data argument if we've found
// the matching callback. This undoes changes in change_timer_function_usage.
@unchange_timer_function_usage
depends on change_timer_function_usage &&
!change_callback_handle_cast &&
!change_callback_handle_cast_no_arg &&
!change_callback_handle_arg@
expression change_timer_function_usage._E;
identifier change_timer_function_usage._timer;
identifier change_timer_function_usage._callback;
type change_timer_function_usage._cast_data;
@@
(
-timer_setup(&_E->_timer, _callback, 0);
+setup_timer(&_E->_timer, _callback, (_cast_data)_E);
|
-timer_setup(&_E._timer, _callback, 0);
+setup_timer(&_E._timer, _callback, (_cast_data)&_E);
)
// If we fixed a callback from a .function assignment, fix the
// assignment cast now.
@change_timer_function_assignment
depends on change_timer_function_usage &&
(change_callback_handle_cast ||
change_callback_handle_cast_no_arg ||
change_callback_handle_arg)@
expression change_timer_function_usage._E;
identifier change_timer_function_usage._timer;
identifier change_timer_function_usage._callback;
type _cast_func;
typedef TIMER_FUNC_TYPE;
@@
(
_E->_timer.function =
-_callback
+(TIMER_FUNC_TYPE)_callback
;
|
_E->_timer.function =
-&_callback
+(TIMER_FUNC_TYPE)_callback
;
|
_E->_timer.function =
-(_cast_func)_callback;
+(TIMER_FUNC_TYPE)_callback
;
|
_E->_timer.function =
-(_cast_func)&_callback
+(TIMER_FUNC_TYPE)_callback
;
|
_E._timer.function =
-_callback
+(TIMER_FUNC_TYPE)_callback
;
|
_E._timer.function =
-&_callback;
+(TIMER_FUNC_TYPE)_callback
;
|
_E._timer.function =
-(_cast_func)_callback
+(TIMER_FUNC_TYPE)_callback
;
|
_E._timer.function =
-(_cast_func)&_callback
+(TIMER_FUNC_TYPE)_callback
;
)
// Sometimes timer functions are called directly. Replace matched args.
@change_timer_function_calls
depends on change_timer_function_usage &&
(change_callback_handle_cast ||
change_callback_handle_cast_no_arg ||
change_callback_handle_arg)@
expression _E;
identifier change_timer_function_usage._timer;
identifier change_timer_function_usage._callback;
type _cast_data;
@@
_callback(
(
-(_cast_data)_E
+&_E->_timer
|
-(_cast_data)&_E
+&_E._timer
|
-_E
+&_E->_timer
)
)
// If a timer has been configured without a data argument, it can be
// converted without regard to the callback argument, since it is unused.
@match_timer_function_unused_data@
expression _E;
identifier _timer;
identifier _callback;
@@
(
-setup_timer(&_E->_timer, _callback, 0);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E->_timer, _callback, 0L);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E->_timer, _callback, 0UL);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E._timer, _callback, 0);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_E._timer, _callback, 0L);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_E._timer, _callback, 0UL);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_timer, _callback, 0);
+timer_setup(&_timer, _callback, 0);
|
-setup_timer(&_timer, _callback, 0L);
+timer_setup(&_timer, _callback, 0);
|
-setup_timer(&_timer, _callback, 0UL);
+timer_setup(&_timer, _callback, 0);
|
-setup_timer(_timer, _callback, 0);
+timer_setup(_timer, _callback, 0);
|
-setup_timer(_timer, _callback, 0L);
+timer_setup(_timer, _callback, 0);
|
-setup_timer(_timer, _callback, 0UL);
+timer_setup(_timer, _callback, 0);
)
@change_callback_unused_data
depends on match_timer_function_unused_data@
identifier match_timer_function_unused_data._callback;
type _origtype;
identifier _origarg;
@@
void _callback(
-_origtype _origarg
+struct timer_list *unused
)
{
... when != _origarg
}
Signed-off-by: Kees Cook <keescook@chromium.org>
2017-10-17 00:43:17 +03:00
|
|
|
static void eql_timer(struct timer_list *t)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
treewide: setup_timer() -> timer_setup()
This converts all remaining cases of the old setup_timer() API into using
timer_setup(), where the callback argument is the structure already
holding the struct timer_list. These should have no behavioral changes,
since they just change which pointer is passed into the callback with
the same available pointers after conversion. It handles the following
examples, in addition to some other variations.
Casting from unsigned long:
void my_callback(unsigned long data)
{
struct something *ptr = (struct something *)data;
...
}
...
setup_timer(&ptr->my_timer, my_callback, ptr);
and forced object casts:
void my_callback(struct something *ptr)
{
...
}
...
setup_timer(&ptr->my_timer, my_callback, (unsigned long)ptr);
become:
void my_callback(struct timer_list *t)
{
struct something *ptr = from_timer(ptr, t, my_timer);
...
}
...
timer_setup(&ptr->my_timer, my_callback, 0);
Direct function assignments:
void my_callback(unsigned long data)
{
struct something *ptr = (struct something *)data;
...
}
...
ptr->my_timer.function = my_callback;
have a temporary cast added, along with converting the args:
void my_callback(struct timer_list *t)
{
struct something *ptr = from_timer(ptr, t, my_timer);
...
}
...
ptr->my_timer.function = (TIMER_FUNC_TYPE)my_callback;
And finally, callbacks without a data assignment:
void my_callback(unsigned long data)
{
...
}
...
setup_timer(&ptr->my_timer, my_callback, 0);
have their argument renamed to verify they're unused during conversion:
void my_callback(struct timer_list *unused)
{
...
}
...
timer_setup(&ptr->my_timer, my_callback, 0);
The conversion is done with the following Coccinelle script:
spatch --very-quiet --all-includes --include-headers \
-I ./arch/x86/include -I ./arch/x86/include/generated \
-I ./include -I ./arch/x86/include/uapi \
-I ./arch/x86/include/generated/uapi -I ./include/uapi \
-I ./include/generated/uapi --include ./include/linux/kconfig.h \
--dir . \
--cocci-file ~/src/data/timer_setup.cocci
@fix_address_of@
expression e;
@@
setup_timer(
-&(e)
+&e
, ...)
// Update any raw setup_timer() usages that have a NULL callback, but
// would otherwise match change_timer_function_usage, since the latter
// will update all function assignments done in the face of a NULL
// function initialization in setup_timer().
@change_timer_function_usage_NULL@
expression _E;
identifier _timer;
type _cast_data;
@@
(
-setup_timer(&_E->_timer, NULL, _E);
+timer_setup(&_E->_timer, NULL, 0);
|
-setup_timer(&_E->_timer, NULL, (_cast_data)_E);
+timer_setup(&_E->_timer, NULL, 0);
|
-setup_timer(&_E._timer, NULL, &_E);
+timer_setup(&_E._timer, NULL, 0);
|
-setup_timer(&_E._timer, NULL, (_cast_data)&_E);
+timer_setup(&_E._timer, NULL, 0);
)
@change_timer_function_usage@
expression _E;
identifier _timer;
struct timer_list _stl;
identifier _callback;
type _cast_func, _cast_data;
@@
(
-setup_timer(&_E->_timer, _callback, _E);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E->_timer, &_callback, _E);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E->_timer, _callback, (_cast_data)_E);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E->_timer, &_callback, (_cast_data)_E);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E->_timer, (_cast_func)_callback, _E);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E->_timer, (_cast_func)&_callback, _E);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E->_timer, (_cast_func)_callback, (_cast_data)_E);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E->_timer, (_cast_func)&_callback, (_cast_data)_E);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E._timer, _callback, (_cast_data)_E);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_E._timer, _callback, (_cast_data)&_E);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_E._timer, &_callback, (_cast_data)_E);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_E._timer, &_callback, (_cast_data)&_E);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_E._timer, (_cast_func)_callback, (_cast_data)_E);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_E._timer, (_cast_func)_callback, (_cast_data)&_E);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_E._timer, (_cast_func)&_callback, (_cast_data)_E);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_E._timer, (_cast_func)&_callback, (_cast_data)&_E);
+timer_setup(&_E._timer, _callback, 0);
|
_E->_timer@_stl.function = _callback;
|
_E->_timer@_stl.function = &_callback;
|
_E->_timer@_stl.function = (_cast_func)_callback;
|
_E->_timer@_stl.function = (_cast_func)&_callback;
|
_E._timer@_stl.function = _callback;
|
_E._timer@_stl.function = &_callback;
|
_E._timer@_stl.function = (_cast_func)_callback;
|
_E._timer@_stl.function = (_cast_func)&_callback;
)
// callback(unsigned long arg)
@change_callback_handle_cast
depends on change_timer_function_usage@
identifier change_timer_function_usage._callback;
identifier change_timer_function_usage._timer;
type _origtype;
identifier _origarg;
type _handletype;
identifier _handle;
@@
void _callback(
-_origtype _origarg
+struct timer_list *t
)
{
(
... when != _origarg
_handletype *_handle =
-(_handletype *)_origarg;
+from_timer(_handle, t, _timer);
... when != _origarg
|
... when != _origarg
_handletype *_handle =
-(void *)_origarg;
+from_timer(_handle, t, _timer);
... when != _origarg
|
... when != _origarg
_handletype *_handle;
... when != _handle
_handle =
-(_handletype *)_origarg;
+from_timer(_handle, t, _timer);
... when != _origarg
|
... when != _origarg
_handletype *_handle;
... when != _handle
_handle =
-(void *)_origarg;
+from_timer(_handle, t, _timer);
... when != _origarg
)
}
// callback(unsigned long arg) without existing variable
@change_callback_handle_cast_no_arg
depends on change_timer_function_usage &&
!change_callback_handle_cast@
identifier change_timer_function_usage._callback;
identifier change_timer_function_usage._timer;
type _origtype;
identifier _origarg;
type _handletype;
@@
void _callback(
-_origtype _origarg
+struct timer_list *t
)
{
+ _handletype *_origarg = from_timer(_origarg, t, _timer);
+
... when != _origarg
- (_handletype *)_origarg
+ _origarg
... when != _origarg
}
// Avoid already converted callbacks.
@match_callback_converted
depends on change_timer_function_usage &&
!change_callback_handle_cast &&
!change_callback_handle_cast_no_arg@
identifier change_timer_function_usage._callback;
identifier t;
@@
void _callback(struct timer_list *t)
{ ... }
// callback(struct something *handle)
@change_callback_handle_arg
depends on change_timer_function_usage &&
!match_callback_converted &&
!change_callback_handle_cast &&
!change_callback_handle_cast_no_arg@
identifier change_timer_function_usage._callback;
identifier change_timer_function_usage._timer;
type _handletype;
identifier _handle;
@@
void _callback(
-_handletype *_handle
+struct timer_list *t
)
{
+ _handletype *_handle = from_timer(_handle, t, _timer);
...
}
// If change_callback_handle_arg ran on an empty function, remove
// the added handler.
@unchange_callback_handle_arg
depends on change_timer_function_usage &&
change_callback_handle_arg@
identifier change_timer_function_usage._callback;
identifier change_timer_function_usage._timer;
type _handletype;
identifier _handle;
identifier t;
@@
void _callback(struct timer_list *t)
{
- _handletype *_handle = from_timer(_handle, t, _timer);
}
// We only want to refactor the setup_timer() data argument if we've found
// the matching callback. This undoes changes in change_timer_function_usage.
@unchange_timer_function_usage
depends on change_timer_function_usage &&
!change_callback_handle_cast &&
!change_callback_handle_cast_no_arg &&
!change_callback_handle_arg@
expression change_timer_function_usage._E;
identifier change_timer_function_usage._timer;
identifier change_timer_function_usage._callback;
type change_timer_function_usage._cast_data;
@@
(
-timer_setup(&_E->_timer, _callback, 0);
+setup_timer(&_E->_timer, _callback, (_cast_data)_E);
|
-timer_setup(&_E._timer, _callback, 0);
+setup_timer(&_E._timer, _callback, (_cast_data)&_E);
)
// If we fixed a callback from a .function assignment, fix the
// assignment cast now.
@change_timer_function_assignment
depends on change_timer_function_usage &&
(change_callback_handle_cast ||
change_callback_handle_cast_no_arg ||
change_callback_handle_arg)@
expression change_timer_function_usage._E;
identifier change_timer_function_usage._timer;
identifier change_timer_function_usage._callback;
type _cast_func;
typedef TIMER_FUNC_TYPE;
@@
(
_E->_timer.function =
-_callback
+(TIMER_FUNC_TYPE)_callback
;
|
_E->_timer.function =
-&_callback
+(TIMER_FUNC_TYPE)_callback
;
|
_E->_timer.function =
-(_cast_func)_callback;
+(TIMER_FUNC_TYPE)_callback
;
|
_E->_timer.function =
-(_cast_func)&_callback
+(TIMER_FUNC_TYPE)_callback
;
|
_E._timer.function =
-_callback
+(TIMER_FUNC_TYPE)_callback
;
|
_E._timer.function =
-&_callback;
+(TIMER_FUNC_TYPE)_callback
;
|
_E._timer.function =
-(_cast_func)_callback
+(TIMER_FUNC_TYPE)_callback
;
|
_E._timer.function =
-(_cast_func)&_callback
+(TIMER_FUNC_TYPE)_callback
;
)
// Sometimes timer functions are called directly. Replace matched args.
@change_timer_function_calls
depends on change_timer_function_usage &&
(change_callback_handle_cast ||
change_callback_handle_cast_no_arg ||
change_callback_handle_arg)@
expression _E;
identifier change_timer_function_usage._timer;
identifier change_timer_function_usage._callback;
type _cast_data;
@@
_callback(
(
-(_cast_data)_E
+&_E->_timer
|
-(_cast_data)&_E
+&_E._timer
|
-_E
+&_E->_timer
)
)
// If a timer has been configured without a data argument, it can be
// converted without regard to the callback argument, since it is unused.
@match_timer_function_unused_data@
expression _E;
identifier _timer;
identifier _callback;
@@
(
-setup_timer(&_E->_timer, _callback, 0);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E->_timer, _callback, 0L);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E->_timer, _callback, 0UL);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E._timer, _callback, 0);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_E._timer, _callback, 0L);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_E._timer, _callback, 0UL);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_timer, _callback, 0);
+timer_setup(&_timer, _callback, 0);
|
-setup_timer(&_timer, _callback, 0L);
+timer_setup(&_timer, _callback, 0);
|
-setup_timer(&_timer, _callback, 0UL);
+timer_setup(&_timer, _callback, 0);
|
-setup_timer(_timer, _callback, 0);
+timer_setup(_timer, _callback, 0);
|
-setup_timer(_timer, _callback, 0L);
+timer_setup(_timer, _callback, 0);
|
-setup_timer(_timer, _callback, 0UL);
+timer_setup(_timer, _callback, 0);
)
@change_callback_unused_data
depends on match_timer_function_unused_data@
identifier match_timer_function_unused_data._callback;
type _origtype;
identifier _origarg;
@@
void _callback(
-_origtype _origarg
+struct timer_list *unused
)
{
... when != _origarg
}
Signed-off-by: Kees Cook <keescook@chromium.org>
2017-10-17 00:43:17 +03:00
|
|
|
equalizer_t *eql = from_timer(eql, t, timer);
|
2005-04-17 02:20:36 +04:00
|
|
|
struct list_head *this, *tmp, *head;
|
2006-09-13 21:24:59 +04:00
|
|
|
|
2012-03-27 02:52:00 +04:00
|
|
|
spin_lock(&eql->queue.lock);
|
2005-04-17 02:20:36 +04:00
|
|
|
head = &eql->queue.all_slaves;
|
|
|
|
list_for_each_safe(this, tmp, head) {
|
|
|
|
slave_t *slave = list_entry(this, slave_t, list);
|
|
|
|
|
|
|
|
if ((slave->dev->flags & IFF_UP) == IFF_UP) {
|
|
|
|
slave->bytes_queued -= slave->priority_Bps;
|
|
|
|
if (slave->bytes_queued < 0)
|
|
|
|
slave->bytes_queued = 0;
|
|
|
|
} else {
|
2005-07-22 01:16:54 +04:00
|
|
|
eql_kill_one_slave(&eql->queue, slave);
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2012-03-27 02:52:00 +04:00
|
|
|
spin_unlock(&eql->queue.lock);
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
eql->timer.expires = jiffies + EQL_DEFAULT_RESCHED_IVAL;
|
|
|
|
add_timer(&eql->timer);
|
|
|
|
}
|
|
|
|
|
2009-03-20 10:14:14 +03:00
|
|
|
static const char version[] __initconst =
|
2011-03-04 00:30:20 +03:00
|
|
|
"Equalizer2002: Simon Janes (simon@ncm.com) and David S. Miller (davem@redhat.com)";
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2008-11-22 04:37:54 +03:00
|
|
|
static const struct net_device_ops eql_netdev_ops = {
|
|
|
|
.ndo_open = eql_open,
|
|
|
|
.ndo_stop = eql_close,
|
|
|
|
.ndo_do_ioctl = eql_ioctl,
|
|
|
|
.ndo_start_xmit = eql_slave_xmit,
|
|
|
|
};
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
static void __init eql_setup(struct net_device *dev)
|
|
|
|
{
|
|
|
|
equalizer_t *eql = netdev_priv(dev);
|
|
|
|
|
treewide: setup_timer() -> timer_setup()
This converts all remaining cases of the old setup_timer() API into using
timer_setup(), where the callback argument is the structure already
holding the struct timer_list. These should have no behavioral changes,
since they just change which pointer is passed into the callback with
the same available pointers after conversion. It handles the following
examples, in addition to some other variations.
Casting from unsigned long:
void my_callback(unsigned long data)
{
struct something *ptr = (struct something *)data;
...
}
...
setup_timer(&ptr->my_timer, my_callback, ptr);
and forced object casts:
void my_callback(struct something *ptr)
{
...
}
...
setup_timer(&ptr->my_timer, my_callback, (unsigned long)ptr);
become:
void my_callback(struct timer_list *t)
{
struct something *ptr = from_timer(ptr, t, my_timer);
...
}
...
timer_setup(&ptr->my_timer, my_callback, 0);
Direct function assignments:
void my_callback(unsigned long data)
{
struct something *ptr = (struct something *)data;
...
}
...
ptr->my_timer.function = my_callback;
have a temporary cast added, along with converting the args:
void my_callback(struct timer_list *t)
{
struct something *ptr = from_timer(ptr, t, my_timer);
...
}
...
ptr->my_timer.function = (TIMER_FUNC_TYPE)my_callback;
And finally, callbacks without a data assignment:
void my_callback(unsigned long data)
{
...
}
...
setup_timer(&ptr->my_timer, my_callback, 0);
have their argument renamed to verify they're unused during conversion:
void my_callback(struct timer_list *unused)
{
...
}
...
timer_setup(&ptr->my_timer, my_callback, 0);
The conversion is done with the following Coccinelle script:
spatch --very-quiet --all-includes --include-headers \
-I ./arch/x86/include -I ./arch/x86/include/generated \
-I ./include -I ./arch/x86/include/uapi \
-I ./arch/x86/include/generated/uapi -I ./include/uapi \
-I ./include/generated/uapi --include ./include/linux/kconfig.h \
--dir . \
--cocci-file ~/src/data/timer_setup.cocci
@fix_address_of@
expression e;
@@
setup_timer(
-&(e)
+&e
, ...)
// Update any raw setup_timer() usages that have a NULL callback, but
// would otherwise match change_timer_function_usage, since the latter
// will update all function assignments done in the face of a NULL
// function initialization in setup_timer().
@change_timer_function_usage_NULL@
expression _E;
identifier _timer;
type _cast_data;
@@
(
-setup_timer(&_E->_timer, NULL, _E);
+timer_setup(&_E->_timer, NULL, 0);
|
-setup_timer(&_E->_timer, NULL, (_cast_data)_E);
+timer_setup(&_E->_timer, NULL, 0);
|
-setup_timer(&_E._timer, NULL, &_E);
+timer_setup(&_E._timer, NULL, 0);
|
-setup_timer(&_E._timer, NULL, (_cast_data)&_E);
+timer_setup(&_E._timer, NULL, 0);
)
@change_timer_function_usage@
expression _E;
identifier _timer;
struct timer_list _stl;
identifier _callback;
type _cast_func, _cast_data;
@@
(
-setup_timer(&_E->_timer, _callback, _E);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E->_timer, &_callback, _E);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E->_timer, _callback, (_cast_data)_E);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E->_timer, &_callback, (_cast_data)_E);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E->_timer, (_cast_func)_callback, _E);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E->_timer, (_cast_func)&_callback, _E);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E->_timer, (_cast_func)_callback, (_cast_data)_E);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E->_timer, (_cast_func)&_callback, (_cast_data)_E);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E._timer, _callback, (_cast_data)_E);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_E._timer, _callback, (_cast_data)&_E);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_E._timer, &_callback, (_cast_data)_E);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_E._timer, &_callback, (_cast_data)&_E);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_E._timer, (_cast_func)_callback, (_cast_data)_E);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_E._timer, (_cast_func)_callback, (_cast_data)&_E);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_E._timer, (_cast_func)&_callback, (_cast_data)_E);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_E._timer, (_cast_func)&_callback, (_cast_data)&_E);
+timer_setup(&_E._timer, _callback, 0);
|
_E->_timer@_stl.function = _callback;
|
_E->_timer@_stl.function = &_callback;
|
_E->_timer@_stl.function = (_cast_func)_callback;
|
_E->_timer@_stl.function = (_cast_func)&_callback;
|
_E._timer@_stl.function = _callback;
|
_E._timer@_stl.function = &_callback;
|
_E._timer@_stl.function = (_cast_func)_callback;
|
_E._timer@_stl.function = (_cast_func)&_callback;
)
// callback(unsigned long arg)
@change_callback_handle_cast
depends on change_timer_function_usage@
identifier change_timer_function_usage._callback;
identifier change_timer_function_usage._timer;
type _origtype;
identifier _origarg;
type _handletype;
identifier _handle;
@@
void _callback(
-_origtype _origarg
+struct timer_list *t
)
{
(
... when != _origarg
_handletype *_handle =
-(_handletype *)_origarg;
+from_timer(_handle, t, _timer);
... when != _origarg
|
... when != _origarg
_handletype *_handle =
-(void *)_origarg;
+from_timer(_handle, t, _timer);
... when != _origarg
|
... when != _origarg
_handletype *_handle;
... when != _handle
_handle =
-(_handletype *)_origarg;
+from_timer(_handle, t, _timer);
... when != _origarg
|
... when != _origarg
_handletype *_handle;
... when != _handle
_handle =
-(void *)_origarg;
+from_timer(_handle, t, _timer);
... when != _origarg
)
}
// callback(unsigned long arg) without existing variable
@change_callback_handle_cast_no_arg
depends on change_timer_function_usage &&
!change_callback_handle_cast@
identifier change_timer_function_usage._callback;
identifier change_timer_function_usage._timer;
type _origtype;
identifier _origarg;
type _handletype;
@@
void _callback(
-_origtype _origarg
+struct timer_list *t
)
{
+ _handletype *_origarg = from_timer(_origarg, t, _timer);
+
... when != _origarg
- (_handletype *)_origarg
+ _origarg
... when != _origarg
}
// Avoid already converted callbacks.
@match_callback_converted
depends on change_timer_function_usage &&
!change_callback_handle_cast &&
!change_callback_handle_cast_no_arg@
identifier change_timer_function_usage._callback;
identifier t;
@@
void _callback(struct timer_list *t)
{ ... }
// callback(struct something *handle)
@change_callback_handle_arg
depends on change_timer_function_usage &&
!match_callback_converted &&
!change_callback_handle_cast &&
!change_callback_handle_cast_no_arg@
identifier change_timer_function_usage._callback;
identifier change_timer_function_usage._timer;
type _handletype;
identifier _handle;
@@
void _callback(
-_handletype *_handle
+struct timer_list *t
)
{
+ _handletype *_handle = from_timer(_handle, t, _timer);
...
}
// If change_callback_handle_arg ran on an empty function, remove
// the added handler.
@unchange_callback_handle_arg
depends on change_timer_function_usage &&
change_callback_handle_arg@
identifier change_timer_function_usage._callback;
identifier change_timer_function_usage._timer;
type _handletype;
identifier _handle;
identifier t;
@@
void _callback(struct timer_list *t)
{
- _handletype *_handle = from_timer(_handle, t, _timer);
}
// We only want to refactor the setup_timer() data argument if we've found
// the matching callback. This undoes changes in change_timer_function_usage.
@unchange_timer_function_usage
depends on change_timer_function_usage &&
!change_callback_handle_cast &&
!change_callback_handle_cast_no_arg &&
!change_callback_handle_arg@
expression change_timer_function_usage._E;
identifier change_timer_function_usage._timer;
identifier change_timer_function_usage._callback;
type change_timer_function_usage._cast_data;
@@
(
-timer_setup(&_E->_timer, _callback, 0);
+setup_timer(&_E->_timer, _callback, (_cast_data)_E);
|
-timer_setup(&_E._timer, _callback, 0);
+setup_timer(&_E._timer, _callback, (_cast_data)&_E);
)
// If we fixed a callback from a .function assignment, fix the
// assignment cast now.
@change_timer_function_assignment
depends on change_timer_function_usage &&
(change_callback_handle_cast ||
change_callback_handle_cast_no_arg ||
change_callback_handle_arg)@
expression change_timer_function_usage._E;
identifier change_timer_function_usage._timer;
identifier change_timer_function_usage._callback;
type _cast_func;
typedef TIMER_FUNC_TYPE;
@@
(
_E->_timer.function =
-_callback
+(TIMER_FUNC_TYPE)_callback
;
|
_E->_timer.function =
-&_callback
+(TIMER_FUNC_TYPE)_callback
;
|
_E->_timer.function =
-(_cast_func)_callback;
+(TIMER_FUNC_TYPE)_callback
;
|
_E->_timer.function =
-(_cast_func)&_callback
+(TIMER_FUNC_TYPE)_callback
;
|
_E._timer.function =
-_callback
+(TIMER_FUNC_TYPE)_callback
;
|
_E._timer.function =
-&_callback;
+(TIMER_FUNC_TYPE)_callback
;
|
_E._timer.function =
-(_cast_func)_callback
+(TIMER_FUNC_TYPE)_callback
;
|
_E._timer.function =
-(_cast_func)&_callback
+(TIMER_FUNC_TYPE)_callback
;
)
// Sometimes timer functions are called directly. Replace matched args.
@change_timer_function_calls
depends on change_timer_function_usage &&
(change_callback_handle_cast ||
change_callback_handle_cast_no_arg ||
change_callback_handle_arg)@
expression _E;
identifier change_timer_function_usage._timer;
identifier change_timer_function_usage._callback;
type _cast_data;
@@
_callback(
(
-(_cast_data)_E
+&_E->_timer
|
-(_cast_data)&_E
+&_E._timer
|
-_E
+&_E->_timer
)
)
// If a timer has been configured without a data argument, it can be
// converted without regard to the callback argument, since it is unused.
@match_timer_function_unused_data@
expression _E;
identifier _timer;
identifier _callback;
@@
(
-setup_timer(&_E->_timer, _callback, 0);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E->_timer, _callback, 0L);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E->_timer, _callback, 0UL);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E._timer, _callback, 0);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_E._timer, _callback, 0L);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_E._timer, _callback, 0UL);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_timer, _callback, 0);
+timer_setup(&_timer, _callback, 0);
|
-setup_timer(&_timer, _callback, 0L);
+timer_setup(&_timer, _callback, 0);
|
-setup_timer(&_timer, _callback, 0UL);
+timer_setup(&_timer, _callback, 0);
|
-setup_timer(_timer, _callback, 0);
+timer_setup(_timer, _callback, 0);
|
-setup_timer(_timer, _callback, 0L);
+timer_setup(_timer, _callback, 0);
|
-setup_timer(_timer, _callback, 0UL);
+timer_setup(_timer, _callback, 0);
)
@change_callback_unused_data
depends on match_timer_function_unused_data@
identifier match_timer_function_unused_data._callback;
type _origtype;
identifier _origarg;
@@
void _callback(
-_origtype _origarg
+struct timer_list *unused
)
{
... when != _origarg
}
Signed-off-by: Kees Cook <keescook@chromium.org>
2017-10-17 00:43:17 +03:00
|
|
|
timer_setup(&eql->timer, eql_timer, 0);
|
2005-04-17 02:20:36 +04:00
|
|
|
eql->timer.expires = jiffies + EQL_DEFAULT_RESCHED_IVAL;
|
|
|
|
|
|
|
|
spin_lock_init(&eql->queue.lock);
|
|
|
|
INIT_LIST_HEAD(&eql->queue.all_slaves);
|
|
|
|
eql->queue.master_dev = dev;
|
|
|
|
|
2008-11-22 04:37:54 +03:00
|
|
|
dev->netdev_ops = &eql_netdev_ops;
|
2006-09-13 21:24:59 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
/*
|
|
|
|
* Now we undo some of the things that eth_setup does
|
2006-09-13 21:24:59 +04:00
|
|
|
* that we don't like
|
2005-04-17 02:20:36 +04:00
|
|
|
*/
|
2006-09-13 21:24:59 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
dev->mtu = EQL_DEFAULT_MTU; /* set to 576 in if_eql.h */
|
|
|
|
dev->flags = IFF_MASTER;
|
|
|
|
|
|
|
|
dev->type = ARPHRD_SLIP;
|
|
|
|
dev->tx_queue_len = 5; /* Hands them off fast */
|
2014-10-06 05:38:35 +04:00
|
|
|
netif_keep_dst(dev);
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static int eql_open(struct net_device *dev)
|
|
|
|
{
|
|
|
|
equalizer_t *eql = netdev_priv(dev);
|
|
|
|
|
|
|
|
/* XXX We should force this off automatically for the user. */
|
2011-03-04 00:30:20 +03:00
|
|
|
netdev_info(dev,
|
|
|
|
"remember to turn off Van-Jacobson compression on your slave devices\n");
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2006-04-02 15:52:48 +04:00
|
|
|
BUG_ON(!list_empty(&eql->queue.all_slaves));
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
eql->min_slaves = 1;
|
|
|
|
eql->max_slaves = EQL_DEFAULT_MAX_SLAVES; /* 4 usually... */
|
|
|
|
|
|
|
|
add_timer(&eql->timer);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-07-22 01:16:54 +04:00
|
|
|
static void eql_kill_one_slave(slave_queue_t *queue, slave_t *slave)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
list_del(&slave->list);
|
2005-07-22 01:16:54 +04:00
|
|
|
queue->num_slaves--;
|
2005-04-17 02:20:36 +04:00
|
|
|
slave->dev->flags &= ~IFF_SLAVE;
|
|
|
|
dev_put(slave->dev);
|
|
|
|
kfree(slave);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void eql_kill_slave_queue(slave_queue_t *queue)
|
2006-09-13 21:24:59 +04:00
|
|
|
{
|
2005-04-17 02:20:36 +04:00
|
|
|
struct list_head *head, *tmp, *this;
|
|
|
|
|
|
|
|
spin_lock_bh(&queue->lock);
|
|
|
|
|
|
|
|
head = &queue->all_slaves;
|
|
|
|
list_for_each_safe(this, tmp, head) {
|
|
|
|
slave_t *s = list_entry(this, slave_t, list);
|
|
|
|
|
2005-07-22 01:16:54 +04:00
|
|
|
eql_kill_one_slave(queue, s);
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
spin_unlock_bh(&queue->lock);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int eql_close(struct net_device *dev)
|
|
|
|
{
|
|
|
|
equalizer_t *eql = netdev_priv(dev);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The timer has to be stopped first before we start hacking away
|
2006-09-13 21:24:59 +04:00
|
|
|
* at the data structure it scans every so often...
|
2005-04-17 02:20:36 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
del_timer_sync(&eql->timer);
|
|
|
|
|
|
|
|
eql_kill_slave_queue(&eql->queue);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int eql_enslave(struct net_device *dev, slaving_request_t __user *srq);
|
|
|
|
static int eql_emancipate(struct net_device *dev, slaving_request_t __user *srq);
|
|
|
|
|
|
|
|
static int eql_g_slave_cfg(struct net_device *dev, slave_config_t __user *sc);
|
|
|
|
static int eql_s_slave_cfg(struct net_device *dev, slave_config_t __user *sc);
|
|
|
|
|
|
|
|
static int eql_g_master_cfg(struct net_device *dev, master_config_t __user *mc);
|
|
|
|
static int eql_s_master_cfg(struct net_device *dev, master_config_t __user *mc);
|
|
|
|
|
|
|
|
static int eql_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
|
2006-09-13 21:24:59 +04:00
|
|
|
{
|
2005-04-17 02:20:36 +04:00
|
|
|
if (cmd != EQL_GETMASTRCFG && cmd != EQL_GETSLAVECFG &&
|
|
|
|
!capable(CAP_NET_ADMIN))
|
|
|
|
return -EPERM;
|
|
|
|
|
|
|
|
switch (cmd) {
|
|
|
|
case EQL_ENSLAVE:
|
|
|
|
return eql_enslave(dev, ifr->ifr_data);
|
|
|
|
case EQL_EMANCIPATE:
|
|
|
|
return eql_emancipate(dev, ifr->ifr_data);
|
|
|
|
case EQL_GETSLAVECFG:
|
|
|
|
return eql_g_slave_cfg(dev, ifr->ifr_data);
|
|
|
|
case EQL_SETSLAVECFG:
|
|
|
|
return eql_s_slave_cfg(dev, ifr->ifr_data);
|
|
|
|
case EQL_GETMASTRCFG:
|
|
|
|
return eql_g_master_cfg(dev, ifr->ifr_data);
|
|
|
|
case EQL_SETMASTRCFG:
|
|
|
|
return eql_s_master_cfg(dev, ifr->ifr_data);
|
|
|
|
default:
|
|
|
|
return -EOPNOTSUPP;
|
2010-05-18 09:47:34 +04:00
|
|
|
}
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* queue->lock must be held */
|
|
|
|
static slave_t *__eql_schedule_slaves(slave_queue_t *queue)
|
|
|
|
{
|
|
|
|
unsigned long best_load = ~0UL;
|
|
|
|
struct list_head *this, *tmp, *head;
|
|
|
|
slave_t *best_slave;
|
|
|
|
|
|
|
|
best_slave = NULL;
|
|
|
|
|
|
|
|
/* Make a pass to set the best slave. */
|
|
|
|
head = &queue->all_slaves;
|
|
|
|
list_for_each_safe(this, tmp, head) {
|
|
|
|
slave_t *slave = list_entry(this, slave_t, list);
|
2006-09-13 21:24:59 +04:00
|
|
|
unsigned long slave_load, bytes_queued, priority_Bps;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
/* Go through the slave list once, updating best_slave
|
|
|
|
* whenever a new best_load is found.
|
|
|
|
*/
|
|
|
|
bytes_queued = slave->bytes_queued;
|
2006-09-13 21:24:59 +04:00
|
|
|
priority_Bps = slave->priority_Bps;
|
2005-04-17 02:20:36 +04:00
|
|
|
if ((slave->dev->flags & IFF_UP) == IFF_UP) {
|
2006-09-13 21:24:59 +04:00
|
|
|
slave_load = (~0UL - (~0UL / 2)) -
|
2005-04-17 02:20:36 +04:00
|
|
|
(priority_Bps) + bytes_queued * 8;
|
|
|
|
|
|
|
|
if (slave_load < best_load) {
|
|
|
|
best_load = slave_load;
|
|
|
|
best_slave = slave;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* We found a dead slave, kill it. */
|
2005-07-22 01:16:54 +04:00
|
|
|
eql_kill_one_slave(queue, slave);
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return best_slave;
|
|
|
|
}
|
|
|
|
|
2009-08-31 23:50:51 +04:00
|
|
|
static netdev_tx_t eql_slave_xmit(struct sk_buff *skb, struct net_device *dev)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
equalizer_t *eql = netdev_priv(dev);
|
|
|
|
slave_t *slave;
|
|
|
|
|
|
|
|
spin_lock(&eql->queue.lock);
|
|
|
|
|
|
|
|
slave = __eql_schedule_slaves(&eql->queue);
|
|
|
|
if (slave) {
|
|
|
|
struct net_device *slave_dev = slave->dev;
|
|
|
|
|
|
|
|
skb->dev = slave_dev;
|
2012-03-27 02:52:00 +04:00
|
|
|
skb->priority = TC_PRIO_FILLER;
|
2006-09-13 21:24:59 +04:00
|
|
|
slave->bytes_queued += skb->len;
|
2005-04-17 02:20:36 +04:00
|
|
|
dev_queue_xmit(skb);
|
2007-10-04 04:41:50 +04:00
|
|
|
dev->stats.tx_packets++;
|
2005-04-17 02:20:36 +04:00
|
|
|
} else {
|
2007-10-04 04:41:50 +04:00
|
|
|
dev->stats.tx_dropped++;
|
2005-04-17 02:20:36 +04:00
|
|
|
dev_kfree_skb(skb);
|
2006-09-13 21:24:59 +04:00
|
|
|
}
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
spin_unlock(&eql->queue.lock);
|
|
|
|
|
2009-06-23 10:03:08 +04:00
|
|
|
return NETDEV_TX_OK;
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Private ioctl functions
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* queue->lock must be held */
|
|
|
|
static slave_t *__eql_find_slave_dev(slave_queue_t *queue, struct net_device *dev)
|
|
|
|
{
|
|
|
|
struct list_head *this, *head;
|
|
|
|
|
|
|
|
head = &queue->all_slaves;
|
|
|
|
list_for_each(this, head) {
|
|
|
|
slave_t *slave = list_entry(this, slave_t, list);
|
|
|
|
|
|
|
|
if (slave->dev == dev)
|
|
|
|
return slave;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int eql_is_full(slave_queue_t *queue)
|
|
|
|
{
|
|
|
|
equalizer_t *eql = netdev_priv(queue->master_dev);
|
|
|
|
|
|
|
|
if (queue->num_slaves >= eql->max_slaves)
|
|
|
|
return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* queue->lock must be held */
|
|
|
|
static int __eql_insert_slave(slave_queue_t *queue, slave_t *slave)
|
|
|
|
{
|
|
|
|
if (!eql_is_full(queue)) {
|
|
|
|
slave_t *duplicate_slave = NULL;
|
|
|
|
|
|
|
|
duplicate_slave = __eql_find_slave_dev(queue, slave->dev);
|
2007-08-25 09:37:49 +04:00
|
|
|
if (duplicate_slave)
|
2005-07-22 01:16:54 +04:00
|
|
|
eql_kill_one_slave(queue, duplicate_slave);
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2014-01-15 06:23:38 +04:00
|
|
|
dev_hold(slave->dev);
|
2005-04-17 02:20:36 +04:00
|
|
|
list_add(&slave->list, &queue->all_slaves);
|
|
|
|
queue->num_slaves++;
|
|
|
|
slave->dev->flags |= IFF_SLAVE;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return -ENOSPC;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int eql_enslave(struct net_device *master_dev, slaving_request_t __user *srqp)
|
|
|
|
{
|
|
|
|
struct net_device *slave_dev;
|
|
|
|
slaving_request_t srq;
|
|
|
|
|
|
|
|
if (copy_from_user(&srq, srqp, sizeof (slaving_request_t)))
|
|
|
|
return -EFAULT;
|
|
|
|
|
2014-01-15 06:23:38 +04:00
|
|
|
slave_dev = __dev_get_by_name(&init_net, srq.slave_name);
|
|
|
|
if (!slave_dev)
|
|
|
|
return -ENODEV;
|
|
|
|
|
|
|
|
if ((master_dev->flags & IFF_UP) == IFF_UP) {
|
|
|
|
/* slave is not a master & not already a slave: */
|
|
|
|
if (!eql_is_master(slave_dev) && !eql_is_slave(slave_dev)) {
|
|
|
|
slave_t *s = kmalloc(sizeof(*s), GFP_KERNEL);
|
|
|
|
equalizer_t *eql = netdev_priv(master_dev);
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (!s)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
memset(s, 0, sizeof(*s));
|
|
|
|
s->dev = slave_dev;
|
|
|
|
s->priority = srq.priority;
|
|
|
|
s->priority_bps = srq.priority;
|
|
|
|
s->priority_Bps = srq.priority / 8;
|
|
|
|
|
|
|
|
spin_lock_bh(&eql->queue.lock);
|
|
|
|
ret = __eql_insert_slave(&eql->queue, s);
|
|
|
|
if (ret)
|
|
|
|
kfree(s);
|
|
|
|
|
|
|
|
spin_unlock_bh(&eql->queue.lock);
|
|
|
|
|
|
|
|
return ret;
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int eql_emancipate(struct net_device *master_dev, slaving_request_t __user *srqp)
|
|
|
|
{
|
|
|
|
equalizer_t *eql = netdev_priv(master_dev);
|
|
|
|
struct net_device *slave_dev;
|
|
|
|
slaving_request_t srq;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (copy_from_user(&srq, srqp, sizeof (slaving_request_t)))
|
|
|
|
return -EFAULT;
|
|
|
|
|
2014-01-15 06:23:38 +04:00
|
|
|
slave_dev = __dev_get_by_name(&init_net, srq.slave_name);
|
|
|
|
if (!slave_dev)
|
|
|
|
return -ENODEV;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2014-01-15 06:23:38 +04:00
|
|
|
ret = -EINVAL;
|
|
|
|
spin_lock_bh(&eql->queue.lock);
|
|
|
|
if (eql_is_slave(slave_dev)) {
|
|
|
|
slave_t *slave = __eql_find_slave_dev(&eql->queue, slave_dev);
|
|
|
|
if (slave) {
|
|
|
|
eql_kill_one_slave(&eql->queue, slave);
|
|
|
|
ret = 0;
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
}
|
2014-01-15 06:23:38 +04:00
|
|
|
spin_unlock_bh(&eql->queue.lock);
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int eql_g_slave_cfg(struct net_device *dev, slave_config_t __user *scp)
|
|
|
|
{
|
|
|
|
equalizer_t *eql = netdev_priv(dev);
|
|
|
|
slave_t *slave;
|
|
|
|
struct net_device *slave_dev;
|
|
|
|
slave_config_t sc;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (copy_from_user(&sc, scp, sizeof (slave_config_t)))
|
|
|
|
return -EFAULT;
|
|
|
|
|
2014-01-15 06:23:38 +04:00
|
|
|
slave_dev = __dev_get_by_name(&init_net, sc.slave_name);
|
2005-04-17 02:20:36 +04:00
|
|
|
if (!slave_dev)
|
|
|
|
return -ENODEV;
|
|
|
|
|
|
|
|
ret = -EINVAL;
|
|
|
|
|
|
|
|
spin_lock_bh(&eql->queue.lock);
|
|
|
|
if (eql_is_slave(slave_dev)) {
|
|
|
|
slave = __eql_find_slave_dev(&eql->queue, slave_dev);
|
|
|
|
if (slave) {
|
|
|
|
sc.priority = slave->priority;
|
|
|
|
ret = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
spin_unlock_bh(&eql->queue.lock);
|
|
|
|
|
|
|
|
if (!ret && copy_to_user(scp, &sc, sizeof (slave_config_t)))
|
|
|
|
ret = -EFAULT;
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int eql_s_slave_cfg(struct net_device *dev, slave_config_t __user *scp)
|
|
|
|
{
|
|
|
|
slave_t *slave;
|
|
|
|
equalizer_t *eql;
|
|
|
|
struct net_device *slave_dev;
|
|
|
|
slave_config_t sc;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (copy_from_user(&sc, scp, sizeof (slave_config_t)))
|
|
|
|
return -EFAULT;
|
|
|
|
|
2014-01-15 06:23:38 +04:00
|
|
|
slave_dev = __dev_get_by_name(&init_net, sc.slave_name);
|
2005-04-17 02:20:36 +04:00
|
|
|
if (!slave_dev)
|
|
|
|
return -ENODEV;
|
|
|
|
|
|
|
|
ret = -EINVAL;
|
|
|
|
|
|
|
|
eql = netdev_priv(dev);
|
|
|
|
spin_lock_bh(&eql->queue.lock);
|
|
|
|
if (eql_is_slave(slave_dev)) {
|
|
|
|
slave = __eql_find_slave_dev(&eql->queue, slave_dev);
|
|
|
|
if (slave) {
|
|
|
|
slave->priority = sc.priority;
|
|
|
|
slave->priority_bps = sc.priority;
|
|
|
|
slave->priority_Bps = sc.priority / 8;
|
|
|
|
ret = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
spin_unlock_bh(&eql->queue.lock);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int eql_g_master_cfg(struct net_device *dev, master_config_t __user *mcp)
|
|
|
|
{
|
|
|
|
equalizer_t *eql;
|
|
|
|
master_config_t mc;
|
|
|
|
|
2010-09-15 15:43:04 +04:00
|
|
|
memset(&mc, 0, sizeof(master_config_t));
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
if (eql_is_master(dev)) {
|
|
|
|
eql = netdev_priv(dev);
|
|
|
|
mc.max_slaves = eql->max_slaves;
|
|
|
|
mc.min_slaves = eql->min_slaves;
|
|
|
|
if (copy_to_user(mcp, &mc, sizeof (master_config_t)))
|
|
|
|
return -EFAULT;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int eql_s_master_cfg(struct net_device *dev, master_config_t __user *mcp)
|
|
|
|
{
|
|
|
|
equalizer_t *eql;
|
|
|
|
master_config_t mc;
|
|
|
|
|
|
|
|
if (copy_from_user(&mc, mcp, sizeof (master_config_t)))
|
|
|
|
return -EFAULT;
|
|
|
|
|
|
|
|
if (eql_is_master(dev)) {
|
|
|
|
eql = netdev_priv(dev);
|
|
|
|
eql->max_slaves = mc.max_slaves;
|
|
|
|
eql->min_slaves = mc.min_slaves;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct net_device *dev_eql;
|
|
|
|
|
|
|
|
static int __init eql_init_module(void)
|
|
|
|
{
|
|
|
|
int err;
|
|
|
|
|
2011-03-04 00:30:20 +03:00
|
|
|
pr_info("%s\n", version);
|
2005-04-17 02:20:36 +04:00
|
|
|
|
net: set name_assign_type in alloc_netdev()
Extend alloc_netdev{,_mq{,s}}() to take name_assign_type as argument, and convert
all users to pass NET_NAME_UNKNOWN.
Coccinelle patch:
@@
expression sizeof_priv, name, setup, txqs, rxqs, count;
@@
(
-alloc_netdev_mqs(sizeof_priv, name, setup, txqs, rxqs)
+alloc_netdev_mqs(sizeof_priv, name, NET_NAME_UNKNOWN, setup, txqs, rxqs)
|
-alloc_netdev_mq(sizeof_priv, name, setup, count)
+alloc_netdev_mq(sizeof_priv, name, NET_NAME_UNKNOWN, setup, count)
|
-alloc_netdev(sizeof_priv, name, setup)
+alloc_netdev(sizeof_priv, name, NET_NAME_UNKNOWN, setup)
)
v9: move comments here from the wrong commit
Signed-off-by: Tom Gundersen <teg@jklm.no>
Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2014-07-14 18:37:24 +04:00
|
|
|
dev_eql = alloc_netdev(sizeof(equalizer_t), "eql", NET_NAME_UNKNOWN,
|
|
|
|
eql_setup);
|
2005-04-17 02:20:36 +04:00
|
|
|
if (!dev_eql)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
err = register_netdev(dev_eql);
|
2006-09-13 21:24:59 +04:00
|
|
|
if (err)
|
2005-04-17 02:20:36 +04:00
|
|
|
free_netdev(dev_eql);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __exit eql_cleanup_module(void)
|
|
|
|
{
|
|
|
|
unregister_netdev(dev_eql);
|
|
|
|
free_netdev(dev_eql);
|
|
|
|
}
|
|
|
|
|
|
|
|
module_init(eql_init_module);
|
|
|
|
module_exit(eql_cleanup_module);
|
|
|
|
MODULE_LICENSE("GPL");
|