void *rtnl_cls_data(struct rtnl_cls *cls) { if (!cls->c_subdata) { struct rtnl_cls_ops *ops = cls->c_ops; if (!ops) { if (!cls->c_kind[0]) BUG(); ops = __rtnl_cls_lookup_ops(cls->c_kind); if (ops == NULL) return NULL; cls->c_ops = ops; } if (!ops->co_size) BUG(); if (!(cls->c_subdata = nl_data_alloc(NULL, ops->co_size))) return NULL; } return nl_data_get(cls->c_subdata); }
static inline struct tc_u32_mark *u32_mark_alloc(struct rtnl_u32 *u) { if (!u->cu_mark) u->cu_mark = nl_data_alloc(NULL, sizeof(struct tc_u32_mark)); return (struct tc_u32_mark *) u->cu_mark->d_data; }
static inline struct tc_u32_sel *u32_selector_alloc(struct rtnl_u32 *u) { if (!u->cu_selector) u->cu_selector = nl_data_alloc(NULL, sizeof(struct tc_u32_sel)); return u32_selector(u); }
/** * Clone an abstract data object. * @arg src Abstract data object * * @return Cloned object or NULL */ struct nl_data *nl_data_clone(struct nl_data *src) { return nl_data_alloc(src->d_data, src->d_size); }
/** * Allocate abstract data object based on netlink attribute. * @arg nla Netlink attribute of unspecific type. * * Allocates a new abstract data and copies the payload of the * attribute to the abstract data object. * * @see nla_data_alloc * @return Newly allocated data handle or NULL */ struct nl_data *nl_data_alloc_attr(struct nlattr *nla) { return nl_data_alloc(nla_data(nla), nla_len(nla)); }