mirror of
https://github.com/sheumann/hush.git
synced 2024-09-12 15:54:56 +00:00
nameif: fix parsing of /proc/net/dev; small code shrink
function old new delta nameif_main 628 618 -10 Signed-off-by: Phil Sutter <phil.sutter@viprinet.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
bd74e3d8be
commit
2adc0e6d8b
@ -133,7 +133,7 @@ void delete_eth_table(ethtable_t *ch);
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
int nameif_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
int nameif_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||||
int nameif_main(int argc, char **argv)
|
int nameif_main(int argc UNUSED_PARAM, char **argv)
|
||||||
{
|
{
|
||||||
ethtable_t *clist = NULL;
|
ethtable_t *clist = NULL;
|
||||||
const char *fname = "/etc/mactab";
|
const char *fname = "/etc/mactab";
|
||||||
@ -148,17 +148,15 @@ int nameif_main(int argc, char **argv)
|
|||||||
* can't hurt. 2>/dev/null if you don't like it: */
|
* can't hurt. 2>/dev/null if you don't like it: */
|
||||||
logmode |= LOGMODE_SYSLOG;
|
logmode |= LOGMODE_SYSLOG;
|
||||||
}
|
}
|
||||||
argc -= optind;
|
|
||||||
argv += optind;
|
argv += optind;
|
||||||
|
|
||||||
if (argc & 1)
|
if (argv[0]) {
|
||||||
|
do {
|
||||||
|
if (!argv[1])
|
||||||
bb_show_usage();
|
bb_show_usage();
|
||||||
|
prepend_new_eth_table(&clist, argv[0], argv[1]);
|
||||||
if (argc) {
|
argv += 2;
|
||||||
while (*argv) {
|
} while (*argv);
|
||||||
char *ifname = *argv++;
|
|
||||||
prepend_new_eth_table(&clist, ifname, *argv++);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
parser = config_open(fname);
|
parser = config_open(fname);
|
||||||
while (config_read(parser, token, 2, 2, "# \t", PARSE_NORMAL))
|
while (config_read(parser, token, 2, 2, "# \t", PARSE_NORMAL))
|
||||||
@ -174,7 +172,7 @@ int nameif_main(int argc, char **argv)
|
|||||||
#if ENABLE_FEATURE_NAMEIF_EXTENDED
|
#if ENABLE_FEATURE_NAMEIF_EXTENDED
|
||||||
struct ethtool_drvinfo drvinfo;
|
struct ethtool_drvinfo drvinfo;
|
||||||
#endif
|
#endif
|
||||||
if (parser->lineno < 2)
|
if (parser->lineno <= 2)
|
||||||
continue; /* Skip the first two lines */
|
continue; /* Skip the first two lines */
|
||||||
|
|
||||||
/* Find the current interface name and copy it to ifr.ifr_name */
|
/* Find the current interface name and copy it to ifr.ifr_name */
|
||||||
|
Loading…
Reference in New Issue
Block a user