Skip to content

Commit

Permalink
*: fix code style
Browse files Browse the repository at this point in the history
#7680 (review)

Signed-off-by: Hiroki Shirokura <slank.dev@gmail.com>
  • Loading branch information
slankdev committed Dec 6, 2020
1 parent ec5aa48 commit bba7a35
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 31 deletions.
5 changes: 2 additions & 3 deletions lib/nexthop.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ static int _nexthop_labels_cmp(const struct nexthop *nh1,
}

static int _nexthop_seg6local_cmp(const struct nexthop *nh1,
const struct nexthop *nh2)
const struct nexthop *nh2)
{
if (nh1->nh_seg6local_action > nh2->nh_seg6local_action)
return 1;
Expand All @@ -84,8 +84,7 @@ static int _nexthop_seg6local_cmp(const struct nexthop *nh1,
if (!nh1->nh_seg6local_ctx && nh2->nh_seg6local_ctx)
return -1;

return memcmp(nh1->nh_seg6local_ctx,
nh2->nh_seg6local_ctx,
return memcmp(nh1->nh_seg6local_ctx, nh2->nh_seg6local_ctx,
sizeof(struct seg6local_context));
}

Expand Down
6 changes: 2 additions & 4 deletions lib/zclient.c
Original file line number Diff line number Diff line change
Expand Up @@ -804,8 +804,7 @@ static int zapi_nexthop_seg6local_cmp(const struct zapi_nexthop *next1,
if (next1->seg6local_action < next2->seg6local_action)
return -1;

return memcmp(&next1->seg6local_ctx,
&next2->seg6local_ctx,
return memcmp(&next1->seg6local_ctx, &next2->seg6local_ctx,
sizeof(struct seg6local_context));
}

Expand Down Expand Up @@ -1690,8 +1689,7 @@ int zapi_nexthop_from_nexthop(struct zapi_nexthop *znh,
memcpy(znh->backup_idx, nh->backup_idx, znh->backup_num);
}

if (nh->nh_seg6local_action != 0 &&
nh->nh_seg6local_ctx != NULL) {
if (nh->nh_seg6local_action != 0 && nh->nh_seg6local_ctx != NULL) {
znh->seg6local_action = nh->nh_seg6local_action;
memcpy(&znh->seg6local_ctx, nh->nh_seg6local_ctx,
sizeof(struct seg6local_context));
Expand Down
36 changes: 18 additions & 18 deletions zebra/rt_netlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -1290,31 +1290,31 @@ static bool _netlink_route_build_singlepath(const struct prefix *p,
action = nexthop->nh_seg6local_action;
encap = LWTUNNEL_ENCAP_SEG6_LOCAL;
nl_attr_put(nlmsg, req_size, RTA_ENCAP_TYPE, &encap,
sizeof(uint16_t));
sizeof(uint16_t));

nest = nl_attr_nest(nlmsg, req_size, RTA_ENCAP);
switch (nexthop->nh_seg6local_action) {
case ZEBRA_SEG6_LOCAL_ACTION_END:
nl_attr_put32(nlmsg, req_size, SEG6_LOCAL_ACTION,
SEG6_LOCAL_ACTION_END);
SEG6_LOCAL_ACTION_END);
break;
case ZEBRA_SEG6_LOCAL_ACTION_END_X:
nl_attr_put32(nlmsg, req_size, SEG6_LOCAL_ACTION,
SEG6_LOCAL_ACTION_END_X);
SEG6_LOCAL_ACTION_END_X);
nl_attr_put(nlmsg, req_size, SEG6_LOCAL_NH6, &ctx->nh6,
sizeof(struct in6_addr));
sizeof(struct in6_addr));
break;
case ZEBRA_SEG6_LOCAL_ACTION_END_T:
nl_attr_put32(nlmsg, req_size, SEG6_LOCAL_ACTION,
SEG6_LOCAL_ACTION_END_T);
SEG6_LOCAL_ACTION_END_T);
nl_attr_put32(nlmsg, req_size, SEG6_LOCAL_TABLE,
ctx->table);
break;
case ZEBRA_SEG6_LOCAL_ACTION_END_DX4:
nl_attr_put32(nlmsg, req_size, SEG6_LOCAL_ACTION,
SEG6_LOCAL_ACTION_END_DX4);
SEG6_LOCAL_ACTION_END_DX4);
nl_attr_put(nlmsg, req_size, SEG6_LOCAL_NH4, &ctx->nh4,
sizeof(struct in_addr));
sizeof(struct in_addr));
break;
default:
zlog_err("%s: unsupport seg6local behaviour action=%u",
Expand Down Expand Up @@ -2314,23 +2314,23 @@ ssize_t netlink_nexthop_msg_encode(uint16_t cmd,
ctx = nh->nh_seg6local_ctx;
encap = LWTUNNEL_ENCAP_SEG6_LOCAL;
nl_attr_put(&req->n, buflen, NHA_ENCAP_TYPE,
&encap, sizeof(uint16_t));
&encap, sizeof(uint16_t));

nest = nl_attr_nest(&req->n, buflen,
NHA_ENCAP | NLA_F_NESTED);
switch (action) {
case SEG6_LOCAL_ACTION_END:
nl_attr_put32(&req->n, buflen,
SEG6_LOCAL_ACTION,
SEG6_LOCAL_ACTION_END);
SEG6_LOCAL_ACTION,
SEG6_LOCAL_ACTION_END);
break;
case SEG6_LOCAL_ACTION_END_X:
nl_attr_put32(&req->n, buflen,
SEG6_LOCAL_ACTION,
SEG6_LOCAL_ACTION_END_X);
SEG6_LOCAL_ACTION,
SEG6_LOCAL_ACTION_END_X);
nl_attr_put(&req->n, buflen,
SEG6_LOCAL_NH6, &ctx->nh6,
sizeof(struct in6_addr));
SEG6_LOCAL_NH6, &ctx->nh6,
sizeof(struct in6_addr));
break;
case SEG6_LOCAL_ACTION_END_T:
nl_attr_put32(&req->n, buflen,
Expand All @@ -2342,11 +2342,11 @@ ssize_t netlink_nexthop_msg_encode(uint16_t cmd,
break;
case SEG6_LOCAL_ACTION_END_DX4:
nl_attr_put32(&req->n, buflen,
SEG6_LOCAL_ACTION,
SEG6_LOCAL_ACTION_END_DX4);
SEG6_LOCAL_ACTION,
SEG6_LOCAL_ACTION_END_DX4);
nl_attr_put(&req->n, buflen,
SEG6_LOCAL_NH4, &ctx->nh4,
sizeof(struct in_addr));
SEG6_LOCAL_NH4, &ctx->nh4,
sizeof(struct in_addr));
break;
default:
zlog_err("%s: unsupport seg6local behaviour action=%u",
Expand Down
9 changes: 3 additions & 6 deletions zebra/zebra_vty.c
Original file line number Diff line number Diff line change
Expand Up @@ -605,8 +605,7 @@ static void show_route_nexthop_helper(struct vty *vty,
nexthop->nh_seg6local_ctx,
nexthop->nh_seg6local_action);
vty_out(vty, ", seg6local %s %s",
seg6local_action2str(
nexthop->nh_seg6local_action),
seg6local_action2str(nexthop->nh_seg6local_action),
buf);
}

Expand Down Expand Up @@ -815,10 +814,8 @@ static void show_nexthop_json_helper(json_object *json_nexthop,
json_seg6local = json_object_new_object();
json_object_string_add(
json_seg6local, "action",
seg6local_action2str(
nexthop->nh_seg6local_action));
json_object_object_add(json_nexthop,
"seg6local",
seg6local_action2str(nexthop->nh_seg6local_action));
json_object_object_add(json_nexthop, "seg6local",
json_seg6local);
}
}
Expand Down

0 comments on commit bba7a35

Please sign in to comment.