[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v3 2/2] procfs: Populate /proc/route with network routes
From: |
Samuel Thibault |
Subject: |
Re: [PATCH v3 2/2] procfs: Populate /proc/route with network routes |
Date: |
Sun, 11 Sep 2022 19:18:02 +0200 |
User-agent: |
NeoMutt/20170609 (1.8.3) |
Hello,
Damien Zammit, le ven. 09 sept. 2022 09:43:01 +0000, a ecrit:
> This requires the new client side <net/route.h> to be installed.
I'm not sure to understand what you mean. The installed <net/route.h>
comes from the glibc package, not the hurd package.
> diff --git a/procfs/rootdir.c b/procfs/rootdir.c
> index 0e7c05c0..813e75f1 100644
> --- a/procfs/rootdir.c
> +++ b/procfs/rootdir.c
> @@ -37,8 +38,13 @@
> #include "procfs.h"
> #include "procfs_dir.h"
> #include "main.h"
> +#include <net/route.h>
>
> #include "mach_debug_U.h"
> +#define SOCKET_INET_STRLEN 20
I don't think you need to define a macro for that.
>
> /* This implements a directory node with the static files in /proc.
> NB: the libps functions for host information return static storage;
> @@ -408,6 +414,71 @@ out:
> return err;
> }
>
> +static error_t
> +rootdir_gc_route (void *hook, char **contents, ssize_t *contents_len)
> +{
> + error_t err;
> + mach_port_t pfinet;
> + unsigned int i, len, buflen = 0;
> + char *src, *dst;
> + ifrtreq_t *r;
> + char dest[INET_ADDRSTRLEN], gw[INET_ADDRSTRLEN], mask[INET_ADDRSTRLEN];
> + char socket_inet[SOCKET_INET_STRLEN] = {0};
You can set 20 here
> +
> + char *inet_to_str(in_addr_t addr)
> + {
> + struct in_addr sin;
> +
> + sin.s_addr = addr;
> + return inet_ntoa(sin);
> + }
> +
> + snprintf(socket_inet, SOCKET_INET_STRLEN, _SERVERS_SOCKET "/%d", AF_INET);
and use sizeof there.
Also, there is no need to explicitly initialize socket_inet, snprintf
will fill it anyway.
Samuel