From 7c503d88d29e8ce87c4a67f82c0c0c2d7f9eef03 Mon Sep 17 00:00:00 2001 From: Damien Robert Date: Mon, 30 Sep 2019 23:11:37 +0200 Subject: [PATCH 1/9] man: add reference to `ip route add encap ... src` The ability to specify the source adresse for 'encap ip' / 'encap ip6' was added in commit 94a8722f2f78f04c47678cf864ac234a38366709 but the man page was not updated. Also fixes a missing page in ip-route.8.in. Signed-off-by: Damien Robert Signed-off-by: Stephen Hemminger --- man/man8/ip-route.8.in | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/man/man8/ip-route.8.in b/man/man8/ip-route.8.in index a61b263e..34763cc3 100644 --- a/man/man8/ip-route.8.in +++ b/man/man8/ip-route.8.in @@ -206,6 +206,8 @@ throw " | " unreachable " | " prohibit " | " blackhole " | " nat " ]" .IR TUNNEL_ID .B dst .IR REMOTE_IP " [ " +.B src +.IR SRC " ] [" .B tos .IR TOS " ] [" .B ttl @@ -740,11 +742,13 @@ is a set of encapsulation attributes specific to the .I TUNNEL_ID .B dst .IR REMOTE_IP " [ " +.B src +.IR SRC " ] [" .B tos .IR TOS " ] [" .B ttl .IR TTL " ] [ " -.BR key " ] [" csum " ] [ " seq " ] " +.BR key " ] [ " csum " ] [ " seq " ] " .in -2 .sp From e047ca988f1858a6b91bda837b45a7c783a33295 Mon Sep 17 00:00:00 2001 From: Andrea Claudi Date: Tue, 1 Oct 2019 12:32:17 +0200 Subject: [PATCH 2/9] tc: fix segmentation fault on gact action tc segfaults if gact action is used without action or index: $ ip link add type dummy $ tc actions add action pipe index 1 $ tc filter add dev dummy0 parent ffff: protocol ip \ pref 10 u32 match ip src 127.0.0.2 flowid 1:10 action gact Segmentation fault We expect tc to fail gracefully with an error message. This happens if gact is the last argument of the incomplete command. In this case the "gact" action is parsed, the macro NEXT_ARG_FWD() is executed and the next matches() crashes because of null argv pointer. To avoid this, simply use NEXT_ARG() instead. With this change in place: $ ip link add type dummy $ tc actions add action pipe index 1 $ tc filter add dev dummy0 parent ffff: protocol ip \ pref 10 u32 match ip src 127.0.0.2 flowid 1:10 action gact Command line is not complete. Try option "help" Fixes: fa4958897314 ("tc: Fix binding of gact action by index.") Reported-by: Davide Caratti Signed-off-by: Andrea Claudi Signed-off-by: Stephen Hemminger --- tc/m_gact.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tc/m_gact.c b/tc/m_gact.c index dca2a2f9..b06e8ee9 100644 --- a/tc/m_gact.c +++ b/tc/m_gact.c @@ -87,7 +87,7 @@ parse_gact(struct action_util *a, int *argc_p, char ***argv_p, return -1; if (!matches(*argv, "gact")) - NEXT_ARG_FWD(); + NEXT_ARG(); /* we're binding existing gact action to filter by index. */ if (!matches(*argv, "index")) goto skip_args; From 56b725a442ccd128077755ab2a97d06909bd1227 Mon Sep 17 00:00:00 2001 From: Aya Levin Date: Wed, 2 Oct 2019 17:35:14 +0300 Subject: [PATCH 3/9] devlink: Add helper for left justification print Introduce a helper function which wraps code that adds a left hand side space separator unless it follows a newline. Fixes: e3d0f0c0e3d8 ("devlink: add option to generate JSON output") Signed-off-by: Aya Levin Acked-by: Jiri Pirko Signed-off-by: Tariq Toukan Signed-off-by: Stephen Hemminger --- devlink/devlink.c | 45 ++++++++++++++++++++------------------------- 1 file changed, 20 insertions(+), 25 deletions(-) diff --git a/devlink/devlink.c b/devlink/devlink.c index 5e762e37..d654dc7b 100644 --- a/devlink/devlink.c +++ b/devlink/devlink.c @@ -379,6 +379,12 @@ static bool dl_no_arg(struct dl *dl) return dl_argc(dl) == 0; } +static void __pr_out_indent_newline(struct dl *dl) +{ + if (!g_indent_newline && !dl->json_output) + pr_out(" "); +} + static const enum mnl_attr_data_type devlink_policy[DEVLINK_ATTR_MAX + 1] = { [DEVLINK_ATTR_BUS_NAME] = MNL_TYPE_NUL_STRING, [DEVLINK_ATTR_DEV_NAME] = MNL_TYPE_NUL_STRING, @@ -1828,14 +1834,11 @@ static void pr_out_port_handle_end(struct dl *dl) static void pr_out_str(struct dl *dl, const char *name, const char *val) { - if (dl->json_output) { + __pr_out_indent_newline(dl); + if (dl->json_output) jsonw_string_field(dl->jw, name, val); - } else { - if (g_indent_newline) - pr_out("%s %s", name, val); - else - pr_out(" %s %s", name, val); - } + else + pr_out("%s %s", name, val); } static void pr_out_bool(struct dl *dl, const char *name, bool val) @@ -1848,29 +1851,23 @@ static void pr_out_bool(struct dl *dl, const char *name, bool val) static void pr_out_uint(struct dl *dl, const char *name, unsigned int val) { - if (dl->json_output) { + __pr_out_indent_newline(dl); + if (dl->json_output) jsonw_uint_field(dl->jw, name, val); - } else { - if (g_indent_newline) - pr_out("%s %u", name, val); - else - pr_out(" %s %u", name, val); - } + else + pr_out("%s %u", name, val); } static void pr_out_u64(struct dl *dl, const char *name, uint64_t val) { + __pr_out_indent_newline(dl); if (val == (uint64_t) -1) return pr_out_str(dl, name, "unlimited"); - if (dl->json_output) { + if (dl->json_output) jsonw_u64_field(dl->jw, name, val); - } else { - if (g_indent_newline) - pr_out("%s %"PRIu64, name, val); - else - pr_out(" %s %"PRIu64, name, val); - } + else + pr_out("%s %"PRIu64, name, val); } static void pr_out_bool_value(struct dl *dl, bool value) @@ -6118,14 +6115,12 @@ static void pr_out_region_handle_end(struct dl *dl) static void pr_out_region_snapshots_start(struct dl *dl, bool array) { + __pr_out_indent_newline(dl); if (dl->json_output) { jsonw_name(dl->jw, "snapshot"); jsonw_start_array(dl->jw); } else { - if (g_indent_newline) - pr_out("snapshot %s", array ? "[" : ""); - else - pr_out(" snapshot %s", array ? "[" : ""); + pr_out("snapshot %s", array ? "[" : ""); } } From 7dd3d51b9137e51c667c9c05df3ec3e5009ca157 Mon Sep 17 00:00:00 2001 From: Aya Levin Date: Wed, 2 Oct 2019 17:35:15 +0300 Subject: [PATCH 4/9] devlink: Left justification on FMSG output FMSG output is dynamic, space separator must be on the left hand side of the value. Otherwise output has redundant left indentation regardless the hierarchy. Before the patch: Common config: SQ: stride size: 64 size: 1024 CQ: stride size: 64 size: 1024 SQs: channel ix: 0 tc: 0 txq ix: 0 sqn: 10 HW state: 1 stopped: false cc: 0 pc: 0 CQ: cqn: 6 HW status: 0 channel ix: 1 tc: 0 txq ix: 1 sqn: 14 HW state: 1 stopped: false cc: 0 pc: 0 CQ: cqn: 10 HW status: 0 channel ix: 2 tc: 0 txq ix: 2 sqn: 18 HW state: 1 stopped: false cc: 5 pc: 5 CQ: cqn: 14 HW status: 0 channel ix: 3 tc: 0 txq ix: 3 sqn: 22 HW state: 1 stopped: false cc: 0 pc: 0 CQ: cqn: 18 HW status: 0 With the patch: Common config: SQ: stride size: 64 size: 1024 CQ: stride size: 64 size: 1024 SQs: channel ix: 0 tc: 0 txq ix: 0 sqn: 10 HW state: 1 stopped: false cc: 0 pc: 0 CQ: cqn: 6 HW status: 0 channel ix: 1 tc: 0 txq ix: 1 sqn: 14 HW state: 1 stopped: false cc: 0 pc: 0 CQ: cqn: 10 HW status: 0 channel ix: 2 tc: 0 txq ix: 2 sqn: 18 HW state: 1 stopped: false cc: 5 pc: 5 CQ: cqn: 14 HW status: 0 channel ix: 3 tc: 0 txq ix: 3 sqn: 22 HW state: 1 stopped: false cc: 0 pc: 0 CQ: cqn: 18 HW status: 0 Fixes: 844a61764c6f ("devlink: Add helper functions for name and value separately") Signed-off-by: Aya Levin Acked-by: Jiri Pirko Signed-off-by: Tariq Toukan Signed-off-by: Stephen Hemminger --- devlink/devlink.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/devlink/devlink.c b/devlink/devlink.c index d654dc7b..50baf82a 100644 --- a/devlink/devlink.c +++ b/devlink/devlink.c @@ -1872,26 +1872,29 @@ static void pr_out_u64(struct dl *dl, const char *name, uint64_t val) static void pr_out_bool_value(struct dl *dl, bool value) { + __pr_out_indent_newline(dl); if (dl->json_output) jsonw_bool(dl->jw, value); else - pr_out(" %s", value ? "true" : "false"); + pr_out("%s", value ? "true" : "false"); } static void pr_out_uint_value(struct dl *dl, unsigned int value) { + __pr_out_indent_newline(dl); if (dl->json_output) jsonw_uint(dl->jw, value); else - pr_out(" %u", value); + pr_out("%u", value); } static void pr_out_uint64_value(struct dl *dl, uint64_t value) { + __pr_out_indent_newline(dl); if (dl->json_output) jsonw_u64(dl->jw, value); else - pr_out(" %"PRIu64, value); + pr_out("%"PRIu64, value); } static bool is_binary_eol(int i) @@ -1918,18 +1921,20 @@ static void pr_out_binary_value(struct dl *dl, uint8_t *data, uint32_t len) static void pr_out_str_value(struct dl *dl, const char *value) { + __pr_out_indent_newline(dl); if (dl->json_output) jsonw_string(dl->jw, value); else - pr_out(" %s", value); + pr_out("%s", value); } static void pr_out_name(struct dl *dl, const char *name) { + __pr_out_indent_newline(dl); if (dl->json_output) jsonw_name(dl->jw, name); else - pr_out(" %s:", name); + pr_out("%s:", name); } static void pr_out_region_chunk_start(struct dl *dl, uint64_t addr) From 94ff4d68822492a93141f79f5e7015a0a4e9056f Mon Sep 17 00:00:00 2001 From: Aya Levin Date: Wed, 2 Oct 2019 17:35:16 +0300 Subject: [PATCH 5/9] devlink: Fix inconsistency between command input and output In devlink health show command the reporter's name parameter is called reporter, but in the output the reporter's name is referred to as name Before this patch: $ devlink health show pci/0000:04:00.0 reporter tx pci/0000:04:00.0: name tx state healthy error 0 recover 0 grace_period 500 auto_recover true After this patch: $ devlink health show pci/0000:04:00.0 reporter tx pci/0000:04:00.0: reporter tx state healthy error 0 recover 0 grace_period 500 auto_recover true Reported-by: Jiri Pirko Fixes: 2f1242efe9d0 ("devlink: Add devlink health show command") Signed-off-by: Aya Levin Acked-by: Jiri Pirko Signed-off-by: Tariq Toukan Signed-off-by: Stephen Hemminger --- devlink/devlink.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/devlink/devlink.c b/devlink/devlink.c index 50baf82a..5bbe0bdd 100644 --- a/devlink/devlink.c +++ b/devlink/devlink.c @@ -6660,7 +6660,7 @@ static void pr_out_health(struct dl *dl, struct nlattr **tb_health) pr_out_handle_start_arr(dl, tb_health); - pr_out_str(dl, "name", + pr_out_str(dl, "reporter", mnl_attr_get_str(tb[DEVLINK_ATTR_HEALTH_REPORTER_NAME])); if (!dl->json_output) { __pr_out_newline(); From eaefb07804a11d3542e61b6bde38ed0b95b28405 Mon Sep 17 00:00:00 2001 From: Nicolas Dichtel Date: Mon, 7 Oct 2019 15:44:47 +0200 Subject: [PATCH 6/9] ipnetns: enable to dump nsid conversion table This patch enables to dump/get nsid from a netns into another netns. Example: $ ./test.sh + ip netns add foo + ip netns add bar + touch /var/run/netns/init_net + mount --bind /proc/1/ns/net /var/run/netns/init_net + ip netns set init_net 11 + ip netns set foo 12 + ip netns set bar 13 + ip netns init_net (id: 11) bar (id: 13) foo (id: 12) + ip -n foo netns set init_net 21 + ip -n foo netns set foo 22 + ip -n foo netns set bar 23 + ip -n foo netns init_net (id: 21) bar (id: 23) foo (id: 22) + ip -n bar netns set init_net 31 + ip -n bar netns set foo 32 + ip -n bar netns set bar 33 + ip -n bar netns init_net (id: 31) bar (id: 33) foo (id: 32) + ip netns list-id target-nsid 12 nsid 21 current-nsid 11 (iproute2 netns name: init_net) nsid 22 current-nsid 12 (iproute2 netns name: foo) nsid 23 current-nsid 13 (iproute2 netns name: bar) + ip -n foo netns list-id target-nsid 21 nsid 11 current-nsid 21 (iproute2 netns name: init_net) nsid 12 current-nsid 22 (iproute2 netns name: foo) nsid 13 current-nsid 23 (iproute2 netns name: bar) + ip -n bar netns list-id target-nsid 33 nsid 32 nsid 32 current-nsid 32 (iproute2 netns name: foo) + ip -n bar netns list-id target-nsid 31 nsid 32 nsid 12 current-nsid 32 (iproute2 netns name: foo) + ip netns list-id nsid 13 nsid 13 (iproute2 netns name: bar) CC: Petr Oros Signed-off-by: Nicolas Dichtel Tested-by: Petr Oros Signed-off-by: Stephen Hemminger --- include/libnetlink.h | 5 +- ip/ip_common.h | 1 + ip/ipnetns.c | 115 +++++++++++++++++++++++++++++++++++++++++-- lib/libnetlink.c | 15 ++++-- 4 files changed, 126 insertions(+), 10 deletions(-) diff --git a/include/libnetlink.h b/include/libnetlink.h index 311cf3fc..8ebdc6d3 100644 --- a/include/libnetlink.h +++ b/include/libnetlink.h @@ -71,8 +71,6 @@ int rtnl_mdbdump_req(struct rtnl_handle *rth, int family) __attribute__((warn_unused_result)); int rtnl_netconfdump_req(struct rtnl_handle *rth, int family) __attribute__((warn_unused_result)); -int rtnl_nsiddump_req(struct rtnl_handle *rth, int family) - __attribute__((warn_unused_result)); int rtnl_linkdump_req(struct rtnl_handle *rth, int fam) __attribute__((warn_unused_result)); @@ -85,6 +83,9 @@ int rtnl_linkdump_req_filter_fn(struct rtnl_handle *rth, int fam, int rtnl_fdb_linkdump_req_filter_fn(struct rtnl_handle *rth, req_filter_fn_t filter_fn) __attribute__((warn_unused_result)); +int rtnl_nsiddump_req_filter_fn(struct rtnl_handle *rth, int family, + req_filter_fn_t filter_fn) + __attribute__((warn_unused_result)); int rtnl_statsdump_req_filter(struct rtnl_handle *rth, int fam, __u32 filt_mask) __attribute__((warn_unused_result)); int rtnl_dump_request(struct rtnl_handle *rth, int type, void *req, diff --git a/ip/ip_common.h b/ip/ip_common.h index cd916ec8..879287e3 100644 --- a/ip/ip_common.h +++ b/ip/ip_common.h @@ -24,6 +24,7 @@ struct link_filter { int master; char *kind; char *slave_kind; + int target_nsid; }; int get_operstate(const char *name); diff --git a/ip/ipnetns.c b/ip/ipnetns.c index a883f210..20110ef0 100644 --- a/ip/ipnetns.c +++ b/ip/ipnetns.c @@ -36,7 +36,7 @@ static int usage(void) " ip netns pids NAME\n" " ip [-all] netns exec [NAME] cmd ...\n" " ip netns monitor\n" - " ip netns list-id\n" + " ip netns list-id [target-nsid POSITIVE-INT] [nsid POSITIVE-INT]\n" "NETNSID := auto | POSITIVE-INT\n"); exit(-1); } @@ -46,6 +46,7 @@ static struct rtnl_handle rtnsh = { .fd = -1 }; static int have_rtnl_getnsid = -1; static int saved_netns = -1; +static struct link_filter filter; static int ipnetns_accept_msg(struct rtnl_ctrl_data *ctrl, struct nlmsghdr *n, void *arg) @@ -294,7 +295,7 @@ int print_nsid(struct nlmsghdr *n, void *arg) FILE *fp = (FILE *)arg; struct nsid_cache *c; char name[NAME_MAX]; - int nsid; + int nsid, current; if (n->nlmsg_type != RTM_NEWNSID && n->nlmsg_type != RTM_DELNSID) return 0; @@ -317,9 +318,22 @@ int print_nsid(struct nlmsghdr *n, void *arg) print_bool(PRINT_ANY, "deleted", "Deleted ", true); nsid = rta_getattr_u32(tb[NETNSA_NSID]); - print_uint(PRINT_ANY, "nsid", "nsid %u ", nsid); + if (nsid < 0) + print_string(PRINT_ANY, "nsid", "nsid %s ", "not-assigned"); + else + print_uint(PRINT_ANY, "nsid", "nsid %u ", nsid); - c = netns_map_get_by_nsid(nsid); + if (tb[NETNSA_CURRENT_NSID]) { + current = rta_getattr_u32(tb[NETNSA_CURRENT_NSID]); + if (current < 0) + print_string(PRINT_ANY, "current-nsid", + "current-nsid %s ", "not-assigned"); + else + print_uint(PRINT_ANY, "current-nsid", + "current-nsid %u ", current); + } + + c = netns_map_get_by_nsid(tb[NETNSA_CURRENT_NSID] ? current : nsid); if (c != NULL) { print_string(PRINT_ANY, "name", "(iproute2 netns name: %s)", c->name); @@ -340,15 +354,106 @@ int print_nsid(struct nlmsghdr *n, void *arg) return 0; } +static int get_netnsid_from_netnsid(int nsid) +{ + struct { + struct nlmsghdr n; + struct rtgenmsg g; + char buf[1024]; + } req = { + .n.nlmsg_len = NLMSG_LENGTH(NLMSG_ALIGN(sizeof(struct rtgenmsg))), + .n.nlmsg_flags = NLM_F_REQUEST, + .n.nlmsg_type = RTM_GETNSID, + .g.rtgen_family = AF_UNSPEC, + }; + struct nlmsghdr *answer; + int err; + + netns_nsid_socket_init(); + + err = addattr32(&req.n, sizeof(req), NETNSA_NSID, nsid); + if (err) + return err; + + if (filter.target_nsid >= 0) { + err = addattr32(&req.n, sizeof(req), NETNSA_TARGET_NSID, + filter.target_nsid); + if (err) + return err; + } + + if (rtnl_talk(&rtnsh, &req.n, &answer) < 0) + return -2; + + /* Validate message and parse attributes */ + if (answer->nlmsg_type == NLMSG_ERROR) + goto err_out; + + new_json_obj(json); + err = print_nsid(answer, stdout); + delete_json_obj(); +err_out: + free(answer); + return err; +} + +static int netns_filter_req(struct nlmsghdr *nlh, int reqlen) +{ + int err; + + if (filter.target_nsid >= 0) { + err = addattr32(nlh, reqlen, NETNSA_TARGET_NSID, + filter.target_nsid); + if (err) + return err; + } + + return 0; +} + static int netns_list_id(int argc, char **argv) { + int nsid = -1; + if (!ipnetns_have_nsid()) { fprintf(stderr, "RTM_GETNSID is not supported by the kernel.\n"); return -ENOTSUP; } - if (rtnl_nsiddump_req(&rth, AF_UNSPEC) < 0) { + filter.target_nsid = -1; + while (argc > 0) { + if (strcmp(*argv, "target-nsid") == 0) { + if (filter.target_nsid >= 0) + duparg("target-nsid", *argv); + NEXT_ARG(); + + if (get_integer(&filter.target_nsid, *argv, 0)) + invarg("\"target-nsid\" value is invalid\n", + *argv); + else if (filter.target_nsid < 0) + invarg("\"target-nsid\" value should be >= 0\n", + argv[1]); + } else if (strcmp(*argv, "nsid") == 0) { + if (nsid >= 0) + duparg("nsid", *argv); + NEXT_ARG(); + + if (get_integer(&nsid, *argv, 0)) + invarg("\"nsid\" value is invalid\n", *argv); + else if (nsid < 0) + invarg("\"nsid\" value should be >= 0\n", + argv[1]); + } else + usage(); + argc--; argv++; + } + + if (nsid >= 0) + return get_netnsid_from_netnsid(nsid); + + if (rtnl_nsiddump_req_filter_fn(&rth, AF_UNSPEC, + netns_filter_req) < 0) { perror("Cannot send dump request"); exit(1); } diff --git a/lib/libnetlink.c b/lib/libnetlink.c index 8c490f89..6ce8b199 100644 --- a/lib/libnetlink.c +++ b/lib/libnetlink.c @@ -438,12 +438,13 @@ int rtnl_netconfdump_req(struct rtnl_handle *rth, int family) return send(rth->fd, &req, sizeof(req), 0); } -int rtnl_nsiddump_req(struct rtnl_handle *rth, int family) +int rtnl_nsiddump_req_filter_fn(struct rtnl_handle *rth, int family, + req_filter_fn_t filter_fn) { struct { struct nlmsghdr nlh; struct rtgenmsg rtm; - char buf[0] __aligned(NLMSG_ALIGNTO); + char buf[1024]; } req = { .nlh.nlmsg_len = NLMSG_LENGTH(NLMSG_ALIGN(sizeof(struct rtgenmsg))), .nlh.nlmsg_type = RTM_GETNSID, @@ -451,8 +452,16 @@ int rtnl_nsiddump_req(struct rtnl_handle *rth, int family) .nlh.nlmsg_seq = rth->dump = ++rth->seq, .rtm.rtgen_family = family, }; + int err; - return send(rth->fd, &req, sizeof(req), 0); + if (!filter_fn) + return -EINVAL; + + err = filter_fn(&req.nlh, sizeof(req)); + if (err) + return err; + + return send(rth->fd, &req, req.nlh.nlmsg_len, 0); } static int __rtnl_linkdump_req(struct rtnl_handle *rth, int family) From 10d39984b76c532a3dbfad087df2488954d2ad30 Mon Sep 17 00:00:00 2001 From: Florent Fourcot Date: Tue, 15 Oct 2019 17:35:50 +0200 Subject: [PATCH 7/9] man: remove "defaut group" sentence on ip link By default, all devices are listed, not only the default group. Signed-off-by: Florent Fourcot Signed-off-by: Romain Bellan Signed-off-by: Stephen Hemminger --- man/man8/ip-link.8.in | 1 - 1 file changed, 1 deletion(-) diff --git a/man/man8/ip-link.8.in b/man/man8/ip-link.8.in index a8ae72d2..31051c52 100644 --- a/man/man8/ip-link.8.in +++ b/man/man8/ip-link.8.in @@ -2364,7 +2364,6 @@ Commands: .BI dev " NAME " (default) .I NAME specifies the network device to show. -If this argument is omitted all devices in the default group are listed. .TP .BI group " GROUP " From 63ab204e7bd9764b9f1021cb21982b9d0b7e8b99 Mon Sep 17 00:00:00 2001 From: Nicolas Dichtel Date: Wed, 16 Oct 2019 17:00:51 +0200 Subject: [PATCH 8/9] ip-netns.8: document the 'auto' keyword of 'ip netns set' This is a follow up of the commit ebe3ce2fcc5f ("ipnetns: parse nsid as a signed integer"). Signed-off-by: Nicolas Dichtel Signed-off-by: Stephen Hemminger --- man/man8/ip-netns.8 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/man/man8/ip-netns.8 b/man/man8/ip-netns.8 index 39a10e76..961bcf03 100644 --- a/man/man8/ip-netns.8 +++ b/man/man8/ip-netns.8 @@ -31,6 +31,9 @@ ip-netns \- process network namespace management .B ip netns set .I NETNSNAME NETNSID +.ti -8 +.IR NETNSID " := " auto " | " POSITIVE-INT + .ti -8 .BR "ip netns identify" .RI "[ " PID " ]" From 6ed2915f9cc851c9e7876f7c58193b9ad8dac85a Mon Sep 17 00:00:00 2001 From: Nicolas Dichtel Date: Wed, 16 Oct 2019 17:00:52 +0200 Subject: [PATCH 9/9] ip-netns.8: document target-nsid and nsid options of list-id This is a follow up of the commit eaefb07804a1 ("ipnetns: enable to dump nsid conversion table"). Signed-off-by: Nicolas Dichtel Signed-off-by: Stephen Hemminger --- man/man8/ip-netns.8 | 48 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 2 deletions(-) diff --git a/man/man8/ip-netns.8 b/man/man8/ip-netns.8 index 961bcf03..c75917da 100644 --- a/man/man8/ip-netns.8 +++ b/man/man8/ip-netns.8 @@ -51,6 +51,7 @@ ip-netns \- process network namespace management .ti -8 .BR "ip netns list-id" +.RI "[ target-nsid " POSITIVE-INT " ] [ nsid " POSITIVE-INT " ]" .SH DESCRIPTION A network namespace is logically another copy of the network stack, @@ -196,12 +197,28 @@ This command watches network namespace name addition and deletion events and prints a line for each event it sees. .TP -.B ip netns list-id - list network namespace ids (nsid) +.B ip netns list-id [target-nsid POSITIVE-INT] [nsid POSITIVE-INT] - list network namespace ids (nsid) .sp Network namespace ids are used to identify a peer network namespace. This -command displays nsid of the current network namespace and provides the +command displays nsids of the current network namespace and provides the corresponding iproute2 netns name (from /var/run/netns) if any. +The +.B target-nsid +option enables to display nsids of the specified network namespace instead of the current network +namespace. This +.B target-nsid +is a nsid from the current network namespace. + +The +.B nsid +option enables to display only this nsid. It is a nsid from the current network namespace. In +combination with the +.B target-nsid +option, it enables to convert a specific nsid from the current network namespace to a nsid of the +.B target-nsid +network namespace. + .SH EXAMPLES .PP ip netns list @@ -218,6 +235,31 @@ ip netns exec vpn ip link set lo up .RS Bring up the loopback interface in the vpn network namespace. .RE +.PP +ip netns add foo +.br +ip netns add bar +.br +ip netns set foo 12 +.br +ip netns set bar 13 +.br +ip -n foo netns set foo 22 +.br +ip -n foo netns set bar 23 +.br +ip -n bar netns set foo 32 +.br +ip -n bar netns set bar 33 +.br +ip netns list-id target-nsid 12 +.RS +Shows the list of nsids from the network namespace foo. +.RE +ip netns list-id target-nsid 12 nsid 13 +.RS +Get nsid of bar from the network namespace foo (result is 23). +.RE .SH SEE ALSO .br @@ -225,3 +267,5 @@ Bring up the loopback interface in the vpn network namespace. .SH AUTHOR Original Manpage by Eric W. Biederman +.br +Manpage revised by Nicolas Dichtel