From 30359046d81b637168c2cbd449d7fdfce9baca39 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Tue, 9 Aug 2016 13:02:27 -0400 Subject: [PATCH] zebra: Allow netlink_talk to choose the filter function to call The netlink_talk call sends a message to the kernel, which with netlink_talk_filter only waits for the ACK. It would be nice to have the ability to specify what the handler function would be for when we send queries about mcast S,G routes so that we can gather the data returned from the kernel. Signed-off-by: Donald Sharp --- zebra/kernel_netlink.c | 8 +++++--- zebra/kernel_netlink.h | 6 +++++- zebra/rt_netlink.c | 6 +++--- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/zebra/kernel_netlink.c b/zebra/kernel_netlink.c index 70b56b31b6..9142d4d151 100644 --- a/zebra/kernel_netlink.c +++ b/zebra/kernel_netlink.c @@ -100,7 +100,7 @@ extern u_int32_t nl_rcvbufsize; extern struct zebra_privs_t zserv_privs; -static int +int netlink_talk_filter (struct sockaddr_nl *snl, struct nlmsghdr *h, ns_id_t ns_id) { @@ -593,7 +593,9 @@ netlink_parse_info (int (*filter) (struct sockaddr_nl *, struct nlmsghdr *, /* sendmsg() to netlink socket then recvmsg(). */ int -netlink_talk (struct nlmsghdr *n, struct nlsock *nl, struct zebra_ns *zns) +netlink_talk (int (*filter) (struct sockaddr_nl *, struct nlmsghdr *, + ns_id_t), + struct nlmsghdr *n, struct nlsock *nl, struct zebra_ns *zns) { int status; struct sockaddr_nl snl; @@ -649,7 +651,7 @@ netlink_talk (struct nlmsghdr *n, struct nlsock *nl, struct zebra_ns *zns) * Get reply from netlink socket. * The reply should either be an acknowlegement or an error. */ - return netlink_parse_info (netlink_talk_filter, nl, zns, 0); + return netlink_parse_info (filter, nl, zns, 0); } /* Get type specified information from netlink. */ diff --git a/zebra/kernel_netlink.h b/zebra/kernel_netlink.h index 890236c047..f97e6e8ccc 100644 --- a/zebra/kernel_netlink.h +++ b/zebra/kernel_netlink.h @@ -44,7 +44,11 @@ extern const char * nl_rtproto_to_str (u_char rtproto); extern int netlink_parse_info (int (*filter) (struct sockaddr_nl *, struct nlmsghdr *, ns_id_t), struct nlsock *nl, struct zebra_ns *zns, int count); -extern int netlink_talk (struct nlmsghdr *n, struct nlsock *nl, +extern int netlink_talk_filter (struct sockaddr_nl *, struct nlmsghdr *, + ns_id_t); +extern int netlink_talk (int (*filter) (struct sockaddr_nl *, struct nlmsghdr *, + ns_id_t), + struct nlmsghdr *n, struct nlsock *nl, struct zebra_ns *zns); extern int netlink_request (int family, int type, struct nlsock *nl); diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c index 4e87ab9fa6..a351b457ce 100644 --- a/zebra/rt_netlink.c +++ b/zebra/rt_netlink.c @@ -1158,7 +1158,7 @@ netlink_neigh_update (int cmd, int ifindex, uint32_t addr, char *lla, int llalen addattr_l(&req.n, sizeof(req), NDA_DST, &addr, 4); addattr_l(&req.n, sizeof(req), NDA_LLADDR, lla, llalen); - return netlink_talk (&req.n, &zns->netlink_cmd, zns); + return netlink_talk (netlink_talk_filter, &req.n, &zns->netlink_cmd, zns); } /* Routing table change via netlink interface. */ @@ -1453,7 +1453,7 @@ skip: snl.nl_family = AF_NETLINK; /* Talk to netlink socket. */ - return netlink_talk (&req.n, &zns->netlink_cmd, zns); + return netlink_talk (netlink_talk_filter, &req.n, &zns->netlink_cmd, zns); } int @@ -1643,7 +1643,7 @@ netlink_mpls_multipath (int cmd, zebra_lsp_t *lsp) } /* Talk to netlink socket. */ - return netlink_talk (&req.n, &zns->netlink_cmd, zns); + return netlink_talk (netlink_talk_filter, &req.n, &zns->netlink_cmd, zns); } /* -- 2.39.5