Skip to content

Commit

Permalink
bgpd: define val in ecommunity_val as uint8_t
Browse files Browse the repository at this point in the history
The type of the val field in ecommunity_val is used inconsistently
in a number of places. It should be defined as uint8_t.

Signed-off-by: Enke Chen <[email protected]>
  • Loading branch information
enkechen-panw committed Sep 17, 2024
1 parent da96ad0 commit 7d41a14
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions bgpd/bgp_ecommunity.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,12 @@ struct ecommunity_ip6 {

/* Extended community value is eight octet. */
struct ecommunity_val {
char val[ECOMMUNITY_SIZE];
uint8_t val[ECOMMUNITY_SIZE];
};

/* IPv6 Extended community value is eight octet. */
struct ecommunity_val_ipv6 {
char val[IPV6_ECOMMUNITY_SIZE];
uint8_t val[IPV6_ECOMMUNITY_SIZE];
};

#define ecom_length_size(X, Y) ((X)->size * (Y))
Expand Down
4 changes: 2 additions & 2 deletions bgpd/bgp_evpn.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ int vni_list_cmp(void *p1, void *p2)
static unsigned int vrf_import_rt_hash_key_make(const void *p)
{
const struct vrf_irt_node *irt = p;
const char *pnt = irt->rt.val;
const uint8_t *pnt = irt->rt.val;

return jhash(pnt, 8, 0x5abc1234);
}
Expand Down Expand Up @@ -229,7 +229,7 @@ static int is_vrf_present_in_irt_vrfs(struct list *vrfs, struct bgp *bgp_vrf)
static unsigned int import_rt_hash_key_make(const void *p)
{
const struct irt_node *irt = p;
const char *pnt = irt->rt.val;
const uint8_t *pnt = irt->rt.val;

return jhash(pnt, 8, 0xdeadbeef);
}
Expand Down
22 changes: 11 additions & 11 deletions bgpd/bgp_pbr.c
Original file line number Diff line number Diff line change
Expand Up @@ -776,13 +776,13 @@ int bgp_pbr_build_and_validate_entry(const struct prefix *p,
api_action = &api->actions[action_count - 1];

if ((ecom_eval->val[1] ==
(char)ECOMMUNITY_REDIRECT_VRF) &&
ECOMMUNITY_REDIRECT_VRF) &&
(ecom_eval->val[0] ==
(char)ECOMMUNITY_ENCODE_TRANS_EXP ||
ECOMMUNITY_ENCODE_TRANS_EXP ||
ecom_eval->val[0] ==
(char)ECOMMUNITY_EXTENDED_COMMUNITY_PART_2 ||
ECOMMUNITY_EXTENDED_COMMUNITY_PART_2 ||
ecom_eval->val[0] ==
(char)ECOMMUNITY_EXTENDED_COMMUNITY_PART_3)) {
ECOMMUNITY_EXTENDED_COMMUNITY_PART_3)) {
struct ecommunity *eckey = ecommunity_new();
struct ecommunity_val ecom_copy;

Expand All @@ -800,9 +800,9 @@ int bgp_pbr_build_and_validate_entry(const struct prefix *p,
eckey);
ecommunity_free(&eckey);
} else if ((ecom_eval->val[0] ==
(char)ECOMMUNITY_ENCODE_REDIRECT_IP_NH) &&
ECOMMUNITY_ENCODE_REDIRECT_IP_NH) &&
(ecom_eval->val[1] ==
(char)ECOMMUNITY_REDIRECT_IP_NH)) {
ECOMMUNITY_REDIRECT_IP_NH)) {
/* in case the 2 ecom present,
* do not overwrite
* draft-ietf-idr-flowspec-redirect
Expand Down Expand Up @@ -862,9 +862,9 @@ int bgp_pbr_build_and_validate_entry(const struct prefix *p,
api_action_redirect_ip = api_action;
}
} else if ((ecom_eval->val[0] ==
(char)ECOMMUNITY_ENCODE_IP) &&
ECOMMUNITY_ENCODE_IP) &&
(ecom_eval->val[1] ==
(char)ECOMMUNITY_FLOWSPEC_REDIRECT_IPV4)) {
ECOMMUNITY_FLOWSPEC_REDIRECT_IPV4)) {
/* in case the 2 ecom present,
* overwrite simpson draft
* update redirect ip fields
Expand All @@ -888,7 +888,7 @@ int bgp_pbr_build_and_validate_entry(const struct prefix *p,
}
} else {
if (ecom_eval->val[0] !=
(char)ECOMMUNITY_ENCODE_TRANS_EXP)
ECOMMUNITY_ENCODE_TRANS_EXP)
continue;
ret = ecommunity_fill_pbr_action(ecom_eval,
api_action,
Expand Down Expand Up @@ -920,9 +920,9 @@ int bgp_pbr_build_and_validate_entry(const struct prefix *p,
}
api_action = &api->actions[action_count - 1];
if ((ipv6_ecom_eval->val[1] ==
(char)ECOMMUNITY_FLOWSPEC_REDIRECT_IPV6) &&
ECOMMUNITY_FLOWSPEC_REDIRECT_IPV6) &&
(ipv6_ecom_eval->val[0] ==
(char)ECOMMUNITY_ENCODE_TRANS_EXP)) {
ECOMMUNITY_ENCODE_TRANS_EXP)) {
struct ecommunity *eckey = ecommunity_new();
struct ecommunity_val_ipv6 ecom_copy;

Expand Down

0 comments on commit 7d41a14

Please sign in to comment.