From 501d5c2bec60070e78024bb98917970d207de06b Mon Sep 17 00:00:00 2001 From: chengyechun Date: Thu, 16 Dec 2021 22:32:30 +0800 Subject: [PATCH] add a test:test add route --- add-a-test-test-add-route.patch | 44 +++++++++++++++++++++++++++++++++ libnl3.spec | 9 ++++++- 2 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 add-a-test-test-add-route.patch diff --git a/add-a-test-test-add-route.patch b/add-a-test-test-add-route.patch new file mode 100644 index 0000000..ceba74f --- /dev/null +++ b/add-a-test-test-add-route.patch @@ -0,0 +1,44 @@ +From 92d64e75d74aa7343769f9923d0a9294caa0cadd Mon Sep 17 00:00:00 2001 +From: chengyechun +Date: Thu, 16 Dec 2021 22:13:04 +0800 +Subject: [PATCH] add a test:test add route + +--- + tests/test-add-route.c | 25 +++++++++++++++++++++++++ + 1 file changed, 25 insertions(+) + create mode 100644 tests/test-add-route.c + +diff --git a/tests/test-add-route.c b/tests/test-add-route.c +new file mode 100644 +index 0000000..b93db60 +--- /dev/null ++++ b/tests/test-add-route.c +@@ -0,0 +1,25 @@ ++#include ++#include ++#include ++#include ++ ++ ++int main(int argc, char *argv[]) ++{ ++ struct nl_sock *sk; ++ struct rtnl_route *route; ++ struct nl_cache *link_cache, *route_cache; ++ char dst_addr[] = "10.10.10.0/23"; ++ char nexthop[] = "dev=eth0, via=10.10.10.10.1"; ++ int err; ++ sk = nl_cli_alloc_socket(); ++ nl_cli_connect(sk, NETLINK_ROUTE); ++ link_cache = nl_cli_link_alloc_cache(sk); ++ route_cache = nl_cli_route_alloc_cache(sk); ++ route = nl_cli_route_alloc(); ++ nl_Cli_route_parse_dst(route, dst_addr); ++ nl_cli_route_parse_nexthop(route, nexthop, link_cache); ++ if ((err = rtnl_route_add(sk, route, NLM_F_EXCL)) < 0) ++ nl_cli_fatal(err, "Unable to add route: %s", nl_geterror(err)); ++ return 0; ++} +-- +2.23.0 + diff --git a/libnl3.spec b/libnl3.spec index 8b32e85..52d5351 100644 --- a/libnl3.spec +++ b/libnl3.spec @@ -1,6 +1,6 @@ Name: libnl3 Version: 3.5.0 -Release: 4 +Release: 5 Summary: Providing APIs to netlink protocol based Linux kernel interfaces License: LGPLv2 URL: http://www.infradead.org/~tgr/libnl/ @@ -13,6 +13,7 @@ Patch6003: backport-route-link-Check-for-null-pointer-in-macvlan.patch Patch6004: backport-rtnl-link-fix-leaking-rtnl_link_af_ops-in-link_msg_parser.patch Patch6005: backport-rtnl-route-fix-NLE_NOMEM-handling-in-parse_multipath.patch Patch9000: solve-redefinition-of-struct-ipv6_mreq.patch +Patch9001: add-a-test-test-add-route.patch BuildRequires: flex bison libtool autoconf automake swig Requires: %{name} = %{version}-%{release} @@ -97,6 +98,12 @@ cd python %{python3_sitearch}/netlink-*.egg-info %changelog +* Thu Dec 16 2021 chengyechun - 3.5.0-5 +- Type:bugfix +- ID:NA +- SUG:NA +- DES:add a test:test add route + * Wed Mar 10 2021 zengwefeng - 3.5.0-4 - Type:bugfix - ID:NA