Skip to content

Commit

Permalink
Avoid using #ifdef/#endif surrounding multilink functionality
Browse files Browse the repository at this point in the history
Signed-off-by: Eivind Næss <[email protected]>
  • Loading branch information
enaess committed Jan 11, 2023
1 parent 29ae55f commit 8343b13
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 34 deletions.
18 changes: 0 additions & 18 deletions pppd/auth.c
Original file line number Diff line number Diff line change
Expand Up @@ -709,24 +709,18 @@ link_terminated(int unit)
}
session_end(devnam);

#ifdef PPP_WITH_MULTILINK
if (!mp_on()) {
notice("Connection terminated.");
print_link_stats();
} else
#endif
notice("Link terminated.");

/*
* Delete pid files before disestablishing ppp. Otherwise it
* can happen that another pppd gets the same unit and then
* we delete its pid file.
*/
#ifdef PPP_WITH_MULTILINK
if (!demand && !mp_on())
#else
if (!demand)
#endif
remove_pidfiles();
/*
* If we may want to bring the link up again, transfer
Expand All @@ -737,19 +731,13 @@ link_terminated(int unit)
remove_fd(fd_ppp);
clean_check();
the_channel->disestablish_ppp(devfd);
#ifdef PPP_WITH_MULTILINK
if (mp_on())
mp_exit_bundle();
#endif
fd_ppp = -1;
}
if (!hungup)
lcp_lowerdown(0);
#ifdef PPP_WITH_MULTILINK
if (!mp_on() && !demand)
#else
if (!demand)
#endif
ppp_script_unsetenv("IFNAME");

/*
Expand All @@ -763,7 +751,6 @@ link_terminated(int unit)
if (the_channel->cleanup)
(*the_channel->cleanup)();

#ifdef PPP_WITH_MULTILINK
if (mp_on() && mp_master()) {
if (!bundle_terminating) {
new_phase(PHASE_MASTER);
Expand All @@ -772,7 +759,6 @@ link_terminated(int unit)
} else
mp_bundle_terminated();
} else
#endif
new_phase(PHASE_DEAD);
}

Expand All @@ -791,9 +777,7 @@ link_down(int unit)
auth_script(PPP_PATH_AUTHDOWN);
}
}
#ifdef PPP_WITH_MULTILINK
if (!mp_on())
#endif
{
upper_layers_down(unit);
if (!in_phase(PHASE_DEAD) && !in_phase(PHASE_MASTER))
Expand Down Expand Up @@ -840,9 +824,7 @@ link_established(int unit)
/*
* Tell higher-level protocols that LCP is up.
*/
#ifdef PPP_WITH_MULTILINK
if (!mp_on())
#endif
for (i = 0; (protp = protocols[i]) != NULL; ++i)
if (protp->protocol != PPP_LCP && protp->enabled_flag
&& protp->lowerup != NULL)
Expand Down
8 changes: 0 additions & 8 deletions pppd/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -461,9 +461,7 @@ main(int argc, char *argv[])
if (!sys_check_options())
exit(EXIT_OPTION_ERROR);
auth_check_options();
#ifdef PPP_WITH_MULTILINK
mp_check_options();
#endif
for (i = 0; (protp = protocols[i]) != NULL; ++i)
if (protp->check_options != NULL)
(*protp->check_options)();
Expand Down Expand Up @@ -605,10 +603,8 @@ main(int argc, char *argv[])
lcp_close(0, "User request");
if (asked_to_quit) {
bundle_terminating = 1;
#ifdef PPP_WITH_MULTILINK
if (phase == PHASE_MASTER)
mp_bundle_terminated();
#endif
}
if (open_ccp_flag) {
if (phase == PHASE_NETWORK || phase == PHASE_RUNNING) {
Expand Down Expand Up @@ -1113,13 +1109,11 @@ get_input(void)
return;

if (len == 0) {
#ifdef PPP_WITH_MULTILINK
if (bundle_eof && mp_master()) {
notice("Last channel has disconnected");
mp_bundle_terminated();
return;
}
#endif
notice("Modem hangup");
hungup = 1;
code = EXIT_HANGUP;
Expand Down Expand Up @@ -1247,10 +1241,8 @@ void
die(int status)
{

#if PPP_WITH_MULTILINK
if (!mp_on() || mp_master())
print_link_stats();
#endif
cleanup();
notify(exitnotify, status);
syslog(LOG_INFO, "Exit.");
Expand Down
15 changes: 15 additions & 0 deletions pppd/multilink.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,5 +93,20 @@ int str_to_epdisc(struct epdisc *, char *);
typedef void (multilink_join_hook_fn)(void);
extern multilink_join_hook_fn *multilink_join_hook;

#else

#define mp_check_options(x) ((void)0)
#define mp_join_bundle(x) ((void)0)
#define mp_exit_bundle(x) ((void)0)
#define mp_bundle_terminated(x) ((void)0)

static inline bool mp_on() {
return false;
}

static inline bool mp_master() {
return false;
}

#endif // PPP_WITH_MULTILINK
#endif // PPP_MULTILINK_H
4 changes: 2 additions & 2 deletions pppd/plugins/pppol2tp/openl2tp.c
Original file line number Diff line number Diff line change
Expand Up @@ -280,16 +280,16 @@ static void openl2tp_ppp_updown_ind(int tunnel_id, int session_id, int up)
* multilink bundle.
*****************************************************************************/

#ifdef PPP_WITH_MULTILINK
static void openl2tp_multilink_join_ind(void)
{
#ifdef PPP_WITH_MULTILINK
if (mp_on() && !mp_master()) {
/* send event only if not master */
openl2tp_ppp_updown_ind(pppol2tp_tunnel_id,
pppol2tp_session_id, 1);
}
#endif
}
#endif

/*****************************************************************************
* Application init
Expand Down
6 changes: 0 additions & 6 deletions pppd/sys-linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -800,11 +800,7 @@ void ppp_generic_disestablish(int dev_fd)
if (demand) {
modify_flags(ppp_dev_fd, 0, SC_LOOP_TRAFFIC);
looped = 1;
#ifdef PPP_WITH_MULTILINK
} else if (!mp_on() && ppp_dev_fd >= 0) {
#else
} else if (ppp_dev_fd >= 0) {
#endif
close(ppp_dev_fd);
remove_fd(ppp_dev_fd);
ppp_dev_fd = -1;
Expand Down Expand Up @@ -1510,12 +1506,10 @@ int read_packet (unsigned char *buf)
error("read /dev/ppp: %m");
if (nr < 0 && errno == ENXIO)
nr = 0;
#ifdef PPP_WITH_MULTILINK
if (nr == 0 && mp_on()) {
remove_fd(ppp_dev_fd);
bundle_eof = 1;
}
#endif
}
if (new_style_driver && ppp_fd < 0 && ppp_dev_fd < 0)
nr = 0;
Expand Down

0 comments on commit 8343b13

Please sign in to comment.