Skip to content

Commit

Permalink
lib/route: allow rtnl_neigh_get_ext_flags to fail
Browse files Browse the repository at this point in the history
Make rtnl_neigh_get_ext_flags return -NLE_NOATTR when the flags are not
present (so the user can know when the kernel didn't send those flags).
The absence of the attribute does not however imply that the kernel
lacks support for the ext flags.
  • Loading branch information
ronand-atl committed Sep 13, 2024
1 parent c238ca1 commit d9332d6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
3 changes: 2 additions & 1 deletion include/netlink/route/neighbour.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ extern void rtnl_neigh_set_ext_flags(struct rtnl_neigh *,
uint32_t);
extern void rtnl_neigh_unset_ext_flags(struct rtnl_neigh *,
uint32_t);
extern uint32_t rtnl_neigh_get_ext_flags(struct rtnl_neigh *);
extern int rtnl_neigh_get_ext_flags(struct rtnl_neigh *,
uint32_t *);

extern void rtnl_neigh_set_ifindex(struct rtnl_neigh *,
int);
Expand Down
8 changes: 6 additions & 2 deletions lib/route/neigh.c
Original file line number Diff line number Diff line change
Expand Up @@ -1037,9 +1037,13 @@ void rtnl_neigh_set_ext_flags(struct rtnl_neigh *neigh, uint32_t ext_flags)
neigh->ce_mask |= NEIGH_ATTR_EXT_FLAGS;
}

uint32_t rtnl_neigh_get_ext_flags(struct rtnl_neigh *neigh)
int rtnl_neigh_get_ext_flags(struct rtnl_neigh *neigh, uint32_t *out_val)
{
return neigh->n_ext_flags;
if (!(neigh->ce_mask & NEIGH_ATTR_EXT_FLAGS))
return -NLE_NOATTR;

*out_val = neigh->n_ext_flags;
return NLE_SUCCESS;
}

void rtnl_neigh_unset_ext_flags(struct rtnl_neigh *neigh, uint32_t ext_flags)
Expand Down

0 comments on commit d9332d6

Please sign in to comment.