lib: add _NL_RETURN_*() helper macros
lib: add _NL_RETURN_*() helper macros

These macros shall replace the NLA_PUT*() macros that on failure "goto
nla_put_failure;". There are two problems with NLA_PUT*() macors:

- the "goto nla_put_failure;" makes code harder to follow, because it
  jumps to some cleanup section, and then there is the potential of
  doing inconsistent things. Instead, we should not require any cleanup
  code by using _nl_auto* macros and consistently propagate the *right*
  error.

- NLA_PUT() goes to failure regardless what the problem was. The most
  common error is of course running out of buffer space (which nla_put()
  and nlmsg_append() signal by -NLE_MSGSIZE). But there are other errors
  too, like -NLE_INVAL. In those cases, we should propagate the original
  error, and only coerce -NLE_NOMEM to -NLE_MSGSIZE.

For example, note how link_request_update() does

        err = nla_put(msg, IFLA_EXT_MASK, sizeof(ext_filter_mask), &ext_filter_mask);
        if (err < 0)
            goto nla_put_failure;
        ...
    nla_put_failure:
        nlmsg_free(msg);
        return err;

thus, propagating out of buffers as -NLE_NOMEM. But while most users of NLA_PUT() will
coerce any error to -NLE_MSGSIZE, which is better but only correct in case of -NLE_NOMEM.
This is an error prone pattern, that lead to a lot of inconsistent error results.

Replace

    NLA_PUT_STRING(msg, IFLA_IFNAME, name);

by

    _NL_RETURN_ON_PUT_ERR(nla_put_string(msg, IFLA_IFNAME, name));

which instead handles the error propagation in a uniform manner, and
returns early.

thom311/libnl,greearb/libnl-ct,greearb/libnl-ct,thom311/libnl,thom311/libnl,greearb/libnl-ct