summaryrefslogtreecommitdiff
path: root/zebra/kernel_netlink.c
diff options
context:
space:
mode:
authorMark Stapp <mjs@voltanet.io>2018-09-12 14:59:57 -0400
committerDonald Sharp <sharpd@cumulusnetworks.com>2018-09-19 18:34:25 -0400
commit85a75f1e775be73178d1b292ec0866fb336ddf2a (patch)
tree1680b5d2f030740314940b0db721827394fe32f2 /zebra/kernel_netlink.c
parentea1c14f6801881b7d2e1b4035b8f085f6d663927 (diff)
zebra: Start abstraction of zebra_dplane_info for context passing
Reduce or eliminate use of global zebra_ns structs in a couple of netlink/kernel code paths, so that those paths can potentially be made asynch eventually. Signed-off-by: Mark Stapp <mjs@voltanet.io> Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Diffstat (limited to 'zebra/kernel_netlink.c')
-rw-r--r--zebra/kernel_netlink.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/zebra/kernel_netlink.c b/zebra/kernel_netlink.c
index d35230d7bd..c8ea8ae445 100644
--- a/zebra/kernel_netlink.c
+++ b/zebra/kernel_netlink.c
@@ -373,7 +373,13 @@ static long netlink_read_file(char *buf, const char *fname)
static int kernel_read(struct thread *thread)
{
struct zebra_ns *zns = (struct zebra_ns *)THREAD_ARG(thread);
- netlink_parse_info(netlink_information_fetch, &zns->netlink, zns, 5, 0);
+ struct zebra_dplane_info dp_info;
+
+ /* Capture key info from ns struct */
+ zebra_dplane_info_from_zns(&dp_info, zns, false);
+
+ netlink_parse_info(netlink_information_fetch, &zns->netlink, &dp_info,
+ 5, 0);
zns->t_netlink = NULL;
thread_add_read(zebrad.master, kernel_read, zns, zns->netlink.sock,
&zns->t_netlink);
@@ -672,8 +678,8 @@ static void netlink_parse_extended_ack(struct nlmsghdr *h)
* the filter.
*/
int netlink_parse_info(int (*filter)(struct nlmsghdr *, ns_id_t, int),
- struct nlsock *nl, struct zebra_ns *zns, int count,
- int startup)
+ struct nlsock *nl, struct zebra_dplane_info *zns,
+ int count, int startup)
{
int status;
int ret = 0;
@@ -811,7 +817,7 @@ int netlink_parse_info(int (*filter)(struct nlmsghdr *, ns_id_t, int),
/* Deal with errors that occur because of races
* in link handling */
- if (nl == &zns->netlink_cmd
+ if (zns->is_cmd
&& ((msg_type == RTM_DELROUTE
&& (-errnum == ENODEV
|| -errnum == ESRCH))
@@ -838,8 +844,7 @@ int netlink_parse_info(int (*filter)(struct nlmsghdr *, ns_id_t, int),
* so do not log these as an error.
*/
if (msg_type == RTM_DELNEIGH
- || (nl == &zns->netlink_cmd
- && msg_type == RTM_NEWROUTE
+ || (zns->is_cmd && msg_type == RTM_NEWROUTE
&& (-errnum == ESRCH
|| -errnum == ENETUNREACH))) {
/* This is known to happen in some
@@ -935,6 +940,7 @@ int netlink_talk(int (*filter)(struct nlmsghdr *, ns_id_t, int startup),
struct iovec iov;
struct msghdr msg;
int save_errno = 0;
+ struct zebra_dplane_info dp_info;
memset(&snl, 0, sizeof snl);
memset(&iov, 0, sizeof iov);
@@ -981,7 +987,8 @@ int netlink_talk(int (*filter)(struct nlmsghdr *, ns_id_t, int startup),
* Get reply from netlink socket.
* The reply should either be an acknowlegement or an error.
*/
- return netlink_parse_info(filter, nl, zns, 0, startup);
+ zebra_dplane_info_from_zns(&dp_info, zns, (nl == &(zns->netlink_cmd)));
+ return netlink_parse_info(filter, nl, &dp_info, 0, startup);
}
/* Issue request message to kernel via netlink socket. GET messages