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
0bef1c9c
Commit
0bef1c9c
authored
Jun 12, 2003
by
Stephen Hemminger
Committed by
David S. Miller
Jun 12, 2003
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[NET]: Dynamic allocation for dummy net device.
parent
068990ad
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
25 deletions
+16
-25
drivers/net/dummy.c
drivers/net/dummy.c
+16
-25
No files found.
drivers/net/dummy.c
View file @
0bef1c9c
...
...
@@ -51,15 +51,9 @@ static int dummy_accept_fastpath(struct net_device *dev, struct dst_entry *dst)
}
#endif
static
int
__init
dummy_init
(
struct
net_device
*
dev
)
static
void
__init
dummy_setup
(
struct
net_device
*
dev
)
{
/* Initialize the device structure. */
dev
->
priv
=
kmalloc
(
sizeof
(
struct
net_device_stats
),
GFP_KERNEL
);
if
(
dev
->
priv
==
NULL
)
return
-
ENOMEM
;
memset
(
dev
->
priv
,
0
,
sizeof
(
struct
net_device_stats
));
dev
->
get_stats
=
dummy_get_stats
;
dev
->
hard_start_xmit
=
dummy_xmit
;
dev
->
set_multicast_list
=
set_multicast_list
;
...
...
@@ -72,8 +66,7 @@ static int __init dummy_init(struct net_device *dev)
dev
->
tx_queue_len
=
0
;
dev
->
flags
|=
IFF_NOARP
;
dev
->
flags
&=
~
IFF_MULTICAST
;
return
0
;
SET_MODULE_OWNER
(
dev
);
}
static
int
dummy_xmit
(
struct
sk_buff
*
skb
,
struct
net_device
*
dev
)
...
...
@@ -92,32 +85,30 @@ 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
*
dev_dummy
;
static
int
__init
dummy_init_module
(
void
)
{
int
err
;
dev_dummy
.
init
=
dummy_init
;
SET_MODULE_OWNER
(
&
dev_dummy
);
dev_dummy
=
alloc_netdev
(
sizeof
(
struct
net_device_stats
),
"dummy%d"
,
dummy_setup
);
/* Find a name for this unit */
err
=
dev_alloc_name
(
&
dev_dummy
,
"dummy%d"
)
;
if
(
err
<
0
)
return
err
;
err
=
register_netdev
(
&
dev_dummy
);
if
(
err
<
0
)
return
err
;
return
0
;
if
(
!
dev_dummy
)
return
-
ENOMEM
;
if
((
err
=
register_netdev
(
dev_dummy
)))
{
kfree
(
dev_dummy
);
dev_dummy
=
NULL
;
}
return
err
;
}
static
void
__exit
dummy_cleanup_module
(
void
)
{
unregister_netdev
(
&
dev_dummy
);
kfree
(
dev_dummy
.
priv
);
memset
(
&
dev_dummy
,
0
,
sizeof
(
dev_dummy
));
dev_dummy
.
init
=
dummy_init
;
unregister_netdev
(
dev_dummy
);
kfree
(
dev_dummy
);
dev_dummy
=
NULL
;
}
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