public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: David Ahern <dsahern@kernel.org>
To: Mohsin Bashir <mohsin.bashr@gmail.com>, netdev@vger.kernel.org
Cc: stephen@networkplumber.org, pabeni@redhat.com, kuba@kernel.org,
	ernis@linux.microsoft.com
Subject: Re: [PATCH iproute2-next 1/5] netshaper: Extract parse_scope() and parse_rate() helpers
Date: Fri, 1 May 2026 11:47:40 -0600	[thread overview]
Message-ID: <1c2fb5a2-6756-4a76-91b3-f1ef578ba8a3@kernel.org> (raw)
In-Reply-To: <20260501011611.3533573-2-mohsin.bashr@gmail.com>

On 4/30/26 7:16 PM, Mohsin Bashir wrote:
> diff --git a/netshaper/netshaper.c b/netshaper/netshaper.c
> index 47fb805e..1603e6e5 100644
> --- a/netshaper/netshaper.c
> +++ b/netshaper/netshaper.c
> @@ -47,6 +47,28 @@ static const char *net_shaper_scope_names[NET_SHAPER_SCOPE_MAX + 1] = {
>  	"node"
>  };
>  
> +static int parse_scope(const char *str)
> +{
> +	if (strcmp(str, "netdev") == 0)
> +		return NET_SHAPER_SCOPE_NETDEV;
> +	if (strcmp(str, "queue") == 0)
> +		return NET_SHAPER_SCOPE_QUEUE;
> +	if (strcmp(str, "node") == 0)
> +		return NET_SHAPER_SCOPE_NODE;
> +	return -1;

net_shaper_scope_names exists. Create 1 table used for both parsing and
printing.

> +}
> +
> +static int parse_rate(const char *str, __u64 *rate_bps)
> +{
> +	if (get_rate64(rate_bps, str)) {
> +		fprintf(stderr, "Invalid rate value \"%s\"\n", str);
> +		return -1;
> +	}
> +	/* get_rate64 returns bytes/sec, convert to bits/sec */
> +	*rate_bps *= 8;

no magic numbers. Add a define for BITS_PER_BYTE to include/utils.h
above BIT()

  reply	other threads:[~2026-05-01 17:47 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-01  1:16 [PATCH iproute2-next 0/5] netshaper: Extend netshaper support Mohsin Bashir
2026-05-01  1:16 ` [PATCH iproute2-next 1/5] netshaper: Extract parse_scope() and parse_rate() helpers Mohsin Bashir
2026-05-01 17:47   ` David Ahern [this message]
2026-05-01  1:16 ` [PATCH iproute2-next 2/5] netshaper: Add bw-min and weight parameter support Mohsin Bashir
2026-05-01 17:50   ` David Ahern
2026-05-01  1:16 ` [PATCH iproute2-next 3/5] netshaper: Extend show output with parent, bw-min and weight Mohsin Bashir
2026-05-01  1:16 ` [PATCH iproute2-next 4/5] netshaper: Make handle id optional for node scope Mohsin Bashir
2026-05-01  1:16 ` [PATCH iproute2-next 5/5] netshaper: Add group command for creating scheduling hierarchies Mohsin Bashir
2026-05-01 15:17 ` [PATCH iproute2-next 0/5] netshaper: Extend netshaper support Stephen Hemminger
2026-05-01 21:13   ` Mohsin Bashir
2026-05-01 17:52 ` David Ahern

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=1c2fb5a2-6756-4a76-91b3-f1ef578ba8a3@kernel.org \
    --to=dsahern@kernel.org \
    --cc=ernis@linux.microsoft.com \
    --cc=kuba@kernel.org \
    --cc=mohsin.bashr@gmail.com \
    --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