nhrpd: copy NAT extension if present else attempt to populate

Signed-off-by: Reuben Dowle <reuben.dowle@4rf.com>
This commit is contained in:
Amol Lad 2021-02-26 13:30:34 +05:30 committed by Reuben Dowle
parent 9c292647a9
commit 1bd508da17

View File

@ -966,6 +966,10 @@ static void nhrp_peer_forward(struct nhrp_peer *p,
} }
break; break;
case NHRP_EXTENSION_NAT_ADDRESS: case NHRP_EXTENSION_NAT_ADDRESS:
/* if NAT extension is not empty then copy it across else attempt to populate it */
if (len > 0) {
zbuf_copy(zb, &extpl, len);
} else {
if(packet_types[hdr->type].type == PACKET_REQUEST) { if(packet_types[hdr->type].type == PACKET_REQUEST) {
debugf(NHRP_DEBUG_COMMON,"Processing NHRP_EXTENSION_NAT_ADDRESS while forwarding the request packet"); debugf(NHRP_DEBUG_COMMON,"Processing NHRP_EXTENSION_NAT_ADDRESS while forwarding the request packet");
proto = &pp->src_proto; proto = &pp->src_proto;
@ -993,6 +997,7 @@ static void nhrp_peer_forward(struct nhrp_peer *p,
} else { } else {
zbuf_put(zb, extpl.head, len); zbuf_put(zb, extpl.head, len);
} }
}
break; break;
default: default:
if (htons(ext->type) & NHRP_EXTENSION_FLAG_COMPULSORY) if (htons(ext->type) & NHRP_EXTENSION_FLAG_COMPULSORY)