* [PATCH net-next v4 0/3] ioam6: netlink multicast event
@ 2024-02-23 14:41 Justin Iurman
2024-02-23 14:41 ` [PATCH net-next v4 1/3] uapi: ioam6: API for netlink multicast events Justin Iurman
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: Justin Iurman @ 2024-02-23 14:41 UTC (permalink / raw)
To: netdev; +Cc: davem, dsahern, edumazet, kuba, pabeni, linux-kernel,
justin.iurman
v4:
- rebase on top of net merge
v3:
- patchset was mistakenly superseded due to same cover title used for
iproute2-next equivalent patch -> resend (renamed)
v2:
- fix warnings
Add generic netlink multicast event support to ioam6 as another solution
to share IOAM data with user space. The other one being via IPv6 raw
sockets combined with ancillary data. This patchset focuses on the IOAM
Pre-allocated Trace (the only Option-Type currently supported), and so
on IOAM "trace" events. See an example of a consumer here [1].
[1] https://github.com/Advanced-Observability/ioam-agent-python/blob/netlink_event/ioam-agent.py
Justin Iurman (3):
uapi: ioam6: API for netlink multicast events
net: ioam6: multicast event
net: exthdrs: ioam6: send trace event
include/net/ioam6.h | 4 +++
include/uapi/linux/ioam6_genl.h | 20 +++++++++++
net/ipv6/exthdrs.c | 6 ++++
net/ipv6/ioam6.c | 64 +++++++++++++++++++++++++++++++++
4 files changed, 94 insertions(+)
base-commit: a818bd12538c1408c7480de31573cdb3c3c0926f
--
2.34.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH net-next v4 1/3] uapi: ioam6: API for netlink multicast events
2024-02-23 14:41 [PATCH net-next v4 0/3] ioam6: netlink multicast event Justin Iurman
@ 2024-02-23 14:41 ` Justin Iurman
2024-02-23 14:41 ` [PATCH net-next v4 2/3] net: ioam6: multicast event Justin Iurman
` (2 subsequent siblings)
3 siblings, 0 replies; 6+ messages in thread
From: Justin Iurman @ 2024-02-23 14:41 UTC (permalink / raw)
To: netdev; +Cc: davem, dsahern, edumazet, kuba, pabeni, linux-kernel,
justin.iurman
Add new api to support ioam6 events for generic netlink multicast. A
first "trace" event is added to the list of ioam6 events, which will
represent an IOAM Pre-allocated (or Incremental) Trace Option-Type. It
provides another solution to share IOAM data with user space.
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 ca4b22833754..1733fbc51fb5 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 /* _UAPI_LINUX_IOAM6_GENL_H */
--
2.34.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH net-next v4 2/3] net: ioam6: multicast event
2024-02-23 14:41 [PATCH net-next v4 0/3] ioam6: netlink multicast event Justin Iurman
2024-02-23 14:41 ` [PATCH net-next v4 1/3] uapi: ioam6: API for netlink multicast events Justin Iurman
@ 2024-02-23 14:41 ` Justin Iurman
2024-02-23 14:41 ` [PATCH net-next v4 3/3] net: exthdrs: ioam6: send trace event Justin Iurman
2024-02-23 16:50 ` [PATCH net-next v4 0/3] ioam6: netlink multicast event David Ahern
3 siblings, 0 replies; 6+ messages in thread
From: Justin Iurman @ 2024-02-23 14:41 UTC (permalink / raw)
To: netdev; +Cc: davem, dsahern, edumazet, kuba, pabeni, linux-kernel,
justin.iurman
Add a multicast group to the ioam6 generic netlink family and provide
ioam6_event() to send an ioam6 event to the multicast group.
Signed-off-by: Justin Iurman <justin.iurman@uliege.be>
---
include/net/ioam6.h | 4 +++
net/ipv6/ioam6.c | 64 +++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 68 insertions(+)
diff --git a/include/net/ioam6.h b/include/net/ioam6.h
index 781d2d8b2f29..2cbbee6e806a 100644
--- a/include/net/ioam6.h
+++ b/include/net/ioam6.h
@@ -12,6 +12,7 @@
#include <linux/net.h>
#include <linux/ipv6.h>
#include <linux/ioam6.h>
+#include <linux/ioam6_genl.h>
#include <linux/rhashtable-types.h>
struct ioam6_namespace {
@@ -65,4 +66,7 @@ void ioam6_exit(void);
int ioam6_iptunnel_init(void);
void ioam6_iptunnel_exit(void);
+void ioam6_event(enum ioam6_event_type type, struct net *net, gfp_t gfp,
+ void *opt, unsigned int opt_len);
+
#endif /* _NET_IOAM6_H */
diff --git a/net/ipv6/ioam6.c b/net/ipv6/ioam6.c
index 571f0e4d9cf3..5fa923f06632 100644
--- a/net/ipv6/ioam6.c
+++ b/net/ipv6/ioam6.c
@@ -612,6 +612,68 @@ static const struct genl_ops ioam6_genl_ops[] = {
},
};
+#define IOAM6_GENL_EV_GRP_OFFSET 0
+
+static const struct genl_multicast_group ioam6_mcgrps[] = {
+ [IOAM6_GENL_EV_GRP_OFFSET] = { .name = IOAM6_GENL_EV_GRP_NAME,
+ .flags = GENL_MCAST_CAP_NET_ADMIN },
+};
+
+static int ioam6_event_put_trace(struct sk_buff *skb,
+ struct ioam6_trace_hdr *trace,
+ unsigned int len)
+{
+ if (nla_put_u16(skb, IOAM6_EVENT_ATTR_TRACE_NAMESPACE,
+ be16_to_cpu(trace->namespace_id)) ||
+ nla_put_u8(skb, IOAM6_EVENT_ATTR_TRACE_NODELEN, trace->nodelen) ||
+ nla_put_u32(skb, IOAM6_EVENT_ATTR_TRACE_TYPE,
+ be32_to_cpu(trace->type_be32)) ||
+ nla_put(skb, IOAM6_EVENT_ATTR_TRACE_DATA,
+ len - sizeof(struct ioam6_trace_hdr) - trace->remlen * 4,
+ trace->data + trace->remlen * 4))
+ return 1;
+
+ return 0;
+}
+
+void ioam6_event(enum ioam6_event_type type, struct net *net, gfp_t gfp,
+ void *opt, unsigned int opt_len)
+{
+ struct nlmsghdr *nlh;
+ struct sk_buff *skb;
+
+ if (!genl_has_listeners(&ioam6_genl_family, net,
+ IOAM6_GENL_EV_GRP_OFFSET))
+ return;
+
+ skb = nlmsg_new(NLMSG_DEFAULT_SIZE, gfp);
+ if (!skb)
+ return;
+
+ nlh = genlmsg_put(skb, 0, 0, &ioam6_genl_family, 0, type);
+ if (!nlh)
+ goto nla_put_failure;
+
+ switch (type) {
+ case IOAM6_EVENT_UNSPEC:
+ WARN_ON_ONCE(1);
+ break;
+ case IOAM6_EVENT_TRACE:
+ if (ioam6_event_put_trace(skb, (struct ioam6_trace_hdr *)opt,
+ opt_len))
+ goto nla_put_failure;
+ break;
+ }
+
+ genlmsg_end(skb, nlh);
+ genlmsg_multicast_netns(&ioam6_genl_family, net, skb, 0,
+ IOAM6_GENL_EV_GRP_OFFSET, gfp);
+ return;
+
+nla_put_failure:
+ nlmsg_free(skb);
+}
+
static struct genl_family ioam6_genl_family __ro_after_init = {
.name = IOAM6_GENL_NAME,
.version = IOAM6_GENL_VERSION,
@@ -620,6 +682,8 @@ static struct genl_family ioam6_genl_family __ro_after_init = {
.ops = ioam6_genl_ops,
.n_ops = ARRAY_SIZE(ioam6_genl_ops),
.resv_start_op = IOAM6_CMD_NS_SET_SCHEMA + 1,
+ .mcgrps = ioam6_mcgrps,
+ .n_mcgrps = ARRAY_SIZE(ioam6_mcgrps),
.module = THIS_MODULE,
};
--
2.34.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH net-next v4 3/3] net: exthdrs: ioam6: send trace event
2024-02-23 14:41 [PATCH net-next v4 0/3] ioam6: netlink multicast event Justin Iurman
2024-02-23 14:41 ` [PATCH net-next v4 1/3] uapi: ioam6: API for netlink multicast events Justin Iurman
2024-02-23 14:41 ` [PATCH net-next v4 2/3] net: ioam6: multicast event Justin Iurman
@ 2024-02-23 14:41 ` Justin Iurman
2024-02-23 18:20 ` Justin Iurman
2024-02-23 16:50 ` [PATCH net-next v4 0/3] ioam6: netlink multicast event David Ahern
3 siblings, 1 reply; 6+ messages in thread
From: Justin Iurman @ 2024-02-23 14:41 UTC (permalink / raw)
To: netdev; +Cc: davem, dsahern, edumazet, kuba, pabeni, linux-kernel,
justin.iurman
If we're processing an IOAM Pre-allocated Trace Option-Type (the only
one supported currently), and if we're the destination, then send the
trace as an ioam6 event to the multicast group. This way, user space
apps will be able to collect IOAM data (for a trace, it only makes sense
to send events if we're the destination).
Signed-off-by: Justin Iurman <justin.iurman@uliege.be>
---
net/ipv6/exthdrs.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/net/ipv6/exthdrs.c b/net/ipv6/exthdrs.c
index 02e9ffb63af1..003f35d9b42b 100644
--- a/net/ipv6/exthdrs.c
+++ b/net/ipv6/exthdrs.c
@@ -50,6 +50,7 @@
#endif
#include <net/rpl.h>
#include <linux/ioam6.h>
+#include <linux/ioam6_genl.h>
#include <net/ioam6.h>
#include <net/dst_metadata.h>
@@ -954,6 +955,11 @@ static bool ipv6_hop_ioam(struct sk_buff *skb, int optoff)
+ optoff + sizeof(*hdr));
ioam6_fill_trace_data(skb, ns, trace, true);
+
+ if (skb_dst(skb)->dev->flags & IFF_LOOPBACK)
+ ioam6_event(IOAM6_EVENT_TRACE, dev_net(skb->dev),
+ GFP_ATOMIC, (void *)trace,
+ hdr->opt_len - 2);
break;
default:
break;
--
2.34.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH net-next v4 0/3] ioam6: netlink multicast event
2024-02-23 14:41 [PATCH net-next v4 0/3] ioam6: netlink multicast event Justin Iurman
` (2 preceding siblings ...)
2024-02-23 14:41 ` [PATCH net-next v4 3/3] net: exthdrs: ioam6: send trace event Justin Iurman
@ 2024-02-23 16:50 ` David Ahern
3 siblings, 0 replies; 6+ messages in thread
From: David Ahern @ 2024-02-23 16:50 UTC (permalink / raw)
To: Justin Iurman, netdev; +Cc: davem, edumazet, kuba, pabeni, linux-kernel
On 2/23/24 7:41 AM, Justin Iurman wrote:
> v4:
> - rebase on top of net merge
> v3:
> - patchset was mistakenly superseded due to same cover title used for
> iproute2-next equivalent patch -> resend (renamed)
> v2:
> - fix warnings
>
> Add generic netlink multicast event support to ioam6 as another solution
> to share IOAM data with user space. The other one being via IPv6 raw
> sockets combined with ancillary data. This patchset focuses on the IOAM
> Pre-allocated Trace (the only Option-Type currently supported), and so
> on IOAM "trace" events. See an example of a consumer here [1].
>
> [1] https://github.com/Advanced-Observability/ioam-agent-python/blob/netlink_event/ioam-agent.py
>
> Justin Iurman (3):
> uapi: ioam6: API for netlink multicast events
> net: ioam6: multicast event
> net: exthdrs: ioam6: send trace event
>
> include/net/ioam6.h | 4 +++
> include/uapi/linux/ioam6_genl.h | 20 +++++++++++
> net/ipv6/exthdrs.c | 6 ++++
> net/ipv6/ioam6.c | 64 +++++++++++++++++++++++++++++++++
> 4 files changed, 94 insertions(+)
>
>
> base-commit: a818bd12538c1408c7480de31573cdb3c3c0926f
For the set:
Reviewed-by: David Ahern <dsahern@kernel.org>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net-next v4 3/3] net: exthdrs: ioam6: send trace event
2024-02-23 14:41 ` [PATCH net-next v4 3/3] net: exthdrs: ioam6: send trace event Justin Iurman
@ 2024-02-23 18:20 ` Justin Iurman
0 siblings, 0 replies; 6+ messages in thread
From: Justin Iurman @ 2024-02-23 18:20 UTC (permalink / raw)
To: netdev; +Cc: davem, dsahern, edumazet, kuba, pabeni, linux-kernel,
justin.iurman
On 2/23/24 15:41, Justin Iurman wrote:
> If we're processing an IOAM Pre-allocated Trace Option-Type (the only
> one supported currently), and if we're the destination, then send the
> trace as an ioam6 event to the multicast group. This way, user space
> apps will be able to collect IOAM data (for a trace, it only makes sense
> to send events if we're the destination).
>
> Signed-off-by: Justin Iurman <justin.iurman@uliege.be>
> ---
> net/ipv6/exthdrs.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/net/ipv6/exthdrs.c b/net/ipv6/exthdrs.c
> index 02e9ffb63af1..003f35d9b42b 100644
> --- a/net/ipv6/exthdrs.c
> +++ b/net/ipv6/exthdrs.c
> @@ -50,6 +50,7 @@
> #endif
> #include <net/rpl.h>
> #include <linux/ioam6.h>
> +#include <linux/ioam6_genl.h>
> #include <net/ioam6.h>
> #include <net/dst_metadata.h>
>
> @@ -954,6 +955,11 @@ static bool ipv6_hop_ioam(struct sk_buff *skb, int optoff)
> + optoff + sizeof(*hdr));
>
> ioam6_fill_trace_data(skb, ns, trace, true);
> +
> + if (skb_dst(skb)->dev->flags & IFF_LOOPBACK)
Hmm, now that I think about this a bit more, I'm not sure we should
force a node to be the destination in order to send the event. Instead,
we could just remove the "am I the destination" check and directly call
ioam6_event(), which does check if there is at least one listener before
sending the event. I see two reasons for the change: (a) one may want
(for whatever reason) to capture IOAM traces on transit nodes, or (b)
one may use inline (instead of encap) IOAM injection where the
destination may be outside the IOAM domain (i.e., destination !=
decap/egress IOAM node), which is not RFC8200-compliant and requires
removing the IOAM Option-Type in-flight from the HbH, but that's another
story.
Any opinion?
> + ioam6_event(IOAM6_EVENT_TRACE, dev_net(skb->dev),
> + GFP_ATOMIC, (void *)trace,
> + hdr->opt_len - 2);
> break;
> default:
> break;
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-02-23 18:20 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-23 14:41 [PATCH net-next v4 0/3] ioam6: netlink multicast event Justin Iurman
2024-02-23 14:41 ` [PATCH net-next v4 1/3] uapi: ioam6: API for netlink multicast events Justin Iurman
2024-02-23 14:41 ` [PATCH net-next v4 2/3] net: ioam6: multicast event Justin Iurman
2024-02-23 14:41 ` [PATCH net-next v4 3/3] net: exthdrs: ioam6: send trace event Justin Iurman
2024-02-23 18:20 ` Justin Iurman
2024-02-23 16:50 ` [PATCH net-next v4 0/3] ioam6: netlink multicast event David Ahern
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox