Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
I
iproute2
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
iproute2
Commits
4f2fdd44
Commit
4f2fdd44
authored
Apr 05, 2012
by
Stephen Hemminger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add ability to set link state with ip
Exposes existing netlink operations to modify link state of devices.
parent
ae5555d3
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
1 deletion
+27
-1
ip/ip_common.h
ip/ip_common.h
+1
-0
ip/ipaddress.c
ip/ipaddress.c
+10
-0
ip/iplink.c
ip/iplink.c
+9
-1
man/man8/ip-link.8
man/man8/ip-link.8
+7
-0
No files found.
ip/ip_common.h
View file @
4f2fdd44
extern
int
get_operstate
(
const
char
*
name
);
extern
int
print_linkinfo
(
const
struct
sockaddr_nl
*
who
,
struct
nlmsghdr
*
n
,
void
*
arg
);
...
...
ip/ipaddress.c
View file @
4f2fdd44
...
...
@@ -131,6 +131,16 @@ static void print_operstate(FILE *f, __u8 state)
fprintf
(
f
,
"state %s "
,
oper_states
[
state
]);
}
int
get_operstate
(
const
char
*
name
)
{
int
i
;
for
(
i
=
0
;
i
<
sizeof
(
oper_states
)
/
sizeof
(
oper_states
[
0
]);
i
++
)
if
(
strcasecmp
(
name
,
oper_states
[
i
])
==
0
)
return
i
;
return
-
1
;
}
static
void
print_queuelen
(
FILE
*
f
,
struct
rtattr
*
tb
[
IFLA_MAX
+
1
])
{
int
qlen
;
...
...
ip/iplink.c
View file @
4f2fdd44
...
...
@@ -437,6 +437,14 @@ int iplink_parse(int argc, char **argv, struct iplink_req *req,
if
(
mode
<
0
)
invarg
(
"Invalid link mode
\n
"
,
*
argv
);
addattr8
(
&
req
->
n
,
sizeof
(
*
req
),
IFLA_LINKMODE
,
mode
);
}
else
if
(
strcmp
(
*
argv
,
"state"
)
==
0
)
{
int
state
;
NEXT_ARG
();
state
=
get_operstate
(
*
argv
);
if
(
state
<
0
)
invarg
(
"Invalid operstate
\n
"
,
*
argv
);
addattr8
(
&
req
->
n
,
sizeof
(
*
req
),
IFLA_OPERSTATE
,
state
);
}
else
{
if
(
strcmp
(
*
argv
,
"dev"
)
==
0
)
{
NEXT_ARG
();
...
...
man/man8/ip-link.8
View file @
4f2fdd44
...
...
@@ -103,6 +103,9 @@ ip-link \- network device configuration
.B mode
.IR LINKMODE " |"
.br
.B state
.IR LINKSTATE " |"
.br
.B master
.IR DEVICE
.br
...
...
@@ -259,6 +262,10 @@ the device will transistion to when it is brought up. Setting
mode changes the behaviour so that device goes into DORMANT state instead
of UP when driver is ready.
.TP
.BI state " LINKSTATE"
allows setting the operational link state. The values (defined in RFC2863)
are: UP, DOWN, TESTING, UNKNOWN, DORMANT, NOTPRESENT, LOWERLAYERDOWN.
.TP
.BI alias " NAME"
give the device a symbolic name for easy reference.
...
...
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