Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
linux
Commits
2b65a560
Commit
2b65a560
authored
Jan 12, 2004
by
Andi Kleen
Committed by
Jeff Garzik
Jan 12, 2004
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[PATCH] variable number of dummy devices
Uses the new module_params that nobody else uses now.
parent
838f7f95
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
5 deletions
+37
-5
drivers/net/dummy.c
drivers/net/dummy.c
+37
-5
No files found.
drivers/net/dummy.c
View file @
2b65a560
...
...
@@ -33,6 +33,9 @@
#include <linux/kernel.h>
#include <linux/netdevice.h>
#include <linux/init.h>
#include <linux/moduleparam.h>
static
int
numdummies
=
1
;
static
int
dummy_xmit
(
struct
sk_buff
*
skb
,
struct
net_device
*
dev
);
static
struct
net_device_stats
*
dummy_get_stats
(
struct
net_device
*
dev
);
...
...
@@ -83,10 +86,14 @@ static struct net_device_stats *dummy_get_stats(struct net_device *dev)
return
dev
->
priv
;
}
static
struct
net_device
*
dev_dummy
;
static
struct
net_device
*
*
dummies
;
static
int
__init
dummy_init_module
(
void
)
/* Number of dummy devices to be set up by this module. */
module_param
(
numdummies
,
int
,
0
);
static
int
__init
dummy_init_one
(
int
index
)
{
struct
net_device
*
dev_dummy
;
int
err
;
dev_dummy
=
alloc_netdev
(
sizeof
(
struct
net_device_stats
),
...
...
@@ -98,15 +105,40 @@ static int __init dummy_init_module(void)
if
((
err
=
register_netdev
(
dev_dummy
)))
{
kfree
(
dev_dummy
);
dev_dummy
=
NULL
;
}
else
{
dummies
[
index
]
=
dev_dummy
;
}
return
err
;
}
static
void
__exit
dummy_free_one
(
int
index
)
{
unregister_netdev
(
dummies
[
index
]);
free_netdev
(
dummies
[
index
]);
}
static
int
__init
dummy_init_module
(
void
)
{
int
i
,
err
=
0
;
dummies
=
kmalloc
(
numdummies
*
sizeof
(
void
*
),
GFP_KERNEL
);
if
(
!
dummies
)
return
-
ENOMEM
;
for
(
i
=
0
;
i
<
numdummies
&&
!
err
;
i
++
)
err
=
dummy_init_one
(
i
);
if
(
err
)
{
while
(
--
i
>=
0
)
dummy_free_one
(
i
);
}
return
err
;
}
static
void
__exit
dummy_cleanup_module
(
void
)
{
unregister_netdev
(
dev_dummy
);
free_netdev
(
dev_dummy
);
dev_dummy
=
NULL
;
int
i
;
for
(
i
=
0
;
i
<
numdummies
;
i
++
)
dummy_free_one
(
i
);
kfree
(
dummies
);
}
module_init
(
dummy_init_module
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment