mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-06 12:52:49 +00:00
bgpd: Use uint32_t for size value instead of int in ecommunity struct
The `struct ecommunity` structure is using an int for a size value. Let's switch it over to a uint32_t for size values since a size value for data can never be negative. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
This commit is contained in:
parent
3a15018892
commit
f6e07e1bdf
@ -3395,7 +3395,8 @@ void bgp_attr_extcom_tunnel_type(struct attr *attr,
|
||||
bgp_encap_types *tunnel_type)
|
||||
{
|
||||
struct ecommunity *ecom;
|
||||
int i;
|
||||
uint32_t i;
|
||||
|
||||
if (!attr)
|
||||
return;
|
||||
|
||||
@ -4021,7 +4022,7 @@ bgp_size_t bgp_packet_attribute(struct bgp *bgp, struct peer *peer,
|
||||
uint8_t *pnt;
|
||||
int tbit;
|
||||
int ecom_tr_size = 0;
|
||||
int i;
|
||||
uint32_t i;
|
||||
|
||||
for (i = 0; i < attr->ecommunity->size; i++) {
|
||||
pnt = attr->ecommunity->val + (i * 8);
|
||||
|
@ -89,7 +89,7 @@ char *ecom_mac2str(char *ecom_mac)
|
||||
/* Fetch router-mac from extended community */
|
||||
bool bgp_attr_rmac(struct attr *attr, struct ethaddr *rmac)
|
||||
{
|
||||
int i = 0;
|
||||
uint32_t i = 0;
|
||||
struct ecommunity *ecom;
|
||||
|
||||
ecom = attr->ecommunity;
|
||||
@ -122,7 +122,7 @@ bool bgp_attr_rmac(struct attr *attr, struct ethaddr *rmac)
|
||||
uint8_t bgp_attr_default_gw(struct attr *attr)
|
||||
{
|
||||
struct ecommunity *ecom;
|
||||
int i;
|
||||
uint32_t i;
|
||||
|
||||
ecom = attr->ecommunity;
|
||||
if (!ecom || !ecom->size)
|
||||
@ -153,7 +153,7 @@ uint8_t bgp_attr_default_gw(struct attr *attr)
|
||||
uint16_t bgp_attr_df_pref_from_ec(struct attr *attr, uint8_t *alg)
|
||||
{
|
||||
struct ecommunity *ecom;
|
||||
int i;
|
||||
uint32_t i;
|
||||
uint16_t df_pref = 0;
|
||||
|
||||
*alg = EVPN_MH_DF_ALG_SERVICE_CARVING;
|
||||
@ -190,7 +190,7 @@ uint16_t bgp_attr_df_pref_from_ec(struct attr *attr, uint8_t *alg)
|
||||
uint32_t bgp_attr_mac_mobility_seqnum(struct attr *attr, uint8_t *sticky)
|
||||
{
|
||||
struct ecommunity *ecom;
|
||||
int i;
|
||||
uint32_t i;
|
||||
uint8_t flags = 0;
|
||||
|
||||
ecom = attr->ecommunity;
|
||||
@ -237,7 +237,7 @@ void bgp_attr_evpn_na_flag(struct attr *attr,
|
||||
uint8_t *router_flag, bool *proxy)
|
||||
{
|
||||
struct ecommunity *ecom;
|
||||
int i;
|
||||
uint32_t i;
|
||||
uint8_t val;
|
||||
|
||||
ecom = attr->ecommunity;
|
||||
|
@ -95,7 +95,7 @@ static bool ecommunity_add_val_internal(struct ecommunity *ecom,
|
||||
bool unique, bool overwrite,
|
||||
uint8_t ecom_size)
|
||||
{
|
||||
int c, ins_idx;
|
||||
uint32_t c, ins_idx;
|
||||
const struct ecommunity_val *eval4 = (struct ecommunity_val *)eval;
|
||||
const struct ecommunity_val_ipv6 *eval6 =
|
||||
(struct ecommunity_val_ipv6 *)eval;
|
||||
@ -113,7 +113,7 @@ static bool ecommunity_add_val_internal(struct ecommunity *ecom,
|
||||
/* check also if the extended community itself exists. */
|
||||
c = 0;
|
||||
|
||||
ins_idx = -1;
|
||||
ins_idx = UINT32_MAX;
|
||||
for (uint8_t *p = ecom->val; c < ecom->size;
|
||||
p += ecom_size, c++) {
|
||||
if (unique) {
|
||||
@ -145,12 +145,12 @@ static bool ecommunity_add_val_internal(struct ecommunity *ecom,
|
||||
if (ret > 0) {
|
||||
if (!unique)
|
||||
break;
|
||||
if (ins_idx == -1)
|
||||
if (ins_idx == UINT32_MAX)
|
||||
ins_idx = c;
|
||||
}
|
||||
}
|
||||
|
||||
if (ins_idx == -1)
|
||||
if (ins_idx == UINT32_MAX)
|
||||
ins_idx = c;
|
||||
|
||||
/* Add the value to the structure with numerical sorting. */
|
||||
@ -193,7 +193,7 @@ static struct ecommunity *
|
||||
ecommunity_uniq_sort_internal(struct ecommunity *ecom,
|
||||
unsigned short ecom_size)
|
||||
{
|
||||
int i;
|
||||
uint32_t i;
|
||||
struct ecommunity *new;
|
||||
const void *eval;
|
||||
|
||||
@ -895,7 +895,7 @@ static int ecommunity_lb_str(char *buf, size_t bufsz, const uint8_t *pnt)
|
||||
*/
|
||||
char *ecommunity_ecom2str(struct ecommunity *ecom, int format, int filter)
|
||||
{
|
||||
int i;
|
||||
uint32_t i;
|
||||
uint8_t *pnt;
|
||||
uint8_t type = 0;
|
||||
uint8_t sub_type = 0;
|
||||
@ -1176,8 +1176,8 @@ char *ecommunity_ecom2str(struct ecommunity *ecom, int format, int filter)
|
||||
bool ecommunity_match(const struct ecommunity *ecom1,
|
||||
const struct ecommunity *ecom2)
|
||||
{
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
uint32_t i = 0;
|
||||
uint32_t j = 0;
|
||||
|
||||
if (ecom1 == NULL && ecom2 == NULL)
|
||||
return true;
|
||||
@ -1209,7 +1209,7 @@ extern struct ecommunity_val *ecommunity_lookup(const struct ecommunity *ecom,
|
||||
uint8_t type, uint8_t subtype)
|
||||
{
|
||||
uint8_t *p;
|
||||
int c;
|
||||
uint32_t c;
|
||||
|
||||
/* If the value already exists in the structure return 0. */
|
||||
c = 0;
|
||||
@ -1230,7 +1230,7 @@ bool ecommunity_strip(struct ecommunity *ecom, uint8_t type,
|
||||
uint8_t subtype)
|
||||
{
|
||||
uint8_t *p, *q, *new;
|
||||
int c, found = 0;
|
||||
uint32_t c, found = 0;
|
||||
/* When this is fist value, just add it. */
|
||||
if (ecom == NULL || ecom->val == NULL)
|
||||
return false;
|
||||
@ -1278,7 +1278,7 @@ bool ecommunity_strip(struct ecommunity *ecom, uint8_t type,
|
||||
bool ecommunity_del_val(struct ecommunity *ecom, struct ecommunity_val *eval)
|
||||
{
|
||||
uint8_t *p;
|
||||
int c, found = 0;
|
||||
uint32_t c, found = 0;
|
||||
|
||||
/* Make sure specified value exists. */
|
||||
if (ecom == NULL || ecom->val == NULL)
|
||||
@ -1512,7 +1512,7 @@ void bgp_remove_ecomm_from_aggregate_hash(struct bgp_aggregate *aggregate,
|
||||
const uint8_t *ecommunity_linkbw_present(struct ecommunity *ecom, uint32_t *bw)
|
||||
{
|
||||
const uint8_t *eval;
|
||||
int i;
|
||||
uint32_t i;
|
||||
|
||||
if (bw)
|
||||
*bw = 0;
|
||||
|
@ -114,7 +114,7 @@ struct ecommunity {
|
||||
uint8_t unit_size;
|
||||
|
||||
/* Size of Extended Communities attribute. */
|
||||
int size;
|
||||
uint32_t size;
|
||||
|
||||
/* Extended Communities value. */
|
||||
uint8_t *val;
|
||||
|
@ -870,7 +870,7 @@ static void add_mac_mobility_to_attr(uint32_t seq_num, struct attr *attr)
|
||||
struct ecommunity ecom_tmp;
|
||||
struct ecommunity_val eval;
|
||||
uint8_t *ecom_val_ptr;
|
||||
int i;
|
||||
uint32_t i;
|
||||
uint8_t *pnt;
|
||||
int type = 0;
|
||||
int sub_type = 0;
|
||||
@ -2710,7 +2710,7 @@ static int is_route_matching_for_vrf(struct bgp *bgp_vrf,
|
||||
{
|
||||
struct attr *attr = pi->attr;
|
||||
struct ecommunity *ecom;
|
||||
int i;
|
||||
uint32_t i;
|
||||
|
||||
assert(attr);
|
||||
/* Route should have valid RT to be even considered. */
|
||||
@ -2777,7 +2777,7 @@ static int is_route_matching_for_vni(struct bgp *bgp, struct bgpevpn *vpn,
|
||||
{
|
||||
struct attr *attr = pi->attr;
|
||||
struct ecommunity *ecom;
|
||||
int i;
|
||||
uint32_t i;
|
||||
|
||||
assert(attr);
|
||||
/* Route should have valid RT to be even considered. */
|
||||
@ -3260,7 +3260,7 @@ static int bgp_evpn_install_uninstall_table(struct bgp *bgp, afi_t afi,
|
||||
struct prefix_evpn *evp = (struct prefix_evpn *)p;
|
||||
struct attr *attr = pi->attr;
|
||||
struct ecommunity *ecom;
|
||||
int i;
|
||||
uint32_t i;
|
||||
struct prefix_evpn ad_evp;
|
||||
|
||||
assert(attr);
|
||||
@ -4906,7 +4906,7 @@ int bgp_nlri_parse_evpn(struct peer *peer, struct attr *attr,
|
||||
*/
|
||||
void bgp_evpn_map_vrf_to_its_rts(struct bgp *bgp_vrf)
|
||||
{
|
||||
int i = 0;
|
||||
uint32_t i = 0;
|
||||
struct ecommunity_val *eval = NULL;
|
||||
struct listnode *node = NULL, *nnode = NULL;
|
||||
struct ecommunity *ecom = NULL;
|
||||
@ -4926,7 +4926,7 @@ void bgp_evpn_map_vrf_to_its_rts(struct bgp *bgp_vrf)
|
||||
*/
|
||||
void bgp_evpn_unmap_vrf_from_its_rts(struct bgp *bgp_vrf)
|
||||
{
|
||||
int i;
|
||||
uint32_t i;
|
||||
struct ecommunity_val *eval;
|
||||
struct listnode *node, *nnode;
|
||||
struct ecommunity *ecom;
|
||||
@ -4963,7 +4963,7 @@ void bgp_evpn_unmap_vrf_from_its_rts(struct bgp *bgp_vrf)
|
||||
*/
|
||||
void bgp_evpn_map_vni_to_its_rts(struct bgp *bgp, struct bgpevpn *vpn)
|
||||
{
|
||||
int i;
|
||||
uint32_t i;
|
||||
struct ecommunity_val *eval;
|
||||
struct listnode *node, *nnode;
|
||||
struct ecommunity *ecom;
|
||||
@ -4983,7 +4983,7 @@ void bgp_evpn_map_vni_to_its_rts(struct bgp *bgp, struct bgpevpn *vpn)
|
||||
*/
|
||||
void bgp_evpn_unmap_vni_from_its_rts(struct bgp *bgp, struct bgpevpn *vpn)
|
||||
{
|
||||
int i;
|
||||
uint32_t i;
|
||||
struct ecommunity_val *eval;
|
||||
struct listnode *node, *nnode;
|
||||
struct ecommunity *ecom;
|
||||
|
@ -419,8 +419,7 @@ int vpn_leak_label_callback(
|
||||
|
||||
static bool ecom_intersect(struct ecommunity *e1, struct ecommunity *e2)
|
||||
{
|
||||
int i;
|
||||
int j;
|
||||
uint32_t i, j;
|
||||
|
||||
if (!e1 || !e2)
|
||||
return false;
|
||||
|
@ -754,7 +754,7 @@ int bgp_pbr_build_and_validate_entry(const struct prefix *p,
|
||||
struct bgp_pbr_entry_main *api)
|
||||
{
|
||||
int ret;
|
||||
int i, action_count = 0;
|
||||
uint32_t i, action_count = 0;
|
||||
struct ecommunity *ecom;
|
||||
struct ecommunity_val *ecom_eval;
|
||||
struct bgp_pbr_entry_action *api_action;
|
||||
|
@ -984,7 +984,7 @@ static int rfapiEcommunitiesMatchBeec(struct ecommunity *ecom,
|
||||
|
||||
int rfapiEcommunitiesIntersect(struct ecommunity *e1, struct ecommunity *e2)
|
||||
{
|
||||
int i, j;
|
||||
uint32_t i, j;
|
||||
|
||||
if (!e1 || !e2)
|
||||
return 0;
|
||||
@ -1014,7 +1014,8 @@ int rfapiEcommunitiesIntersect(struct ecommunity *e1, struct ecommunity *e2)
|
||||
int rfapiEcommunityGetLNI(struct ecommunity *ecom, uint32_t *lni)
|
||||
{
|
||||
if (ecom) {
|
||||
int i;
|
||||
uint32_t i;
|
||||
|
||||
for (i = 0; i < ecom->size; ++i) {
|
||||
uint8_t *p = ecom->val + (i * ECOMMUNITY_SIZE);
|
||||
|
||||
@ -1034,7 +1035,8 @@ int rfapiEcommunityGetEthernetTag(struct ecommunity *ecom, uint16_t *tag_id)
|
||||
struct bgp *bgp = bgp_get_default();
|
||||
*tag_id = 0; /* default to untagged */
|
||||
if (ecom) {
|
||||
int i;
|
||||
uint32_t i;
|
||||
|
||||
for (i = 0; i < ecom->size; ++i) {
|
||||
as_t as = 0;
|
||||
int encode = 0;
|
||||
|
@ -134,7 +134,7 @@ static void encap_attr_export_ce(struct attr *new, struct attr *orig,
|
||||
static int getce(struct bgp *bgp, struct attr *attr, struct prefix *pfx_ce)
|
||||
{
|
||||
uint8_t *ecp;
|
||||
int i;
|
||||
uint32_t i;
|
||||
uint16_t localadmin = bgp->rfapi_cfg->resolve_nve_roo_local_admin;
|
||||
|
||||
for (ecp = attr->ecommunity->val, i = 0; i < attr->ecommunity->size;
|
||||
|
Loading…
Reference in New Issue
Block a user