Skip to content

Corrected PPP debug trace flagging #12195

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions features/netsocket/ppp/include/ppp_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,8 @@ int str_to_epdisc (struct epdisc *, char *); /* endpt disc. from str */
#define multilink_master 0
#endif

#if PPP_DEBUG

/* Procedures exported from utils.c. */
void ppp_print_string(const u_char *p, int len, void (*printer) (void *, const char *, ...), void *arg); /* Format a string for output */
int ppp_slprintf(char *buf, int buflen, const char *fmt, ...); /* sprintf++ */
Expand All @@ -665,6 +667,22 @@ void ppp_dump_packet(ppp_pcb *pcb, const char *tag, unsigned char *p, int len);
/* dump packet to debug log if interesting */
#endif /* PRINTPKT_SUPPORT */

#else

#define ppp_print_string(...)
#define ppp_slprintf(...)
#define ppp_vslprintf(...)
#define ppp_strlcpy(...)
#define ppp_strlcat(...)
#define ppp_dbglog(...)
#define ppp_info(...)
#define ppp_notice(...)
#define ppp_warn(...)
#define ppp_error(...)
#define ppp_fatal(...)

#endif /* PPP_DEBUG */

/*
* Number of necessary timers analysis.
*
Expand Down
17 changes: 13 additions & 4 deletions features/netsocket/ppp/source/auth.c
Original file line number Diff line number Diff line change
Expand Up @@ -630,12 +630,13 @@ void link_terminated(ppp_pcb *pcb) {
#endif /* UNUSED */

if (!doing_multilink) {
ppp_notice("Connection terminated.");
ppp_notice("Connection terminated.");
#if PPP_STATS_SUPPORT
print_link_stats();
print_link_stats();
#endif /* PPP_STATS_SUPPORT */
} else
ppp_notice("Link terminated.");
} else {
ppp_notice("Link terminated.");
}

lcp_lowerdown(pcb);

Expand Down Expand Up @@ -1131,13 +1132,17 @@ void auth_withpeer_fail(ppp_pcb *pcb, int protocol) {
*/
void auth_withpeer_success(ppp_pcb *pcb, int protocol, int prot_flavor) {
int bit;
#if PPP_DEBUG
const char *prot = "";
#endif

switch (protocol) {
#if CHAP_SUPPORT
case PPP_CHAP:
bit = CHAP_WITHPEER;
#if PPP_DEBUG
prot = "CHAP";
#endif
switch (prot_flavor) {
case CHAP_MD5:
bit |= CHAP_MD5_WITHPEER;
Expand All @@ -1158,13 +1163,17 @@ void auth_withpeer_success(ppp_pcb *pcb, int protocol, int prot_flavor) {
#if PAP_SUPPORT
case PPP_PAP:
bit = PAP_WITHPEER;
#if PPP_DEBUG
prot = "PAP";
#endif
break;
#endif /* PAP_SUPPORT */
#if EAP_SUPPORT
case PPP_EAP:
bit = EAP_WITHPEER;
#if PPP_DEBUG
prot = "EAP";
#endif
break;
#endif /* EAP_SUPPORT */
default:
Expand Down
8 changes: 5 additions & 3 deletions features/netsocket/ppp/source/chap-new.c
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,10 @@ void chap_auth_with_peer(ppp_pcb *pcb, const char *our_name, int digest_code) {
if (dp->code == digest_code)
break;

if (dp == NULL)
if (dp == NULL) {
ppp_fatal("CHAP digest 0x%x requested but not available",
digest_code);
}

pcb->chap_client.digest = dp;
pcb->chap_client.name = our_name;
Expand Down Expand Up @@ -519,10 +520,11 @@ static void chap_handle_status(ppp_pcb *pcb, int code, int id,
msg = "CHAP authentication failed";
}
if (msg) {
if (len > 0)
if (len > 0) {
ppp_info("%s: %.*v", msg, len, pkt);
else
} else {
ppp_info("%s", msg);
}
}
if (code == CHAP_SUCCESS)
auth_withpeer_success(pcb, PPP_CHAP, pcb->chap_client.digest->code);
Expand Down
7 changes: 6 additions & 1 deletion features/netsocket/ppp/source/fsm.c
Original file line number Diff line number Diff line change
Expand Up @@ -589,8 +589,9 @@ static void fsm_rtermreq(fsm *f, int id, u_char *p, int len) {
case PPP_FSM_OPENED:
if (len > 0) {
ppp_info("%s terminated by peer (%0.*v)", PROTO_NAME(f), len, p);
} else
} else {
ppp_info("%s terminated by peer", PROTO_NAME(f));
}
f->retransmits = 0;
f->state = PPP_FSM_STOPPING;
if (f->callbacks->down)
Expand Down Expand Up @@ -643,15 +644,19 @@ static void fsm_rtermack(fsm *f) {
* fsm_rcoderej - Receive an Code-Reject.
*/
static void fsm_rcoderej(fsm *f, u_char *inp, int len) {
#if PPP_DEBUG
u_char code, id;
#endif

if (len < HEADERLEN) {
FSMDEBUG(("fsm_rcoderej: Rcvd short Code-Reject packet!"));
return;
}
#if PPP_DEBUG
GETCHAR(code, inp);
GETCHAR(id, inp);
ppp_warn("%s: Rcvd Code-Reject for code %d, id %d", PROTO_NAME(f), code, id);
#endif

if( f->state == PPP_FSM_ACKRCVD )
f->state = PPP_FSM_REQSENT;
Expand Down
9 changes: 6 additions & 3 deletions features/netsocket/ppp/source/ipcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -2087,13 +2087,16 @@ static void ipcp_up(fsm *f) {
wo->ouraddr = go->ouraddr;

ppp_notice("local IP address %I", go->ouraddr);
if (ho->hisaddr != 0)
if (ho->hisaddr != 0) {
ppp_notice("remote IP address %I", ho->hisaddr);
}
#if PPP_DNS
if (go->dnsaddr[0])
if (go->dnsaddr[0]) {
ppp_notice("primary DNS address %I", go->dnsaddr[0]);
if (go->dnsaddr[1])
}
if (go->dnsaddr[1]) {
ppp_notice("secondary DNS address %I", go->dnsaddr[1]);
}
#endif /* PPP_DNS */
}

Expand Down
6 changes: 5 additions & 1 deletion features/netsocket/ppp/source/ipv6cp.c
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,9 @@ static enum script_state {
static pid_t ipv6cp_script_pid;
#endif /* UNUSED */

#if PPP_DEBUG
static char *llv6_ntoa(eui64_t ifaceid);
#endif

#if PPP_OPTIONS
/*
Expand Down Expand Up @@ -409,6 +411,7 @@ printifaceid(opt, printer, arg)
/*
* Make a string representation of a network address.
*/
#if PPP_DEBUG
static char *
llv6_ntoa(eui64_t ifaceid)
{
Expand All @@ -420,7 +423,7 @@ llv6_ntoa(eui64_t ifaceid)

return b;
}

#endif

/*
* ipv6cp_init - Initialize IPV6CP.
Expand Down Expand Up @@ -1245,6 +1248,7 @@ static void ipv6cp_up(fsm *f) {
ipv6cp_close(f->pcb, "Interface configuration failed");
return;
}

#if DEMAND_SUPPORT
sifnpmode(f->pcb, PPP_IPV6, NPMODE_PASS);
#endif /* DEMAND_SUPPORT */
Expand Down
5 changes: 3 additions & 2 deletions features/netsocket/ppp/source/lcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -2664,8 +2664,9 @@ static void LcpEchoCheck(fsm *f) {
/*
* Start the timer for the next interval.
*/
if (pcb->lcp_echo_timer_running)
ppp_warn("assertion lcp_echo_timer_running==0 failed");
if (pcb->lcp_echo_timer_running) {
ppp_warn("assertion lcp_echo_timer_running==0 failed");
}
TIMEOUT (LcpEchoTimeout, f, pcb->settings.lcp_echo_interval);
pcb->lcp_echo_timer_running = 1;
}
Expand Down
2 changes: 2 additions & 0 deletions features/netsocket/ppp/source/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

#include "ppp_opts.h"
#if PPP_SUPPORT /* don't build if not configured for use in ppp_opts.h */
#if PPP_DEBUG

#if 0 /* UNUSED */
#include <stdio.h>
Expand Down Expand Up @@ -955,4 +956,5 @@ unlock()

#endif /* Unused */

#endif /* PPP_DEBUG */
#endif /* PPP_SUPPORT */