sd-netlink: introduce multipath_route_dup()
The function will be used in later commits.
This commit is contained in:
@@ -418,6 +418,35 @@ MultipathRoute *multipath_route_free(MultipathRoute *m) {
|
||||
return mfree(m);
|
||||
}
|
||||
|
||||
int multipath_route_dup(const MultipathRoute *m, MultipathRoute **ret) {
|
||||
_cleanup_(multipath_route_freep) MultipathRoute *n = NULL;
|
||||
_cleanup_free_ char *ifname = NULL;
|
||||
|
||||
assert(m);
|
||||
assert(ret);
|
||||
|
||||
if (m->ifname) {
|
||||
ifname = strdup(m->ifname);
|
||||
if (!ifname)
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
n = new(MultipathRoute, 1);
|
||||
if (!n)
|
||||
return -ENOMEM;
|
||||
|
||||
*n = (MultipathRoute) {
|
||||
.gateway = m->gateway,
|
||||
.weight = m->weight,
|
||||
.ifindex = m->ifindex,
|
||||
.ifname = TAKE_PTR(ifname),
|
||||
};
|
||||
|
||||
*ret = TAKE_PTR(n);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int rtattr_read_nexthop(const struct rtnexthop *rtnh, size_t size, int family, OrderedSet **ret) {
|
||||
_cleanup_ordered_set_free_free_ OrderedSet *set = NULL;
|
||||
int r;
|
||||
|
||||
@@ -27,6 +27,8 @@ typedef struct MultipathRoute {
|
||||
MultipathRoute *multipath_route_free(MultipathRoute *m);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(MultipathRoute*, multipath_route_free);
|
||||
|
||||
int multipath_route_dup(const MultipathRoute *m, MultipathRoute **ret);
|
||||
|
||||
int rtnl_message_new_synthetic_error(sd_netlink *rtnl, int error, uint32_t serial, sd_netlink_message **ret);
|
||||
uint32_t rtnl_message_get_serial(sd_netlink_message *m);
|
||||
void rtnl_message_seal(sd_netlink_message *m);
|
||||
|
||||
Reference in New Issue
Block a user