Skip to content

Commit

Permalink
link: Add function to unset carrier request
Browse files Browse the repository at this point in the history
When fetching from the kernel this flag seems to be set and when
making a change request this presists. Since it's only internal
variables we need a function to unset it from the outside.

ndo_carrier_change in the kernel should only be implemented by
non-hardware interfaces. For hardware interfaces (e.g. physical ports)
it will be EOPNOTSUPP. Allow unsetting it to not get an error.

Signed-off-by: Casper Andersson <casper.andersson@westermo.com>
  • Loading branch information
Casper Andersson committed May 23, 2024
1 parent b227834 commit ab8cd24
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/netlink/route/link.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ extern int rtnl_link_get_master(struct rtnl_link *);

extern void rtnl_link_set_carrier(struct rtnl_link *, uint8_t);
extern uint8_t rtnl_link_get_carrier(struct rtnl_link *);
extern void rtnl_link_unset_carrier_request_flag(struct rtnl_link *);

extern int rtnl_link_get_carrier_changes(struct rtnl_link *, uint32_t *);

Expand Down
11 changes: 11 additions & 0 deletions lib/route/link.c
Original file line number Diff line number Diff line change
Expand Up @@ -2433,6 +2433,17 @@ uint8_t rtnl_link_get_carrier(struct rtnl_link *link)
return link->l_carrier;
}

/**
* Unset carrier request of link object
* @arg link Link object
*
* @see rtnl_link_set_carrier()
*/
void rtnl_link_unset_carrier_request_flag(struct rtnl_link *link)
{
link->ce_mask &= ~LINK_ATTR_CARRIER;
}

/**
* Return carrier on/off changes of link object
* @arg link Link object
Expand Down
1 change: 1 addition & 0 deletions libnl-route-3.sym
Original file line number Diff line number Diff line change
Expand Up @@ -1358,4 +1358,5 @@ global:
rtnl_interlink_set_net_id;
rtnl_flower_set_ip_ttl;
rtnl_flower_get_ip_ttl;
rtnl_link_unset_carrier_request_flag;
} libnl_3_6;

0 comments on commit ab8cd24

Please sign in to comment.