]> git.proxmox.com Git - mirror_frr.git/blame - pimd/pim_msdp.h
pimd: Add (-) PRUNE(S,G,rpt) from interface determination.
[mirror_frr.git] / pimd / pim_msdp.h
CommitLineData
11128587 1/*
2a333e0f 2 * IP MSDP for Quagga
11128587 3 * Copyright (C) 2016 Cumulus Networks, Inc.
11128587
DS
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; see the file COPYING; if not, write to the
17 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
18 * MA 02110-1301 USA
19 */
20#ifndef PIM_MSDP_H
21#define PIM_MSDP_H
22
2a333e0f 23enum pim_msdp_peer_state {
24 PIM_MSDP_DISABLED,
25 PIM_MSDP_INACTIVE,
26 PIM_MSDP_LISTEN,
27 PIM_MSDP_CONNECTING,
28 PIM_MSDP_ESTABLISHED
29};
11128587 30
2a333e0f 31/* SA and KA TLVs are processed; rest ignored */
32enum pim_msdp_tlv {
33 PIM_MSDP_V4_SOURCE_ACTIVE = 1,
34 PIM_MSDP_V4_SOURCE_ACTIVE_REQUEST,
35 PIM_MSDP_V4_SOURCE_ACTIVE_RESPONSE,
36 PIM_MSDP_KEEPALIVE,
37 PIM_MSDP_RESERVED,
38 PIM_MSDP_TRACEROUTE_PROGRESS,
39 PIM_MSDP_TRACEROUTE_REPLY,
40};
41
42/* MSDP error codes */
43enum pim_msdp_err {
44 PIM_MSDP_ERR_NONE = 0,
45 PIM_MSDP_ERR_OOM = -1,
46 PIM_MSDP_ERR_PEER_EXISTS = -2,
47 PIM_MSDP_ERR_MAX_MESH_GROUPS = -3,
48 PIM_MSDP_ERR_NO_PEER = -4,
49};
50
51#define PIM_MSDP_STATE_STRLEN 16
52#define PIM_MSDP_PEER_KEY_STRLEN 80
3c72d654 53#define PIM_MSDP_SA_KEY_STRLEN 80
2a333e0f 54#define PIM_MSDP_UPTIME_STRLEN 80
55#define PIM_MSDP_TCP_PORT 639
56#define PIM_MSDP_SOCKET_SNDBUF_SIZE 65536
57
3c72d654 58enum pim_msdp_sa_flags {
59 PIM_MSDP_SAF_NONE = 0,
60 /* There are two cases where we can pickup an active source locally -
61 * 1. We are RP and got a source-register from the FHR
62 * 2. We are RP and FHR and learnt a new directly connected source on a
63 * DR interface */
64 PIM_MSDP_SAF_LOCAL = (1 << 0),
65 /* We got this in the MSDP SA TLV from a peer (and this passed peer-RPF
66 * checks) */
67 PIM_MSDP_SAF_PEER = (1 << 1),
68 PIM_MSDP_SAF_REF = (PIM_MSDP_SAF_LOCAL | PIM_MSDP_SAF_PEER),
69 PIM_MSDP_SAF_STALE = (1 << 2) /* local entries can get kicked out on
70 * misc pim events such as RP change */
71};
72
73struct pim_msdp_sa {
74 struct prefix_sg sg;
75 struct in_addr rp; /* Last RP address associated with this SA */
76 struct in_addr peer; /* last peer from who we heard this SA */
77 enum pim_msdp_sa_flags flags;
78
79 /* rfc-3618 is missing default value for SA-hold-down-Period. pulled
80 * this number from industry-standards */
81#define PIM_MSDP_SA_HOLD_TIME ((3*60)+30)
82 struct thread *sa_state_timer; // 5.6
83 int64_t uptime;
84};
85
2a333e0f 86enum pim_msdp_peer_flags {
87 PIM_MSDP_PEERF_NONE = 0,
3c72d654 88 PIM_MSDP_PEERF_LISTENER = (1 << 0),
89#define PIM_MSDP_PEER_IS_LISTENER(mp) (mp->flags & PIM_MSDP_PEERF_LISTENER)
90 PIM_MSDP_PEERF_SA_JUST_SENT = (1 << 1)
2a333e0f 91};
92
93struct pim_msdp_peer {
94 /* configuration */
95 struct in_addr local;
96 struct in_addr peer;
97 char *mesh_group_name;
98
99 /* state */
100 enum pim_msdp_peer_state state;
101 enum pim_msdp_peer_flags flags;
102
103 /* TCP socket info */
104 union sockunion su_local;
105 union sockunion su_peer;
106 int fd;
107
108 /* protocol timers */
109#define PIM_MSDP_PEER_HOLD_TIME 75
110 struct thread *hold_timer; // 5.4
111#define PIM_MSDP_PEER_KA_TIME 60
11128587 112 struct thread *ka_timer; // 5.5
2a333e0f 113#define PIM_MSDP_PEER_CONNECT_RETRY_TIME 30
114 struct thread *cr_timer; // 5.6
115
116 /* packet thread and buffers */
3c72d654 117 uint32_t packet_size;
2a333e0f 118 struct stream *ibuf;
119 struct stream_fifo *obuf;
120 struct thread *t_read;
121 struct thread *t_write;
122
123 /* stats */
124 uint32_t ka_tx_cnt;
125 uint32_t sa_tx_cnt;
126 uint32_t ka_rx_cnt;
127 uint32_t sa_rx_cnt;
128 uint32_t unk_rx_cnt;
129
130 /* timestamps */
131 int64_t uptime;
132};
133
134enum pim_msdp_flags {
135 PIM_MSDPF_NONE = 0,
3c72d654 136 PIM_MSDPF_ENABLE = (1 << 0),
137 PIM_MSDPF_LISTENER = (1 << 1)
2a333e0f 138};
139
140struct pim_msdp_listener {
141 int fd;
142 union sockunion su;
143 struct thread *thread;
144};
11128587 145
2a333e0f 146struct pim_msdp {
147 enum pim_msdp_flags flags;
2a333e0f 148 struct thread_master *master;
3c72d654 149 struct pim_msdp_listener listener;
2a333e0f 150 uint32_t rejected_accepts;
3c72d654 151
152 /* MSDP peer info */
153 struct hash *peer_hash;
154 struct list *peer_list;
155
156 /* MSDP active-source info */
157#define PIM_MSDP_SA_ADVERTISMENT_TIME 60
158 struct thread *sa_adv_timer; // 5.6
159 struct hash *sa_hash;
160 struct list *sa_list;
161 uint32_t local_cnt;
162
163 /* keep a scratch pad for building SA TLVs */
164 struct stream *work_obuf;
165
166 struct in_addr originator_id;
11128587
DS
167};
168
2a333e0f 169#define PIM_MSDP_PEER_READ_ON(mp) THREAD_READ_ON(msdp->master, mp->t_read, pim_msdp_read, mp, mp->fd);
170#define PIM_MSDP_PEER_WRITE_ON(mp) THREAD_WRITE_ON(msdp->master, mp->t_write, pim_msdp_write, mp, mp->fd);
171
172#define PIM_MSDP_PEER_READ_OFF(mp) THREAD_READ_OFF(mp->t_read)
173#define PIM_MSDP_PEER_WRITE_OFF(mp) THREAD_WRITE_OFF(mp->t_write)
174
175extern struct pim_msdp *msdp;
176void pim_msdp_init(struct thread_master *master);
177void pim_msdp_exit(void);
178enum pim_msdp_err pim_msdp_peer_add(struct in_addr peer, struct in_addr local, const char *mesh_group_name);
179enum pim_msdp_err pim_msdp_peer_del(struct in_addr peer_addr);
180char *pim_msdp_state_dump(enum pim_msdp_peer_state state, char *buf, int buf_size);
181struct pim_msdp_peer *pim_msdp_peer_find(struct in_addr peer_addr);
182void pim_msdp_peer_established(struct pim_msdp_peer *mp);
183void pim_msdp_peer_pkt_rxed(struct pim_msdp_peer *mp);
184void pim_msdp_peer_stop_tcp_conn(struct pim_msdp_peer *mp, bool chg_state);
185void pim_msdp_peer_reset_tcp_conn(struct pim_msdp_peer *mp, const char *rc_str);
186int pim_msdp_write(struct thread *thread);
187char *pim_msdp_peer_key_dump(struct pim_msdp_peer *mp, char *buf, int buf_size, bool long_format);
3c72d654 188int pim_msdp_config_write(struct vty *vty);
189void pim_msdp_peer_pkt_txed(struct pim_msdp_peer *mp);
190char *pim_msdp_sa_key_dump(struct pim_msdp_sa *sa, char *buf, int buf_size, bool long_format);
191void pim_msdp_sa_ref(struct pim_msdp_peer *mp, struct prefix_sg *sg, struct in_addr rp);
192void pim_msdp_sa_local_add(struct prefix_sg *sg);
193void pim_msdp_sa_local_del(struct prefix_sg *sg);
194void pim_msdp_i_am_rp_changed(void);
195bool pim_msdp_peer_rpf_check(struct pim_msdp_peer *mp, struct in_addr rp);
11128587 196#endif