]> git.puffer.fish Git - matthieu/frr.git/commitdiff
zebra: Allow netlink_talk to choose the filter function to call
authorDonald Sharp <sharpd@cumulusnetworks.com>
Tue, 9 Aug 2016 17:02:27 +0000 (13:02 -0400)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Tue, 17 Jan 2017 23:29:46 +0000 (18:29 -0500)
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 <sharpd@cumulusnetworks.com>
zebra/kernel_netlink.c
zebra/kernel_netlink.h
zebra/rt_netlink.c

index 70b56b31b64adff66ad4247d56f3e24567865109..9142d4d151074736d784419d71915d1a4ed55983 100644 (file)
@@ -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. */
index 890236c0471e9d7f2ee5f1bb6f2bc21665c478d0..f97e6e8ccc045442a434d0ea2ee2073dd75221a9 100644 (file)
@@ -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);
 
index 4e87ab9fa63f4d21243b58d8b1be6bda728e27e7..a351b457ce07ec2e97d74b78f5924cbec06ab061 100644 (file)
@@ -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);
 }
 
 /*