ip: iprule style cleanup

Trivial whitespace cleanup to iprule
This commit is contained in:
Stephen Hemminger 2016-10-09 19:29:24 -07:00
parent ca89c52143
commit e147161b1a
1 changed files with 22 additions and 15 deletions

View File

@ -40,19 +40,20 @@ static void usage(void) __attribute__((noreturn));
static void usage(void) static void usage(void)
{ {
fprintf(stderr, "Usage: ip rule { add | del } SELECTOR ACTION\n"); fprintf(stderr,
fprintf(stderr, " ip rule { flush | save | restore }\n"); "Usage: ip rule { add | del } SELECTOR ACTION\n"
fprintf(stderr, " ip rule [ list [ SELECTOR ]]\n"); " ip rule { flush | save | restore }\n"
fprintf(stderr, "SELECTOR := [ not ] [ from PREFIX ] [ to PREFIX ] [ tos TOS ] [ fwmark FWMARK[/MASK] ]\n"); " ip rule [ list [ SELECTOR ]]\n"
fprintf(stderr, " [ iif STRING ] [ oif STRING ] [ pref NUMBER ] [ l3mdev ]\n"); "SELECTOR := [ not ] [ from PREFIX ] [ to PREFIX ] [ tos TOS ] [ fwmark FWMARK[/MASK] ]\n"
fprintf(stderr, "ACTION := [ table TABLE_ID ]\n"); " [ iif STRING ] [ oif STRING ] [ pref NUMBER ] [ l3mdev ]\n"
fprintf(stderr, " [ nat ADDRESS ]\n"); "ACTION := [ table TABLE_ID ]\n"
fprintf(stderr, " [ realms [SRCREALM/]DSTREALM ]\n"); " [ nat ADDRESS ]\n"
fprintf(stderr, " [ goto NUMBER ]\n"); " [ realms [SRCREALM/]DSTREALM ]\n"
fprintf(stderr, " SUPPRESSOR\n"); " [ goto NUMBER ]\n"
fprintf(stderr, "SUPPRESSOR := [ suppress_prefixlength NUMBER ]\n"); " SUPPRESSOR\n"
fprintf(stderr, " [ suppress_ifgroup DEVGROUP ]\n"); "SUPPRESSOR := [ suppress_prefixlength NUMBER ]\n"
fprintf(stderr, "TABLE_ID := [ local | main | default | NUMBER ]\n"); " [ suppress_ifgroup DEVGROUP ]\n"
"TABLE_ID := [ local | main | default | NUMBER ]\n");
exit(-1); exit(-1);
} }
@ -114,6 +115,7 @@ static bool filter_nlmsg(struct nlmsghdr *n, struct rtattr **tb, int host_len)
if (filter.fwmark) { if (filter.fwmark) {
__u32 mark = 0; __u32 mark = 0;
if (tb[FRA_FWMARK]) if (tb[FRA_FWMARK])
mark = rta_getattr_u32(tb[FRA_FWMARK]); mark = rta_getattr_u32(tb[FRA_FWMARK]);
if (filter.fwmark ^ mark) if (filter.fwmark ^ mark)
@ -121,6 +123,7 @@ static bool filter_nlmsg(struct nlmsghdr *n, struct rtattr **tb, int host_len)
} }
if (filter.fwmask) { if (filter.fwmask) {
__u32 mask = 0; __u32 mask = 0;
if (tb[FRA_FWMASK]) if (tb[FRA_FWMASK])
mask = rta_getattr_u32(tb[FRA_FWMASK]); mask = rta_getattr_u32(tb[FRA_FWMASK]);
if (filter.fwmask ^ mask) if (filter.fwmask ^ mask)
@ -177,7 +180,7 @@ int print_rule(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
host_len = af_bit_len(r->rtm_family); host_len = af_bit_len(r->rtm_family);
if(!filter_nlmsg(n, tb, host_len)) if (!filter_nlmsg(n, tb, host_len))
return 0; return 0;
if (n->nlmsg_type == RTM_DELRULE) if (n->nlmsg_type == RTM_DELRULE)
@ -416,6 +419,7 @@ static int iprule_list_flush_or_save(int argc, char **argv, int action)
matches(*argv, "order") == 0 || matches(*argv, "order") == 0 ||
matches(*argv, "priority") == 0) { matches(*argv, "priority") == 0) {
__u32 pref; __u32 pref;
NEXT_ARG(); NEXT_ARG();
if (get_u32(&pref, *argv, 0)) if (get_u32(&pref, *argv, 0))
invarg("preference value is invalid\n", *argv); invarg("preference value is invalid\n", *argv);
@ -425,6 +429,7 @@ static int iprule_list_flush_or_save(int argc, char **argv, int action)
filter.not = 1; filter.not = 1;
} else if (strcmp(*argv, "tos") == 0) { } else if (strcmp(*argv, "tos") == 0) {
__u32 tos; __u32 tos;
NEXT_ARG(); NEXT_ARG();
if (rtnl_dsfield_a2n(&tos, *argv)) if (rtnl_dsfield_a2n(&tos, *argv))
invarg("TOS value is invalid\n", *argv); invarg("TOS value is invalid\n", *argv);
@ -433,6 +438,7 @@ static int iprule_list_flush_or_save(int argc, char **argv, int action)
} else if (strcmp(*argv, "fwmark") == 0) { } else if (strcmp(*argv, "fwmark") == 0) {
char *slash; char *slash;
__u32 fwmark, fwmask; __u32 fwmark, fwmask;
NEXT_ARG(); NEXT_ARG();
slash = strchr(*argv, '/'); slash = strchr(*argv, '/');
if (slash != NULL) if (slash != NULL)
@ -458,8 +464,9 @@ static int iprule_list_flush_or_save(int argc, char **argv, int action)
} else if (strcmp(*argv, "l3mdev") == 0) { } else if (strcmp(*argv, "l3mdev") == 0) {
filter.l3mdev = 1; filter.l3mdev = 1;
} else if (matches(*argv, "lookup") == 0 || } else if (matches(*argv, "lookup") == 0 ||
matches(*argv, "table") == 0 ) { matches(*argv, "table") == 0) {
__u32 tid; __u32 tid;
NEXT_ARG(); NEXT_ARG();
if (rtnl_rttable_a2n(&tid, *argv)) if (rtnl_rttable_a2n(&tid, *argv))
invarg("table id value is invalid\n", *argv); invarg("table id value is invalid\n", *argv);