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.
{
struct nl_msg *msg;
struct nl_addr *addr;
uint64_t fwmark;
int tos, scope, table;
struct fib_result_nl fr = {0};
fwmark = flnl_request_get_fwmark(req);
tos = flnl_request_get_tos(req);
scope = flnl_request_get_scope(req);
table = flnl_request_get_table(req);
fr.fl_fwmark = fwmark != UINT_LEAST64_MAX ? fwmark : 0;
fr.fl_tos = tos >= 0 ? tos : 0;
fr.fl_scope = scope >= 0 ? scope : RT_SCOPE_UNIVERSE;
fr.tb_id_in = table >= 0 ? table : RT_TABLE_UNSPEC;
addr = flnl_request_get_addr(req);
if (!addr) {
nl_error(EINVAL, "Request must specify the address");
return NULL;
}
if (!msg)
goto errout;
goto errout;
return msg;
errout:
return NULL;
}