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>
bgp_encap_types *tunnel_type)
{
struct ecommunity *ecom;
- int i;
+ uint32_t i;
+
if (!attr)
return;
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);
/* 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;
uint8_t bgp_attr_default_gw(struct attr *attr)
{
struct ecommunity *ecom;
- int i;
+ uint32_t i;
ecom = attr->ecommunity;
if (!ecom || !ecom->size)
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;
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;
uint8_t *router_flag, bool *proxy)
{
struct ecommunity *ecom;
- int i;
+ uint32_t i;
uint8_t val;
ecom = attr->ecommunity;
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;
/* 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) {
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. */
ecommunity_uniq_sort_internal(struct ecommunity *ecom,
unsigned short ecom_size)
{
- int i;
+ uint32_t i;
struct ecommunity *new;
const void *eval;
*/
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;
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;
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;
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;
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)
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;
uint8_t unit_size;
/* Size of Extended Communities attribute. */
- int size;
+ uint32_t size;
/* Extended Communities value. */
uint8_t *val;
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;
{
struct attr *attr = pi->attr;
struct ecommunity *ecom;
- int i;
+ uint32_t i;
assert(attr);
/* Route should have valid RT to be even considered. */
{
struct attr *attr = pi->attr;
struct ecommunity *ecom;
- int i;
+ uint32_t i;
assert(attr);
/* Route should have valid RT to be even considered. */
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);
*/
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;
*/
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;
*/
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;
*/
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;
static bool ecom_intersect(struct ecommunity *e1, struct ecommunity *e2)
{
- int i;
- int j;
+ uint32_t i, j;
if (!e1 || !e2)
return false;
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;
int rfapiEcommunitiesIntersect(struct ecommunity *e1, struct ecommunity *e2)
{
- int i, j;
+ uint32_t i, j;
if (!e1 || !e2)
return 0;
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);
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;
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;