Optionally re-introduce bb_info_msg()
Between Busybox 1.24.2 and 1.25.0 the bb_info_msg() function was eliminated and calls to it changed to be bb_error_msg(). The downside of this is that daemons now log all messages to syslog at the LOG_ERR level which makes it hard to filter errors from informational messages. This change optionally re-introduces bb_info_msg(), controlled by a new option FEATURE_SYSLOG_INFO, restores all the calls to bb_info_msg() that were removed (only in applets that set logmode to LOGMODE_SYSLOG or LOGMODE_BOTH), and also changes informational messages in ifplugd and ntpd. The code size change of this is as follows (using 'defconfig' on x86_64 with gcc 7.3.0-27ubuntu1~18.04) function old new delta bb_info_msg - 182 +182 bb_vinfo_msg - 27 +27 static.log7 194 198 +4 log8 190 191 +1 log5 190 191 +1 crondlog 45 - -45 ------------------------------------------------------------------------------ (add/remove: 2/1 grow/shrink: 3/0 up/down: 215/-45) Total: 170 bytes If you don't care about everything being logged at LOG_ERR level then when FEATURE_SYSLOG_INFO is disabled Busybox actually gets smaller: function old new delta static.log7 194 200 +6 log8 190 193 +3 log5 190 193 +3 syslog_level 1 - -1 bb_verror_msg 583 581 -2 crondlog 45 - -45 ------------------------------------------------------------------------------ (add/remove: 0/2 grow/shrink: 3/1 up/down: 12/-48) Total: -36 bytes Signed-off-by: James Byrne <james.byrne@origamienergy.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
f3a064f495
commit
253c4e787a
@ -339,6 +339,15 @@ config FEATURE_CLEAN_UP
|
|||||||
Don't enable this unless you have a really good reason to clean
|
Don't enable this unless you have a really good reason to clean
|
||||||
things up manually.
|
things up manually.
|
||||||
|
|
||||||
|
config FEATURE_SYSLOG_INFO
|
||||||
|
bool "Support LOG_INFO level syslog messages"
|
||||||
|
default y
|
||||||
|
depends on FEATURE_SYSLOG
|
||||||
|
help
|
||||||
|
Applets which send their output to syslog use either LOG_INFO or
|
||||||
|
LOG_ERR log levels, but by disabling this option all messages will
|
||||||
|
be logged at the LOG_ERR level, saving just under 200 bytes.
|
||||||
|
|
||||||
# These are auto-selected by other options
|
# These are auto-selected by other options
|
||||||
|
|
||||||
config FEATURE_SYSLOG
|
config FEATURE_SYSLOG
|
||||||
|
@ -1316,7 +1316,6 @@ enum {
|
|||||||
LOGMODE_BOTH = LOGMODE_SYSLOG + LOGMODE_STDIO,
|
LOGMODE_BOTH = LOGMODE_SYSLOG + LOGMODE_STDIO,
|
||||||
};
|
};
|
||||||
extern const char *msg_eol;
|
extern const char *msg_eol;
|
||||||
extern smallint syslog_level;
|
|
||||||
extern smallint logmode;
|
extern smallint logmode;
|
||||||
extern uint8_t xfunc_error_retval;
|
extern uint8_t xfunc_error_retval;
|
||||||
extern void (*die_func)(void);
|
extern void (*die_func)(void);
|
||||||
@ -1336,6 +1335,14 @@ void bb_verror_msg(const char *s, va_list p, const char *strerr) FAST_FUNC;
|
|||||||
void bb_die_memory_exhausted(void) NORETURN FAST_FUNC;
|
void bb_die_memory_exhausted(void) NORETURN FAST_FUNC;
|
||||||
void bb_logenv_override(void) FAST_FUNC;
|
void bb_logenv_override(void) FAST_FUNC;
|
||||||
|
|
||||||
|
#if ENABLE_FEATURE_SYSLOG_INFO
|
||||||
|
void bb_info_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2))) FAST_FUNC;
|
||||||
|
void bb_vinfo_msg(const char *s, va_list p) FAST_FUNC;
|
||||||
|
#else
|
||||||
|
#define bb_info_msg bb_error_msg
|
||||||
|
#define bb_vinfo_msg(s,p) bb_verror_msg(s,p,NULL)
|
||||||
|
#endif
|
||||||
|
|
||||||
/* We need to export XXX_main from libbusybox
|
/* We need to export XXX_main from libbusybox
|
||||||
* only if we build "individual" binaries
|
* only if we build "individual" binaries
|
||||||
*/
|
*/
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if ENABLE_FEATURE_SYSLOG
|
#if ENABLE_FEATURE_SYSLOG
|
||||||
smallint syslog_level = LOG_ERR;
|
static smallint syslog_level = LOG_ERR;
|
||||||
#endif
|
#endif
|
||||||
smallint logmode = LOGMODE_STDIO;
|
smallint logmode = LOGMODE_STDIO;
|
||||||
const char *msg_eol = "\n";
|
const char *msg_eol = "\n";
|
||||||
@ -154,7 +154,7 @@ void FAST_FUNC bb_verror_msg(const char *s, va_list p, const char* strerr)
|
|||||||
}
|
}
|
||||||
# if ENABLE_FEATURE_SYSLOG
|
# if ENABLE_FEATURE_SYSLOG
|
||||||
if (logmode & LOGMODE_SYSLOG) {
|
if (logmode & LOGMODE_SYSLOG) {
|
||||||
syslog(LOG_ERR, "%s", msgc);
|
syslog(syslog_level, "%s", msgc);
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
free(msgc);
|
free(msgc);
|
||||||
@ -180,3 +180,21 @@ void FAST_FUNC bb_error_msg(const char *s, ...)
|
|||||||
bb_verror_msg(s, p, NULL);
|
bb_verror_msg(s, p, NULL);
|
||||||
va_end(p);
|
va_end(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if ENABLE_FEATURE_SYSLOG_INFO
|
||||||
|
void FAST_FUNC bb_vinfo_msg(const char *s, va_list p)
|
||||||
|
{
|
||||||
|
syslog_level = LOG_INFO;
|
||||||
|
bb_verror_msg(s, p, NULL);
|
||||||
|
syslog_level = LOG_ERR;
|
||||||
|
}
|
||||||
|
|
||||||
|
void FAST_FUNC bb_info_msg(const char *s, ...)
|
||||||
|
{
|
||||||
|
va_list p;
|
||||||
|
|
||||||
|
va_start(p, s);
|
||||||
|
bb_vinfo_msg(s, p);
|
||||||
|
va_end(p);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
@ -114,7 +114,7 @@ int chpasswd_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
bb_error_msg_and_die("an error occurred updating password for %s", name);
|
bb_error_msg_and_die("an error occurred updating password for %s", name);
|
||||||
if (rc)
|
if (rc)
|
||||||
bb_error_msg("password for '%s' changed", name);
|
bb_info_msg("password for '%s' changed", name);
|
||||||
logmode = LOGMODE_STDIO;
|
logmode = LOGMODE_STDIO;
|
||||||
free(name);
|
free(name);
|
||||||
free(free_me);
|
free(free_me);
|
||||||
|
@ -228,7 +228,7 @@ int passwd_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
/* LOGMODE_BOTH */
|
/* LOGMODE_BOTH */
|
||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
bb_error_msg_and_die("can't update password file %s", filename);
|
bb_error_msg_and_die("can't update password file %s", filename);
|
||||||
bb_error_msg("password for %s changed by %s", name, myname);
|
bb_info_msg("password for %s changed by %s", name, myname);
|
||||||
|
|
||||||
/*if (ENABLE_FEATURE_CLEAN_UP) free(newp); - can't, it may be non-malloced */
|
/*if (ENABLE_FEATURE_CLEAN_UP) free(newp); - can't, it may be non-malloced */
|
||||||
skip:
|
skip:
|
||||||
|
@ -68,17 +68,17 @@ int sulogin_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
);
|
);
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
/* ^D, ^C, timeout, or read error */
|
/* ^D, ^C, timeout, or read error */
|
||||||
bb_error_msg("normal startup");
|
bb_info_msg("normal startup");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (r > 0) {
|
if (r > 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
bb_do_delay(LOGIN_FAIL_DELAY);
|
bb_do_delay(LOGIN_FAIL_DELAY);
|
||||||
bb_error_msg("Login incorrect");
|
bb_info_msg("Login incorrect");
|
||||||
}
|
}
|
||||||
|
|
||||||
bb_error_msg("starting shell for system maintenance");
|
bb_info_msg("starting shell for system maintenance");
|
||||||
|
|
||||||
IF_SELINUX(renew_current_security_context());
|
IF_SELINUX(renew_current_security_context());
|
||||||
|
|
||||||
|
@ -181,9 +181,7 @@ static void crondlog(unsigned level, const char *msg, va_list va)
|
|||||||
* need not touch syslog_level
|
* need not touch syslog_level
|
||||||
* (they are ok with LOG_ERR default).
|
* (they are ok with LOG_ERR default).
|
||||||
*/
|
*/
|
||||||
syslog_level = LOG_INFO;
|
bb_vinfo_msg(msg, va);
|
||||||
bb_verror_msg(msg, va, /* strerr: */ NULL);
|
|
||||||
syslog_level = LOG_ERR;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1108,7 +1106,7 @@ int crond_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
process_cron_update_file();
|
process_cron_update_file();
|
||||||
log5("wakeup dt=%ld", dt);
|
log5("wakeup dt=%ld", dt);
|
||||||
if (dt < -60 * 60 || dt > 60 * 60) {
|
if (dt < -60 * 60 || dt > 60 * 60) {
|
||||||
bb_error_msg("time disparity of %ld minutes detected", dt / 60);
|
bb_info_msg("time disparity of %ld minutes detected", dt / 60);
|
||||||
/* and we do not run any jobs in this case */
|
/* and we do not run any jobs in this case */
|
||||||
} else if (dt > 0) {
|
} else if (dt > 0) {
|
||||||
/* Usual case: time advances forward, as expected */
|
/* Usual case: time advances forward, as expected */
|
||||||
|
@ -343,7 +343,7 @@ static const char bb_msg_variable_not_found[] ALIGN1 = "variable: %s not found";
|
|||||||
|
|
||||||
/* Busybox stuff */
|
/* Busybox stuff */
|
||||||
#if ENABLE_DEVFSD_VERBOSE || ENABLE_DEBUG
|
#if ENABLE_DEVFSD_VERBOSE || ENABLE_DEBUG
|
||||||
#define info_logger(p, fmt, args...) bb_error_msg(fmt, ## args)
|
#define info_logger(p, fmt, args...) bb_info_msg(fmt, ## args)
|
||||||
#define msg_logger(p, fmt, args...) bb_error_msg(fmt, ## args)
|
#define msg_logger(p, fmt, args...) bb_error_msg(fmt, ## args)
|
||||||
#define msg_logger_and_die(p, fmt, args...) bb_error_msg_and_die(fmt, ## args)
|
#define msg_logger_and_die(p, fmt, args...) bb_error_msg_and_die(fmt, ## args)
|
||||||
#define error_logger(p, fmt, args...) bb_perror_msg(fmt, ## args)
|
#define error_logger(p, fmt, args...) bb_perror_msg(fmt, ## args)
|
||||||
|
@ -133,7 +133,7 @@ static struct dns_entry *parse_conf_file(const char *fileconf)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (OPT_verbose)
|
if (OPT_verbose)
|
||||||
bb_error_msg("name:%s, ip:%s", token[0], token[1]);
|
bb_info_msg("name:%s, ip:%s", token[0], token[1]);
|
||||||
|
|
||||||
/* sizeof(*m) includes 1 byte for m->name[0] */
|
/* sizeof(*m) includes 1 byte for m->name[0] */
|
||||||
m = xzalloc(sizeof(*m) + strlen(token[0]) + 1);
|
m = xzalloc(sizeof(*m) + strlen(token[0]) + 1);
|
||||||
@ -438,7 +438,7 @@ static int process_packet(struct dns_entry *conf_data,
|
|||||||
answstr = table_lookup(conf_data, type, query_string);
|
answstr = table_lookup(conf_data, type, query_string);
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
/* Shows lengths instead of dots, unusable for !DEBUG */
|
/* Shows lengths instead of dots, unusable for !DEBUG */
|
||||||
bb_error_msg("'%s'->'%s'", query_string, answstr);
|
bb_info_msg("'%s'->'%s'", query_string, answstr);
|
||||||
#endif
|
#endif
|
||||||
outr_rlen = 4;
|
outr_rlen = 4;
|
||||||
if (answstr && type == htons(REQ_PTR)) {
|
if (answstr && type == htons(REQ_PTR)) {
|
||||||
@ -474,7 +474,7 @@ static int process_packet(struct dns_entry *conf_data,
|
|||||||
* RCODE = 0 "success"
|
* RCODE = 0 "success"
|
||||||
*/
|
*/
|
||||||
if (OPT_verbose)
|
if (OPT_verbose)
|
||||||
bb_error_msg("returning positive reply");
|
bb_info_msg("returning positive reply");
|
||||||
outr_flags = htons(0x8000 | 0x0400 | 0);
|
outr_flags = htons(0x8000 | 0x0400 | 0);
|
||||||
/* we have one answer */
|
/* we have one answer */
|
||||||
head->nansw = htons(1);
|
head->nansw = htons(1);
|
||||||
@ -539,7 +539,7 @@ int dnsd_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
|
|
||||||
{
|
{
|
||||||
char *p = xmalloc_sockaddr2dotted(&lsa->u.sa);
|
char *p = xmalloc_sockaddr2dotted(&lsa->u.sa);
|
||||||
bb_error_msg("accepting UDP packets on %s", p);
|
bb_info_msg("accepting UDP packets on %s", p);
|
||||||
free(p);
|
free(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -557,7 +557,7 @@ int dnsd_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (OPT_verbose)
|
if (OPT_verbose)
|
||||||
bb_error_msg("got UDP packet");
|
bb_info_msg("got UDP packet");
|
||||||
buf[r] = '\0'; /* paranoia */
|
buf[r] = '\0'; /* paranoia */
|
||||||
r = process_packet(conf_data, conf_ttl, buf);
|
r = process_packet(conf_data, conf_ttl, buf);
|
||||||
if (r <= 0)
|
if (r <= 0)
|
||||||
|
@ -326,7 +326,7 @@ static int run_script(const char *action)
|
|||||||
char *argv[5];
|
char *argv[5];
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
bb_error_msg("executing '%s %s %s'", G.script_name, G.iface, action);
|
bb_info_msg("executing '%s %s %s'", G.script_name, G.iface, action);
|
||||||
|
|
||||||
argv[0] = (char*) G.script_name;
|
argv[0] = (char*) G.script_name;
|
||||||
argv[1] = (char*) G.iface;
|
argv[1] = (char*) G.iface;
|
||||||
@ -345,7 +345,7 @@ static int run_script(const char *action)
|
|||||||
bb_unsetenv_and_free(env_PREVIOUS);
|
bb_unsetenv_and_free(env_PREVIOUS);
|
||||||
bb_unsetenv_and_free(env_CURRENT);
|
bb_unsetenv_and_free(env_CURRENT);
|
||||||
|
|
||||||
bb_error_msg("exit code: %d", r & 0xff);
|
bb_info_msg("exit code: %d", r & 0xff);
|
||||||
return (option_mask32 & FLAG_IGNORE_RETVAL) ? 0 : r;
|
return (option_mask32 & FLAG_IGNORE_RETVAL) ? 0 : r;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -365,7 +365,7 @@ static void up_iface(void)
|
|||||||
if (!(ifrequest.ifr_flags & IFF_UP)) {
|
if (!(ifrequest.ifr_flags & IFF_UP)) {
|
||||||
ifrequest.ifr_flags |= IFF_UP;
|
ifrequest.ifr_flags |= IFF_UP;
|
||||||
/* Let user know we mess up with interface */
|
/* Let user know we mess up with interface */
|
||||||
bb_error_msg("upping interface");
|
bb_info_msg("upping interface");
|
||||||
if (network_ioctl(SIOCSIFFLAGS, &ifrequest, "setting interface flags") < 0) {
|
if (network_ioctl(SIOCSIFFLAGS, &ifrequest, "setting interface flags") < 0) {
|
||||||
if (errno != ENODEV && errno != EADDRNOTAVAIL)
|
if (errno != ENODEV && errno != EADDRNOTAVAIL)
|
||||||
xfunc_die();
|
xfunc_die();
|
||||||
@ -414,7 +414,7 @@ static void maybe_up_new_iface(void)
|
|||||||
(uint8_t)(ifrequest.ifr_hwaddr.sa_data[5]));
|
(uint8_t)(ifrequest.ifr_hwaddr.sa_data[5]));
|
||||||
}
|
}
|
||||||
|
|
||||||
bb_error_msg("using interface %s%s with driver<%s> (version: %s)",
|
bb_info_msg("using interface %s%s with driver<%s> (version: %s)",
|
||||||
G.iface, buf, driver_info.driver, driver_info.version);
|
G.iface, buf, driver_info.driver, driver_info.version);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -447,7 +447,7 @@ static smallint detect_link(void)
|
|||||||
logmode = sv_logmode;
|
logmode = sv_logmode;
|
||||||
if (status != IFSTATUS_ERR) {
|
if (status != IFSTATUS_ERR) {
|
||||||
G.api_method_num = i;
|
G.api_method_num = i;
|
||||||
bb_error_msg("using %s detection mode", method_table[i].name);
|
bb_info_msg("using %s detection mode", method_table[i].name);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -632,7 +632,7 @@ int ifplugd_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
/* | (1 << SIGCHLD) - run_script does not use it anymore */
|
/* | (1 << SIGCHLD) - run_script does not use it anymore */
|
||||||
, record_signo);
|
, record_signo);
|
||||||
|
|
||||||
bb_error_msg("started: %s", bb_banner);
|
bb_info_msg("started: %s", bb_banner);
|
||||||
|
|
||||||
if (opts & FLAG_MONITOR) {
|
if (opts & FLAG_MONITOR) {
|
||||||
struct ifreq ifrequest;
|
struct ifreq ifrequest;
|
||||||
@ -649,7 +649,7 @@ int ifplugd_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
iface_status_str = strstatus(iface_status);
|
iface_status_str = strstatus(iface_status);
|
||||||
|
|
||||||
if (opts & FLAG_MONITOR) {
|
if (opts & FLAG_MONITOR) {
|
||||||
bb_error_msg("interface %s",
|
bb_info_msg("interface %s",
|
||||||
G.iface_exists ? "exists"
|
G.iface_exists ? "exists"
|
||||||
: "doesn't exist, waiting");
|
: "doesn't exist, waiting");
|
||||||
}
|
}
|
||||||
@ -657,7 +657,7 @@ int ifplugd_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
* by potentially lying that it really exists */
|
* by potentially lying that it really exists */
|
||||||
|
|
||||||
if (G.iface_exists) {
|
if (G.iface_exists) {
|
||||||
bb_error_msg("link is %s", iface_status_str);
|
bb_info_msg("link is %s", iface_status_str);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((!(opts & FLAG_NO_STARTUP)
|
if ((!(opts & FLAG_NO_STARTUP)
|
||||||
@ -712,7 +712,7 @@ int ifplugd_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
if (G.iface_exists < 0) /* error */
|
if (G.iface_exists < 0) /* error */
|
||||||
goto exiting;
|
goto exiting;
|
||||||
if (iface_exists_old != G.iface_exists) {
|
if (iface_exists_old != G.iface_exists) {
|
||||||
bb_error_msg("interface %sappeared",
|
bb_info_msg("interface %sappeared",
|
||||||
G.iface_exists ? "" : "dis");
|
G.iface_exists ? "" : "dis");
|
||||||
if (G.iface_exists)
|
if (G.iface_exists)
|
||||||
maybe_up_new_iface();
|
maybe_up_new_iface();
|
||||||
@ -730,7 +730,7 @@ int ifplugd_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
iface_status_str = strstatus(iface_status);
|
iface_status_str = strstatus(iface_status);
|
||||||
|
|
||||||
if (iface_status_old != iface_status) {
|
if (iface_status_old != iface_status) {
|
||||||
bb_error_msg("link is %s", iface_status_str);
|
bb_info_msg("link is %s", iface_status_str);
|
||||||
|
|
||||||
if (delay_time) {
|
if (delay_time) {
|
||||||
/* link restored its old status before
|
/* link restored its old status before
|
||||||
|
@ -1130,7 +1130,7 @@ step_time(double offset)
|
|||||||
}
|
}
|
||||||
tval = tvn.tv_sec;
|
tval = tvn.tv_sec;
|
||||||
strftime_YYYYMMDDHHMMSS(buf, sizeof(buf), &tval);
|
strftime_YYYYMMDDHHMMSS(buf, sizeof(buf), &tval);
|
||||||
bb_error_msg("setting time to %s.%06u (offset %+fs)", buf, (unsigned)tvn.tv_usec, offset);
|
bb_info_msg("setting time to %s.%06u (offset %+fs)", buf, (unsigned)tvn.tv_usec, offset);
|
||||||
//maybe? G.FREQHOLD_cnt = 0;
|
//maybe? G.FREQHOLD_cnt = 0;
|
||||||
|
|
||||||
/* Correct various fields which contain time-relative values: */
|
/* Correct various fields which contain time-relative values: */
|
||||||
@ -2132,7 +2132,7 @@ recv_and_process_peer_pkt(peer_t *p)
|
|||||||
|
|
||||||
p->reachable_bits |= 1;
|
p->reachable_bits |= 1;
|
||||||
if ((MAX_VERBOSE && G.verbose) || (option_mask32 & OPT_w)) {
|
if ((MAX_VERBOSE && G.verbose) || (option_mask32 & OPT_w)) {
|
||||||
bb_error_msg("reply from %s: offset:%+f delay:%f status:0x%02x strat:%d refid:0x%08x rootdelay:%f reach:0x%02x",
|
bb_info_msg("reply from %s: offset:%+f delay:%f status:0x%02x strat:%d refid:0x%08x rootdelay:%f reach:0x%02x",
|
||||||
p->p_dotted,
|
p->p_dotted,
|
||||||
offset,
|
offset,
|
||||||
p->p_raw_delay,
|
p->p_raw_delay,
|
||||||
|
@ -245,7 +245,7 @@ static int tftp_blksize_check(const char *blksize_str, int maxsize)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
# if ENABLE_TFTP_DEBUG
|
# if ENABLE_TFTP_DEBUG
|
||||||
bb_error_msg("using blksize %u", blksize);
|
bb_info_msg("using blksize %u", blksize);
|
||||||
# endif
|
# endif
|
||||||
return blksize;
|
return blksize;
|
||||||
}
|
}
|
||||||
|
@ -191,7 +191,7 @@ static void log_option(const char *pfx, const uint8_t *opt)
|
|||||||
if (dhcp_verbose >= 2) {
|
if (dhcp_verbose >= 2) {
|
||||||
char buf[256 * 2 + 2];
|
char buf[256 * 2 + 2];
|
||||||
*bin2hex(buf, (void*) (opt + OPT_DATA), opt[OPT_LEN]) = '\0';
|
*bin2hex(buf, (void*) (opt + OPT_DATA), opt[OPT_LEN]) = '\0';
|
||||||
bb_error_msg("%s: 0x%02x %s", pfx, opt[OPT_CODE], buf);
|
bb_info_msg("%s: 0x%02x %s", pfx, opt[OPT_CODE], buf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
@ -274,16 +274,16 @@ struct option_set *udhcp_find_option(struct option_set *opt_list, uint8_t code)
|
|||||||
#if defined CONFIG_UDHCP_DEBUG && CONFIG_UDHCP_DEBUG >= 1
|
#if defined CONFIG_UDHCP_DEBUG && CONFIG_UDHCP_DEBUG >= 1
|
||||||
# define IF_UDHCP_VERBOSE(...) __VA_ARGS__
|
# define IF_UDHCP_VERBOSE(...) __VA_ARGS__
|
||||||
extern unsigned dhcp_verbose;
|
extern unsigned dhcp_verbose;
|
||||||
# define log1(...) do { if (dhcp_verbose >= 1) bb_error_msg(__VA_ARGS__); } while (0)
|
# define log1(...) do { if (dhcp_verbose >= 1) bb_info_msg(__VA_ARGS__); } while (0)
|
||||||
# if CONFIG_UDHCP_DEBUG >= 2
|
# if CONFIG_UDHCP_DEBUG >= 2
|
||||||
void udhcp_dump_packet(struct dhcp_packet *packet) FAST_FUNC;
|
void udhcp_dump_packet(struct dhcp_packet *packet) FAST_FUNC;
|
||||||
# define log2(...) do { if (dhcp_verbose >= 2) bb_error_msg(__VA_ARGS__); } while (0)
|
# define log2(...) do { if (dhcp_verbose >= 2) bb_info_msg(__VA_ARGS__); } while (0)
|
||||||
# else
|
# else
|
||||||
# define udhcp_dump_packet(...) ((void)0)
|
# define udhcp_dump_packet(...) ((void)0)
|
||||||
# define log2(...) ((void)0)
|
# define log2(...) ((void)0)
|
||||||
# endif
|
# endif
|
||||||
# if CONFIG_UDHCP_DEBUG >= 3
|
# if CONFIG_UDHCP_DEBUG >= 3
|
||||||
# define log3(...) do { if (dhcp_verbose >= 3) bb_error_msg(__VA_ARGS__); } while (0)
|
# define log3(...) do { if (dhcp_verbose >= 3) bb_info_msg(__VA_ARGS__); } while (0)
|
||||||
# else
|
# else
|
||||||
# define log3(...) ((void)0)
|
# define log3(...) ((void)0)
|
||||||
# endif
|
# endif
|
||||||
|
@ -670,7 +670,7 @@ static NOINLINE int send_d6_discover(uint32_t xid, struct in6_addr *requested_ip
|
|||||||
*/
|
*/
|
||||||
opt_ptr = add_d6_client_options(opt_ptr);
|
opt_ptr = add_d6_client_options(opt_ptr);
|
||||||
|
|
||||||
bb_error_msg("sending %s", "discover");
|
bb_info_msg("sending %s", "discover");
|
||||||
return d6_mcast_from_client_config_ifindex(&packet, opt_ptr);
|
return d6_mcast_from_client_config_ifindex(&packet, opt_ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -727,7 +727,7 @@ static NOINLINE int send_d6_select(uint32_t xid)
|
|||||||
*/
|
*/
|
||||||
opt_ptr = add_d6_client_options(opt_ptr);
|
opt_ptr = add_d6_client_options(opt_ptr);
|
||||||
|
|
||||||
bb_error_msg("sending %s", "select");
|
bb_info_msg("sending %s", "select");
|
||||||
return d6_mcast_from_client_config_ifindex(&packet, opt_ptr);
|
return d6_mcast_from_client_config_ifindex(&packet, opt_ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -800,7 +800,7 @@ static NOINLINE int send_d6_renew(uint32_t xid, struct in6_addr *server_ipv6, st
|
|||||||
*/
|
*/
|
||||||
opt_ptr = add_d6_client_options(opt_ptr);
|
opt_ptr = add_d6_client_options(opt_ptr);
|
||||||
|
|
||||||
bb_error_msg("sending %s", "renew");
|
bb_info_msg("sending %s", "renew");
|
||||||
if (server_ipv6)
|
if (server_ipv6)
|
||||||
return d6_send_kernel_packet(
|
return d6_send_kernel_packet(
|
||||||
&packet, (opt_ptr - (uint8_t*) &packet),
|
&packet, (opt_ptr - (uint8_t*) &packet),
|
||||||
@ -830,7 +830,7 @@ int send_d6_release(struct in6_addr *server_ipv6, struct in6_addr *our_cur_ipv6)
|
|||||||
if (client6_data.ia_pd)
|
if (client6_data.ia_pd)
|
||||||
opt_ptr = mempcpy(opt_ptr, client6_data.ia_pd, client6_data.ia_pd->len + 2+2);
|
opt_ptr = mempcpy(opt_ptr, client6_data.ia_pd, client6_data.ia_pd->len + 2+2);
|
||||||
|
|
||||||
bb_error_msg("sending %s", "release");
|
bb_info_msg("sending %s", "release");
|
||||||
return d6_send_kernel_packet(
|
return d6_send_kernel_packet(
|
||||||
&packet, (opt_ptr - (uint8_t*) &packet),
|
&packet, (opt_ptr - (uint8_t*) &packet),
|
||||||
our_cur_ipv6, CLIENT_PORT6,
|
our_cur_ipv6, CLIENT_PORT6,
|
||||||
@ -1033,7 +1033,7 @@ static void change_listen_mode(int new_mode)
|
|||||||
/* Called only on SIGUSR1 */
|
/* Called only on SIGUSR1 */
|
||||||
static void perform_renew(void)
|
static void perform_renew(void)
|
||||||
{
|
{
|
||||||
bb_error_msg("performing DHCP renew");
|
bb_info_msg("performing DHCP renew");
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case BOUND:
|
case BOUND:
|
||||||
change_listen_mode(LISTEN_KERNEL);
|
change_listen_mode(LISTEN_KERNEL);
|
||||||
@ -1061,10 +1061,10 @@ static void perform_d6_release(struct in6_addr *server_ipv6, struct in6_addr *ou
|
|||||||
|| state == REBINDING
|
|| state == REBINDING
|
||||||
|| state == RENEW_REQUESTED
|
|| state == RENEW_REQUESTED
|
||||||
) {
|
) {
|
||||||
bb_error_msg("unicasting a release");
|
bb_info_msg("unicasting a release");
|
||||||
send_d6_release(server_ipv6, our_cur_ipv6); /* unicast */
|
send_d6_release(server_ipv6, our_cur_ipv6); /* unicast */
|
||||||
}
|
}
|
||||||
bb_error_msg("entering released state");
|
bb_info_msg("entering released state");
|
||||||
/*
|
/*
|
||||||
* We can be here on: SIGUSR2,
|
* We can be here on: SIGUSR2,
|
||||||
* or on exit (SIGTERM) and -R "release on quit" is specified.
|
* or on exit (SIGTERM) and -R "release on quit" is specified.
|
||||||
@ -1274,7 +1274,7 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
/* Create pidfile */
|
/* Create pidfile */
|
||||||
write_pidfile(client_config.pidfile);
|
write_pidfile(client_config.pidfile);
|
||||||
/* Goes to stdout (unless NOMMU) and possibly syslog */
|
/* Goes to stdout (unless NOMMU) and possibly syslog */
|
||||||
bb_error_msg("started, v"BB_VER);
|
bb_info_msg("started, v"BB_VER);
|
||||||
/* Set up the signal pipe */
|
/* Set up the signal pipe */
|
||||||
udhcp_sp_setup();
|
udhcp_sp_setup();
|
||||||
|
|
||||||
@ -1363,7 +1363,7 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
d6_run_script_no_option("leasefail");
|
d6_run_script_no_option("leasefail");
|
||||||
#if BB_MMU /* -b is not supported on NOMMU */
|
#if BB_MMU /* -b is not supported on NOMMU */
|
||||||
if (opt & OPT_b) { /* background if no lease */
|
if (opt & OPT_b) { /* background if no lease */
|
||||||
bb_error_msg("no lease, forking to background");
|
bb_info_msg("no lease, forking to background");
|
||||||
client_background();
|
client_background();
|
||||||
/* do not background again! */
|
/* do not background again! */
|
||||||
opt = ((opt & ~(OPT_b|OPT_n)) | OPT_f);
|
opt = ((opt & ~(OPT_b|OPT_n)) | OPT_f);
|
||||||
@ -1376,7 +1376,7 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
if (opt & OPT_n) { /* abort if no lease */
|
if (opt & OPT_n) { /* abort if no lease */
|
||||||
bb_error_msg("no lease, failing");
|
bb_info_msg("no lease, failing");
|
||||||
retval = 1;
|
retval = 1;
|
||||||
goto ret;
|
goto ret;
|
||||||
}
|
}
|
||||||
@ -1439,7 +1439,7 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
/* Timed out, enter init state */
|
/* Timed out, enter init state */
|
||||||
bb_error_msg("lease lost, entering init state");
|
bb_info_msg("lease lost, entering init state");
|
||||||
d6_run_script_no_option("deconfig");
|
d6_run_script_no_option("deconfig");
|
||||||
state = INIT_SELECTING;
|
state = INIT_SELECTING;
|
||||||
client_config.first_secs = 0; /* make secs field count from 0 */
|
client_config.first_secs = 0; /* make secs field count from 0 */
|
||||||
@ -1484,7 +1484,7 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
timeout = INT_MAX;
|
timeout = INT_MAX;
|
||||||
continue;
|
continue;
|
||||||
case SIGTERM:
|
case SIGTERM:
|
||||||
bb_error_msg("received %s", "SIGTERM");
|
bb_info_msg("received %s", "SIGTERM");
|
||||||
goto ret0;
|
goto ret0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1544,7 +1544,7 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
option = d6_find_option(packet.d6_options, packet_end, D6_OPT_STATUS_CODE);
|
option = d6_find_option(packet.d6_options, packet_end, D6_OPT_STATUS_CODE);
|
||||||
if (option && (option->data[0] | option->data[1]) != 0) {
|
if (option && (option->data[0] | option->data[1]) != 0) {
|
||||||
/* return to init state */
|
/* return to init state */
|
||||||
bb_error_msg("received DHCP NAK (%u)", option->data[4]);
|
bb_info_msg("received DHCP NAK (%u)", option->data[4]);
|
||||||
d6_run_script(packet.d6_options,
|
d6_run_script(packet.d6_options,
|
||||||
packet_end, "nak");
|
packet_end, "nak");
|
||||||
if (state != REQUESTING)
|
if (state != REQUESTING)
|
||||||
@ -1561,7 +1561,7 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
}
|
}
|
||||||
option = d6_copy_option(packet.d6_options, packet_end, D6_OPT_SERVERID);
|
option = d6_copy_option(packet.d6_options, packet_end, D6_OPT_SERVERID);
|
||||||
if (!option) {
|
if (!option) {
|
||||||
bb_error_msg("no server ID, ignoring packet");
|
bb_info_msg("no server ID, ignoring packet");
|
||||||
continue;
|
continue;
|
||||||
/* still selecting - this server looks bad */
|
/* still selecting - this server looks bad */
|
||||||
}
|
}
|
||||||
@ -1670,11 +1670,11 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
free(client6_data.ia_na);
|
free(client6_data.ia_na);
|
||||||
client6_data.ia_na = d6_copy_option(packet.d6_options, packet_end, D6_OPT_IA_NA);
|
client6_data.ia_na = d6_copy_option(packet.d6_options, packet_end, D6_OPT_IA_NA);
|
||||||
if (!client6_data.ia_na) {
|
if (!client6_data.ia_na) {
|
||||||
bb_error_msg("no %s option, ignoring packet", "IA_NA");
|
bb_info_msg("no %s option, ignoring packet", "IA_NA");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (client6_data.ia_na->len < (4 + 4 + 4) + (2 + 2 + 16 + 4 + 4)) {
|
if (client6_data.ia_na->len < (4 + 4 + 4) + (2 + 2 + 16 + 4 + 4)) {
|
||||||
bb_error_msg("%s option is too short:%d bytes",
|
bb_info_msg("%s option is too short:%d bytes",
|
||||||
"IA_NA", client6_data.ia_na->len);
|
"IA_NA", client6_data.ia_na->len);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -1683,11 +1683,11 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
D6_OPT_IAADDR
|
D6_OPT_IAADDR
|
||||||
);
|
);
|
||||||
if (!iaaddr) {
|
if (!iaaddr) {
|
||||||
bb_error_msg("no %s option, ignoring packet", "IAADDR");
|
bb_info_msg("no %s option, ignoring packet", "IAADDR");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (iaaddr->len < (16 + 4 + 4)) {
|
if (iaaddr->len < (16 + 4 + 4)) {
|
||||||
bb_error_msg("%s option is too short:%d bytes",
|
bb_info_msg("%s option is too short:%d bytes",
|
||||||
"IAADDR", iaaddr->len);
|
"IAADDR", iaaddr->len);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -1698,7 +1698,7 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
move_from_unaligned32(lease_seconds, iaaddr->data + 16 + 4);
|
move_from_unaligned32(lease_seconds, iaaddr->data + 16 + 4);
|
||||||
lease_seconds = ntohl(lease_seconds);
|
lease_seconds = ntohl(lease_seconds);
|
||||||
/// TODO: check for 0 lease time?
|
/// TODO: check for 0 lease time?
|
||||||
bb_error_msg("%s obtained, lease time %u",
|
bb_info_msg("%s obtained, lease time %u",
|
||||||
"IPv6", /*inet_ntoa(temp_addr),*/ (unsigned)lease_seconds);
|
"IPv6", /*inet_ntoa(temp_addr),*/ (unsigned)lease_seconds);
|
||||||
address_timeout = lease_seconds;
|
address_timeout = lease_seconds;
|
||||||
}
|
}
|
||||||
@ -1708,11 +1708,11 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
free(client6_data.ia_pd);
|
free(client6_data.ia_pd);
|
||||||
client6_data.ia_pd = d6_copy_option(packet.d6_options, packet_end, D6_OPT_IA_PD);
|
client6_data.ia_pd = d6_copy_option(packet.d6_options, packet_end, D6_OPT_IA_PD);
|
||||||
if (!client6_data.ia_pd) {
|
if (!client6_data.ia_pd) {
|
||||||
bb_error_msg("no %s option, ignoring packet", "IA_PD");
|
bb_info_msg("no %s option, ignoring packet", "IA_PD");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (client6_data.ia_pd->len < (4 + 4 + 4) + (2 + 2 + 4 + 4 + 1 + 16)) {
|
if (client6_data.ia_pd->len < (4 + 4 + 4) + (2 + 2 + 4 + 4 + 1 + 16)) {
|
||||||
bb_error_msg("%s option is too short:%d bytes",
|
bb_info_msg("%s option is too short:%d bytes",
|
||||||
"IA_PD", client6_data.ia_pd->len);
|
"IA_PD", client6_data.ia_pd->len);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -1721,17 +1721,17 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
D6_OPT_IAPREFIX
|
D6_OPT_IAPREFIX
|
||||||
);
|
);
|
||||||
if (!iaprefix) {
|
if (!iaprefix) {
|
||||||
bb_error_msg("no %s option, ignoring packet", "IAPREFIX");
|
bb_info_msg("no %s option, ignoring packet", "IAPREFIX");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (iaprefix->len < (4 + 4 + 1 + 16)) {
|
if (iaprefix->len < (4 + 4 + 1 + 16)) {
|
||||||
bb_error_msg("%s option is too short:%d bytes",
|
bb_info_msg("%s option is too short:%d bytes",
|
||||||
"IAPREFIX", iaprefix->len);
|
"IAPREFIX", iaprefix->len);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
move_from_unaligned32(lease_seconds, iaprefix->data + 4);
|
move_from_unaligned32(lease_seconds, iaprefix->data + 4);
|
||||||
lease_seconds = ntohl(lease_seconds);
|
lease_seconds = ntohl(lease_seconds);
|
||||||
bb_error_msg("%s obtained, lease time %u",
|
bb_info_msg("%s obtained, lease time %u",
|
||||||
"prefix", /*inet_ntoa(temp_addr),*/ (unsigned)lease_seconds);
|
"prefix", /*inet_ntoa(temp_addr),*/ (unsigned)lease_seconds);
|
||||||
prefix_timeout = lease_seconds;
|
prefix_timeout = lease_seconds;
|
||||||
}
|
}
|
||||||
@ -1781,4 +1781,3 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
/*if (client_config.pidfile) - remove_pidfile has its own check */
|
/*if (client_config.pidfile) - remove_pidfile has its own check */
|
||||||
remove_pidfile(client_config.pidfile);
|
remove_pidfile(client_config.pidfile);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
|
||||||
|
@ -17,7 +17,7 @@ void FAST_FUNC d6_dump_packet(struct d6_packet *packet)
|
|||||||
if (dhcp_verbose < 2)
|
if (dhcp_verbose < 2)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
bb_error_msg(
|
bb_info_msg(
|
||||||
" xid %x"
|
" xid %x"
|
||||||
, packet->d6_xid32
|
, packet->d6_xid32
|
||||||
);
|
);
|
||||||
@ -40,7 +40,7 @@ int FAST_FUNC d6_recv_kernel_packet(struct in6_addr *peer_ipv6
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (bytes < offsetof(struct d6_packet, d6_options)) {
|
if (bytes < offsetof(struct d6_packet, d6_options)) {
|
||||||
bb_error_msg("packet with bad magic, ignoring");
|
bb_info_msg("packet with bad magic, ignoring");
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
log1("received %s", "a packet");
|
log1("received %s", "a packet");
|
||||||
|
@ -730,7 +730,7 @@ static NOINLINE int send_discover(uint32_t xid, uint32_t requested)
|
|||||||
*/
|
*/
|
||||||
add_client_options(&packet);
|
add_client_options(&packet);
|
||||||
|
|
||||||
bb_error_msg("sending %s", "discover");
|
bb_info_msg("sending %s", "discover");
|
||||||
return raw_bcast_from_client_config_ifindex(&packet, INADDR_ANY);
|
return raw_bcast_from_client_config_ifindex(&packet, INADDR_ANY);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -774,7 +774,7 @@ static NOINLINE int send_select(uint32_t xid, uint32_t server, uint32_t requeste
|
|||||||
add_client_options(&packet);
|
add_client_options(&packet);
|
||||||
|
|
||||||
temp_addr.s_addr = requested;
|
temp_addr.s_addr = requested;
|
||||||
bb_error_msg("sending select for %s", inet_ntoa(temp_addr));
|
bb_info_msg("sending select for %s", inet_ntoa(temp_addr));
|
||||||
return raw_bcast_from_client_config_ifindex(&packet, INADDR_ANY);
|
return raw_bcast_from_client_config_ifindex(&packet, INADDR_ANY);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -815,7 +815,7 @@ static NOINLINE int send_renew(uint32_t xid, uint32_t server, uint32_t ciaddr)
|
|||||||
add_client_options(&packet);
|
add_client_options(&packet);
|
||||||
|
|
||||||
temp_addr.s_addr = server;
|
temp_addr.s_addr = server;
|
||||||
bb_error_msg("sending renew to %s", inet_ntoa(temp_addr));
|
bb_info_msg("sending renew to %s", inet_ntoa(temp_addr));
|
||||||
return bcast_or_ucast(&packet, ciaddr, server);
|
return bcast_or_ucast(&packet, ciaddr, server);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -844,7 +844,7 @@ static NOINLINE int send_decline(/*uint32_t xid,*/ uint32_t server, uint32_t req
|
|||||||
|
|
||||||
udhcp_add_simple_option(&packet, DHCP_SERVER_ID, server);
|
udhcp_add_simple_option(&packet, DHCP_SERVER_ID, server);
|
||||||
|
|
||||||
bb_error_msg("sending %s", "decline");
|
bb_info_msg("sending %s", "decline");
|
||||||
return raw_bcast_from_client_config_ifindex(&packet, INADDR_ANY);
|
return raw_bcast_from_client_config_ifindex(&packet, INADDR_ANY);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -866,7 +866,7 @@ int send_release(uint32_t server, uint32_t ciaddr)
|
|||||||
|
|
||||||
udhcp_add_simple_option(&packet, DHCP_SERVER_ID, server);
|
udhcp_add_simple_option(&packet, DHCP_SERVER_ID, server);
|
||||||
|
|
||||||
bb_error_msg("sending %s", "release");
|
bb_info_msg("sending %s", "release");
|
||||||
/* Note: normally we unicast here since "server" is not zero.
|
/* Note: normally we unicast here since "server" is not zero.
|
||||||
* However, there _are_ people who run "address-less" DHCP servers,
|
* However, there _are_ people who run "address-less" DHCP servers,
|
||||||
* and reportedly ISC dhcp client and Windows allow that.
|
* and reportedly ISC dhcp client and Windows allow that.
|
||||||
@ -969,7 +969,7 @@ static NOINLINE int udhcp_recv_raw_packet(struct dhcp_packet *dhcp_pkt, int fd)
|
|||||||
skip_udp_sum_check:
|
skip_udp_sum_check:
|
||||||
|
|
||||||
if (packet.data.cookie != htonl(DHCP_MAGIC)) {
|
if (packet.data.cookie != htonl(DHCP_MAGIC)) {
|
||||||
bb_error_msg("packet with bad magic, ignoring");
|
bb_info_msg("packet with bad magic, ignoring");
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1117,7 +1117,7 @@ static void change_listen_mode(int new_mode)
|
|||||||
/* Called only on SIGUSR1 */
|
/* Called only on SIGUSR1 */
|
||||||
static void perform_renew(void)
|
static void perform_renew(void)
|
||||||
{
|
{
|
||||||
bb_error_msg("performing DHCP renew");
|
bb_info_msg("performing DHCP renew");
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case BOUND:
|
case BOUND:
|
||||||
change_listen_mode(LISTEN_KERNEL);
|
change_listen_mode(LISTEN_KERNEL);
|
||||||
@ -1151,11 +1151,11 @@ static void perform_release(uint32_t server_addr, uint32_t requested_ip)
|
|||||||
temp_addr.s_addr = server_addr;
|
temp_addr.s_addr = server_addr;
|
||||||
strcpy(buffer, inet_ntoa(temp_addr));
|
strcpy(buffer, inet_ntoa(temp_addr));
|
||||||
temp_addr.s_addr = requested_ip;
|
temp_addr.s_addr = requested_ip;
|
||||||
bb_error_msg("unicasting a release of %s to %s",
|
bb_info_msg("unicasting a release of %s to %s",
|
||||||
inet_ntoa(temp_addr), buffer);
|
inet_ntoa(temp_addr), buffer);
|
||||||
send_release(server_addr, requested_ip); /* unicast */
|
send_release(server_addr, requested_ip); /* unicast */
|
||||||
}
|
}
|
||||||
bb_error_msg("entering released state");
|
bb_info_msg("entering released state");
|
||||||
/*
|
/*
|
||||||
* We can be here on: SIGUSR2,
|
* We can be here on: SIGUSR2,
|
||||||
* or on exit (SIGTERM) and -R "release on quit" is specified.
|
* or on exit (SIGTERM) and -R "release on quit" is specified.
|
||||||
@ -1391,7 +1391,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
/* Create pidfile */
|
/* Create pidfile */
|
||||||
write_pidfile(client_config.pidfile);
|
write_pidfile(client_config.pidfile);
|
||||||
/* Goes to stdout (unless NOMMU) and possibly syslog */
|
/* Goes to stdout (unless NOMMU) and possibly syslog */
|
||||||
bb_error_msg("started, v"BB_VER);
|
bb_info_msg("started, v"BB_VER);
|
||||||
/* Set up the signal pipe */
|
/* Set up the signal pipe */
|
||||||
udhcp_sp_setup();
|
udhcp_sp_setup();
|
||||||
/* We want random_xid to be random... */
|
/* We want random_xid to be random... */
|
||||||
@ -1481,7 +1481,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
udhcp_run_script(NULL, "leasefail");
|
udhcp_run_script(NULL, "leasefail");
|
||||||
#if BB_MMU /* -b is not supported on NOMMU */
|
#if BB_MMU /* -b is not supported on NOMMU */
|
||||||
if (opt & OPT_b) { /* background if no lease */
|
if (opt & OPT_b) { /* background if no lease */
|
||||||
bb_error_msg("no lease, forking to background");
|
bb_info_msg("no lease, forking to background");
|
||||||
client_background();
|
client_background();
|
||||||
/* do not background again! */
|
/* do not background again! */
|
||||||
opt = ((opt & ~(OPT_b|OPT_n)) | OPT_f);
|
opt = ((opt & ~(OPT_b|OPT_n)) | OPT_f);
|
||||||
@ -1494,7 +1494,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
if (opt & OPT_n) { /* abort if no lease */
|
if (opt & OPT_n) { /* abort if no lease */
|
||||||
bb_error_msg("no lease, failing");
|
bb_info_msg("no lease, failing");
|
||||||
retval = 1;
|
retval = 1;
|
||||||
goto ret;
|
goto ret;
|
||||||
}
|
}
|
||||||
@ -1570,7 +1570,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
/* Timed out, enter init state */
|
/* Timed out, enter init state */
|
||||||
bb_error_msg("lease lost, entering init state");
|
bb_info_msg("lease lost, entering init state");
|
||||||
udhcp_run_script(NULL, "deconfig");
|
udhcp_run_script(NULL, "deconfig");
|
||||||
state = INIT_SELECTING;
|
state = INIT_SELECTING;
|
||||||
client_config.first_secs = 0; /* make secs field count from 0 */
|
client_config.first_secs = 0; /* make secs field count from 0 */
|
||||||
@ -1615,7 +1615,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
timeout = INT_MAX;
|
timeout = INT_MAX;
|
||||||
continue;
|
continue;
|
||||||
case SIGTERM:
|
case SIGTERM:
|
||||||
bb_error_msg("received %s", "SIGTERM");
|
bb_info_msg("received %s", "SIGTERM");
|
||||||
goto ret0;
|
goto ret0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1662,7 +1662,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
|
|
||||||
message = udhcp_get_option(&packet, DHCP_MESSAGE_TYPE);
|
message = udhcp_get_option(&packet, DHCP_MESSAGE_TYPE);
|
||||||
if (message == NULL) {
|
if (message == NULL) {
|
||||||
bb_error_msg("no message type option, ignoring packet");
|
bb_info_msg("no message type option, ignoring packet");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1691,7 +1691,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
* might work too.
|
* might work too.
|
||||||
* "Next server" and router are definitely wrong ones to use, though...
|
* "Next server" and router are definitely wrong ones to use, though...
|
||||||
*/
|
*/
|
||||||
/* We used to ignore pcakets without DHCP_SERVER_ID.
|
/* We used to ignore packets without DHCP_SERVER_ID.
|
||||||
* I've got user reports from people who run "address-less" servers.
|
* I've got user reports from people who run "address-less" servers.
|
||||||
* They either supply DHCP_SERVER_ID of 0.0.0.0 or don't supply it at all.
|
* They either supply DHCP_SERVER_ID of 0.0.0.0 or don't supply it at all.
|
||||||
* They say ISC DHCP client supports this case.
|
* They say ISC DHCP client supports this case.
|
||||||
@ -1699,7 +1699,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
server_addr = 0;
|
server_addr = 0;
|
||||||
temp = udhcp_get_option32(&packet, DHCP_SERVER_ID);
|
temp = udhcp_get_option32(&packet, DHCP_SERVER_ID);
|
||||||
if (!temp) {
|
if (!temp) {
|
||||||
bb_error_msg("no server ID, using 0.0.0.0");
|
bb_info_msg("no server ID, using 0.0.0.0");
|
||||||
} else {
|
} else {
|
||||||
/* it IS unaligned sometimes, don't "optimize" */
|
/* it IS unaligned sometimes, don't "optimize" */
|
||||||
move_from_unaligned32(server_addr, temp);
|
move_from_unaligned32(server_addr, temp);
|
||||||
@ -1726,7 +1726,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
|
|
||||||
temp = udhcp_get_option32(&packet, DHCP_LEASE_TIME);
|
temp = udhcp_get_option32(&packet, DHCP_LEASE_TIME);
|
||||||
if (!temp) {
|
if (!temp) {
|
||||||
bb_error_msg("no lease time with ACK, using 1 hour lease");
|
bb_info_msg("no lease time with ACK, using 1 hour lease");
|
||||||
lease_seconds = 60 * 60;
|
lease_seconds = 60 * 60;
|
||||||
} else {
|
} else {
|
||||||
/* it IS unaligned sometimes, don't "optimize" */
|
/* it IS unaligned sometimes, don't "optimize" */
|
||||||
@ -1759,7 +1759,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
client_config.interface,
|
client_config.interface,
|
||||||
arpping_ms)
|
arpping_ms)
|
||||||
) {
|
) {
|
||||||
bb_error_msg("offered address is in use "
|
bb_info_msg("offered address is in use "
|
||||||
"(got ARP reply), declining");
|
"(got ARP reply), declining");
|
||||||
send_decline(/*xid,*/ server_addr, packet.yiaddr);
|
send_decline(/*xid,*/ server_addr, packet.yiaddr);
|
||||||
|
|
||||||
@ -1778,7 +1778,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
#endif
|
#endif
|
||||||
/* enter bound state */
|
/* enter bound state */
|
||||||
temp_addr.s_addr = packet.yiaddr;
|
temp_addr.s_addr = packet.yiaddr;
|
||||||
bb_error_msg("lease of %s obtained, lease time %u",
|
bb_info_msg("lease of %s obtained, lease time %u",
|
||||||
inet_ntoa(temp_addr), (unsigned)lease_seconds);
|
inet_ntoa(temp_addr), (unsigned)lease_seconds);
|
||||||
requested_ip = packet.yiaddr;
|
requested_ip = packet.yiaddr;
|
||||||
|
|
||||||
@ -1831,7 +1831,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
goto non_matching_svid;
|
goto non_matching_svid;
|
||||||
}
|
}
|
||||||
/* return to init state */
|
/* return to init state */
|
||||||
bb_error_msg("received %s", "DHCP NAK");
|
bb_info_msg("received %s", "DHCP NAK");
|
||||||
udhcp_run_script(&packet, "nak");
|
udhcp_run_script(&packet, "nak");
|
||||||
if (state != REQUESTING)
|
if (state != REQUESTING)
|
||||||
udhcp_run_script(NULL, "deconfig");
|
udhcp_run_script(NULL, "deconfig");
|
||||||
|
@ -104,7 +104,7 @@ static void log_static_leases(struct static_lease **st_lease_pp)
|
|||||||
|
|
||||||
cur = *st_lease_pp;
|
cur = *st_lease_pp;
|
||||||
while (cur) {
|
while (cur) {
|
||||||
bb_error_msg("static lease: mac:%02x:%02x:%02x:%02x:%02x:%02x nip:%x",
|
bb_info_msg("static lease: mac:%02x:%02x:%02x:%02x:%02x:%02x nip:%x",
|
||||||
cur->mac[0], cur->mac[1], cur->mac[2],
|
cur->mac[0], cur->mac[1], cur->mac[2],
|
||||||
cur->mac[3], cur->mac[4], cur->mac[5],
|
cur->mac[3], cur->mac[4], cur->mac[5],
|
||||||
cur->nip
|
cur->nip
|
||||||
@ -242,7 +242,7 @@ static int nobody_responds_to_arp(uint32_t nip, const uint8_t *safe_mac, unsigne
|
|||||||
return r;
|
return r;
|
||||||
|
|
||||||
temp.s_addr = nip;
|
temp.s_addr = nip;
|
||||||
bb_error_msg("%s belongs to someone, reserving it for %u seconds",
|
bb_info_msg("%s belongs to someone, reserving it for %u seconds",
|
||||||
inet_ntoa(temp), (unsigned)server_config.conflict_time);
|
inet_ntoa(temp), (unsigned)server_config.conflict_time);
|
||||||
add_lease(NULL, nip, server_config.conflict_time, NULL, 0);
|
add_lease(NULL, nip, server_config.conflict_time, NULL, 0);
|
||||||
return 0;
|
return 0;
|
||||||
@ -722,7 +722,7 @@ static NOINLINE void send_offer(struct dhcp_packet *oldpacket,
|
|||||||
add_server_options(&packet);
|
add_server_options(&packet);
|
||||||
|
|
||||||
addr.s_addr = packet.yiaddr;
|
addr.s_addr = packet.yiaddr;
|
||||||
bb_error_msg("sending OFFER of %s", inet_ntoa(addr));
|
bb_info_msg("sending OFFER of %s", inet_ntoa(addr));
|
||||||
/* send_packet emits error message itself if it detects failure */
|
/* send_packet emits error message itself if it detects failure */
|
||||||
send_packet(&packet, /*force_bcast:*/ 0);
|
send_packet(&packet, /*force_bcast:*/ 0);
|
||||||
}
|
}
|
||||||
@ -755,7 +755,7 @@ static NOINLINE void send_ACK(struct dhcp_packet *oldpacket, uint32_t yiaddr)
|
|||||||
add_server_options(&packet);
|
add_server_options(&packet);
|
||||||
|
|
||||||
addr.s_addr = yiaddr;
|
addr.s_addr = yiaddr;
|
||||||
bb_error_msg("sending ACK to %s", inet_ntoa(addr));
|
bb_info_msg("sending ACK to %s", inet_ntoa(addr));
|
||||||
send_packet(&packet, /*force_bcast:*/ 0);
|
send_packet(&packet, /*force_bcast:*/ 0);
|
||||||
|
|
||||||
p_host_name = (const char*) udhcp_get_option(oldpacket, DHCP_HOST_NAME);
|
p_host_name = (const char*) udhcp_get_option(oldpacket, DHCP_HOST_NAME);
|
||||||
@ -865,7 +865,7 @@ int udhcpd_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
write_pidfile(server_config.pidfile);
|
write_pidfile(server_config.pidfile);
|
||||||
/* if (!..) bb_perror_msg("can't create pidfile %s", pidfile); */
|
/* if (!..) bb_perror_msg("can't create pidfile %s", pidfile); */
|
||||||
|
|
||||||
bb_error_msg("started, v"BB_VER);
|
bb_info_msg("started, v"BB_VER);
|
||||||
|
|
||||||
option = udhcp_find_option(server_config.options, DHCP_LEASE_TIME);
|
option = udhcp_find_option(server_config.options, DHCP_LEASE_TIME);
|
||||||
server_config.max_lease_sec = DEFAULT_LEASE_TIME;
|
server_config.max_lease_sec = DEFAULT_LEASE_TIME;
|
||||||
@ -944,12 +944,12 @@ int udhcpd_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
|
|
||||||
if (pfds[0].revents) switch (udhcp_sp_read()) {
|
if (pfds[0].revents) switch (udhcp_sp_read()) {
|
||||||
case SIGUSR1:
|
case SIGUSR1:
|
||||||
bb_error_msg("received %s", "SIGUSR1");
|
bb_info_msg("received %s", "SIGUSR1");
|
||||||
write_leases();
|
write_leases();
|
||||||
/* why not just reset the timeout, eh */
|
/* why not just reset the timeout, eh */
|
||||||
goto continue_with_autotime;
|
goto continue_with_autotime;
|
||||||
case SIGTERM:
|
case SIGTERM:
|
||||||
bb_error_msg("received %s", "SIGTERM");
|
bb_info_msg("received %s", "SIGTERM");
|
||||||
write_leases();
|
write_leases();
|
||||||
goto ret0;
|
goto ret0;
|
||||||
}
|
}
|
||||||
@ -973,16 +973,16 @@ int udhcpd_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (packet.hlen != 6) {
|
if (packet.hlen != 6) {
|
||||||
bb_error_msg("MAC length != 6, ignoring packet");
|
bb_info_msg("MAC length != 6, ignoring packet");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (packet.op != BOOTREQUEST) {
|
if (packet.op != BOOTREQUEST) {
|
||||||
bb_error_msg("not a REQUEST, ignoring packet");
|
bb_info_msg("not a REQUEST, ignoring packet");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
state = udhcp_get_option(&packet, DHCP_MESSAGE_TYPE);
|
state = udhcp_get_option(&packet, DHCP_MESSAGE_TYPE);
|
||||||
if (state == NULL || state[0] < DHCP_MINTYPE || state[0] > DHCP_MAXTYPE) {
|
if (state == NULL || state[0] < DHCP_MINTYPE || state[0] > DHCP_MAXTYPE) {
|
||||||
bb_error_msg("no or bad message type option, ignoring packet");
|
bb_info_msg("no or bad message type option, ignoring packet");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1001,7 +1001,7 @@ int udhcpd_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
/* Look for a static/dynamic lease */
|
/* Look for a static/dynamic lease */
|
||||||
static_lease_nip = get_static_nip_by_mac(server_config.static_leases, &packet.chaddr);
|
static_lease_nip = get_static_nip_by_mac(server_config.static_leases, &packet.chaddr);
|
||||||
if (static_lease_nip) {
|
if (static_lease_nip) {
|
||||||
bb_error_msg("found static lease: %x", static_lease_nip);
|
bb_info_msg("found static lease: %x", static_lease_nip);
|
||||||
memcpy(&fake_lease.lease_mac, &packet.chaddr, 6);
|
memcpy(&fake_lease.lease_mac, &packet.chaddr, 6);
|
||||||
fake_lease.lease_nip = static_lease_nip;
|
fake_lease.lease_nip = static_lease_nip;
|
||||||
fake_lease.expires = 0;
|
fake_lease.expires = 0;
|
||||||
|
@ -40,7 +40,7 @@ void FAST_FUNC udhcp_dump_packet(struct dhcp_packet *packet)
|
|||||||
if (dhcp_verbose < 2)
|
if (dhcp_verbose < 2)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
bb_error_msg(
|
bb_info_msg(
|
||||||
//" op %x"
|
//" op %x"
|
||||||
//" htype %x"
|
//" htype %x"
|
||||||
" hlen %x"
|
" hlen %x"
|
||||||
@ -73,7 +73,7 @@ void FAST_FUNC udhcp_dump_packet(struct dhcp_packet *packet)
|
|||||||
//, packet->options[]
|
//, packet->options[]
|
||||||
);
|
);
|
||||||
*bin2hex(buf, (void *) packet->chaddr, sizeof(packet->chaddr)) = '\0';
|
*bin2hex(buf, (void *) packet->chaddr, sizeof(packet->chaddr)) = '\0';
|
||||||
bb_error_msg(" chaddr %s", buf);
|
bb_info_msg(" chaddr %s", buf);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -92,7 +92,7 @@ int FAST_FUNC udhcp_recv_kernel_packet(struct dhcp_packet *packet, int fd)
|
|||||||
if (bytes < offsetof(struct dhcp_packet, options)
|
if (bytes < offsetof(struct dhcp_packet, options)
|
||||||
|| packet->cookie != htonl(DHCP_MAGIC)
|
|| packet->cookie != htonl(DHCP_MAGIC)
|
||||||
) {
|
) {
|
||||||
bb_error_msg("packet with bad magic, ignoring");
|
bb_info_msg("packet with bad magic, ignoring");
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
log1("received %s", "a packet");
|
log1("received %s", "a packet");
|
||||||
|
@ -195,7 +195,7 @@ static int run(char *argv[3], const char *param, uint32_t nip)
|
|||||||
putenv(env_ip);
|
putenv(env_ip);
|
||||||
fmt -= 3;
|
fmt -= 3;
|
||||||
}
|
}
|
||||||
bb_error_msg(fmt, argv[2], argv[0], addr);
|
bb_info_msg(fmt, argv[2], argv[0], addr);
|
||||||
status = spawn_and_wait(argv + 1);
|
status = spawn_and_wait(argv + 1);
|
||||||
if (nip != 0)
|
if (nip != 0)
|
||||||
bb_unsetenv_and_free(env_ip);
|
bb_unsetenv_and_free(env_ip);
|
||||||
@ -339,7 +339,7 @@ int zcip_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
#if BB_MMU
|
#if BB_MMU
|
||||||
bb_daemonize(0 /*was: DAEMON_CHDIR_ROOT*/);
|
bb_daemonize(0 /*was: DAEMON_CHDIR_ROOT*/);
|
||||||
#endif
|
#endif
|
||||||
bb_error_msg("start, interface %s", argv_intf);
|
bb_info_msg("start, interface %s", argv_intf);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run the dynamic address negotiation protocol,
|
// Run the dynamic address negotiation protocol,
|
||||||
|
Loading…
Reference in New Issue
Block a user