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
730d3f61
Commit
730d3f61
authored
Jan 23, 2014
by
Jiri Pirko
Committed by
Stephen Hemminger
Feb 17, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
iplink: add support for bonding slave
Signed-off-by:
Jiri Pirko
<
jiri@resnulli.us
>
parent
fbea6115
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
91 additions
and
1 deletion
+91
-1
ip/Makefile
ip/Makefile
+1
-1
ip/iplink_bond_slave.c
ip/iplink_bond_slave.c
+90
-0
No files found.
ip/Makefile
View file @
730d3f61
...
...
@@ -5,7 +5,7 @@ IPOBJ=ip.o ipaddress.o ipaddrlabel.o iproute.o iprule.o ipnetns.o \
iplink_vlan.o link_veth.o link_gre.o iplink_can.o
\
iplink_macvlan.o iplink_macvtap.o ipl2tp.o link_vti.o
\
iplink_vxlan.o tcp_metrics.o iplink_ipoib.o ipnetconf.o link_ip6tnl.o
\
link_iptnl.o link_gre6.o iplink_bond.o iplink_hsr.o
link_iptnl.o link_gre6.o iplink_bond.o iplink_
bond_slave.o iplink_
hsr.o
RTMONOBJ
=
rtmon.o
...
...
ip/iplink_bond_slave.c
0 → 100644
View file @
730d3f61
/*
* iplink_bond_slave.c Bonding slave device support
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
* Authors: Jiri Pirko <jiri@resnulli.us>
*/
#include <stdio.h>
#include <sys/socket.h>
#include <linux/if_bonding.h>
#include "rt_names.h"
#include "utils.h"
#include "ip_common.h"
static
const
char
*
slave_states
[]
=
{
[
BOND_STATE_ACTIVE
]
=
"ACTIVE"
,
[
BOND_STATE_BACKUP
]
=
"BACKUP"
,
};
static
void
print_slave_state
(
FILE
*
f
,
struct
rtattr
*
tb
)
{
unsigned
int
state
=
rta_getattr_u8
(
tb
);
if
(
state
>=
sizeof
(
slave_states
)
/
sizeof
(
slave_states
[
0
]))
fprintf
(
f
,
"state %d "
,
state
);
else
fprintf
(
f
,
"state %s "
,
slave_states
[
state
]);
}
static
const
char
*
slave_mii_status
[]
=
{
[
BOND_LINK_UP
]
=
"UP"
,
[
BOND_LINK_FAIL
]
=
"GOING_DOWN"
,
[
BOND_LINK_DOWN
]
=
"DOWN"
,
[
BOND_LINK_BACK
]
=
"GOING_BACK"
,
};
static
void
print_slave_mii_status
(
FILE
*
f
,
struct
rtattr
*
tb
)
{
unsigned
int
status
=
rta_getattr_u8
(
tb
);
fprintf
(
f
,
"mii_status %d "
,
status
);
if
(
status
>=
sizeof
(
slave_mii_status
)
/
sizeof
(
slave_mii_status
[
0
]))
fprintf
(
f
,
"mii_status %d "
,
status
);
else
fprintf
(
f
,
"mii_status %s "
,
slave_mii_status
[
status
]);
}
static
void
bond_slave_print_opt
(
struct
link_util
*
lu
,
FILE
*
f
,
struct
rtattr
*
tb
[])
{
SPRINT_BUF
(
b1
);
if
(
!
tb
)
return
;
if
(
tb
[
IFLA_BOND_SLAVE_STATE
])
print_slave_state
(
f
,
tb
[
IFLA_BOND_SLAVE_STATE
]);
if
(
tb
[
IFLA_BOND_SLAVE_MII_STATUS
])
print_slave_mii_status
(
f
,
tb
[
IFLA_BOND_SLAVE_MII_STATUS
]);
if
(
tb
[
IFLA_BOND_SLAVE_LINK_FAILURE_COUNT
])
fprintf
(
f
,
"link_failure_count %d "
,
rta_getattr_u32
(
tb
[
IFLA_BOND_SLAVE_LINK_FAILURE_COUNT
]));
if
(
tb
[
IFLA_BOND_SLAVE_PERM_HWADDR
])
fprintf
(
f
,
"perm_hwaddr %s "
,
ll_addr_n2a
(
RTA_DATA
(
tb
[
IFLA_BOND_SLAVE_PERM_HWADDR
]),
RTA_PAYLOAD
(
tb
[
IFLA_BOND_SLAVE_PERM_HWADDR
]),
0
,
b1
,
sizeof
(
b1
)));
if
(
tb
[
IFLA_BOND_SLAVE_QUEUE_ID
])
fprintf
(
f
,
"queue_id %d "
,
rta_getattr_u16
(
tb
[
IFLA_BOND_SLAVE_QUEUE_ID
]));
if
(
tb
[
IFLA_BOND_SLAVE_AD_AGGREGATOR_ID
])
fprintf
(
f
,
"ad_aggregator_id %d "
,
rta_getattr_u16
(
tb
[
IFLA_BOND_SLAVE_AD_AGGREGATOR_ID
]));
}
struct
link_util
bond_slave_link_util
=
{
.
id
=
"bond"
,
.
maxattr
=
IFLA_BOND_SLAVE_MAX
,
.
print_opt
=
bond_slave_print_opt
,
.
slave
=
true
,
};
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