diff --git a/ip/iplink.c b/ip/iplink.c index 369d50ea..edee0f7a 100644 --- a/ip/iplink.c +++ b/ip/iplink.c @@ -94,7 +94,7 @@ void iplink_usage(void) fprintf(stderr, "TYPE := { vlan | veth | vcan | dummy | ifb | macvlan | macvtap |\n"); fprintf(stderr, " bridge | bond | ipoib | ip6tnl | ipip | sit | vxlan |\n"); fprintf(stderr, " gre | gretap | ip6gre | ip6gretap | vti | nlmon |\n"); - fprintf(stderr, " bond_slave | ipvlan | geneve }\n"); + fprintf(stderr, " bond_slave | ipvlan | geneve | bridge_slave }\n"); } exit(-1); } @@ -508,7 +508,7 @@ int iplink_parse(int argc, char **argv, struct iplink_req *req, } else if (strcmp(*argv, "off") == 0) { req->i.ifi_flags |= IFF_NOARP; } else - return on_off("noarp", *argv); + return on_off("arp", *argv); } else if (strcmp(*argv, "vf") == 0) { struct rtattr *vflist; NEXT_ARG(); diff --git a/ip/iplink_bridge.c b/ip/iplink_bridge.c index 297160c4..1e699601 100644 --- a/ip/iplink_bridge.c +++ b/ip/iplink_bridge.c @@ -17,9 +17,9 @@ #include "utils.h" #include "ip_common.h" -static void explain(void) +static void print_explain(FILE *f) { - fprintf(stderr, + fprintf(f, "Usage: ... bridge [ forward_delay FORWARD_DELAY ]\n" " [ hello_time HELLO_TIME ]\n" " [ max_age MAX_AGE ]\n" @@ -29,6 +29,11 @@ static void explain(void) ); } +static void explain(void) +{ + print_explain(stderr); +} + static int bridge_parse_opt(struct link_util *lu, int argc, char **argv, struct nlmsghdr *n) { @@ -111,9 +116,16 @@ static void bridge_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[]) rta_getattr_u32(tb[IFLA_BR_MAX_AGE])); } +static void bridge_print_help(struct link_util *lu, int argc, char **argv, + FILE *f) +{ + print_explain(f); +} + struct link_util bridge_link_util = { .id = "bridge", .maxattr = IFLA_BR_MAX, .parse_opt = bridge_parse_opt, .print_opt = bridge_print_opt, + .print_help = bridge_print_help, }; diff --git a/ip/iplink_bridge_slave.c b/ip/iplink_bridge_slave.c index a2851855..4593872e 100644 --- a/ip/iplink_bridge_slave.c +++ b/ip/iplink_bridge_slave.c @@ -19,9 +19,9 @@ #include "utils.h" #include "ip_common.h" -static void explain(void) +static void print_explain(FILE *f) { - fprintf(stderr, + fprintf(f, "Usage: ... bridge_slave [ state STATE ] [ priority PRIO ] [cost COST ]\n" " [ guard {on | off} ]\n" " [ hairpin {on | off} ] \n" @@ -32,6 +32,11 @@ static void explain(void) ); } +static void explain(void) +{ + print_explain(stderr); +} + static const char *port_states[] = { [BR_STATE_DISABLED] = "disabled", [BR_STATE_LISTENING] = "listening", @@ -172,10 +177,17 @@ static int bridge_slave_parse_opt(struct link_util *lu, int argc, char **argv, return 0; } +static void bridge_slave_print_help(struct link_util *lu, int argc, char **argv, + FILE *f) +{ + print_explain(f); +} + struct link_util bridge_slave_link_util = { .id = "bridge", .maxattr = IFLA_BRPORT_MAX, .print_opt = bridge_slave_print_opt, .parse_opt = bridge_slave_parse_opt, + .print_help = bridge_slave_print_help, .slave = true, }; diff --git a/ip/ipnetns.c b/ip/ipnetns.c index 3b704a45..088096f6 100644 --- a/ip/ipnetns.c +++ b/ip/ipnetns.c @@ -139,7 +139,7 @@ struct nsid_cache { struct hlist_node nsid_hash; struct hlist_node name_hash; int nsid; - char name[NAME_MAX]; + char name[0]; }; #define NSIDMAP_SIZE 128 @@ -164,7 +164,7 @@ static struct nsid_cache *netns_map_get_by_nsid(int nsid) return NULL; } -static int netns_map_add(int nsid, char *name) +static int netns_map_add(int nsid, const char *name) { struct nsid_cache *c; uint32_t h; @@ -172,7 +172,7 @@ static int netns_map_add(int nsid, char *name) if (netns_map_get_by_nsid(nsid) != NULL) return -EEXIST; - c = malloc(sizeof(*c)); + c = malloc(sizeof(*c) + strlen(name)); if (c == NULL) { perror("malloc"); return -ENOMEM; diff --git a/man/man8/ip-link.8.in b/man/man8/ip-link.8.in index c123fcc0..1c312af6 100644 --- a/man/man8/ip-link.8.in +++ b/man/man8/ip-link.8.in @@ -889,7 +889,7 @@ output more statistics about packet usage. output more detailed information. .TP -.BR "\-h", " \-human", " \-human-readble" +.BR "\-h", " \-human", " \-human-readable" output statistics with human readable values number followed by suffix .TP