bgpd: Refactor 'struct attr_extra' into 'struct attr'

Most of the attributes in 'struct attr_extra' allow for
the more interesting cases of using bgp.  The extra
overhead of managing it will induce errors as we add
more attributes and the extra memory overhead is
negligible on anything but full bgp feeds.

Additionally this greatly simplifies the code for
the handling of data.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>

bgpd: Fix missing label set

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
This commit is contained in:
Donald Sharp 2017-06-06 13:20:38 -04:00
parent d5424e5356
commit aadc090505
26 changed files with 923 additions and 1315 deletions

File diff suppressed because it is too large Load Diff

View File

@ -98,13 +98,35 @@ struct overlay_index
union gw_addr gw_ip;
};
/* Additional/uncommon BGP attributes.
* lazily allocated as and when a struct attr
* requires it.
*/
struct attr_extra
/* BGP core attribute structure. */
struct attr
{
/* Multi-Protocol Nexthop, AFI IPv6 */
/* AS Path structure */
struct aspath *aspath;
/* Community structure */
struct community *community;
/* Reference count of this attribute. */
unsigned long refcnt;
/* Flag of attribute is set or not. */
uint64_t flag;
/* Apart from in6_addr, the remaining static attributes */
struct in_addr nexthop;
u_int32_t med;
u_int32_t local_pref;
ifindex_t nh_ifindex;
/* Path origin attribute */
u_char origin;
/* has the route-map changed any attribute?
Used on the peer outbound side. */
u_int32_t rmap_change_flags;
/* Multi-Protocol Nexthop, AFI IPv6 */
struct in6_addr mp_nexthop_global;
struct in6_addr mp_nexthop_local;
@ -165,38 +187,6 @@ struct attr_extra
u_int32_t mm_seqnum;
};
/* BGP core attribute structure. */
struct attr
{
/* AS Path structure */
struct aspath *aspath;
/* Community structure */
struct community *community;
/* Lazily allocated pointer to extra attributes */
struct attr_extra *extra;
/* Reference count of this attribute. */
unsigned long refcnt;
/* Flag of attribute is set or not. */
uint64_t flag;
/* Apart from in6_addr, the remaining static attributes */
struct in_addr nexthop;
u_int32_t med;
u_int32_t local_pref;
ifindex_t nh_ifindex;
/* Path origin attribute */
u_char origin;
/* has the route-map changed any attribute?
Used on the peer outbound side. */
u_int32_t rmap_change_flags;
};
/* rmap_change_flags definition */
#define BATTR_RMAP_IPV4_NHOP_CHANGED (1 << 0)
#define BATTR_RMAP_NEXTHOP_PEER_ADDRESS (1 << 1)
@ -226,7 +216,7 @@ struct transit
#define BGP_CLUSTER_LIST_LENGTH(attr) \
(((attr)->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)) ? \
(attr)->extra->cluster->length : 0)
(attr)->cluster->length : 0)
typedef enum {
BGP_ATTR_PARSE_PROCEED = 0,
@ -245,8 +235,6 @@ extern void bgp_attr_finish (void);
extern bgp_attr_parse_ret_t bgp_attr_parse (struct peer *, struct attr *,
bgp_size_t, struct bgp_nlri *,
struct bgp_nlri *);
extern struct attr_extra *bgp_attr_extra_get (struct attr *);
extern void bgp_attr_extra_free (struct attr *);
extern void bgp_attr_dup (struct attr *, struct attr *);
extern void bgp_attr_deep_dup (struct attr *, struct attr *);
extern void bgp_attr_deep_free (struct attr *);
@ -342,7 +330,7 @@ bgp_rmap_nhop_changed(u_int32_t out_rmap_flags, u_int32_t in_rmap_flags)
static inline u_int32_t
mac_mobility_seqnum (struct attr *attr)
{
return (attr && attr->extra) ? attr->extra->mm_seqnum : 0;
return (attr) ? attr->mm_seqnum : 0;
}
#endif /* _QUAGGA_BGP_ATTR_H */

View File

@ -39,17 +39,14 @@ void bgp_add_routermac_ecom(struct attr *attr, struct ethaddr *routermac)
{
struct ecommunity_val routermac_ecom;
if (attr->extra)
{
memset(&routermac_ecom, 0, sizeof(struct ecommunity_val));
routermac_ecom.val[0] = ECOMMUNITY_ENCODE_EVPN;
routermac_ecom.val[1] = ECOMMUNITY_EVPN_SUBTYPE_ROUTERMAC;
memcpy(&routermac_ecom.val[2], routermac->octet, ETHER_ADDR_LEN);
if (!attr->extra->ecommunity)
attr->extra->ecommunity = ecommunity_new();
ecommunity_add_val(attr->extra->ecommunity, &routermac_ecom);
ecommunity_str (attr->extra->ecommunity);
}
memset(&routermac_ecom, 0, sizeof(struct ecommunity_val));
routermac_ecom.val[0] = ECOMMUNITY_ENCODE_EVPN;
routermac_ecom.val[1] = ECOMMUNITY_EVPN_SUBTYPE_ROUTERMAC;
memcpy(&routermac_ecom.val[2], routermac->octet, ETHER_ADDR_LEN);
if (!attr->ecommunity)
attr->ecommunity = ecommunity_new();
ecommunity_add_val(attr->ecommunity, &routermac_ecom);
ecommunity_str (attr->ecommunity);
}
/* converts to an esi
@ -119,7 +116,7 @@ bgp_attr_mac_mobility_seqnum (struct attr *attr, u_char *sticky)
int i;
u_char flags = 0;
ecom = attr->extra->ecommunity;
ecom = attr->ecommunity;
if (!ecom || !ecom->size)
return 0;

View File

@ -387,6 +387,8 @@ bgp_debug_peer_updout_enabled(char *host)
int
bgp_dump_attr (struct attr *attr, char *buf, size_t size)
{
char addrbuf[BUFSIZ];
if (! attr)
return 0;
@ -397,73 +399,68 @@ bgp_dump_attr (struct attr *attr, char *buf, size_t size)
snprintf (buf + strlen (buf), size - strlen (buf), ", origin %s",
bgp_origin_str[attr->origin]);
if (attr->extra)
{
char addrbuf[BUFSIZ];
/* Add MP case. */
if (attr->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL
|| attr->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL)
snprintf (buf + strlen (buf), size - strlen (buf), ", mp_nexthop %s",
inet_ntop (AF_INET6, &attr->mp_nexthop_global,
addrbuf, BUFSIZ));
/* Add MP case. */
if (attr->extra->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL
|| attr->extra->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL)
snprintf (buf + strlen (buf), size - strlen (buf), ", mp_nexthop %s",
inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global,
addrbuf, BUFSIZ));
if (attr->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL)
snprintf (buf + strlen (buf), size - strlen (buf), "(%s)",
inet_ntop (AF_INET6, &attr->mp_nexthop_local,
addrbuf, BUFSIZ));
if (attr->extra->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL)
snprintf (buf + strlen (buf), size - strlen (buf), "(%s)",
inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local,
addrbuf, BUFSIZ));
if (attr->extra->mp_nexthop_len == BGP_ATTR_NHLEN_IPV4)
snprintf (buf, size, "nexthop %s", inet_ntoa (attr->nexthop));
}
if (attr->mp_nexthop_len == BGP_ATTR_NHLEN_IPV4)
snprintf (buf, size, "nexthop %s", inet_ntoa (attr->nexthop));
if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)))
snprintf (buf + strlen (buf), size - strlen (buf), ", localpref %u",
attr->local_pref);
if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)))
if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)))
snprintf (buf + strlen (buf), size - strlen (buf), ", metric %u",
attr->med);
if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_COMMUNITIES)))
if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_COMMUNITIES)))
snprintf (buf + strlen (buf), size - strlen (buf), ", community %s",
community_str (attr->community));
if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_EXT_COMMUNITIES)))
snprintf (buf + strlen (buf), size - strlen (buf), ", extcommunity %s",
ecommunity_str (attr->extra->ecommunity));
ecommunity_str (attr->ecommunity));
if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE)))
snprintf (buf + strlen (buf), size - strlen (buf), ", atomic-aggregate");
if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR)))
snprintf (buf + strlen (buf), size - strlen (buf), ", aggregated by %u %s",
attr->extra->aggregator_as,
inet_ntoa (attr->extra->aggregator_addr));
attr->aggregator_as,
inet_ntoa (attr->aggregator_addr));
if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID)))
snprintf (buf + strlen (buf), size - strlen (buf), ", originator %s",
inet_ntoa (attr->extra->originator_id));
inet_ntoa (attr->originator_id));
if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_CLUSTER_LIST)))
{
int i;
snprintf (buf + strlen (buf), size - strlen (buf), ", clusterlist");
for (i = 0; i < attr->extra->cluster->length / 4; i++)
for (i = 0; i < attr->cluster->length / 4; i++)
snprintf (buf + strlen (buf), size - strlen (buf), " %s",
inet_ntoa (attr->extra->cluster->list[i]));
inet_ntoa (attr->cluster->list[i]));
}
if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_AS_PATH)))
if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_AS_PATH)))
snprintf (buf + strlen (buf), size - strlen (buf), ", path %s",
aspath_print (attr->aspath));
if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_PREFIX_SID)))
{
if (attr->extra->label_index != BGP_INVALID_LABEL_INDEX)
if (attr->label_index != BGP_INVALID_LABEL_INDEX)
snprintf (buf + strlen (buf), size - strlen (buf), ", label-index %u",
attr->extra->label_index);
attr->label_index);
}
if (strlen (buf) > 1)

View File

@ -238,7 +238,7 @@ subtlv_encode_remote_endpoint(
if (last) {\
last->next = new;\
} else {\
extra->encap_subtlvs = new;\
attr->encap_subtlvs = new;\
}\
last = new;\
}\
@ -249,13 +249,12 @@ bgp_encap_type_l2tpv3overip_to_tlv(
struct bgp_encap_type_l2tpv3_over_ip *bet, /* input structure */
struct attr *attr)
{
struct attr_extra *extra = bgp_attr_extra_get(attr);
struct bgp_attr_encap_subtlv *last;
/* advance to last subtlv */
for (last = extra->encap_subtlvs; last && last->next; last = last->next);
for (last = attr->encap_subtlvs; last && last->next; last = last->next);
extra->encap_tunneltype = BGP_ENCAP_TYPE_L2TPV3_OVER_IP;
attr->encap_tunneltype = BGP_ENCAP_TYPE_L2TPV3_OVER_IP;
assert(CHECK_FLAG(bet->valid_subtlvs, BGP_TEA_SUBTLV_ENCAP));
@ -270,13 +269,12 @@ bgp_encap_type_gre_to_tlv(
struct bgp_encap_type_gre *bet, /* input structure */
struct attr *attr)
{
struct attr_extra *extra = bgp_attr_extra_get(attr);
struct bgp_attr_encap_subtlv *last;
/* advance to last subtlv */
for (last = extra->encap_subtlvs; last && last->next; last = last->next);
for (last = attr->encap_subtlvs; last && last->next; last = last->next);
extra->encap_tunneltype = BGP_ENCAP_TYPE_GRE;
attr->encap_tunneltype = BGP_ENCAP_TYPE_GRE;
ENC_SUBTLV(BGP_TEA_SUBTLV_ENCAP, subtlv_encode_encap_gre, st_encap);
ENC_SUBTLV(BGP_TEA_SUBTLV_PROTO_TYPE, subtlv_encode_proto_type, st_proto);
@ -289,13 +287,12 @@ bgp_encap_type_ip_in_ip_to_tlv(
struct bgp_encap_type_ip_in_ip *bet, /* input structure */
struct attr *attr)
{
struct attr_extra *extra = bgp_attr_extra_get(attr);
struct bgp_attr_encap_subtlv *last;
/* advance to last subtlv */
for (last = extra->encap_subtlvs; last && last->next; last = last->next);
for (last = attr->encap_subtlvs; last && last->next; last = last->next);
extra->encap_tunneltype = BGP_ENCAP_TYPE_IP_IN_IP;
attr->encap_tunneltype = BGP_ENCAP_TYPE_IP_IN_IP;
ENC_SUBTLV(BGP_TEA_SUBTLV_PROTO_TYPE, subtlv_encode_proto_type, st_proto);
ENC_SUBTLV(BGP_TEA_SUBTLV_COLOR, subtlv_encode_color, st_color);
@ -307,13 +304,12 @@ bgp_encap_type_transmit_tunnel_endpoint(
struct bgp_encap_type_transmit_tunnel_endpoint *bet, /* input structure */
struct attr *attr)
{
struct attr_extra *extra = bgp_attr_extra_get(attr);
struct bgp_attr_encap_subtlv *last;
/* advance to last subtlv */
for (last = extra->encap_subtlvs; last && last->next; last = last->next);
for (last = attr->encap_subtlvs; last && last->next; last = last->next);
extra->encap_tunneltype = BGP_ENCAP_TYPE_TRANSMIT_TUNNEL_ENDPOINT;
attr->encap_tunneltype = BGP_ENCAP_TYPE_TRANSMIT_TUNNEL_ENDPOINT;
/* no subtlvs for this type */
}
@ -323,13 +319,12 @@ bgp_encap_type_ipsec_in_tunnel_mode_to_tlv(
struct bgp_encap_type_ipsec_in_tunnel_mode *bet, /* input structure */
struct attr *attr)
{
struct attr_extra *extra = bgp_attr_extra_get(attr);
struct bgp_attr_encap_subtlv *last;
/* advance to last subtlv */
for (last = extra->encap_subtlvs; last && last->next; last = last->next);
for (last = attr->encap_subtlvs; last && last->next; last = last->next);
extra->encap_tunneltype = BGP_ENCAP_TYPE_IPSEC_IN_TUNNEL_MODE;
attr->encap_tunneltype = BGP_ENCAP_TYPE_IPSEC_IN_TUNNEL_MODE;
ENC_SUBTLV(BGP_TEA_SUBTLV_IPSEC_TA, subtlv_encode_ipsec_ta, st_ipsec_ta);
}
@ -339,13 +334,12 @@ bgp_encap_type_ip_in_ip_tunnel_with_ipsec_transport_mode_to_tlv(
struct bgp_encap_type_ip_in_ip_tunnel_with_ipsec_transport_mode *bet, /* input structure */
struct attr *attr)
{
struct attr_extra *extra = bgp_attr_extra_get(attr);
struct bgp_attr_encap_subtlv *last;
/* advance to last subtlv */
for (last = extra->encap_subtlvs; last && last->next; last = last->next);
for (last = attr->encap_subtlvs; last && last->next; last = last->next);
extra->encap_tunneltype = BGP_ENCAP_TYPE_IP_IN_IP_TUNNEL_WITH_IPSEC_TRANSPORT_MODE;
attr->encap_tunneltype = BGP_ENCAP_TYPE_IP_IN_IP_TUNNEL_WITH_IPSEC_TRANSPORT_MODE;
ENC_SUBTLV(BGP_TEA_SUBTLV_IPSEC_TA, subtlv_encode_ipsec_ta, st_ipsec_ta);
}
@ -355,13 +349,12 @@ bgp_encap_type_mpls_in_ip_tunnel_with_ipsec_transport_mode_to_tlv(
struct bgp_encap_type_mpls_in_ip_tunnel_with_ipsec_transport_mode *bet, /* input structure */
struct attr *attr)
{
struct attr_extra *extra = bgp_attr_extra_get(attr);
struct bgp_attr_encap_subtlv *last;
/* advance to last subtlv */
for (last = extra->encap_subtlvs; last && last->next; last = last->next);
for (last = attr->encap_subtlvs; last && last->next; last = last->next);
extra->encap_tunneltype = BGP_ENCAP_TYPE_MPLS_IN_IP_TUNNEL_WITH_IPSEC_TRANSPORT_MODE;
attr->encap_tunneltype = BGP_ENCAP_TYPE_MPLS_IN_IP_TUNNEL_WITH_IPSEC_TRANSPORT_MODE;
ENC_SUBTLV(BGP_TEA_SUBTLV_IPSEC_TA, subtlv_encode_ipsec_ta, st_ipsec_ta);
}
@ -371,13 +364,12 @@ bgp_encap_type_pbb_to_tlv(
struct bgp_encap_type_pbb *bet, /* input structure */
struct attr *attr)
{
struct attr_extra *extra = bgp_attr_extra_get(attr);
struct bgp_attr_encap_subtlv *last;
/* advance to last subtlv */
for (last = extra->encap_subtlvs; last && last->next; last = last->next);
for (last = attr->encap_subtlvs; last && last->next; last = last->next);
extra->encap_tunneltype = BGP_ENCAP_TYPE_PBB;
attr->encap_tunneltype = BGP_ENCAP_TYPE_PBB;
assert(CHECK_FLAG(bet->valid_subtlvs, BGP_TEA_SUBTLV_ENCAP));
ENC_SUBTLV(BGP_TEA_SUBTLV_ENCAP, subtlv_encode_encap_pbb, st_encap);
@ -388,16 +380,15 @@ bgp_encap_type_vxlan_to_tlv(
struct bgp_encap_type_vxlan *bet, /* input structure */
struct attr *attr)
{
struct attr_extra *extra = bgp_attr_extra_get(attr);
struct bgp_attr_encap_subtlv *tlv;
uint32_t vnid;
extra->encap_tunneltype = BGP_ENCAP_TYPE_VXLAN;
attr->encap_tunneltype = BGP_ENCAP_TYPE_VXLAN;
if(bet == NULL ||!bet->vnid)
return;
if(extra->encap_subtlvs)
XFREE(MTYPE_ENCAP_TLV, extra->encap_subtlvs);
if(attr->encap_subtlvs)
XFREE(MTYPE_ENCAP_TLV, attr->encap_subtlvs);
tlv = XCALLOC (MTYPE_ENCAP_TLV, sizeof(struct bgp_attr_encap_subtlv)-1+12);
tlv->type = 1; /* encapsulation type */
tlv->length = 12;
@ -411,7 +402,7 @@ bgp_encap_type_vxlan_to_tlv(
char *ptr = (char *)&tlv->value + 4;
memcpy( ptr, bet->mac_address, 6);
}
extra->encap_subtlvs = tlv;
attr->encap_subtlvs = tlv;
return;
}
@ -420,9 +411,7 @@ bgp_encap_type_nvgre_to_tlv(
struct bgp_encap_type_nvgre *bet, /* input structure */
struct attr *attr)
{
struct attr_extra *extra = bgp_attr_extra_get(attr);
extra->encap_tunneltype = BGP_ENCAP_TYPE_NVGRE;
attr->encap_tunneltype = BGP_ENCAP_TYPE_NVGRE;
}
void
@ -438,9 +427,7 @@ bgp_encap_type_mpls_in_gre_to_tlv(
struct bgp_encap_type_mpls_in_gre *bet, /* input structure */
struct attr *attr)
{
struct attr_extra *extra = bgp_attr_extra_get(attr);
extra->encap_tunneltype = BGP_ENCAP_TYPE_MPLS_IN_GRE;
attr->encap_tunneltype = BGP_ENCAP_TYPE_MPLS_IN_GRE;
}
void
@ -448,9 +435,8 @@ bgp_encap_type_vxlan_gpe_to_tlv(
struct bgp_encap_type_vxlan_gpe *bet, /* input structure */
struct attr *attr)
{
struct attr_extra *extra = bgp_attr_extra_get(attr);
extra->encap_tunneltype = BGP_ENCAP_TYPE_VXLAN_GPE;
attr->encap_tunneltype = BGP_ENCAP_TYPE_VXLAN_GPE;
}
void
@ -458,9 +444,8 @@ bgp_encap_type_mpls_in_udp_to_tlv(
struct bgp_encap_type_mpls_in_udp *bet, /* input structure */
struct attr *attr)
{
struct attr_extra *extra = bgp_attr_extra_get(attr);
extra->encap_tunneltype = BGP_ENCAP_TYPE_MPLS_IN_UDP;
attr->encap_tunneltype = BGP_ENCAP_TYPE_MPLS_IN_UDP;
}

View File

@ -450,7 +450,6 @@ bgp_zebra_send_remote_vtep (struct bgp *bgp, struct bgpevpn *vpn,
static void
build_evpn_route_extcomm (struct bgpevpn *vpn, struct attr *attr)
{
struct attr_extra *attre;
struct ecommunity ecom_encap;
struct ecommunity ecom_sticky;
struct ecommunity_val eval;
@ -460,8 +459,6 @@ build_evpn_route_extcomm (struct bgpevpn *vpn, struct attr *attr)
struct ecommunity *ecom;
u_int32_t seqnum;
attre = bgp_attr_extra_get (attr);
/* Encap */
tnl_type = BGP_ENCAP_TYPE_VXLAN;
memset (&ecom_encap, 0, sizeof (ecom_encap));
@ -470,20 +467,20 @@ build_evpn_route_extcomm (struct bgpevpn *vpn, struct attr *attr)
ecom_encap.val = (u_int8_t *)eval.val;
/* Add Encap */
attre->ecommunity = ecommunity_dup (&ecom_encap);
attr->ecommunity = ecommunity_dup (&ecom_encap);
/* Add the export RTs */
for (ALL_LIST_ELEMENTS (vpn->export_rtl, node, nnode, ecom))
attre->ecommunity = ecommunity_merge (attre->ecommunity, ecom);
attr->ecommunity = ecommunity_merge (attr->ecommunity, ecom);
if (attre->sticky)
if (attr->sticky)
{
seqnum = 0;
memset (&ecom_sticky, 0, sizeof (ecom_sticky));
encode_mac_mobility_extcomm(1, seqnum, &eval_sticky);
ecom_sticky.size = 1;
ecom_sticky.val = (u_int8_t *)eval_sticky.val;
attre->ecommunity = ecommunity_merge (attre->ecommunity, &ecom_sticky);
attr->ecommunity = ecommunity_merge (attr->ecommunity, &ecom_sticky);
}
attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_EXT_COMMUNITIES);
@ -495,7 +492,6 @@ build_evpn_route_extcomm (struct bgpevpn *vpn, struct attr *attr)
static void
add_mac_mobility_to_attr (u_int32_t seq_num, struct attr *attr)
{
struct attr_extra *attre;
struct ecommunity ecom_tmp;
struct ecommunity_val eval;
struct ecommunity *ecom_mm;
@ -504,25 +500,23 @@ add_mac_mobility_to_attr (u_int32_t seq_num, struct attr *attr)
int type = 0;
int sub_type = 0;
attre = bgp_attr_extra_get (attr);
/* Build MM */
encode_mac_mobility_extcomm (0, seq_num, &eval);
/* Find current MM ecommunity */
ecom_mm = NULL;
if (attre->ecommunity)
if (attr->ecommunity)
{
for (i = 0; i < attre->ecommunity->size; i++)
for (i = 0; i < attr->ecommunity->size; i++)
{
pnt = attre->ecommunity->val + (i * 8);
pnt = attr->ecommunity->val + (i * 8);
type = *pnt++;
sub_type = *pnt++;
if (type == ECOMMUNITY_ENCODE_EVPN && sub_type == ECOMMUNITY_EVPN_SUBTYPE_MACMOBILITY)
{
ecom_mm = (struct ecommunity*) attre->ecommunity->val + (i * 8);
ecom_mm = (struct ecommunity*) attr->ecommunity->val + (i * 8);
break;
}
}
@ -540,7 +534,7 @@ add_mac_mobility_to_attr (u_int32_t seq_num, struct attr *attr)
ecom_tmp.size = 1;
ecom_tmp.val = (u_int8_t *)eval.val;
attre->ecommunity = ecommunity_merge (attre->ecommunity, &ecom_tmp);
attr->ecommunity = ecommunity_merge (attr->ecommunity, &ecom_tmp);
}
}
@ -645,7 +639,7 @@ evpn_route_select_install (struct bgp *bgp, struct bgpevpn *vpn,
if (bgp_zebra_has_route_changed (rn, old_select))
ret = evpn_zebra_install (bgp, vpn, (struct prefix_evpn *)&rn->p,
old_select->attr->nexthop,
old_select->attr->extra->sticky);
old_select->attr->sticky);
UNSET_FLAG (old_select->flags, BGP_INFO_MULTIPATH_CHG);
bgp_zebra_clear_route_change_flags (rn);
return ret;
@ -675,7 +669,7 @@ evpn_route_select_install (struct bgp *bgp, struct bgpevpn *vpn,
{
ret = evpn_zebra_install (bgp, vpn, (struct prefix_evpn *) &rn->p,
new_select->attr->nexthop,
new_select->attr->extra->sticky);
new_select->attr->sticky);
/* If an old best existed and it was a "local" route, the only reason
* it would be supplanted is due to MAC mobility procedures. So, we
* need to do an implicit delete and withdraw that route from peers.
@ -727,7 +721,7 @@ evpn_route_is_sticky (struct bgp *bgp, struct bgp_node *rn)
if (!local_ri)
return 0;
return local_ri->attr->extra->sticky;
return local_ri->attr->sticky;
}
/*
@ -801,8 +795,8 @@ update_evpn_route_entry (struct bgp *bgp, struct bgpevpn *vpn, afi_t afi,
attr_new = bgp_attr_intern (attr);
/* Extract MAC mobility sequence number, if any. */
attr_new->extra->mm_seqnum = bgp_attr_mac_mobility_seqnum (attr_new, &sticky);
attr_new->extra->sticky = sticky;
attr_new->mm_seqnum = bgp_attr_mac_mobility_seqnum (attr_new, &sticky);
attr_new->sticky = sticky;
/* Create new route with its attribute. */
tmp_ri = info_make (ZEBRA_ROUTE_BGP, BGP_ROUTE_STATIC, 0,
@ -866,9 +860,9 @@ update_evpn_route (struct bgp *bgp, struct bgpevpn *vpn,
/* Build path-attribute for this route. */
bgp_attr_default_set (&attr, BGP_ORIGIN_IGP);
attr.nexthop = vpn->originator_ip;
attr.extra->mp_nexthop_global_in = vpn->originator_ip;
attr.extra->mp_nexthop_len = BGP_ATTR_NHLEN_IPV4;
attr.extra->sticky = sticky;
attr.mp_nexthop_global_in = vpn->originator_ip;
attr.mp_nexthop_len = BGP_ATTR_NHLEN_IPV4;
attr.sticky = sticky;
/* Set up RT and ENCAP extended community. */
build_evpn_route_extcomm (vpn, &attr);
@ -910,7 +904,6 @@ update_evpn_route (struct bgp *bgp, struct bgpevpn *vpn,
/* Unintern temporary. */
aspath_unintern (&attr.aspath);
bgp_attr_extra_free (&attr);
return 0;
}
@ -1017,12 +1010,12 @@ update_all_type2_routes (struct bgp *bgp, struct bgpevpn *vpn)
bgp_attr_default_set (&attr, BGP_ORIGIN_IGP);
bgp_attr_default_set (&attr_sticky, BGP_ORIGIN_IGP);
attr.nexthop = vpn->originator_ip;
attr.extra->mp_nexthop_global_in = vpn->originator_ip;
attr.extra->mp_nexthop_len = BGP_ATTR_NHLEN_IPV4;
attr.mp_nexthop_global_in = vpn->originator_ip;
attr.mp_nexthop_len = BGP_ATTR_NHLEN_IPV4;
attr_sticky.nexthop = vpn->originator_ip;
attr_sticky.extra->mp_nexthop_global_in = vpn->originator_ip;
attr_sticky.extra->mp_nexthop_len = BGP_ATTR_NHLEN_IPV4;
attr_sticky.extra->sticky = 1;
attr_sticky.mp_nexthop_global_in = vpn->originator_ip;
attr_sticky.mp_nexthop_len = BGP_ATTR_NHLEN_IPV4;
attr_sticky.sticky = 1;
/* Set up RT, ENCAP and sticky MAC extended community. */
build_evpn_route_extcomm (vpn, &attr);
@ -1073,8 +1066,6 @@ update_all_type2_routes (struct bgp *bgp, struct bgpevpn *vpn)
/* Unintern temporary. */
aspath_unintern (&attr.aspath);
aspath_unintern (&attr_sticky.aspath);
bgp_attr_extra_free (&attr);
bgp_attr_extra_free (&attr_sticky);
return 0;
}
@ -1376,7 +1367,7 @@ is_route_matching_for_vni (struct bgp *bgp, struct bgpevpn *vpn,
if (!(attr->flag & ATTR_FLAG_BIT (BGP_ATTR_EXT_COMMUNITIES)))
return 0;
ecom = attr->extra->ecommunity;
ecom = attr->ecommunity;
if (!ecom || !ecom->size)
return 0;
@ -1592,7 +1583,7 @@ install_uninstall_evpn_route (struct bgp *bgp, afi_t afi, safi_t safi,
if (!(attr->flag & ATTR_FLAG_BIT (BGP_ATTR_EXT_COMMUNITIES)))
return 0;
ecom = attr->extra->ecommunity;
ecom = attr->ecommunity;
if (!ecom || !ecom->size)
return -1;
@ -2095,8 +2086,8 @@ evpn_mpattr_encode_type5 (struct stream *s, struct prefix *p,
/* Prefix contains RD, ESI, EthTag, IP length, IP, GWIP and VNI */
stream_putc(s, 8 + 10 + 4 + 1 + len + 3);
stream_put(s, prd->val, 8);
if (attr && attr->extra)
stream_put(s, &(attr->extra->evpn_overlay.eth_s_id), 10);
if (attr && attr)
stream_put(s, &(attr->evpn_overlay.eth_s_id), 10);
else
stream_put(s, &temp, 10);
stream_putl(s, p_evpn_p->eth_tag);
@ -2105,12 +2096,12 @@ evpn_mpattr_encode_type5 (struct stream *s, struct prefix *p,
stream_put_ipv4(s, p_evpn_p->ip.ipaddr_v4.s_addr);
else
stream_put(s, &p_evpn_p->ip.ipaddr_v6, 16);
if (attr && attr->extra)
if (attr && attr)
{
if (IS_IPADDR_V4(&p_evpn_p->ip))
stream_put_ipv4(s, attr->extra->evpn_overlay.gw_ip.ipv4. s_addr);
stream_put_ipv4(s, attr->evpn_overlay.gw_ip.ipv4. s_addr);
else
stream_put(s, &(attr->extra->evpn_overlay.gw_ip.ipv6), 16);
stream_put(s, &(attr->evpn_overlay.gw_ip.ipv6), 16);
}
else
{

View File

@ -151,12 +151,10 @@ bgp_reg_dereg_for_label (struct bgp_node *rn, struct bgp_info *ri,
assert (ri);
if (ri->attr->flag & ATTR_FLAG_BIT (BGP_ATTR_PREFIX_SID))
{
assert (ri->attr->extra);
if (ri->attr->extra->label_index != BGP_INVALID_LABEL_INDEX)
if (ri->attr->label_index != BGP_INVALID_LABEL_INDEX)
{
flags |= ZEBRA_FEC_REGISTER_LABEL_INDEX;
stream_putl (s, ri->attr->extra->label_index);
stream_putl (s, ri->attr->label_index);
}
}
SET_FLAG (rn->flags, BGP_NODE_REGISTERED_FOR_LABEL);

View File

@ -43,7 +43,6 @@ DEFINE_MTYPE(BGPD, BGP_UPDGRP, "BGP update group")
DEFINE_MTYPE(BGPD, BGP_UPD_SUBGRP, "BGP update subgroup")
DEFINE_MTYPE(BGPD, BGP_PACKET, "BGP packet")
DEFINE_MTYPE(BGPD, ATTR, "BGP attribute")
DEFINE_MTYPE(BGPD, ATTR_EXTRA, "BGP extra attributes")
DEFINE_MTYPE(BGPD, AS_PATH, "BGP aspath")
DEFINE_MTYPE(BGPD, AS_SEG, "BGP aspath seg")
DEFINE_MTYPE(BGPD, AS_SEG_DATA, "BGP aspath segment data")

View File

@ -39,7 +39,6 @@ DECLARE_MTYPE(BGP_UPDGRP)
DECLARE_MTYPE(BGP_UPD_SUBGRP)
DECLARE_MTYPE(BGP_PACKET)
DECLARE_MTYPE(ATTR)
DECLARE_MTYPE(ATTR_EXTRA)
DECLARE_MTYPE(AS_PATH)
DECLARE_MTYPE(AS_SEG)
DECLARE_MTYPE(AS_SEG_DATA)

View File

@ -106,35 +106,31 @@ bgp_maximum_paths_unset (struct bgp *bgp, afi_t afi, safi_t safi,
int
bgp_info_nexthop_cmp (struct bgp_info *bi1, struct bgp_info *bi2)
{
struct attr_extra *ae1, *ae2;
int compare;
ae1 = bi1->attr->extra;
ae2 = bi2->attr->extra;
compare = IPV4_ADDR_CMP (&bi1->attr->nexthop, &bi2->attr->nexthop);
if (!compare && ae1 && ae2)
if (!compare)
{
if (ae1->mp_nexthop_len == ae2->mp_nexthop_len)
if (bi1->attr->mp_nexthop_len == bi2->attr->mp_nexthop_len)
{
switch (ae1->mp_nexthop_len)
switch (bi1->attr->mp_nexthop_len)
{
case BGP_ATTR_NHLEN_IPV4:
case BGP_ATTR_NHLEN_VPNV4:
compare = IPV4_ADDR_CMP (&ae1->mp_nexthop_global_in,
&ae2->mp_nexthop_global_in);
compare = IPV4_ADDR_CMP (&bi1->attr->mp_nexthop_global_in,
&bi2->attr->mp_nexthop_global_in);
break;
case BGP_ATTR_NHLEN_IPV6_GLOBAL:
case BGP_ATTR_NHLEN_VPNV6_GLOBAL:
compare = IPV6_ADDR_CMP (&ae1->mp_nexthop_global,
&ae2->mp_nexthop_global);
compare = IPV6_ADDR_CMP (&bi1->attr->mp_nexthop_global,
&bi2->attr->mp_nexthop_global);
break;
case BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL:
compare = IPV6_ADDR_CMP (&ae1->mp_nexthop_global,
&ae2->mp_nexthop_global);
compare = IPV6_ADDR_CMP (&bi1->attr->mp_nexthop_global,
&bi2->attr->mp_nexthop_global);
if (!compare)
compare = IPV6_ADDR_CMP (&ae1->mp_nexthop_local,
&ae2->mp_nexthop_local);
compare = IPV6_ADDR_CMP (&bi1->attr->mp_nexthop_local,
&bi2->attr->mp_nexthop_local);
break;
}
}
@ -142,14 +138,14 @@ bgp_info_nexthop_cmp (struct bgp_info *bi1, struct bgp_info *bi2)
/* This can happen if one IPv6 peer sends you global and link-local
* nexthops but another IPv6 peer only sends you global
*/
else if (ae1->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL ||
ae1->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL)
else if (bi1->attr->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL ||
bi1->attr->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL)
{
compare = IPV6_ADDR_CMP (&ae1->mp_nexthop_global,
&ae2->mp_nexthop_global);
compare = IPV6_ADDR_CMP (&bi1->attr->mp_nexthop_global,
&bi2->attr->mp_nexthop_global);
if (!compare)
{
if (ae1->mp_nexthop_len < ae2->mp_nexthop_len)
if (bi1->attr->mp_nexthop_len < bi2->attr->mp_nexthop_len)
compare = -1;
else
compare = 1;
@ -663,7 +659,6 @@ bgp_info_mpath_aggregate_update (struct bgp_info *new_best,
struct community *community, *commerge;
struct ecommunity *ecomm, *ecommerge;
struct lcommunity *lcomm, *lcommerge;
struct attr_extra *ae;
struct attr attr = { 0 };
if (old_best && (old_best != new_best) &&
@ -697,9 +692,8 @@ bgp_info_mpath_aggregate_update (struct bgp_info *new_best,
aspath = aspath_dup (attr.aspath);
origin = attr.origin;
community = attr.community ? community_dup (attr.community) : NULL;
ae = attr.extra;
ecomm = (ae && ae->ecommunity) ? ecommunity_dup (ae->ecommunity) : NULL;
lcomm = (ae && ae->lcommunity) ? lcommunity_dup (ae->lcommunity) : NULL;
ecomm = (attr.ecommunity) ? ecommunity_dup (attr.ecommunity) : NULL;
lcomm = (attr.lcommunity) ? lcommunity_dup (attr.lcommunity) : NULL;
for (mpinfo = bgp_info_mpath_first (new_best); mpinfo;
mpinfo = bgp_info_mpath_next (mpinfo))
@ -723,28 +717,27 @@ bgp_info_mpath_aggregate_update (struct bgp_info *new_best,
community = community_dup (mpinfo->attr->community);
}
ae = mpinfo->attr->extra;
if (ae && ae->ecommunity)
if (mpinfo->attr->ecommunity)
{
if (ecomm)
{
ecommerge = ecommunity_merge (ecomm, ae->ecommunity);
ecommerge = ecommunity_merge (ecomm, mpinfo->attr->ecommunity);
ecomm = ecommunity_uniq_sort (ecommerge);
ecommunity_free (&ecommerge);
}
else
ecomm = ecommunity_dup (ae->ecommunity);
ecomm = ecommunity_dup (mpinfo->attr->ecommunity);
}
if (ae && ae->lcommunity)
if (mpinfo->attr->lcommunity)
{
if (lcomm)
{
lcommerge = lcommunity_merge (lcomm, ae->lcommunity);
lcommerge = lcommunity_merge (lcomm, mpinfo->attr->lcommunity);
lcomm = lcommunity_uniq_sort (lcommerge);
lcommunity_free (&lcommerge);
}
else
lcomm = lcommunity_dup (ae->lcommunity);
lcomm = lcommunity_dup (mpinfo->attr->lcommunity);
}
}
@ -757,21 +750,18 @@ bgp_info_mpath_aggregate_update (struct bgp_info *new_best,
}
if (ecomm)
{
ae = bgp_attr_extra_get (&attr);
ae->ecommunity = ecomm;
attr.ecommunity = ecomm;
attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_EXT_COMMUNITIES);
}
/* Zap multipath attr nexthop so we set nexthop to self */
attr.nexthop.s_addr = 0;
if (attr.extra)
memset (&attr.extra->mp_nexthop_global, 0, sizeof (struct in6_addr));
memset (&attr.mp_nexthop_global, 0, sizeof (struct in6_addr));
/* TODO: should we set ATOMIC_AGGREGATE and AGGREGATOR? */
}
new_attr = bgp_attr_intern (&attr);
bgp_attr_extra_free (&attr);
if (new_attr != bgp_info_mpath_attr (new_best))
{

View File

@ -532,8 +532,8 @@ make_prefix (int afi, struct bgp_info *ri, struct prefix *p)
break;
case AFI_IP6:
/* We don't register link local NH */
if (ri->attr->extra->mp_nexthop_len != BGP_ATTR_NHLEN_IPV6_GLOBAL
|| IN6_IS_ADDR_LINKLOCAL (&ri->attr->extra->mp_nexthop_global))
if (ri->attr->mp_nexthop_len != BGP_ATTR_NHLEN_IPV6_GLOBAL
|| IN6_IS_ADDR_LINKLOCAL (&ri->attr->mp_nexthop_global))
return -1;
p->family = AF_INET6;
@ -545,7 +545,7 @@ make_prefix (int afi, struct bgp_info *ri, struct prefix *p)
}
else
{
p->u.prefix6 = ri->attr->extra->mp_nexthop_global;
p->u.prefix6 = ri->attr->mp_nexthop_global;
p->prefixlen = IPV6_MAX_BITLEN;
}
break;

View File

@ -1364,7 +1364,6 @@ bgp_update_receive (struct peer *peer, bgp_size_t size)
u_char *end;
struct stream *s;
struct attr attr;
struct attr_extra extra;
bgp_size_t attribute_len;
bgp_size_t update_len;
bgp_size_t withdraw_len;
@ -1389,11 +1388,9 @@ bgp_update_receive (struct peer *peer, bgp_size_t size)
/* Set initial values. */
memset (&attr, 0, sizeof (struct attr));
memset (&extra, 0, sizeof (struct attr_extra));
extra.label_index = BGP_INVALID_LABEL_INDEX;
extra.label = MPLS_INVALID_LABEL;
attr.label_index = BGP_INVALID_LABEL_INDEX;
attr.label = MPLS_INVALID_LABEL;
memset (&nlris, 0, sizeof (nlris));
attr.extra = &extra;
memset (peer->rcvd_attr_str, 0, BUFSIZ);
peer->rcvd_attr_printed = 0;

File diff suppressed because it is too large Load Diff

View File

@ -232,8 +232,8 @@ struct bgp_static
#define BGP_ATTR_NEXTHOP_AFI_IP6(attr) \
(! CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_NEXT_HOP)) && \
(attr)->extra && ((attr)->extra->mp_nexthop_len == 16 || \
(attr)->extra->mp_nexthop_len == 32))
((attr)->mp_nexthop_len == 16 || \
(attr)->mp_nexthop_len == 32))
#define BGP_INFO_COUNTABLE(BI) \
(! CHECK_FLAG ((BI)->flags, BGP_INFO_HISTORY) \
&& ! CHECK_FLAG ((BI)->flags, BGP_INFO_REMOVED))

View File

@ -868,8 +868,7 @@ route_match_lcommunity (void *rule, struct prefix *prefix,
if (! list)
return RMAP_NOMATCH;
if (bgp_info->attr->extra &&
lcommunity_list_match (bgp_info->attr->extra->lcommunity, list))
if (lcommunity_list_match (bgp_info->attr->lcommunity, list))
return RMAP_MATCH;
}
@ -933,15 +932,12 @@ route_match_ecommunity (void *rule, struct prefix *prefix,
{
bgp_info = object;
if (!bgp_info->attr->extra)
return RMAP_NOMATCH;
list = community_list_lookup (bgp_clist, (char *) rule,
EXTCOMMUNITY_LIST_MASTER);
if (! list)
return RMAP_NOMATCH;
if (ecommunity_list_match (bgp_info->attr->extra->ecommunity, list))
if (ecommunity_list_match (bgp_info->attr->ecommunity, list))
return RMAP_MATCH;
}
return RMAP_NOMATCH;
@ -1149,10 +1145,7 @@ route_match_tag (void *rule, struct prefix *prefix,
tag = rule;
bgp_info = object;
if (!bgp_info->attr->extra)
return RMAP_NOMATCH;
return ((bgp_info->attr->extra->tag == *tag)? RMAP_MATCH : RMAP_NOMATCH);
return ((bgp_info->attr->tag == *tag)? RMAP_MATCH : RMAP_NOMATCH);
}
return RMAP_NOMATCH;
@ -1332,7 +1325,6 @@ route_set_weight (void *rule, struct prefix *prefix, route_map_object_t type,
{
struct rmap_value *rv;
struct bgp_info *bgp_info;
u_int32_t weight;
if (type == RMAP_BGP)
{
@ -1341,11 +1333,7 @@ route_set_weight (void *rule, struct prefix *prefix, route_map_object_t type,
bgp_info = object;
/* Set weight value. */
weight = route_value_adjust(rv, 0, bgp_info->peer);
if (weight)
(bgp_attr_extra_get (bgp_info->attr))->weight = weight;
else if (bgp_info->attr->extra)
bgp_info->attr->extra->weight = 0;
bgp_info->attr->weight = route_value_adjust(rv, 0, bgp_info->peer);
}
return RMAP_OKAY;
@ -1644,14 +1632,13 @@ route_set_lcommunity (void *rule, struct prefix *prefix,
rcs = rule;
binfo = object;
attr = binfo->attr;
old = (attr->extra) ? attr->extra->lcommunity : NULL;
old = attr->lcommunity;
/* "none" case. */
if (rcs->none)
{
attr->flag &= ~(ATTR_FLAG_BIT (BGP_ATTR_LARGE_COMMUNITIES));
if (attr->extra)
attr->extra->lcommunity = NULL;
attr->lcommunity = NULL;
/* See the longer comment down below. */
if (old && old->refcnt == 0)
@ -1676,7 +1663,7 @@ route_set_lcommunity (void *rule, struct prefix *prefix,
new = lcommunity_dup (rcs->lcom);
/* will be intern()'d or attr_flush()'d by bgp_update_main() */
(bgp_attr_extra_get (attr))->lcommunity = new;
attr->lcommunity = new;
attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_LARGE_COMMUNITIES);
}
@ -1766,7 +1753,7 @@ route_set_lcommunity_delete (void *rule, struct prefix *prefix,
binfo = object;
list = community_list_lookup (bgp_clist, rule,
LARGE_COMMUNITY_LIST_MASTER);
old = ((binfo->attr->extra) ? binfo->attr->extra->lcommunity : NULL);
old = binfo->attr->lcommunity;
if (list && old)
{
@ -1783,13 +1770,13 @@ route_set_lcommunity_delete (void *rule, struct prefix *prefix,
if (new->size == 0)
{
binfo->attr->extra->lcommunity = NULL;
binfo->attr->lcommunity = NULL;
binfo->attr->flag &= ~ATTR_FLAG_BIT (BGP_ATTR_LARGE_COMMUNITIES);
lcommunity_free (&new);
}
else
{
binfo->attr->extra->lcommunity = new;
binfo->attr->lcommunity = new;
binfo->attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_LARGE_COMMUNITIES);
}
}
@ -1946,7 +1933,7 @@ route_set_ecommunity (void *rule, struct prefix *prefix,
return RMAP_OKAY;
/* We assume additive for Extended Community. */
old_ecom = (bgp_attr_extra_get (bgp_info->attr))->ecommunity;
old_ecom = bgp_info->attr->ecommunity;
if (old_ecom)
{
@ -1961,7 +1948,7 @@ route_set_ecommunity (void *rule, struct prefix *prefix,
new_ecom = ecommunity_dup (ecom);
/* will be intern()'d or attr_flush()'d by bgp_update_main() */
bgp_info->attr->extra->ecommunity = new_ecom;
bgp_info->attr->ecommunity = new_ecom;
bgp_info->attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_EXT_COMMUNITIES);
}
@ -2129,16 +2116,14 @@ route_set_aggregator_as (void *rule, struct prefix *prefix,
{
struct bgp_info *bgp_info;
struct aggregator *aggregator;
struct attr_extra *ae;
if (type == RMAP_BGP)
{
bgp_info = object;
aggregator = rule;
ae = bgp_attr_extra_get (bgp_info->attr);
ae->aggregator_as = aggregator->as;
ae->aggregator_addr = aggregator->address;
bgp_info->attr->aggregator_as = aggregator->as;
bgp_info->attr->aggregator_addr = aggregator->address;
bgp_info->attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR);
}
@ -2187,16 +2172,14 @@ route_set_tag (void *rule, struct prefix *prefix,
{
route_tag_t *tag;
struct bgp_info *bgp_info;
struct attr_extra *ae;
if (type == RMAP_BGP)
{
tag = rule;
bgp_info = object;
ae = bgp_attr_extra_get (bgp_info->attr);
/* Set tag value */
ae->tag=*tag;
bgp_info->attr->tag=*tag;
}
@ -2231,7 +2214,7 @@ route_set_label_index (void *rule, struct prefix *prefix,
label_index = rv->value;
if (label_index)
{
(bgp_attr_extra_get (bgp_info->attr))->label_index = label_index;
bgp_info->attr->label_index = label_index;
bgp_info->attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_PREFIX_SID);
}
}
@ -2302,14 +2285,11 @@ route_match_ipv6_next_hop (void *rule, struct prefix *prefix,
{
bgp_info = object;
if (!bgp_info->attr->extra)
return RMAP_NOMATCH;
if (IPV6_ADDR_SAME (&bgp_info->attr->extra->mp_nexthop_global, addr))
if (IPV6_ADDR_SAME (&bgp_info->attr->mp_nexthop_global, addr))
return RMAP_MATCH;
if (bgp_info->attr->extra->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL &&
IPV6_ADDR_SAME (&bgp_info->attr->extra->mp_nexthop_local, rule))
if (bgp_info->attr->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL &&
IPV6_ADDR_SAME (&bgp_info->attr->mp_nexthop_local, rule))
return RMAP_MATCH;
return RMAP_NOMATCH;
@ -2407,11 +2387,11 @@ route_set_ipv6_nexthop_global (void *rule, struct prefix *prefix,
bgp_info = object;
/* Set next hop value. */
(bgp_attr_extra_get (bgp_info->attr))->mp_nexthop_global = *address;
bgp_info->attr->mp_nexthop_global = *address;
/* Set nexthop length. */
if (bgp_info->attr->extra->mp_nexthop_len == 0)
bgp_info->attr->extra->mp_nexthop_len = BGP_ATTR_NHLEN_IPV6_GLOBAL;
if (bgp_info->attr->mp_nexthop_len == 0)
bgp_info->attr->mp_nexthop_len = BGP_ATTR_NHLEN_IPV6_GLOBAL;
SET_FLAG(bgp_info->attr->rmap_change_flags,
BATTR_RMAP_IPV6_GLOBAL_NHOP_CHANGED);
@ -2477,13 +2457,13 @@ route_set_ipv6_nexthop_prefer_global (void *rule, struct prefix *prefix,
&& sockunion_family (peer->su_remote) == AF_INET6)
{
/* Set next hop preference to global */
bgp_info->attr->extra->mp_nexthop_prefer_global = TRUE;
bgp_info->attr->mp_nexthop_prefer_global = TRUE;
SET_FLAG(bgp_info->attr->rmap_change_flags,
BATTR_RMAP_IPV6_PREFER_GLOBAL_CHANGED);
}
else
{
bgp_info->attr->extra->mp_nexthop_prefer_global = FALSE;
bgp_info->attr->mp_nexthop_prefer_global = FALSE;
SET_FLAG(bgp_info->attr->rmap_change_flags,
BATTR_RMAP_IPV6_PREFER_GLOBAL_CHANGED);
}
@ -2535,11 +2515,11 @@ route_set_ipv6_nexthop_local (void *rule, struct prefix *prefix,
bgp_info = object;
/* Set next hop value. */
(bgp_attr_extra_get (bgp_info->attr))->mp_nexthop_local = *address;
bgp_info->attr->mp_nexthop_local = *address;
/* Set nexthop length. */
if (bgp_info->attr->extra->mp_nexthop_len != BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL)
bgp_info->attr->extra->mp_nexthop_len = BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL;
if (bgp_info->attr->mp_nexthop_len != BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL)
bgp_info->attr->mp_nexthop_len = BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL;
SET_FLAG(bgp_info->attr->rmap_change_flags,
BATTR_RMAP_IPV6_LL_NHOP_CHANGED);
@ -2611,15 +2591,15 @@ route_set_ipv6_nexthop_peer (void *rule, struct prefix *prefix,
/* Set next hop value and length in attribute. */
if (IN6_IS_ADDR_LINKLOCAL(&peer_address))
{
(bgp_attr_extra_get (bgp_info->attr))->mp_nexthop_local = peer_address;
if (bgp_info->attr->extra->mp_nexthop_len != 32)
bgp_info->attr->extra->mp_nexthop_len = 32;
bgp_info->attr->mp_nexthop_local = peer_address;
if (bgp_info->attr->mp_nexthop_len != 32)
bgp_info->attr->mp_nexthop_len = 32;
}
else
{
(bgp_attr_extra_get (bgp_info->attr))->mp_nexthop_global = peer_address;
if (bgp_info->attr->extra->mp_nexthop_len == 0)
bgp_info->attr->extra->mp_nexthop_len = 16;
bgp_info->attr->mp_nexthop_global = peer_address;
if (bgp_info->attr->mp_nexthop_len == 0)
bgp_info->attr->mp_nexthop_len = 16;
}
}
@ -2633,9 +2613,9 @@ route_set_ipv6_nexthop_peer (void *rule, struct prefix *prefix,
SET_FLAG(bgp_info->attr->rmap_change_flags,
BATTR_RMAP_NEXTHOP_PEER_ADDRESS);
/* clear next hop value. */
memset (&((bgp_attr_extra_get (bgp_info->attr))->mp_nexthop_global),
memset (&(bgp_info->attr->mp_nexthop_global),
0, sizeof (struct in6_addr));
memset (&((bgp_attr_extra_get (bgp_info->attr))->mp_nexthop_local),
memset (&(bgp_info->attr->mp_nexthop_local),
0, sizeof (struct in6_addr));
}
}
@ -2688,8 +2668,8 @@ route_set_vpnv4_nexthop (void *rule, struct prefix *prefix,
bgp_info = object;
/* Set next hop value. */
(bgp_attr_extra_get (bgp_info->attr))->mp_nexthop_global_in = *address;
(bgp_attr_extra_get (bgp_info->attr))->mp_nexthop_len = 4;
bgp_info->attr->mp_nexthop_global_in = *address;
bgp_info->attr->mp_nexthop_len = 4;
}
return RMAP_OKAY;
@ -2730,8 +2710,8 @@ route_set_vpnv6_nexthop (void *rule, struct prefix *prefix,
bgp_info = object;
/* Set next hop value. */
memcpy (&(bgp_attr_extra_get (bgp_info->attr))->mp_nexthop_global, address, sizeof(struct in6_addr));
(bgp_attr_extra_get (bgp_info->attr))->mp_nexthop_len = BGP_ATTR_NHLEN_VPNV6_GLOBAL;
memcpy (&bgp_info->attr->mp_nexthop_global, address, sizeof(struct in6_addr));
bgp_info->attr->mp_nexthop_len = BGP_ATTR_NHLEN_VPNV6_GLOBAL;
}
return RMAP_OKAY;
@ -2794,7 +2774,7 @@ route_set_originator_id (void *rule, struct prefix *prefix, route_map_object_t t
bgp_info = object;
bgp_info->attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID);
(bgp_attr_extra_get (bgp_info->attr))->originator_id = *address;
bgp_info->attr->originator_id = *address;
}
return RMAP_OKAY;

View File

@ -802,16 +802,10 @@ bgp4PathAttrTable (struct variable *v, oid name[], size_t *length,
return SNMP_INTEGER (1);
break;
case BGP4PATHATTRAGGREGATORAS: /* 10 */
if (binfo->attr->extra)
return SNMP_INTEGER (binfo->attr->extra->aggregator_as);
else
return SNMP_INTEGER (0);
return SNMP_INTEGER (binfo->attr->aggregator_as);
break;
case BGP4PATHATTRAGGREGATORADDR: /* 11 */
if (binfo->attr->extra)
return SNMP_IPADDRESS (binfo->attr->extra->aggregator_addr);
else
return SNMP_INTEGER (0);
return SNMP_IPADDRESS (binfo->attr->aggregator_addr);
break;
case BGP4PATHATTRCALCLOCALPREF: /* 12 */
return SNMP_INTEGER (-1);

View File

@ -587,7 +587,6 @@ subgroup_announce_table (struct update_subgroup *subgrp,
struct bgp_node *rn;
struct bgp_info *ri;
struct attr attr;
struct attr_extra extra;
struct peer *peer;
afi_t afi;
safi_t safi;
@ -610,9 +609,6 @@ subgroup_announce_table (struct update_subgroup *subgrp,
&& CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE))
subgroup_default_originate (subgrp, 0);
/* It's initialized in bgp_announce_check() */
attr.extra = &extra;
for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
for (ri = rn->info; ri; ri = ri->next)
@ -716,18 +712,16 @@ subgroup_default_originate (struct update_subgroup *subgrp, int withdraw)
str2prefix ("0.0.0.0/0", &p);
else if (afi == AFI_IP6)
{
struct attr_extra *ae = attr.extra;
str2prefix ("::/0", &p);
/* IPv6 global nexthop must be included. */
ae->mp_nexthop_len = BGP_ATTR_NHLEN_IPV6_GLOBAL;
attr.mp_nexthop_len = BGP_ATTR_NHLEN_IPV6_GLOBAL;
/* If the peer is on shared nextwork and we have link-local
nexthop set it. */
if (peer->shared_network
&& !IN6_IS_ADDR_UNSPECIFIED (&peer->nexthop.v6_local))
ae->mp_nexthop_len = BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL;
attr.mp_nexthop_len = BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL;
}
if (peer->default_rmap[afi][safi].name)
@ -739,11 +733,9 @@ subgroup_default_originate (struct update_subgroup *subgrp, int withdraw)
for (ri = rn->info; ri; ri = ri->next)
{
struct attr dummy_attr;
struct attr_extra dummy_extra;
struct bgp_info info;
/* Provide dummy so the route-map can't modify the attributes */
dummy_attr.extra = &dummy_extra;
bgp_attr_dup (&dummy_attr, ri->attr);
info.peer = ri->peer;
info.attr = &dummy_attr;
@ -794,7 +786,6 @@ subgroup_default_originate (struct update_subgroup *subgrp, int withdraw)
}
}
bgp_attr_extra_free (&attr);
aspath_unintern (&aspath);
}

View File

@ -6724,11 +6724,6 @@ DEFUN (show_bgp_memory,
mtype_memstr (memstrbuf, sizeof (memstrbuf),
count * sizeof(struct attr)),
VTYNL);
if ((count = mtype_stats_alloc (MTYPE_ATTR_EXTRA)))
vty_out (vty, "%ld BGP extra attributes, using %s of memory%s", count,
mtype_memstr (memstrbuf, sizeof (memstrbuf),
count * sizeof(struct attr_extra)),
VTYNL);
if ((count = attr_unknown_count()))
vty_out (vty, "%ld unknown attributes%s", count, VTYNL);

View File

@ -73,14 +73,12 @@ struct stream *bgp_label_buf = NULL;
2. use an array to avoid number of mallocs.
Number of supported next-hops are finite, use of arrays should be ok. */
struct attr attr_cp[MULTIPATH_NUM];
struct attr_extra attr_extra_cp[MULTIPATH_NUM];
unsigned int attr_index = 0;
/* Once per address-family initialization of the attribute array */
#define BGP_INFO_ATTR_BUF_INIT()\
do {\
memset(attr_cp, 0, MULTIPATH_NUM * sizeof(struct attr));\
memset(attr_extra_cp, 0, MULTIPATH_NUM * sizeof(struct attr_extra));\
attr_index = 0;\
} while (0)
@ -88,7 +86,6 @@ do {\
do { \
*info_dst = *info_src; \
assert(attr_index != multipath_num);\
attr_cp[attr_index].extra = &attr_extra_cp[attr_index]; \
bgp_attr_dup (&attr_cp[attr_index], info_src->attr); \
bgp_attr_deep_dup (&attr_cp[attr_index], info_src->attr); \
info_dst->attr = &attr_cp[attr_index]; \
@ -1162,23 +1159,23 @@ bgp_info_to_ipv6_nexthop (struct bgp_info *info)
struct in6_addr *nexthop = NULL;
/* Only global address nexthop exists. */
if (info->attr->extra->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL)
nexthop = &info->attr->extra->mp_nexthop_global;
if (info->attr->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL)
nexthop = &info->attr->mp_nexthop_global;
/* If both global and link-local address present. */
if (info->attr->extra->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL)
if (info->attr->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL)
{
/* Check if route-map is set to prefer global over link-local */
if (info->attr->extra->mp_nexthop_prefer_global)
nexthop = &info->attr->extra->mp_nexthop_global;
if (info->attr->mp_nexthop_prefer_global)
nexthop = &info->attr->mp_nexthop_global;
else
{
/* Workaround for Cisco's nexthop bug. */
if (IN6_IS_ADDR_UNSPECIFIED (&info->attr->extra->mp_nexthop_global)
if (IN6_IS_ADDR_UNSPECIFIED (&info->attr->mp_nexthop_global)
&& info->peer->su_remote->sa.sa_family == AF_INET6)
nexthop = &info->peer->su_remote->sin6.sin6_addr;
else
nexthop = &info->attr->extra->mp_nexthop_local;
nexthop = &info->attr->mp_nexthop_local;
}
}
@ -1248,10 +1245,7 @@ bgp_zebra_announce (struct bgp_node *rn, struct prefix *p, struct bgp_info *info
flags = 0;
peer = info->peer;
if ((info->attr->extra) && (info->attr->extra->tag != 0))
tag = info->attr->extra->tag;
else
tag = 0;
tag = info->attr->tag;
/* When we create an aggregate route we must also install a Null0 route in
* the RIB */
@ -1305,7 +1299,7 @@ bgp_zebra_announce (struct bgp_node *rn, struct prefix *p, struct bgp_info *info
{
/* Metric is currently based on the best-path only */
metric = info_cp->attr->med;
tag = info_cp->attr->extra->tag;
tag = info_cp->attr->tag;
}
nexthop = &info_cp->attr->nexthop;
}
@ -1420,8 +1414,6 @@ bgp_zebra_announce (struct bgp_node *rn, struct prefix *p, struct bgp_info *info
ifindex = 0;
nexthop = NULL;
assert (info->attr->extra);
if (bgp->table_map[afi][safi].name)
BGP_INFO_ATTR_BUF_INIT();
@ -1441,7 +1433,7 @@ bgp_zebra_announce (struct bgp_node *rn, struct prefix *p, struct bgp_info *info
if (mpinfo == info)
{
metric = info_cp->attr->med;
tag = info_cp->attr->extra->tag;
tag = info_cp->attr->tag;
}
nexthop = bgp_info_to_ipv6_nexthop(info_cp);
}
@ -1454,7 +1446,7 @@ bgp_zebra_announce (struct bgp_node *rn, struct prefix *p, struct bgp_info *info
continue;
if ((mpinfo == info) &&
mpinfo->attr->extra->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL)
mpinfo->attr->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL)
if (mpinfo->peer->nexthop.ifp)
ifindex = mpinfo->peer->nexthop.ifp->ifindex;
@ -1674,10 +1666,10 @@ bgp_zebra_withdraw (struct prefix *p, struct bgp_info *info, safi_t safi)
api.metric = info->attr->med;
api.tag = 0;
if ((info->attr->extra) && (info->attr->extra->tag != 0))
if (info->attr->tag != 0)
{
SET_FLAG(api.message, ZAPI_MESSAGE_TAG);
api.tag = info->attr->extra->tag;
api.tag = info->attr->tag;
}
if (bgp_debug_zebra(p))
@ -1696,8 +1688,6 @@ bgp_zebra_withdraw (struct prefix *p, struct bgp_info *info, safi_t safi)
if (p->family == AF_INET6)
{
struct zapi_ipv6 api;
assert (info->attr->extra);
api.vrf_id = peer->bgp->vrf_id;
api.flags = flags;
@ -1714,10 +1704,10 @@ bgp_zebra_withdraw (struct prefix *p, struct bgp_info *info, safi_t safi)
api.metric = info->attr->med;
api.tag = 0;
if ((info->attr->extra) && (info->attr->extra->tag != 0))
if (info->attr->tag != 0)
{
SET_FLAG(api.message, ZAPI_MESSAGE_TAG);
api.tag = info->attr->extra->tag;
api.tag = info->attr->tag;
}
if (bgp_debug_zebra(p))
@ -1903,9 +1893,7 @@ bgp_redistribute_metric_set (struct bgp *bgp, struct bgp_redist *red, afi_t afi,
{
struct attr *old_attr;
struct attr new_attr;
struct attr_extra new_extra;
new_attr.extra = &new_extra;
bgp_attr_dup (&new_attr, ri->attr);
new_attr.med = red->redist_metric;
old_attr = ri->attr;

View File

@ -715,7 +715,6 @@ add_vnc_route (
/* Cripes, the memory management of attributes is byzantine */
bgp_attr_default_set (&attr, BGP_ORIGIN_INCOMPLETE);
assert (attr.extra);
/*
* At this point:
@ -772,7 +771,6 @@ add_vnc_route (
/* Encap SAFI not used with MPLS */
vnc_zlog_debug_verbose ("%s: mpls tunnel type, encap safi omitted", __func__);
aspath_unintern (&attr.aspath); /* Unintern original. */
bgp_attr_extra_free (&attr);
return;
}
}
@ -790,7 +788,7 @@ add_vnc_route (
}
/* override default weight assigned by bgp_attr_default_set() */
attr.extra->weight = rfd->peer ? rfd->peer->weight[afi][safi] : 0;
attr.weight = rfd->peer ? rfd->peer->weight[afi][safi] : 0;
/*
* NB: ticket 81: do not reset attr.aspath here because it would
@ -808,7 +806,7 @@ add_vnc_route (
if (type == ZEBRA_ROUTE_BGP_DIRECT || type == ZEBRA_ROUTE_BGP_DIRECT_EXT)
{
attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID);
attr.extra->originator_id = bgp->router_id;
attr.originator_id = bgp->router_id;
}
@ -825,7 +823,7 @@ add_vnc_route (
encaptlv->length = 4;
lt = htonl (*lifetime);
memcpy (encaptlv->value, &lt, 4);
attr.extra->vnc_subtlvs = encaptlv;
attr.vnc_subtlvs = encaptlv;
vnc_zlog_debug_verbose ("%s: set Encap Attr Prefix Lifetime to %d",
__func__, *lifetime);
}
@ -845,13 +843,13 @@ add_vnc_route (
*/
encaptlv =
encap_tlv_dup ((struct bgp_attr_encap_subtlv *) rfp_options);
if (attr.extra->vnc_subtlvs)
if (attr.vnc_subtlvs)
{
attr.extra->vnc_subtlvs->next = encaptlv;
attr.vnc_subtlvs->next = encaptlv;
}
else
{
attr.extra->vnc_subtlvs = encaptlv;
attr.vnc_subtlvs = encaptlv;
}
}
@ -859,7 +857,7 @@ add_vnc_route (
{
struct bgp_tea_options *hop;
/* XXX max of one tlv present so far from above code */
struct bgp_attr_encap_subtlv *tail = attr.extra->vnc_subtlvs;
struct bgp_attr_encap_subtlv *tail = attr.vnc_subtlvs;
for (hop = rfp_options; hop; hop = hop->next)
{
@ -887,7 +885,7 @@ add_vnc_route (
}
else
{
attr.extra->vnc_subtlvs = encaptlv;
attr.vnc_subtlvs = encaptlv;
}
tail = encaptlv;
}
@ -903,8 +901,8 @@ add_vnc_route (
*/
attr.extra->ecommunity = ecommunity_new ();
assert (attr.extra->ecommunity);
attr.ecommunity = ecommunity_new ();
assert (attr.ecommunity);
if (TunnelType != BGP_ENCAP_TYPE_MPLS &&
TunnelType != BGP_ENCAP_TYPE_RESERVED)
@ -921,7 +919,7 @@ add_vnc_route (
beec.val[1] = ECOMMUNITY_OPAQUE_SUBTYPE_ENCAP;
beec.val[6] = ((TunnelType) >> 8) & 0xff;
beec.val[7] = (TunnelType) & 0xff;
ecommunity_add_val (attr.extra->ecommunity, &beec);
ecommunity_add_val (attr.ecommunity, &beec);
}
/*
@ -929,21 +927,21 @@ add_vnc_route (
*/
if (rt_export_list)
{
attr.extra->ecommunity =
ecommunity_merge (attr.extra->ecommunity, rt_export_list);
attr.ecommunity =
ecommunity_merge (attr.ecommunity, rt_export_list);
}
if (attr.extra->ecommunity->size)
if (attr.ecommunity->size)
{
attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_EXT_COMMUNITIES);
}
else
{
ecommunity_free (&attr.extra->ecommunity);
attr.extra->ecommunity = NULL;
ecommunity_free (&attr.ecommunity);
attr.ecommunity = NULL;
}
vnc_zlog_debug_verbose ("%s: attr.extra->ecommunity=%p", __func__,
attr.extra->ecommunity);
vnc_zlog_debug_verbose ("%s: attr.ecommunity=%p", __func__,
attr.ecommunity);
/*
@ -965,13 +963,13 @@ add_vnc_route (
*/
attr.nexthop.s_addr = nexthop->addr.v4.s_addr;
attr.extra->mp_nexthop_global_in = nexthop->addr.v4;
attr.extra->mp_nexthop_len = 4;
attr.mp_nexthop_global_in = nexthop->addr.v4;
attr.mp_nexthop_len = 4;
break;
case AF_INET6:
attr.extra->mp_nexthop_global = nexthop->addr.v6;
attr.extra->mp_nexthop_len = 16;
attr.mp_nexthop_global = nexthop->addr.v6;
attr.mp_nexthop_len = 16;
break;
default:
@ -1016,7 +1014,6 @@ add_vnc_route (
new_attr = bgp_attr_intern (&attr);
aspath_unintern (&attr.aspath); /* Unintern original. */
bgp_attr_extra_free (&attr);
/*
* At this point:

View File

@ -162,28 +162,24 @@ rfapi_tunneltype_option_to_tlv (
struct rfapi_un_option *
rfapi_encap_tlv_to_un_option (struct attr *attr)
{
struct attr_extra *attre = attr->extra;
struct rfapi_un_option *uo = NULL;
struct rfapi_tunneltype_option *tto;
int rc;
struct bgp_attr_encap_subtlv *stlv;
if (!attre)
return NULL;
/* no tunnel encap attr stored */
if (!attre->encap_tunneltype)
if (!attr->encap_tunneltype)
return NULL;
stlv = attre->encap_subtlvs;
stlv = attr->encap_subtlvs;
uo = XCALLOC (MTYPE_RFAPI_UN_OPTION, sizeof (struct rfapi_un_option));
assert (uo);
uo->type = RFAPI_UN_OPTION_TYPE_TUNNELTYPE;
uo->v.tunnel.type = attre->encap_tunneltype;
uo->v.tunnel.type = attr->encap_tunneltype;
tto = &uo->v.tunnel;
switch (attre->encap_tunneltype)
switch (attr->encap_tunneltype)
{
case BGP_ENCAP_TYPE_L2TPV3_OVER_IP:
rc = tlv_to_bgp_encap_type_l2tpv3overip (stlv, &tto->bgpinfo.l2tpv3_ip);
@ -249,7 +245,7 @@ rfapi_encap_tlv_to_un_option (struct attr *attr)
default:
vnc_zlog_debug_verbose ("%s: unknown tunnel type %d",
__func__, attre->encap_tunneltype);
__func__, attr->encap_tunneltype);
rc = -1;
break;
}

View File

@ -1,4 +1,4 @@
/*
/*
*
* Copyright 2009-2016, LabN Consulting, L.L.C.
*
@ -308,12 +308,12 @@ rfapi_deferred_close_workfunc (struct work_queue *q, void *data)
int
rfapiGetL2o (struct attr *attr, struct rfapi_l2address_option *l2o)
{
if (attr && attr->extra)
if (attr)
{
struct bgp_attr_encap_subtlv *pEncap;
for (pEncap = attr->extra->vnc_subtlvs; pEncap; pEncap = pEncap->next)
for (pEncap = attr->vnc_subtlvs; pEncap; pEncap = pEncap->next)
{
if (pEncap->type == BGP_VNC_SUBTLV_TYPE_RFPOPTION)
@ -358,10 +358,10 @@ rfapiGetVncLifetime (struct attr *attr, uint32_t * lifetime)
*lifetime = RFAPI_INFINITE_LIFETIME; /* default to infinite */
if (attr && attr->extra)
if (attr)
{
for (pEncap = attr->extra->vnc_subtlvs; pEncap; pEncap = pEncap->next)
for (pEncap = attr->vnc_subtlvs; pEncap; pEncap = pEncap->next)
{
if (pEncap->type == BGP_VNC_SUBTLV_TYPE_LIFETIME)
@ -387,9 +387,9 @@ rfapiGetTunnelType (struct attr *attr,
bgp_encap_types *type)
{
*type = BGP_ENCAP_TYPE_MPLS; /* default to MPLS */
if (attr && attr->extra && attr->extra->ecommunity)
if (attr && attr->ecommunity)
{
struct ecommunity *ecom = attr->extra->ecommunity;
struct ecommunity *ecom = attr->ecommunity;
int i;
for (i = 0; i < (ecom->size * ECOMMUNITY_SIZE); i += ECOMMUNITY_SIZE)
@ -431,9 +431,9 @@ rfapiGetVncTunnelUnAddr (struct attr *attr, struct prefix *p)
return ENOENT;
}
if (attr && attr->extra)
if (attr)
{
for (pEncap = attr->extra->encap_subtlvs; pEncap; pEncap = pEncap->next)
for (pEncap = attr->encap_subtlvs; pEncap; pEncap = pEncap->next)
{
if (pEncap->type == BGP_ENCAP_SUBTLV_TYPE_REMOTE_ENDPOINT)
@ -1184,7 +1184,7 @@ rfapiVpnBiNhEqualsPt (struct bgp_info *bi, struct rfapi_ip_addr *hpt)
if (!hpt || !bi)
return 0;
family = BGP_MP_NEXTHOP_FAMILY (bi->attr->extra->mp_nexthop_len);
family = BGP_MP_NEXTHOP_FAMILY (bi->attr->mp_nexthop_len);
if (hpt->addr_family != family)
return 0;
@ -1192,12 +1192,12 @@ rfapiVpnBiNhEqualsPt (struct bgp_info *bi, struct rfapi_ip_addr *hpt)
switch (family)
{
case AF_INET:
if (bi->attr->extra->mp_nexthop_global_in.s_addr != hpt->addr.v4.s_addr)
if (bi->attr->mp_nexthop_global_in.s_addr != hpt->addr.v4.s_addr)
return 0;
break;
case AF_INET6:
if (IPV6_ADDR_CMP (&bi->attr->extra->mp_nexthop_global, &hpt->addr.v6))
if (IPV6_ADDR_CMP (&bi->attr->mp_nexthop_global, &hpt->addr.v6))
return 0;
break;
@ -1225,31 +1225,27 @@ rfapiVpnBiSamePtUn (struct bgp_info *bi1, struct bgp_info *bi2)
if (!bi1->attr || !bi2->attr)
return 0;
if (!bi1->attr->extra || !bi2->attr->extra)
return 0;
/*
* VN address comparisons
*/
if (BGP_MP_NEXTHOP_FAMILY (bi1->attr->extra->mp_nexthop_len) !=
BGP_MP_NEXTHOP_FAMILY (bi2->attr->extra->mp_nexthop_len))
if (BGP_MP_NEXTHOP_FAMILY (bi1->attr->mp_nexthop_len) !=
BGP_MP_NEXTHOP_FAMILY (bi2->attr->mp_nexthop_len))
{
return 0;
}
switch (BGP_MP_NEXTHOP_FAMILY (bi1->attr->extra->mp_nexthop_len))
switch (BGP_MP_NEXTHOP_FAMILY (bi1->attr->mp_nexthop_len))
{
case AF_INET:
if (bi1->attr->extra->mp_nexthop_global_in.s_addr !=
bi2->attr->extra->mp_nexthop_global_in.s_addr)
if (bi1->attr->mp_nexthop_global_in.s_addr !=
bi2->attr->mp_nexthop_global_in.s_addr)
return 0;
break;
case AF_INET6:
if (IPV6_ADDR_CMP (&bi1->attr->extra->mp_nexthop_global,
&bi2->attr->extra->mp_nexthop_global))
if (IPV6_ADDR_CMP (&bi1->attr->mp_nexthop_global,
&bi2->attr->mp_nexthop_global))
return 0;
break;
@ -1419,11 +1415,11 @@ rfapiRouteInfo2NextHopEntry (
memcpy (&vo->v.l2addr.macaddr, &rn->p.u.prefix_eth.octet,
ETHER_ADDR_LEN);
/* only low 3 bytes of this are significant */
if (bi->attr && bi->attr->extra)
if (bi->attr)
{
(void) rfapiEcommunityGetLNI (bi->attr->extra->ecommunity,
(void) rfapiEcommunityGetLNI (bi->attr->ecommunity,
&vo->v.l2addr.logical_net_id);
(void) rfapiEcommunityGetEthernetTag (bi->attr->extra->ecommunity,
(void) rfapiEcommunityGetEthernetTag (bi->attr->ecommunity,
&vo->v.l2addr.tag_id);
}
@ -1451,132 +1447,129 @@ rfapiRouteInfo2NextHopEntry (
bgp_encap_types tun_type;
new->prefix.cost = rfapiRfpCost (bi->attr);
if (bi->attr->extra)
struct bgp_attr_encap_subtlv *pEncap;
switch (BGP_MP_NEXTHOP_FAMILY (bi->attr->mp_nexthop_len))
{
case AF_INET:
new->vn_address.addr_family = AF_INET;
new->vn_address.addr.v4 = bi->attr->mp_nexthop_global_in;
break;
struct bgp_attr_encap_subtlv *pEncap;
case AF_INET6:
new->vn_address.addr_family = AF_INET6;
new->vn_address.addr.v6 = bi->attr->mp_nexthop_global;
break;
switch (BGP_MP_NEXTHOP_FAMILY (bi->attr->extra->mp_nexthop_len))
default:
zlog_warn ("%s: invalid vpn nexthop length: %d",
__func__, bi->attr->mp_nexthop_len);
rfapi_free_next_hop_list (new);
return NULL;
}
for (pEncap = bi->attr->vnc_subtlvs; pEncap;
pEncap = pEncap->next)
{
switch (pEncap->type)
{
case AF_INET:
new->vn_address.addr_family = AF_INET;
new->vn_address.addr.v4 = bi->attr->extra->mp_nexthop_global_in;
break;
case AF_INET6:
new->vn_address.addr_family = AF_INET6;
new->vn_address.addr.v6 = bi->attr->extra->mp_nexthop_global;
case BGP_VNC_SUBTLV_TYPE_LIFETIME:
/* use configured lifetime, not attr lifetime */
break;
default:
zlog_warn ("%s: invalid vpn nexthop length: %d",
__func__, bi->attr->extra->mp_nexthop_len);
rfapi_free_next_hop_list (new);
return NULL;
zlog_warn ("%s: unknown VNC option type %d",
__func__, pEncap->type);
break;
}
}
for (pEncap = bi->attr->extra->vnc_subtlvs; pEncap;
pEncap = pEncap->next)
rfapiGetTunnelType (bi->attr, &tun_type);
if (tun_type == BGP_ENCAP_TYPE_MPLS)
{
struct prefix p;
/* MPLS carries UN address in next hop */
rfapiNexthop2Prefix (bi->attr, &p);
if (p.family != 0)
{
switch (pEncap->type)
{
case BGP_VNC_SUBTLV_TYPE_LIFETIME:
/* use configured lifetime, not attr lifetime */
break;
default:
zlog_warn ("%s: unknown VNC option type %d",
__func__, pEncap->type);
break;
}
rfapiQprefix2Raddr(&p, &new->un_address);
have_vnc_tunnel_un = 1;
}
}
rfapiGetTunnelType (bi->attr, &tun_type);
if (tun_type == BGP_ENCAP_TYPE_MPLS)
for (pEncap = bi->attr->encap_subtlvs; pEncap;
pEncap = pEncap->next)
{
switch (pEncap->type)
{
struct prefix p;
/* MPLS carries UN address in next hop */
rfapiNexthop2Prefix (bi->attr, &p);
if (p.family != 0)
case BGP_ENCAP_SUBTLV_TYPE_REMOTE_ENDPOINT:
/*
* Overrides ENCAP UN address, if any
*/
switch (pEncap->length)
{
rfapiQprefix2Raddr(&p, &new->un_address);
case 8:
new->un_address.addr_family = AF_INET;
memcpy (&new->un_address.addr.v4, pEncap->value, 4);
have_vnc_tunnel_un = 1;
}
}
break;
for (pEncap = bi->attr->extra->encap_subtlvs; pEncap;
pEncap = pEncap->next)
{
switch (pEncap->type)
{
case BGP_ENCAP_SUBTLV_TYPE_REMOTE_ENDPOINT:
/*
* Overrides ENCAP UN address, if any
*/
switch (pEncap->length)
{
case 8:
new->un_address.addr_family = AF_INET;
memcpy (&new->un_address.addr.v4, pEncap->value, 4);
have_vnc_tunnel_un = 1;
break;
case 20:
new->un_address.addr_family = AF_INET6;
memcpy (&new->un_address.addr.v6, pEncap->value, 16);
have_vnc_tunnel_un = 1;
break;
default:
zlog_warn
("%s: invalid tunnel subtlv UN addr length (%d) for bi %p",
__func__, pEncap->length, bi);
}
case 20:
new->un_address.addr_family = AF_INET6;
memcpy (&new->un_address.addr.v6, pEncap->value, 16);
have_vnc_tunnel_un = 1;
break;
default:
zlog_warn ("%s: unknown Encap Attribute option type %d",
__func__, pEncap->type);
break;
zlog_warn
("%s: invalid tunnel subtlv UN addr length (%d) for bi %p",
__func__, pEncap->length, bi);
}
}
break;
new->un_options = rfapi_encap_tlv_to_un_option (bi->attr);
default:
zlog_warn ("%s: unknown Encap Attribute option type %d",
__func__, pEncap->type);
break;
}
}
new->un_options = rfapi_encap_tlv_to_un_option (bi->attr);
#if DEBUG_ENCAP_MONITOR
vnc_zlog_debug_verbose ("%s: line %d: have_vnc_tunnel_un=%d",
__func__, __LINE__, have_vnc_tunnel_un);
vnc_zlog_debug_verbose ("%s: line %d: have_vnc_tunnel_un=%d",
__func__, __LINE__, have_vnc_tunnel_un);
#endif
if (!have_vnc_tunnel_un && bi && bi->extra)
if (!have_vnc_tunnel_un && bi && bi->extra)
{
/*
* use cached UN address from ENCAP route
*/
new->un_address.addr_family = bi->extra->vnc.import.un_family;
switch (new->un_address.addr_family)
{
/*
* use cached UN address from ENCAP route
*/
new->un_address.addr_family = bi->extra->vnc.import.un_family;
switch (new->un_address.addr_family)
{
case AF_INET:
new->un_address.addr.v4 = bi->extra->vnc.import.un.addr4;
break;
case AF_INET6:
new->un_address.addr.v6 = bi->extra->vnc.import.un.addr6;
break;
default:
zlog_warn ("%s: invalid UN addr family (%d) for bi %p",
__func__, new->un_address.addr_family, bi);
rfapi_free_next_hop_list (new);
return NULL;
break;
}
case AF_INET:
new->un_address.addr.v4 = bi->extra->vnc.import.un.addr4;
break;
case AF_INET6:
new->un_address.addr.v6 = bi->extra->vnc.import.un.addr6;
break;
default:
zlog_warn ("%s: invalid UN addr family (%d) for bi %p",
__func__, new->un_address.addr_family, bi);
rfapi_free_next_hop_list (new);
return NULL;
break;
}
}
}
new->lifetime = lifetime;
return new;
}
@ -2702,19 +2695,18 @@ rfapiNexthop2Prefix (struct attr *attr, struct prefix *p)
{
assert (p);
assert (attr);
assert (attr->extra);
memset (p, 0, sizeof (struct prefix));
switch (p->family = BGP_MP_NEXTHOP_FAMILY (attr->extra->mp_nexthop_len))
switch (p->family = BGP_MP_NEXTHOP_FAMILY (attr->mp_nexthop_len))
{
case AF_INET:
p->u.prefix4 = attr->extra->mp_nexthop_global_in;
p->u.prefix4 = attr->mp_nexthop_global_in;
p->prefixlen = 32;
break;
case AF_INET6:
p->u.prefix6 = attr->extra->mp_nexthop_global;
p->u.prefix6 = attr->mp_nexthop_global;
p->prefixlen = 128;
break;
@ -2779,9 +2771,7 @@ rfapiAttrNexthopAddrDifferent (struct prefix *p1, struct prefix *p2)
static void
rfapiCopyUnEncap2VPN (struct bgp_info *encap_bi, struct bgp_info *vpn_bi)
{
struct attr_extra *attre;
if (!encap_bi->attr || !encap_bi->attr->extra)
if (!encap_bi->attr)
{
zlog_warn ("%s: no encap bi attr/extra, can't copy UN address",
__func__);
@ -2795,9 +2785,7 @@ rfapiCopyUnEncap2VPN (struct bgp_info *encap_bi, struct bgp_info *vpn_bi)
return;
}
attre = encap_bi->attr->extra;
switch (BGP_MP_NEXTHOP_FAMILY (attre->mp_nexthop_len))
switch (BGP_MP_NEXTHOP_FAMILY (encap_bi->attr->mp_nexthop_len))
{
case AF_INET:
@ -2811,17 +2799,17 @@ rfapiCopyUnEncap2VPN (struct bgp_info *encap_bi, struct bgp_info *vpn_bi)
}
vpn_bi->extra->vnc.import.un_family = AF_INET;
vpn_bi->extra->vnc.import.un.addr4 = attre->mp_nexthop_global_in;
vpn_bi->extra->vnc.import.un.addr4 = encap_bi->attr->mp_nexthop_global_in;
break;
case AF_INET6:
vpn_bi->extra->vnc.import.un_family = AF_INET6;
vpn_bi->extra->vnc.import.un.addr6 = attre->mp_nexthop_global;
vpn_bi->extra->vnc.import.un.addr6 = encap_bi->attr->mp_nexthop_global;
break;
default:
zlog_warn ("%s: invalid encap nexthop length: %d",
__func__, attre->mp_nexthop_len);
__func__, encap_bi->attr->mp_nexthop_len);
vpn_bi->extra->vnc.import.un_family = 0;
break;
}
@ -3102,21 +3090,21 @@ rfapiExpireEncapNow (
static int
rfapiGetNexthop (struct attr *attr, struct prefix *prefix)
{
switch (BGP_MP_NEXTHOP_FAMILY (attr->extra->mp_nexthop_len))
switch (BGP_MP_NEXTHOP_FAMILY (attr->mp_nexthop_len))
{
case AF_INET:
prefix->family = AF_INET;
prefix->prefixlen = 32;
prefix->u.prefix4 = attr->extra->mp_nexthop_global_in;
prefix->u.prefix4 = attr->mp_nexthop_global_in;
break;
case AF_INET6:
prefix->family = AF_INET6;
prefix->prefixlen = 128;
prefix->u.prefix6 = attr->extra->mp_nexthop_global;
prefix->u.prefix6 = attr->mp_nexthop_global;
break;
default:
vnc_zlog_debug_verbose ("%s: unknown attr->extra->mp_nexthop_len %d", __func__,
attr->extra->mp_nexthop_len);
vnc_zlog_debug_verbose ("%s: unknown attr->mp_nexthop_len %d", __func__,
attr->mp_nexthop_len);
return EINVAL;
}
return 0;
@ -3187,7 +3175,7 @@ rfapiBgpInfoFilteredImportEncap (
* On a withdraw, peer and RD are sufficient to determine if
* we should act.
*/
if (!attr || !attr->extra || !attr->extra->ecommunity)
if (!attr || !attr->ecommunity)
{
vnc_zlog_debug_verbose ("%s: attr, extra, or ecommunity missing, not importing",
@ -3195,7 +3183,7 @@ rfapiBgpInfoFilteredImportEncap (
return;
}
#if RFAPI_REQUIRE_ENCAP_BEEC
if (!rfapiEcommunitiesMatchBeec (attr->extra->ecommunity))
if (!rfapiEcommunitiesMatchBeec (attr->ecommunity))
{
vnc_zlog_debug_verbose ("%s: it=%p: no match for BGP Encapsulation ecommunity",
__func__, import_table);
@ -3203,7 +3191,7 @@ rfapiBgpInfoFilteredImportEncap (
}
#endif
if (!rfapiEcommunitiesIntersect (import_table->rt_import_list,
attr->extra->ecommunity))
attr->ecommunity))
{
vnc_zlog_debug_verbose ("%s: it=%p: no ecommunity intersection",
@ -3669,7 +3657,7 @@ rfapiBgpInfoFilteredImportVPN (
*/
if (action == FIF_ACTION_UPDATE)
{
if (!attr || !attr->extra || !attr->extra->ecommunity)
if (!attr || !attr->ecommunity)
{
vnc_zlog_debug_verbose ("%s: attr, extra, or ecommunity missing, not importing",
@ -3678,7 +3666,7 @@ rfapiBgpInfoFilteredImportVPN (
}
if ((import_table != bgp->rfapi->it_ce) &&
!rfapiEcommunitiesIntersect (import_table->rt_import_list,
attr->extra->ecommunity))
attr->ecommunity))
{
vnc_zlog_debug_verbose ("%s: it=%p: no ecommunity intersection",
@ -4162,12 +4150,12 @@ rfapiProcessUpdate (
* Find rt containing LNI (Logical Network ID), which
* _should_ always be present when mac address is present
*/
rc = rfapiEcommunityGetLNI (attr->extra->ecommunity, &lni);
rc = rfapiEcommunityGetLNI (attr->ecommunity, &lni);
vnc_zlog_debug_verbose
("%s: rfapiEcommunityGetLNI returned %d, lni=%d, attr=%p, attr->extra=%p",
__func__, rc, lni, attr, attr->extra);
if (attr && attr->extra && !rc)
("%s: rfapiEcommunityGetLNI returned %d, lni=%d, attr=%p",
__func__, rc, lni, attr);
if (attr && !rc)
{
it = rfapiMacImportTableGet (bgp, lni);

View File

@ -664,7 +664,7 @@ rfapiRibBi2Ri(
ri->lifetime = lifetime;
/* This loop based on rfapiRouteInfo2NextHopEntry() */
for (pEncap = bi->attr->extra->vnc_subtlvs; pEncap; pEncap = pEncap->next)
for (pEncap = bi->attr->vnc_subtlvs; pEncap; pEncap = pEncap->next)
{
struct bgp_tea_options *hop;
@ -723,11 +723,11 @@ rfapiRibBi2Ri(
memcpy (&vo->v.l2addr.macaddr, bi->extra->vnc.import.rd.val+2,
ETHER_ADDR_LEN);
if (bi->attr && bi->attr->extra)
if (bi->attr)
{
(void) rfapiEcommunityGetLNI (bi->attr->extra->ecommunity,
(void) rfapiEcommunityGetLNI (bi->attr->ecommunity,
&vo->v.l2addr.logical_net_id);
(void) rfapiEcommunityGetEthernetTag (bi->attr->extra->ecommunity,
(void) rfapiEcommunityGetEthernetTag (bi->attr->ecommunity,
&vo->v.l2addr.tag_id);
}

View File

@ -469,9 +469,9 @@ rfapi_vty_out_vncinfo (
}
}
if (bi->attr && bi->attr->extra && bi->attr->extra->ecommunity)
if (bi->attr && bi->attr->ecommunity)
{
s = ecommunity_ecom2str (bi->attr->extra->ecommunity,
s = ecommunity_ecom2str (bi->attr->ecommunity,
ECOMMUNITY_FORMAT_ROUTE_MAP, 0);
vty_out (vty, " EC{%s}", s);
XFREE (MTYPE_ECOMMUNITY_STR, s);
@ -499,7 +499,6 @@ rfapiPrintAttrPtrs (void *stream, struct attr *attr)
void *out;
const char *vty_newline;
struct attr_extra *ae;
char buf[BUFSIZ];
if (rfapiStream2Vty (stream, &fp, &vty, &out, &vty_newline) == 0)
@ -518,15 +517,12 @@ rfapiPrintAttrPtrs (void *stream, struct attr *attr)
fp (out, " community=%p, refcnt=%d%s", attr->community,
(attr->community ? attr->community->refcnt : 0), HVTYNL);
if ((ae = attr->extra))
{
fp (out, " ecommunity=%p, refcnt=%d%s", ae->ecommunity,
(ae->ecommunity ? ae->ecommunity->refcnt : 0), HVTYNL);
fp (out, " cluster=%p, refcnt=%d%s", ae->cluster,
(ae->cluster ? ae->cluster->refcnt : 0), HVTYNL);
fp (out, " transit=%p, refcnt=%d%s", ae->transit,
(ae->transit ? ae->transit->refcnt : 0), HVTYNL);
}
fp (out, " ecommunity=%p, refcnt=%d%s", attr->ecommunity,
(attr->ecommunity ? attr->ecommunity->refcnt : 0), HVTYNL);
fp (out, " cluster=%p, refcnt=%d%s", attr->cluster,
(attr->cluster ? attr->cluster->refcnt : 0), HVTYNL);
fp (out, " transit=%p, refcnt=%d%s", attr->transit,
(attr->transit ? attr->transit->refcnt : 0), HVTYNL);
}
/*
@ -593,26 +589,26 @@ rfapiPrintBi (void *stream, struct bgp_info *bi)
* RFP option sizes (they are opaque values)
* extended communities (RTs)
*/
if (bi->attr && bi->attr->extra)
if (bi->attr)
{
uint32_t lifetime;
int printed_1st_gol = 0;
struct bgp_attr_encap_subtlv *pEncap;
struct prefix pfx_un;
int af = BGP_MP_NEXTHOP_FAMILY (bi->attr->extra->mp_nexthop_len);
int af = BGP_MP_NEXTHOP_FAMILY (bi->attr->mp_nexthop_len);
/* Nexthop */
if (af == AF_INET)
{
r = snprintf (p, REMAIN, "%s", inet_ntop (AF_INET,
&bi->attr->extra->mp_nexthop_global_in,
&bi->attr->mp_nexthop_global_in,
buf, BUFSIZ));
INCP;
}
else if (af == AF_INET6)
{
r = snprintf (p, REMAIN, "%s", inet_ntop (AF_INET6,
&bi->attr->extra->mp_nexthop_global,
&bi->attr->mp_nexthop_global,
buf, BUFSIZ));
INCP;
}
@ -650,7 +646,7 @@ rfapiPrintBi (void *stream, struct bgp_info *bi)
}
/* RFP option lengths */
for (pEncap = bi->attr->extra->vnc_subtlvs; pEncap;
for (pEncap = bi->attr->vnc_subtlvs; pEncap;
pEncap = pEncap->next)
{
@ -673,9 +669,9 @@ rfapiPrintBi (void *stream, struct bgp_info *bi)
}
/* RT list */
if (bi->attr->extra->ecommunity)
if (bi->attr->ecommunity)
{
s = ecommunity_ecom2str (bi->attr->extra->ecommunity,
s = ecommunity_ecom2str (bi->attr->ecommunity,
ECOMMUNITY_FORMAT_ROUTE_MAP, 0);
r = snprintf (p, REMAIN, " %s", s);
INCP;
@ -704,9 +700,9 @@ rfapiPrintBi (void *stream, struct bgp_info *bi)
if (bi->attr)
{
if (bi->attr->extra)
if (bi->attr->weight)
{
r = snprintf (p, REMAIN, " W=%d", bi->attr->extra->weight);
r = snprintf (p, REMAIN, " W=%d", bi->attr->weight);
INCP;
}

View File

@ -74,7 +74,6 @@ encap_attr_export_ce (
*/
memset (new, 0, sizeof (struct attr));
bgp_attr_dup (new, orig);
bgp_attr_extra_get (new);
/*
* Set nexthop
@ -83,17 +82,13 @@ encap_attr_export_ce (
{
case AF_INET:
new->nexthop = use_nexthop->u.prefix4;
new->extra->mp_nexthop_len = 4; /* bytes */
new->mp_nexthop_len = 4; /* bytes */
new->flag |= ATTR_FLAG_BIT (BGP_ATTR_NEXT_HOP);
break;
case AF_INET6:
if (!new->extra)
{
new->extra = XCALLOC (MTYPE_ATTR_EXTRA, sizeof (struct attr_extra));
}
new->extra->mp_nexthop_global = use_nexthop->u.prefix6;
new->extra->mp_nexthop_len = 16; /* bytes */
new->mp_nexthop_global = use_nexthop->u.prefix6;
new->mp_nexthop_len = 16; /* bytes */
break;
default:
@ -133,7 +128,6 @@ encap_attr_export_ce (
*
* Caller should, after using the attr, call:
* - bgp_attr_flush() to free non-interned parts
* - call bgp_attr_extra_free() to free extra
*/
}
@ -144,8 +138,8 @@ getce (struct bgp *bgp, struct attr *attr, struct prefix *pfx_ce)
int i;
uint16_t localadmin = bgp->rfapi_cfg->resolve_nve_roo_local_admin;
for (ecp = attr->extra->ecommunity->val, i = 0;
i < attr->extra->ecommunity->size; ++i, ecp += ECOMMUNITY_SIZE)
for (ecp = attr->ecommunity->val, i = 0;
i < attr->ecommunity->size; ++i, ecp += ECOMMUNITY_SIZE)
{
if (VNC_DEBUG(EXPORT_BGP_GETCE))
@ -309,14 +303,12 @@ vnc_direct_bgp_add_route_ce (
if (ret == RMAP_DENYMATCH)
{
bgp_attr_flush (&hattr);
bgp_attr_extra_free (&hattr);
return;
}
}
iattr = bgp_attr_intern (&hattr);
bgp_attr_flush (&hattr);
bgp_attr_extra_free (&hattr);
/*
* Rule: disallow route-map alteration of next-hop, because it
@ -563,14 +555,14 @@ vnc_route_origin_ecom (struct route_node *rn)
struct ecommunity_val roec;
switch (BGP_MP_NEXTHOP_FAMILY (bi->attr->extra->mp_nexthop_len))
switch (BGP_MP_NEXTHOP_FAMILY (bi->attr->mp_nexthop_len))
{
case AF_INET:
memset (&roec, 0, sizeof (roec));
roec.val[0] = 0x01;
roec.val[1] = 0x03;
memcpy (roec.val + 2,
&bi->attr->extra->mp_nexthop_global_in.s_addr, 4);
&bi->attr->mp_nexthop_global_in.s_addr, 4);
roec.val[6] = 0;
roec.val[7] = 0;
ecommunity_add_val (new, &roec);
@ -642,16 +634,16 @@ encap_attr_export (
{
use_nexthop = &orig_nexthop;
orig_nexthop.family =
BGP_MP_NEXTHOP_FAMILY (orig->extra->mp_nexthop_len);
BGP_MP_NEXTHOP_FAMILY (orig->mp_nexthop_len);
if (orig_nexthop.family == AF_INET)
{
orig_nexthop.prefixlen = 32;
orig_nexthop.u.prefix4 = orig->extra->mp_nexthop_global_in;
orig_nexthop.u.prefix4 = orig->mp_nexthop_global_in;
}
else if (orig_nexthop.family == AF_INET6)
{
orig_nexthop.prefixlen = 128;
orig_nexthop.u.prefix6 = orig->extra->mp_nexthop_global;
orig_nexthop.u.prefix6 = orig->mp_nexthop_global;
}
else
{
@ -673,17 +665,13 @@ encap_attr_export (
{
case AF_INET:
new->nexthop = use_nexthop->u.prefix4;
new->extra->mp_nexthop_len = 4; /* bytes */
new->mp_nexthop_len = 4; /* bytes */
new->flag |= ATTR_FLAG_BIT (BGP_ATTR_NEXT_HOP);
break;
case AF_INET6:
if (!new->extra)
{
new->extra = XCALLOC (MTYPE_ATTR_EXTRA, sizeof (struct attr_extra));
}
new->extra->mp_nexthop_global = use_nexthop->u.prefix6;
new->extra->mp_nexthop_len = 16; /* bytes */
new->mp_nexthop_global = use_nexthop->u.prefix6;
new->mp_nexthop_len = 16; /* bytes */
break;
default:
@ -691,7 +679,6 @@ encap_attr_export (
break;
}
bgp_attr_extra_get (new);
if (rn)
{
ecom_ro = vnc_route_origin_ecom (rn);
@ -701,17 +688,14 @@ encap_attr_export (
/* TBD test/assert for IPv6 */
ecom_ro = vnc_route_origin_ecom_single (&use_nexthop->u.prefix4);
}
if (new->extra->ecommunity)
if (new->ecommunity)
{
if (ecom_ro)
{
new->extra->ecommunity =
ecommunity_merge (ecom_ro, new->extra->ecommunity);
}
new->ecommunity = ecommunity_merge (ecom_ro, new->ecommunity);
}
else
{
new->extra->ecommunity = ecom_ro;
new->ecommunity = ecom_ro;
}
if (ecom_ro)
{
@ -750,7 +734,6 @@ encap_attr_export (
*
* Caller should, after using the attr, call:
* - bgp_attr_flush() to free non-interned parts
* - call bgp_attr_extra_free() to free extra
*/
return 0;
@ -887,7 +870,6 @@ vnc_direct_bgp_add_prefix (
if (ret == RMAP_DENYMATCH)
{
bgp_attr_flush (&hattr);
bgp_attr_extra_free (&hattr);
vnc_zlog_debug_verbose
("%s: route map says DENY, so not calling bgp_update",
__func__);
@ -903,7 +885,6 @@ vnc_direct_bgp_add_prefix (
iattr = bgp_attr_intern (&hattr);
bgp_attr_flush (&hattr);
bgp_attr_extra_free (&hattr);
bgp_update (irfd->peer, &rn->p, /* prefix */
0, /* addpath_id */
@ -917,7 +898,6 @@ vnc_direct_bgp_add_prefix (
}
aspath_unintern (&attr.aspath);
bgp_attr_extra_free (&attr);
}
/*
@ -1134,7 +1114,6 @@ vnc_direct_bgp_add_nve (struct bgp *bgp, struct rfapi_descriptor *rfd)
if (ret == RMAP_DENYMATCH)
{
bgp_attr_flush (&hattr);
bgp_attr_extra_free (&hattr);
continue;
}
@ -1142,7 +1121,6 @@ vnc_direct_bgp_add_nve (struct bgp *bgp, struct rfapi_descriptor *rfd)
iattr = bgp_attr_intern (&hattr);
bgp_attr_flush (&hattr);
bgp_attr_extra_free (&hattr);
bgp_update (irfd->peer, &rn->p, /* prefix */
0, /* addpath_id */
@ -1157,7 +1135,6 @@ vnc_direct_bgp_add_nve (struct bgp *bgp, struct rfapi_descriptor *rfd)
}
aspath_unintern (&attr.aspath);
bgp_attr_extra_free (&attr);
}
}
}
@ -1361,7 +1338,6 @@ vnc_direct_bgp_add_group_afi (
if (ret == RMAP_DENYMATCH)
{
bgp_attr_flush (&hattr);
bgp_attr_extra_free (&hattr);
continue;
}
@ -1369,7 +1345,6 @@ vnc_direct_bgp_add_group_afi (
iattr = bgp_attr_intern (&hattr);
bgp_attr_flush (&hattr);
bgp_attr_extra_free (&hattr);
bgp_update (irfd->peer, &rn->p, /* prefix */
0, /* addpath_id */
@ -1384,7 +1359,6 @@ vnc_direct_bgp_add_group_afi (
}
aspath_unintern (&attr.aspath);
bgp_attr_extra_free (&attr);
}
@ -1744,14 +1718,12 @@ vnc_direct_bgp_rh_add_route (
if (ret == RMAP_DENYMATCH)
{
bgp_attr_flush (&hattr);
bgp_attr_extra_free (&hattr);
return;
}
}
iattr = bgp_attr_intern (&hattr);
bgp_attr_flush (&hattr);
bgp_attr_extra_free (&hattr);
/*
* record route information that we will need to expire
@ -1983,7 +1955,6 @@ vnc_direct_bgp_rh_vpn_enable (struct bgp *bgp, afi_t afi)
if (ret == RMAP_DENYMATCH)
{
bgp_attr_flush (&hattr);
bgp_attr_extra_free (&hattr);
vnc_zlog_debug_verbose ("%s: route map says DENY", __func__);
continue;
}
@ -1991,7 +1962,6 @@ vnc_direct_bgp_rh_vpn_enable (struct bgp *bgp, afi_t afi)
iattr = bgp_attr_intern (&hattr);
bgp_attr_flush (&hattr);
bgp_attr_extra_free (&hattr);
/*
* record route information that we will need to expire

View File

@ -393,7 +393,6 @@ process_unicast_route (
if (ret == RMAP_DENYMATCH)
{
bgp_attr_flush (&hattr);
bgp_attr_extra_free (&hattr);
vnc_zlog_debug_verbose ("%s: route map \"%s\" says DENY, returning", __func__,
rmap->name);
return -1;
@ -406,8 +405,8 @@ process_unicast_route (
*/
rfapiUnicastNexthop2Prefix (afi, &hattr, unicast_nexthop);
if (hattr.extra && hattr.extra->ecommunity)
*ecom = ecommunity_dup (hattr.extra->ecommunity);
if (hattr.ecommunity)
*ecom = ecommunity_dup (hattr.ecommunity);
else
*ecom = ecommunity_new ();
@ -415,7 +414,6 @@ process_unicast_route (
* Done with hattr, clean up
*/
bgp_attr_flush (&hattr);
bgp_attr_extra_free (&hattr);
/*
* Add EC that carries original NH of iBGP route (2 bytes = magic
@ -510,18 +508,18 @@ vnc_import_bgp_add_route_mode_resolve_nve_one_bi (
plifetime = &lifetime;
}
if (bi->attr && bi->attr->extra)
if (bi->attr)
{
encaptlvs = bi->attr->extra->vnc_subtlvs;
if (bi->attr->extra->encap_tunneltype != BGP_ENCAP_TYPE_RESERVED &&
bi->attr->extra->encap_tunneltype != BGP_ENCAP_TYPE_MPLS)
encaptlvs = bi->attr->vnc_subtlvs;
if (bi->attr->encap_tunneltype != BGP_ENCAP_TYPE_RESERVED &&
bi->attr->encap_tunneltype != BGP_ENCAP_TYPE_MPLS)
{
if (opt != NULL)
opt->next = &optary[cur_opt];
opt = &optary[cur_opt++];
memset (opt, 0, sizeof (struct rfapi_un_option));
opt->type = RFAPI_UN_OPTION_TYPE_TUNNELTYPE;
opt->v.tunnel.type = bi->attr->extra->encap_tunneltype;
opt->v.tunnel.type = bi->attr->encap_tunneltype;
/* TBD parse bi->attr->extra->encap_subtlvs */
}
}
@ -532,8 +530,8 @@ vnc_import_bgp_add_route_mode_resolve_nve_one_bi (
struct ecommunity *new_ecom = ecommunity_dup (ecom);
if (bi->attr && bi->attr->extra && bi->attr->extra->ecommunity)
ecommunity_merge (new_ecom, bi->attr->extra->ecommunity);
if (bi->attr && bi->attr->ecommunity)
ecommunity_merge (new_ecom, bi->attr->ecommunity);
if (bi->extra)
label = decode_label (&bi->extra->label);
@ -891,7 +889,6 @@ vnc_import_bgp_add_route_mode_plain (struct bgp *bgp,
if (ret == RMAP_DENYMATCH)
{
bgp_attr_flush (&hattr);
bgp_attr_extra_free (&hattr);
vnc_zlog_debug_verbose ("%s: route map \"%s\" says DENY, returning", __func__,
rmap->name);
return;
@ -900,7 +897,6 @@ vnc_import_bgp_add_route_mode_plain (struct bgp *bgp,
iattr = bgp_attr_intern (&hattr);
bgp_attr_flush (&hattr);
bgp_attr_extra_free (&hattr);
/* Now iattr is an allocated interned attr */
@ -925,8 +921,8 @@ vnc_import_bgp_add_route_mode_plain (struct bgp *bgp,
memset (&prd, 0, sizeof (prd));
rfapi_set_autord_from_vn (&prd, &vnaddr);
if (iattr && iattr->extra && iattr->extra->ecommunity)
ecom = ecommunity_dup (iattr->extra->ecommunity);
if (iattr && iattr->ecommunity)
ecom = ecommunity_dup (iattr->ecommunity);
}
@ -1103,7 +1099,6 @@ vnc_import_bgp_add_route_mode_nvegroup (struct bgp *bgp,
if (ret == RMAP_DENYMATCH)
{
bgp_attr_flush (&hattr);
bgp_attr_extra_free (&hattr);
vnc_zlog_debug_verbose ("%s: route map \"%s\" says DENY, returning", __func__,
rmap->name);
return;
@ -1112,7 +1107,6 @@ vnc_import_bgp_add_route_mode_nvegroup (struct bgp *bgp,
iattr = bgp_attr_intern (&hattr);
bgp_attr_flush (&hattr);
bgp_attr_extra_free (&hattr);
/* Now iattr is an allocated interned attr */
@ -1139,8 +1133,8 @@ vnc_import_bgp_add_route_mode_nvegroup (struct bgp *bgp,
else
ecom = ecommunity_new ();
if (iattr && iattr->extra && iattr->extra->ecommunity)
ecom = ecommunity_merge (ecom, iattr->extra->ecommunity);
if (iattr && iattr->ecommunity)
ecom = ecommunity_merge (ecom, iattr->ecommunity);
}
local_pref = calc_local_pref (iattr, peer);
@ -1942,7 +1936,6 @@ vnc_import_bgp_exterior_add_route_it (
ZEBRA_ROUTE_BGP_DIRECT_EXT,
BGP_ROUTE_REDISTRIBUTE, &label);
bgp_attr_extra_free (&new_attr);
}
if (have_usable_route)
@ -2273,7 +2266,6 @@ vnc_import_bgp_exterior_add_route_interior (
ZEBRA_ROUTE_BGP_DIRECT_EXT,
BGP_ROUTE_REDISTRIBUTE, &label);
bgp_attr_extra_free (&new_attr);
}
vnc_zlog_debug_verbose
("%s: finished constructing exteriors based on existing monitors",
@ -2412,7 +2404,6 @@ vnc_import_bgp_exterior_add_route_interior (
ZEBRA_ROUTE_BGP_DIRECT_EXT,
BGP_ROUTE_REDISTRIBUTE, &label);
bgp_attr_extra_free (&new_attr);
}
}
@ -2536,7 +2527,6 @@ vnc_import_bgp_exterior_add_route_interior (
ZEBRA_ROUTE_BGP_DIRECT_EXT,
BGP_ROUTE_REDISTRIBUTE, &label);
bgp_attr_extra_free (&new_attr);
}
}
if (list_adopted)
@ -2740,7 +2730,6 @@ vnc_import_bgp_exterior_del_route_interior (
ZEBRA_ROUTE_BGP_DIRECT_EXT,
BGP_ROUTE_REDISTRIBUTE, &label);
bgp_attr_extra_free (&new_attr);
}
}