* [PATCH iproute2-next 0/3] multicast event support for ioam6
@ 2024-02-22 15:45 Justin Iurman
2024-02-22 15:45 ` [PATCH iproute2-next 1/3] uapi: ioam6: update uapi based on net-next Justin Iurman
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Justin Iurman @ 2024-02-22 15:45 UTC (permalink / raw)
To: netdev; +Cc: dsahern, justin.iurman
Add support for ioam multicast events via a new command: ip ioam
monitor.
Justin Iurman (3):
uapi: ioam6: update uapi based on net-next
ip: ioam6: add monitor command
man8: ioam: add doc for monitor command
include/uapi/linux/ioam6_genl.h | 20 +++++++++
ip/ipioam6.c | 78 ++++++++++++++++++++++++++++++++-
man/man8/ip-ioam.8 | 5 +++
3 files changed, 102 insertions(+), 1 deletion(-)
base-commit: d2f1c3c9a8a38493cdec9fb93534ccec76c48fe2
--
2.34.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH iproute2-next 1/3] uapi: ioam6: update uapi based on net-next
2024-02-22 15:45 [PATCH iproute2-next 0/3] multicast event support for ioam6 Justin Iurman
@ 2024-02-22 15:45 ` Justin Iurman
2024-02-22 15:45 ` [PATCH iproute2-next 2/3] ip: ioam6: add monitor command Justin Iurman
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Justin Iurman @ 2024-02-22 15:45 UTC (permalink / raw)
To: netdev; +Cc: dsahern, justin.iurman
Update the iproute2 uapi for ioam6 based on net-next uapi.
Signed-off-by: Justin Iurman <justin.iurman@uliege.be>
---
include/uapi/linux/ioam6_genl.h | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/include/uapi/linux/ioam6_genl.h b/include/uapi/linux/ioam6_genl.h
index 6043d9f6..3f89b530 100644
--- a/include/uapi/linux/ioam6_genl.h
+++ b/include/uapi/linux/ioam6_genl.h
@@ -49,4 +49,24 @@ enum {
#define IOAM6_CMD_MAX (__IOAM6_CMD_MAX - 1)
+#define IOAM6_GENL_EV_GRP_NAME "ioam6_events"
+
+enum ioam6_event_type {
+ IOAM6_EVENT_UNSPEC,
+ IOAM6_EVENT_TRACE,
+};
+
+enum ioam6_event_attr {
+ IOAM6_EVENT_ATTR_UNSPEC,
+
+ IOAM6_EVENT_ATTR_TRACE_NAMESPACE, /* u16 */
+ IOAM6_EVENT_ATTR_TRACE_NODELEN, /* u8 */
+ IOAM6_EVENT_ATTR_TRACE_TYPE, /* u32 */
+ IOAM6_EVENT_ATTR_TRACE_DATA, /* Binary */
+
+ __IOAM6_EVENT_ATTR_MAX
+};
+
+#define IOAM6_EVENT_ATTR_MAX (__IOAM6_EVENT_ATTR_MAX - 1)
+
#endif /* _LINUX_IOAM6_GENL_H */
--
2.34.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH iproute2-next 2/3] ip: ioam6: add monitor command
2024-02-22 15:45 [PATCH iproute2-next 0/3] multicast event support for ioam6 Justin Iurman
2024-02-22 15:45 ` [PATCH iproute2-next 1/3] uapi: ioam6: update uapi based on net-next Justin Iurman
@ 2024-02-22 15:45 ` Justin Iurman
2024-02-22 15:45 ` [PATCH iproute2-next 3/3] man8: ioam: add doc for " Justin Iurman
2024-03-03 22:40 ` [PATCH iproute2-next 0/3] multicast event support for ioam6 patchwork-bot+netdevbpf
3 siblings, 0 replies; 5+ messages in thread
From: Justin Iurman @ 2024-02-22 15:45 UTC (permalink / raw)
To: netdev; +Cc: dsahern, justin.iurman
Add the "ip ioam monitor" command to be able to read all IOAM data
received. This is based on a netlink multicast group.
Signed-off-by: Justin Iurman <justin.iurman@uliege.be>
---
ip/ipioam6.c | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 77 insertions(+), 1 deletion(-)
diff --git a/ip/ipioam6.c b/ip/ipioam6.c
index b63d7d5c..18860989 100644
--- a/ip/ipioam6.c
+++ b/ip/ipioam6.c
@@ -13,6 +13,7 @@
#include <inttypes.h>
#include <linux/genetlink.h>
+#include <linux/ioam6.h>
#include <linux/ioam6_genl.h>
#include "utils.h"
@@ -30,7 +31,8 @@ static void usage(void)
" ip ioam schema show\n"
" ip ioam schema add ID DATA\n"
" ip ioam schema del ID\n"
- " ip ioam namespace set ID schema { ID | none }\n");
+ " ip ioam namespace set ID schema { ID | none }\n"
+ " ip ioam monitor\n");
exit(-1);
}
@@ -42,6 +44,7 @@ static int genl_family = -1;
IOAM6_GENL_VERSION, _cmd, _flags)
static struct {
+ bool monitor;
unsigned int cmd;
__u32 sc_id;
__u32 ns_data;
@@ -96,6 +99,37 @@ static void print_schema(struct rtattr *attrs[])
print_nl();
}
+static void print_trace(struct rtattr *attrs[])
+{
+ __u8 data[IOAM6_TRACE_DATA_SIZE_MAX];
+ int len, i = 0;
+
+ printf("[TRACE] ");
+
+ if (attrs[IOAM6_EVENT_ATTR_TRACE_NAMESPACE])
+ printf("Namespace=%u ",
+ rta_getattr_u16(attrs[IOAM6_EVENT_ATTR_TRACE_NAMESPACE]));
+
+ if (attrs[IOAM6_EVENT_ATTR_TRACE_NODELEN])
+ printf("NodeLen=%u ",
+ rta_getattr_u8(attrs[IOAM6_EVENT_ATTR_TRACE_NODELEN]));
+
+ if (attrs[IOAM6_EVENT_ATTR_TRACE_TYPE])
+ printf("Type=%#08x ",
+ rta_getattr_u32(attrs[IOAM6_EVENT_ATTR_TRACE_TYPE]));
+
+ len = RTA_PAYLOAD(attrs[IOAM6_EVENT_ATTR_TRACE_DATA]);
+ memcpy(data, RTA_DATA(attrs[IOAM6_EVENT_ATTR_TRACE_DATA]), len);
+
+ printf("Data=");
+ while (i < len) {
+ printf("%02x", data[i]);
+ i++;
+ }
+
+ printf("\n");
+}
+
static int process_msg(struct nlmsghdr *n, void *arg)
{
struct rtattr *attrs[IOAM6_ATTR_MAX + 1];
@@ -126,6 +160,32 @@ static int process_msg(struct nlmsghdr *n, void *arg)
return 0;
}
+static int ioam6_monitor_msg(struct rtnl_ctrl_data *ctrl, struct nlmsghdr *n,
+ void *arg)
+{
+ struct rtattr *attrs[IOAM6_EVENT_ATTR_MAX + 1];
+ const struct genlmsghdr *ghdr = NLMSG_DATA(n);
+ int len = n->nlmsg_len;
+
+ if (n->nlmsg_type != genl_family)
+ return -1;
+
+ len -= NLMSG_LENGTH(GENL_HDRLEN);
+ if (len < 0)
+ return -1;
+
+ parse_rtattr(attrs, IOAM6_EVENT_ATTR_MAX,
+ (void *)ghdr + GENL_HDRLEN, len);
+
+ switch (ghdr->cmd) {
+ case IOAM6_EVENT_TRACE:
+ print_trace(attrs);
+ break;
+ }
+
+ return 0;
+}
+
static int ioam6_do_cmd(void)
{
IOAM6_REQUEST(req, 1056, opts.cmd, NLM_F_REQUEST);
@@ -134,6 +194,19 @@ static int ioam6_do_cmd(void)
if (genl_init_handle(&grth, IOAM6_GENL_NAME, &genl_family))
exit(1);
+ if (opts.monitor) {
+ if (genl_add_mcast_grp(&grth, genl_family,
+ IOAM6_GENL_EV_GRP_NAME) < 0) {
+ perror("can't subscribe to ioam6 events");
+ exit(1);
+ }
+
+ if (rtnl_listen(&grth, ioam6_monitor_msg, stdout) < 0)
+ exit(1);
+
+ return 0;
+ }
+
req.n.nlmsg_type = genl_family;
switch (opts.cmd) {
@@ -325,6 +398,9 @@ int do_ioam6(int argc, char **argv)
invarg("Unknown", *argv);
}
+ } else if (strcmp(*argv, "monitor") == 0) {
+ opts.monitor = true;
+
} else {
invarg("Unknown", *argv);
}
--
2.34.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH iproute2-next 3/3] man8: ioam: add doc for monitor command
2024-02-22 15:45 [PATCH iproute2-next 0/3] multicast event support for ioam6 Justin Iurman
2024-02-22 15:45 ` [PATCH iproute2-next 1/3] uapi: ioam6: update uapi based on net-next Justin Iurman
2024-02-22 15:45 ` [PATCH iproute2-next 2/3] ip: ioam6: add monitor command Justin Iurman
@ 2024-02-22 15:45 ` Justin Iurman
2024-03-03 22:40 ` [PATCH iproute2-next 0/3] multicast event support for ioam6 patchwork-bot+netdevbpf
3 siblings, 0 replies; 5+ messages in thread
From: Justin Iurman @ 2024-02-22 15:45 UTC (permalink / raw)
To: netdev; +Cc: dsahern, justin.iurman
Add a sentence in the doc to describe what the new "monitor" command
does.
Signed-off-by: Justin Iurman <justin.iurman@uliege.be>
---
man/man8/ip-ioam.8 | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/man/man8/ip-ioam.8 b/man/man8/ip-ioam.8
index 1bdc0ece..c723d782 100644
--- a/man/man8/ip-ioam.8
+++ b/man/man8/ip-ioam.8
@@ -49,12 +49,17 @@ ip-ioam \- IPv6 In-situ OAM (IOAM)
.RI " { " ID " | "
.BR none " }"
+.ti -8
+.B ip ioam monitor
+
.SH DESCRIPTION
The \fBip ioam\fR command is used to configure IPv6 In-situ OAM (IOAM6)
internal parameters, namely IOAM namespaces and schemas.
.PP
Those parameters also include the mapping between an IOAM namespace and an IOAM
schema.
+.PP
+The \fBip ioam monitor\fR command displays IOAM data received.
.SH EXAMPLES
.PP
--
2.34.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH iproute2-next 0/3] multicast event support for ioam6
2024-02-22 15:45 [PATCH iproute2-next 0/3] multicast event support for ioam6 Justin Iurman
` (2 preceding siblings ...)
2024-02-22 15:45 ` [PATCH iproute2-next 3/3] man8: ioam: add doc for " Justin Iurman
@ 2024-03-03 22:40 ` patchwork-bot+netdevbpf
3 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-03-03 22:40 UTC (permalink / raw)
To: Justin Iurman; +Cc: netdev, dsahern
Hello:
This series was applied to iproute2/iproute2-next.git (main)
by David Ahern <dsahern@kernel.org>:
On Thu, 22 Feb 2024 16:45:36 +0100 you wrote:
> Add support for ioam multicast events via a new command: ip ioam
> monitor.
>
> Justin Iurman (3):
> uapi: ioam6: update uapi based on net-next
> ip: ioam6: add monitor command
> man8: ioam: add doc for monitor command
>
> [...]
Here is the summary with links:
- [iproute2-next,1/3] uapi: ioam6: update uapi based on net-next
(no matching commit)
- [iproute2-next,2/3] ip: ioam6: add monitor command
https://git.kernel.org/pub/scm/network/iproute2/iproute2-next.git/commit/?id=ae5c6f9b0391
- [iproute2-next,3/3] man8: ioam: add doc for monitor command
https://git.kernel.org/pub/scm/network/iproute2/iproute2-next.git/commit/?id=94107bba2456
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-03-03 22:40 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-22 15:45 [PATCH iproute2-next 0/3] multicast event support for ioam6 Justin Iurman
2024-02-22 15:45 ` [PATCH iproute2-next 1/3] uapi: ioam6: update uapi based on net-next Justin Iurman
2024-02-22 15:45 ` [PATCH iproute2-next 2/3] ip: ioam6: add monitor command Justin Iurman
2024-02-22 15:45 ` [PATCH iproute2-next 3/3] man8: ioam: add doc for " Justin Iurman
2024-03-03 22:40 ` [PATCH iproute2-next 0/3] multicast event support for ioam6 patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).