-
Notifications
You must be signed in to change notification settings - Fork 314
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
route/link: add bonding parser/getters and lacp rate api #391
base: main
Are you sure you want to change the base?
Conversation
extern void rtnl_link_bond_set_hashing_type (struct rtnl_link *link, uint8_t type); | ||
extern uint8_t rtnl_link_bond_get_hashing_type (struct rtnl_link *link); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe also fix the style here
extern uint8_t rtnl_link_bond_get_hashing_type (struct rtnl_link *link); | |
extern int rtnl_link_bond_get_hashing_type(struct rtnl_link *link, uint8_t *type); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also think so. Only returning uint8_t
leaves no space to signal an error (or a missing attribute -NLE_NOATTR
).
If the value itself is a uint8_t
, then we could still do
int rtnl_link_bond_get_hashing_type (struct rtnl_link *link);
where negative values are error codes and non-negative values are the uint8_t
value.
For uint32_t
types, that doesn't work. So it needs
extern int rtnl_link_bond_get_miimon(struct rtnl_link *link, uint32_t *miimon);
to separately signal the error/NOATTR and the value.
I think int rtnl_link_bond_get_hashing_type (struct rtnl_link *link);
is still less convenient to use, because you need
r = rtnl_link_bond_get_hashing_type(link);
if (r >= 0)
hashing_type = r;
else {
/* handle error */
}
instead of
r = rtnl_link_bond_get_hashing_type(link, &hashing_type);
if (r < 0) {
/* handle error */
}
So just have getters return an int
(zero or negative error code) and the out value separately. Ensure that the out value is touched, if-and-only-if there is no error.
extern void rtnl_link_bond_set_miimon (struct rtnl_link *link, uint32_t miimon); | ||
extern uint32_t rtnl_link_bond_get_miimon (struct rtnl_link *link); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
likewise
extern uint32_t rtnl_link_bond_get_miimon (struct rtnl_link *link); | |
extern int rtnl_link_bond_get_miimon(struct rtnl_link *link, uint32_t *miimon); |
extern void rtnl_link_bond_set_activeslave(struct rtnl_link *link, int active_slave); | ||
extern int rtnl_link_bond_get_activeslave(struct rtnl_link *link); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The usual way for these is to return an int, and store the value in a pointer passed as argument, so you can actually return error values if the value isn't set.
extern int rtnl_link_bond_get_activeslave(struct rtnl_link *link); | |
extern int rtnl_link_bond_get_activeslave(struct rtnl_link *link, int *active_slave); |
E.g. activeslave wouldn't exist for an LACP bond, so we should return an error here.
rtnl_link_bond_get_mode; | ||
rtnl_link_bond_get_hashing_type; | ||
rtnl_link_bond_get_activeslave; | ||
rtnl_link_bond_get_miimon; | ||
rtnl_link_bond_get_min_links; | ||
rtnl_link_bond_set_lacp_rate; | ||
rtnl_link_bond_get_lacp_rate; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alphabetical order?
extern void rtnl_link_bond_set_min_links (struct rtnl_link *link, uint32_t min_links); | ||
extern uint32_t rtnl_link_bond_get_min_links (struct rtnl_link *link); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extern uint32_t rtnl_link_bond_get_min_links (struct rtnl_link *link); | |
extern int rtnl_link_bond_get_min_links(struct rtnl_link *link, uint32_t *min_links); |
extern uint32_t rtnl_link_bond_get_min_links (struct rtnl_link *link); | ||
|
||
extern void rtnl_link_bond_set_lacp_rate(struct rtnl_link *link, uint8_t lacp_rate); | ||
extern uint8_t rtnl_link_bond_get_lacp_rate(struct rtnl_link *link); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extern uint8_t rtnl_link_bond_get_lacp_rate(struct rtnl_link *link); | |
extern int rtnl_link_bond_get_lacp_rate(struct rtnl_link *link, uint8_t *lacp_rate); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(setting flag for "Request changes")
To get this moving in this I decided to push my changes I had already prepared a while ago while I was waiting for the 3.10 release with #401. |
Enables getting attributes from bonding interfaces.