]> git.proxmox.com Git - mirror_frr.git/blobdiff - zebra/zebra_mpls_netlink.c
Merge pull request #13450 from patrasar/mld_core
[mirror_frr.git] / zebra / zebra_mpls_netlink.c
index c95a0216399cc703efd7a9b26f9af550966a757e..4bc676f3926e255883c290130e2b043bf2fabfa5 100644 (file)
@@ -1,21 +1,6 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /* MPLS forwarding table updates using netlink over GNU/Linux system.
  * Copyright (C) 2016  Cumulus Networks, Inc.
- *
- * This file is part of Quagga.
- *
- * Quagga is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2, or (at your option) any
- * later version.
- *
- * Quagga is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; see the file COPYING; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
 #include <zebra.h>
 #include "zebra/zebra_mpls.h"
 #include "zebra/kernel_netlink.h"
 
-/*
- * LSP forwarding update using dataplane context information.
- */
-enum zebra_dplane_result kernel_lsp_update(struct zebra_dplane_ctx *ctx)
+ssize_t netlink_lsp_msg_encoder(struct zebra_dplane_ctx *ctx, void *buf,
+                               size_t buflen)
 {
-       uint8_t nl_pkt[NL_PKT_BUF_SIZE];
-       ssize_t ret = -1;
        int cmd;
 
        /* Call to netlink layer based on type of update */
@@ -48,26 +29,21 @@ enum zebra_dplane_result kernel_lsp_update(struct zebra_dplane_ctx *ctx)
                        if (IS_ZEBRA_DEBUG_KERNEL || IS_ZEBRA_DEBUG_MPLS)
                                zlog_debug("LSP in-label %u: update fails, no best NHLFE",
                                           dplane_ctx_get_in_label(ctx));
-                       goto done;
+                       return -1;
                }
 
                cmd = RTM_NEWROUTE;
        } else
                /* Invalid op? */
-               goto done;
-
-       ret = netlink_mpls_multipath_msg_encode(cmd, ctx, nl_pkt,
-                                               sizeof(nl_pkt));
-       if (ret <= 0)
-               return ZEBRA_DPLANE_REQUEST_FAILURE;
-
-       ret = netlink_talk_info(netlink_talk_filter, (struct nlmsghdr *)nl_pkt,
-                               dplane_ctx_get_ns(ctx), 0);
+               return -1;
 
-done:
+       return netlink_mpls_multipath_msg_encode(cmd, ctx, buf, buflen);
+}
 
-       return (ret == 0 ?
-               ZEBRA_DPLANE_REQUEST_SUCCESS : ZEBRA_DPLANE_REQUEST_FAILURE);
+enum netlink_msg_status netlink_put_lsp_update_msg(struct nl_batch *bth,
+                                                  struct zebra_dplane_ctx *ctx)
+{
+       return netlink_batch_add_msg(bth, ctx, netlink_lsp_msg_encoder, false);
 }
 
 /*
@@ -75,9 +51,10 @@ done:
  * but note that the default has been to report 'success' for pw updates
  * on unsupported platforms.
  */
-enum zebra_dplane_result kernel_pw_update(struct zebra_dplane_ctx *ctx)
+enum netlink_msg_status netlink_put_pw_update_msg(struct nl_batch *bth,
+                                                 struct zebra_dplane_ctx *ctx)
 {
-       return ZEBRA_DPLANE_REQUEST_SUCCESS;
+       return FRR_NETLINK_SUCCESS;
 }
 
 int mpls_kernel_init(void)