Skip to content

Commit

Permalink
Merge branch 'master' into stylechecker
Browse files Browse the repository at this point in the history
  • Loading branch information
qlyoung committed Feb 23, 2018
2 parents 2580e72 + fb444ef commit 6b1ebf3
Show file tree
Hide file tree
Showing 269 changed files with 21,228 additions and 4,214 deletions.
2 changes: 2 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,5 @@ ForEachMacros:
- SUBGRP_FOREACH_ADJ_SAFE
- AF_FOREACH
- FOREACH_AFI_SAFI
# ospfd
- LSDB_LOOP
12 changes: 7 additions & 5 deletions README
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
FRRouting is free software that manages various IPv4 and IPv6 routing
protocols.
FRRouting is free software that implements and manages various IPv4 and IPv6
routing protocols.

Currently FRRouting supports BGP4, BGP4+, OSPFv2, OSPFv3, RIPv1,
RIPv2, RIPng, PIM-SM/MSDP and LDP as well as very early support for IS-IS,
EIGRP and NHRP.
Currently FRRouting supports BGP4, BGP4+, OSPFv2, OSPFv3, RIPv1, RIPv2, RIPng,
IS-IS, PIM-SM/MSDP, LDP and Babel as well as very early support for EIGRP and
NHRP.

See the file REPORTING-BUGS to report bugs.

See COMMUNITY.md for information on contributing.

Free RRRouting is free software. See the file COPYING for copying conditions.

Public email discussion can be found at https://lists.frrouting.org/listinfo
Expand Down
4 changes: 2 additions & 2 deletions babeld/kernel.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ zebra_route(int add, int family, const unsigned char *pref, unsigned short plen,
SET_FLAG(api.message, ZAPI_MESSAGE_NEXTHOP);
api.nexthop_num = 1;
api_nh->ifindex = ifindex;

switch (family) {
api_nh->vrf_id = VRF_DEFAULT;
switch (family) {
case AF_INET:
uchar_to_inaddr(&api_nh->gate.ipv4, gate);
if (IPV4_ADDR_SAME (&api_nh->gate.ipv4, &quagga_prefix.u.prefix4) &&
Expand Down
1 change: 1 addition & 0 deletions bgpd/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ dist_examples_DATA = bgpd.conf.sample bgpd.conf.sample2 \
bgpd.conf.vnc.sample

bgp_vty.o: bgp_vty_clippy.c
bgp_route.o: bgp_route_clippy.c

EXTRA_DIST = BGP4-MIB.txt

6 changes: 0 additions & 6 deletions bgpd/bgp_advertise.c
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,6 @@ void bgp_sync_init(struct peer *peer)
BGP_ADV_FIFO_INIT(&sync->withdraw);
BGP_ADV_FIFO_INIT(&sync->withdraw_low);
peer->sync[afi][safi] = sync;
peer->hash[afi][safi] = hash_create(baa_hash_key, baa_hash_cmp,
"BGP Sync Hash");
}
}

Expand All @@ -260,9 +258,5 @@ void bgp_sync_delete(struct peer *peer)
if (peer->sync[afi][safi])
XFREE(MTYPE_BGP_SYNCHRONISE, peer->sync[afi][safi]);
peer->sync[afi][safi] = NULL;

if (peer->hash[afi][safi])
hash_free(peer->hash[afi][safi]);
peer->hash[afi][safi] = NULL;
}
}
78 changes: 49 additions & 29 deletions bgpd/bgp_attr.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ static const struct message attr_str[] = {
{BGP_ATTR_AS4_PATH, "AS4_PATH"},
{BGP_ATTR_AS4_AGGREGATOR, "AS4_AGGREGATOR"},
{BGP_ATTR_AS_PATHLIMIT, "AS_PATHLIMIT"},
{BGP_ATTR_PMSI_TUNNEL, "PMSI_TUNNEL_ATTRIBUTE"},
{BGP_ATTR_ENCAP, "ENCAP"},
#if ENABLE_BGP_VNC
{BGP_ATTR_VNC, "VNC"},
Expand Down Expand Up @@ -492,19 +493,13 @@ unsigned int attrhash_key_make(void *p)
const struct attr *attr = (struct attr *)p;
uint32_t key = 0;
#define MIX(val) key = jhash_1word(val, key)
#define MIX3(a, b, c) key = jhash_3words((a), (b), (c), key)

MIX(attr->origin);
MIX(attr->nexthop.s_addr);
MIX(attr->med);
MIX(attr->local_pref);
MIX(attr->aggregator_as);
MIX(attr->aggregator_addr.s_addr);
MIX(attr->weight);
MIX(attr->mp_nexthop_global_in.s_addr);
MIX(attr->originator_id.s_addr);
MIX(attr->tag);
MIX(attr->label);
MIX(attr->label_index);
MIX3(attr->origin, attr->nexthop.s_addr, attr->med);
MIX3(attr->local_pref, attr->aggregator_as, attr->aggregator_addr.s_addr);
MIX3(attr->weight, attr->mp_nexthop_global_in.s_addr,
attr->originator_id.s_addr);
MIX3(attr->tag, attr->label, attr->label_index);

if (attr->aspath)
MIX(aspath_key_make(attr->aspath));
Expand Down Expand Up @@ -550,12 +545,6 @@ int attrhash_cmp(const void *p1, const void *p2)
&& attr1->tag == attr2->tag
&& attr1->label_index == attr2->label_index
&& attr1->mp_nexthop_len == attr2->mp_nexthop_len
&& IPV6_ADDR_SAME(&attr1->mp_nexthop_global,
&attr2->mp_nexthop_global)
&& IPV6_ADDR_SAME(&attr1->mp_nexthop_local,
&attr2->mp_nexthop_local)
&& IPV4_ADDR_SAME(&attr1->mp_nexthop_global_in,
&attr2->mp_nexthop_global_in)
&& attr1->ecommunity == attr2->ecommunity
&& attr1->lcommunity == attr2->lcommunity
&& attr1->cluster == attr2->cluster
Expand All @@ -565,6 +554,12 @@ int attrhash_cmp(const void *p1, const void *p2)
#if ENABLE_BGP_VNC
&& encap_same(attr1->vnc_subtlvs, attr2->vnc_subtlvs)
#endif
&& IPV6_ADDR_SAME(&attr1->mp_nexthop_global,
&attr2->mp_nexthop_global)
&& IPV6_ADDR_SAME(&attr1->mp_nexthop_local,
&attr2->mp_nexthop_local)
&& IPV4_ADDR_SAME(&attr1->mp_nexthop_global_in,
&attr2->mp_nexthop_global_in)
&& IPV4_ADDR_SAME(&attr1->originator_id,
&attr2->originator_id)
&& overlay_index_same(attr1, attr2))
Expand Down Expand Up @@ -1040,6 +1035,8 @@ const u_int8_t attr_flags_values[] = {
BGP_ATTR_FLAG_OPTIONAL | BGP_ATTR_FLAG_TRANS,
[BGP_ATTR_AS4_AGGREGATOR] =
BGP_ATTR_FLAG_OPTIONAL | BGP_ATTR_FLAG_TRANS,
[BGP_ATTR_PMSI_TUNNEL] =
BGP_ATTR_FLAG_OPTIONAL | BGP_ATTR_FLAG_TRANS,
[BGP_ATTR_LARGE_COMMUNITIES] =
BGP_ATTR_FLAG_OPTIONAL | BGP_ATTR_FLAG_TRANS,
[BGP_ATTR_PREFIX_SID] =
Expand Down Expand Up @@ -1879,6 +1876,12 @@ bgp_attr_ext_communities(struct bgp_attr_parser_args *args)
attr->mm_seqnum = bgp_attr_mac_mobility_seqnum(attr, &sticky);
attr->sticky = sticky;

/* Check if this is a Gateway MAC-IP advertisement */
attr->default_gw = bgp_attr_default_gw(attr);

/* Extract the Rmac, if any */
bgp_attr_rmac(attr, &attr->rmac);

return BGP_ATTR_PARSE_PROCEED;
}

Expand Down Expand Up @@ -2698,8 +2701,9 @@ size_t bgp_packet_mpattr_start(struct stream *s, struct peer *peer, afi_t afi,

void bgp_packet_mpattr_prefix(struct stream *s, afi_t afi, safi_t safi,
struct prefix *p, struct prefix_rd *prd,
mpls_label_t *label, int addpath_encode,
u_int32_t addpath_tx_id, struct attr *attr)
mpls_label_t *label, u_int32_t num_labels,
int addpath_encode, u_int32_t addpath_tx_id,
struct attr *attr)
{
if (safi == SAFI_MPLS_VPN) {
if (addpath_encode)
Expand All @@ -2711,8 +2715,8 @@ void bgp_packet_mpattr_prefix(struct stream *s, afi_t afi, safi_t safi,
stream_put(s, &p->u.prefix, PSIZE(p->prefixlen));
} else if (afi == AFI_L2VPN && safi == SAFI_EVPN) {
/* EVPN prefix - contents depend on type */
bgp_evpn_encode_prefix(s, p, prd, label, attr, addpath_encode,
addpath_tx_id);
bgp_evpn_encode_prefix(s, p, prd, label, num_labels,
attr, addpath_encode, addpath_tx_id);
} else if (safi == SAFI_LABELED_UNICAST) {
/* Prefix write with label. */
stream_put_labeled_prefix(s, p, label);
Expand Down Expand Up @@ -2840,8 +2844,8 @@ bgp_size_t bgp_packet_attribute(struct bgp *bgp, struct peer *peer,
struct bpacket_attr_vec_arr *vecarr,
struct prefix *p, afi_t afi, safi_t safi,
struct peer *from, struct prefix_rd *prd,
mpls_label_t *label, int addpath_encode,
u_int32_t addpath_tx_id)
mpls_label_t *label, u_int32_t num_labels,
int addpath_encode, u_int32_t addpath_tx_id)
{
size_t cp;
size_t aspath_sizep;
Expand All @@ -2863,7 +2867,8 @@ bgp_size_t bgp_packet_attribute(struct bgp *bgp, struct peer *peer,

mpattrlen_pos = bgp_packet_mpattr_start(s, peer, afi, safi,
vecarr, attr);
bgp_packet_mpattr_prefix(s, afi, safi, p, prd, label,
bgp_packet_mpattr_prefix(s, afi, safi, p, prd,
label, num_labels,
addpath_encode, addpath_tx_id, attr);
bgp_packet_mpattr_end(s, mpattrlen_pos);
}
Expand Down Expand Up @@ -3252,6 +3257,17 @@ bgp_size_t bgp_packet_attribute(struct bgp *bgp, struct peer *peer,
#endif
}

/* PMSI Tunnel */
if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_PMSI_TUNNEL)) {
stream_putc(s, BGP_ATTR_FLAG_OPTIONAL | BGP_ATTR_FLAG_TRANS);
stream_putc(s, BGP_ATTR_PMSI_TUNNEL);
stream_putc(s, 9); // Length
stream_putc(s, 0); // Flags
stream_putc(s, 6); // Tunnel type: Ingress Replication (6)
stream_put(s, &(attr->label), BGP_LABEL_BYTES); // MPLS Label / VXLAN VNI
stream_put_ipv4(s, attr->nexthop.s_addr); // Unicast tunnel endpoint IP address
}

/* Unknown transit attribute. */
if (attr->transit)
stream_put(s, attr->transit->val, attr->transit->length);
Expand Down Expand Up @@ -3284,15 +3300,19 @@ size_t bgp_packet_mpunreach_start(struct stream *s, afi_t afi, safi_t safi)

void bgp_packet_mpunreach_prefix(struct stream *s, struct prefix *p, afi_t afi,
safi_t safi, struct prefix_rd *prd,
mpls_label_t *label, int addpath_encode,
u_int32_t addpath_tx_id, struct attr *attr)
mpls_label_t *label, u_int32_t num_labels,
int addpath_encode, u_int32_t addpath_tx_id,
struct attr *attr)
{
u_char wlabel[3] = {0x80, 0x00, 0x00};

if (safi == SAFI_LABELED_UNICAST)
if (safi == SAFI_LABELED_UNICAST) {
label = (mpls_label_t *)wlabel;
num_labels = 1;
}

return bgp_packet_mpattr_prefix(s, afi, safi, p, prd, label,
return bgp_packet_mpattr_prefix(s, afi, safi, p, prd,
label, num_labels,
addpath_encode, addpath_tx_id, attr);
}

Expand Down
15 changes: 12 additions & 3 deletions bgpd/bgp_attr.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@ struct attr {
/* Static MAC for EVPN */
u_char sticky;

/* Flag for default gateway extended community in EVPN */
u_char default_gw;

/* route tag */
route_tag_t tag;

Expand All @@ -182,6 +185,9 @@ struct attr {

/* EVPN MAC Mobility sequence number, if any. */
u_int32_t mm_seqnum;

/* EVPN local router-mac */
struct ethaddr rmac;
};

/* rmap_change_flags definition */
Expand Down Expand Up @@ -254,7 +260,8 @@ extern bgp_size_t bgp_packet_attribute(struct bgp *bgp, struct peer *,
struct bpacket_attr_vec_arr *vecarr,
struct prefix *, afi_t, safi_t,
struct peer *, struct prefix_rd *,
mpls_label_t *, int, u_int32_t);
mpls_label_t *, u_int32_t,
int, u_int32_t);
extern void bgp_dump_routes_attr(struct stream *, struct attr *,
struct prefix *);
extern int attrhash_cmp(const void *, const void *);
Expand Down Expand Up @@ -302,7 +309,8 @@ extern size_t bgp_packet_mpattr_start(struct stream *s, struct peer *peer,
struct attr *attr);
extern void bgp_packet_mpattr_prefix(struct stream *s, afi_t afi, safi_t safi,
struct prefix *p, struct prefix_rd *prd,
mpls_label_t *label, int addpath_encode,
mpls_label_t *label, u_int32_t num_labels,
int addpath_encode,
u_int32_t addpath_tx_id, struct attr *);
extern size_t bgp_packet_mpattr_prefix_size(afi_t afi, safi_t safi,
struct prefix *p);
Expand All @@ -312,7 +320,8 @@ extern size_t bgp_packet_mpunreach_start(struct stream *s, afi_t afi,
safi_t safi);
extern void bgp_packet_mpunreach_prefix(struct stream *s, struct prefix *p,
afi_t afi, safi_t safi,
struct prefix_rd *prd, mpls_label_t *,
struct prefix_rd *prd,
mpls_label_t *, u_int32_t,
int, u_int32_t, struct attr *);
extern void bgp_packet_mpunreach_end(struct stream *s, size_t attrlen_pnt);

Expand Down
59 changes: 59 additions & 0 deletions bgpd/bgp_attr_evpn.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,65 @@ char *ecom_mac2str(char *ecom_mac)
return prefix_mac2str((struct ethaddr *)en, NULL, 0);
}

/* Fetch router-mac from extended community */
void bgp_attr_rmac(struct attr *attr,
struct ethaddr *rmac)
{
int i = 0;
struct ecommunity *ecom;

ecom = attr->ecommunity;
if (!ecom || !ecom->size)
return;

/* If there is a router mac extended community, set RMAC in attr */
for (i = 0; i < ecom->size; i++) {
u_char *pnt = NULL;
u_char type = 0;
u_char sub_type = 0;

pnt = (ecom->val + (i * ECOMMUNITY_SIZE));
type = *pnt++;
sub_type = *pnt++;

if (!(type == ECOMMUNITY_ENCODE_EVPN &&
sub_type == ECOMMUNITY_EVPN_SUBTYPE_ROUTERMAC))
continue;

memcpy(rmac, pnt, ETH_ALEN);
}
}

/*
* return true if attr contains default gw extended community
*/
uint8_t bgp_attr_default_gw(struct attr *attr)
{
struct ecommunity *ecom;
int i;

ecom = attr->ecommunity;
if (!ecom || !ecom->size)
return 0;

/* If there is a default gw extendd community return true otherwise
* return 0 */
for (i = 0; i < ecom->size; i++) {
u_char *pnt;
u_char type, sub_type;

pnt = (ecom->val + (i * ECOMMUNITY_SIZE));
type = *pnt++;
sub_type = *pnt++;

if ((type == ECOMMUNITY_ENCODE_OPAQUE
&& sub_type == ECOMMUNITY_EVPN_SUBTYPE_DEF_GW))
return 1;
}

return 0;
}

/*
* Fetch and return the sequence number from MAC Mobility extended
* community, if present, else 0.
Expand Down
3 changes: 2 additions & 1 deletion bgpd/bgp_attr_evpn.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,9 @@ extern void bgp_add_routermac_ecom(struct attr *attr,
struct ethaddr *routermac);
extern int bgp_build_evpn_prefix(int type, uint32_t eth_tag,
struct prefix *dst);

extern void bgp_attr_rmac(struct attr *attr, struct ethaddr *rmac);
extern u_int32_t bgp_attr_mac_mobility_seqnum(struct attr *attr,
u_char *sticky);
extern uint8_t bgp_attr_default_gw(struct attr *attr);

#endif /* _QUAGGA_BGP_ATTR_EVPN_H */
4 changes: 2 additions & 2 deletions bgpd/bgp_bfd.c
Original file line number Diff line number Diff line change
Expand Up @@ -302,13 +302,13 @@ static int bgp_bfd_dest_update(int command, struct zclient *zclient,
prefix2str(&dp, buf[0], sizeof(buf[0]));
if (ifp) {
zlog_debug(
"Zebra: vrf %d interface %s bfd destination %s %s",
"Zebra: vrf %u interface %s bfd destination %s %s",
vrf_id, ifp->name, buf[0],
bfd_get_status_str(status));
} else {
prefix2str(&sp, buf[1], sizeof(buf[1]));
zlog_debug(
"Zebra: vrf %d source %s bfd destination %s %s",
"Zebra: vrf %u source %s bfd destination %s %s",
vrf_id, buf[1], buf[0],
bfd_get_status_str(status));
}
Expand Down
Loading

0 comments on commit 6b1ebf3

Please sign in to comment.