]>
Commit | Line | Data |
---|---|---|
be0dba35 RW |
1 | #include <zebra.h> |
2 | #include "zebra/rt.h" | |
3 | #include "zebra/rt_netlink.h" | |
4 | #include "zebra/zebra_mpls.h" | |
5 | ||
6 | /* | |
7 | * Install Label Forwarding entry into the kernel. | |
8 | */ | |
9 | int | |
10 | kernel_add_lsp (zebra_lsp_t *lsp) | |
11 | { | |
12 | int ret; | |
13 | ||
14 | if (!lsp || !lsp->best_nhlfe) // unexpected | |
15 | return -1; | |
16 | ||
17 | UNSET_FLAG (lsp->flags, LSP_FLAG_CHANGED); | |
18 | ret = netlink_mpls_multipath (RTM_NEWROUTE, lsp); | |
19 | if (!ret) | |
20 | SET_FLAG (lsp->flags, LSP_FLAG_INSTALLED); | |
21 | else | |
22 | clear_nhlfe_installed (lsp); | |
23 | ||
24 | return ret; | |
25 | } | |
26 | ||
27 | /* | |
28 | * Update Label Forwarding entry in the kernel. This means that the Label | |
29 | * forwarding entry is already installed and needs an update - either a new | |
30 | * path is to be added, an installed path has changed (e.g., outgoing label) | |
31 | * or an installed path (but not all paths) has to be removed. | |
32 | * TODO: Performs a DEL followed by ADD now, need to change to REPLACE. Note | |
33 | * that REPLACE was originally implemented for IPv4 nexthops but removed as | |
34 | * it was not functioning when moving from swap to PHP as that was signaled | |
35 | * through the metric field (before kernel-MPLS). This shouldn't be an issue | |
36 | * any longer, so REPLACE can be reintroduced. | |
37 | */ | |
38 | int | |
39 | kernel_upd_lsp (zebra_lsp_t *lsp) | |
40 | { | |
41 | int ret; | |
42 | ||
43 | if (!lsp || !lsp->best_nhlfe) // unexpected | |
44 | return -1; | |
45 | ||
46 | UNSET_FLAG (lsp->flags, LSP_FLAG_CHANGED); | |
47 | ||
48 | /* First issue a DEL and clear the installed flag. */ | |
49 | netlink_mpls_multipath (RTM_DELROUTE, lsp); | |
50 | UNSET_FLAG (lsp->flags, LSP_FLAG_INSTALLED); | |
51 | ||
52 | /* Then issue an ADD. */ | |
53 | ret = netlink_mpls_multipath (RTM_NEWROUTE, lsp); | |
54 | if (!ret) | |
55 | SET_FLAG (lsp->flags, LSP_FLAG_INSTALLED); | |
56 | else | |
57 | clear_nhlfe_installed (lsp); | |
58 | ||
59 | return ret; | |
60 | } | |
61 | ||
62 | /* | |
63 | * Delete Label Forwarding entry from the kernel. | |
64 | */ | |
65 | int | |
66 | kernel_del_lsp (zebra_lsp_t *lsp) | |
67 | { | |
68 | if (!lsp) // unexpected | |
69 | return -1; | |
70 | ||
71 | if (CHECK_FLAG (lsp->flags, LSP_FLAG_INSTALLED)) | |
72 | { | |
73 | netlink_mpls_multipath (RTM_DELROUTE, lsp); | |
74 | UNSET_FLAG (lsp->flags, LSP_FLAG_INSTALLED); | |
75 | } | |
76 | ||
77 | return 0; | |
78 | } | |
d3e2c74a RW |
79 | |
80 | void mpls_kernel_init (void) {}; |