diff options
| author | Philippe Guibert <philippe.guibert@6wind.com> | 2020-07-02 08:14:41 +0200 |
|---|---|---|
| committer | Philippe Guibert <philippe.guibert@6wind.com> | 2020-08-21 13:37:08 +0200 |
| commit | 4371bf9110261f81edfd457a33f86cb0ce12ada7 (patch) | |
| tree | dd9edcb9e1150b398cf1123ae34474401f0d7cca | |
| parent | 7659ad686a5605ea3cdaab23690eb63a99f69c1b (diff) | |
bgpd: remove warnings related to line too longs in bgp code
remove warnings related to line too long in bgp code.
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
| -rw-r--r-- | bgpd/bgp_ecommunity.c | 113 | ||||
| -rw-r--r-- | bgpd/bgp_evpn.c | 9 | ||||
| -rw-r--r-- | bgpd/bgp_pbr.c | 25 | ||||
| -rw-r--r-- | bgpd/bgp_route.c | 3 |
4 files changed, 88 insertions, 62 deletions
diff --git a/bgpd/bgp_ecommunity.c b/bgpd/bgp_ecommunity.c index ce67abd364..79fb7e55e9 100644 --- a/bgpd/bgp_ecommunity.c +++ b/bgpd/bgp_ecommunity.c @@ -88,12 +88,15 @@ static void ecommunity_hash_free(struct ecommunity *ecom) once and whether the new value should replace what is existing or not. */ -static bool ecommunity_add_val_internal(struct ecommunity *ecom, const void *eval, - bool unique, bool overwrite, uint8_t ecom_size) +static bool ecommunity_add_val_internal(struct ecommunity *ecom, + const void *eval, + bool unique, bool overwrite, + uint8_t ecom_size) { int c, ins_idx; const struct ecommunity_val *eval4 = (struct ecommunity_val *)eval; - const struct ecommunity_val_ipv6 *eval6 = (struct ecommunity_val_ipv6 *)eval; + const struct ecommunity_val_ipv6 *eval6 = + (struct ecommunity_val_ipv6 *)eval; /* When this is fist value, just add it. */ if (ecom->val == NULL) { @@ -116,7 +119,8 @@ static bool ecommunity_add_val_internal(struct ecommunity *ecom, const void *eva if (p[0] == eval4->val[0] && p[1] == eval4->val[1]) { if (overwrite) { - memcpy(p, eval4->val, ecom_size); + memcpy(p, eval4->val, + ecom_size); return true; } return false; @@ -125,7 +129,8 @@ static bool ecommunity_add_val_internal(struct ecommunity *ecom, const void *eva if (p[0] == eval6->val[0] && p[1] == eval6->val[1]) { if (overwrite) { - memcpy(p, eval6->val, ecom_size); + memcpy(p, eval6->val, + ecom_size); return true; } return false; @@ -162,10 +167,11 @@ static bool ecommunity_add_val_internal(struct ecommunity *ecom, const void *eva } /* Add a new Extended Communities value to Extended Communities - Attribute structure. When the value is already exists in the - structure, we don't add the value. Newly added value is sorted by - numerical order. When the value is added to the structure return 1 - else return 0. */ + * Attribute structure. When the value is already exists in the + * structure, we don't add the value. Newly added value is sorted by + * numerical order. When the value is added to the structure return 1 + * else return 0. + */ bool ecommunity_add_val(struct ecommunity *ecom, struct ecommunity_val *eval, bool unique, bool overwrite) { @@ -173,8 +179,9 @@ bool ecommunity_add_val(struct ecommunity *ecom, struct ecommunity_val *eval, overwrite, ECOMMUNITY_SIZE); } -bool ecommunity_add_val_ipv6(struct ecommunity *ecom, struct ecommunity_val_ipv6 *eval, - bool unique, bool overwrite) +bool ecommunity_add_val_ipv6(struct ecommunity *ecom, + struct ecommunity_val_ipv6 *eval, + bool unique, bool overwrite) { return ecommunity_add_val_internal(ecom, (const void *)eval, unique, overwrite, IPV6_ECOMMUNITY_SIZE); @@ -202,8 +209,9 @@ ecommunity_uniq_sort_internal(struct ecommunity *ecom, } /* This function takes pointer to Extended Communites strucutre then - create a new Extended Communities structure by uniq and sort each - Extended Communities value. */ + * create a new Extended Communities structure by uniq and sort each + * Extended Communities value. + */ struct ecommunity *ecommunity_uniq_sort(struct ecommunity *ecom) { return ecommunity_uniq_sort_internal(ecom, ECOMMUNITY_SIZE); @@ -678,7 +686,8 @@ static struct ecommunity *ecommunity_str2com_internal(const char *str, int type, if (ecom == NULL) ecom = ecommunity_new(); eval.val[1] = type; - ecommunity_add_val_internal(ecom, (void *)&eval, false, false, + ecommunity_add_val_internal(ecom, (void *)&eval, + false, false, ecom->unit_size); break; case ecommunity_token_val6: @@ -707,31 +716,31 @@ static struct ecommunity *ecommunity_str2com_internal(const char *str, int type, } /* Convert string to extended community attribute. - - When type is already known, please specify both str and type. str - should not include keyword such as "rt" and "soo". Type is - ECOMMUNITY_ROUTE_TARGET or ECOMMUNITY_SITE_ORIGIN. - keyword_included should be zero. - - For example route-map's "set extcommunity" command case: - - "rt 100:1 100:2 100:3" -> str = "100:1 100:2 100:3" - type = ECOMMUNITY_ROUTE_TARGET - keyword_included = 0 - - "soo 100:1" -> str = "100:1" - type = ECOMMUNITY_SITE_ORIGIN - keyword_included = 0 - - When string includes keyword for each extended community value. - Please specify keyword_included as non-zero value. - - For example standard extcommunity-list case: - - "rt 100:1 rt 100:2 soo 100:1" -> str = "rt 100:1 rt 100:2 soo 100:1" - type = 0 - keyword_include = 1 -*/ + * + * When type is already known, please specify both str and type. str + * should not include keyword such as "rt" and "soo". Type is + * ECOMMUNITY_ROUTE_TARGET or ECOMMUNITY_SITE_ORIGIN. + * keyword_included should be zero. + * + * For example route-map's "set extcommunity" command case: + * + * "rt 100:1 100:2 100:3" -> str = "100:1 100:2 100:3" + * type = ECOMMUNITY_ROUTE_TARGET + * keyword_included = 0 + * + * "soo 100:1" -> str = "100:1" + * type = ECOMMUNITY_SITE_ORIGIN + * keyword_included = 0 + * + * When string includes keyword for each extended community value. + * Please specify keyword_included as non-zero value. + * + * For example standard extcommunity-list case: + * + * "rt 100:1 rt 100:2 soo 100:1" -> str = "rt 100:1 rt 100:2 soo 100:1" + * type = 0 + * keyword_include = 1 + */ struct ecommunity *ecommunity_str2com(const char *str, int type, int keyword_included) { @@ -789,7 +798,8 @@ static int ecommunity_rt_soo_str_internal(char *buf, size_t bufsz, eas.as |= (*pnt++); pnt = ptr_get_be32(pnt, &eas.val); - len = snprintf(buf, bufsz, "%s%u:%u", prefix, eas.as, eas.val); + len = snprintf(buf, bufsz, "%s%u:%u", prefix, eas.as, + eas.val); } else { /* this is an IPv6 ext community * first 16 bytes stands for IPv6 addres @@ -799,7 +809,8 @@ static int ecommunity_rt_soo_str_internal(char *buf, size_t bufsz, eip6.val = (*pnt++ << 8); eip6.val |= (*pnt++); - inet_ntop(AF_INET6, &eip6.ip, buf_local, sizeof(buf_local)); + inet_ntop(AF_INET6, &eip6.ip, buf_local, + sizeof(buf_local)); len = snprintf(buf, bufsz, "%s%s:%u", prefix, buf_local, eip6.val); } @@ -1052,7 +1063,8 @@ char *ecommunity_ecom2str(struct ecommunity *ecom, int format, int filter) format, ecom->unit_size); snprintf(encbuf, sizeof(encbuf), "%s", buf); - } else if (sub_type == ECOMMUNITY_FLOWSPEC_REDIRECT_IPV6) { + } else if (sub_type == + ECOMMUNITY_FLOWSPEC_REDIRECT_IPV6) { char buf[64]; memset(buf, 0, sizeof(buf)); @@ -1063,19 +1075,22 @@ char *ecommunity_ecom2str(struct ecommunity *ecom, int format, int filter) ECOMMUNITY_ROUTE_TARGET, ECOMMUNITY_FORMAT_DISPLAY, ecom->unit_size); - snprintf(encbuf, sizeof(encbuf), "FS:redirect VRF %s", buf); + snprintf(encbuf, sizeof(encbuf), + "FS:redirect VRF %s", buf); } else if (sub_type == ECOMMUNITY_REDIRECT_VRF) { char buf[16]; memset(buf, 0, sizeof(buf)); - ecommunity_rt_soo_str(buf, sizeof(buf), (const uint8_t *)pnt, - type & - ~ECOMMUNITY_ENCODE_TRANS_EXP, - ECOMMUNITY_ROUTE_TARGET, - ECOMMUNITY_FORMAT_DISPLAY); + ecommunity_rt_soo_str(buf, sizeof(buf), + (const uint8_t *)pnt, + type & + ~ECOMMUNITY_ENCODE_TRANS_EXP, + ECOMMUNITY_ROUTE_TARGET, + ECOMMUNITY_FORMAT_DISPLAY); + snprintf(encbuf, sizeof(encbuf), + "FS:redirect VRF %s", buf); snprintf(encbuf, sizeof(encbuf), "FS:redirect VRF %s", buf); - snprintf(encbuf, sizeof(encbuf), "FS:redirect VRF %s", buf); } else if (type != ECOMMUNITY_ENCODE_TRANS_EXP) unk_ecom = 1; else if (sub_type == ECOMMUNITY_TRAFFIC_ACTION) { diff --git a/bgpd/bgp_evpn.c b/bgpd/bgp_evpn.c index e552866f38..8c3e54566e 100644 --- a/bgpd/bgp_evpn.c +++ b/bgpd/bgp_evpn.c @@ -876,7 +876,8 @@ static void add_mac_mobility_to_attr(uint32_t seq_num, struct attr *attr) if (attr->ecommunity) { for (i = 0; i < attr->ecommunity->size; i++) { - pnt = attr->ecommunity->val + (i * attr->ecommunity->unit_size); + pnt = attr->ecommunity->val + + (i * attr->ecommunity->unit_size); type = *pnt++; sub_type = *pnt++; @@ -884,7 +885,8 @@ static void add_mac_mobility_to_attr(uint32_t seq_num, struct attr *attr) && sub_type == ECOMMUNITY_EVPN_SUBTYPE_MACMOBILITY) { ecom_val_ptr = - (attr->ecommunity->val + (i * attr->ecommunity->unit_size)); + (attr->ecommunity->val + + (i * attr->ecommunity->unit_size)); break; } } @@ -892,7 +894,8 @@ static void add_mac_mobility_to_attr(uint32_t seq_num, struct attr *attr) /* Update the existing MM ecommunity */ if (ecom_val_ptr) { - memcpy(ecom_val_ptr, eval.val, sizeof(char) * attr->ecommunity->unit_size); + memcpy(ecom_val_ptr, eval.val, sizeof(char) + * attr->ecommunity->unit_size); } /* Add MM to existing */ else { diff --git a/bgpd/bgp_pbr.c b/bgpd/bgp_pbr.c index 0c36f138f1..f6e5c196ca 100644 --- a/bgpd/bgp_pbr.c +++ b/bgpd/bgp_pbr.c @@ -172,7 +172,8 @@ static int bgp_pbr_match_walkcb(struct hash_bucket *bucket, void *arg) return HASHWALK_CONTINUE; } -static int snprintf_bgp_pbr_match_val(char *str, int len, struct bgp_pbr_match_val *mval, +static int snprintf_bgp_pbr_match_val(char *str, int len, + struct bgp_pbr_match_val *mval, const char *prepend) { char *ptr = str; @@ -852,14 +853,16 @@ int bgp_pbr_build_and_validate_entry(const struct prefix *p, api_action_redirect_ip->u.zr.duplicate = ecom_eval->val[7]; continue; - } else if (p->u.prefix_flowspec.family == AF_INET) { + } else if (p->u.prefix_flowspec.family == + AF_INET) { api_action->action = ACTION_REDIRECT_IP; api_action->u.zr.redirect_ip_v4.s_addr = path->attr->nexthop.s_addr; api_action->u.zr.duplicate = ecom_eval->val[7]; api_action_redirect_ip = api_action; - } else if (p->u.prefix_flowspec.family == AF_INET6) { + } else if (p->u.prefix_flowspec.family == + AF_INET6) { api_action->action = ACTION_REDIRECT_IP; memcpy(&api_action->u .zr.redirect_ip_v6, @@ -903,8 +906,8 @@ int bgp_pbr_build_and_validate_entry(const struct prefix *p, afi); if (ret != 0) continue; - if ((api_action->action == ACTION_TRAFFICRATE) && - api->actions[i].u.r.rate == 0) + if ((api_action->action == ACTION_TRAFFICRATE) + && api->actions[i].u.r.rate == 0) discard_action_found = true; } api->action_num++; @@ -1465,7 +1468,8 @@ void bgp_pbr_print_policy_route(struct bgp_pbr_entry_main *api) prefix2str(p, buff, 64), api->dst_prefix_offset); else - delta = snprintf(ptr, len, "@dst %s", prefix2str(p, buff, 64)); + delta = snprintf(ptr, len, "@dst %s", + prefix2str(p, buff, 64)); len -= delta; ptr += delta; } @@ -1527,7 +1531,8 @@ void bgp_pbr_print_policy_route(struct bgp_pbr_entry_main *api) if (api->match_packet_length_num) INCREMENT_DISPLAY(ptr, nb_items, len); for (i = 0; i < api->match_packet_length_num; i++) { - delta = snprintf_bgp_pbr_match_val(ptr, len, &api->packet_length[i], + delta = snprintf_bgp_pbr_match_val(ptr, len, + &api->packet_length[i], i > 0 ? NULL : "@plen "); len -= delta; ptr += delta; @@ -1545,7 +1550,8 @@ void bgp_pbr_print_policy_route(struct bgp_pbr_entry_main *api) if (api->match_flowlabel_num) INCREMENT_DISPLAY(ptr, nb_items, len); for (i = 0; i < api->match_flowlabel_num; i++) { - delta = snprintf_bgp_pbr_match_val(ptr, len, &api->flow_label[i], + delta = snprintf_bgp_pbr_match_val(ptr, len, + &api->flow_label[i], i > 0 ? NULL : "@flowlabel "); len -= delta; ptr += delta; @@ -2474,7 +2480,8 @@ static void bgp_pbr_policyroute_add_to_zebra_unit(struct bgp *bgp, if (bpm->unique == 0) { bpm->unique = ++bgp_pbr_match_counter_unique; /* 0 value is forbidden */ - snprintf(bpm->ipset_name, sizeof(bpm->ipset_name), "match%p", bpm); + snprintf(bpm->ipset_name, sizeof(bpm->ipset_name), + "match%p", bpm); bpm->entry_hash = hash_create_size(8, bgp_pbr_match_entry_hash_key, bgp_pbr_match_entry_hash_equal, diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index eefff4bef8..e8baac2c32 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -10014,7 +10014,8 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, safi_t safi, dest_p->u.prefix_flowspec.ptr, dest_p->u.prefix_flowspec.prefixlen, retstr, NLRI_STRING_FORMAT_MIN, NULL, - family2afi(dest_p->u.prefix_flowspec.family)); + family2afi(dest_p->u + .prefix_flowspec.family)); if (first) vty_out(vty, "\"%s/%d\": ", retstr, dest_p->u.prefix_flowspec |
