nhrpd: Make comments clearer, fix style issues

Signed-off-by: Reuben Dowle <reuben.dowle@4rf.com>
This commit is contained in:
Reuben Dowle 2021-03-11 13:51:58 +13:00
parent 083bbfaebf
commit 74e5ba3a3f
3 changed files with 14 additions and 11 deletions

View file

@ -464,15 +464,13 @@ void nhrp_interface_set_protection(struct interface *ifp, const char *profile,
{ {
struct nhrp_interface *nifp = ifp->info; struct nhrp_interface *nifp = ifp->info;
if (nifp->ipsec_profile) if (nifp->ipsec_profile) {
{
vici_terminate_vc_by_profile_name(nifp->ipsec_profile); vici_terminate_vc_by_profile_name(nifp->ipsec_profile);
free(nifp->ipsec_profile); free(nifp->ipsec_profile);
} }
nifp->ipsec_profile = profile ? strdup(profile) : NULL; nifp->ipsec_profile = profile ? strdup(profile) : NULL;
if (nifp->ipsec_fallback_profile) if (nifp->ipsec_fallback_profile) {
{
vici_terminate_vc_by_profile_name(nifp->ipsec_fallback_profile); vici_terminate_vc_by_profile_name(nifp->ipsec_fallback_profile);
free(nifp->ipsec_fallback_profile); free(nifp->ipsec_fallback_profile);
} }

View file

@ -116,12 +116,15 @@ static int nhrp_reg_timeout(struct thread *t)
} }
r->timeout <<= 1; r->timeout <<= 1;
if (r->timeout > 64) if (r->timeout > 64) {
{ /* If registration fails repeatedly, this may be because the
//Remove the ipsec connection if it is there, it can get re-established later * IPSec connection is not working. Close the connection so it
if(r->peer && r->peer->vc && r->peer->vc->ike_uniqueid) * can be re-established correctly
{ */
debugf(NHRP_DEBUG_COMMON, "Terminating IPSec Connection for %d\n", r->peer->vc->ike_uniqueid); if (r->peer && r->peer->vc && r->peer->vc->ike_uniqueid) {
debugf(NHRP_DEBUG_COMMON,
"Terminating IPSec Connection for %d\n",
r->peer->vc->ike_uniqueid);
vici_terminate_vc_by_ike_id(r->peer->vc->ike_uniqueid); vici_terminate_vc_by_ike_id(r->peer->vc->ike_uniqueid);
r->peer->vc->ike_uniqueid = 0; r->peer->vc->ike_uniqueid = 0;
} }

View file

@ -525,6 +525,7 @@ void vici_terminate(void)
void vici_terminate_vc_by_profile_name(char *profile_name) void vici_terminate_vc_by_profile_name(char *profile_name)
{ {
struct vici_conn *vici = &vici_connection; struct vici_conn *vici = &vici_connection;
vici_submit_request(vici, "terminate", VICI_KEY_VALUE, "ike", vici_submit_request(vici, "terminate", VICI_KEY_VALUE, "ike",
strlen(profile_name), profile_name, VICI_END); strlen(profile_name), profile_name, VICI_END);
} }
@ -532,7 +533,8 @@ void vici_terminate_vc_by_profile_name(char *profile_name)
void vici_terminate_vc_by_ike_id(unsigned int ike_id) void vici_terminate_vc_by_ike_id(unsigned int ike_id)
{ {
struct vici_conn *vici = &vici_connection; struct vici_conn *vici = &vici_connection;
char ike_id_str[10]={0}; char ike_id_str[10];
snprintf(ike_id_str, sizeof(ike_id_str), "%d", ike_id); snprintf(ike_id_str, sizeof(ike_id_str), "%d", ike_id);
vici_submit_request(vici, "terminate", VICI_KEY_VALUE, "ike-id", vici_submit_request(vici, "terminate", VICI_KEY_VALUE, "ike-id",
strlen(ike_id_str), ike_id_str, VICI_END); strlen(ike_id_str), ike_id_str, VICI_END);