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
cf814b9b
Commit
cf814b9b
authored
Feb 02, 2003
by
Andi Kleen
Committed by
Sridhar Samudrala
Feb 02, 2003
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[IPV4]: Better behavior for NETDEV_CHANGENAME requests.
parent
43acd266
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
8 deletions
+32
-8
net/ipv4/devinet.c
net/ipv4/devinet.c
+32
-8
No files found.
net/ipv4/devinet.c
View file @
cf814b9b
...
...
@@ -823,6 +823,34 @@ int unregister_inetaddr_notifier(struct notifier_block *nb)
return
notifier_chain_unregister
(
&
inetaddr_chain
,
nb
);
}
/* Rename ifa_labels for a device name change. Make some effort to preserve existing
* alias numbering and to create unique labels if possible.
*/
static
void
inetdev_changename
(
struct
net_device
*
dev
,
struct
in_device
*
in_dev
)
{
struct
in_ifaddr
*
ifa
;
int
named
=
0
;
for
(
ifa
=
in_dev
->
ifa_list
;
ifa
;
ifa
=
ifa
->
ifa_next
)
{
char
old
[
IFNAMSIZ
],
*
dot
;
memcpy
(
old
,
ifa
->
ifa_label
,
IFNAMSIZ
);
memcpy
(
ifa
->
ifa_label
,
dev
->
name
,
IFNAMSIZ
);
if
(
named
++
==
0
)
continue
;
dot
=
strchr
(
ifa
->
ifa_label
,
':'
);
if
(
dot
==
NULL
)
{
sprintf
(
old
,
":%d"
,
named
);
dot
=
old
;
}
if
(
strlen
(
dot
)
+
strlen
(
dev
->
name
)
<
IFNAMSIZ
)
{
strcat
(
ifa
->
ifa_label
,
dot
);
}
else
{
strcpy
(
ifa
->
ifa_label
+
(
IFNAMSIZ
-
strlen
(
dot
)
-
1
),
dot
);
}
}
}
/* Called only under RTNL semaphore */
static
int
inetdev_event
(
struct
notifier_block
*
this
,
unsigned
long
event
,
...
...
@@ -873,14 +901,10 @@ static int inetdev_event(struct notifier_block *this, unsigned long event,
inetdev_destroy
(
in_dev
);
break
;
case
NETDEV_CHANGENAME
:
if
(
in_dev
->
ifa_list
)
{
struct
in_ifaddr
*
ifa
;
for
(
ifa
=
in_dev
->
ifa_list
;
ifa
;
ifa
=
ifa
->
ifa_next
)
memcpy
(
ifa
->
ifa_label
,
dev
->
name
,
IFNAMSIZ
);
/* Do not notify about label change, this event is
not interesting to applications using netlink.
*/
}
/* Do not notify about label change, this event is
* not interesting to applications using netlink.
*/
inetdev_changename
(
dev
,
in_dev
);
break
;
}
out:
...
...
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