diff mbox series

monitor: Print rmnet flags

Message ID 20240823160901.474421-1-denkenz@gmail.com (mailing list archive)
State New
Headers show
Series monitor: Print rmnet flags | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
prestwoj/iwd-alpine-ci-fetch success Fetch PR
prestwoj/iwd-ci-gitlint success GitLint
prestwoj/iwd-ci-fetch success Fetch PR
prestwoj/iwd-alpine-ci-setupell success Prep - Setup ELL
prestwoj/iwd-ci-setupell success Prep - Setup ELL
prestwoj/iwd-ci-makedistcheck success Make Distcheck
prestwoj/iwd-ci-incremental_build success Incremental build not run PASS
prestwoj/iwd-alpine-ci-makedistcheck success Make Distcheck
prestwoj/iwd-alpine-ci-incremental_build success Incremental build not run PASS
prestwoj/iwd-ci-build success Build - Configure
prestwoj/iwd-alpine-ci-build success Build - Configure
prestwoj/iwd-ci-makecheck success Make Check
prestwoj/iwd-ci-makecheckvalgrind success Make Check w/Valgrind
prestwoj/iwd-ci-clang success clang PASS
prestwoj/iwd-alpine-ci-makecheckvalgrind success Make Check w/Valgrind
prestwoj/iwd-alpine-ci-makecheck success Make Check
prestwoj/iwd-ci-testrunner success test-runner PASS

Commit Message

Denis Kenzior Aug. 23, 2024, 4:08 p.m. UTC
---
 monitor/nlmon.c | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

Comments

James Prestwood Aug. 23, 2024, 5:19 p.m. UTC | #1
Hi Denis,

On 8/23/24 9:08 AM, Denis Kenzior wrote:
> ---
>   monitor/nlmon.c | 36 ++++++++++++++++++++++++++++++++++++
>   1 file changed, 36 insertions(+)
>
> diff --git a/monitor/nlmon.c b/monitor/nlmon.c
> index 214246ea72c2..fdf16fbe7a04 100644
> --- a/monitor/nlmon.c
> +++ b/monitor/nlmon.c
> @@ -37,6 +37,7 @@
>   #include <linux/if.h>
>   #include <linux/if_packet.h>
>   #include <linux/if_ether.h>
> +#include <linux/if_link.h>
>   #include <linux/netlink.h>
>   #include <linux/genetlink.h>
>   #include <linux/rtnetlink.h>
> @@ -7597,8 +7598,43 @@ static void flags_str(const struct flag_names *table,
>   	pos += sprintf(str + pos, "]");
>   }
>   
> +static void print_rmnet_flags(unsigned int indent,
> +					const char *label, uint32_t flags)
> +{
> +	if (flags & RMNET_FLAGS_INGRESS_DEAGGREGATION)
> +		print_attr(indent, "%s:%s", label, "deaggregation");
> +	if (flags & RMNET_FLAGS_INGRESS_MAP_COMMANDS)
> +		print_attr(indent, "%s:%s", label, "map commands");
> +	if (flags & RMNET_FLAGS_INGRESS_MAP_CKSUMV4)
> +		print_attr(indent, "%s:%s", label, "ingress_mapv4");
> +	if (flags & RMNET_FLAGS_EGRESS_MAP_CKSUMV4)
> +		print_attr(indent, "%s:%s", label, "egress_mapv4");
> +	if (flags & RMNET_FLAGS_INGRESS_MAP_CKSUMV5)
> +		print_attr(indent, "%s:%s", label, "ingress_mapv5");
> +	if (flags & RMNET_FLAGS_EGRESS_MAP_CKSUMV5)
> +		print_attr(indent, "%s:%s", label, "egress_mapv5");
> +}
> +
> +static void print_ifla_rmnet_flags(unsigned int indent, const char *str,
> +						const void *buf, uint16_t size)
> +{
> +	struct ifla_rmnet_flags flags;
> +
> +	if (size != 8) {
> +		printf("malformed packet\n");
> +		return;
> +	}
> +
> +	memcpy(&flags, buf, size);
> +
> +	print_rmnet_flags(indent + 1, "Flags", flags.flags);
> +	print_rmnet_flags(indent + 1, "Mask", flags.mask);
> +}
> +
>   static struct attr_entry link_info_data_entry[] = {
>   	{ IFLA_RMNET_MUX_ID,	"RMNet Mux Id",		ATTR_U16 },
> +	{ IFLA_RMNET_FLAGS,	"RMNet Flags",		ATTR_CUSTOM,
> +					{ .function = print_ifla_rmnet_flags } },
>   	{ },
>   };
>   
LGTM
Denis Kenzior Aug. 23, 2024, 5:31 p.m. UTC | #2
On 8/23/24 11:08 AM, Denis Kenzior wrote:
> ---
>   monitor/nlmon.c | 36 ++++++++++++++++++++++++++++++++++++
>   1 file changed, 36 insertions(+)
> 

Applied
diff mbox series

Patch

diff --git a/monitor/nlmon.c b/monitor/nlmon.c
index 214246ea72c2..fdf16fbe7a04 100644
--- a/monitor/nlmon.c
+++ b/monitor/nlmon.c
@@ -37,6 +37,7 @@ 
 #include <linux/if.h>
 #include <linux/if_packet.h>
 #include <linux/if_ether.h>
+#include <linux/if_link.h>
 #include <linux/netlink.h>
 #include <linux/genetlink.h>
 #include <linux/rtnetlink.h>
@@ -7597,8 +7598,43 @@  static void flags_str(const struct flag_names *table,
 	pos += sprintf(str + pos, "]");
 }
 
+static void print_rmnet_flags(unsigned int indent,
+					const char *label, uint32_t flags)
+{
+	if (flags & RMNET_FLAGS_INGRESS_DEAGGREGATION)
+		print_attr(indent, "%s:%s", label, "deaggregation");
+	if (flags & RMNET_FLAGS_INGRESS_MAP_COMMANDS)
+		print_attr(indent, "%s:%s", label, "map commands");
+	if (flags & RMNET_FLAGS_INGRESS_MAP_CKSUMV4)
+		print_attr(indent, "%s:%s", label, "ingress_mapv4");
+	if (flags & RMNET_FLAGS_EGRESS_MAP_CKSUMV4)
+		print_attr(indent, "%s:%s", label, "egress_mapv4");
+	if (flags & RMNET_FLAGS_INGRESS_MAP_CKSUMV5)
+		print_attr(indent, "%s:%s", label, "ingress_mapv5");
+	if (flags & RMNET_FLAGS_EGRESS_MAP_CKSUMV5)
+		print_attr(indent, "%s:%s", label, "egress_mapv5");
+}
+
+static void print_ifla_rmnet_flags(unsigned int indent, const char *str,
+						const void *buf, uint16_t size)
+{
+	struct ifla_rmnet_flags flags;
+
+	if (size != 8) {
+		printf("malformed packet\n");
+		return;
+	}
+
+	memcpy(&flags, buf, size);
+
+	print_rmnet_flags(indent + 1, "Flags", flags.flags);
+	print_rmnet_flags(indent + 1, "Mask", flags.mask);
+}
+
 static struct attr_entry link_info_data_entry[] = {
 	{ IFLA_RMNET_MUX_ID,	"RMNet Mux Id",		ATTR_U16 },
+	{ IFLA_RMNET_FLAGS,	"RMNet Flags",		ATTR_CUSTOM,
+					{ .function = print_ifla_rmnet_flags } },
 	{ },
 };