/src/frr/zebra/zebra_ptm_redistribute.c
Line | Count | Source |
1 | | // SPDX-License-Identifier: GPL-2.0-or-later |
2 | | /** |
3 | | * @copyright Copyright (C) 2015 Cumulus Networks, Inc. |
4 | | */ |
5 | | |
6 | | #include <zebra.h> |
7 | | #include "prefix.h" |
8 | | #include "vty.h" |
9 | | #include "stream.h" |
10 | | #include "zebra/zebra_router.h" |
11 | | #include "zebra/zapi_msg.h" |
12 | | #include "zebra/zebra_ptm.h" |
13 | | #include "zebra/zebra_ptm_redistribute.h" |
14 | | |
15 | | static int zsend_interface_bfd_update(int cmd, struct zserv *client, |
16 | | struct interface *ifp, struct prefix *dp, |
17 | | struct prefix *sp, int status, |
18 | | vrf_id_t vrf_id) |
19 | 0 | { |
20 | 0 | int blen; |
21 | 0 | struct stream *s; |
22 | |
|
23 | 0 | s = stream_new(ZEBRA_MAX_PACKET_SIZ); |
24 | |
|
25 | 0 | zclient_create_header(s, cmd, vrf_id); |
26 | 0 | if (ifp) |
27 | 0 | stream_putl(s, ifp->ifindex); |
28 | 0 | else |
29 | 0 | stream_putl(s, 0); |
30 | | |
31 | | /* BFD destination prefix information. */ |
32 | 0 | stream_putc(s, dp->family); |
33 | 0 | blen = prefix_blen(dp); |
34 | 0 | stream_put(s, &dp->u.prefix, blen); |
35 | 0 | stream_putc(s, dp->prefixlen); |
36 | | |
37 | | /* BFD status */ |
38 | 0 | stream_putl(s, status); |
39 | | |
40 | | /* BFD source prefix information. */ |
41 | 0 | stream_putc(s, sp->family); |
42 | 0 | blen = prefix_blen(sp); |
43 | 0 | stream_put(s, &sp->u.prefix, blen); |
44 | 0 | stream_putc(s, sp->prefixlen); |
45 | | |
46 | | /* c-bit bullshit */ |
47 | 0 | stream_putc(s, 0); |
48 | | |
49 | | /* Write packet size. */ |
50 | 0 | stream_putw_at(s, 0, stream_get_endp(s)); |
51 | |
|
52 | 0 | client->if_bfd_cnt++; |
53 | 0 | return zserv_send_message(client, s); |
54 | 0 | } |
55 | | |
56 | | void zebra_interface_bfd_update(struct interface *ifp, struct prefix *dp, |
57 | | struct prefix *sp, int status, vrf_id_t vrf_id) |
58 | 0 | { |
59 | 0 | struct listnode *node, *nnode; |
60 | 0 | struct zserv *client; |
61 | |
|
62 | 0 | for (ALL_LIST_ELEMENTS(zrouter.client_list, node, nnode, client)) { |
63 | 0 | if (!IS_BFD_ENABLED_PROTOCOL(client->proto)) |
64 | 0 | continue; |
65 | | |
66 | | /* Notify to the protocol daemons. */ |
67 | 0 | zsend_interface_bfd_update(ZEBRA_INTERFACE_BFD_DEST_UPDATE, |
68 | 0 | client, ifp, dp, sp, status, vrf_id); |
69 | 0 | } |
70 | 0 | } |
71 | | |
72 | | static int zsend_bfd_peer_replay(int cmd, struct zserv *client) |
73 | 0 | { |
74 | 0 | struct stream *s; |
75 | |
|
76 | 0 | s = stream_new(ZEBRA_MAX_PACKET_SIZ); |
77 | |
|
78 | 0 | zclient_create_header(s, cmd, VRF_DEFAULT); |
79 | | |
80 | | /* Write packet size. */ |
81 | 0 | stream_putw_at(s, 0, stream_get_endp(s)); |
82 | |
|
83 | 0 | client->bfd_peer_replay_cnt++; |
84 | 0 | return zserv_send_message(client, s); |
85 | 0 | } |
86 | | |
87 | | void zebra_bfd_peer_replay_req(void) |
88 | 0 | { |
89 | 0 | struct listnode *node, *nnode; |
90 | 0 | struct zserv *client; |
91 | |
|
92 | 0 | for (ALL_LIST_ELEMENTS(zrouter.client_list, node, nnode, client)) { |
93 | 0 | if (!IS_BFD_ENABLED_PROTOCOL(client->proto)) |
94 | 0 | continue; |
95 | | |
96 | | /* Notify to the protocol daemons. */ |
97 | 0 | zsend_bfd_peer_replay(ZEBRA_BFD_DEST_REPLAY, client); |
98 | 0 | } |
99 | 0 | } |