diff options
| author | Mark Stapp <mjs@voltanet.io> | 2018-11-14 14:45:30 -0500 |
|---|---|---|
| committer | Mark Stapp <mjs@voltanet.io> | 2018-11-21 10:38:08 -0500 |
| commit | 80776aec8147d643ca8aaa99f7320c7f22a70677 (patch) | |
| tree | ee07000787c8d6a6756e9d5d349c8efbb9464f7c /zebra/kernel_socket.c | |
| parent | 62b8bb7a1776ea98e5874a4a057617e335a7f77c (diff) | |
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>
Diffstat (limited to 'zebra/kernel_socket.c')
| -rw-r--r-- | zebra/kernel_socket.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/zebra/kernel_socket.c b/zebra/kernel_socket.c index ff739ae79b..dcc22d2162 100644 --- a/zebra/kernel_socket.c +++ b/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,6 +1395,9 @@ 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) { @@ -1397,6 +1405,12 @@ static void routing_socket(struct zebra_ns *zns) 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. |
