lib, zebra: fix formatting and style

Signed-off-by: Fredi Raspall <fredi@voltanet.io>
This commit is contained in:
Fredi Raspall 2018-05-08 10:13:20 +02:00
parent aec865e416
commit 0313523d77
4 changed files with 64 additions and 64 deletions

View file

@ -1231,9 +1231,8 @@ stream_failure:
return 0; return 0;
} }
static void zapi_encode_prefix(struct stream *s, static void zapi_encode_prefix(struct stream *s, struct prefix *p,
struct prefix *p, uint8_t family)
uint8_t family)
{ {
struct prefix any; struct prefix any;
@ -1248,8 +1247,7 @@ static void zapi_encode_prefix(struct stream *s,
stream_put(s, &p->u.prefix, prefix_blen(p)); stream_put(s, &p->u.prefix, prefix_blen(p));
} }
int zapi_pbr_rule_encode(uint8_t cmd, struct stream *s, int zapi_pbr_rule_encode(uint8_t cmd, struct stream *s, struct pbr_rule *zrule)
struct pbr_rule *zrule)
{ {
stream_reset(s); stream_reset(s);
zclient_create_header(s, cmd, zrule->vrf_id); zclient_create_header(s, cmd, zrule->vrf_id);
@ -1265,11 +1263,11 @@ int zapi_pbr_rule_encode(uint8_t cmd, struct stream *s,
zapi_encode_prefix(s, &(zrule->filter.src_ip), zapi_encode_prefix(s, &(zrule->filter.src_ip),
zrule->filter.src_ip.family); zrule->filter.src_ip.family);
stream_putw(s, zrule->filter.src_port); /* src port */ stream_putw(s, zrule->filter.src_port); /* src port */
zapi_encode_prefix(s, &(zrule->filter.dst_ip), zapi_encode_prefix(s, &(zrule->filter.dst_ip),
zrule->filter.src_ip.family); zrule->filter.src_ip.family);
stream_putw(s, zrule->filter.dst_port); /* dst port */ stream_putw(s, zrule->filter.dst_port); /* dst port */
stream_putw(s, zrule->filter.fwmark); /* fwmark */ stream_putw(s, zrule->filter.fwmark); /* fwmark */
stream_putl(s, zrule->action.table); stream_putl(s, zrule->action.table);
stream_putl(s, zrule->ifindex); stream_putl(s, zrule->ifindex);
@ -1317,8 +1315,8 @@ bool zapi_rule_notify_decode(struct stream *s, uint32_t *seqno,
STREAM_GETL(s, ifi); STREAM_GETL(s, ifi);
if (zclient_debug) if (zclient_debug)
zlog_debug("%s: %u %u %u %u", __PRETTY_FUNCTION__, zlog_debug("%s: %u %u %u %u", __PRETTY_FUNCTION__, seq, prio,
seq, prio, uni, ifi); uni, ifi);
*seqno = seq; *seqno = seq;
*priority = prio; *priority = prio;
*unique = uni; *unique = uni;
@ -1330,9 +1328,8 @@ stream_failure:
return false; return false;
} }
bool zapi_ipset_notify_decode(struct stream *s, bool zapi_ipset_notify_decode(struct stream *s, uint32_t *unique,
uint32_t *unique, enum zapi_ipset_notify_owner *note)
enum zapi_ipset_notify_owner *note)
{ {
uint32_t uni; uint32_t uni;
@ -1350,10 +1347,9 @@ stream_failure:
return false; return false;
} }
bool zapi_ipset_entry_notify_decode(struct stream *s, bool zapi_ipset_entry_notify_decode(struct stream *s, uint32_t *unique,
uint32_t *unique, char *ipset_name,
char *ipset_name, enum zapi_ipset_entry_notify_owner *note)
enum zapi_ipset_entry_notify_owner *note)
{ {
uint32_t uni; uint32_t uni;
@ -1361,8 +1357,7 @@ bool zapi_ipset_entry_notify_decode(struct stream *s,
STREAM_GETL(s, uni); STREAM_GETL(s, uni);
STREAM_GET(ipset_name, s, STREAM_GET(ipset_name, s, ZEBRA_IPSET_NAME_SIZE);
ZEBRA_IPSET_NAME_SIZE);
if (zclient_debug) if (zclient_debug)
zlog_debug("%s: %u", __PRETTY_FUNCTION__, uni); zlog_debug("%s: %u", __PRETTY_FUNCTION__, uni);
@ -1388,7 +1383,7 @@ struct nexthop *nexthop_from_zapi_nexthop(struct zapi_nexthop *znh)
*/ */
if (znh->label_num) { if (znh->label_num) {
nexthop_add_labels(n, ZEBRA_LSP_NONE, znh->label_num, nexthop_add_labels(n, ZEBRA_LSP_NONE, znh->label_num,
znh->labels); znh->labels);
} }
return n; return n;
@ -1449,7 +1444,7 @@ bool zapi_nexthop_update_decode(struct stream *s, struct zapi_route *nhr)
if (nhr->nexthops[i].label_num) if (nhr->nexthops[i].label_num)
STREAM_GET(&nhr->nexthops[i].labels[0], s, STREAM_GET(&nhr->nexthops[i].labels[0], s,
nhr->nexthops[i].label_num nhr->nexthops[i].label_num
* sizeof(mpls_label_t)); * sizeof(mpls_label_t));
} }
return true; return true;
@ -1872,8 +1867,9 @@ struct connected *zebra_interface_address_read(int type, struct stream *s,
zlog_warn( zlog_warn(
"warning: interface %s address %s " "warning: interface %s address %s "
"with peer flag set, but no peer address!", "with peer flag set, but no peer address!",
ifp->name, prefix2str(ifc->address, buf, ifp->name,
sizeof buf)); prefix2str(ifc->address, buf,
sizeof buf));
UNSET_FLAG(ifc->flags, ZEBRA_IFA_PEER); UNSET_FLAG(ifc->flags, ZEBRA_IFA_PEER);
} }
} }
@ -2086,17 +2082,18 @@ int lm_label_manager_connect(struct zclient *zclient)
/* sanity */ /* sanity */
if (proto != zclient->redist_default) if (proto != zclient->redist_default)
zlog_err("Wrong proto (%u) in LM connect response. Should be %u", zlog_err(
proto, zclient->redist_default); "Wrong proto (%u) in LM connect response. Should be %u",
proto, zclient->redist_default);
if (instance != zclient->instance) if (instance != zclient->instance)
zlog_err("Wrong instId (%u) in LM connect response. Should be %u", zlog_err(
instance, zclient->instance); "Wrong instId (%u) in LM connect response. Should be %u",
instance, zclient->instance);
/* result code */ /* result code */
result = stream_getc(s); result = stream_getc(s);
if (zclient_debug) if (zclient_debug)
zlog_debug( zlog_debug("LM connect-response received, result %u", result);
"LM connect-response received, result %u", result);
return (int)result; return (int)result;
} }
@ -2109,10 +2106,8 @@ int lm_label_manager_connect(struct zclient *zclient)
* @param chunk_size Amount of labels requested * @param chunk_size Amount of labels requested
* @result 0 on success, -1 otherwise * @result 0 on success, -1 otherwise
*/ */
int zclient_send_get_label_chunk( int zclient_send_get_label_chunk(struct zclient *zclient, uint8_t keep,
struct zclient *zclient, uint32_t chunk_size)
uint8_t keep,
uint32_t chunk_size)
{ {
struct stream *s; struct stream *s;
@ -2210,10 +2205,10 @@ int lm_get_label_chunk(struct zclient *zclient, uint8_t keep,
/* sanities */ /* sanities */
if (proto != zclient->redist_default) if (proto != zclient->redist_default)
zlog_err("Wrong proto (%u) in get chunk response. Should be %u", zlog_err("Wrong proto (%u) in get chunk response. Should be %u",
proto, zclient->redist_default); proto, zclient->redist_default);
if (instance != zclient->instance) if (instance != zclient->instance)
zlog_err("Wrong instId (%u) in get chunk response Should be %u", zlog_err("Wrong instId (%u) in get chunk response Should be %u",
instance, zclient->instance); instance, zclient->instance);
/* keep */ /* keep */
response_keep = stream_getc(s); response_keep = stream_getc(s);
@ -2334,8 +2329,7 @@ int tm_table_manager_connect(struct zclient *zclient)
return -1; return -1;
if (zclient_debug) if (zclient_debug)
zlog_debug("%s: Table manager connect request sent", zlog_debug("%s: Table manager connect request sent", __func__);
__func__);
/* read response */ /* read response */
if (zclient_read_sync_response(zclient, ZEBRA_TABLE_MANAGER_CONNECT) if (zclient_read_sync_response(zclient, ZEBRA_TABLE_MANAGER_CONNECT)
@ -2798,7 +2792,7 @@ static int zclient_read(struct thread *thread)
case ZEBRA_GET_LABEL_CHUNK: case ZEBRA_GET_LABEL_CHUNK:
if (zclient->label_chunk) if (zclient->label_chunk)
(*zclient->label_chunk)(command, zclient, length, (*zclient->label_chunk)(command, zclient, length,
vrf_id); vrf_id);
break; break;
default: default:
break; break;

View file

@ -82,8 +82,8 @@ static int relay_response_back(void)
ret = zclient_read_header(src, zclient->sock, &size, &marker, &version, ret = zclient_read_header(src, zclient->sock, &size, &marker, &version,
&vrf_id, &resp_cmd); &vrf_id, &resp_cmd);
if (ret < 0 && errno != EAGAIN) { if (ret < 0 && errno != EAGAIN) {
zlog_err("%s: Error reading Label Manager response: %s", zlog_err("Error reading Label Manager response: %s",
__func__, strerror(errno)); strerror(errno));
return -1; return -1;
} }
zlog_debug("Label Manager response received, %d bytes", size); zlog_debug("Label Manager response received, %d bytes", size);
@ -101,12 +101,13 @@ static int relay_response_back(void)
/* lookup the client to relay the msg to */ /* lookup the client to relay the msg to */
zserv = zebra_find_client(proto, instance); zserv = zebra_find_client(proto, instance);
if (!zserv) { if (!zserv) {
zlog_err("Error relaying LM response: can't find client %s, instance %u", zlog_err(
proto_str, instance); "Error relaying LM response: can't find client %s, instance %u",
proto_str, instance);
return -1; return -1;
} }
zlog_debug("Found client to relay LM response to client %s instance %u", zlog_debug("Found client to relay LM response to client %s instance %u",
proto_str, instance); proto_str, instance);
/* copy msg into output buffer */ /* copy msg into output buffer */
dst = obuf; dst = obuf;
@ -116,11 +117,11 @@ static int relay_response_back(void)
ret = writen(zserv->sock, dst->data, stream_get_endp(dst)); ret = writen(zserv->sock, dst->data, stream_get_endp(dst));
if (ret <= 0) { if (ret <= 0) {
zlog_err("Error relaying LM response to %s instance %u: %s", zlog_err("Error relaying LM response to %s instance %u: %s",
proto_str, instance, strerror(errno)); proto_str, instance, strerror(errno));
return -1; return -1;
} }
zlog_debug("Relayed LM response (%d bytes) to %s instance %u", zlog_debug("Relayed LM response (%d bytes) to %s instance %u", ret,
ret, proto_str, instance); proto_str, instance);
return 0; return 0;
} }
@ -173,7 +174,7 @@ static int reply_error(int cmd, struct zserv *zserv, vrf_id_t vrf_id)
* @return 0 on success, -1 otherwise * @return 0 on success, -1 otherwise
*/ */
int zread_relay_label_manager_request(int cmd, struct zserv *zserv, int zread_relay_label_manager_request(int cmd, struct zserv *zserv,
struct stream *msg, vrf_id_t vrf_id) struct stream *msg, vrf_id_t vrf_id)
{ {
struct stream *dst; struct stream *dst;
int ret = 0; int ret = 0;
@ -203,15 +204,15 @@ int zread_relay_label_manager_request(int cmd, struct zserv *zserv,
/* check & set client proto if unset */ /* check & set client proto if unset */
if (zserv->proto && zserv->proto != proto) { if (zserv->proto && zserv->proto != proto) {
zlog_warn("Client proto(%u) != msg proto(%u)", zlog_warn("Client proto(%u) != msg proto(%u)", zserv->proto,
zserv->proto, proto); proto);
return -1; return -1;
} }
/* check & set client instance if unset */ /* check & set client instance if unset */
if (zserv->instance && zserv->instance != instance) { if (zserv->instance && zserv->instance != instance) {
zlog_err("Client instance(%u) != msg instance(%u)", zlog_err("Client instance(%u) != msg instance(%u)",
zserv->instance, instance); zserv->instance, instance);
return -1; return -1;
} }
@ -233,12 +234,12 @@ int zread_relay_label_manager_request(int cmd, struct zserv *zserv,
ret = writen(zclient->sock, dst->data, stream_get_endp(dst)); ret = writen(zclient->sock, dst->data, stream_get_endp(dst));
if (ret <= 0) { if (ret <= 0) {
zlog_err("Error relaying LM request from %s instance %u: %s", zlog_err("Error relaying LM request from %s instance %u: %s",
proto_str, instance, strerror(errno)); proto_str, instance, strerror(errno));
reply_error(cmd, zserv, vrf_id); reply_error(cmd, zserv, vrf_id);
return -1; return -1;
} }
zlog_debug("Relayed LM request (%d bytes) from %s instance %u", zlog_debug("Relayed LM request (%d bytes) from %s instance %u", ret,
ret, proto_str, instance); proto_str, instance);
/* Release label chunk has no response */ /* Release label chunk has no response */

View file

@ -64,7 +64,7 @@ struct label_manager {
bool lm_is_external; bool lm_is_external;
int zread_relay_label_manager_request(int cmd, struct zserv *zserv, int zread_relay_label_manager_request(int cmd, struct zserv *zserv,
struct stream *msg, vrf_id_t vrf_id); struct stream *msg, vrf_id_t vrf_id);
void label_manager_init(char *lm_zserv_path); void label_manager_init(char *lm_zserv_path);
struct label_manager_chunk *assign_label_chunk(uint8_t proto, struct label_manager_chunk *assign_label_chunk(uint8_t proto,
unsigned short instance, unsigned short instance,

View file

@ -2413,14 +2413,15 @@ static int msg_client_id_mismatch(const char *op, struct zserv *client,
{ {
if (proto != client->proto) { if (proto != client->proto) {
zlog_err("%s: msg vs client proto mismatch, client=%u msg=%u", zlog_err("%s: msg vs client proto mismatch, client=%u msg=%u",
op, client->proto, proto); op, client->proto, proto);
/* TODO: fail when BGP sets proto and instance */ /* TODO: fail when BGP sets proto and instance */
/* return 1; */ /* return 1; */
} }
if (instance != client->instance) { if (instance != client->instance) {
zlog_err("%s: msg vs client instance mismatch, client=%u msg=%u", zlog_err(
op, client->instance, instance); "%s: msg vs client instance mismatch, client=%u msg=%u",
op, client->instance, instance);
/* TODO: fail when BGP sets proto and instance */ /* TODO: fail when BGP sets proto and instance */
/* return 1; */ /* return 1; */
} }
@ -2453,11 +2454,14 @@ static void zread_get_label_chunk(struct zserv *client, struct stream *msg,
lmc = assign_label_chunk(client->proto, client->instance, keep, size); lmc = assign_label_chunk(client->proto, client->instance, keep, size);
if (!lmc) if (!lmc)
zlog_err("Unable to assign Label Chunk of size %u to %s instance %u", zlog_err(
size, zebra_route_string(client->proto), client->instance); "Unable to assign Label Chunk of size %u to %s instance %u",
size, zebra_route_string(client->proto),
client->instance);
else else
zlog_debug("Assigned Label Chunk %u - %u to %s instance %u", lmc->start, zlog_debug("Assigned Label Chunk %u - %u to %s instance %u",
lmc->end, zebra_route_string(client->proto), client->instance); lmc->start, lmc->end,
zebra_route_string(client->proto), client->instance);
/* send response back */ /* send response back */
zsend_assign_label_chunk_response(client, vrf_id, lmc); zsend_assign_label_chunk_response(client, vrf_id, lmc);
@ -2482,7 +2486,8 @@ static void zread_release_label_chunk(struct zserv *client, struct stream *msg)
STREAM_GETL(s, end); STREAM_GETL(s, end);
/* detect client vs message (proto,instance) mismatch */ /* detect client vs message (proto,instance) mismatch */
if (msg_client_id_mismatch("Release-label-chunk", client, proto, instance)) if (msg_client_id_mismatch("Release-label-chunk", client, proto,
instance))
return; return;
release_label_chunk(client->proto, client->instance, start, end); release_label_chunk(client->proto, client->instance, start, end);
@ -2498,8 +2503,8 @@ static void zread_label_manager_request(ZAPI_HANDLER_ARGS)
/* external label manager */ /* external label manager */
if (lm_is_external) if (lm_is_external)
zread_relay_label_manager_request(hdr->command, client, zread_relay_label_manager_request(hdr->command, client, msg,
msg, zvrf_id(zvrf)); zvrf_id(zvrf));
/* this is a label manager */ /* this is a label manager */
else { else {
if (hdr->command == ZEBRA_LABEL_MANAGER_CONNECT) if (hdr->command == ZEBRA_LABEL_MANAGER_CONNECT)