summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorTobias Waldekranz <tobias@waldekranz.com>2016-01-27 12:22:31 (GMT)
committerVolodymyr Bendiuga <volodymyr.bendiuga@westermo.se>2022-03-11 22:17:29 (GMT)
commit53bc27eae100758ed95a6022c7a3a9dfb695ec20 (patch)
treec0ed6d4edf6d9093e4c764e7d2e165e1d90ccdd7 /lib
parented76b9ac92d47e59f54d4dec97d426902859b7cc (diff)
downloadlibnl-53bc27eae100758ed95a6022c7a3a9dfb695ec20.zip
libnl-53bc27eae100758ed95a6022c7a3a9dfb695ec20.tar.gz
libnl-53bc27eae100758ed95a6022c7a3a9dfb695ec20.tar.bz2
route/route: support FIB lookups using rtnl
Using the flnl_* family of functions to perform FIB lookups is rather limited. In particular, there seems to be no way of resolving the nexthop. By hooking into RTM_GETROUTE, a regular rtnl route object is returned instead.
Diffstat (limited to 'lib')
-rw-r--r--lib/route/route.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/route/route.c b/lib/route/route.c
index 509099a..a761549 100644
--- a/lib/route/route.c
+++ b/lib/route/route.c
@@ -124,6 +124,33 @@ int rtnl_route_build_add_request(struct rtnl_route *tmpl, int flags,
result);
}
+int rtnl_route_lookup(struct nl_sock *sk, struct nl_addr *dst,
+ struct rtnl_route **result)
+{
+ struct nl_msg *msg;
+ struct rtnl_route *tmpl;
+ struct nl_object *obj;
+ int err;
+
+ tmpl = rtnl_route_alloc();
+ rtnl_route_set_dst(tmpl, dst);
+ err = build_route_msg(tmpl, RTM_GETROUTE, 0, &msg);
+ rtnl_route_put(tmpl);
+ if (err < 0)
+ return err;
+
+ err = nl_send_auto(sk, msg);
+ nlmsg_free(msg);
+ if (err < 0)
+ return err;
+
+ if ((err = nl_pickup(sk, route_msg_parser, &obj)) < 0)
+ return err;
+
+ *result = (struct rtnl_route *)obj;
+ return wait_for_ack(sk);
+}
+
int rtnl_route_add(struct nl_sock *sk, struct rtnl_route *route, int flags)
{
struct nl_msg *msg;