summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2023-04-23 12:37:46 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2023-04-23 12:37:46 +0200
commit7ddd233c807f71fc5a303e89ce166bc1cbccf89e (patch)
tree6a9657a856ccc97d0256280523783756034ef05e
parentd2b81b3dc2b31d32e1060d3ea8bd998d30a37d8a (diff)
downloadbusybox-7ddd233c807f71fc5a303e89ce166bc1cbccf89e.tar.gz
ip: code shrink
function old new delta ipaddr_list_or_flush 1089 1079 -10 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--networking/libiproute/ip_parse_common_args.c77
-rw-r--r--networking/libiproute/ipaddress.c10
2 files changed, 82 insertions, 5 deletions
diff --git a/networking/libiproute/ip_parse_common_args.c b/networking/libiproute/ip_parse_common_args.c
index d693c54fa..eccd7e670 100644
--- a/networking/libiproute/ip_parse_common_args.c
+++ b/networking/libiproute/ip_parse_common_args.c
@@ -14,6 +14,83 @@
#include "ip_common.h" /* #include "libbb.h" is inside */
#include "utils.h"
+/* iproute2-5.17.0:
+-V, -Version
+ Print the version of the ip utility and exit.
+-h, -human, -human-readable
+ output statistics with human readable values followed by suffix.
+-b, -batch FILENAME
+ Read commands from provided file or standard input and invoke them.
+ First failure will cause termination of ip.
+-force Don't terminate ip on errors in batch mode. If there were any errors
+ during execution of the commands, the application return code will be
+ non zero.
+-s, -stats, -statistics
+ Output more information. If the option appears twice or more,
+ the amount of information increases. As a rule, the information
+ is statistics or some time values.
+-d, -details
+ Output more detailed information.
+-l, -loops COUNT
+ Specify maximum number of loops the 'ip address flush' logic will
+ attempt before giving up. The default is 10. Zero (0) means loop
+ until all addresses are removed.
+-f, -family FAMILY
+ Specifies the protocol family to use. The protocol family identifier
+ can be one of inet, inet6, bridge, mpls or link. If this option is
+ not present, the protocol family is guessed from other arguments.
+ If the rest of the command line does not give enough information
+ to guess the family, ip falls back to the default one, usually inet
+ or any. link is a special family identifier meaning that
+ no networking protocol is involved.
+-4 shortcut for -family inet.
+-6 shortcut for -family inet6.
+-B shortcut for -family bridge.
+-M shortcut for -family mpls.
+-0 shortcut for -family link.
+-o, -oneline
+ output each record on a single line, replacing line feeds with the '\'
+ character. This is convenient when you want to count records with wc(1)
+ or to grep(1) the output.
+-r, -resolve
+ use the system's name resolver to print DNS names instead of addresses.
+-n, -netns NETNS
+ switches ip to the specified network namespace NETNS. Actually it just
+ simplifies executing of:
+ ip netns exec NETNS ip [ OPTIONS ] OBJECT { COMMAND | help }
+ to
+ ip -n[etns] NETNS [ OPTIONS ] OBJECT { COMMAND | help }
+-N, -Numeric
+ Print the number of protocol, scope, dsfield, etc directly instead of
+ converting it to human readable name.
+-a, -all
+ executes specified command over all objects, it depends if command
+ supports this option.
+-c[color][={always|auto|never}
+ Configure color output. If parameter is omitted or always, color output
+ is enabled regardless of stdout state. If parameter is auto, stdout is
+ checked to be a terminal before enabling color output. If parameter is
+ never, color output is disabled. If specified multiple times, the last
+ one takes precedence. This flag is ignored if -json is also given.
+ Used color palette can be influenced by COLORFGBG environment variable.
+-t, -timestamp
+ display current time when using monitor option.
+-ts, -tshort
+ Like -timestamp, but use shorter format.
+-rc, -rcvbuf SIZE
+ Set the netlink socket receive buffer size, defaults to 1MB.
+-iec print human readable rates in IEC units (e.g. 1Ki = 1024).
+-br, -brief
+ Print only basic information in a tabular format for better readability.
+ This option is currently only supported by ip addr show , ip link show
+ & ip neigh show commands.
+-j, -json
+ Output results in JavaScript Object Notation (JSON).
+-p, -pretty
+ The default JSON format is compact and more efficient to parse but hard
+ for most users to read. This flag adds indentation for readability.
+*/
+
family_t preferred_family = AF_UNSPEC;
smallint oneline;
char _SL_;
diff --git a/networking/libiproute/ipaddress.c b/networking/libiproute/ipaddress.c
index ecc3848ff..c8d77422c 100644
--- a/networking/libiproute/ipaddress.c
+++ b/networking/libiproute/ipaddress.c
@@ -44,7 +44,7 @@ struct filter_t {
int ifindex;
family_t family;
smallint showqueue;
- smallint oneline;
+ /*smallint oneline; - redundant, global "oneline" flag is enough */
smallint up;
/* Misnomer. Does not mean "flushed something" */
/* More like "flush commands were constructed by print_addrinfo()" */
@@ -297,7 +297,7 @@ static int FAST_FUNC print_addrinfo(const struct sockaddr_nl *who UNUSED_PARAM,
if (n->nlmsg_type == RTM_DELADDR)
printf("Deleted ");
- if (G_filter.oneline)
+ if (/*G_filter.*/ oneline)
printf("%u: %s", ifa->ifa_index, ll_index_to_name(ifa->ifa_index));
if (ifa->ifa_family == AF_INET)
printf(" inet ");
@@ -427,10 +427,10 @@ static int FAST_FUNC store_nlmsg(const struct sockaddr_nl *who, struct nlmsghdr
return 0;
}
-static void ipaddr_reset_filter(int _oneline)
+static void ipaddr_reset_filter(void /*int _oneline*/)
{
memset(&G_filter, 0, sizeof(G_filter));
- G_filter.oneline = _oneline;
+ /*G_filter.oneline = _oneline;*/
}
/* Return value becomes exitcode. It's okay to not return at all */
@@ -444,7 +444,7 @@ int FAST_FUNC ipaddr_list_or_flush(char **argv, int flush)
struct rtnl_handle rth;
char *filter_dev = NULL;
- ipaddr_reset_filter(oneline);
+ ipaddr_reset_filter(/*oneline*/);
G_filter.showqueue = 1;
if (G_filter.family == AF_UNSPEC)