]> git.proxmox.com Git - mirror_frr.git/blobdiff - zebra/kernel_socket.c
zebra: dup addr detect clear cmd non-zero return
[mirror_frr.git] / zebra / kernel_socket.c
index 9c3d9adefbc96cde7887e6a73eeda9255d6ee25f..dcc22d2162ff67cc28afe2577f2ef1b486e40514 100644 (file)
@@ -48,6 +48,7 @@
 #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;
 
@@ -277,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 */
 
@@ -326,7 +332,7 @@ static int ifan_read(struct if_announcemsghdr *ifan)
                                __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);
@@ -1135,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 */
@@ -1242,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)
@@ -1389,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) {
@@ -1396,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.
@@ -1414,7 +1429,7 @@ void kernel_init(struct zebra_ns *zns)
        routing_socket(zns);
 }
 
-void kernel_terminate(struct zebra_ns *zns)
+void kernel_terminate(struct zebra_ns *zns, bool complete)
 {
        return;
 }