Skip to content

Commit ee01c00

Browse files
stchengjpirko
authored andcommitted
libteam: Add team_get_port_enabled function
This function corresponds to team_set_port_enabled. With this function, it is able to get the enabled state for port identified by port_ifindex. Signed-off-by: Shuotian Cheng <[email protected]> Signed-off-by: Jiri Pirko <[email protected]>
1 parent e91c31e commit ee01c00

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

include/team.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ int team_get_bpf_hash_func(struct team_handle *th, struct sock_fprog *fp);
6868
int team_set_bpf_hash_func(struct team_handle *th, const struct sock_fprog *fp);
6969
int team_set_port_enabled(struct team_handle *th,
7070
uint32_t port_ifindex, bool val);
71+
int team_get_port_enabled(struct team_handle *th,
72+
uint32_t port_ifindex, bool *enabled);
7173
int team_set_port_user_linkup_enabled(struct team_handle *th,
7274
uint32_t port_ifindex, bool val);
7375
int team_get_port_user_linkup(struct team_handle *th,

libteam/libteam.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1338,6 +1338,28 @@ int team_set_port_enabled(struct team_handle *th,
13381338
return team_set_option_value_bool(th, option, val);
13391339
}
13401340

1341+
/**
1342+
* @param th libteam library context
1343+
* @param port_ifindex port interface index
1344+
* @param enabled where the enabled state will be stored
1345+
*
1346+
* @details Gets enabled state for port identified by port_ifindex
1347+
*
1348+
* @return Zero on success or negative number in case of an error.
1349+
**/
1350+
TEAM_EXPORT
1351+
int team_get_port_enabled(struct team_handle *th,
1352+
uint32_t port_ifindex, bool *enabled)
1353+
{
1354+
struct team_option *option;
1355+
1356+
option = team_get_option(th, "np", "enabled", port_ifindex);
1357+
if (!option)
1358+
return -ENOENT;
1359+
*enabled = team_get_option_value_bool(option);
1360+
return 0;
1361+
}
1362+
13411363
/**
13421364
* @param th libteam library context
13431365
* @param port_ifindex port interface index

0 commit comments

Comments
 (0)