Skip to content
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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

eguillaume-kalray
Copy link

Enables getting attributes from bonding interfaces.

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);
Copy link
Contributor

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

Suggested change
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);

Copy link
Owner

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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

likewise

Suggested change
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);
Copy link
Contributor

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.

Suggested change
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.

Comment on lines +1334 to +1340
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;
Copy link
Contributor

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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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);

Copy link
Owner

@thom311 thom311 left a 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")

@KanjiMonster
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants