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