Skip to content

Commit

Permalink
zebra: clang-format for the refactor
Browse files Browse the repository at this point in the history
apply formatting rules to the code within the refactor commits.

Signed-off-by: Pat Ruddy <pat@voltanet.io>
  • Loading branch information
pjdruddy committed Aug 10, 2020
1 parent 87073be commit c20a811
Show file tree
Hide file tree
Showing 6 changed files with 187 additions and 186 deletions.
61 changes: 30 additions & 31 deletions zebra/zebra_evpn.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ static const struct message zvtep_flood_str[] = {
{VXLAN_FLOOD_DISABLED, VXLAN_FLOOD_STR_NO_INFO},
{VXLAN_FLOOD_PIM_SM, "PIM-SM"},
{VXLAN_FLOOD_HEAD_END_REPL, "HER"},
{0}
};
{0}};

int advertise_gw_macip_enabled(zebra_evpn_t *zevpn)
{
Expand Down Expand Up @@ -116,7 +115,8 @@ void zebra_evpn_print(zebra_evpn_t *zevpn, void **ctxt)
if (json == NULL) {
vty_out(vty, "VNI: %u\n", zevpn->vni);
vty_out(vty, " Type: %s\n", "L2");
vty_out(vty, " Tenant VRF: %s\n", vrf_id_to_name(zevpn->vrf_id));
vty_out(vty, " Tenant VRF: %s\n",
vrf_id_to_name(zevpn->vrf_id));
} else {
json_object_int_add(json, "vni", zevpn->vni);
json_object_string_add(json, "type", "L2");
Expand All @@ -136,18 +136,18 @@ void zebra_evpn_print(zebra_evpn_t *zevpn, void **ctxt)
vty_out(vty, " VxLAN ifIndex: %u\n", zevpn->vxlan_if->ifindex);
vty_out(vty, " Local VTEP IP: %s\n",
inet_ntoa(zevpn->local_vtep_ip));
vty_out(vty, " Mcast group: %s\n",
inet_ntoa(zevpn->mcast_grp));
vty_out(vty, " Mcast group: %s\n", inet_ntoa(zevpn->mcast_grp));
} else {
json_object_string_add(json, "vxlanInterface",
zevpn->vxlan_if->name);
json_object_int_add(json, "ifindex", zevpn->vxlan_if->ifindex);
json_object_string_add(json, "vtepIp",
inet_ntoa(zevpn->local_vtep_ip));
json_object_string_add(json, "mcastGroup",
inet_ntoa(zevpn->mcast_grp));
inet_ntoa(zevpn->mcast_grp));
json_object_string_add(json, "advertiseGatewayMacip",
zevpn->advertise_gw_macip ? "Yes" : "No");
zevpn->advertise_gw_macip ? "Yes"
: "No");
json_object_int_add(json, "numMacs", num_macs);
json_object_int_add(json, "numArpNd", num_neigh);
}
Expand All @@ -160,19 +160,18 @@ void zebra_evpn_print(zebra_evpn_t *zevpn, void **ctxt)
else
json_vtep_list = json_object_new_array();
for (zvtep = zevpn->vteps; zvtep; zvtep = zvtep->next) {
const char *flood_str = lookup_msg(zvtep_flood_str,
zvtep->flood_control,
VXLAN_FLOOD_STR_DEFAULT);
const char *flood_str = lookup_msg(
zvtep_flood_str, zvtep->flood_control,
VXLAN_FLOOD_STR_DEFAULT);

if (json == NULL) {
vty_out(vty, " %s flood: %s\n",
inet_ntoa(zvtep->vtep_ip),
flood_str);
inet_ntoa(zvtep->vtep_ip), flood_str);
} else {
json_ip_str = json_object_new_string(
inet_ntoa(zvtep->vtep_ip));
inet_ntoa(zvtep->vtep_ip));
json_object_array_add(json_vtep_list,
json_ip_str);
json_ip_str);
}
}
if (json)
Expand Down Expand Up @@ -235,7 +234,7 @@ void zebra_evpn_print_hash(struct hash_bucket *bucket, void *ctxt[])
json_object_string_add(json_evpn, "type", "L2");
json_object_string_add(json_evpn, "vxlanIf",
zevpn->vxlan_if ? zevpn->vxlan_if->name
: "unknown");
: "unknown");
json_object_int_add(json_evpn, "numMacs", num_macs);
json_object_int_add(json_evpn, "numArpNd", num_neigh);
json_object_int_add(json_evpn, "numRemoteVteps", num_vteps);
Expand Down Expand Up @@ -451,11 +450,10 @@ int zebra_evpn_gw_macip_del(struct interface *ifp, zebra_evpn_t *zevpn,
mac = zebra_evpn_mac_lookup(zevpn, &n->emac);
if (!mac) {
if (IS_ZEBRA_DEBUG_VXLAN)
zlog_debug("MAC %s doesn't exist for neigh %s on VNI %u",
prefix_mac2str(&n->emac,
buf1, sizeof(buf1)),
ipaddr2str(ip, buf2, sizeof(buf2)),
zevpn->vni);
zlog_debug(
"MAC %s doesn't exist for neigh %s on VNI %u",
prefix_mac2str(&n->emac, buf1, sizeof(buf1)),
ipaddr2str(ip, buf2, sizeof(buf2)), zevpn->vni);
return -1;
}

Expand Down Expand Up @@ -595,8 +593,9 @@ void zebra_evpn_svi_macip_del_for_evpn_hash(struct hash_bucket *bucket,
*/
if (zevpn->advertise_svi_macip) {
if (IS_ZEBRA_DEBUG_VXLAN)
zlog_debug("VNI: %u SVI-MACIP enabled, retain svi-macip",
zevpn->vni);
zlog_debug(
"VNI: %u SVI-MACIP enabled, retain svi-macip",
zevpn->vni);
return;
}

Expand Down Expand Up @@ -986,8 +985,8 @@ int zebra_evpn_send_add_to_client(zebra_evpn_t *zevpn)
stream_putw_at(s, 0, stream_get_endp(s));

if (IS_ZEBRA_DEBUG_VXLAN)
zlog_debug("Send EVPN_ADD %u %s tenant vrf %s to %s", zevpn->vni,
inet_ntoa(zevpn->local_vtep_ip),
zlog_debug("Send EVPN_ADD %u %s tenant vrf %s to %s",
zevpn->vni, inet_ntoa(zevpn->local_vtep_ip),
vrf_id_to_name(zevpn->vrf_id),
zebra_route_string(client->proto));

Expand Down Expand Up @@ -1133,11 +1132,11 @@ int zebra_evpn_vtep_del_all(zebra_evpn_t *zevpn, int uninstall)
*/
int zebra_evpn_vtep_install(zebra_evpn_t *zevpn, zebra_vtep_t *zvtep)
{
if (is_vxlan_flooding_head_end() &&
(zvtep->flood_control == VXLAN_FLOOD_HEAD_END_REPL)) {
if (ZEBRA_DPLANE_REQUEST_FAILURE ==
dplane_vtep_add(zevpn->vxlan_if,
&zvtep->vtep_ip, zevpn->vni))
if (is_vxlan_flooding_head_end()
&& (zvtep->flood_control == VXLAN_FLOOD_HEAD_END_REPL)) {
if (ZEBRA_DPLANE_REQUEST_FAILURE
== dplane_vtep_add(zevpn->vxlan_if, &zvtep->vtep_ip,
zevpn->vni))
return -1;
}

Expand All @@ -1155,8 +1154,8 @@ int zebra_evpn_vtep_uninstall(zebra_evpn_t *zevpn, struct in_addr *vtep_ip)
return -1;
}

if (ZEBRA_DPLANE_REQUEST_FAILURE ==
dplane_vtep_delete(zevpn->vxlan_if, vtep_ip, zevpn->vni))
if (ZEBRA_DPLANE_REQUEST_FAILURE
== dplane_vtep_delete(zevpn->vxlan_if, vtep_ip, zevpn->vni))
return -1;

return 0;
Expand Down
47 changes: 22 additions & 25 deletions zebra/zebra_evpn_mac.c
Original file line number Diff line number Diff line change
Expand Up @@ -416,12 +416,13 @@ static void zebra_evpn_dup_addr_detect_for_mac(struct zebra_vrf *zvrf,
mac->dad_count++;

if (mac->dad_count >= zvrf->dad_max_moves) {
flog_warn(EC_ZEBRA_DUP_MAC_DETECTED,
"VNI %u: MAC %s detected as duplicate during %s VTEP %s",
mac->zevpn->vni,
prefix_mac2str(&mac->macaddr, buf, sizeof(buf)),
is_local ? "local update, last" :
"remote update, from", inet_ntoa(vtep_ip));
flog_warn(
EC_ZEBRA_DUP_MAC_DETECTED,
"VNI %u: MAC %s detected as duplicate during %s VTEP %s",
mac->zevpn->vni,
prefix_mac2str(&mac->macaddr, buf, sizeof(buf)),
is_local ? "local update, last" : "remote update, from",
inet_ntoa(vtep_ip));

SET_FLAG(mac->flags, ZEBRA_MAC_DUPLICATE);

Expand All @@ -441,13 +442,13 @@ static void zebra_evpn_dup_addr_detect_for_mac(struct zebra_vrf *zvrf,

nbr->dad_dup_detect_time = monotime(NULL);

flog_warn(EC_ZEBRA_DUP_IP_INHERIT_DETECTED,
"VNI %u: MAC %s IP %s detected as duplicate during %s update, inherit duplicate from MAC",
mac->zevpn->vni,
prefix_mac2str(&mac->macaddr,
buf, sizeof(buf)),
ipaddr2str(&nbr->ip, buf1, sizeof(buf1)),
is_local ? "local" : "remote");
flog_warn(
EC_ZEBRA_DUP_IP_INHERIT_DETECTED,
"VNI %u: MAC %s IP %s detected as duplicate during %s update, inherit duplicate from MAC",
mac->zevpn->vni,
prefix_mac2str(&mac->macaddr, buf, sizeof(buf)),
ipaddr2str(&nbr->ip, buf1, sizeof(buf1)),
is_local ? "local" : "remote");
}

/* Start auto recovery timer for this MAC */
Expand Down Expand Up @@ -558,7 +559,7 @@ void zebra_evpn_print_mac(zebra_mac_t *mac, void *ctxt, json_object *json)
mac->hold_timer));
if (mac->es)
json_object_string_add(json_mac, "esi",
mac->es->esi_str);
mac->es->esi_str);
/* print all the associated neigh */
if (!listcount(mac->neigh_list))
json_object_string_add(json_mac, "neighbors", "none");
Expand Down Expand Up @@ -685,17 +686,13 @@ void zebra_evpn_print_mac(zebra_mac_t *mac, void *ctxt, json_object *json)
}

static char *zebra_evpn_print_mac_flags(zebra_mac_t *mac, char *flags_buf,
uint32_t flags_buf_sz)
uint32_t flags_buf_sz)
{
snprintf(flags_buf, flags_buf_sz, "%s%s%s%s",
mac->sync_neigh_cnt ?
"N" : "",
(mac->flags & ZEBRA_MAC_ES_PEER_ACTIVE) ?
"P" : "",
(mac->flags & ZEBRA_MAC_ES_PEER_PROXY) ?
"X" : "",
(mac->flags & ZEBRA_MAC_LOCAL_INACTIVE) ?
"I" : "");
mac->sync_neigh_cnt ? "N" : "",
(mac->flags & ZEBRA_MAC_ES_PEER_ACTIVE) ? "P" : "",
(mac->flags & ZEBRA_MAC_ES_PEER_PROXY) ? "X" : "",
(mac->flags & ZEBRA_MAC_LOCAL_INACTIVE) ? "I" : "");

return flags_buf;
}
Expand Down Expand Up @@ -732,7 +729,7 @@ void zebra_evpn_print_mac_hash(struct hash_bucket *bucket, void *ctxt)
if (json_mac_hdr == NULL) {
vty_out(vty, "%-17s %-6s %-5s %-30s", buf1, "local",
zebra_evpn_print_mac_flags(mac, flags_buf,
sizeof(flags_buf)),
sizeof(flags_buf)),
ifp ? ifp->name : "-");
} else {
json_object_string_add(json_mac, "type", "local");
Expand Down Expand Up @@ -788,7 +785,7 @@ void zebra_evpn_print_mac_hash(struct hash_bucket *bucket, void *ctxt)
vty_out(vty, "%-17s %-6s %-5s %-30s %-5s %u/%u\n", buf1,
"remote",
zebra_evpn_print_mac_flags(mac, flags_buf,
sizeof(flags_buf)),
sizeof(flags_buf)),
mac->es ? mac->es->esi_str
: inet_ntoa(mac->fwd_info.r_vtep_ip),
"", mac->loc_seq, mac->rem_seq);
Expand Down
Loading

0 comments on commit c20a811

Please sign in to comment.