summaryrefslogtreecommitdiffstats
path: root/eigrpd
diff options
context:
space:
mode:
Diffstat (limited to 'eigrpd')
-rw-r--r--eigrpd/eigrp_dump.c6
-rw-r--r--eigrpd/eigrp_hello.c6
-rw-r--r--eigrpd/eigrp_interface.c10
-rw-r--r--eigrpd/eigrp_packet.c29
-rw-r--r--eigrpd/eigrp_routemap.c97
-rw-r--r--eigrpd/eigrp_topology.c2
-rw-r--r--eigrpd/eigrp_update.c3
-rw-r--r--eigrpd/eigrp_vty.c22
8 files changed, 105 insertions, 70 deletions
diff --git a/eigrpd/eigrp_dump.c b/eigrpd/eigrp_dump.c
index 57aeb2a4d..091b27112 100644
--- a/eigrpd/eigrp_dump.c
+++ b/eigrpd/eigrp_dump.c
@@ -295,11 +295,13 @@ void show_ip_eigrp_prefix_entry(struct vty *vty, struct eigrp_prefix_entry *tn)
vty_out(vty, "%s, ",
prefix2str(tn->destination, buffer, PREFIX_STRLEN));
- vty_out(vty, "%u successors, ", successors->count);
+ vty_out(vty, "%u successors, ",
+ (successors) ? successors->count : 0);
vty_out(vty, "FD is %u, serno: %" PRIu64 " \n", tn->fdistance,
tn->serno);
- list_delete(successors);
+ if (successors)
+ list_delete(successors);
}
void show_ip_eigrp_nexthop_entry(struct vty *vty, struct eigrp *eigrp,
diff --git a/eigrpd/eigrp_hello.c b/eigrpd/eigrp_hello.c
index ef10ebf54..49647c6b8 100644
--- a/eigrpd/eigrp_hello.c
+++ b/eigrpd/eigrp_hello.c
@@ -412,11 +412,15 @@ void eigrp_sw_version_initialize(void)
{
char ver_string[] = VERSION;
char *dash = strstr(ver_string, "-");
+ int ret;
if (dash)
dash[0] = '\0';
- sscanf(ver_string, "%d.%d", &FRR_MAJOR, &FRR_MINOR);
+ ret = sscanf(ver_string, "%d.%d", &FRR_MAJOR, &FRR_MINOR);
+ if (ret != 2)
+ zlog_err("Did not Properly parse %s, please fix VERSION string",
+ VERSION);
}
/**
diff --git a/eigrpd/eigrp_interface.c b/eigrpd/eigrp_interface.c
index f72e23ecd..f2512eada 100644
--- a/eigrpd/eigrp_interface.c
+++ b/eigrpd/eigrp_interface.c
@@ -249,15 +249,14 @@ int eigrp_if_up(struct eigrp_interface *ei)
struct eigrp_metrics metric;
struct eigrp_interface *ei2;
struct listnode *node, *nnode;
- struct eigrp *eigrp = eigrp_lookup();
+ struct eigrp *eigrp;
if (ei == NULL)
return 0;
- if (eigrp != NULL)
- eigrp_adjust_sndbuflen(eigrp, ei->ifp->mtu);
- else
- zlog_warn("%s: eigrp_lookup () returned NULL", __func__);
+ eigrp = ei->eigrp;
+ eigrp_adjust_sndbuflen(eigrp, ei->ifp->mtu);
+
eigrp_if_stream_set(ei);
/* Set multicast memberships appropriately for new state. */
@@ -307,6 +306,7 @@ int eigrp_if_up(struct eigrp_interface *ei)
pe->nt = EIGRP_TOPOLOGY_TYPE_CONNECTED;
ne->prefix = pe;
+ pe->reported_metric = metric;
pe->state = EIGRP_FSM_STATE_PASSIVE;
pe->fdistance = eigrp_calculate_metrics(eigrp, metric);
pe->req_action |= EIGRP_FSM_NEED_UPDATE;
diff --git a/eigrpd/eigrp_packet.c b/eigrpd/eigrp_packet.c
index 68e7cdcbb..8a7d4d958 100644
--- a/eigrpd/eigrp_packet.c
+++ b/eigrpd/eigrp_packet.c
@@ -193,6 +193,12 @@ int eigrp_check_md5_digest(struct stream *s,
if (keychain)
key = key_lookup_for_send(keychain);
+ if (!key) {
+ zlog_warn("Interface %s: Expected key value not found in config",
+ nbr->ei->ifp->name);
+ return 0;
+ }
+
memset(&ctx, 0, sizeof(ctx));
MD5Init(&ctx);
@@ -229,8 +235,7 @@ int eigrp_check_md5_digest(struct stream *s,
}
/* save neighbor's crypt_seqnum */
- if (nbr)
- nbr->crypt_seqnum = authTLV->key_sequence;
+ nbr->crypt_seqnum = authTLV->key_sequence;
return 1;
}
@@ -240,10 +245,11 @@ int eigrp_make_sha256_digest(struct eigrp_interface *ei, struct stream *s,
{
struct key *key = NULL;
struct keychain *keychain;
- char *source_ip;
+ char source_ip[PREFIX_STRLEN];
unsigned char digest[EIGRP_AUTH_TYPE_SHA256_LEN];
unsigned char buffer[1 + PLAINTEXT_LENGTH + 45 + 1] = {0};
+
HMAC_SHA256_CTX ctx;
void *ibuf;
size_t backup_get, backup_end;
@@ -263,11 +269,13 @@ int eigrp_make_sha256_digest(struct eigrp_interface *ei, struct stream *s,
if (keychain)
key = key_lookup_for_send(keychain);
- // saved_len[index] = strnzcpyn(saved_key[index], key,
- // PLAINTEXT_LENGTH + 1);
+ if (!key) {
+ zlog_warn("Interface %s: Expected key value not found in config",
+ ei->ifp->name);
+ return 0;
+ }
- source_ip = calloc(16, sizeof(char));
- inet_ntop(AF_INET, &ei->address->u.prefix4, source_ip, 16);
+ inet_ntop(AF_INET, &ei->address->u.prefix4, source_ip, PREFIX_STRLEN);
memset(&ctx, 0, sizeof(ctx));
buffer[0] = '\n';
@@ -287,7 +295,6 @@ int eigrp_make_sha256_digest(struct eigrp_interface *ei, struct stream *s,
stream_set_endp(s, backup_end);
eigrp_authTLV_SHA256_free(auth_TLV);
- free(source_ip);
return EIGRP_AUTH_TYPE_SHA256_LEN;
}
@@ -613,10 +620,10 @@ int eigrp_read(struct thread *thread)
opcode = eigrph->opcode;
if (IS_DEBUG_EIGRP_TRANSMIT(0, RECV)) {
- char src[100], dst[100];
+ char src[PREFIX_STRLEN], dst[PREFIX_STRLEN];
- strcpy(src, inet_ntoa(iph->ip_src));
- strcpy(dst, inet_ntoa(iph->ip_dst));
+ strncpy(src, inet_ntoa(iph->ip_src), PREFIX_STRLEN);
+ strncpy(dst, inet_ntoa(iph->ip_dst), PREFIX_STRLEN);
zlog_debug("Received [%s][%d/%d] length [%u] via [%s] src [%s] dst [%s]",
lookup_msg(eigrp_packet_type_str, opcode, NULL),
ntohl(eigrph->sequence), ntohl(eigrph->ack), length,
diff --git a/eigrpd/eigrp_routemap.c b/eigrpd/eigrp_routemap.c
index b645ed198..360e28adf 100644
--- a/eigrpd/eigrp_routemap.c
+++ b/eigrpd/eigrp_routemap.c
@@ -137,16 +137,19 @@ static int eigrp_route_match_add(struct vty *vty, struct route_map_index *index,
{
int ret;
ret = route_map_add_match(index, command, arg);
- if (ret) {
- switch (ret) {
- case RMAP_RULE_MISSING:
- vty_out(vty, "%% Can't find rule.\n");
- return CMD_WARNING_CONFIG_FAILED;
- case RMAP_COMPILE_ERROR:
- vty_out(vty, "%% Argument is malformed.\n");
- return CMD_WARNING_CONFIG_FAILED;
- }
+ switch (ret) {
+ case RMAP_RULE_MISSING:
+ vty_out(vty, "%% Can't find rule.\n");
+ return CMD_WARNING_CONFIG_FAILED;
+ break;
+ case RMAP_COMPILE_ERROR:
+ vty_out(vty, "%% Argument is malformed.\n");
+ return CMD_WARNING_CONFIG_FAILED;
+ break;
+ case RMAP_COMPILE_SUCCESS:
+ break;
}
+
return CMD_SUCCESS;
}
@@ -157,16 +160,19 @@ static int eigrp_route_match_delete(struct vty *vty,
{
int ret;
ret = route_map_delete_match(index, command, arg);
- if (ret) {
- switch (ret) {
- case RMAP_RULE_MISSING:
- vty_out(vty, "%% Can't find rule.\n");
- return CMD_WARNING_CONFIG_FAILED;
- case RMAP_COMPILE_ERROR:
- vty_out(vty, "%% Argument is malformed.\n");
- return CMD_WARNING_CONFIG_FAILED;
- }
+ switch (ret) {
+ case RMAP_RULE_MISSING:
+ vty_out(vty, "%% Can't find rule.\n");
+ return CMD_WARNING_CONFIG_FAILED;
+ break;
+ case RMAP_COMPILE_ERROR:
+ vty_out(vty, "%% Argument is malformed.\n");
+ return CMD_WARNING_CONFIG_FAILED;
+ break;
+ case RMAP_COMPILE_SUCCESS:
+ break;
}
+
return CMD_SUCCESS;
}
@@ -177,25 +183,27 @@ static int eigrp_route_set_add(struct vty *vty, struct route_map_index *index,
int ret;
ret = route_map_add_set(index, command, arg);
- if (ret) {
- switch (ret) {
- case RMAP_RULE_MISSING:
- vty_out(vty, "%% Can't find rule.\n");
+ switch (ret) {
+ case RMAP_RULE_MISSING:
+ vty_out(vty, "%% Can't find rule.\n");
+ return CMD_WARNING_CONFIG_FAILED;
+ break;
+ case RMAP_COMPILE_ERROR:
+ /*
+ * rip, ripng and other protocols share the set metric command
+ * but only values from 0 to 16 are valid for rip and ripng
+ * if metric is out of range for rip and ripng, it is
+ * not for other protocols. Do not return an error
+ */
+ if (strcmp(command, "metric")) {
+ vty_out(vty, "%% Argument is malformed.\n");
return CMD_WARNING_CONFIG_FAILED;
- case RMAP_COMPILE_ERROR:
- /* rip, ripng and other protocols share the set metric
- command
- but only values from 0 to 16 are valid for rip and
- ripng
- if metric is out of range for rip and ripng, it is
- not for
- other protocols. Do not return an error */
- if (strcmp(command, "metric")) {
- vty_out(vty, "%% Argument is malformed.\n");
- return CMD_WARNING_CONFIG_FAILED;
- }
}
+ break;
+ case RMAP_COMPILE_SUCCESS:
+ break;
}
+
return CMD_SUCCESS;
}
@@ -207,16 +215,19 @@ static int eigrp_route_set_delete(struct vty *vty,
int ret;
ret = route_map_delete_set(index, command, arg);
- if (ret) {
- switch (ret) {
- case RMAP_RULE_MISSING:
- vty_out(vty, "%% Can't find rule.\n");
- return CMD_WARNING_CONFIG_FAILED;
- case RMAP_COMPILE_ERROR:
- vty_out(vty, "%% Argument is malformed.\n");
- return CMD_WARNING_CONFIG_FAILED;
- }
+ switch (ret) {
+ case RMAP_RULE_MISSING:
+ vty_out(vty, "%% Can't find rule.\n");
+ return CMD_WARNING_CONFIG_FAILED;
+ break;
+ case RMAP_COMPILE_ERROR:
+ vty_out(vty, "%% Argument is malformed.\n");
+ return CMD_WARNING_CONFIG_FAILED;
+ break;
+ case RMAP_COMPILE_SUCCESS:
+ break;
}
+
return CMD_SUCCESS;
}
diff --git a/eigrpd/eigrp_topology.c b/eigrpd/eigrp_topology.c
index 2545f4d63..f1bc83af6 100644
--- a/eigrpd/eigrp_topology.c
+++ b/eigrpd/eigrp_topology.c
@@ -444,7 +444,7 @@ void eigrp_topology_update_node_flags(struct eigrp_prefix_entry *dest)
for (ALL_LIST_ELEMENTS_RO(dest->entries, node, entry)) {
if (((uint64_t)entry->distance
- <= (uint64_t)(dest->distance * eigrp->variance))
+ <= (uint64_t)dest->distance * (uint64_t)eigrp->variance)
&& entry->distance != EIGRP_MAX_METRIC) // is successor
{
entry->flags |= EIGRP_NEXTHOP_ENTRY_SUCCESSOR_FLAG;
diff --git a/eigrpd/eigrp_update.c b/eigrpd/eigrp_update.c
index fad4093ef..baa1ac553 100644
--- a/eigrpd/eigrp_update.c
+++ b/eigrpd/eigrp_update.c
@@ -409,6 +409,9 @@ void eigrp_update_receive(struct eigrp *eigrp, struct ip *iph,
eigrp_query_send_all(eigrp);
eigrp_update_send_all(eigrp, ei);
+
+ if (nbr_prefixes)
+ list_delete(nbr_prefixes);
}
/*send EIGRP Update packet*/
diff --git a/eigrpd/eigrp_vty.c b/eigrpd/eigrp_vty.c
index f9119b56e..01407a746 100644
--- a/eigrpd/eigrp_vty.c
+++ b/eigrpd/eigrp_vty.c
@@ -93,7 +93,7 @@ static int config_write_interfaces(struct vty *vty, struct eigrp *eigrp)
struct listnode *node;
for (ALL_LIST_ELEMENTS_RO(eigrp->eiflist, node, ei)) {
- vty_out(vty, "interface %s\n", ei->ifp->name);
+ vty_frame(vty, "interface %s\n", ei->ifp->name);
if ((IF_DEF_PARAMS(ei->ifp)->auth_type)
== EIGRP_AUTH_TYPE_MD5) {
@@ -128,7 +128,7 @@ static int config_write_interfaces(struct vty *vty, struct eigrp *eigrp)
}
/*Separate this EIGRP interface configuration from the others*/
- vty_out(vty, "!\n");
+ vty_endframe(vty, "!\n");
}
return 0;
@@ -140,7 +140,7 @@ static int eigrp_write_interface(struct vty *vty)
struct interface *ifp;
for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), node, ifp)) {
- vty_out(vty, "interface %s\n", ifp->name);
+ vty_frame(vty, "interface %s\n", ifp->name);
if (ifp->desc)
vty_out(vty, " description %s\n", ifp->desc);
@@ -157,7 +157,7 @@ static int eigrp_write_interface(struct vty *vty)
vty_out(vty, " ip hold-time eigrp %u\n",
IF_DEF_PARAMS(ifp)->v_wait);
- vty_out(vty, "!\n");
+ vty_endframe(vty, "!\n");
}
return 0;
@@ -400,7 +400,7 @@ DEFUN (eigrp_network,
if (ret == 0) {
vty_out(vty, "There is already same network statement.\n");
- return CMD_WARNING_CONFIG_FAILED;
+ return CMD_WARNING;
}
return CMD_SUCCESS;
@@ -1267,7 +1267,11 @@ DEFUN (clear_ip_eigrp_neighbors_IP,
struct eigrp_neighbor *nbr;
struct in_addr nbr_addr;
- inet_aton(argv[4]->arg, &nbr_addr);
+ if (!inet_aton(argv[4]->arg, &nbr_addr)) {
+ vty_out(vty, "Unable to parse %s",
+ argv[4]->arg);
+ return CMD_WARNING;
+ }
/* Check if eigrp process is enabled */
eigrp = eigrp_lookup();
@@ -1370,7 +1374,11 @@ DEFUN (clear_ip_eigrp_neighbors_IP_soft,
struct eigrp_neighbor *nbr;
struct in_addr nbr_addr;
- inet_aton(argv[4]->arg, &nbr_addr);
+ if (!inet_aton(argv[4]->arg, &nbr_addr)) {
+ vty_out(vty, "Unable to parse: %s",
+ argv[4]->arg);
+ return CMD_WARNING;
+ }
/* Check if eigrp process is enabled */
eigrp = eigrp_lookup();