Skip to content

Commit c473769

Browse files
committed
nhrpd: add cisco-authentication password support
Taking over this development from FRRouting#14788 This commit addresses 4 issues found in the previous PR 1) FRR would accept messages from a spoke without authentication when FRR NHRP had auth configured. 2) The error indication was not being sent in network byte order 3) The debug print in nhrp_connection_authorized was not correctly printing the received password 4) The addresses portion of the mandatory part of the error indication was invalid on the wire (confirmed in wireshark) Signed-off-by: Dave LeRoy <dleroy@labn.net>
1 parent 753d89b commit c473769

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

nhrpd/nhrp_peer.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1125,7 +1125,7 @@ static int nhrp_packet_send_error(struct nhrp_packet_parser *pp,
11251125
hdr = nhrp_packet_push(zb, NHRP_PACKET_ERROR_INDICATION, &pp->src_nbma,
11261126
&src_proto, &dst_proto);
11271127

1128-
hdr->u.error.code = indication_code;
1128+
hdr->u.error.code = htons(indication_code);
11291129
hdr->u.error.offset = htons(offset);
11301130
hdr->flags = pp->hdr->flags;
11311131
hdr->hop_count = 0; // XXX: cisco returns 255
@@ -1135,7 +1135,12 @@ static int nhrp_packet_send_error(struct nhrp_packet_parser *pp,
11351135
/* wireshark gives bad checksum, without exts */
11361136
// pp->hdr->checksum = nhrp_packet_calculate_checksum(zbuf_used(&pp->payload))
11371137
zbuf_put(zb, pp->hdr, sizeof(*pp->hdr));
1138-
zbuf_copy(zb, &pp->payload, zbuf_used(&pp->payload));
1138+
zbuf_put(zb, sockunion_get_addr(&pp->src_nbma),
1139+
hdr->src_nbma_address_len);
1140+
zbuf_put(zb, sockunion_get_addr(&pp->src_proto),
1141+
hdr->src_protocol_address_len);
1142+
zbuf_put(zb, sockunion_get_addr(&pp->dst_proto),
1143+
hdr->dst_protocol_address_len);
11391144
nhrp_packet_complete_auth(zb, hdr, pp->ifp, false);
11401145

11411146
/* nhrp_packet_debug(zb, "SEND_ERROR"); */
@@ -1151,7 +1156,7 @@ static bool nhrp_connection_authorized(struct nhrp_packet_parser *pp)
11511156
struct zbuf *auth = nifp->auth_token;
11521157
struct nhrp_extension_header *ext;
11531158
struct zbuf *extensions, pl;
1154-
int cmp = 0;
1159+
int cmp = 1;
11551160

11561161

11571162
extensions = zbuf_alloc(zbuf_used(&pp->extensions));
@@ -1164,7 +1169,11 @@ static bool nhrp_connection_authorized(struct nhrp_packet_parser *pp)
11641169
auth->buf;
11651170
debugf(NHRP_DEBUG_COMMON,
11661171
"Processing Authentication Extension for (%s:%s|%d)",
1167-
auth_ext->secret, (const char *)pl.buf, cmp);
1172+
auth_ext->secret,
1173+
((struct nhrp_cisco_authentication_extension *)
1174+
pl.buf)
1175+
->secret,
1176+
cmp);
11681177
break;
11691178
}
11701179
}

0 commit comments

Comments
 (0)