Netdev List
 help / color / mirror / Atom feed
From: David Ahern <dsahern@kernel.org>
To: Fernando Fernandez Mancera <fmancera@suse.de>, netdev@vger.kernel.org
Cc: stephen@networkplumber.org, davem@davemloft.net,
	edumazet@google.com, kuba@kernel.org, pabeni@redhat.com,
	horms@kernel.org
Subject: Re: [PATCH iproute-next v3] ipaddress: add support for showing IPv4 devconf attributes
Date: Sun, 28 Jun 2026 11:30:39 -0600	[thread overview]
Message-ID: <6b9df322-718e-4515-a944-48122ed8574c@kernel.org> (raw)
In-Reply-To: <20260614182515.8765-1-fmancera@suse.de>

On 6/14/26 12:25 PM, Fernando Fernandez Mancera wrote:
> This patch introduces support for showing IPv4 devconf attributes on
> detailed output of an interface e.g "ip -d link show dev enp1s0".
> 
> Additionally, this refactors 'print_af_spec()' to sequentially process
> both AF_INET and AF_INET6 attributes rather than returning early if
> AF_INET6 is missing.

refactors should be a separate patch.

> 
> Signed-off-by: Fernando Fernandez Mancera <fmancera@suse.de>
> ---
> v2: changed print_string to print_bool for boolean attributes
> v3: use print_bool for JSON output only
> ---
>  ip/ipaddress.c | 313 ++++++++++++++++++++++++++++++++++++++++++-------
>  1 file changed, 273 insertions(+), 40 deletions(-)
> 
> diff --git a/ip/ipaddress.c b/ip/ipaddress.c
> index 6017bc83..1530b836 100644
> --- a/ip/ipaddress.c
> +++ b/ip/ipaddress.c
> @@ -23,6 +23,7 @@
>  #include <linux/netdevice.h>
>  #include <linux/if_arp.h>
>  #include <linux/if_infiniband.h>
> +#include <linux/ip.h>
>  #include <linux/sockios.h>
>  #include <linux/net_namespace.h>
>  
> @@ -294,53 +295,285 @@ static void print_linktype(FILE *fp, struct rtattr *tb)
>  	close_json_object();
>  }
>  
> +static void print_inet(FILE *fp, struct rtattr *inet_attr)
> +{
> +	struct rtattr *tb[IFLA_INET_MAX + 1];
> +
> +	parse_rtattr_nested(tb, IFLA_INET_MAX, inet_attr);
> +
> +	if (tb[IFLA_INET_CONF]) {
> +		int *conf = RTA_DATA(tb[IFLA_INET_CONF]);
> +		int max_elements = RTA_PAYLOAD(tb[IFLA_INET_CONF]) / sizeof(int);
> +
> +		if (max_elements >= IPV4_DEVCONF_FORWARDING) {
> +			print_bool(PRINT_JSON, "forwarding", NULL,
> +				   conf[IPV4_DEVCONF_FORWARDING - 1]);
> +			print_string(PRINT_FP, "forwarding", "forwarding %s ",
> +				     conf[IPV4_DEVCONF_FORWARDING - 1] ? "on" : "off");
> +		}
> +
> +		if (max_elements >= IPV4_DEVCONF_MC_FORWARDING) {
> +			print_bool(PRINT_JSON, "mc_forwarding", NULL,
> +				   conf[IPV4_DEVCONF_MC_FORWARDING - 1]);
> +			print_string(PRINT_FP, "mc_forwarding", "mc_forwarding %s ",
> +				     conf[IPV4_DEVCONF_MC_FORWARDING - 1] ? "on" : "off");
> +		}
> +
> +		if (max_elements >= IPV4_DEVCONF_PROXY_ARP) {
> +			print_bool(PRINT_JSON, "proxy_arp", NULL,
> +				   conf[IPV4_DEVCONF_PROXY_ARP - 1]);
> +			print_string(PRINT_FP, "proxy_arp", "proxy_arp %s ",
> +				     conf[IPV4_DEVCONF_PROXY_ARP - 1] ? "on" : "off");
> +		}
> +
> +		if (max_elements >= IPV4_DEVCONF_ACCEPT_REDIRECTS) {
> +			print_bool(PRINT_JSON, "accept_redirects", NULL,
> +				   conf[IPV4_DEVCONF_ACCEPT_REDIRECTS - 1]);
> +			print_string(PRINT_FP, "accept_redirects",
> +				     "accept_redirects %s ",
> +				     conf[IPV4_DEVCONF_ACCEPT_REDIRECTS - 1] ? "on" : "off");

As I stated in the last patch for devconf:

"iproute2 follows netdev with coding standards and those need to be
followed as long as humans are in the loop. Please make sure follow on
patches adhere to roughly 80 columns with a little extra if it improves
readability (and of course strings are not broken across lines)."

Use print_on_off for example for these or use a temp variable for the
attributes.



      reply	other threads:[~2026-06-28 17:30 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-14 18:25 [PATCH iproute-next v3] ipaddress: add support for showing IPv4 devconf attributes Fernando Fernandez Mancera
2026-06-28 17:30 ` David Ahern [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6b9df322-718e-4515-a944-48122ed8574c@kernel.org \
    --to=dsahern@kernel.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=fmancera@suse.de \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=stephen@networkplumber.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox