From 8343b13a051dacfa8a460982ffa30dabd8deb430 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eivind=20N=C3=A6ss?= Date: Wed, 11 Jan 2023 08:38:43 -0800 Subject: [PATCH] Avoid using #ifdef/#endif surrounding multilink functionality MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Eivind Næss --- pppd/auth.c | 18 ------------------ pppd/main.c | 8 -------- pppd/multilink.h | 15 +++++++++++++++ pppd/plugins/pppol2tp/openl2tp.c | 4 ++-- pppd/sys-linux.c | 6 ------ 5 files changed, 17 insertions(+), 34 deletions(-) diff --git a/pppd/auth.c b/pppd/auth.c index 4748458fe..d27f6306c 100644 --- a/pppd/auth.c +++ b/pppd/auth.c @@ -709,12 +709,10 @@ 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."); /* @@ -722,11 +720,7 @@ link_terminated(int unit) * 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 @@ -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"); /* @@ -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); @@ -772,7 +759,6 @@ link_terminated(int unit) } else mp_bundle_terminated(); } else -#endif new_phase(PHASE_DEAD); } @@ -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)) @@ -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) diff --git a/pppd/main.c b/pppd/main.c index f126c98e0..1a2a446cc 100644 --- a/pppd/main.c +++ b/pppd/main.c @@ -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)(); @@ -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) { @@ -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; @@ -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."); diff --git a/pppd/multilink.h b/pppd/multilink.h index 312ba27f4..e4639bb62 100644 --- a/pppd/multilink.h +++ b/pppd/multilink.h @@ -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 diff --git a/pppd/plugins/pppol2tp/openl2tp.c b/pppd/plugins/pppol2tp/openl2tp.c index 05e6137ed..940d2bc4e 100644 --- a/pppd/plugins/pppol2tp/openl2tp.c +++ b/pppd/plugins/pppol2tp/openl2tp.c @@ -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 diff --git a/pppd/sys-linux.c b/pppd/sys-linux.c index d477d6507..561b150f2 100644 --- a/pppd/sys-linux.c +++ b/pppd/sys-linux.c @@ -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; @@ -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;