diff options
author | roopa <roopa@cumulusnetworks.com> | 2013-02-15 18:26:30 (GMT) |
---|---|---|
committer | Thomas Graf <tgraf@suug.ch> | 2013-02-24 16:11:36 (GMT) |
commit | ded20487fd631f7fcfc8f3cc547f6a8852501b83 (patch) | |
tree | 3e63b437994799191c252298dda51c872f4387cf /lib/route | |
parent | 8f151fadda62bdbd363b8d4a0167d5d29bb5163b (diff) | |
download | libnl-ded20487fd631f7fcfc8f3cc547f6a8852501b83.zip libnl-ded20487fd631f7fcfc8f3cc547f6a8852501b83.tar.gz libnl-ded20487fd631f7fcfc8f3cc547f6a8852501b83.tar.bz2 |
link: Fix rtnl_link_af_data_compare return value
This patch fixes a bug where because of the af_ops check
being first in the function, we were returning ~0 if af_ops
was null even if both objects really did not have af_data
and we should be returning 0.
Its better to have the af_data present check before anything else.
So, Rearranged some of the code in rtnl_link_af_data_compare.
Changes include:
- Do the attribute present check before anything else
- If ao_compare op not present, return ~0
Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
Reviewed-by: Nolan Leake <nolan@cumulusnetworks.com>
Reviewed-by: Shrijeet Mukherjee <shm@cumulusnetworks.com>
Reviewed-by: Wilson Kok <wkok@cumulusnetworks.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
Diffstat (limited to 'lib/route')
-rw-r--r-- | lib/route/link/api.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/lib/route/link/api.c b/lib/route/link/api.c index 63ff99c..352bb83 100644 --- a/lib/route/link/api.c +++ b/lib/route/link/api.c @@ -365,22 +365,26 @@ errout: int rtnl_link_af_data_compare(struct rtnl_link *a, struct rtnl_link *b, int family) { - struct rtnl_link_af_ops *af_ops = rtnl_link_af_ops_lookup(family); + struct rtnl_link_af_ops *af_ops; int ret = 0; - if (!af_ops) + if (!a->l_af_data[family] && !b->l_af_data[family]) + return 0; + + if (!a->l_af_data[family] || !b->l_af_data[family]) return ~0; - if (!a->l_af_data[family] && !b->l_af_data[family]) - goto out; + af_ops = rtnl_link_af_ops_lookup(family); + if (!af_ops) + return ~0; - if (!a->l_af_data[family] || !b->l_af_data[family]) { + if (af_ops->ao_compare == NULL) { ret = ~0; goto out; } - if (af_ops->ao_compare) - ret = af_ops->ao_compare(a, b, family, ~0, 0); + ret = af_ops->ao_compare(a, b, family, ~0, 0); + out: rtnl_link_af_ops_put(af_ops); |