]> git.proxmox.com Git - mirror_frr.git/blame - bgpd/bgp_attr.h
Merge pull request #12920 from sri-mohan1/sri-mohan-ldp
[mirror_frr.git] / bgpd / bgp_attr.h
CommitLineData
acddc0ed 1// SPDX-License-Identifier: GPL-2.0-or-later
d62a17ae 2/* BGP attributes.
896014f4 3 * Copyright (C) 1996, 97, 98 Kunihiro Ishiguro
896014f4 4 */
718e3744 5
00d252cb 6#ifndef _QUAGGA_BGP_ATTR_H
7#define _QUAGGA_BGP_ATTR_H
8
9bedbb1e 9#include "mpls.h"
684a7227 10#include "bgp_attr_evpn.h"
f4bd90c5 11#include "bgpd/bgp_encap_types.h"
ef3e0d04 12#include "srte.h"
684a7227 13
718e3744 14/* Simple bit mapping. */
15#define BITMAP_NBBY 8
16
d62a17ae 17#define SET_BITMAP(MAP, NUM) \
18 SET_FLAG(MAP[(NUM) / BITMAP_NBBY], 1 << ((NUM) % BITMAP_NBBY))
718e3744 19
d62a17ae 20#define CHECK_BITMAP(MAP, NUM) \
21 CHECK_FLAG(MAP[(NUM) / BITMAP_NBBY], 1 << ((NUM) % BITMAP_NBBY))
718e3744 22
3b424979 23#define BGP_MED_MAX UINT32_MAX
24
718e3744 25/* BGP Attribute type range. */
26#define BGP_ATTR_TYPE_RANGE 256
27#define BGP_ATTR_BITMAP_SIZE (BGP_ATTR_TYPE_RANGE / BITMAP_NBBY)
28
29/* BGP Attribute flags. */
30#define BGP_ATTR_FLAG_OPTIONAL 0x80 /* Attribute is optional. */
31#define BGP_ATTR_FLAG_TRANS 0x40 /* Attribute is transitive. */
32#define BGP_ATTR_FLAG_PARTIAL 0x20 /* Attribute is partial. */
33#define BGP_ATTR_FLAG_EXTLEN 0x10 /* Extended length flag. */
34
35/* BGP attribute header must bigger than 2. */
370b64a2 36#define BGP_ATTR_MIN_LEN 3 /* Attribute flag, type length. */
03e214c8
PJ
37#define BGP_ATTR_DEFAULT_WEIGHT 32768
38
801a9bcc
DS
39/* Valid lengths for mp_nexthop_len */
40#define BGP_ATTR_NHLEN_IPV4 IPV4_MAX_BYTELEN
945c8fe9 41#define BGP_ATTR_NHLEN_VPNV4 8+IPV4_MAX_BYTELEN
801a9bcc
DS
42#define BGP_ATTR_NHLEN_IPV6_GLOBAL IPV6_MAX_BYTELEN
43#define BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL (IPV6_MAX_BYTELEN * 2)
945c8fe9
LB
44#define BGP_ATTR_NHLEN_VPNV6_GLOBAL 8+IPV6_MAX_BYTELEN
45#define BGP_ATTR_NHLEN_VPNV6_GLOBAL_AND_LL ((8+IPV6_MAX_BYTELEN) * 2)
801a9bcc 46
c5a543b4
DW
47/* Prefix SID types */
48#define BGP_PREFIX_SID_LABEL_INDEX 1
49#define BGP_PREFIX_SID_IPV6 2
50#define BGP_PREFIX_SID_ORIGINATOR_SRGB 3
e496b420 51#define BGP_PREFIX_SID_VPN_SID 4
c6ca155d
HS
52#define BGP_PREFIX_SID_SRV6_L3_SERVICE 5
53#define BGP_PREFIX_SID_SRV6_L2_SERVICE 6
c5a543b4
DW
54
55#define BGP_PREFIX_SID_LABEL_INDEX_LENGTH 7
56#define BGP_PREFIX_SID_IPV6_LENGTH 19
57#define BGP_PREFIX_SID_ORIGINATOR_SRGB_LENGTH 6
e496b420 58#define BGP_PREFIX_SID_VPN_SID_LENGTH 19
a3e3b5b0
RS
59
60/* SRv6 Service Sub-TLV types */
61#define BGP_PREFIX_SID_SRV6_L3_SERVICE_SID_INFO 1
62#define BGP_PREFIX_SID_SRV6_L3_SERVICE_SID_INFO_LENGTH 21
f4c89855 63
73604f82
RS
64/* SRv6 Service Data Sub-Sub-TLV types */
65#define BGP_PREFIX_SID_SRV6_L3_SERVICE_SID_STRUCTURE 1
a1a51008 66#define BGP_PREFIX_SID_SRV6_L3_SERVICE_SID_STRUCTURE_LENGTH 6
73604f82 67
7c312383
AD
68#define BGP_ATTR_NH_AFI(afi, attr) \
69 ((afi != AFI_L2VPN) ? afi : \
70 ((attr->mp_nexthop_len == BGP_ATTR_NHLEN_IPV4) ? AFI_IP : AFI_IP6))
71
7fd077aa 72/* PMSI tunnel types (RFC 6514) */
73
f4c89855 74struct bgp_attr_encap_subtlv {
d62a17ae 75 struct bgp_attr_encap_subtlv *next; /* for chaining */
76 /* Reference count of this attribute. */
77 unsigned long refcnt;
78 uint16_t type;
79 uint16_t length;
8c9cc7bb 80 uint8_t value[0]; /* will be extended */
f4c89855
LB
81};
82
49e5a4a0 83#ifdef ENABLE_BGP_VNC
65efcfce
LB
84/*
85 * old rfp<->rfapi representation
86 */
87struct bgp_tea_options {
d62a17ae 88 struct bgp_tea_options *next;
89 uint8_t options_count;
90 uint16_t options_length; /* each TLV may be 256 in length */
91 uint8_t type;
92 uint8_t length;
93 void *value; /* pointer to data */
65efcfce
LB
94};
95
96#endif
97
7fd077aa 98enum pta_type {
b7d08f5a 99 PMSI_TNLTYPE_NO_INFO = 0,
7fd077aa 100 PMSI_TNLTYPE_RSVP_TE_P2MP,
101 PMSI_TNLTYPE_MLDP_P2MP,
102 PMSI_TNLTYPE_PIM_SSM,
103 PMSI_TNLTYPE_PIM_SM,
104 PMSI_TNLTYPE_PIM_BIDIR,
105 PMSI_TNLTYPE_INGR_REPL,
106 PMSI_TNLTYPE_MLDP_MP2MP,
107 PMSI_TNLTYPE_MAX = PMSI_TNLTYPE_MLDP_MP2MP
108};
109
e496b420
HS
110/*
111 * Prefix-SID type-4
112 * SRv6-VPN-SID-TLV
113 * draft-dawra-idr-srv6-vpn-04
114 */
115struct bgp_attr_srv6_vpn {
116 unsigned long refcnt;
117 uint8_t sid_flags;
118 struct in6_addr sid;
119};
120
121/*
122 * Prefix-SID type-5
123 * SRv6-L3VPN-Service-TLV
124 * draft-dawra-idr-srv6-vpn-05
125 */
126struct bgp_attr_srv6_l3vpn {
127 unsigned long refcnt;
128 uint8_t sid_flags;
129 uint16_t endpoint_behavior;
130 struct in6_addr sid;
9299fd00
RS
131 uint8_t loc_block_len;
132 uint8_t loc_node_len;
133 uint8_t func_len;
134 uint8_t arg_len;
135 uint8_t transposition_len;
136 uint8_t transposition_offset;
e496b420
HS
137};
138
aadc0905 139/* BGP core attribute structure. */
d62a17ae 140struct attr {
141 /* AS Path structure */
142 struct aspath *aspath;
143
144 /* Community structure */
145 struct community *community;
146
147 /* Reference count of this attribute. */
148 unsigned long refcnt;
149
150 /* Flag of attribute is set or not. */
151 uint64_t flag;
152
153 /* Apart from in6_addr, the remaining static attributes */
154 struct in_addr nexthop;
d7c0a89a
QY
155 uint32_t med;
156 uint32_t local_pref;
d62a17ae 157 ifindex_t nh_ifindex;
158
159 /* Path origin attribute */
d7c0a89a 160 uint8_t origin;
d62a17ae 161
adde1db9
IR
162 /* PMSI tunnel type (RFC 6514). */
163 enum pta_type pmsi_tnl_type;
164
d62a17ae 165 /* has the route-map changed any attribute?
166 Used on the peer outbound side. */
d7c0a89a 167 uint32_t rmap_change_flags;
d62a17ae 168
169 /* Multi-Protocol Nexthop, AFI IPv6 */
170 struct in6_addr mp_nexthop_global;
171 struct in6_addr mp_nexthop_local;
172
77e62f2b 173 /* ifIndex corresponding to mp_nexthop_local. */
174 ifindex_t nh_lla_ifindex;
175
d62a17ae 176 /* Extended Communities attribute. */
177 struct ecommunity *ecommunity;
178
a2d3103a
IR
179 /* Extended Communities attribute. */
180 struct ecommunity *ipv6_ecommunity;
9a659715 181
d62a17ae 182 /* Large Communities attribute. */
183 struct lcommunity *lcommunity;
184
185 /* Route-Reflector Cluster attribute */
779fee93 186 struct cluster_list *cluster1;
d62a17ae 187
188 /* Unknown transitive attribute. */
189 struct transit *transit;
190
191 struct in_addr mp_nexthop_global_in;
192
193 /* Aggregator Router ID attribute */
194 struct in_addr aggregator_addr;
195
196 /* Route Reflector Originator attribute */
197 struct in_addr originator_id;
198
199 /* Local weight, not actually an attribute */
d7c0a89a 200 uint32_t weight;
d62a17ae 201
202 /* Aggregator ASN */
203 as_t aggregator_as;
204
205 /* MP Nexthop length */
d7c0a89a 206 uint8_t mp_nexthop_len;
d62a17ae 207
2bb8b49c
DS
208 /* MP Nexthop preference */
209 uint8_t mp_nexthop_prefer_global;
210
d62a17ae 211 /* Static MAC for EVPN */
d7c0a89a 212 uint8_t sticky;
d62a17ae 213
ead40654 214 /* Flag for default gateway extended community in EVPN */
d7c0a89a 215 uint8_t default_gw;
ead40654 216
68e33151
CS
217 /* NA router flag (R-bit) support in EVPN */
218 uint8_t router_flag;
219
7904e9fd
AK
220 /* ES info */
221 uint8_t es_flags;
222 /* Path is not "locally-active" on the advertising VTEP. This is
223 * translated into an ARP-ND ECOM.
224 */
225#define ATTR_ES_PROXY_ADVERT (1 << 0)
226 /* Destination ES is present locally. This flag is set on local
227 * paths and sync paths
228 */
229#define ATTR_ES_IS_LOCAL (1 << 1)
230 /* There are one or more non-best paths from ES peers. Note that
231 * this flag is only set on the local MAC-IP paths in the VNI
232 * route table (not set in the global routing table). And only
233 * non-proxy advertisements from an ES peer can result in this
234 * flag being set.
235 */
236#define ATTR_ES_PEER_ACTIVE (1 << 2)
237 /* There are one or more non-best proxy paths from ES peers */
238#define ATTR_ES_PEER_PROXY (1 << 3)
239 /* An ES peer has router bit set - only applicable if
240 * ATTR_ES_PEER_ACTIVE is set
241 */
242#define ATTR_ES_PEER_ROUTER (1 << 4)
243
58bff4d1
AK
244 /* These two flags are only set on L3 routes installed in a
245 * VRF as a result of EVPN MAC-IP route
246 * XXX - while splitting up per-family attrs these need to be
247 * classified as non-EVPN
248 */
249#define ATTR_ES_L3_NHG_USE (1 << 5)
250#define ATTR_ES_L3_NHG_ACTIVE (1 << 6)
251#define ATTR_ES_L3_NHG (ATTR_ES_L3_NHG_USE | ATTR_ES_L3_NHG_ACTIVE)
252
d62a17ae 253 /* route tag */
254 route_tag_t tag;
255
256 /* Label index */
d7c0a89a 257 uint32_t label_index;
d62a17ae 258
259 /* MPLS label */
260 mpls_label_t label;
261
e496b420
HS
262 /* SRv6 VPN SID */
263 struct bgp_attr_srv6_vpn *srv6_vpn;
264
265 /* SRv6 L3VPN SID */
266 struct bgp_attr_srv6_l3vpn *srv6_l3vpn;
267
d62a17ae 268 uint16_t encap_tunneltype; /* grr */
269 struct bgp_attr_encap_subtlv *encap_subtlvs; /* rfc5512 */
65efcfce 270
49e5a4a0 271#ifdef ENABLE_BGP_VNC
d62a17ae 272 struct bgp_attr_encap_subtlv *vnc_subtlvs; /* VNC-specific */
65efcfce 273#endif
d62a17ae 274 /* EVPN */
ea7741a0 275 struct bgp_route_evpn evpn_overlay;
128ea8ab 276
d62a17ae 277 /* EVPN MAC Mobility sequence number, if any. */
d7c0a89a 278 uint32_t mm_seqnum;
7904e9fd
AK
279 /* highest MM sequence number rxed in a MAC-IP route from an
280 * ES peer (this includes both proxy and non-proxy MAC-IP
281 * advertisements from ES peers).
282 * This is only applicable to local paths in the VNI routing
283 * table and derived from other imported/non-best paths.
284 */
285 uint32_t mm_sync_seqnum;
bc59a672
MK
286
287 /* EVPN local router-mac */
288 struct ethaddr rmac;
7b7d48e5
DS
289
290 /* Distance as applied by Route map */
291 uint8_t distance;
951745bd
PG
292
293 /* rmap set table */
294 uint32_t rmap_table_id;
d901dc13 295
296 /* Link bandwidth value, if any. */
297 uint32_t link_bw;
0a50c248
AK
298
299 /* EVPN ES */
300 esi_t esi;
ef3e0d04
SM
301
302 /* SR-TE Color */
303 uint32_t srte_color;
74e2bd89
AK
304
305 /* EVPN DF preference and algorithm for DF election on local ESs */
306 uint16_t df_pref;
307 uint8_t df_alg;
0789eb69
KM
308
309 /* Nexthop type */
310 enum nexthop_types_t nh_type;
311
312 /* If NEXTHOP_TYPE_BLACKHOLE, then blackhole type */
313 enum blackhole_type bh_type;
d864dd9e
EB
314
315 /* OTC value if set */
316 uint32_t otc;
97a52c82
DA
317
318 /* AIGP Metric */
319 uint64_t aigp_metric;
fb982c25
PJ
320};
321
3f9c7369 322/* rmap_change_flags definition */
3811f1e2 323#define BATTR_RMAP_IPV4_NHOP_CHANGED (1 << 0)
3f9c7369
DS
324#define BATTR_RMAP_NEXTHOP_PEER_ADDRESS (1 << 1)
325#define BATTR_REFLECTED (1 << 2)
316e074d 326#define BATTR_RMAP_NEXTHOP_UNCHANGED (1 << 3)
3811f1e2
DS
327#define BATTR_RMAP_IPV6_GLOBAL_NHOP_CHANGED (1 << 4)
328#define BATTR_RMAP_IPV6_LL_NHOP_CHANGED (1 << 5)
b2e03f7a 329#define BATTR_RMAP_IPV6_PREFER_GLOBAL_CHANGED (1 << 6)
7b651a32 330#define BATTR_RMAP_LINK_BW_SET (1 << 7)
1bb550b6 331#define BATTR_RMAP_L3VPN_ACCEPT_GRE (1 << 8)
6eeb9255
DA
332#define BATTR_RMAP_VPNV4_NHOP_CHANGED (1 << 9)
333#define BATTR_RMAP_VPNV6_GLOBAL_NHOP_CHANGED (1 << 10)
3f9c7369 334
718e3744 335/* Router Reflector related structure. */
d62a17ae 336struct cluster_list {
337 unsigned long refcnt;
338 int length;
339 struct in_addr *list;
718e3744 340};
341
342/* Unknown transit attribute. */
d62a17ae 343struct transit {
344 unsigned long refcnt;
345 int length;
d7c0a89a 346 uint8_t *val;
718e3744 347};
348
96099b40
DL
349/* "(void) 0" will generate a compiler error. this is a safety check to
350 * ensure we're not using a value that exceeds the bit size of attr->flag. */
996c9314
LB
351#define ATTR_FLAG_BIT(X) \
352 __builtin_choose_expr((X) >= 1 && (X) <= 64, 1ULL << ((X)-1), (void)0)
718e3744 353
d62a17ae 354#define BGP_CLUSTER_LIST_LENGTH(attr) \
355 (((attr)->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)) \
779fee93 356 ? bgp_attr_get_cluster((attr))->length \
d62a17ae 357 : 0)
5e242b0d 358
79288e4c 359enum bgp_attr_parse_ret {
d62a17ae 360 BGP_ATTR_PARSE_PROCEED = 0,
361 BGP_ATTR_PARSE_ERROR = -1,
362 BGP_ATTR_PARSE_WITHDRAW = -2,
f57000c0 363
d62a17ae 364 /* only used internally, send notify + convert to BGP_ATTR_PARSE_ERROR
682abee1 365 */
d62a17ae 366 BGP_ATTR_PARSE_ERROR_NOTIFYPLS = -3,
9b9df989 367 BGP_ATTR_PARSE_EOR = -4,
79288e4c 368};
b881c707 369
3f9c7369
DS
370struct bpacket_attr_vec_arr;
371
718e3744 372/* Prototypes. */
d62a17ae 373extern void bgp_attr_init(void);
374extern void bgp_attr_finish(void);
d7db24db
DS
375extern enum bgp_attr_parse_ret
376bgp_attr_parse(struct peer *peer, struct attr *attr, bgp_size_t size,
377 struct bgp_nlri *mp_update, struct bgp_nlri *mp_withdraw);
d62a17ae 378extern struct attr *bgp_attr_intern(struct attr *attr);
d7db24db
DS
379extern void bgp_attr_unintern_sub(struct attr *attr);
380extern void bgp_attr_unintern(struct attr **pattr);
381extern void bgp_attr_flush(struct attr *attr);
0f05ea43
DA
382extern struct attr *bgp_attr_default_set(struct attr *attr, struct bgp *bgp,
383 uint8_t origin);
5f040085
DS
384extern struct attr *bgp_attr_aggregate_intern(
385 struct bgp *bgp, uint8_t origin, struct aspath *aspath,
386 struct community *community, struct ecommunity *ecommunity,
387 struct lcommunity *lcommunity, struct bgp_aggregate *aggregate,
388 uint8_t atomic_aggregate, const struct prefix *p);
97a52c82
DA
389extern bgp_size_t bgp_packet_attribute(
390 struct bgp *bgp, struct peer *peer, struct stream *s, struct attr *attr,
391 struct bpacket_attr_vec_arr *vecarr, struct prefix *p, afi_t afi,
392 safi_t safi, struct peer *from, struct prefix_rd *prd,
393 mpls_label_t *label, uint32_t num_labels, bool addpath_capable,
394 uint32_t addpath_tx_id, struct bgp_path_info *bpi);
395extern void bgp_dump_routes_attr(struct stream *s, struct bgp_path_info *bpi,
bd494ec5 396 const struct prefix *p);
74df8d6d 397extern bool attrhash_cmp(const void *arg1, const void *arg2);
d7db24db
DS
398extern unsigned int attrhash_key_make(const void *p);
399extern void attr_show_all(struct vty *vty);
d62a17ae 400extern unsigned long int attr_count(void);
401extern unsigned long int attr_unknown_count(void);
a5c6a9b1 402extern void bgp_path_attribute_discard_vty(struct vty *vty, struct peer *peer,
b986d7f4 403 const char *discard_attrs, bool set);
e2863b4f
DA
404extern void bgp_path_attribute_withdraw_vty(struct vty *vty, struct peer *peer,
405 const char *withdraw_attrs,
406 bool set);
407extern enum bgp_attr_parse_ret bgp_attr_ignore(struct peer *peer, uint8_t type);
718e3744 408
409/* Cluster list prototypes. */
d7db24db
DS
410extern bool cluster_loop_check(struct cluster_list *cluster,
411 struct in_addr originator);
718e3744 412
835315bf
PJ
413/* Below exported for unit-test purposes only */
414struct bgp_attr_parser_args {
d62a17ae 415 struct peer *peer;
416 bgp_size_t length; /* attribute data length; */
417 bgp_size_t total; /* total length, inc header */
418 struct attr *attr;
d7c0a89a
QY
419 uint8_t type;
420 uint8_t flags;
421 uint8_t *startp;
835315bf 422};
d62a17ae 423extern int bgp_mp_reach_parse(struct bgp_attr_parser_args *args,
d7db24db 424 struct bgp_nlri *mp_update);
d62a17ae 425extern int bgp_mp_unreach_parse(struct bgp_attr_parser_args *args,
d7db24db 426 struct bgp_nlri *mp_withdraw);
79288e4c 427extern enum bgp_attr_parse_ret
45a06b11 428bgp_attr_prefix_sid(struct bgp_attr_parser_args *args);
03292809 429
f4c89855
LB
430extern struct bgp_attr_encap_subtlv *
431encap_tlv_dup(struct bgp_attr_encap_subtlv *orig);
432
d62a17ae 433extern void bgp_attr_flush_encap(struct attr *attr);
f4c89855 434
f4bd90c5
LK
435extern void bgp_attr_extcom_tunnel_type(struct attr *attr,
436 bgp_encap_types *tunnel_type);
437
8c71e481
PM
438/**
439 * Set of functions to encode MP_REACH_NLRI and MP_UNREACH_NLRI attributes.
440 * Typical call sequence is to call _start(), followed by multiple _prefix(),
441 * one for each NLRI that needs to be encoded into the UPDATE message, and
442 * finally the _end() function.
443 */
2b26882d 444extern size_t bgp_packet_mpattr_start(struct stream *s, struct peer *peer,
d62a17ae 445 afi_t afi, safi_t safi,
446 struct bpacket_attr_vec_arr *vecarr,
8c71e481
PM
447 struct attr *attr);
448extern void bgp_packet_mpattr_prefix(struct stream *s, afi_t afi, safi_t safi,
5f040085
DS
449 const struct prefix *p,
450 const struct prefix_rd *prd,
d7c0a89a 451 mpls_label_t *label, uint32_t num_labels,
be92fc9f
DA
452 bool addpath_capable,
453 uint32_t addpath_tx_id, struct attr *);
93b73dfa 454extern size_t bgp_packet_mpattr_prefix_size(afi_t afi, safi_t safi,
5f040085 455 const struct prefix *p);
8c71e481
PM
456extern void bgp_packet_mpattr_end(struct stream *s, size_t sizep);
457
d62a17ae 458extern size_t bgp_packet_mpunreach_start(struct stream *s, afi_t afi,
459 safi_t safi);
5f040085
DS
460extern void bgp_packet_mpunreach_prefix(
461 struct stream *s, const struct prefix *p, afi_t afi, safi_t safi,
462 const struct prefix_rd *prd, mpls_label_t *label, uint32_t num_labels,
be92fc9f 463 bool addpath_capable, uint32_t addpath_tx_id, struct attr *attr);
d62a17ae 464extern void bgp_packet_mpunreach_end(struct stream *s, size_t attrlen_pnt);
8c71e481 465
79288e4c
DA
466extern enum bgp_attr_parse_ret bgp_attr_nexthop_valid(struct peer *peer,
467 struct attr *attr);
9738e9aa 468
6dad190d
DA
469static inline bool bgp_rmap_nhop_changed(uint32_t out_rmap_flags,
470 uint32_t in_rmap_flags)
3811f1e2 471{
6eeb9255
DA
472 return ((CHECK_FLAG(out_rmap_flags, BATTR_RMAP_NEXTHOP_PEER_ADDRESS) ||
473 CHECK_FLAG(out_rmap_flags, BATTR_RMAP_NEXTHOP_UNCHANGED) ||
474 CHECK_FLAG(out_rmap_flags, BATTR_RMAP_IPV4_NHOP_CHANGED) ||
475 CHECK_FLAG(out_rmap_flags, BATTR_RMAP_VPNV4_NHOP_CHANGED) ||
476 CHECK_FLAG(out_rmap_flags,
477 BATTR_RMAP_VPNV6_GLOBAL_NHOP_CHANGED) ||
478 CHECK_FLAG(out_rmap_flags,
479 BATTR_RMAP_IPV6_GLOBAL_NHOP_CHANGED) ||
480 CHECK_FLAG(out_rmap_flags,
481 BATTR_RMAP_IPV6_PREFER_GLOBAL_CHANGED) ||
482 CHECK_FLAG(out_rmap_flags, BATTR_RMAP_IPV6_LL_NHOP_CHANGED) ||
483 CHECK_FLAG(in_rmap_flags, BATTR_RMAP_NEXTHOP_UNCHANGED))
6dad190d
DA
484 ? true
485 : false);
3811f1e2
DS
486}
487
d7c0a89a 488static inline uint32_t mac_mobility_seqnum(struct attr *attr)
128ea8ab 489{
d62a17ae 490 return (attr) ? attr->mm_seqnum : 0;
128ea8ab 491}
2a3f51cf 492
adde1db9 493static inline enum pta_type bgp_attr_get_pmsi_tnl_type(struct attr *attr)
2a3f51cf 494{
adde1db9 495 return attr->pmsi_tnl_type;
2a3f51cf
DS
496}
497
498static inline void bgp_attr_set_pmsi_tnl_type(struct attr *attr,
499 enum pta_type pmsi_tnl_type)
500{
adde1db9 501 attr->pmsi_tnl_type = pmsi_tnl_type;
2a3f51cf
DS
502}
503
b53e67a3
DA
504static inline struct ecommunity *
505bgp_attr_get_ecommunity(const struct attr *attr)
506{
507 return attr->ecommunity;
508}
509
510static inline void bgp_attr_set_ecommunity(struct attr *attr,
511 struct ecommunity *ecomm)
512{
513 attr->ecommunity = ecomm;
58cf5c08
DA
514
515 if (ecomm)
516 SET_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES));
517 else
518 UNSET_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES));
b53e67a3
DA
519}
520
1bcf3a96
DA
521static inline struct lcommunity *
522bgp_attr_get_lcommunity(const struct attr *attr)
523{
524 return attr->lcommunity;
525}
526
527static inline void bgp_attr_set_lcommunity(struct attr *attr,
528 struct lcommunity *lcomm)
529{
530 attr->lcommunity = lcomm;
9d34440b
DA
531
532 if (lcomm)
533 SET_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_LARGE_COMMUNITIES));
534 else
535 UNSET_FLAG(attr->flag,
536 ATTR_FLAG_BIT(BGP_ATTR_LARGE_COMMUNITIES));
1bcf3a96
DA
537}
538
9a706b42
DA
539static inline struct community *bgp_attr_get_community(const struct attr *attr)
540{
541 return attr->community;
542}
543
544static inline void bgp_attr_set_community(struct attr *attr,
545 struct community *comm)
546{
547 attr->community = comm;
9d34440b
DA
548
549 if (comm)
550 SET_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_COMMUNITIES));
551 else
552 UNSET_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_COMMUNITIES));
9a706b42
DA
553}
554
d04ac434
DS
555static inline struct ecommunity *
556bgp_attr_get_ipv6_ecommunity(const struct attr *attr)
557{
a2d3103a 558 return attr->ipv6_ecommunity;
d04ac434
DS
559}
560
561static inline void bgp_attr_set_ipv6_ecommunity(struct attr *attr,
562 struct ecommunity *ipv6_ecomm)
563{
a2d3103a 564 attr->ipv6_ecommunity = ipv6_ecomm;
58cf5c08
DA
565
566 if (ipv6_ecomm)
567 SET_FLAG(attr->flag,
568 ATTR_FLAG_BIT(BGP_ATTR_IPV6_EXT_COMMUNITIES));
569 else
570 UNSET_FLAG(attr->flag,
571 ATTR_FLAG_BIT(BGP_ATTR_IPV6_EXT_COMMUNITIES));
d04ac434
DS
572}
573
04fb21e2
DS
574static inline struct transit *bgp_attr_get_transit(const struct attr *attr)
575{
576 return attr->transit;
577}
578
579static inline void bgp_attr_set_transit(struct attr *attr,
580 struct transit *transit)
581{
582 attr->transit = transit;
583}
779fee93 584
97a52c82
DA
585static inline uint64_t bgp_attr_get_aigp_metric(const struct attr *attr)
586{
587 return attr->aigp_metric;
588}
589
590static inline void bgp_attr_set_aigp_metric(struct attr *attr, uint64_t aigp)
591{
592 attr->aigp_metric = aigp;
593
594 if (aigp)
595 attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_AIGP);
596}
597
779fee93
DS
598static inline struct cluster_list *bgp_attr_get_cluster(const struct attr *attr)
599{
600 return attr->cluster1;
601}
602
603static inline void bgp_attr_set_cluster(struct attr *attr,
604 struct cluster_list *cl)
605{
606 attr->cluster1 = cl;
607}
6c924775
DS
608
609static inline const struct bgp_route_evpn *
610bgp_attr_get_evpn_overlay(const struct attr *attr)
611{
612 return &attr->evpn_overlay;
613}
614
615static inline void bgp_attr_set_evpn_overlay(struct attr *attr,
616 struct bgp_route_evpn *eo)
617{
618 memcpy(&attr->evpn_overlay, eo, sizeof(struct bgp_route_evpn));
619}
620
91ebf12c
DS
621static inline struct bgp_attr_encap_subtlv *
622bgp_attr_get_vnc_subtlvs(const struct attr *attr)
623{
624#ifdef ENABLE_BGP_VNC
625 return attr->vnc_subtlvs;
626#else
627 return NULL;
628#endif
629}
630
631static inline void
632bgp_attr_set_vnc_subtlvs(struct attr *attr,
633 struct bgp_attr_encap_subtlv *vnc_subtlvs)
634{
635#ifdef ENABLE_BGP_VNC
636 attr->vnc_subtlvs = vnc_subtlvs;
637#endif
638}
639
00d252cb 640#endif /* _QUAGGA_BGP_ATTR_H */