summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--zebra/zapi_msg.c74
-rw-r--r--zebra/zapi_msg.h46
-rw-r--r--zebra/zebra_ptm.c2
-rw-r--r--zebra/zebra_rnh.c3
-rw-r--r--zebra/zserv.c4
-rw-r--r--zebra/zserv.h4
6 files changed, 78 insertions, 55 deletions
diff --git a/zebra/zapi_msg.c b/zebra/zapi_msg.c
index f613ee6de3..2ff660b3f9 100644
--- a/zebra/zapi_msg.c
+++ b/zebra/zapi_msg.c
@@ -451,7 +451,8 @@ void nbr_connected_add_ipv6(struct interface *ifp, struct in6_addr *address)
IPV6_ADDR_COPY(&p.u.prefix, address);
p.prefixlen = IPV6_MAX_PREFIXLEN;
- if (!(ifc = listnode_head(ifp->nbr_connected))) {
+ ifc = listnode_head(ifp->nbr_connected);
+ if (!ifc) {
/* new addition */
ifc = nbr_connected_new();
ifc->address = prefix_new();
@@ -592,6 +593,7 @@ int zsend_redistribute_route(int cmd, struct zserv *client, struct prefix *p,
if (IS_ZEBRA_DEBUG_SEND) {
char buf_prefix[PREFIX_STRLEN];
+
prefix2str(&api.prefix, buf_prefix, sizeof(buf_prefix));
zlog_debug("%s: %s to client %s: type %s, vrf_id %d, p %s",
@@ -630,18 +632,21 @@ static int zsend_ipv4_nexthop_lookup_mrib(struct zserv *client,
stream_putc(s, re->distance);
stream_putl(s, re->metric);
num = 0;
- nump = stream_get_endp(
- s); /* remember position for nexthop_num */
- stream_putc(s, 0); /* reserve room for nexthop_num */
- /* Only non-recursive routes are elegible to resolve the nexthop
- * we
- * are looking up. Therefore, we will just iterate over the top
- * chain of nexthops. */
+ /* remember position for nexthop_num */
+ nump = stream_get_endp(s);
+ /* reserve room for nexthop_num */
+ stream_putc(s, 0);
+ /*
+ * Only non-recursive routes are elegible to resolve the
+ * nexthop we are looking up. Therefore, we will just iterate
+ * over the top chain of nexthops.
+ */
for (nexthop = re->ng.nexthop; nexthop; nexthop = nexthop->next)
if (CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_ACTIVE))
num += zserv_encode_nexthop(s, nexthop);
- stream_putc_at(s, nump, num); /* store nexthop_num */
+ /* store nexthop_num */
+ stream_putc_at(s, nump, num);
} else {
stream_putc(s, 0); /* distance */
stream_putl(s, 0); /* metric */
@@ -1117,7 +1122,7 @@ static void zread_fec_register(ZAPI_HANDLER_ARGS)
s = msg;
zvrf = vrf_info_lookup(VRF_DEFAULT);
if (!zvrf)
- return; // unexpected
+ return;
/*
* The minimum amount of data that can be sent for one fec
@@ -1175,7 +1180,7 @@ static void zread_fec_unregister(ZAPI_HANDLER_ARGS)
s = msg;
zvrf = vrf_info_lookup(VRF_DEFAULT);
if (!zvrf)
- return; // unexpected
+ return;
/*
* The minimum amount of data that can be sent for one
@@ -1256,6 +1261,7 @@ void zserv_nexthop_num_warn(const char *caller, const struct prefix *p,
{
if (nexthop_num > multipath_num) {
char buff[PREFIX2STR_BUFFER];
+
prefix2str(p, buff, sizeof(buff));
zlog_warn(
"%s: Prefix %s has %d nexthops, but we can only use the first %d",
@@ -1286,6 +1292,7 @@ static void zread_route_add(ZAPI_HANDLER_ARGS)
if (IS_ZEBRA_DEBUG_RECV) {
char buf_prefix[PREFIX_STRLEN];
+
prefix2str(&api.prefix, buf_prefix, sizeof(buf_prefix));
zlog_debug("%s: p=%s, ZAPI_MESSAGE_LABEL: %sset, flags=0x%x",
__func__, buf_prefix,
@@ -1312,14 +1319,13 @@ static void zread_route_add(ZAPI_HANDLER_ARGS)
* api_nh->vrf_id instead of re->vrf_id ? I only changed
* for cases NEXTHOP_TYPE_IPV4 and NEXTHOP_TYPE_IPV6.
*/
- if (CHECK_FLAG(api.message, ZAPI_MESSAGE_NEXTHOP)) {
+ if (CHECK_FLAG(api.message, ZAPI_MESSAGE_NEXTHOP))
for (i = 0; i < api.nexthop_num; i++) {
api_nh = &api.nexthops[i];
ifindex_t ifindex = 0;
- if (IS_ZEBRA_DEBUG_RECV) {
+ if (IS_ZEBRA_DEBUG_RECV)
zlog_debug("nh type %d", api_nh->type);
- }
switch (api_nh->type) {
case NEXTHOP_TYPE_IFINDEX:
@@ -1329,6 +1335,7 @@ static void zread_route_add(ZAPI_HANDLER_ARGS)
case NEXTHOP_TYPE_IPV4:
if (IS_ZEBRA_DEBUG_RECV) {
char nhbuf[INET6_ADDRSTRLEN] = {0};
+
inet_ntop(AF_INET, &api_nh->gate.ipv4,
nhbuf, INET6_ADDRSTRLEN);
zlog_debug("%s: nh=%s, vrf_id=%d",
@@ -1351,6 +1358,7 @@ static void zread_route_add(ZAPI_HANDLER_ARGS)
if (IS_ZEBRA_DEBUG_RECV) {
char nhbuf[INET6_ADDRSTRLEN] = {0};
+
inet_ntop(AF_INET, &api_nh->gate.ipv4,
nhbuf, INET6_ADDRSTRLEN);
zlog_debug(
@@ -1446,7 +1454,6 @@ static void zread_route_add(ZAPI_HANDLER_ARGS)
&api_nh->labels[0]);
}
}
- }
if (CHECK_FLAG(api.message, ZAPI_MESSAGE_DISTANCE))
re->distance = api.distance;
@@ -1610,8 +1617,10 @@ static void zread_ipv4_add(ZAPI_HANDLER_ARGS)
IPV4_MAX_BYTELEN);
nexthop = route_entry_nexthop_ipv4_add(
re, &nhop_addr, NULL, re->vrf_id);
- /* For labeled-unicast, each nexthop is followed
- * by label. */
+ /*
+ * For labeled-unicast, each nexthop is followed
+ * by the label.
+ */
if (CHECK_FLAG(message, ZAPI_MESSAGE_LABEL)) {
STREAM_GETL(s, label);
nexthop_add_labels(nexthop, label_type,
@@ -1633,7 +1642,6 @@ static void zread_ipv4_add(ZAPI_HANDLER_ARGS)
nexthops_free(re->ng.nexthop);
XFREE(MTYPE_RE, re);
return;
- break;
case NEXTHOP_TYPE_BLACKHOLE:
route_entry_nexthop_blackhole_add(re, bh_type);
break;
@@ -1796,10 +1804,12 @@ static void zread_ipv4_route_ipv6_nexthop_add(ZAPI_HANDLER_ARGS)
/* VRF ID */
re->vrf_id = zvrf_id(zvrf);
- /* We need to give nh-addr, nh-ifindex with the same next-hop object
+ /*
+ * We need to give nh-addr, nh-ifindex with the same next-hop object
* to the re to ensure that IPv6 multipathing works; need to coalesce
* these. Clients should send the same number of paired set of
- * next-hop-addr/next-hop-ifindices. */
+ * next-hop-addr/next-hop-ifindices.
+ */
if (CHECK_FLAG(message, ZAPI_MESSAGE_NEXTHOP)) {
unsigned int nh_count = 0;
unsigned int if_count = 0;
@@ -1819,8 +1829,10 @@ static void zread_ipv4_route_ipv6_nexthop_add(ZAPI_HANDLER_ARGS)
case NEXTHOP_TYPE_IPV6:
STREAM_GET(&nhop_addr, s, 16);
if (nh_count < MULTIPATH_NUM) {
- /* For labeled-unicast, each nexthop is
- * followed by label. */
+ /*
+ * For labeled-unicast, each nexthop is
+ * followed by the label.
+ */
if (CHECK_FLAG(message,
ZAPI_MESSAGE_LABEL)) {
STREAM_GETL(s, label);
@@ -1831,9 +1843,8 @@ static void zread_ipv4_route_ipv6_nexthop_add(ZAPI_HANDLER_ARGS)
}
break;
case NEXTHOP_TYPE_IFINDEX:
- if (if_count < multipath_num) {
+ if (if_count < multipath_num)
STREAM_GETL(s, ifindices[if_count++]);
- }
break;
case NEXTHOP_TYPE_BLACKHOLE:
route_entry_nexthop_blackhole_add(re, bh_type);
@@ -1985,10 +1996,12 @@ static void zread_ipv6_add(ZAPI_HANDLER_ARGS)
/* VRF ID */
re->vrf_id = zvrf_id(zvrf);
- /* We need to give nh-addr, nh-ifindex with the same next-hop object
+ /*
+ * We need to give nh-addr, nh-ifindex with the same next-hop object
* to the re to ensure that IPv6 multipathing works; need to coalesce
* these. Clients should send the same number of paired set of
- * next-hop-addr/next-hop-ifindices. */
+ * next-hop-addr/next-hop-ifindices.
+ */
if (CHECK_FLAG(message, ZAPI_MESSAGE_NEXTHOP)) {
unsigned int nh_count = 0;
unsigned int if_count = 0;
@@ -2008,8 +2021,10 @@ static void zread_ipv6_add(ZAPI_HANDLER_ARGS)
case NEXTHOP_TYPE_IPV6:
STREAM_GET(&nhop_addr, s, 16);
if (nh_count < MULTIPATH_NUM) {
- /* For labeled-unicast, each nexthop is
- * followed by label. */
+ /*
+ * For labeled-unicast, each nexthop is
+ * followed by label.
+ */
if (CHECK_FLAG(message,
ZAPI_MESSAGE_LABEL)) {
STREAM_GETL(s, label);
@@ -2025,9 +2040,8 @@ static void zread_ipv6_add(ZAPI_HANDLER_ARGS)
re, &nhop_addr, ifindex, re->vrf_id);
break;
case NEXTHOP_TYPE_IFINDEX:
- if (if_count < multipath_num) {
+ if (if_count < multipath_num)
STREAM_GETL(s, ifindices[if_count++]);
- }
break;
case NEXTHOP_TYPE_BLACKHOLE:
route_entry_nexthop_blackhole_add(re, bh_type);
diff --git a/zebra/zapi_msg.h b/zebra/zapi_msg.h
index f50c985266..1658c9852d 100644
--- a/zebra/zapi_msg.h
+++ b/zebra/zapi_msg.h
@@ -47,23 +47,31 @@
extern void zserv_handle_commands(struct zserv *client, struct zmsghdr *hdr,
struct stream *msg, struct zebra_vrf *zvrf);
-extern int zsend_vrf_add(struct zserv *, struct zebra_vrf *);
-extern int zsend_vrf_delete(struct zserv *, struct zebra_vrf *);
-extern int zsend_interface_add(struct zserv *, struct interface *);
-extern int zsend_interface_delete(struct zserv *, struct interface *);
-extern int zsend_interface_addresses(struct zserv *, struct interface *);
-extern int zsend_interface_address(int, struct zserv *, struct interface *,
- struct connected *);
-extern void nbr_connected_add_ipv6(struct interface *, struct in6_addr *);
-extern void nbr_connected_delete_ipv6(struct interface *, struct in6_addr *);
-extern int zsend_interface_update(int, struct zserv *, struct interface *);
-extern int zsend_redistribute_route(int, struct zserv *, struct prefix *,
- struct prefix *, struct route_entry *);
-extern int zsend_router_id_update(struct zserv *, struct prefix *, vrf_id_t);
-extern int zsend_interface_vrf_update(struct zserv *, struct interface *,
- vrf_id_t);
-extern int zsend_interface_link_params(struct zserv *, struct interface *);
-extern int zsend_pw_update(struct zserv *, struct zebra_pw *);
+extern int zsend_vrf_add(struct zserv *zclient, struct zebra_vrf *zvrf);
+extern int zsend_vrf_delete(struct zserv *zclient, struct zebra_vrf *zvrf);
+extern int zsend_interface_add(struct zserv *zclient, struct interface *ifp);
+extern int zsend_interface_delete(struct zserv *zclient, struct interface *ifp);
+extern int zsend_interface_addresses(struct zserv *zclient,
+ struct interface *ifp);
+extern int zsend_interface_address(int cmd, struct zserv *zclient,
+ struct interface *ifp,
+ struct connected *ifc);
+extern void nbr_connected_add_ipv6(struct interface *ifp,
+ struct in6_addr *address);
+extern void nbr_connected_delete_ipv6(struct interface *ifp,
+ struct in6_addr *address);
+extern int zsend_interface_update(int cmd, struct zserv *client,
+ struct interface *ifp);
+extern int zsend_redistribute_route(int cmd, struct zserv *zclient,
+ struct prefix *p, struct prefix *src_p,
+ struct route_entry *re);
+extern int zsend_router_id_update(struct zserv *zclient, struct prefix *p,
+ vrf_id_t vrf_id);
+extern int zsend_interface_vrf_update(struct zserv *zclient,
+ struct interface *ifp, vrf_id_t vrf_id);
+extern int zsend_interface_link_params(struct zserv *zclient,
+ struct interface *ifp);
+extern int zsend_pw_update(struct zserv *client, struct zebra_pw *pw);
extern int zsend_route_notify_owner(struct route_entry *re, struct prefix *p,
enum zapi_route_notify_owner note);
@@ -76,5 +84,5 @@ zsend_ipset_entry_notify_owner(struct zebra_pbr_ipset_entry *ipset,
enum zapi_ipset_entry_notify_owner note);
extern void zsend_iptable_notify_owner(struct zebra_pbr_iptable *iptable,
enum zapi_iptable_notify_owner note);
-extern void zserv_nexthop_num_warn(const char *, const struct prefix *,
- const unsigned int);
+extern void zserv_nexthop_num_warn(const char *caller, const struct prefix *p,
+ const unsigned int nexthop_num);
diff --git a/zebra/zebra_ptm.c b/zebra/zebra_ptm.c
index f8b5a97ffb..07e81aa020 100644
--- a/zebra/zebra_ptm.c
+++ b/zebra/zebra_ptm.c
@@ -91,7 +91,7 @@ static int zebra_ptm_handle_msg_cb(void *arg, void *in_ctxt);
void zebra_bfd_peer_replay_req(void);
void zebra_ptm_send_status_req(void);
void zebra_ptm_reset_status(int ptm_disable);
-int zebra_ptm_bfd_client_deregister(struct zserv *client);
+static int zebra_ptm_bfd_client_deregister(struct zserv *client);
const char ZEBRA_PTM_SOCK_NAME[] = "\0/var/run/ptmd.socket";
diff --git a/zebra/zebra_rnh.c b/zebra/zebra_rnh.c
index c05c89858e..90c39bcc6f 100644
--- a/zebra/zebra_rnh.c
+++ b/zebra/zebra_rnh.c
@@ -1216,7 +1216,8 @@ static int zebra_client_cleanup_rnh(struct zserv *client)
struct zebra_vrf *zvrf;
RB_FOREACH (vrf, vrf_id_head, &vrfs_by_id) {
- if ((zvrf = vrf->info) != NULL) {
+ zvrf = vrf->info;
+ if (zvrf) {
zebra_cleanup_rnh_client(zvrf_id(zvrf), AF_INET, client,
RNH_NEXTHOP_TYPE);
zebra_cleanup_rnh_client(zvrf_id(zvrf), AF_INET6,
diff --git a/zebra/zserv.c b/zebra/zserv.c
index d374621410..7dcd654240 100644
--- a/zebra/zserv.c
+++ b/zebra/zserv.c
@@ -80,8 +80,8 @@ int zebra_server_send_message(struct zserv *client, struct stream *msg)
/* Lifecycle ---------------------------------------------------------------- */
/* Hooks for client connect / disconnect */
-DEFINE_HOOK(zapi_client_connect, (struct zserv * client), (client));
-DEFINE_KOOH(zapi_client_close, (struct zserv * client), (client));
+DEFINE_HOOK(zapi_client_connect, (struct zserv *client), (client));
+DEFINE_KOOH(zapi_client_close, (struct zserv *client), (client));
/* free zebra client information. */
static void zebra_client_free(struct zserv *client)
diff --git a/zebra/zserv.h b/zebra/zserv.h
index 05262490dd..a5b5acbb33 100644
--- a/zebra/zserv.h
+++ b/zebra/zserv.h
@@ -145,8 +145,8 @@ struct zserv {
struct zebra_vrf *zvrf
/* Hooks for client connect / disconnect */
-DECLARE_HOOK(zapi_client_connect, (struct zserv * client), (client));
-DECLARE_KOOH(zapi_client_close, (struct zserv * client), (client));
+DECLARE_HOOK(zapi_client_connect, (struct zserv *client), (client));
+DECLARE_KOOH(zapi_client_close, (struct zserv *client), (client));
/* Zebra instance */
struct zebra_t {