netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Graf <tgraf@suug.ch>
To: netdev@oss.sgi.com
Subject: [RFC] Extend netlink error codes
Date: Sat, 11 Sep 2004 00:51:58 +0200	[thread overview]
Message-ID: <20040910225158.GO20088@postel.suug.ch> (raw)

The current situation with error codes sent back to a netlink
application is unsatisfactory. Most often, the application
receives EINVAL but has no idea what was wrong.

Here is my plan:

Introduce some macros:

#define NLERR_MAJ_MASK (0x7FFF0000U)
#define NLERR_MIN_MASK (0x0000FFFFU)
#define NLERR_MAJ(e) ((abs(e) & NLERR_MAJ_MASK) >> 16)
#define NLERR_MIN(e) (abs(e) & NLERR_MIN_MASK)
#define NLERR_MAKE(err, nle) ((((nle) << 16) & NLERR_MAJ_MASK)
		| ((err) & NLERR_MIN_MASK))

Specify netlink specific error codes, e.g.:

#define NLE_SUCCESS     0
#define NLE_NOQDISC     1
#define NLE_NOTCLASFUL  2
...

Predefined error messages could be provided by libnetlink
via nl_strerror().

Replace vague error return calls with something like:

return -NLERR_MAKE(EINVAL, NLE_NOQDISC);

Once in netlink_ack, split the combined error message again,
fill the existing errno into nlerrmsg.error and provide the
netlink specific error code in a newly introduced TLV. This
way, no binaries or old applications would break, but
applications can support it and provide more meanigful error
message with almost no effort.

Comments?

             reply	other threads:[~2004-09-10 22:51 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-09-10 22:51 Thomas Graf [this message]
2004-09-10 23:07 ` [RFC] Extend netlink error codes David S. Miller
2004-09-11  1:38   ` jamal
2004-09-11 15:49     ` Thomas Graf
2004-09-11 15:58 ` Andi Kleen
2004-09-11 16:24   ` Thomas Graf
2004-09-11 16:50     ` Andi Kleen
2004-09-11 17:57       ` Thomas Graf
2004-09-11 18:48     ` Sam Leffler
2004-09-11 21:10       ` jamal
2004-09-13 20:36         ` Thomas Graf
2004-09-13 23:28           ` David S. Miller
2004-09-14  2:00           ` jamal
2004-09-12 23:37     ` David S. Miller
2004-09-13  6:26       ` Andi Kleen
2004-09-13 19:33         ` David S. Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040910225158.GO20088@postel.suug.ch \
    --to=tgraf@suug.ch \
    --cc=netdev@oss.sgi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).