#include "zebra/kernel_socket.h"
#include "zebra/rib.h"
#include "zebra/zebra_errors.h"
+#include "zebra/zebra_ptm.h"
extern struct zebra_privs_t zserv_privs;
/* 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 */
__func__, ifan->ifan_index, ifan->ifan_name);
/* Create Interface */
- ifp = if_get_by_name(ifan->ifan_name, VRF_DEFAULT, 0);
+ ifp = if_get_by_name(ifan->ifan_name, VRF_DEFAULT);
if_set_index(ifp, ifan->ifan_index);
if_get_metric(ifp);
char buf[512];
} msg;
- if (routing_sock < 0)
+ if (dplane_routing_sock < 0)
return ZEBRA_ERR_EPERM;
/* Clear and set rt_msghdr values */
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)
{
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) {
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.
routing_socket(zns);
}
-void kernel_terminate(struct zebra_ns *zns)
+void kernel_terminate(struct zebra_ns *zns, bool complete)
{
return;
}