1 /* E-VPN header for packet handling
2 * Copyright (C) 2016 6WIND
4 * This file is part of FRRouting.
6 * FRRouting 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
11 * FRRouting 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.
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
21 #ifndef _QUAGGA_BGP_EVPN_H
22 #define _QUAGGA_BGP_EVPN_H
27 #define EVPN_ROUTE_STRLEN 200 /* Must be >> MAC + IPv6 strings. */
29 static inline int is_evpn_enabled(void)
31 struct bgp
*bgp
= NULL
;
33 bgp
= bgp_get_default();
34 return bgp
? bgp
->advertise_all_vni
: 0;
37 static inline void vni2label(vni_t vni
, mpls_label_t
*label
)
39 u_char
*tag
= (u_char
*)label
;
41 tag
[0] = (vni
>> 16) & 0xFF;
42 tag
[1] = (vni
>> 8) & 0xFF;
46 static inline vni_t
label2vni(mpls_label_t
*label
)
48 u_char
*tag
= (u_char
*)label
;
51 vni
= ((u_int32_t
)*tag
++ << 16);
52 vni
|= (u_int32_t
)*tag
++ << 8;
53 vni
|= (u_int32_t
)(*tag
& 0xFF);
58 static inline int advertise_type5_routes(struct bgp
*bgp_vrf
,
65 CHECK_FLAG(bgp_vrf
->af_flags
[AFI_L2VPN
][SAFI_EVPN
],
66 BGP_L2VPN_EVPN_ADVERTISE_IPV4_UNICAST
))
70 CHECK_FLAG(bgp_vrf
->af_flags
[AFI_L2VPN
][SAFI_EVPN
],
71 BGP_L2VPN_EVPN_ADVERTISE_IPV6_UNICAST
))
77 extern void bgp_evpn_advertise_type5_route(struct bgp
*bgp_vrf
,
79 struct attr
*src_attr
, afi_t afi
,
81 extern void bgp_evpn_withdraw_type5_route(struct bgp
*bgp_vrf
, struct prefix
*p
,
82 afi_t afi
, safi_t safi
);
83 extern void bgp_evpn_withdraw_type5_routes(struct bgp
*bgp_vrf
, afi_t afi
,
85 extern void bgp_evpn_advertise_type5_routes(struct bgp
*bgp_vrf
, afi_t afi
,
87 extern void bgp_evpn_vrf_delete(struct bgp
*bgp_vrf
);
88 extern void bgp_evpn_handle_router_id_update(struct bgp
*bgp
, int withdraw
);
89 extern char *bgp_evpn_label2str(mpls_label_t
*label
, u_int32_t num_labels
,
91 extern char *bgp_evpn_route2str(struct prefix_evpn
*p
, char *buf
, int len
);
92 extern void bgp_evpn_route2json(struct prefix_evpn
*p
, json_object
*json
);
93 extern void bgp_evpn_encode_prefix(struct stream
*s
, struct prefix
*p
,
94 struct prefix_rd
*prd
, mpls_label_t
*label
,
95 u_int32_t num_labels
, struct attr
*attr
,
96 int addpath_encode
, u_int32_t addpath_tx_id
);
97 extern int bgp_nlri_parse_evpn(struct peer
*peer
, struct attr
*attr
,
98 struct bgp_nlri
*packet
, int withdraw
);
99 extern int bgp_evpn_import_route(struct bgp
*bgp
, afi_t afi
, safi_t safi
,
100 struct prefix
*p
, struct bgp_info
*ri
);
101 extern int bgp_evpn_unimport_route(struct bgp
*bgp
, afi_t afi
, safi_t safi
,
102 struct prefix
*p
, struct bgp_info
*ri
);
103 extern int bgp_filter_evpn_routes_upon_martian_nh_change(struct bgp
*bgp
);
104 extern int bgp_evpn_local_macip_del(struct bgp
*bgp
, vni_t vni
,
105 struct ethaddr
*mac
, struct ipaddr
*ip
);
106 extern int bgp_evpn_local_macip_add(struct bgp
*bgp
, vni_t vni
,
107 struct ethaddr
*mac
, struct ipaddr
*ip
,
109 extern int bgp_evpn_local_l3vni_add(vni_t vni
, vrf_id_t vrf_id
,
110 struct ethaddr
*rmac
,
111 struct in_addr originator_ip
, int filter
);
112 extern int bgp_evpn_local_l3vni_del(vni_t vni
, vrf_id_t vrf_id
);
113 extern int bgp_evpn_local_vni_del(struct bgp
*bgp
, vni_t vni
);
114 extern int bgp_evpn_local_vni_add(struct bgp
*bgp
, vni_t vni
,
115 struct in_addr originator_ip
,
116 vrf_id_t tenant_vrf_id
);
117 extern void bgp_evpn_cleanup_on_disable(struct bgp
*bgp
);
118 extern void bgp_evpn_cleanup(struct bgp
*bgp
);
119 extern void bgp_evpn_init(struct bgp
*bgp
);
121 #endif /* _QUAGGA_BGP_EVPN_H */