Builds a new netlink message requesting a change of link attributes. The netlink message header isn't fully equipped with all relevant fields and must be sent out via nl_send_auto_complete() or supplemented as needed. old must point to a link currently configured in the kernel and tmpl must contain the attributes to be changed set via rtnl_link_set_* functions.
213{
214 struct nl_msg *msg;
215 struct nl_addr *addr;
216 uint64_t fwmark;
217 int tos, scope, table;
218 struct fib_result_nl fr = {0};
219
220 fwmark = flnl_request_get_fwmark(req);
221 tos = flnl_request_get_tos(req);
222 scope = flnl_request_get_scope(req);
223 table = flnl_request_get_table(req);
224
225 fr.fl_fwmark = fwmark != UINT_LEAST64_MAX ? fwmark : 0;
226 fr.fl_tos = tos >= 0 ? tos : 0;
227 fr.fl_scope = scope >= 0 ? scope : RT_SCOPE_UNIVERSE;
228 fr.tb_id_in = table >= 0 ? table : RT_TABLE_UNSPEC;
229
230 addr = flnl_request_get_addr(req);
231 if (!addr) {
232 nl_error(EINVAL, "Request must specify the address");
233 return NULL;
234 }
235
237
239 if (!msg)
240 goto errout;
241
242 if (
nlmsg_append(msg, &fr,
sizeof(fr), NLMSG_ALIGNTO) < 0)
243 goto errout;
244
245 return msg;
246
247errout:
249 return NULL;
250}
void * nl_addr_get_binary_addr(struct nl_addr *addr)
Get binary address of abstract address object.
struct nl_msg * nlmsg_alloc_simple(int nlmsgtype, int flags)
Allocate a new netlink message.
void nlmsg_free(struct nl_msg *n)
Free a netlink message.
int nlmsg_append(struct nl_msg *n, void *data, size_t len, int pad)
Append data to tail of a netlink message.