]> git.proxmox.com Git - mirror_frr.git/blame - zebra/zebra_mpls_netlink.c
Merge pull request #5793 from ton31337/fix/formatting_show_bgp_summary_failed
[mirror_frr.git] / zebra / zebra_mpls_netlink.c
CommitLineData
3c3877cd
DL
1/* MPLS forwarding table updates using netlink over GNU/Linux system.
2 * Copyright (C) 2016 Cumulus Networks, Inc.
3 *
4 * This file is part of Quagga.
5 *
6 * Quagga is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2, or (at your option) any
9 * later version.
10 *
11 * Quagga is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
896014f4
DL
16 * You should have received a copy of the GNU General Public License along
17 * with this program; see the file COPYING; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
3c3877cd
DL
19 */
20
be0dba35 21#include <zebra.h>
ddfeb486
DL
22
23#ifdef HAVE_NETLINK
24
d37f4d6c 25#include "zebra/debug.h"
be0dba35
RW
26#include "zebra/rt.h"
27#include "zebra/rt_netlink.h"
28#include "zebra/zebra_mpls.h"
29
d37f4d6c
MS
30/*
31 * LSP forwarding update using dataplane context information.
32 */
16c628de
MS
33enum zebra_dplane_result kernel_lsp_update(struct zebra_dplane_ctx *ctx)
34{
d37f4d6c
MS
35 int cmd, ret = -1;
36
37 /* Call to netlink layer based on type of update */
38 if (dplane_ctx_get_op(ctx) == DPLANE_OP_LSP_DELETE) {
39 cmd = RTM_DELROUTE;
40 } else if (dplane_ctx_get_op(ctx) == DPLANE_OP_LSP_INSTALL ||
41 dplane_ctx_get_op(ctx) == DPLANE_OP_LSP_UPDATE) {
42
43 /* Validate */
44 if (dplane_ctx_get_best_nhlfe(ctx) == NULL) {
45 if (IS_ZEBRA_DEBUG_KERNEL || IS_ZEBRA_DEBUG_MPLS)
46 zlog_debug("LSP in-label %u: update fails, no best NHLFE",
47 dplane_ctx_get_in_label(ctx));
48 goto done;
49 }
50
51 cmd = RTM_NEWROUTE;
52 } else
53 /* Invalid op? */
54 goto done;
55
fc608372 56 ret = netlink_mpls_multipath(cmd, ctx);
d37f4d6c
MS
57
58done:
59
60 return (ret == 0 ?
61 ZEBRA_DPLANE_REQUEST_SUCCESS : ZEBRA_DPLANE_REQUEST_FAILURE);
16c628de
MS
62}
63
97d8d05a
MS
64/*
65 * Pseudowire update api - not supported by netlink as of 12/18,
66 * but note that the default has been to report 'success' for pw updates
67 * on unsupported platforms.
68 */
69enum zebra_dplane_result kernel_pw_update(struct zebra_dplane_ctx *ctx)
70{
71 return ZEBRA_DPLANE_REQUEST_SUCCESS;
72}
73
d62a17ae 74int mpls_kernel_init(void)
fe6c7157 75{
d62a17ae 76 struct stat st;
fe6c7157 77
d62a17ae 78 /*
79 * Check if the MPLS module is loaded in the kernel.
80 */
81 if (stat("/proc/sys/net/mpls", &st) != 0)
82 return -1;
fe6c7157 83
d62a17ae 84 return 0;
fe6c7157 85};
ddfeb486
DL
86
87#endif /* HAVE_NETLINK */