Skip to content
Permalink
Browse files

zebra: add dataplane routing socket

To avoid conflicts between the zebra main pthread and the
dataplane pthread, use a separate routing socket (on non-netlink
platforms) for dataplane route updates to the OS.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
  • Loading branch information...
mjstapp committed Nov 14, 2018
1 parent 62b8bb7 commit 80776aec8147d643ca8aaa99f7320c7f22a70677
Showing with 16 additions and 2 deletions.
  1. +16 −2 zebra/kernel_socket.c
@@ -278,6 +278,11 @@ static const struct message rtm_flag_str[] = {{RTF_UP, "UP"},
/* Kernel routing update socket. */
int routing_sock = -1;

/* Kernel dataplane routing update socket, used in the dataplane pthread
* context.
*/
int dplane_routing_sock = -1;

/* Yes I'm checking ugly routing socket behavior. */
/* #define DEBUG */

@@ -1136,7 +1141,7 @@ int rtm_write(int message, union sockunion *dest, union sockunion *mask,
char buf[512];
} msg;

if (routing_sock < 0)
if (dplane_routing_sock < 0)
return ZEBRA_ERR_EPERM;

/* Clear and set rt_msghdr values */
@@ -1243,7 +1248,7 @@ int rtm_write(int message, union sockunion *dest, union sockunion *mask,

msg.rtm.rtm_msglen = pnt - (caddr_t)&msg;

ret = write(routing_sock, &msg, msg.rtm.rtm_msglen);
ret = write(dplane_routing_sock, &msg, msg.rtm.rtm_msglen);

if (ret != msg.rtm.rtm_msglen) {
if (errno == EEXIST)
@@ -1390,13 +1395,22 @@ static void routing_socket(struct zebra_ns *zns)
{
frr_elevate_privs(&zserv_privs) {
routing_sock = ns_socket(AF_ROUTE, SOCK_RAW, 0, zns->ns_id);

dplane_routing_sock =
ns_socket(AF_ROUTE, SOCK_RAW, 0, zns->ns_id);
}

if (routing_sock < 0) {
flog_err_sys(EC_LIB_SOCKET, "Can't init kernel routing socket");
return;
}

if (dplane_routing_sock < 0) {
flog_err_sys(EC_LIB_SOCKET,
"Can't init kernel dataplane routing socket");
return;
}

/* XXX: Socket should be NONBLOCK, however as we currently
* discard failed writes, this will lead to inconsistencies.
* For now, socket must be blocking.

0 comments on commit 80776ae

Please sign in to comment.
You can’t perform that action at this time.